max-limits.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. ** Link this program against an SQLite library of unknown provenance in order
  3. ** to display the compile-time maximum values for various settings.
  4. */
  5. #include "sqlite3.h"
  6. #include <stdio.h>
  7. static const struct {
  8. int eCode;
  9. char *zName;
  10. } aLimit[] = {
  11. { SQLITE_LIMIT_LENGTH, "SQLITE_MAX_LENGTH" },
  12. { SQLITE_LIMIT_SQL_LENGTH, "SQLITE_MAX_SQL_LENGTH" },
  13. { SQLITE_LIMIT_COLUMN, "SQLITE_MAX_COLUMN" },
  14. { SQLITE_LIMIT_EXPR_DEPTH, "SQLITE_MAX_EXPR_DEPTH" },
  15. { SQLITE_LIMIT_COMPOUND_SELECT, "SQLITE_MAX_COMPOUND_SELECT" },
  16. { SQLITE_LIMIT_VDBE_OP, "SQLITE_MAX_VDBE_OP" },
  17. { SQLITE_LIMIT_FUNCTION_ARG, "SQLITE_MAX_FUNCTION_ARG" },
  18. { SQLITE_LIMIT_ATTACHED, "SQLITE_MAX_ATTACHED" },
  19. { SQLITE_LIMIT_LIKE_PATTERN_LENGTH, "SQLITE_MAX_LIKE_PATTERN_LENGTH" },
  20. { SQLITE_LIMIT_VARIABLE_NUMBER, "SQLITE_MAX_VARIABLE_NUMBER" },
  21. { SQLITE_LIMIT_TRIGGER_DEPTH, "SQLITE_MAX_TRIGGER_DEPTH" },
  22. { SQLITE_LIMIT_WORKER_THREADS, "SQLITE_MAX_WORKER_THREADS" },
  23. };
  24. static int maxLimit(sqlite3 *db, int eCode){
  25. int iOrig = sqlite3_limit(db, eCode, 0x7fffffff);
  26. return sqlite3_limit(db, eCode, iOrig);
  27. }
  28. int main(int argc, char **argv){
  29. sqlite3 *db;
  30. int j, rc;
  31. rc = sqlite3_open(":memory:", &db);
  32. if( rc==SQLITE_OK ){
  33. for(j=0; j<sizeof(aLimit)/sizeof(aLimit[0]); j++){
  34. printf("%-35s %10d\n", aLimit[j].zName, maxLimit(db, aLimit[j].eCode));
  35. }
  36. sqlite3_close(db);
  37. }
  38. }