| | @@ -350,11 +350,11 @@ |
| 350 | 350 | ** rendering ASCII text in cases where NL-to-CRLF expansion would |
| 351 | 351 | ** not be correct.) |
| 352 | 352 | ** |
| 353 | 353 | ** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT |
| 354 | 354 | ** when appropriate when writing to stdout or stderr. Use O_BINARY |
| 355 | | -** or O_TEXT (depending on things like the .mode and the .crnl setting |
| 355 | +** or O_TEXT (depending on things like the .mode and the .crlf setting |
| 356 | 356 | ** in the CLI, or other context clues in other applications) for all |
| 357 | 357 | ** other output channels. |
| 358 | 358 | ** |
| 359 | 359 | ** The default behavior, if neither of the above is defined is to |
| 360 | 360 | ** use O_U8TEXT when writing to the Windows console (or anything |
| | @@ -14068,10 +14068,70 @@ |
| 14068 | 14068 | } |
| 14069 | 14069 | |
| 14070 | 14070 | return rc; |
| 14071 | 14071 | } |
| 14072 | 14072 | |
| 14073 | +/* |
| 14074 | +** This function tests if the schema of the main database of database handle |
| 14075 | +** db contains an object named zTab. Assuming no error occurs, output parameter |
| 14076 | +** (*pbContains) is set to true if zTab exists, or false if it does not. |
| 14077 | +** |
| 14078 | +** Or, if an error occurs, an SQLite error code is returned. The final value |
| 14079 | +** of (*pbContains) is undefined in this case. |
| 14080 | +*/ |
| 14081 | +static int expertDbContainsObject( |
| 14082 | + sqlite3 *db, |
| 14083 | + const char *zTab, |
| 14084 | + int *pbContains /* OUT: True if object exists */ |
| 14085 | +){ |
| 14086 | + const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?"; |
| 14087 | + sqlite3_stmt *pSql = 0; |
| 14088 | + int rc = SQLITE_OK; |
| 14089 | + int ret = 0; |
| 14090 | + |
| 14091 | + rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0); |
| 14092 | + if( rc==SQLITE_OK ){ |
| 14093 | + sqlite3_bind_text(pSql, 1, zTab, -1, SQLITE_STATIC); |
| 14094 | + if( SQLITE_ROW==sqlite3_step(pSql) ){ |
| 14095 | + ret = 1; |
| 14096 | + } |
| 14097 | + rc = sqlite3_finalize(pSql); |
| 14098 | + } |
| 14099 | + |
| 14100 | + *pbContains = ret; |
| 14101 | + return rc; |
| 14102 | +} |
| 14103 | + |
| 14104 | +/* |
| 14105 | +** Execute SQL command zSql using database handle db. If no error occurs, |
| 14106 | +** set (*pzErr) to NULL and return SQLITE_OK. |
| 14107 | +** |
| 14108 | +** If an error does occur, return an SQLite error code and set (*pzErr) to |
| 14109 | +** point to a buffer containing an English language error message. Except, |
| 14110 | +** if the error message begins with "no such module:", then ignore the |
| 14111 | +** error and return as if the SQL statement had succeeded. |
| 14112 | +** |
| 14113 | +** This is used to copy as much of the database schema as possible while |
| 14114 | +** ignoring any errors related to missing virtual table modules. |
| 14115 | +*/ |
| 14116 | +static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){ |
| 14117 | + int rc = SQLITE_OK; |
| 14118 | + char *zErr = 0; |
| 14119 | + |
| 14120 | + rc = sqlite3_exec(db, zSql, 0, 0, &zErr); |
| 14121 | + if( rc!=SQLITE_OK && zErr ){ |
| 14122 | + int nErr = STRLEN(zErr); |
| 14123 | + if( nErr>=15 && memcmp(zErr, "no such module:", 15)==0 ){ |
| 14124 | + sqlite3_free(zErr); |
| 14125 | + rc = SQLITE_OK; |
| 14126 | + zErr = 0; |
| 14127 | + } |
| 14128 | + } |
| 14129 | + |
| 14130 | + *pzErr = zErr; |
| 14131 | + return rc; |
| 14132 | +} |
| 14073 | 14133 | |
| 14074 | 14134 | static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ |
| 14075 | 14135 | int rc = idxRegisterVtab(p); |
| 14076 | 14136 | sqlite3_stmt *pSchema = 0; |
| 14077 | 14137 | |
| | @@ -14079,26 +14139,33 @@ |
| 14079 | 14139 | ** |
| 14080 | 14140 | ** 1) Add an entry to the p->pTable list, and |
| 14081 | 14141 | ** 2) Create the equivalent virtual table in dbv. |
| 14082 | 14142 | */ |
| 14083 | 14143 | rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg, |
| 14084 | | - "SELECT type, name, sql, 1 FROM sqlite_schema " |
| 14144 | + "SELECT type, name, sql, 1, sql LIKE 'create virtual%' " |
| 14145 | + "FROM sqlite_schema " |
| 14085 | 14146 | "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' " |
| 14086 | 14147 | " UNION ALL " |
| 14087 | | - "SELECT type, name, sql, 2 FROM sqlite_schema " |
| 14148 | + "SELECT type, name, sql, 2, 0 FROM sqlite_schema " |
| 14088 | 14149 | "WHERE type = 'trigger'" |
| 14089 | 14150 | " AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') " |
| 14090 | | - "ORDER BY 4, 1" |
| 14151 | + "ORDER BY 4, 5 DESC, 1" |
| 14091 | 14152 | ); |
| 14092 | 14153 | while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){ |
| 14093 | 14154 | const char *zType = (const char*)sqlite3_column_text(pSchema, 0); |
| 14094 | 14155 | const char *zName = (const char*)sqlite3_column_text(pSchema, 1); |
| 14095 | 14156 | const char *zSql = (const char*)sqlite3_column_text(pSchema, 2); |
| 14157 | + int bVirtual = sqlite3_column_int(pSchema, 4); |
| 14158 | + int bExists = 0; |
| 14096 | 14159 | |
| 14097 | 14160 | if( zType==0 || zName==0 ) continue; |
| 14098 | | - if( zType[0]=='v' || zType[1]=='r' ){ |
| 14099 | | - if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg); |
| 14161 | + rc = expertDbContainsObject(p->dbv, zName, &bExists); |
| 14162 | + if( rc || bExists ) continue; |
| 14163 | + |
| 14164 | + if( zType[0]=='v' || zType[1]=='r' || bVirtual ){ |
| 14165 | + /* A view. Or a trigger on a view. */ |
| 14166 | + if( zSql ) rc = expertSchemaSql(p->dbv, zSql, pzErrmsg); |
| 14100 | 14167 | }else{ |
| 14101 | 14168 | IdxTable *pTab; |
| 14102 | 14169 | rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg); |
| 14103 | 14170 | if( rc==SQLITE_OK ){ |
| 14104 | 14171 | int i; |
| | @@ -14633,16 +14700,22 @@ |
| 14633 | 14700 | |
| 14634 | 14701 | /* Copy the entire schema of database [db] into [dbm]. */ |
| 14635 | 14702 | if( rc==SQLITE_OK ){ |
| 14636 | 14703 | sqlite3_stmt *pSql = 0; |
| 14637 | 14704 | rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, |
| 14638 | | - "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" |
| 14639 | | - " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid" |
| 14705 | + "SELECT sql, name " |
| 14706 | + " FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" |
| 14707 | + " ORDER BY rowid" |
| 14640 | 14708 | ); |
| 14641 | 14709 | while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ |
| 14642 | 14710 | const char *zSql = (const char*)sqlite3_column_text(pSql, 0); |
| 14643 | | - if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg); |
| 14711 | + const char *zName = (const char*)sqlite3_column_text(pSql, 1); |
| 14712 | + int bExists = 0; |
| 14713 | + rc = expertDbContainsObject(pNew->dbm, zName, &bExists); |
| 14714 | + if( rc==SQLITE_OK && zSql && bExists==0 ){ |
| 14715 | + rc = expertSchemaSql(pNew->dbm, zSql, pzErrmsg); |
| 14716 | + } |
| 14644 | 14717 | } |
| 14645 | 14718 | idxFinalize(&rc, pSql); |
| 14646 | 14719 | } |
| 14647 | 14720 | |
| 14648 | 14721 | /* Create the vtab schema */ |
| | @@ -19072,11 +19145,11 @@ |
| 19072 | 19145 | }while( strstr(z,zBuf)!=0 ); |
| 19073 | 19146 | return zBuf; |
| 19074 | 19147 | } |
| 19075 | 19148 | |
| 19076 | 19149 | /* |
| 19077 | | -** Implementation of scalar SQL function "escape_crnl". The argument passed to |
| 19150 | +** Implementation of scalar SQL function "escape_crlf". The argument passed to |
| 19078 | 19151 | ** this function is the output of built-in function quote(). If the first |
| 19079 | 19152 | ** character of the input is "'", indicating that the value passed to quote() |
| 19080 | 19153 | ** was a text value, then this function searches the input for "\n" and "\r" |
| 19081 | 19154 | ** characters and adds a wrapper similar to the following: |
| 19082 | 19155 | ** |
| | @@ -19083,11 +19156,11 @@ |
| 19083 | 19156 | ** replace(replace(<input>, '\n', char(10), '\r', char(13)); |
| 19084 | 19157 | ** |
| 19085 | 19158 | ** Or, if the first character of the input is not "'", then a copy of the input |
| 19086 | 19159 | ** is returned. |
| 19087 | 19160 | */ |
| 19088 | | -static void recoverEscapeCrnl( |
| 19161 | +static void recoverEscapeCrlf( |
| 19089 | 19162 | sqlite3_context *context, |
| 19090 | 19163 | int argc, |
| 19091 | 19164 | sqlite3_value **argv |
| 19092 | 19165 | ){ |
| 19093 | 19166 | const char *zText = (const char*)sqlite3_value_text(argv[0]); |
| | @@ -19298,11 +19371,11 @@ |
| 19298 | 19371 | void (*xFunc)(sqlite3_context*,int,sqlite3_value **); |
| 19299 | 19372 | } aFunc[] = { |
| 19300 | 19373 | { "getpage", 1, recoverGetPage }, |
| 19301 | 19374 | { "page_is_used", 1, recoverPageIsUsed }, |
| 19302 | 19375 | { "read_i32", 2, recoverReadI32 }, |
| 19303 | | - { "escape_crnl", 1, recoverEscapeCrnl }, |
| 19376 | + { "escape_crlf", 1, recoverEscapeCrlf }, |
| 19304 | 19377 | }; |
| 19305 | 19378 | |
| 19306 | 19379 | const int flags = SQLITE_OPEN_URI|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE; |
| 19307 | 19380 | sqlite3 *db = 0; /* New database handle */ |
| 19308 | 19381 | int ii; /* For iterating through aFunc[] */ |
| | @@ -19651,11 +19724,11 @@ |
| 19651 | 19724 | assert( pTab->aCol[ii].iField>=0 && pTab->aCol[ii].iBind>=1 ); |
| 19652 | 19725 | zSql = recoverMPrintf(p, "%z%s%Q", zSql, zSep, pTab->aCol[ii].zCol); |
| 19653 | 19726 | |
| 19654 | 19727 | if( bSql ){ |
| 19655 | 19728 | zBind = recoverMPrintf(p, |
| 19656 | | - "%z%sescape_crnl(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind |
| 19729 | + "%z%sescape_crlf(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind |
| 19657 | 19730 | ); |
| 19658 | 19731 | zSqlSep = "||', '||"; |
| 19659 | 19732 | }else{ |
| 19660 | 19733 | zBind = recoverMPrintf(p, "%z%s?%d", zBind, zSep, pTab->aCol[ii].iBind); |
| 19661 | 19734 | } |
| | @@ -21268,11 +21341,11 @@ |
| 21268 | 21341 | u8 nEqpLevel; /* Depth of the EQP output graph */ |
| 21269 | 21342 | u8 eTraceType; /* SHELL_TRACE_* value for type of trace */ |
| 21270 | 21343 | u8 bSafeMode; /* True to prohibit unsafe operations */ |
| 21271 | 21344 | u8 bSafeModePersist; /* The long-term value of bSafeMode */ |
| 21272 | 21345 | u8 eRestoreState; /* See comments above doAutoDetectRestore() */ |
| 21273 | | - u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */ |
| 21346 | + u8 crlfMode; /* Do NL-to-CRLF translations when enabled (maybe) */ |
| 21274 | 21347 | ColModeOpts cmOpts; /* Option values affecting columnar mode output */ |
| 21275 | 21348 | unsigned statsOn; /* True to display memory stats before each finalize */ |
| 21276 | 21349 | unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */ |
| 21277 | 21350 | int inputNesting; /* Track nesting level of .read and other redirects */ |
| 21278 | 21351 | int outCount; /* Revert to stdout when reaching zero */ |
| | @@ -21449,11 +21522,11 @@ |
| 21449 | 21522 | #define SEP_Column "|" |
| 21450 | 21523 | #define SEP_Row "\n" |
| 21451 | 21524 | #define SEP_Tab "\t" |
| 21452 | 21525 | #define SEP_Space " " |
| 21453 | 21526 | #define SEP_Comma "," |
| 21454 | | -#define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */ |
| 21527 | +#define SEP_CrLf "\r\n" |
| 21455 | 21528 | #define SEP_Unit "\x1F" |
| 21456 | 21529 | #define SEP_Record "\x1E" |
| 21457 | 21530 | |
| 21458 | 21531 | /* |
| 21459 | 21532 | ** Limit input nesting via .read or any other input redirect. |
| | @@ -21534,11 +21607,11 @@ |
| 21534 | 21607 | char *zTempFile = 0; |
| 21535 | 21608 | sqlite3 *db; |
| 21536 | 21609 | char *zCmd = 0; |
| 21537 | 21610 | int bBin; |
| 21538 | 21611 | int rc; |
| 21539 | | - int hasCRNL = 0; |
| 21612 | + int hasCRLF = 0; |
| 21540 | 21613 | FILE *f = 0; |
| 21541 | 21614 | sqlite3_int64 sz; |
| 21542 | 21615 | sqlite3_int64 x; |
| 21543 | 21616 | unsigned char *p = 0; |
| 21544 | 21617 | |
| | @@ -21579,11 +21652,11 @@ |
| 21579 | 21652 | if( bBin ){ |
| 21580 | 21653 | x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f); |
| 21581 | 21654 | }else{ |
| 21582 | 21655 | const char *z = (const char*)sqlite3_value_text(argv[0]); |
| 21583 | 21656 | /* Remember whether or not the value originally contained \r\n */ |
| 21584 | | - if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1; |
| 21657 | + if( z && strstr(z,"\r\n")!=0 ) hasCRLF = 1; |
| 21585 | 21658 | x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f); |
| 21586 | 21659 | } |
| 21587 | 21660 | fclose(f); |
| 21588 | 21661 | f = 0; |
| 21589 | 21662 | if( x!=sz ){ |
| | @@ -21624,11 +21697,11 @@ |
| 21624 | 21697 | } |
| 21625 | 21698 | if( bBin ){ |
| 21626 | 21699 | sqlite3_result_blob64(context, p, sz, sqlite3_free); |
| 21627 | 21700 | }else{ |
| 21628 | 21701 | sqlite3_int64 i, j; |
| 21629 | | - if( hasCRNL ){ |
| 21702 | + if( hasCRLF ){ |
| 21630 | 21703 | /* If the original contains \r\n then do no conversions back to \n */ |
| 21631 | 21704 | }else{ |
| 21632 | 21705 | /* If the file did not originally contain \r\n then convert any new |
| 21633 | 21706 | ** \r\n back into \n */ |
| 21634 | 21707 | p[sz] = 0; |
| | @@ -21669,17 +21742,19 @@ |
| 21669 | 21742 | } |
| 21670 | 21743 | |
| 21671 | 21744 | /* |
| 21672 | 21745 | ** Set output mode to text or binary for Windows. |
| 21673 | 21746 | */ |
| 21674 | | -static void setCrnlMode(ShellState *p){ |
| 21747 | +static void setCrlfMode(ShellState *p){ |
| 21675 | 21748 | #ifdef _WIN32 |
| 21676 | | - if( p->crnlMode ){ |
| 21749 | + if( p->crlfMode ){ |
| 21677 | 21750 | sqlite3_fsetmode(p->out, _O_TEXT); |
| 21678 | 21751 | }else{ |
| 21679 | 21752 | sqlite3_fsetmode(p->out, _O_BINARY); |
| 21680 | 21753 | } |
| 21754 | +#else |
| 21755 | + UNUSED_PARAMETER(p); |
| 21681 | 21756 | #endif |
| 21682 | 21757 | } |
| 21683 | 21758 | |
| 21684 | 21759 | /* |
| 21685 | 21760 | ** Output the given string as a hex-encoded blob (eg. X'1234' ) |
| | @@ -21758,11 +21833,11 @@ |
| 21758 | 21833 | } |
| 21759 | 21834 | z++; |
| 21760 | 21835 | } |
| 21761 | 21836 | sqlite3_fputs("'", out); |
| 21762 | 21837 | } |
| 21763 | | - setCrnlMode(p); |
| 21838 | + setCrlfMode(p); |
| 21764 | 21839 | } |
| 21765 | 21840 | |
| 21766 | 21841 | /* |
| 21767 | 21842 | ** Output the given string as a quoted string using SQL quoting conventions. |
| 21768 | 21843 | ** Additionallly , escape the "\n" and "\r" characters so that they do not |
| | @@ -21826,11 +21901,11 @@ |
| 21826 | 21901 | } |
| 21827 | 21902 | if( nNL ){ |
| 21828 | 21903 | sqlite3_fprintf(out, ",'%s',char(10))", zNL); |
| 21829 | 21904 | } |
| 21830 | 21905 | } |
| 21831 | | - setCrnlMode(p); |
| 21906 | + setCrlfMode(p); |
| 21832 | 21907 | } |
| 21833 | 21908 | |
| 21834 | 21909 | /* |
| 21835 | 21910 | ** Find earliest of chars within s specified in zAny. |
| 21836 | 21911 | ** With ns == ~0, is like strpbrk(s,zAny) and s must be 0-terminated. |
| | @@ -22615,27 +22690,19 @@ |
| 22615 | 22690 | sqlite3_fsetmode(p->out, _O_BINARY); |
| 22616 | 22691 | if( p->cnt++==0 && p->showHeader ){ |
| 22617 | 22692 | for(i=0; i<nArg; i++){ |
| 22618 | 22693 | output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); |
| 22619 | 22694 | } |
| 22620 | | - if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ |
| 22621 | | - sqlite3_fputs("\r\n", p->out); |
| 22622 | | - }else{ |
| 22623 | | - sqlite3_fputs(p->rowSeparator, p->out); |
| 22624 | | - } |
| 22695 | + sqlite3_fputs(p->rowSeparator, p->out); |
| 22625 | 22696 | } |
| 22626 | 22697 | if( nArg>0 ){ |
| 22627 | 22698 | for(i=0; i<nArg; i++){ |
| 22628 | 22699 | output_csv(p, azArg[i], i<nArg-1); |
| 22629 | 22700 | } |
| 22630 | | - if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){ |
| 22631 | | - sqlite3_fputs("\r\n", p->out); |
| 22632 | | - }else{ |
| 22633 | | - sqlite3_fputs(p->rowSeparator, p->out); |
| 22634 | | - } |
| 22701 | + sqlite3_fputs(p->rowSeparator, p->out); |
| 22635 | 22702 | } |
| 22636 | | - setCrnlMode(p); |
| 22703 | + setCrlfMode(p); |
| 22637 | 22704 | break; |
| 22638 | 22705 | } |
| 22639 | 22706 | case MODE_Insert: { |
| 22640 | 22707 | if( azArg==0 ) break; |
| 22641 | 22708 | sqlite3_fprintf(p->out, "INSERT INTO %s",p->zDestTable); |
| | @@ -24589,11 +24656,11 @@ |
| 24589 | 24656 | if( zType==0 ) return 0; |
| 24590 | 24657 | dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0; |
| 24591 | 24658 | noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0; |
| 24592 | 24659 | |
| 24593 | 24660 | if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){ |
| 24594 | | - if( !dataOnly ) sqlite3_fputs("DELETE FROM sqlite_sequence;\n", p->out); |
| 24661 | + /* no-op */ |
| 24595 | 24662 | }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){ |
| 24596 | 24663 | if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out); |
| 24597 | 24664 | }else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){ |
| 24598 | 24665 | return 0; |
| 24599 | 24666 | }else if( dataOnly ){ |
| | @@ -24774,11 +24841,11 @@ |
| 24774 | 24841 | #ifndef SQLITE_SHELL_FIDDLE |
| 24775 | 24842 | ".check GLOB Fail if output since .testcase does not match", |
| 24776 | 24843 | ".clone NEWDB Clone data into NEWDB from the existing database", |
| 24777 | 24844 | #endif |
| 24778 | 24845 | ".connection [close] [#] Open or close an auxiliary database connection", |
| 24779 | | - ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF", |
| 24846 | + ".crlf ?on|off? Whether or not to use \\r\\n line endings", |
| 24780 | 24847 | ".databases List names and files of attached databases", |
| 24781 | 24848 | ".dbconfig ?op? ?val? List or change sqlite3_db_config() options", |
| 24782 | 24849 | #if SQLITE_SHELL_HAVE_RECOVER |
| 24783 | 24850 | ".dbinfo ?DB? Show status information about the database", |
| 24784 | 24851 | #endif |
| | @@ -26255,11 +26322,11 @@ |
| 26255 | 26322 | static void output_redir(ShellState *p, FILE *pfNew){ |
| 26256 | 26323 | if( p->out != stdout ){ |
| 26257 | 26324 | sqlite3_fputs("Output already redirected.\n", stderr); |
| 26258 | 26325 | }else{ |
| 26259 | 26326 | p->out = pfNew; |
| 26260 | | - setCrnlMode(p); |
| 26327 | + setCrlfMode(p); |
| 26261 | 26328 | if( p->mode==MODE_Www ){ |
| 26262 | 26329 | sqlite3_fputs( |
| 26263 | 26330 | "<!DOCTYPE html>\n" |
| 26264 | 26331 | "<HTML><BODY><PRE>\n", |
| 26265 | 26332 | p->out |
| | @@ -26311,11 +26378,11 @@ |
| 26311 | 26378 | } |
| 26312 | 26379 | #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */ |
| 26313 | 26380 | } |
| 26314 | 26381 | p->outfile[0] = 0; |
| 26315 | 26382 | p->out = stdout; |
| 26316 | | - setCrnlMode(p); |
| 26383 | + setCrlfMode(p); |
| 26317 | 26384 | } |
| 26318 | 26385 | #else |
| 26319 | 26386 | # define output_redir(SS,pfO) |
| 26320 | 26387 | # define output_reset(SS) |
| 26321 | 26388 | #endif |
| | @@ -28264,11 +28331,11 @@ |
| 28264 | 28331 | eputz("Usage: .bail on|off\n"); |
| 28265 | 28332 | rc = 1; |
| 28266 | 28333 | } |
| 28267 | 28334 | }else |
| 28268 | 28335 | |
| 28269 | | - /* Undocumented. Legacy only. See "crnl" below */ |
| 28336 | + /* Undocumented. Legacy only. See "crlf" below */ |
| 28270 | 28337 | if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){ |
| 28271 | 28338 | eputz("The \".binary\" command is deprecated.\n"); |
| 28272 | 28339 | rc = 1; |
| 28273 | 28340 | }else |
| 28274 | 28341 | |
| | @@ -28392,18 +28459,22 @@ |
| 28392 | 28459 | eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n"); |
| 28393 | 28460 | rc = 1; |
| 28394 | 28461 | } |
| 28395 | 28462 | }else |
| 28396 | 28463 | |
| 28397 | | - if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ |
| 28464 | + if( c=='c' && n==4 |
| 28465 | + && (cli_strncmp(azArg[0], "crlf", n)==0 |
| 28466 | + || cli_strncmp(azArg[0], "crnl",n)==0) |
| 28467 | + ){ |
| 28398 | 28468 | if( nArg==2 ){ |
| 28399 | | - p->crnlMode = booleanValue(azArg[1]); |
| 28400 | | - setCrnlMode(p); |
| 28401 | | - }else{ |
| 28402 | | - sqlite3_fprintf(stderr, "crnl is currently %s\n", |
| 28403 | | - p->crnlMode ? "ON" : "OFF"); |
| 28469 | +#ifdef _WIN32 |
| 28470 | + p->crlfMode = booleanValue(azArg[1]); |
| 28471 | +#else |
| 28472 | + p->crlfMode = 0; |
| 28473 | +#endif |
| 28404 | 28474 | } |
| 28475 | + sqlite3_fprintf(stderr, "crlf is %s\n", p->crlfMode ? "ON" : "OFF"); |
| 28405 | 28476 | }else |
| 28406 | 28477 | |
| 28407 | 28478 | if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){ |
| 28408 | 28479 | char **azName = 0; |
| 28409 | 28480 | int nName = 0; |
| | @@ -32419,10 +32490,13 @@ |
| 32419 | 32490 | */ |
| 32420 | 32491 | static void main_init(ShellState *data) { |
| 32421 | 32492 | memset(data, 0, sizeof(*data)); |
| 32422 | 32493 | data->normalMode = data->cMode = data->mode = MODE_List; |
| 32423 | 32494 | data->autoExplain = 1; |
| 32495 | +#ifdef _WIN32 |
| 32496 | + data->crlfMode = 1; |
| 32497 | +#endif |
| 32424 | 32498 | data->pAuxDb = &data->aAuxDb[0]; |
| 32425 | 32499 | memcpy(data->colSeparator,SEP_Column, 2); |
| 32426 | 32500 | memcpy(data->rowSeparator,SEP_Row, 2); |
| 32427 | 32501 | data->showHeader = 0; |
| 32428 | 32502 | data->shellFlgs = SHFLG_Lookaside; |
| | @@ -32432,20 +32506,10 @@ |
| 32432 | 32506 | #endif |
| 32433 | 32507 | sqlite3_config(SQLITE_CONFIG_URI, 1); |
| 32434 | 32508 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); |
| 32435 | 32509 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); |
| 32436 | 32510 | sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); |
| 32437 | | - |
| 32438 | | - /* By default, come up in O_BINARY mode. That way, the default output is |
| 32439 | | - ** the same for Windows and non-Windows systems. Use the ".crnl on" |
| 32440 | | - ** command to change into O_TEXT mode to do automatic NL-to-CRLF |
| 32441 | | - ** conversions on output for Windows. |
| 32442 | | - ** |
| 32443 | | - ** End-of-line marks on CVS output is CRLF when in .crnl is on and |
| 32444 | | - ** NL when .crnl is off. |
| 32445 | | - */ |
| 32446 | | - data->crnlMode = 0; |
| 32447 | 32511 | } |
| 32448 | 32512 | |
| 32449 | 32513 | /* |
| 32450 | 32514 | ** Output text to the console in a font that attracts extra attention. |
| 32451 | 32515 | */ |
| 32452 | 32516 | |