/ Check-in [803cb60e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the ".limit" command to the command-line shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 803cb60e75e0b09a526eefec11139cb3e8ae8c7c
User & Date: drh 2015-05-02 17:40:23
Context
2015-05-02
19:54
Improvements to fuzzershell: Avoid excess memory allocations when loading many files. Show the total runtime on final output. Show individual filenames as they are processed even if they are single test-case files. check-in: 34a722a2 user: drh tags: trunk
18:25
Add the SQLITE_LIMIT_PRINTF_WIDTH setting for sqlite3_limit() and associated logic for preventing DOS attacks using printf() with oversized widths or precisions. Leaf check-in: f8b15979 user: drh tags: limit-printf-width
17:40
Add the ".limit" command to the command-line shell. check-in: 803cb60e user: drh tags: trunk
12:40
Reorganize some multi-threaded code in vdbesort.c so that full MC/DC test coverage does not depend on the outcome of a race condition. check-in: 78c7ec95 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1789   1789     ".import FILE TABLE     Import data from FILE into TABLE\n"
  1790   1790     ".indexes ?TABLE?       Show names of all indexes\n"
  1791   1791     "                         If TABLE specified, only show indexes for tables\n"
  1792   1792     "                         matching LIKE pattern TABLE.\n"
  1793   1793   #ifdef SQLITE_ENABLE_IOTRACE
  1794   1794     ".iotrace FILE          Enable I/O diagnostic logging to FILE\n"
  1795   1795   #endif
         1796  +  ".limit ?LIMIT? ?VAL?   Display or change the value of an SQLITE_LIMIT\n"
  1796   1797   #ifndef SQLITE_OMIT_LOAD_EXTENSION
  1797   1798     ".load FILE ?ENTRY?     Load an extension library\n"
  1798   1799   #endif
  1799   1800     ".log FILE|off          Turn logging on or off.  FILE can be stderr/stdout\n"
  1800   1801     ".mode MODE ?TABLE?     Set output mode where MODE is one of:\n"
  1801   1802     "                         ascii    Columns/rows delimited by 0x1F and 0x1E\n"
  1802   1803     "                         csv      Comma-separated values\n"
................................................................................
  3167   3168           rc = 1;
  3168   3169         }else{
  3169   3170           sqlite3IoTrace = iotracePrintf;
  3170   3171         }
  3171   3172       }
  3172   3173     }else
  3173   3174   #endif
         3175  +  if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){
         3176  +    static const struct {
         3177  +       const char *zLimitName;   /* Name of a limit */
         3178  +       int limitCode;            /* Integer code for that limit */
         3179  +    } aLimit[] = {
         3180  +      { "length",                SQLITE_LIMIT_LENGTH                    },
         3181  +      { "sql_length",            SQLITE_LIMIT_SQL_LENGTH                },
         3182  +      { "column",                SQLITE_LIMIT_COLUMN                    },
         3183  +      { "expr_depth",            SQLITE_LIMIT_EXPR_DEPTH                },
         3184  +      { "compound_select",       SQLITE_LIMIT_COMPOUND_SELECT           },
         3185  +      { "vdbe_op",               SQLITE_LIMIT_VDBE_OP                   },
         3186  +      { "function_arg",          SQLITE_LIMIT_FUNCTION_ARG              },
         3187  +      { "attached",              SQLITE_LIMIT_ATTACHED                  },
         3188  +      { "like_pattern_length",   SQLITE_LIMIT_LIKE_PATTERN_LENGTH       },
         3189  +      { "variable_number",       SQLITE_LIMIT_VARIABLE_NUMBER           },
         3190  +      { "trigger_depth",         SQLITE_LIMIT_TRIGGER_DEPTH             },
         3191  +      { "worker_threads",        SQLITE_LIMIT_WORKER_THREADS            },
         3192  +    };
         3193  +    int i, n2;
         3194  +    open_db(p, 0);
         3195  +    if( nArg==1 ){
         3196  +      for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
         3197  +        printf("%20s %d\n", aLimit[i].zLimitName, 
         3198  +               sqlite3_limit(p->db, aLimit[i].limitCode, -1));
         3199  +      }
         3200  +    }else if( nArg>3 ){
         3201  +      fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n");
         3202  +      rc = 1;
         3203  +      goto meta_command_exit;
         3204  +    }else{
         3205  +      int iLimit = -1;
         3206  +      n2 = strlen30(azArg[1]);
         3207  +      for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
         3208  +        if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){
         3209  +          if( iLimit<0 ){
         3210  +            iLimit = i;
         3211  +          }else{
         3212  +            fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]);
         3213  +            rc = 1;
         3214  +            goto meta_command_exit;
         3215  +          }
         3216  +        }
         3217  +      }
         3218  +      if( iLimit<0 ){
         3219  +        fprintf(stderr, "unknown limit: \"%s\"\n"
         3220  +                        "enter \".limits\" with no arguments for a list.\n",
         3221  +                         azArg[1]);
         3222  +        rc = 1;
         3223  +        goto meta_command_exit;
         3224  +      }
         3225  +      if( nArg==3 ){
         3226  +        sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2]));
         3227  +      }
         3228  +      printf("%20s %d\n", aLimit[iLimit].zLimitName,
         3229  +             sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));
         3230  +    }
         3231  +  }else
  3174   3232   
  3175   3233   #ifndef SQLITE_OMIT_LOAD_EXTENSION
  3176   3234     if( c=='l' && strncmp(azArg[0], "load", n)==0 ){
  3177   3235       const char *zFile, *zProc;
  3178   3236       char *zErrMsg = 0;
  3179   3237       if( nArg<2 ){
  3180   3238         fprintf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n");