Huge list protection implemented

main
Inga 🏳‍🌈 15 years ago
parent 51127b659c
commit c5c2d9414b
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 6
      Core/DB/IDBConnection.cs
  4. 5
      MySQLConnector/Connection.cs

@ -8,7 +8,7 @@ namespace FLocal.Core.DB {
List<Dictionary<string, string>> LoadByIds(ITableSpec table, List<string> ids); List<Dictionary<string, string>> LoadByIds(ITableSpec table, List<string> ids);
List<string> LoadIdsByConditions(ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts); List<string> LoadIdsByConditions(ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists);
long GetCountByConditions(ITableSpec table, conditions.AbstractCondition conditions, JoinSpec[] joins); long GetCountByConditions(ITableSpec table, conditions.AbstractCondition conditions, JoinSpec[] joins);
@ -30,6 +30,10 @@ namespace FLocal.Core.DB {
public static class IDBConnectionExtensions { public static class IDBConnectionExtensions {
public static List<string> LoadIdsByConditions(this IDBConnection connection, ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts) {
return connection.LoadIdsByConditions(table, conditions, diapasone, joins, sorts, false);
}
public static List<string> LoadIdsByConditions(this IDBConnection connection, ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, params JoinSpec[] joins) { public static List<string> LoadIdsByConditions(this IDBConnection connection, ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, params JoinSpec[] joins) {
return connection.LoadIdsByConditions(table, conditions, diapasone, joins, new SortSpec[] { new SortSpec(table.getIdSpec(), true) }); return connection.LoadIdsByConditions(table, conditions, diapasone, joins, new SortSpec[] { new SortSpec(table.getIdSpec(), true) });
} }

@ -82,7 +82,7 @@ namespace FLocal.MySQLConnector {
} }
} }
public List<string> LoadIdsByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts) { public List<string> LoadIdsByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists) {
lock(this) { lock(this) {
using(DbCommand command = this.connection.CreateCommand()) { using(DbCommand command = this.connection.CreateCommand()) {
@ -132,6 +132,9 @@ namespace FLocal.MySQLConnector {
return new List<string>(); return new List<string>();
} else { } else {
diapasone.total = count; diapasone.total = count;
if(diapasone.total > 1000 && diapasone.count < 0 && !allowHugeLists) {
throw new CriticalException("huge list");
}
string queryLimits = ""; string queryLimits = "";
if(diapasone.count >= 0) { if(diapasone.count >= 0) {
queryLimits = "LIMIT " + diapasone.count + " OFFSET " + diapasone.start; queryLimits = "LIMIT " + diapasone.count + " OFFSET " + diapasone.start;

Loading…
Cancel
Save