diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 90445c9cf..b0f3b02dc 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8836,6 +8836,7 @@ static int do_meta_command(char *zLine, ShellState *p){ int needCommit; /* True to COMMIT or ROLLBACK at end */ int nSep; /* Number of bytes in p->colSeparator[] */ char *zSql; /* An SQL statement */ + char *zFullTabName; /* Table name with schema if applicable */ ImportCtx sCtx; /* Reader context */ char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */ int eVerbose = 0; /* Larger for more console output */ @@ -8979,12 +8980,12 @@ static int do_meta_command(char *zLine, ShellState *p){ while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){} } if( zSchema!=0 ){ - zSchema = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable); + zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable); }else{ - zSchema = sqlite3_mprintf("\"%w\"", zTable); + zFullTabName = sqlite3_mprintf("\"%w\"", zTable); } - zSql = sqlite3_mprintf("SELECT * FROM %s", zSchema); - if( zSql==0 || zSchema==0 ){ + zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName); + if( zSql==0 || zFullTabName==0 ){ import_cleanup(&sCtx); shell_out_of_memory(); } @@ -8992,7 +8993,7 @@ static int do_meta_command(char *zLine, ShellState *p){ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */ if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){ - char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zSchema); + char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName); sqlite3 *dbCols = 0; char *zRenames = 0; char *zColDefs; @@ -9013,7 +9014,7 @@ static int do_meta_command(char *zLine, ShellState *p){ import_fail: sqlite3_free(zCreate); sqlite3_free(zSql); - sqlite3_free(zSchema); + sqlite3_free(zFullTabName); import_cleanup(&sCtx); rc = 1; goto meta_command_exit; @@ -9046,7 +9047,7 @@ static int do_meta_command(char *zLine, ShellState *p){ import_cleanup(&sCtx); shell_out_of_memory(); } - sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zSchema); + sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName); j = strlen30(zSql); for(i=1; i<nCol; i++){ zSql[j++] = ','; @@ -9064,7 +9065,7 @@ static int do_meta_command(char *zLine, ShellState *p){ goto import_fail; } sqlite3_free(zSql); - sqlite3_free(zSchema); + sqlite3_free(zFullTabName); needCommit = sqlite3_get_autocommit(p->db); if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0); do{ |