mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix the .crnl command in the shell so that it does not get undone by
calls to print a quoted string or CSV output. FossilOrigin-Name: 6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5
This commit is contained in:
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
|||||||
C Allow\sexpressions\swith\ssubtypes\sto\sbe\sread\sfrom\sindexes\sunless\sthey\sare\nbeing\sused\sas\sdirect\sor\sindirect\sparameters\sto\sSQLITE_SUBTYPE\sfunctions.
|
C Fix\sthe\s.crnl\scommand\sin\sthe\sshell\sso\sthat\sit\sdoes\snot\sget\sundone\sby\ncalls\sto\sprint\sa\squoted\sstring\sor\sCSV\soutput.
|
||||||
D 2024-10-08T10:10:42.057
|
D 2024-10-08T14:07:28.260
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
|||||||
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
|
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
|
||||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||||
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
|
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
|
||||||
F src/shell.c.in 981efe98f98a983c1d0193d18528eb2d765207c0c82b67b610be60f17995a43e
|
F src/shell.c.in 188b1fe5e403e8e0638e0aa1151a95d47e841ddaf0545973cae09e4a6cef4d98
|
||||||
F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e
|
F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e
|
||||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||||
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
||||||
@ -2216,9 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5
|
P 39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8
|
||||||
R 4f5fad7a5b3f0800af84dc5d2cb9639f
|
R f65d905956fc73a7bb20b3c2e0376b8f
|
||||||
T +closed f150c3c5b898975b1f83d61fa589753449a48f8a0007e8e167dbd702528197c5
|
|
||||||
U drh
|
U drh
|
||||||
Z d4cafc45e7a2f93bf4c10b241262518d
|
Z b2ad2cadf0ade220cb843ebb395ae876
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8
|
6b932337c8dee3e52b472a38984e91b5091f3d90c41ac1cc171fa4149cc491c5
|
||||||
|
@ -1448,6 +1448,7 @@ struct ShellState {
|
|||||||
u8 bSafeMode; /* True to prohibit unsafe operations */
|
u8 bSafeMode; /* True to prohibit unsafe operations */
|
||||||
u8 bSafeModePersist; /* The long-term value of bSafeMode */
|
u8 bSafeModePersist; /* The long-term value of bSafeMode */
|
||||||
u8 eRestoreState; /* See comments above doAutoDetectRestore() */
|
u8 eRestoreState; /* See comments above doAutoDetectRestore() */
|
||||||
|
u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */
|
||||||
ColModeOpts cmOpts; /* Option values affecting columnar mode output */
|
ColModeOpts cmOpts; /* Option values affecting columnar mode output */
|
||||||
unsigned statsOn; /* True to display memory stats before each finalize */
|
unsigned statsOn; /* True to display memory stats before each finalize */
|
||||||
unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
|
unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
|
||||||
@ -1851,6 +1852,19 @@ static void outputModePop(ShellState *p){
|
|||||||
memcpy(p->rowSeparator, p->rowSepPrior, sizeof(p->rowSeparator));
|
memcpy(p->rowSeparator, p->rowSepPrior, sizeof(p->rowSeparator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Set output mode to text or binary for Windows.
|
||||||
|
*/
|
||||||
|
static void setCrnlMode(ShellState *p){
|
||||||
|
#ifdef _WIN32
|
||||||
|
if( p->crnlMode ){
|
||||||
|
sqlite3_fsetmode(p->out, _O_TEXT);
|
||||||
|
}else{
|
||||||
|
sqlite3_fsetmode(p->out, _O_BINARY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Output the given string as a hex-encoded blob (eg. X'1234' )
|
** Output the given string as a hex-encoded blob (eg. X'1234' )
|
||||||
*/
|
*/
|
||||||
@ -1901,9 +1915,10 @@ static const char *unused_string(
|
|||||||
**
|
**
|
||||||
** See also: output_quoted_escaped_string()
|
** See also: output_quoted_escaped_string()
|
||||||
*/
|
*/
|
||||||
static void output_quoted_string(FILE *out, const char *z){
|
static void output_quoted_string(ShellState *p, const char *z){
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
|
FILE *out = p->out;
|
||||||
sqlite3_fsetmode(out, _O_BINARY);
|
sqlite3_fsetmode(out, _O_BINARY);
|
||||||
if( z==0 ) return;
|
if( z==0 ) return;
|
||||||
for(i=0; (c = z[i])!=0 && c!='\''; i++){}
|
for(i=0; (c = z[i])!=0 && c!='\''; i++){}
|
||||||
@ -1929,7 +1944,7 @@ static void output_quoted_string(FILE *out, const char *z){
|
|||||||
}
|
}
|
||||||
sqlite3_fputs("'", out);
|
sqlite3_fputs("'", out);
|
||||||
}
|
}
|
||||||
sqlite3_fsetmode(out, _O_TEXT);
|
setCrnlMode(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1941,9 +1956,10 @@ static void output_quoted_string(FILE *out, const char *z){
|
|||||||
** This is like output_quoted_string() but with the addition of the \r\n
|
** This is like output_quoted_string() but with the addition of the \r\n
|
||||||
** escape mechanism.
|
** escape mechanism.
|
||||||
*/
|
*/
|
||||||
static void output_quoted_escaped_string(FILE *out, const char *z){
|
static void output_quoted_escaped_string(ShellState *p, const char *z){
|
||||||
int i;
|
int i;
|
||||||
char c;
|
char c;
|
||||||
|
FILE *out = p->out;
|
||||||
sqlite3_fsetmode(out, _O_BINARY);
|
sqlite3_fsetmode(out, _O_BINARY);
|
||||||
for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
|
for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
|
||||||
if( c==0 ){
|
if( c==0 ){
|
||||||
@ -1996,7 +2012,7 @@ static void output_quoted_escaped_string(FILE *out, const char *z){
|
|||||||
sqlite3_fprintf(out, ",'%s',char(10))", zNL);
|
sqlite3_fprintf(out, ",'%s',char(10))", zNL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3_fsetmode(stdout, _O_TEXT);
|
setCrnlMode(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2793,7 +2809,7 @@ static int shell_callback(
|
|||||||
}
|
}
|
||||||
sqlite3_fputs(p->rowSeparator, p->out);
|
sqlite3_fputs(p->rowSeparator, p->out);
|
||||||
}
|
}
|
||||||
sqlite3_fsetmode(p->out, _O_TEXT);
|
setCrnlMode(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MODE_Insert: {
|
case MODE_Insert: {
|
||||||
@ -2821,9 +2837,9 @@ static int shell_callback(
|
|||||||
sqlite3_fputs("NULL", p->out);
|
sqlite3_fputs("NULL", p->out);
|
||||||
}else if( aiType && aiType[i]==SQLITE_TEXT ){
|
}else if( aiType && aiType[i]==SQLITE_TEXT ){
|
||||||
if( ShellHasFlag(p, SHFLG_Newlines) ){
|
if( ShellHasFlag(p, SHFLG_Newlines) ){
|
||||||
output_quoted_string(p->out, azArg[i]);
|
output_quoted_string(p, azArg[i]);
|
||||||
}else{
|
}else{
|
||||||
output_quoted_escaped_string(p->out, azArg[i]);
|
output_quoted_escaped_string(p, azArg[i]);
|
||||||
}
|
}
|
||||||
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
|
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
|
||||||
sqlite3_fputs(azArg[i], p->out);
|
sqlite3_fputs(azArg[i], p->out);
|
||||||
@ -2852,9 +2868,9 @@ static int shell_callback(
|
|||||||
}else if( isNumber(azArg[i], 0) ){
|
}else if( isNumber(azArg[i], 0) ){
|
||||||
sqlite3_fputs(azArg[i], p->out);
|
sqlite3_fputs(azArg[i], p->out);
|
||||||
}else if( ShellHasFlag(p, SHFLG_Newlines) ){
|
}else if( ShellHasFlag(p, SHFLG_Newlines) ){
|
||||||
output_quoted_string(p->out, azArg[i]);
|
output_quoted_string(p, azArg[i]);
|
||||||
}else{
|
}else{
|
||||||
output_quoted_escaped_string(p->out, azArg[i]);
|
output_quoted_escaped_string(p, azArg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3_fputs(");\n", p->out);
|
sqlite3_fputs(");\n", p->out);
|
||||||
@ -2907,7 +2923,7 @@ static int shell_callback(
|
|||||||
if( p->cnt==0 && p->showHeader ){
|
if( p->cnt==0 && p->showHeader ){
|
||||||
for(i=0; i<nArg; i++){
|
for(i=0; i<nArg; i++){
|
||||||
if( i>0 ) sqlite3_fputs(p->colSeparator, p->out);
|
if( i>0 ) sqlite3_fputs(p->colSeparator, p->out);
|
||||||
output_quoted_string(p->out, azCol[i]);
|
output_quoted_string(p, azCol[i]);
|
||||||
}
|
}
|
||||||
sqlite3_fputs(p->rowSeparator, p->out);
|
sqlite3_fputs(p->rowSeparator, p->out);
|
||||||
}
|
}
|
||||||
@ -2917,7 +2933,7 @@ static int shell_callback(
|
|||||||
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
|
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
|
||||||
sqlite3_fputs("NULL", p->out);
|
sqlite3_fputs("NULL", p->out);
|
||||||
}else if( aiType && aiType[i]==SQLITE_TEXT ){
|
}else if( aiType && aiType[i]==SQLITE_TEXT ){
|
||||||
output_quoted_string(p->out, azArg[i]);
|
output_quoted_string(p, azArg[i]);
|
||||||
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
|
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
|
||||||
sqlite3_fputs(azArg[i], p->out);
|
sqlite3_fputs(azArg[i], p->out);
|
||||||
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
|
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
|
||||||
@ -2932,7 +2948,7 @@ static int shell_callback(
|
|||||||
}else if( isNumber(azArg[i], 0) ){
|
}else if( isNumber(azArg[i], 0) ){
|
||||||
sqlite3_fputs(azArg[i], p->out);
|
sqlite3_fputs(azArg[i], p->out);
|
||||||
}else{
|
}else{
|
||||||
output_quoted_string(p->out, azArg[i]);
|
output_quoted_string(p, azArg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3_fputs(p->rowSeparator, p->out);
|
sqlite3_fputs(p->rowSeparator, p->out);
|
||||||
@ -8429,7 +8445,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
|||||||
|
|
||||||
/* Undocumented. Legacy only. See "crnl" below */
|
/* Undocumented. Legacy only. See "crnl" below */
|
||||||
if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){
|
if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){
|
||||||
eputz("The \".binary\" command is deprecated. Use \".crnl\" instead.\n");
|
eputz("The \".binary\" command is deprecated.\n");
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}else
|
}else
|
||||||
|
|
||||||
@ -8561,11 +8577,8 @@ static int do_meta_command(char *zLine, ShellState *p){
|
|||||||
sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out);
|
sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out);
|
||||||
#else
|
#else
|
||||||
if( nArg==2 ){
|
if( nArg==2 ){
|
||||||
if( booleanValue(azArg[1]) ){
|
p->crnlMode = booleanValue(azArg[1]);
|
||||||
sqlite3_fsetmode(p->out, _O_TEXT);
|
setCrnlMode(p);
|
||||||
}else{
|
|
||||||
sqlite3_fsetmode(p->out, _O_BINARY);
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
eputz("Usage: .crnl on|off\n");
|
eputz("Usage: .crnl on|off\n");
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
Reference in New Issue
Block a user