1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-03 16:53:36 +03:00

Add the --raw option to the ".read" dot-command of the command-line shell,

to cause the named file to be read and sent directly into sqlite3_exec()
without any interpretation.

FossilOrigin-Name: 09233770b24d69a305556241a6beeb5e4d77c0d7
This commit is contained in:
drh
2016-11-11 04:37:00 +00:00
parent 4360fcea6d
commit c5b86be7db
3 changed files with 47 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
C Take\scare\snot\sto\stry\sto\sgenerate\scode\sfor\sthe\sATTACH\sand\sDETACH\scommands\nif\sthere\swere\ssyntax\serrors\sduring\sparsing.\nFix\sfor\sticket\s[2f1b168ab4d4844]
D 2016-11-11T03:37:24.086
C Add\sthe\s--raw\soption\sto\sthe\s".read"\sdot-command\sof\sthe\scommand-line\sshell,\nto\scause\sthe\snamed\sfile\sto\sbe\sread\sand\ssent\sdirectly\sinto\ssqlite3_exec()\nwithout\sany\sinterpretation.
D 2016-11-11T04:37:00.671
F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e0217f2d35a0448abbe4b066132ae20136e8b408
@@ -388,7 +388,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c 3fac1b2737ea5a724f20b921ac7e259c9be2100b
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c ea3af83e2d0f245fef81ea4cf04cb730ce67f722
F src/shell.c 63e54cfa1c7ec5b70a4c9a86502bc10280c3d5a3
F src/shell.c e77c47b035e7ac79c89ca25fdb4fbc7158a86a20
F src/sqlite.h.in 803f7050f69b2eea573fac219f3c92582c096027
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
@@ -1530,7 +1530,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P b4889588246c33374ff3758e21ccc4ce246380b6
R 26247ef800afdc7745db1d52a3a74bf0
P b0ff183b8ffdbebece06cfea1c6781fc0e8e8547
R 1bc28093103f82773b6175c0eaf36791
U drh
Z bdc6c3a824c3e2f132fc99deec6951e5
Z 12078e4f7b8e85a9a59383108eda95de

View File

@@ -1 +1 @@
b0ff183b8ffdbebece06cfea1c6781fc0e8e8547
09233770b24d69a305556241a6beeb5e4d77c0d7

View File

@@ -4205,12 +4205,43 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
FILE *alt;
if( nArg!=2 ){
raw_printf(stderr, "Usage: .read FILE\n");
char *zFile;
int rawMode = 0;
if( nArg!=2 && nArg!=3 ){
raw_printf(stderr, "Usage: .read [--raw] FILE\n");
rc = 1;
goto meta_command_exit;
}
alt = fopen(azArg[1], "rb");
if( nArg==3 ){
const char *z = azArg[1];
while( z[0]=='-' ) z++;
if( strcmp(z,"raw")==0 ){
rawMode = 1;
}
else{
raw_printf(stderr, "unknown option: \"%s\"\n", azArg[1]);
rc = 1;
goto meta_command_exit;
}
}
zFile = azArg[nArg-1];
if( rawMode ){
char *z = readFile(zFile);
if( z==0 ){
utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
rc = 1;
}else{
char *zErr = 0;
open_db(p, 1);
rc = sqlite3_exec(p->db, z, callback, p, &zErr);
sqlite3_free(z);
if( zErr ){
utf8_printf(stdout, "%s", zErr);
sqlite3_free(zErr);
}
}
}else{
alt = fopen(zFile, "rb");
if( alt==0 ){
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
@@ -4218,6 +4249,7 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = process_input(p, alt);
fclose(alt);
}
}
}else
if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){