-C When\sthe\sresult\sof\sa\ssubquery\sis\sto\sbe\sstored\sin\sa\sregister\sand\sthat\nsubquery\shas\san\sORDER\sBY\sclause\sand\san\sOFFSET,\sNULL\sout\sthe\sdestination\nregister\sbefore\sstarting\sthe\sORDER\sBY\sso\sthat\sthe\sregister\swill\sbe\sset\ncorrectly\seven\sif\sthe\sOFFSET\sis\slarger\sthan\sthe\snumber\sof\soutput\srows.\nFix\sfor\sthe\sproblem\sreported\sin\n[forum:/forumpost/0ec80f12d02acb3f|forum\spost\s0ec80f12d02acb3f].
-D 2022-01-12T20:31:14.514
+C Add\s--schema\sS\soption\sto\s.import
+D 2022-01-13T21:22:54.666
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/resolve.c 359bc0e445d427583d2ab6110433a5dc777f64a0ecdf8d24826d8b475233ead9
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c a4a23a70f0a24a1103ac9698f6be181a6ec7ff6c19e03e8899c43cb6d2af09d6
-F src/shell.c.in f5111900d646a07da18e6438d57be20f112397daba6bfc85b117a0da586e55da
+F src/shell.c.in 851ce2b310888c68f3f66d876b7392cc822f0cb0e316b1a89997abb1d7ec67f0
F src/sqlite.h.in a5e0d6bd47e67aabf1475986d36bdcc7bfa9e06566790ebf8e3aa7fa551c9f99
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 01eb85e4f2759a5ee79c183f4b2877889d4ffdc49d27ae74529c9579e3c8c0ef
F test/shell2.test f00a0501c00583cbc46f7510e1d713366326b2b3e63d06d15937284171a8787c
F test/shell3.test cb4b835a901742c9719437a89171172ecc4a8823ad97349af8e4e841e6f82566
F test/shell4.test 3ed6c4b42fd695efcbc25d69ef759dbb15855ca8e52ba6c5ee076f8b435f48be
-F test/shell5.test 6e4aa0e531dcb8dcf74b7920a2a7442c6712d4dff8422bbc81f768f9dee8a0e3
+F test/shell5.test b85069bfcf3159b225228629ab2c3e69aa923d098fea8ea074b5dcd743522e2c
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 02aaa10f34ab17e76feb7b6f79048309536c0794fcb534b934e06f3daedfeaba
-R 926926c5df28210b2eccf7396e21106e
-U drh
-Z bb0f2b9d8929fd104a37ff3ae2f31816
+P 9282bcde301cee2a5c3c068b5b0b7ce992c155ece894413a6a9a51a81e4133fd
+R 85600e55f5465c0d7b90f18f16da5617
+U larrybr
+Z 49bd76acfcc3b273011e69ab0fa8281f
# Remove this line to create a well-formed Fossil manifest.
-9282bcde301cee2a5c3c068b5b0b7ce992c155ece894413a6a9a51a81e4133fd
\ No newline at end of file
+38d9dbca166078013a44214c88805fc7cca578976ceed9fc62f5159a38ec96a7
\ No newline at end of file
" --ascii Use \\037 and \\036 as column and row separators",
" --csv Use , and \\n as column and row separators",
" --skip N Skip the first N rows of input",
+ " --schema S Target table to be S.TABLE",
" -v \"Verbose\" - increase auxiliary output",
" Notes:",
" * If TABLE does not exist, it is created. The first row of input",
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
char *zTable = 0; /* Insert data into this table */
+ char *zSchema = "main"; /* within this schema */
char *zFile = 0; /* Name of file to extra content from */
sqlite3_stmt *pStmt = NULL; /* A statement */
int nCol; /* Number of columns in the table */
}
}else if( strcmp(z,"-v")==0 ){
eVerbose++;
+ }else if( strcmp(z,"-schema")==0 && i<nArg-1 ){
+ zSchema = azArg[++i];
}else if( strcmp(z,"-skip")==0 && i<nArg-1 ){
nSkip = integerValue(azArg[++i]);
}else if( strcmp(z,"-ascii")==0 ){
import_cleanup(&sCtx);
goto meta_command_exit;
}
+ /* Below, resources must be freed before exit. */
if( eVerbose>=2 || (eVerbose>=1 && useOutputMode) ){
char zSep[2];
zSep[1] = 0;
while( (nSkip--)>0 ){
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
}
- zSql = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
+ zSql = sqlite3_mprintf("SELECT * FROM %s.\"%w\"", zSchema, zTable);
if( zSql==0 ){
import_cleanup(&sCtx);
shell_out_of_memory();
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 \"%w\"", zTable);
+ char *zCreate = sqlite3_mprintf("CREATE TABLE %s.\"%w\"", zSchema,zTable);
char cSep = '(';
while( xRead(&sCtx) ){
zCreate = sqlite3_mprintf("%z%c\n \"%w\" TEXT", zCreate, cSep, sCtx.z);
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
sqlite3_free(zCreate);
if( rc ){
- utf8_printf(stderr, "CREATE TABLE \"%s\"(...) failed: %s\n", zTable,
- sqlite3_errmsg(p->db));
+ utf8_printf(stderr, "CREATE TABLE %s.\"%s\"(...) failed: %s\n",
+ zSchema, zTable, sqlite3_errmsg(p->db));
import_cleanup(&sCtx);
rc = 1;
goto meta_command_exit;
import_cleanup(&sCtx);
shell_out_of_memory();
}
- sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
+ sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s.\"%w\" VALUES(?",
+ zSchema, zTable);
j = strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
forcedelete shell5.csv
set in [open shell5.csv w]
close $in
- set res [catchcmd "test.db" {.import shell5.csv t1
-SELECT COUNT(*) FROM t1;}]
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
} {0 0}
# import file with 1 row, 1 column (expecting 2 cols)
set in [open shell5.csv w]
puts $in "1"
close $in
- set res [catchcmd "test.db" {.import shell5.csv t1}]
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1}]
} {1 {shell5.csv:1: expected 2 columns but found 1 - filling the rest with NULL}}
# import file with 1 row, 3 columns (expecting 2 cols)
set in [open shell5.csv w]
puts $in "1|2|3"
close $in
- set res [catchcmd "test.db" {.import shell5.csv t1}]
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import --schema test shell5.csv t1}]
} {1 {shell5.csv:1: expected 2 columns but found 3 - extras ignored}}
# import file with 1 row, 2 columns
puts $in "2|3"
puts $in "3|4"
close $in
- set res [catchcmd "test.db" {.import shell5.csv t1
-SELECT COUNT(*) FROM t1;}]
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.import -schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
} {0 3}
# import file with 1 row, 2 columns, using a comma
set in [open shell5.csv w]
puts $in "4,5"
close $in
- set res [catchcmd "test.db" {.separator ,
-.import shell5.csv t1
-SELECT COUNT(*) FROM t1;}]
+ set res [catchcmd ":memory:" {ATTACH 'test.db' AS test;
+.separator ,
+.import --schema test shell5.csv t1
+SELECT COUNT(*) FROM test.t1;}]
} {0 4}
# import file with 1 row, 2 columns, text data