------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Merge\sthe\sMD5\schecksum\slogic\sinto\sthe\sTCL\sinterface.\s\sThis\sfacilitates\sbuilding\na\stclsh\sthat\scontains\sboth\sSQLite\sand\sMD5.\s\sThe\splan\sis\sto\suse\sthis\naugmented\stclsh\sto\shelp\sbuild\sthe\sdocumentation.
-D 2009-10-22T20:52:05
+C In\sshell,\sreworked\s.header\sand\s.echo\shandling.\s\s\s\nUpdated\sshell_exec()\sto\s(really)\shandle\smultiple\sstatements.\nTickets\s[72adc99de9],\s[7b61b6c6ce],\sand\s[eb620916be].
+D 2009-10-22T21:23:35
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a77dfde96ad86aafd3f71651a4333a104debe86a
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/resolve.c 3ac31c7181fab03732125fdedf7c2091a5c07f1b
F src/rowset.c c64dafba1f9fd876836c8db8682966b9d197eb1f
F src/select.c cbe366a0ce114856e66f5daf0f848d7c48a88298
-F src/shell.c 5d875ff501a361459fb3b7750af7818298acb515
+F src/shell.c 3a2b0649426d75b5cd2937ed90d06b25951a91e4
F src/sqlite.h.in 5853e42a4066a6c9c3bf6592a9d57d0012bfdb90
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h 3b00a3ce79e60c5a47c342b738c8b75013f3ec84
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 9854ad00aed08793ae7ba3c2cfbab7a2dba4dcb8
-R ff5c7263b704c24b2617ea3d38e8b0a4
-U drh
-Z beec7ddcfaa2c60bb6e07c180674b0ac
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFK4MX4oxKgR168RlERArbdAJ90lkW1Q+8Lz1nMdSvuEiSBFrB0vgCgh6mI
-NrvEz/WTtlUC3GfFZQ78MLs=
-=xACK
------END PGP SIGNATURE-----
+P a024c0a85b6f2288c455a7192f6ca7a8493b621a
+R 3ab26891a50ecbe8d9dce9e787f45010
+U shane
+Z 313314dc4aa5889bc53b3806bff86b7f
static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){
int i;
struct callback_data *p = (struct callback_data*)pArg;
+
+ if( p->echoOn && p->cnt==0 && p->pStmt){
+ printf("%s\n", sqlite3_sql(p->pStmt));
+ }
+
switch( p->mode ){
case MODE_Line: {
int w = 5;
break;
}
case MODE_Insert: {
+ p->cnt++;
if( azArg==0 ) break;
fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
for(i=0; i<nArg; i++){
char **pzErrMsg /* Error msg written here */
){
sqlite3_stmt *pStmt = NULL;
- int rc, rc2;
+ int rc = SQLITE_OK;
+ int rc2;
+ const char *zLeftover; /* Tail of unprocessed SQL */
if( pzErrMsg ){
*pzErrMsg = NULL;
}
- rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
- if( (SQLITE_OK != rc) || !pStmt ){
- if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db);
- }
- }else{
- /* perform the first step. this will tell us if we
- ** have a result set or not and how wide it is.
- */
- rc = sqlite3_step(pStmt);
- /* if we have a result set... */
- if( SQLITE_ROW == rc ){
- /* if callback... */
- if( xCallback ){
- /* allocate space for col name ptr, value ptr, and type */
- int nCol = sqlite3_column_count(pStmt);
- void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1);
- if( !pData ){
- rc = SQLITE_NOMEM;
- }else{
- char **azCols = (char **)pData; /* Names of result columns */
- char **azVals = &azCols[nCol]; /* Results */
- int *aiTypes = (int *)&azVals[nCol]; /* Result types */
- int i;
- assert(sizeof(int) <= sizeof(char *));
- /* save off ptrs to column names */
- for(i=0; i<nCol; i++){
- azCols[i] = (char *)sqlite3_column_name(pStmt, i);
- }
- /* save off the prepared statment handle */
- if( pArg ){
- pArg->pStmt = pStmt;
- }
- do{
- /* extract the data and data types */
+ while( zSql[0] && (SQLITE_OK == rc) ){
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
+ if( SQLITE_OK != rc ){
+ if( pzErrMsg ){
+ *pzErrMsg = save_err_msg(db);
+ }
+ }else{
+ if( !pStmt ){
+ /* this happens for a comment or white-space */
+ zSql = zLeftover;
+ while( isspace(zSql[0]) ) zSql++;
+ continue;
+ }
+
+ /* perform the first step. this will tell us if we
+ ** have a result set or not and how wide it is.
+ */
+ rc = sqlite3_step(pStmt);
+ /* if we have a result set... */
+ if( SQLITE_ROW == rc ){
+ /* if we have a callback... */
+ if( xCallback ){
+ /* allocate space for col name ptr, value ptr, and type */
+ int nCol = sqlite3_column_count(pStmt);
+ void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1);
+ if( !pData ){
+ rc = SQLITE_NOMEM;
+ }else{
+ char **azCols = (char **)pData; /* Names of result columns */
+ char **azVals = &azCols[nCol]; /* Results */
+ int *aiTypes = (int *)&azVals[nCol]; /* Result types */
+ int i;
+ assert(sizeof(int) <= sizeof(char *));
+ /* save off ptrs to column names */
for(i=0; i<nCol; i++){
- azVals[i] = (char *)sqlite3_column_text(pStmt, i);
- aiTypes[i] = sqlite3_column_type(pStmt, i);
- if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
- rc = SQLITE_NOMEM;
- break; /* from for */
- }
- } /* end for */
-
- /* if data and types extracted successfully... */
- if( SQLITE_ROW == rc ){
- /* call the supplied callback with the result row data */
- if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){
- rc = SQLITE_ABORT;
- }else{
- rc = sqlite3_step(pStmt);
+ azCols[i] = (char *)sqlite3_column_name(pStmt, i);
+ }
+ /* save off the prepared statment handle and reset row count */
+ if( pArg ){
+ pArg->pStmt = pStmt;
+ pArg->cnt = 0;
+ }
+ do{
+ /* extract the data and data types */
+ for(i=0; i<nCol; i++){
+ azVals[i] = (char *)sqlite3_column_text(pStmt, i);
+ aiTypes[i] = sqlite3_column_type(pStmt, i);
+ if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
+ rc = SQLITE_NOMEM;
+ break; /* from for */
+ }
+ } /* end for */
+
+ /* if data and types extracted successfully... */
+ if( SQLITE_ROW == rc ){
+ /* call the supplied callback with the result row data */
+ if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){
+ rc = SQLITE_ABORT;
+ }else{
+ rc = sqlite3_step(pStmt);
+ }
}
+ } while( SQLITE_ROW == rc );
+ sqlite3_free(pData);
+ if( pArg ){
+ pArg->pStmt = NULL;
}
- } while( SQLITE_ROW == rc );
- sqlite3_free(pData);
- if( pArg ){
- pArg->pStmt = NULL;
}
+ }else{
+ do{
+ rc = sqlite3_step(pStmt);
+ } while( rc == SQLITE_ROW );
+ }
+ }
+
+ /* if the last sqlite3_step() didn't complete successfully... */
+ if( (SQLITE_OK != rc) && (SQLITE_DONE != rc) ){
+ if( pzErrMsg ){
+ *pzErrMsg = save_err_msg(db);
}
}else{
- do{
- rc = sqlite3_step(pStmt);
- } while( rc == SQLITE_ROW );
+ rc = SQLITE_OK;
}
- }
- /* if the last sqlite3_step() didn't complete successfully... */
- if( (SQLITE_OK != rc) && (SQLITE_DONE != rc) ){
- if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db);
+ rc2 = sqlite3_finalize(pStmt);
+ /* if the last sqlite3_finalize() didn't complete successfully
+ ** AND we don't have a save error from sqlite3_step ... */
+ if( (SQLITE_OK != rc2) && (SQLITE_OK == rc) ){
+ rc = rc2;
+ if( pzErrMsg ){
+ *pzErrMsg = save_err_msg(db);
+ }
}
- }else{
- rc = SQLITE_OK;
- }
- rc2 = sqlite3_finalize(pStmt);
- /* if the last sqlite3_finalize() didn't complete successfully
- ** AND we don't have a save error from sqlite3_step ... */
- if( (SQLITE_OK != rc2) && (SQLITE_OK == rc) ){
- rc = rc2;
- if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db);
+ if( SQLITE_OK == rc ){
+ zSql = zLeftover;
+ while( isspace(zSql[0]) ) zSql++;
}
}
- }
+ } /* end while */
return rc;
}
seenInterrupt = 0;
}
lineno++;
- if( p->echoOn ) printf("%s\n", zLine);
if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;
if( zLine && zLine[0]=='.' && nSql==0 ){
+ if( p->echoOn ) printf("%s\n", zLine);
rc = do_meta_command(zLine, p);
if( rc==2 ){
break;