1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-05 04:30:38 +03:00

In shell, in shell_exec() logic, use type info if available when

outputting in "insert" mode for other types in addition to blobs.
Changed shell_exec() to use sqlite_prepare_v2().  Ticket [72adc99de9].

FossilOrigin-Name: ab99faca6ce57a5e37405dfc8dc55d149cf3f8a3
This commit is contained in:
shane
2009-10-22 18:12:58 +00:00
parent 626a6e4aa2
commit ad6b8d073d
3 changed files with 14 additions and 9 deletions

View File

@@ -1647,8 +1647,13 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
for(i=0; i<nArg; i++){
char *zSep = i>0 ? ",": "";
if( azArg[i]==0 ){
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
fprintf(p->out,"%sNULL",zSep);
}else if( aiType && aiType[i]==SQLITE_TEXT ){
if( zSep[0] ) fprintf(p->out,"%s",zSep);
output_quoted_string(p->out, azArg[i]);
}else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){
fprintf(p->out,"%s%s",zSep, azArg[i]);
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
int nBlob = sqlite3_column_bytes(p->pStmt, i);
@@ -1830,7 +1835,7 @@ static int shell_exec(
*pzErrMsg = NULL;
}
rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( (SQLITE_OK != rc) || !pStmt ){
if( pzErrMsg ){
*pzErrMsg = save_err_msg(db);