mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Improved the ability of the CLI to handle very long input lines.
Potentially a fix for the bug reported by [forum:/forumpost/fa4bb2941a|forum post fa4bb2941a]. FossilOrigin-Name: d0e107ee00101f42b4c9bf372625311d04b83c96a4a9caacac866ea03d8e7fa4
This commit is contained in:
13
manifest
13
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Enhance\sthe\s"PRAGMA\sintegrity_check"\sstatement\sso\sthat\sit\sverifies\sdatatype\nconstraints\son\snon-STRICT\stables:\s\s(1)\sColumns\swith\sTEXT\saffinity\sshould\snot\ncontain\snumeric\svalues,\sand\s(2)\scolumns\swith\sNUMERIC\saffinity\sshould\snot\ncontain\sTEXT\svalues\sthat\scould\sbe\sconverted\sinto\snumbers.
|
C Improved\sthe\sability\sof\sthe\sCLI\sto\shandle\svery\slong\sinput\slines.\nPotentially\sa\sfix\sfor\sthe\sbug\sreported\sby\n[forum:/forumpost/fa4bb2941a|forum\spost\sfa4bb2941a].
|
||||||
D 2022-10-10T23:54:17.674
|
D 2022-10-11T12:02:42.516
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -589,7 +589,7 @@ F src/random.c 546d6feb15ec69c1aafe9bb351a277cbb498fd5410e646add673acb805714960
|
|||||||
F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633
|
F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633
|
||||||
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
|
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
|
||||||
F src/select.c bb18acf4eded647fef88d4d543c673874dbebff516fbeba90a85e6c13f2a58cd
|
F src/select.c bb18acf4eded647fef88d4d543c673874dbebff516fbeba90a85e6c13f2a58cd
|
||||||
F src/shell.c.in e7e7c2c69ae86c5ee9e8ad66227203d46ff6dce8700a1b1dababff01c71d33df
|
F src/shell.c.in d89ed19d90870491d113758f302aabda434154da0f0b16c652748e5881d095ef
|
||||||
F src/sqlite.h.in bcc51bb43c54676dccbad07051c6d463212707f50363d64f1831440749e91ddb
|
F src/sqlite.h.in bcc51bb43c54676dccbad07051c6d463212707f50363d64f1831440749e91ddb
|
||||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||||
F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d
|
F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d
|
||||||
@@ -2002,9 +2002,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 327965bc71023d9380a9d6805062659108dab4bfcd386b7aba813754f270d33a a140173102febe9ef8064ee9b95bee489db54caba149e577d69e4d75161bf390
|
P aa6e9086196248675b9e33dbfaad9ef67097432535896790f80d2470002978b1
|
||||||
R 27cc3a1e54ea78f4322ce43e3f2008e7
|
R 00c6f1b8c7c66f6a163223479513c839
|
||||||
T +closed a140173102febe9ef8064ee9b95bee489db54caba149e577d69e4d75161bf390
|
|
||||||
U drh
|
U drh
|
||||||
Z e702316a9b12d63d22f572b11832de1b
|
Z 946bcdd9664c36b8c41d069cd2649097
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
aa6e9086196248675b9e33dbfaad9ef67097432535896790f80d2470002978b1
|
d0e107ee00101f42b4c9bf372625311d04b83c96a4a9caacac866ea03d8e7fa4
|
||||||
@@ -672,7 +672,7 @@ static char *local_getline(char *zLine, FILE *in){
|
|||||||
if( stdin_is_interactive && in==stdin ){
|
if( stdin_is_interactive && in==stdin ){
|
||||||
char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
|
char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
|
||||||
if( zTrans ){
|
if( zTrans ){
|
||||||
int nTrans = strlen30(zTrans)+1;
|
i64 nTrans = strlen(zTrans)+1;
|
||||||
if( nTrans>nLine ){
|
if( nTrans>nLine ){
|
||||||
zLine = realloc(zLine, nTrans);
|
zLine = realloc(zLine, nTrans);
|
||||||
shell_check_oom(zLine);
|
shell_check_oom(zLine);
|
||||||
@@ -808,9 +808,9 @@ static void freeText(ShellText *p){
|
|||||||
** quote character for zAppend.
|
** quote character for zAppend.
|
||||||
*/
|
*/
|
||||||
static void appendText(ShellText *p, const char *zAppend, char quote){
|
static void appendText(ShellText *p, const char *zAppend, char quote){
|
||||||
int len;
|
i64 len;
|
||||||
int i;
|
i64 i;
|
||||||
int nAppend = strlen30(zAppend);
|
i64 nAppend = strlen30(zAppend);
|
||||||
|
|
||||||
len = nAppend+p->n+1;
|
len = nAppend+p->n+1;
|
||||||
if( quote ){
|
if( quote ){
|
||||||
@@ -1676,9 +1676,9 @@ static void output_c_string(FILE *out, const char *z){
|
|||||||
/*
|
/*
|
||||||
** Output the given string as a quoted according to JSON quoting rules.
|
** Output the given string as a quoted according to JSON quoting rules.
|
||||||
*/
|
*/
|
||||||
static void output_json_string(FILE *out, const char *z, int n){
|
static void output_json_string(FILE *out, const char *z, i64 n){
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
if( n<0 ) n = (int)strlen(z);
|
if( n<0 ) n = strlen(z);
|
||||||
fputc('"', out);
|
fputc('"', out);
|
||||||
while( n-- ){
|
while( n-- ){
|
||||||
c = *(z++);
|
c = *(z++);
|
||||||
@@ -1981,7 +1981,7 @@ static int wsToEol(const char *z){
|
|||||||
*/
|
*/
|
||||||
static void eqp_append(ShellState *p, int iEqpId, int p2, const char *zText){
|
static void eqp_append(ShellState *p, int iEqpId, int p2, const char *zText){
|
||||||
EQPGraphRow *pNew;
|
EQPGraphRow *pNew;
|
||||||
int nText = strlen30(zText);
|
i64 nText = strlen(zText);
|
||||||
if( p->autoEQPtest ){
|
if( p->autoEQPtest ){
|
||||||
utf8_printf(p->out, "%d,%d,%s\n", iEqpId, p2, zText);
|
utf8_printf(p->out, "%d,%d,%s\n", iEqpId, p2, zText);
|
||||||
}
|
}
|
||||||
@@ -2026,14 +2026,14 @@ static EQPGraphRow *eqp_next_row(ShellState *p, int iEqpId, EQPGraphRow *pOld){
|
|||||||
*/
|
*/
|
||||||
static void eqp_render_level(ShellState *p, int iEqpId){
|
static void eqp_render_level(ShellState *p, int iEqpId){
|
||||||
EQPGraphRow *pRow, *pNext;
|
EQPGraphRow *pRow, *pNext;
|
||||||
int n = strlen30(p->sGraph.zPrefix);
|
i64 n = strlen(p->sGraph.zPrefix);
|
||||||
char *z;
|
char *z;
|
||||||
for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
|
for(pRow = eqp_next_row(p, iEqpId, 0); pRow; pRow = pNext){
|
||||||
pNext = eqp_next_row(p, iEqpId, pRow);
|
pNext = eqp_next_row(p, iEqpId, pRow);
|
||||||
z = pRow->zText;
|
z = pRow->zText;
|
||||||
utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix,
|
utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix,
|
||||||
pNext ? "|--" : "`--", z);
|
pNext ? "|--" : "`--", z);
|
||||||
if( n<(int)sizeof(p->sGraph.zPrefix)-7 ){
|
if( n<(i64)sizeof(p->sGraph.zPrefix)-7 ){
|
||||||
memcpy(&p->sGraph.zPrefix[n], pNext ? "| " : " ", 4);
|
memcpy(&p->sGraph.zPrefix[n], pNext ? "| " : " ", 4);
|
||||||
eqp_render_level(p, pRow->iEqpId);
|
eqp_render_level(p, pRow->iEqpId);
|
||||||
p->sGraph.zPrefix[n] = 0;
|
p->sGraph.zPrefix[n] = 0;
|
||||||
@@ -4945,28 +4945,28 @@ static void shellEscapeCrnl(
|
|||||||
const char *zText = (const char*)sqlite3_value_text(argv[0]);
|
const char *zText = (const char*)sqlite3_value_text(argv[0]);
|
||||||
UNUSED_PARAMETER(argc);
|
UNUSED_PARAMETER(argc);
|
||||||
if( zText && zText[0]=='\'' ){
|
if( zText && zText[0]=='\'' ){
|
||||||
int nText = sqlite3_value_bytes(argv[0]);
|
i64 nText = sqlite3_value_bytes(argv[0]);
|
||||||
int i;
|
i64 i;
|
||||||
char zBuf1[20];
|
char zBuf1[20];
|
||||||
char zBuf2[20];
|
char zBuf2[20];
|
||||||
const char *zNL = 0;
|
const char *zNL = 0;
|
||||||
const char *zCR = 0;
|
const char *zCR = 0;
|
||||||
int nCR = 0;
|
i64 nCR = 0;
|
||||||
int nNL = 0;
|
i64 nNL = 0;
|
||||||
|
|
||||||
for(i=0; zText[i]; i++){
|
for(i=0; zText[i]; i++){
|
||||||
if( zNL==0 && zText[i]=='\n' ){
|
if( zNL==0 && zText[i]=='\n' ){
|
||||||
zNL = unused_string(zText, "\\n", "\\012", zBuf1);
|
zNL = unused_string(zText, "\\n", "\\012", zBuf1);
|
||||||
nNL = (int)strlen(zNL);
|
nNL = strlen(zNL);
|
||||||
}
|
}
|
||||||
if( zCR==0 && zText[i]=='\r' ){
|
if( zCR==0 && zText[i]=='\r' ){
|
||||||
zCR = unused_string(zText, "\\r", "\\015", zBuf2);
|
zCR = unused_string(zText, "\\r", "\\015", zBuf2);
|
||||||
nCR = (int)strlen(zCR);
|
nCR = strlen(zCR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( zNL || zCR ){
|
if( zNL || zCR ){
|
||||||
int iOut = 0;
|
i64 iOut = 0;
|
||||||
i64 nMax = (nNL > nCR) ? nNL : nCR;
|
i64 nMax = (nNL > nCR) ? nNL : nCR;
|
||||||
i64 nAlloc = nMax * nText + (nMax+64)*2;
|
i64 nAlloc = nMax * nText + (nMax+64)*2;
|
||||||
char *zOut = (char*)sqlite3_malloc64(nAlloc);
|
char *zOut = (char*)sqlite3_malloc64(nAlloc);
|
||||||
@@ -5207,8 +5207,8 @@ static char **readline_completion(const char *zText, int iStart, int iEnd){
|
|||||||
** Linenoise completion callback
|
** Linenoise completion callback
|
||||||
*/
|
*/
|
||||||
static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
|
static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
|
||||||
int nLine = strlen30(zLine);
|
i64 nLine = strlen(zLine);
|
||||||
int i, iStart;
|
i64 i, iStart;
|
||||||
sqlite3_stmt *pStmt = 0;
|
sqlite3_stmt *pStmt = 0;
|
||||||
char *zSql;
|
char *zSql;
|
||||||
char zBuf[1000];
|
char zBuf[1000];
|
||||||
@@ -5374,7 +5374,7 @@ static int sql_trace_callback(
|
|||||||
ShellState *p = (ShellState*)pArg;
|
ShellState *p = (ShellState*)pArg;
|
||||||
sqlite3_stmt *pStmt;
|
sqlite3_stmt *pStmt;
|
||||||
const char *zSql;
|
const char *zSql;
|
||||||
int nSql;
|
i64 nSql;
|
||||||
if( p->traceOut==0 ) return 0;
|
if( p->traceOut==0 ) return 0;
|
||||||
if( mType==SQLITE_TRACE_CLOSE ){
|
if( mType==SQLITE_TRACE_CLOSE ){
|
||||||
utf8_printf(p->traceOut, "-- closing database connection\n");
|
utf8_printf(p->traceOut, "-- closing database connection\n");
|
||||||
@@ -5402,17 +5402,18 @@ static int sql_trace_callback(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( zSql==0 ) return 0;
|
if( zSql==0 ) return 0;
|
||||||
nSql = strlen30(zSql);
|
nSql = strlen(zSql);
|
||||||
|
if( nSql>1000000000 ) nSql = 1000000000;
|
||||||
while( nSql>0 && zSql[nSql-1]==';' ){ nSql--; }
|
while( nSql>0 && zSql[nSql-1]==';' ){ nSql--; }
|
||||||
switch( mType ){
|
switch( mType ){
|
||||||
case SQLITE_TRACE_ROW:
|
case SQLITE_TRACE_ROW:
|
||||||
case SQLITE_TRACE_STMT: {
|
case SQLITE_TRACE_STMT: {
|
||||||
utf8_printf(p->traceOut, "%.*s;\n", nSql, zSql);
|
utf8_printf(p->traceOut, "%.*s;\n", (int)nSql, zSql);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SQLITE_TRACE_PROFILE: {
|
case SQLITE_TRACE_PROFILE: {
|
||||||
sqlite3_int64 nNanosec = *(sqlite3_int64*)pX;
|
sqlite3_int64 nNanosec = *(sqlite3_int64*)pX;
|
||||||
utf8_printf(p->traceOut, "%.*s; -- %lld ns\n", nSql, zSql, nNanosec);
|
utf8_printf(p->traceOut, "%.*s; -- %lld ns\n", (int)nSql, zSql, nNanosec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11609,7 +11610,7 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
|
|||||||
const char *zBegin = shellState.wasm.zPos;
|
const char *zBegin = shellState.wasm.zPos;
|
||||||
const char *z = zBegin;
|
const char *z = zBegin;
|
||||||
char *zLine = 0;
|
char *zLine = 0;
|
||||||
int nZ = 0;
|
i64 nZ = 0;
|
||||||
|
|
||||||
UNUSED_PARAMETER(in);
|
UNUSED_PARAMETER(in);
|
||||||
UNUSED_PARAMETER(isContinuation);
|
UNUSED_PARAMETER(isContinuation);
|
||||||
@@ -11625,7 +11626,7 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
|
|||||||
shellState.wasm.zPos = z;
|
shellState.wasm.zPos = z;
|
||||||
zLine = realloc(zPrior, nZ+1);
|
zLine = realloc(zPrior, nZ+1);
|
||||||
shell_check_oom(zLine);
|
shell_check_oom(zLine);
|
||||||
memcpy(zLine, zBegin, (size_t)nZ);
|
memcpy(zLine, zBegin, nZ);
|
||||||
zLine[nZ] = 0;
|
zLine[nZ] = 0;
|
||||||
return zLine;
|
return zLine;
|
||||||
}
|
}
|
||||||
@@ -11643,12 +11644,12 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
|
|||||||
static int process_input(ShellState *p){
|
static int process_input(ShellState *p){
|
||||||
char *zLine = 0; /* A single input line */
|
char *zLine = 0; /* A single input line */
|
||||||
char *zSql = 0; /* Accumulated SQL text */
|
char *zSql = 0; /* Accumulated SQL text */
|
||||||
int nLine; /* Length of current line */
|
i64 nLine; /* Length of current line */
|
||||||
int nSql = 0; /* Bytes of zSql[] used */
|
i64 nSql = 0; /* Bytes of zSql[] used */
|
||||||
int nAlloc = 0; /* Allocated zSql[] space */
|
i64 nAlloc = 0; /* Allocated zSql[] space */
|
||||||
int rc; /* Error code */
|
int rc; /* Error code */
|
||||||
int errCnt = 0; /* Number of errors seen */
|
int errCnt = 0; /* Number of errors seen */
|
||||||
int startline = 0; /* Line number for start of current input */
|
i64 startline = 0; /* Line number for start of current input */
|
||||||
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
|
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
|
||||||
|
|
||||||
if( p->inputNesting==MAX_INPUT_NESTING ){
|
if( p->inputNesting==MAX_INPUT_NESTING ){
|
||||||
@@ -11698,7 +11699,7 @@ static int process_input(ShellState *p){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* No single-line dispositions remain; accumulate line(s). */
|
/* No single-line dispositions remain; accumulate line(s). */
|
||||||
nLine = strlen30(zLine);
|
nLine = strlen(zLine);
|
||||||
if( nSql+nLine+2>=nAlloc ){
|
if( nSql+nLine+2>=nAlloc ){
|
||||||
/* Grow buffer by half-again increments when big. */
|
/* Grow buffer by half-again increments when big. */
|
||||||
nAlloc = nSql+(nSql>>1)+nLine+100;
|
nAlloc = nSql+(nSql>>1)+nLine+100;
|
||||||
@@ -11706,7 +11707,7 @@ static int process_input(ShellState *p){
|
|||||||
shell_check_oom(zSql);
|
shell_check_oom(zSql);
|
||||||
}
|
}
|
||||||
if( nSql==0 ){
|
if( nSql==0 ){
|
||||||
int i;
|
i64 i;
|
||||||
for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
|
for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
|
||||||
assert( nAlloc>0 && zSql!=0 );
|
assert( nAlloc>0 && zSql!=0 );
|
||||||
memcpy(zSql, zLine+i, nLine+1-i);
|
memcpy(zSql, zLine+i, nLine+1-i);
|
||||||
@@ -11806,7 +11807,7 @@ static char *find_home_dir(int clearFlag){
|
|||||||
#endif /* !_WIN32_WCE */
|
#endif /* !_WIN32_WCE */
|
||||||
|
|
||||||
if( home_dir ){
|
if( home_dir ){
|
||||||
int n = strlen30(home_dir) + 1;
|
i64 n = strlen(home_dir) + 1;
|
||||||
char *z = malloc( n );
|
char *z = malloc( n );
|
||||||
if( z ) memcpy(z, home_dir, n);
|
if( z ) memcpy(z, home_dir, n);
|
||||||
home_dir = z;
|
home_dir = z;
|
||||||
@@ -12098,9 +12099,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
|||||||
argv = argvToFree + argc;
|
argv = argvToFree + argc;
|
||||||
for(i=0; i<argc; i++){
|
for(i=0; i<argc; i++){
|
||||||
char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
|
char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
|
||||||
int n;
|
i64 n;
|
||||||
shell_check_oom(z);
|
shell_check_oom(z);
|
||||||
n = (int)strlen(z);
|
n = strlen(z);
|
||||||
argv[i] = malloc( n+1 );
|
argv[i] = malloc( n+1 );
|
||||||
shell_check_oom(argv[i]);
|
shell_check_oom(argv[i]);
|
||||||
memcpy(argv[i], z, n+1);
|
memcpy(argv[i], z, n+1);
|
||||||
|
|||||||
Reference in New Issue
Block a user