1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
|
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
|
-
-
-
-
-
+
+
+
+
+
|
/* Allowed values for ShellState.eTraceType
*/
#define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
#define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
#define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
/* Bits in the ShellState.flgProgress variable */
#define PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
#define PROGRESS_RESET 0x02 /* Reset the count when the progres
** callback limit is reached, and for each
** top-level SQL statement */
#define PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
#define SHELL_PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
#define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progres
** callback limit is reached, and for each
** top-level SQL statement */
#define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
/*
** These are the allowed shellFlgs values
*/
#define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
#define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */
#define SHFLG_Backslash 0x00000004 /* The --backslash option is used */
|
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
|
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
|
-
-
+
+
-
+
|
** Progress handler callback.
*/
static int progress_handler(void *pClientData) {
ShellState *p = (ShellState*)pClientData;
p->nProgress++;
if( p->nProgress>=p->mxProgress && p->mxProgress>0 ){
raw_printf(p->out, "Progress limit reached (%u)\n", p->nProgress);
if( p->flgProgress & PROGRESS_RESET ) p->nProgress = 0;
if( p->flgProgress & PROGRESS_ONCE ) p->mxProgress = 0;
if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
if( p->flgProgress & SHELL_PROGRESS_ONCE ) p->mxProgress = 0;
return 1;
}
if( (p->flgProgress & PROGRESS_QUIET)==0 ){
if( (p->flgProgress & SHELL_PROGRESS_QUIET)==0 ){
raw_printf(p->out, "Progress %u\n", p->nProgress);
}
return 0;
}
/*
** This is the callback routine that the shell
|
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
|
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
|
-
+
-
+
-
+
-
+
-
+
-
+
|
utf8_printf(p->out, "%s", azArg[i]);
}
raw_printf(p->out, "\n");
}else
if( c=='p' && n>=3 && strncmp(azArg[0], "progress", n)==0 ){
int i;
int n = 0;
int nn = 0;
p->flgProgress = 0;
p->mxProgress = 0;
p->nProgress = 0;
for(i=1; i<nArg; i++){
const char *z = azArg[i];
if( z[0]=='-' ){
z++;
if( z[0]=='-' ) z++;
if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
p->flgProgress |= PROGRESS_QUIET;
p->flgProgress |= SHELL_PROGRESS_QUIET;
continue;
}
if( strcmp(z,"reset")==0 ){
p->flgProgress |= PROGRESS_RESET;
p->flgProgress |= SHELL_PROGRESS_RESET;
continue;
}
if( strcmp(z,"once")==0 ){
p->flgProgress |= PROGRESS_ONCE;
p->flgProgress |= SHELL_PROGRESS_ONCE;
continue;
}
if( strcmp(z,"limit")==0 ){
if( i+1>=nArg ){
utf8_printf(stderr, "Error: missing argument on --limit\n");
rc = 1;
goto meta_command_exit;
}else{
p->mxProgress = (int)integerValue(azArg[++i]);
}
continue;
}
utf8_printf(stderr, "Error: unknown option: \"%s\"\n", azArg[i]);
rc = 1;
goto meta_command_exit;
}else{
n = (int)integerValue(z);
nn = (int)integerValue(z);
}
}
open_db(p, 0);
sqlite3_progress_handler(p->db, n, progress_handler, p);
sqlite3_progress_handler(p->db, nn, progress_handler, p);
}else
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
if( nArg >= 2) {
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
}
if( nArg >= 3) {
|
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
|
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
|
-
+
|
*/
static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
int rc;
char *zErrMsg = 0;
open_db(p, 0);
if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
if( p->flgProgress & PROGRESS_RESET ) p->nProgress = 0;
if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
BEGIN_TIMER;
rc = shell_exec(p, zSql, &zErrMsg);
END_TIMER;
if( rc || zErrMsg ){
char zPrefix[100];
if( in!=0 || !stdin_is_interactive ){
sqlite3_snprintf(sizeof(zPrefix), zPrefix,
|