Fossil SCM
Update the built-in SQLite to the first 3.8.10 beta.
Commit
5a87a0314e33b6bace04d6a717d6dbe46e4ef498
Parent
715f88811a2618a…
1 file changed
+120
-15
+120
-15
| --- src/shell.c | ||
| +++ src/shell.c | ||
| @@ -988,11 +988,20 @@ | ||
| 988 | 988 | break; |
| 989 | 989 | } |
| 990 | 990 | case MODE_Insert: { |
| 991 | 991 | p->cnt++; |
| 992 | 992 | if( azArg==0 ) break; |
| 993 | - fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); | |
| 993 | + fprintf(p->out,"INSERT INTO %s",p->zDestTable); | |
| 994 | + if( p->showHeader ){ | |
| 995 | + fprintf(p->out,"("); | |
| 996 | + for(i=0; i<nArg; i++){ | |
| 997 | + char *zSep = i>0 ? ",": ""; | |
| 998 | + fprintf(p->out, "%s%s", zSep, azCol[i]); | |
| 999 | + } | |
| 1000 | + fprintf(p->out,")"); | |
| 1001 | + } | |
| 1002 | + fprintf(p->out," VALUES("); | |
| 994 | 1003 | for(i=0; i<nArg; i++){ |
| 995 | 1004 | char *zSep = i>0 ? ",": ""; |
| 996 | 1005 | if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ |
| 997 | 1006 | fprintf(p->out,"%sNULL",zSep); |
| 998 | 1007 | }else if( aiType && aiType[i]==SQLITE_TEXT ){ |
| @@ -1189,11 +1198,11 @@ | ||
| 1189 | 1198 | */ |
| 1190 | 1199 | static char *save_err_msg( |
| 1191 | 1200 | sqlite3 *db /* Database to query */ |
| 1192 | 1201 | ){ |
| 1193 | 1202 | int nErrMsg = 1+strlen30(sqlite3_errmsg(db)); |
| 1194 | - char *zErrMsg = sqlite3_malloc(nErrMsg); | |
| 1203 | + char *zErrMsg = sqlite3_malloc64(nErrMsg); | |
| 1195 | 1204 | if( zErrMsg ){ |
| 1196 | 1205 | memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg); |
| 1197 | 1206 | } |
| 1198 | 1207 | return zErrMsg; |
| 1199 | 1208 | } |
| @@ -1426,12 +1435,12 @@ | ||
| 1426 | 1435 | int p2op = (p2 + (iOp-iAddr)); |
| 1427 | 1436 | |
| 1428 | 1437 | /* Grow the p->aiIndent array as required */ |
| 1429 | 1438 | if( iOp>=nAlloc ){ |
| 1430 | 1439 | nAlloc += 100; |
| 1431 | - p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int)); | |
| 1432 | - abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int)); | |
| 1440 | + p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int)); | |
| 1441 | + abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int)); | |
| 1433 | 1442 | } |
| 1434 | 1443 | abYield[iOp] = str_in_array(zOp, azYield); |
| 1435 | 1444 | p->aiIndent[iOp] = 0; |
| 1436 | 1445 | p->nIndent = iOp+1; |
| 1437 | 1446 | |
| @@ -1544,11 +1553,11 @@ | ||
| 1544 | 1553 | if( SQLITE_ROW == rc ){ |
| 1545 | 1554 | /* if we have a callback... */ |
| 1546 | 1555 | if( xCallback ){ |
| 1547 | 1556 | /* allocate space for col name ptr, value ptr, and type */ |
| 1548 | 1557 | int nCol = sqlite3_column_count(pStmt); |
| 1549 | - void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1); | |
| 1558 | + void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1); | |
| 1550 | 1559 | if( !pData ){ |
| 1551 | 1560 | rc = SQLITE_NOMEM; |
| 1552 | 1561 | }else{ |
| 1553 | 1562 | char **azCols = (char **)pData; /* Names of result columns */ |
| 1554 | 1563 | char **azVals = &azCols[nCol]; /* Results */ |
| @@ -1770,10 +1779,11 @@ | ||
| 1770 | 1779 | ** Text of a help message |
| 1771 | 1780 | */ |
| 1772 | 1781 | static char zHelp[] = |
| 1773 | 1782 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1774 | 1783 | ".bail on|off Stop after hitting an error. Default OFF\n" |
| 1784 | + ".binary on|off Turn binary output on or off. Default OFF\n" | |
| 1775 | 1785 | ".clone NEWDB Clone data into NEWDB from the existing database\n" |
| 1776 | 1786 | ".databases List names and files of attached databases\n" |
| 1777 | 1787 | ".dbinfo ?DB? Show status information about the database\n" |
| 1778 | 1788 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1779 | 1789 | " If TABLE specified, only dump tables matching\n" |
| @@ -1791,10 +1801,11 @@ | ||
| 1791 | 1801 | " If TABLE specified, only show indexes for tables\n" |
| 1792 | 1802 | " matching LIKE pattern TABLE.\n" |
| 1793 | 1803 | #ifdef SQLITE_ENABLE_IOTRACE |
| 1794 | 1804 | ".iotrace FILE Enable I/O diagnostic logging to FILE\n" |
| 1795 | 1805 | #endif |
| 1806 | + ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n" | |
| 1796 | 1807 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 1797 | 1808 | ".load FILE ?ENTRY? Load an extension library\n" |
| 1798 | 1809 | #endif |
| 1799 | 1810 | ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" |
| 1800 | 1811 | ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" |
| @@ -1860,11 +1871,11 @@ | ||
| 1860 | 1871 | in = fopen(zName, "rb"); |
| 1861 | 1872 | if( in==0 ) return; |
| 1862 | 1873 | fseek(in, 0, SEEK_END); |
| 1863 | 1874 | nIn = ftell(in); |
| 1864 | 1875 | rewind(in); |
| 1865 | - pBuf = sqlite3_malloc( nIn ); | |
| 1876 | + pBuf = sqlite3_malloc64( nIn ); | |
| 1866 | 1877 | if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ |
| 1867 | 1878 | sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); |
| 1868 | 1879 | }else{ |
| 1869 | 1880 | sqlite3_free(pBuf); |
| 1870 | 1881 | } |
| @@ -1907,10 +1918,16 @@ | ||
| 1907 | 1918 | */ |
| 1908 | 1919 | static void open_db(ShellState *p, int keepAlive){ |
| 1909 | 1920 | if( p->db==0 ){ |
| 1910 | 1921 | sqlite3_initialize(); |
| 1911 | 1922 | sqlite3_open(p->zDbFilename, &p->db); |
| 1923 | +#ifdef SQLITE_ENABLE_DBSTAT_VTAB | |
| 1924 | + if( p->db ){ | |
| 1925 | + int sqlite3_dbstat_register(sqlite3*); | |
| 1926 | + sqlite3_dbstat_register(p->db); | |
| 1927 | + } | |
| 1928 | +#endif | |
| 1912 | 1929 | globalDb = p->db; |
| 1913 | 1930 | if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ |
| 1914 | 1931 | sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, |
| 1915 | 1932 | shellstaticFunc, 0, 0); |
| 1916 | 1933 | } |
| @@ -1931,30 +1948,48 @@ | ||
| 1931 | 1948 | } |
| 1932 | 1949 | |
| 1933 | 1950 | /* |
| 1934 | 1951 | ** Do C-language style dequoting. |
| 1935 | 1952 | ** |
| 1953 | +** \a -> alarm | |
| 1954 | +** \b -> backspace | |
| 1936 | 1955 | ** \t -> tab |
| 1937 | 1956 | ** \n -> newline |
| 1957 | +** \v -> vertical tab | |
| 1958 | +** \f -> form feed | |
| 1938 | 1959 | ** \r -> carriage return |
| 1960 | +** \s -> space | |
| 1939 | 1961 | ** \" -> " |
| 1940 | -** \NNN -> ascii character NNN in octal | |
| 1962 | +** \' -> ' | |
| 1941 | 1963 | ** \\ -> backslash |
| 1964 | +** \NNN -> ascii character NNN in octal | |
| 1942 | 1965 | */ |
| 1943 | 1966 | static void resolve_backslashes(char *z){ |
| 1944 | 1967 | int i, j; |
| 1945 | 1968 | char c; |
| 1946 | 1969 | while( *z && *z!='\\' ) z++; |
| 1947 | 1970 | for(i=j=0; (c = z[i])!=0; i++, j++){ |
| 1948 | 1971 | if( c=='\\' && z[i+1]!=0 ){ |
| 1949 | 1972 | c = z[++i]; |
| 1950 | - if( c=='n' ){ | |
| 1951 | - c = '\n'; | |
| 1973 | + if( c=='a' ){ | |
| 1974 | + c = '\a'; | |
| 1975 | + }else if( c=='b' ){ | |
| 1976 | + c = '\b'; | |
| 1952 | 1977 | }else if( c=='t' ){ |
| 1953 | 1978 | c = '\t'; |
| 1979 | + }else if( c=='n' ){ | |
| 1980 | + c = '\n'; | |
| 1981 | + }else if( c=='v' ){ | |
| 1982 | + c = '\v'; | |
| 1983 | + }else if( c=='f' ){ | |
| 1984 | + c = '\f'; | |
| 1954 | 1985 | }else if( c=='r' ){ |
| 1955 | 1986 | c = '\r'; |
| 1987 | + }else if( c=='"' ){ | |
| 1988 | + c = '"'; | |
| 1989 | + }else if( c=='\'' ){ | |
| 1990 | + c = '\''; | |
| 1956 | 1991 | }else if( c=='\\' ){ |
| 1957 | 1992 | c = '\\'; |
| 1958 | 1993 | }else if( c>='0' && c<='7' ){ |
| 1959 | 1994 | c -= '0'; |
| 1960 | 1995 | if( z[i+1]>='0' && z[i+1]<='7' ){ |
| @@ -2120,11 +2155,11 @@ | ||
| 2120 | 2155 | |
| 2121 | 2156 | /* Append a single byte to z[] */ |
| 2122 | 2157 | static void import_append_char(ImportCtx *p, int c){ |
| 2123 | 2158 | if( p->n+1>=p->nAlloc ){ |
| 2124 | 2159 | p->nAlloc += p->nAlloc + 100; |
| 2125 | - p->z = sqlite3_realloc(p->z, p->nAlloc); | |
| 2160 | + p->z = sqlite3_realloc64(p->z, p->nAlloc); | |
| 2126 | 2161 | if( p->z==0 ){ |
| 2127 | 2162 | fprintf(stderr, "out of memory\n"); |
| 2128 | 2163 | exit(1); |
| 2129 | 2164 | } |
| 2130 | 2165 | } |
| @@ -2134,11 +2169,11 @@ | ||
| 2134 | 2169 | /* Read a single field of CSV text. Compatible with rfc4180 and extended |
| 2135 | 2170 | ** with the option of having a separator other than ",". |
| 2136 | 2171 | ** |
| 2137 | 2172 | ** + Input comes from p->in. |
| 2138 | 2173 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2139 | -** from sqlite3_malloc(). | |
| 2174 | +** from sqlite3_malloc64(). | |
| 2140 | 2175 | ** + Use p->cSep as the column separator. The default is ",". |
| 2141 | 2176 | ** + Use p->rSep as the row separator. The default is "\n". |
| 2142 | 2177 | ** + Keep track of the line number in p->nLine. |
| 2143 | 2178 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2144 | 2179 | ** EOF on end-of-file. |
| @@ -2208,11 +2243,11 @@ | ||
| 2208 | 2243 | |
| 2209 | 2244 | /* Read a single field of ASCII delimited text. |
| 2210 | 2245 | ** |
| 2211 | 2246 | ** + Input comes from p->in. |
| 2212 | 2247 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2213 | -** from sqlite3_malloc(). | |
| 2248 | +** from sqlite3_malloc64(). | |
| 2214 | 2249 | ** + Use p->cSep as the column separator. The default is "\x1F". |
| 2215 | 2250 | ** + Use p->rSep as the row separator. The default is "\x1E". |
| 2216 | 2251 | ** + Keep track of the row number in p->nLine. |
| 2217 | 2252 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2218 | 2253 | ** EOF on end-of-file. |
| @@ -2268,11 +2303,11 @@ | ||
| 2268 | 2303 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 2269 | 2304 | zQuery); |
| 2270 | 2305 | goto end_data_xfer; |
| 2271 | 2306 | } |
| 2272 | 2307 | n = sqlite3_column_count(pQuery); |
| 2273 | - zInsert = sqlite3_malloc(200 + nTable + n*3); | |
| 2308 | + zInsert = sqlite3_malloc64(200 + nTable + n*3); | |
| 2274 | 2309 | if( zInsert==0 ){ |
| 2275 | 2310 | fprintf(stderr, "out of memory\n"); |
| 2276 | 2311 | goto end_data_xfer; |
| 2277 | 2312 | } |
| 2278 | 2313 | sqlite3_snprintf(200+nTable,zInsert, |
| @@ -2683,10 +2718,23 @@ | ||
| 2683 | 2718 | }else{ |
| 2684 | 2719 | fprintf(stderr, "Usage: .bail on|off\n"); |
| 2685 | 2720 | rc = 1; |
| 2686 | 2721 | } |
| 2687 | 2722 | }else |
| 2723 | + | |
| 2724 | + if( c=='b' && n>=3 && strncmp(azArg[0], "binary", n)==0 ){ | |
| 2725 | + if( nArg==2 ){ | |
| 2726 | + if( booleanValue(azArg[1]) ){ | |
| 2727 | + setBinaryMode(p->out); | |
| 2728 | + }else{ | |
| 2729 | + setTextMode(p->out); | |
| 2730 | + } | |
| 2731 | + }else{ | |
| 2732 | + fprintf(stderr, "Usage: .binary on|off\n"); | |
| 2733 | + rc = 1; | |
| 2734 | + } | |
| 2735 | + }else | |
| 2688 | 2736 | |
| 2689 | 2737 | /* The undocumented ".breakpoint" command causes a call to the no-op |
| 2690 | 2738 | ** routine named test_breakpoint(). |
| 2691 | 2739 | */ |
| 2692 | 2740 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| @@ -3023,11 +3071,11 @@ | ||
| 3023 | 3071 | } |
| 3024 | 3072 | nCol = sqlite3_column_count(pStmt); |
| 3025 | 3073 | sqlite3_finalize(pStmt); |
| 3026 | 3074 | pStmt = 0; |
| 3027 | 3075 | if( nCol==0 ) return 0; /* no columns, no error */ |
| 3028 | - zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 ); | |
| 3076 | + zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); | |
| 3029 | 3077 | if( zSql==0 ){ |
| 3030 | 3078 | fprintf(stderr, "Error: out of memory\n"); |
| 3031 | 3079 | xCloser(sCtx.in); |
| 3032 | 3080 | return 1; |
| 3033 | 3081 | } |
| @@ -3163,10 +3211,67 @@ | ||
| 3163 | 3211 | sqlite3IoTrace = iotracePrintf; |
| 3164 | 3212 | } |
| 3165 | 3213 | } |
| 3166 | 3214 | }else |
| 3167 | 3215 | #endif |
| 3216 | + if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){ | |
| 3217 | + static const struct { | |
| 3218 | + const char *zLimitName; /* Name of a limit */ | |
| 3219 | + int limitCode; /* Integer code for that limit */ | |
| 3220 | + } aLimit[] = { | |
| 3221 | + { "length", SQLITE_LIMIT_LENGTH }, | |
| 3222 | + { "sql_length", SQLITE_LIMIT_SQL_LENGTH }, | |
| 3223 | + { "column", SQLITE_LIMIT_COLUMN }, | |
| 3224 | + { "expr_depth", SQLITE_LIMIT_EXPR_DEPTH }, | |
| 3225 | + { "compound_select", SQLITE_LIMIT_COMPOUND_SELECT }, | |
| 3226 | + { "vdbe_op", SQLITE_LIMIT_VDBE_OP }, | |
| 3227 | + { "function_arg", SQLITE_LIMIT_FUNCTION_ARG }, | |
| 3228 | + { "attached", SQLITE_LIMIT_ATTACHED }, | |
| 3229 | + { "like_pattern_length", SQLITE_LIMIT_LIKE_PATTERN_LENGTH }, | |
| 3230 | + { "variable_number", SQLITE_LIMIT_VARIABLE_NUMBER }, | |
| 3231 | + { "trigger_depth", SQLITE_LIMIT_TRIGGER_DEPTH }, | |
| 3232 | + { "worker_threads", SQLITE_LIMIT_WORKER_THREADS }, | |
| 3233 | + }; | |
| 3234 | + int i, n2; | |
| 3235 | + open_db(p, 0); | |
| 3236 | + if( nArg==1 ){ | |
| 3237 | + for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){ | |
| 3238 | + printf("%20s %d\n", aLimit[i].zLimitName, | |
| 3239 | + sqlite3_limit(p->db, aLimit[i].limitCode, -1)); | |
| 3240 | + } | |
| 3241 | + }else if( nArg>3 ){ | |
| 3242 | + fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); | |
| 3243 | + rc = 1; | |
| 3244 | + goto meta_command_exit; | |
| 3245 | + }else{ | |
| 3246 | + int iLimit = -1; | |
| 3247 | + n2 = strlen30(azArg[1]); | |
| 3248 | + for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){ | |
| 3249 | + if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){ | |
| 3250 | + if( iLimit<0 ){ | |
| 3251 | + iLimit = i; | |
| 3252 | + }else{ | |
| 3253 | + fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); | |
| 3254 | + rc = 1; | |
| 3255 | + goto meta_command_exit; | |
| 3256 | + } | |
| 3257 | + } | |
| 3258 | + } | |
| 3259 | + if( iLimit<0 ){ | |
| 3260 | + fprintf(stderr, "unknown limit: \"%s\"\n" | |
| 3261 | + "enter \".limits\" with no arguments for a list.\n", | |
| 3262 | + azArg[1]); | |
| 3263 | + rc = 1; | |
| 3264 | + goto meta_command_exit; | |
| 3265 | + } | |
| 3266 | + if( nArg==3 ){ | |
| 3267 | + sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2])); | |
| 3268 | + } | |
| 3269 | + printf("%20s %d\n", aLimit[iLimit].zLimitName, | |
| 3270 | + sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1)); | |
| 3271 | + } | |
| 3272 | + }else | |
| 3168 | 3273 | |
| 3169 | 3274 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 3170 | 3275 | if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ |
| 3171 | 3276 | const char *zFile, *zProc; |
| 3172 | 3277 | char *zErrMsg = 0; |
| @@ -3648,11 +3753,11 @@ | ||
| 3648 | 3753 | } |
| 3649 | 3754 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 3650 | 3755 | if( nRow>=nAlloc ){ |
| 3651 | 3756 | char **azNew; |
| 3652 | 3757 | int n2 = nAlloc*2 + 10; |
| 3653 | - azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n2); | |
| 3758 | + azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2); | |
| 3654 | 3759 | if( azNew==0 ){ |
| 3655 | 3760 | fprintf(stderr, "Error: out of memory\n"); |
| 3656 | 3761 | break; |
| 3657 | 3762 | } |
| 3658 | 3763 | nAlloc = n2; |
| 3659 | 3764 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -988,11 +988,20 @@ | |
| 988 | break; |
| 989 | } |
| 990 | case MODE_Insert: { |
| 991 | p->cnt++; |
| 992 | if( azArg==0 ) break; |
| 993 | fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); |
| 994 | for(i=0; i<nArg; i++){ |
| 995 | char *zSep = i>0 ? ",": ""; |
| 996 | if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ |
| 997 | fprintf(p->out,"%sNULL",zSep); |
| 998 | }else if( aiType && aiType[i]==SQLITE_TEXT ){ |
| @@ -1189,11 +1198,11 @@ | |
| 1189 | */ |
| 1190 | static char *save_err_msg( |
| 1191 | sqlite3 *db /* Database to query */ |
| 1192 | ){ |
| 1193 | int nErrMsg = 1+strlen30(sqlite3_errmsg(db)); |
| 1194 | char *zErrMsg = sqlite3_malloc(nErrMsg); |
| 1195 | if( zErrMsg ){ |
| 1196 | memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg); |
| 1197 | } |
| 1198 | return zErrMsg; |
| 1199 | } |
| @@ -1426,12 +1435,12 @@ | |
| 1426 | int p2op = (p2 + (iOp-iAddr)); |
| 1427 | |
| 1428 | /* Grow the p->aiIndent array as required */ |
| 1429 | if( iOp>=nAlloc ){ |
| 1430 | nAlloc += 100; |
| 1431 | p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int)); |
| 1432 | abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int)); |
| 1433 | } |
| 1434 | abYield[iOp] = str_in_array(zOp, azYield); |
| 1435 | p->aiIndent[iOp] = 0; |
| 1436 | p->nIndent = iOp+1; |
| 1437 | |
| @@ -1544,11 +1553,11 @@ | |
| 1544 | if( SQLITE_ROW == rc ){ |
| 1545 | /* if we have a callback... */ |
| 1546 | if( xCallback ){ |
| 1547 | /* allocate space for col name ptr, value ptr, and type */ |
| 1548 | int nCol = sqlite3_column_count(pStmt); |
| 1549 | void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1); |
| 1550 | if( !pData ){ |
| 1551 | rc = SQLITE_NOMEM; |
| 1552 | }else{ |
| 1553 | char **azCols = (char **)pData; /* Names of result columns */ |
| 1554 | char **azVals = &azCols[nCol]; /* Results */ |
| @@ -1770,10 +1779,11 @@ | |
| 1770 | ** Text of a help message |
| 1771 | */ |
| 1772 | static char zHelp[] = |
| 1773 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1774 | ".bail on|off Stop after hitting an error. Default OFF\n" |
| 1775 | ".clone NEWDB Clone data into NEWDB from the existing database\n" |
| 1776 | ".databases List names and files of attached databases\n" |
| 1777 | ".dbinfo ?DB? Show status information about the database\n" |
| 1778 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1779 | " If TABLE specified, only dump tables matching\n" |
| @@ -1791,10 +1801,11 @@ | |
| 1791 | " If TABLE specified, only show indexes for tables\n" |
| 1792 | " matching LIKE pattern TABLE.\n" |
| 1793 | #ifdef SQLITE_ENABLE_IOTRACE |
| 1794 | ".iotrace FILE Enable I/O diagnostic logging to FILE\n" |
| 1795 | #endif |
| 1796 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 1797 | ".load FILE ?ENTRY? Load an extension library\n" |
| 1798 | #endif |
| 1799 | ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" |
| 1800 | ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" |
| @@ -1860,11 +1871,11 @@ | |
| 1860 | in = fopen(zName, "rb"); |
| 1861 | if( in==0 ) return; |
| 1862 | fseek(in, 0, SEEK_END); |
| 1863 | nIn = ftell(in); |
| 1864 | rewind(in); |
| 1865 | pBuf = sqlite3_malloc( nIn ); |
| 1866 | if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ |
| 1867 | sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); |
| 1868 | }else{ |
| 1869 | sqlite3_free(pBuf); |
| 1870 | } |
| @@ -1907,10 +1918,16 @@ | |
| 1907 | */ |
| 1908 | static void open_db(ShellState *p, int keepAlive){ |
| 1909 | if( p->db==0 ){ |
| 1910 | sqlite3_initialize(); |
| 1911 | sqlite3_open(p->zDbFilename, &p->db); |
| 1912 | globalDb = p->db; |
| 1913 | if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ |
| 1914 | sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, |
| 1915 | shellstaticFunc, 0, 0); |
| 1916 | } |
| @@ -1931,30 +1948,48 @@ | |
| 1931 | } |
| 1932 | |
| 1933 | /* |
| 1934 | ** Do C-language style dequoting. |
| 1935 | ** |
| 1936 | ** \t -> tab |
| 1937 | ** \n -> newline |
| 1938 | ** \r -> carriage return |
| 1939 | ** \" -> " |
| 1940 | ** \NNN -> ascii character NNN in octal |
| 1941 | ** \\ -> backslash |
| 1942 | */ |
| 1943 | static void resolve_backslashes(char *z){ |
| 1944 | int i, j; |
| 1945 | char c; |
| 1946 | while( *z && *z!='\\' ) z++; |
| 1947 | for(i=j=0; (c = z[i])!=0; i++, j++){ |
| 1948 | if( c=='\\' && z[i+1]!=0 ){ |
| 1949 | c = z[++i]; |
| 1950 | if( c=='n' ){ |
| 1951 | c = '\n'; |
| 1952 | }else if( c=='t' ){ |
| 1953 | c = '\t'; |
| 1954 | }else if( c=='r' ){ |
| 1955 | c = '\r'; |
| 1956 | }else if( c=='\\' ){ |
| 1957 | c = '\\'; |
| 1958 | }else if( c>='0' && c<='7' ){ |
| 1959 | c -= '0'; |
| 1960 | if( z[i+1]>='0' && z[i+1]<='7' ){ |
| @@ -2120,11 +2155,11 @@ | |
| 2120 | |
| 2121 | /* Append a single byte to z[] */ |
| 2122 | static void import_append_char(ImportCtx *p, int c){ |
| 2123 | if( p->n+1>=p->nAlloc ){ |
| 2124 | p->nAlloc += p->nAlloc + 100; |
| 2125 | p->z = sqlite3_realloc(p->z, p->nAlloc); |
| 2126 | if( p->z==0 ){ |
| 2127 | fprintf(stderr, "out of memory\n"); |
| 2128 | exit(1); |
| 2129 | } |
| 2130 | } |
| @@ -2134,11 +2169,11 @@ | |
| 2134 | /* Read a single field of CSV text. Compatible with rfc4180 and extended |
| 2135 | ** with the option of having a separator other than ",". |
| 2136 | ** |
| 2137 | ** + Input comes from p->in. |
| 2138 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2139 | ** from sqlite3_malloc(). |
| 2140 | ** + Use p->cSep as the column separator. The default is ",". |
| 2141 | ** + Use p->rSep as the row separator. The default is "\n". |
| 2142 | ** + Keep track of the line number in p->nLine. |
| 2143 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2144 | ** EOF on end-of-file. |
| @@ -2208,11 +2243,11 @@ | |
| 2208 | |
| 2209 | /* Read a single field of ASCII delimited text. |
| 2210 | ** |
| 2211 | ** + Input comes from p->in. |
| 2212 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2213 | ** from sqlite3_malloc(). |
| 2214 | ** + Use p->cSep as the column separator. The default is "\x1F". |
| 2215 | ** + Use p->rSep as the row separator. The default is "\x1E". |
| 2216 | ** + Keep track of the row number in p->nLine. |
| 2217 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2218 | ** EOF on end-of-file. |
| @@ -2268,11 +2303,11 @@ | |
| 2268 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 2269 | zQuery); |
| 2270 | goto end_data_xfer; |
| 2271 | } |
| 2272 | n = sqlite3_column_count(pQuery); |
| 2273 | zInsert = sqlite3_malloc(200 + nTable + n*3); |
| 2274 | if( zInsert==0 ){ |
| 2275 | fprintf(stderr, "out of memory\n"); |
| 2276 | goto end_data_xfer; |
| 2277 | } |
| 2278 | sqlite3_snprintf(200+nTable,zInsert, |
| @@ -2683,10 +2718,23 @@ | |
| 2683 | }else{ |
| 2684 | fprintf(stderr, "Usage: .bail on|off\n"); |
| 2685 | rc = 1; |
| 2686 | } |
| 2687 | }else |
| 2688 | |
| 2689 | /* The undocumented ".breakpoint" command causes a call to the no-op |
| 2690 | ** routine named test_breakpoint(). |
| 2691 | */ |
| 2692 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| @@ -3023,11 +3071,11 @@ | |
| 3023 | } |
| 3024 | nCol = sqlite3_column_count(pStmt); |
| 3025 | sqlite3_finalize(pStmt); |
| 3026 | pStmt = 0; |
| 3027 | if( nCol==0 ) return 0; /* no columns, no error */ |
| 3028 | zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 ); |
| 3029 | if( zSql==0 ){ |
| 3030 | fprintf(stderr, "Error: out of memory\n"); |
| 3031 | xCloser(sCtx.in); |
| 3032 | return 1; |
| 3033 | } |
| @@ -3163,10 +3211,67 @@ | |
| 3163 | sqlite3IoTrace = iotracePrintf; |
| 3164 | } |
| 3165 | } |
| 3166 | }else |
| 3167 | #endif |
| 3168 | |
| 3169 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 3170 | if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ |
| 3171 | const char *zFile, *zProc; |
| 3172 | char *zErrMsg = 0; |
| @@ -3648,11 +3753,11 @@ | |
| 3648 | } |
| 3649 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 3650 | if( nRow>=nAlloc ){ |
| 3651 | char **azNew; |
| 3652 | int n2 = nAlloc*2 + 10; |
| 3653 | azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n2); |
| 3654 | if( azNew==0 ){ |
| 3655 | fprintf(stderr, "Error: out of memory\n"); |
| 3656 | break; |
| 3657 | } |
| 3658 | nAlloc = n2; |
| 3659 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -988,11 +988,20 @@ | |
| 988 | break; |
| 989 | } |
| 990 | case MODE_Insert: { |
| 991 | p->cnt++; |
| 992 | if( azArg==0 ) break; |
| 993 | fprintf(p->out,"INSERT INTO %s",p->zDestTable); |
| 994 | if( p->showHeader ){ |
| 995 | fprintf(p->out,"("); |
| 996 | for(i=0; i<nArg; i++){ |
| 997 | char *zSep = i>0 ? ",": ""; |
| 998 | fprintf(p->out, "%s%s", zSep, azCol[i]); |
| 999 | } |
| 1000 | fprintf(p->out,")"); |
| 1001 | } |
| 1002 | fprintf(p->out," VALUES("); |
| 1003 | for(i=0; i<nArg; i++){ |
| 1004 | char *zSep = i>0 ? ",": ""; |
| 1005 | if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ |
| 1006 | fprintf(p->out,"%sNULL",zSep); |
| 1007 | }else if( aiType && aiType[i]==SQLITE_TEXT ){ |
| @@ -1189,11 +1198,11 @@ | |
| 1198 | */ |
| 1199 | static char *save_err_msg( |
| 1200 | sqlite3 *db /* Database to query */ |
| 1201 | ){ |
| 1202 | int nErrMsg = 1+strlen30(sqlite3_errmsg(db)); |
| 1203 | char *zErrMsg = sqlite3_malloc64(nErrMsg); |
| 1204 | if( zErrMsg ){ |
| 1205 | memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg); |
| 1206 | } |
| 1207 | return zErrMsg; |
| 1208 | } |
| @@ -1426,12 +1435,12 @@ | |
| 1435 | int p2op = (p2 + (iOp-iAddr)); |
| 1436 | |
| 1437 | /* Grow the p->aiIndent array as required */ |
| 1438 | if( iOp>=nAlloc ){ |
| 1439 | nAlloc += 100; |
| 1440 | p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int)); |
| 1441 | abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int)); |
| 1442 | } |
| 1443 | abYield[iOp] = str_in_array(zOp, azYield); |
| 1444 | p->aiIndent[iOp] = 0; |
| 1445 | p->nIndent = iOp+1; |
| 1446 | |
| @@ -1544,11 +1553,11 @@ | |
| 1553 | if( SQLITE_ROW == rc ){ |
| 1554 | /* if we have a callback... */ |
| 1555 | if( xCallback ){ |
| 1556 | /* allocate space for col name ptr, value ptr, and type */ |
| 1557 | int nCol = sqlite3_column_count(pStmt); |
| 1558 | void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1); |
| 1559 | if( !pData ){ |
| 1560 | rc = SQLITE_NOMEM; |
| 1561 | }else{ |
| 1562 | char **azCols = (char **)pData; /* Names of result columns */ |
| 1563 | char **azVals = &azCols[nCol]; /* Results */ |
| @@ -1770,10 +1779,11 @@ | |
| 1779 | ** Text of a help message |
| 1780 | */ |
| 1781 | static char zHelp[] = |
| 1782 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1783 | ".bail on|off Stop after hitting an error. Default OFF\n" |
| 1784 | ".binary on|off Turn binary output on or off. Default OFF\n" |
| 1785 | ".clone NEWDB Clone data into NEWDB from the existing database\n" |
| 1786 | ".databases List names and files of attached databases\n" |
| 1787 | ".dbinfo ?DB? Show status information about the database\n" |
| 1788 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1789 | " If TABLE specified, only dump tables matching\n" |
| @@ -1791,10 +1801,11 @@ | |
| 1801 | " If TABLE specified, only show indexes for tables\n" |
| 1802 | " matching LIKE pattern TABLE.\n" |
| 1803 | #ifdef SQLITE_ENABLE_IOTRACE |
| 1804 | ".iotrace FILE Enable I/O diagnostic logging to FILE\n" |
| 1805 | #endif |
| 1806 | ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n" |
| 1807 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 1808 | ".load FILE ?ENTRY? Load an extension library\n" |
| 1809 | #endif |
| 1810 | ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n" |
| 1811 | ".mode MODE ?TABLE? Set output mode where MODE is one of:\n" |
| @@ -1860,11 +1871,11 @@ | |
| 1871 | in = fopen(zName, "rb"); |
| 1872 | if( in==0 ) return; |
| 1873 | fseek(in, 0, SEEK_END); |
| 1874 | nIn = ftell(in); |
| 1875 | rewind(in); |
| 1876 | pBuf = sqlite3_malloc64( nIn ); |
| 1877 | if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ |
| 1878 | sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); |
| 1879 | }else{ |
| 1880 | sqlite3_free(pBuf); |
| 1881 | } |
| @@ -1907,10 +1918,16 @@ | |
| 1918 | */ |
| 1919 | static void open_db(ShellState *p, int keepAlive){ |
| 1920 | if( p->db==0 ){ |
| 1921 | sqlite3_initialize(); |
| 1922 | sqlite3_open(p->zDbFilename, &p->db); |
| 1923 | #ifdef SQLITE_ENABLE_DBSTAT_VTAB |
| 1924 | if( p->db ){ |
| 1925 | int sqlite3_dbstat_register(sqlite3*); |
| 1926 | sqlite3_dbstat_register(p->db); |
| 1927 | } |
| 1928 | #endif |
| 1929 | globalDb = p->db; |
| 1930 | if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ |
| 1931 | sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, |
| 1932 | shellstaticFunc, 0, 0); |
| 1933 | } |
| @@ -1931,30 +1948,48 @@ | |
| 1948 | } |
| 1949 | |
| 1950 | /* |
| 1951 | ** Do C-language style dequoting. |
| 1952 | ** |
| 1953 | ** \a -> alarm |
| 1954 | ** \b -> backspace |
| 1955 | ** \t -> tab |
| 1956 | ** \n -> newline |
| 1957 | ** \v -> vertical tab |
| 1958 | ** \f -> form feed |
| 1959 | ** \r -> carriage return |
| 1960 | ** \s -> space |
| 1961 | ** \" -> " |
| 1962 | ** \' -> ' |
| 1963 | ** \\ -> backslash |
| 1964 | ** \NNN -> ascii character NNN in octal |
| 1965 | */ |
| 1966 | static void resolve_backslashes(char *z){ |
| 1967 | int i, j; |
| 1968 | char c; |
| 1969 | while( *z && *z!='\\' ) z++; |
| 1970 | for(i=j=0; (c = z[i])!=0; i++, j++){ |
| 1971 | if( c=='\\' && z[i+1]!=0 ){ |
| 1972 | c = z[++i]; |
| 1973 | if( c=='a' ){ |
| 1974 | c = '\a'; |
| 1975 | }else if( c=='b' ){ |
| 1976 | c = '\b'; |
| 1977 | }else if( c=='t' ){ |
| 1978 | c = '\t'; |
| 1979 | }else if( c=='n' ){ |
| 1980 | c = '\n'; |
| 1981 | }else if( c=='v' ){ |
| 1982 | c = '\v'; |
| 1983 | }else if( c=='f' ){ |
| 1984 | c = '\f'; |
| 1985 | }else if( c=='r' ){ |
| 1986 | c = '\r'; |
| 1987 | }else if( c=='"' ){ |
| 1988 | c = '"'; |
| 1989 | }else if( c=='\'' ){ |
| 1990 | c = '\''; |
| 1991 | }else if( c=='\\' ){ |
| 1992 | c = '\\'; |
| 1993 | }else if( c>='0' && c<='7' ){ |
| 1994 | c -= '0'; |
| 1995 | if( z[i+1]>='0' && z[i+1]<='7' ){ |
| @@ -2120,11 +2155,11 @@ | |
| 2155 | |
| 2156 | /* Append a single byte to z[] */ |
| 2157 | static void import_append_char(ImportCtx *p, int c){ |
| 2158 | if( p->n+1>=p->nAlloc ){ |
| 2159 | p->nAlloc += p->nAlloc + 100; |
| 2160 | p->z = sqlite3_realloc64(p->z, p->nAlloc); |
| 2161 | if( p->z==0 ){ |
| 2162 | fprintf(stderr, "out of memory\n"); |
| 2163 | exit(1); |
| 2164 | } |
| 2165 | } |
| @@ -2134,11 +2169,11 @@ | |
| 2169 | /* Read a single field of CSV text. Compatible with rfc4180 and extended |
| 2170 | ** with the option of having a separator other than ",". |
| 2171 | ** |
| 2172 | ** + Input comes from p->in. |
| 2173 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2174 | ** from sqlite3_malloc64(). |
| 2175 | ** + Use p->cSep as the column separator. The default is ",". |
| 2176 | ** + Use p->rSep as the row separator. The default is "\n". |
| 2177 | ** + Keep track of the line number in p->nLine. |
| 2178 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2179 | ** EOF on end-of-file. |
| @@ -2208,11 +2243,11 @@ | |
| 2243 | |
| 2244 | /* Read a single field of ASCII delimited text. |
| 2245 | ** |
| 2246 | ** + Input comes from p->in. |
| 2247 | ** + Store results in p->z of length p->n. Space to hold p->z comes |
| 2248 | ** from sqlite3_malloc64(). |
| 2249 | ** + Use p->cSep as the column separator. The default is "\x1F". |
| 2250 | ** + Use p->rSep as the row separator. The default is "\x1E". |
| 2251 | ** + Keep track of the row number in p->nLine. |
| 2252 | ** + Store the character that terminates the field in p->cTerm. Store |
| 2253 | ** EOF on end-of-file. |
| @@ -2268,11 +2303,11 @@ | |
| 2303 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 2304 | zQuery); |
| 2305 | goto end_data_xfer; |
| 2306 | } |
| 2307 | n = sqlite3_column_count(pQuery); |
| 2308 | zInsert = sqlite3_malloc64(200 + nTable + n*3); |
| 2309 | if( zInsert==0 ){ |
| 2310 | fprintf(stderr, "out of memory\n"); |
| 2311 | goto end_data_xfer; |
| 2312 | } |
| 2313 | sqlite3_snprintf(200+nTable,zInsert, |
| @@ -2683,10 +2718,23 @@ | |
| 2718 | }else{ |
| 2719 | fprintf(stderr, "Usage: .bail on|off\n"); |
| 2720 | rc = 1; |
| 2721 | } |
| 2722 | }else |
| 2723 | |
| 2724 | if( c=='b' && n>=3 && strncmp(azArg[0], "binary", n)==0 ){ |
| 2725 | if( nArg==2 ){ |
| 2726 | if( booleanValue(azArg[1]) ){ |
| 2727 | setBinaryMode(p->out); |
| 2728 | }else{ |
| 2729 | setTextMode(p->out); |
| 2730 | } |
| 2731 | }else{ |
| 2732 | fprintf(stderr, "Usage: .binary on|off\n"); |
| 2733 | rc = 1; |
| 2734 | } |
| 2735 | }else |
| 2736 | |
| 2737 | /* The undocumented ".breakpoint" command causes a call to the no-op |
| 2738 | ** routine named test_breakpoint(). |
| 2739 | */ |
| 2740 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| @@ -3023,11 +3071,11 @@ | |
| 3071 | } |
| 3072 | nCol = sqlite3_column_count(pStmt); |
| 3073 | sqlite3_finalize(pStmt); |
| 3074 | pStmt = 0; |
| 3075 | if( nCol==0 ) return 0; /* no columns, no error */ |
| 3076 | zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); |
| 3077 | if( zSql==0 ){ |
| 3078 | fprintf(stderr, "Error: out of memory\n"); |
| 3079 | xCloser(sCtx.in); |
| 3080 | return 1; |
| 3081 | } |
| @@ -3163,10 +3211,67 @@ | |
| 3211 | sqlite3IoTrace = iotracePrintf; |
| 3212 | } |
| 3213 | } |
| 3214 | }else |
| 3215 | #endif |
| 3216 | if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){ |
| 3217 | static const struct { |
| 3218 | const char *zLimitName; /* Name of a limit */ |
| 3219 | int limitCode; /* Integer code for that limit */ |
| 3220 | } aLimit[] = { |
| 3221 | { "length", SQLITE_LIMIT_LENGTH }, |
| 3222 | { "sql_length", SQLITE_LIMIT_SQL_LENGTH }, |
| 3223 | { "column", SQLITE_LIMIT_COLUMN }, |
| 3224 | { "expr_depth", SQLITE_LIMIT_EXPR_DEPTH }, |
| 3225 | { "compound_select", SQLITE_LIMIT_COMPOUND_SELECT }, |
| 3226 | { "vdbe_op", SQLITE_LIMIT_VDBE_OP }, |
| 3227 | { "function_arg", SQLITE_LIMIT_FUNCTION_ARG }, |
| 3228 | { "attached", SQLITE_LIMIT_ATTACHED }, |
| 3229 | { "like_pattern_length", SQLITE_LIMIT_LIKE_PATTERN_LENGTH }, |
| 3230 | { "variable_number", SQLITE_LIMIT_VARIABLE_NUMBER }, |
| 3231 | { "trigger_depth", SQLITE_LIMIT_TRIGGER_DEPTH }, |
| 3232 | { "worker_threads", SQLITE_LIMIT_WORKER_THREADS }, |
| 3233 | }; |
| 3234 | int i, n2; |
| 3235 | open_db(p, 0); |
| 3236 | if( nArg==1 ){ |
| 3237 | for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){ |
| 3238 | printf("%20s %d\n", aLimit[i].zLimitName, |
| 3239 | sqlite3_limit(p->db, aLimit[i].limitCode, -1)); |
| 3240 | } |
| 3241 | }else if( nArg>3 ){ |
| 3242 | fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n"); |
| 3243 | rc = 1; |
| 3244 | goto meta_command_exit; |
| 3245 | }else{ |
| 3246 | int iLimit = -1; |
| 3247 | n2 = strlen30(azArg[1]); |
| 3248 | for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){ |
| 3249 | if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){ |
| 3250 | if( iLimit<0 ){ |
| 3251 | iLimit = i; |
| 3252 | }else{ |
| 3253 | fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]); |
| 3254 | rc = 1; |
| 3255 | goto meta_command_exit; |
| 3256 | } |
| 3257 | } |
| 3258 | } |
| 3259 | if( iLimit<0 ){ |
| 3260 | fprintf(stderr, "unknown limit: \"%s\"\n" |
| 3261 | "enter \".limits\" with no arguments for a list.\n", |
| 3262 | azArg[1]); |
| 3263 | rc = 1; |
| 3264 | goto meta_command_exit; |
| 3265 | } |
| 3266 | if( nArg==3 ){ |
| 3267 | sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2])); |
| 3268 | } |
| 3269 | printf("%20s %d\n", aLimit[iLimit].zLimitName, |
| 3270 | sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1)); |
| 3271 | } |
| 3272 | }else |
| 3273 | |
| 3274 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 3275 | if( c=='l' && strncmp(azArg[0], "load", n)==0 ){ |
| 3276 | const char *zFile, *zProc; |
| 3277 | char *zErrMsg = 0; |
| @@ -3648,11 +3753,11 @@ | |
| 3753 | } |
| 3754 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 3755 | if( nRow>=nAlloc ){ |
| 3756 | char **azNew; |
| 3757 | int n2 = nAlloc*2 + 10; |
| 3758 | azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2); |
| 3759 | if( azNew==0 ){ |
| 3760 | fprintf(stderr, "Error: out of memory\n"); |
| 3761 | break; |
| 3762 | } |
| 3763 | nAlloc = n2; |
| 3764 |