| | @@ -121,10 +121,14 @@ |
| 121 | 121 | #if defined(_MSC_VER) && !defined(_WIN64) |
| 122 | 122 | #undef SQLITE_4_BYTE_ALIGNED_MALLOC |
| 123 | 123 | #define SQLITE_4_BYTE_ALIGNED_MALLOC |
| 124 | 124 | #endif /* defined(_MSC_VER) && !defined(_WIN64) */ |
| 125 | 125 | |
| 126 | +#if !defined(HAVE_LOG2) && defined(_MSC_VER) && _MSC_VER<1800 |
| 127 | +#define HAVE_LOG2 0 |
| 128 | +#endif /* !defined(HAVE_LOG2) && defined(_MSC_VER) && _MSC_VER<1800 */ |
| 129 | + |
| 126 | 130 | #endif /* SQLITE_MSVC_H */ |
| 127 | 131 | |
| 128 | 132 | /************** End of msvc.h ************************************************/ |
| 129 | 133 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 130 | 134 | |
| | @@ -452,11 +456,11 @@ |
| 452 | 456 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 457 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 458 | */ |
| 455 | 459 | #define SQLITE_VERSION "3.42.0" |
| 456 | 460 | #define SQLITE_VERSION_NUMBER 3042000 |
| 457 | | -#define SQLITE_SOURCE_ID "2023-04-10 18:44:00 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d" |
| 461 | +#define SQLITE_SOURCE_ID "2023-05-01 20:42:15 342af5b4fa0bd7c699e5497161db13d0cf795c7a5875ae30d666122e518f213b" |
| 458 | 462 | |
| 459 | 463 | /* |
| 460 | 464 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 465 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 466 | ** |
| | @@ -2702,29 +2706,29 @@ |
| 2702 | 2706 | ** additional information. This feature can also be turned on and off |
| 2703 | 2707 | ** using the [PRAGMA legacy_alter_table] statement. |
| 2704 | 2708 | ** </dd> |
| 2705 | 2709 | ** |
| 2706 | 2710 | ** [[SQLITE_DBCONFIG_DQS_DML]] |
| 2707 | | -** <dt>SQLITE_DBCONFIG_DQS_DML</td> |
| 2711 | +** <dt>SQLITE_DBCONFIG_DQS_DML</dt> |
| 2708 | 2712 | ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates |
| 2709 | 2713 | ** the legacy [double-quoted string literal] misfeature for DML statements |
| 2710 | 2714 | ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The |
| 2711 | 2715 | ** default value of this setting is determined by the [-DSQLITE_DQS] |
| 2712 | 2716 | ** compile-time option. |
| 2713 | 2717 | ** </dd> |
| 2714 | 2718 | ** |
| 2715 | 2719 | ** [[SQLITE_DBCONFIG_DQS_DDL]] |
| 2716 | | -** <dt>SQLITE_DBCONFIG_DQS_DDL</td> |
| 2720 | +** <dt>SQLITE_DBCONFIG_DQS_DDL</dt> |
| 2717 | 2721 | ** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates |
| 2718 | 2722 | ** the legacy [double-quoted string literal] misfeature for DDL statements, |
| 2719 | 2723 | ** such as CREATE TABLE and CREATE INDEX. The |
| 2720 | 2724 | ** default value of this setting is determined by the [-DSQLITE_DQS] |
| 2721 | 2725 | ** compile-time option. |
| 2722 | 2726 | ** </dd> |
| 2723 | 2727 | ** |
| 2724 | 2728 | ** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] |
| 2725 | | -** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td> |
| 2729 | +** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</dt> |
| 2726 | 2730 | ** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to |
| 2727 | 2731 | ** assume that database schemas are untainted by malicious content. |
| 2728 | 2732 | ** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite |
| 2729 | 2733 | ** takes additional defensive steps to protect the application from harm |
| 2730 | 2734 | ** including: |
| | @@ -2740,20 +2744,20 @@ |
| 2740 | 2744 | ** all applications are advised to turn it off if possible. This setting |
| 2741 | 2745 | ** can also be controlled using the [PRAGMA trusted_schema] statement. |
| 2742 | 2746 | ** </dd> |
| 2743 | 2747 | ** |
| 2744 | 2748 | ** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] |
| 2745 | | -** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td> |
| 2749 | +** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt> |
| 2746 | 2750 | ** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates |
| 2747 | 2751 | ** the legacy file format flag. When activated, this flag causes all newly |
| 2748 | 2752 | ** created database file to have a schema format version number (the 4-byte |
| 2749 | 2753 | ** integer found at offset 44 into the database header) of 1. This in turn |
| 2750 | 2754 | ** means that the resulting database file will be readable and writable by |
| 2751 | 2755 | ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, |
| 2752 | 2756 | ** newly created databases are generally not understandable by SQLite versions |
| 2753 | 2757 | ** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there |
| 2754 | | -** is now scarcely any need to generated database files that are compatible |
| 2758 | +** is now scarcely any need to generate database files that are compatible |
| 2755 | 2759 | ** all the way back to version 3.0.0, and so this setting is of little |
| 2756 | 2760 | ** practical use, but is provided so that SQLite can continue to claim the |
| 2757 | 2761 | ** ability to generate new database files that are compatible with version |
| 2758 | 2762 | ** 3.0.0. |
| 2759 | 2763 | ** <p>Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, |
| | @@ -2762,27 +2766,39 @@ |
| 2762 | 2766 | ** not considered a bug since SQLite versions 3.3.0 and earlier do not support |
| 2763 | 2767 | ** either generated columns or decending indexes. |
| 2764 | 2768 | ** </dd> |
| 2765 | 2769 | ** |
| 2766 | 2770 | ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]] |
| 2767 | | -** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</td> |
| 2771 | +** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt> |
| 2768 | 2772 | ** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in |
| 2769 | 2773 | ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears |
| 2770 | 2774 | ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2() |
| 2771 | 2775 | ** statistics. For statistics to be collected, the flag must be set on |
| 2772 | 2776 | ** the database handle both when the SQL statement is prepared and when it |
| 2773 | 2777 | ** is stepped. The flag is set (collection of statistics is enabled) |
| 2774 | | -** by default.</dd> |
| 2778 | +** by default. This option takes two arguments: an integer and a pointer to |
| 2779 | +** an integer.. The first argument is 1, 0, or -1 to enable, disable, or |
| 2780 | +** leave unchanged the statement scanstatus option. If the second argument |
| 2781 | +** is not NULL, then the value of the statement scanstatus setting after |
| 2782 | +** processing the first argument is written into the integer that the second |
| 2783 | +** argument points to. |
| 2784 | +** </dd> |
| 2775 | 2785 | ** |
| 2776 | 2786 | ** [[SQLITE_DBCONFIG_REVERSE_SCANORDER]] |
| 2777 | | -** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</td> |
| 2778 | | -** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option change the default order |
| 2787 | +** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt> |
| 2788 | +** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order |
| 2779 | 2789 | ** in which tables and indexes are scanned so that the scans start at the end |
| 2780 | 2790 | ** and work toward the beginning rather than starting at the beginning and |
| 2781 | | -** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the |
| 2782 | | -** same as setting [PRAGMA reverse_unordered_selects]. This configuration option |
| 2783 | | -** is useful for application testing.</dd> |
| 2791 | +** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the |
| 2792 | +** same as setting [PRAGMA reverse_unordered_selects]. This option takes |
| 2793 | +** two arguments which are an integer and a pointer to an integer. The first |
| 2794 | +** argument is 1, 0, or -1 to enable, disable, or leave unchanged the |
| 2795 | +** reverse scan order flag, respectively. If the second argument is not NULL, |
| 2796 | +** then 0 or 1 is written into the integer that the second argument points to |
| 2797 | +** depending on if the reverse scan order flag is set after processing the |
| 2798 | +** first argument. |
| 2799 | +** </dd> |
| 2784 | 2800 | ** |
| 2785 | 2801 | ** </dl> |
| 2786 | 2802 | */ |
| 2787 | 2803 | #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ |
| 2788 | 2804 | #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ |
| | @@ -2800,11 +2816,11 @@ |
| 2800 | 2816 | #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */ |
| 2801 | 2817 | #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */ |
| 2802 | 2818 | #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ |
| 2803 | 2819 | #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ |
| 2804 | 2820 | #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ |
| 2805 | | -#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */ |
| 2821 | +#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */ |
| 2806 | 2822 | #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */ |
| 2807 | 2823 | #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */ |
| 2808 | 2824 | |
| 2809 | 2825 | /* |
| 2810 | 2826 | ** CAPI3REF: Enable Or Disable Extended Result Codes |
| | @@ -11106,20 +11122,24 @@ |
| 11106 | 11122 | ** [sqlite3session_create()] for details. |
| 11107 | 11123 | */ |
| 11108 | 11124 | SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); |
| 11109 | 11125 | |
| 11110 | 11126 | /* |
| 11111 | | -** CAPIREF: Conigure a Session Object |
| 11127 | +** CAPI3REF: Configure a Session Object |
| 11112 | 11128 | ** METHOD: sqlite3_session |
| 11113 | 11129 | ** |
| 11114 | 11130 | ** This method is used to configure a session object after it has been |
| 11115 | | -** created. At present the only valid value for the second parameter is |
| 11116 | | -** [SQLITE_SESSION_OBJCONFIG_SIZE]. |
| 11131 | +** created. At present the only valid values for the second parameter are |
| 11132 | +** [SQLITE_SESSION_OBJCONFIG_SIZE] and [SQLITE_SESSION_OBJCONFIG_ROWID]. |
| 11117 | 11133 | ** |
| 11118 | | -** Arguments for sqlite3session_object_config() |
| 11134 | +*/ |
| 11135 | +SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); |
| 11136 | + |
| 11137 | +/* |
| 11138 | +** CAPI3REF: Options for sqlite3session_object_config |
| 11119 | 11139 | ** |
| 11120 | | -** The following values may passed as the the 4th parameter to |
| 11140 | +** The following values may passed as the the 2nd parameter to |
| 11121 | 11141 | ** sqlite3session_object_config(). |
| 11122 | 11142 | ** |
| 11123 | 11143 | ** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd> |
| 11124 | 11144 | ** This option is used to set, clear or query the flag that enables |
| 11125 | 11145 | ** the [sqlite3session_changeset_size()] API. Because it imposes some |
| | @@ -11131,16 +11151,25 @@ |
| 11131 | 11151 | ** variable is set to 1 if the sqlite3session_changeset_size() API is |
| 11132 | 11152 | ** enabled following the current call, or 0 otherwise. |
| 11133 | 11153 | ** |
| 11134 | 11154 | ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after |
| 11135 | 11155 | ** the first table has been attached to the session object. |
| 11156 | +** |
| 11157 | +** <dt>SQLITE_SESSION_OBJCONFIG_ROWID <dd> |
| 11158 | +** This option is used to set, clear or query the flag that enables |
| 11159 | +** collection of data for tables with no explicit PRIMARY KEY. |
| 11160 | +** |
| 11161 | +** Normally, tables with no explicit PRIMARY KEY are simply ignored |
| 11162 | +** by the sessions module. However, if this flag is set, it behaves |
| 11163 | +** as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted |
| 11164 | +** as their leftmost columns. |
| 11165 | +** |
| 11166 | +** It is an error (SQLITE_MISUSE) to attempt to modify this setting after |
| 11167 | +** the first table has been attached to the session object. |
| 11136 | 11168 | */ |
| 11137 | | -SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); |
| 11138 | | - |
| 11139 | | -/* |
| 11140 | | -*/ |
| 11141 | | -#define SQLITE_SESSION_OBJCONFIG_SIZE 1 |
| 11169 | +#define SQLITE_SESSION_OBJCONFIG_SIZE 1 |
| 11170 | +#define SQLITE_SESSION_OBJCONFIG_ROWID 2 |
| 11142 | 11171 | |
| 11143 | 11172 | /* |
| 11144 | 11173 | ** CAPI3REF: Enable Or Disable A Session Object |
| 11145 | 11174 | ** METHOD: sqlite3_session |
| 11146 | 11175 | ** |
| | @@ -13652,11 +13681,11 @@ |
| 13652 | 13681 | # define SQLITE_INLINE __forceinline |
| 13653 | 13682 | #else |
| 13654 | 13683 | # define SQLITE_NOINLINE |
| 13655 | 13684 | # define SQLITE_INLINE |
| 13656 | 13685 | #endif |
| 13657 | | -#if defined(SQLITE_COVERAGE_TEST) |
| 13686 | +#if defined(SQLITE_COVERAGE_TEST) || defined(__STRICT_ANSI__) |
| 13658 | 13687 | # undef SQLITE_INLINE |
| 13659 | 13688 | # define SQLITE_INLINE |
| 13660 | 13689 | #endif |
| 13661 | 13690 | |
| 13662 | 13691 | /* |
| | @@ -20020,19 +20049,23 @@ |
| 20020 | 20049 | # define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02) |
| 20021 | 20050 | # define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04) |
| 20022 | 20051 | # define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08) |
| 20023 | 20052 | # define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)]) |
| 20024 | 20053 | # define sqlite3Isquote(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x80) |
| 20054 | +# define sqlite3JsonId1(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x42) |
| 20055 | +# define sqlite3JsonId2(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x46) |
| 20025 | 20056 | #else |
| 20026 | 20057 | # define sqlite3Toupper(x) toupper((unsigned char)(x)) |
| 20027 | 20058 | # define sqlite3Isspace(x) isspace((unsigned char)(x)) |
| 20028 | 20059 | # define sqlite3Isalnum(x) isalnum((unsigned char)(x)) |
| 20029 | 20060 | # define sqlite3Isalpha(x) isalpha((unsigned char)(x)) |
| 20030 | 20061 | # define sqlite3Isdigit(x) isdigit((unsigned char)(x)) |
| 20031 | 20062 | # define sqlite3Isxdigit(x) isxdigit((unsigned char)(x)) |
| 20032 | 20063 | # define sqlite3Tolower(x) tolower((unsigned char)(x)) |
| 20033 | 20064 | # define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`') |
| 20065 | +# define sqlite3JsonId1(x) (sqlite3IsIdChar(x)&&(x)<'0') |
| 20066 | +# define sqlite3JsonId2(x) sqlite3IsIdChar(x) |
| 20034 | 20067 | #endif |
| 20035 | 20068 | SQLITE_PRIVATE int sqlite3IsIdChar(u8); |
| 20036 | 20069 | |
| 20037 | 20070 | /* |
| 20038 | 20071 | ** Internal function prototypes |
| | @@ -22161,11 +22194,11 @@ |
| 22161 | 22194 | ** isalpha() 0x02 |
| 22162 | 22195 | ** isdigit() 0x04 |
| 22163 | 22196 | ** isalnum() 0x06 |
| 22164 | 22197 | ** isxdigit() 0x08 |
| 22165 | 22198 | ** toupper() 0x20 |
| 22166 | | -** SQLite identifier character 0x40 |
| 22199 | +** SQLite identifier character 0x40 $, _, or non-ascii |
| 22167 | 22200 | ** Quote character 0x80 |
| 22168 | 22201 | ** |
| 22169 | 22202 | ** Bit 0x20 is set if the mapped character requires translation to upper |
| 22170 | 22203 | ** case. i.e. if the character is a lower-case ASCII character. |
| 22171 | 22204 | ** If x is a lower-case ASCII character, then its upper-case equivalent |
| | @@ -34434,17 +34467,19 @@ |
| 34434 | 34467 | }else{ |
| 34435 | 34468 | x = v; |
| 34436 | 34469 | } |
| 34437 | 34470 | i = sizeof(zTemp)-2; |
| 34438 | 34471 | zTemp[sizeof(zTemp)-1] = 0; |
| 34439 | | - do{ |
| 34440 | | - zTemp[i--] = (x%10) + '0'; |
| 34472 | + while( 1 /*exit-by-break*/ ){ |
| 34473 | + zTemp[i] = (x%10) + '0'; |
| 34441 | 34474 | x = x/10; |
| 34442 | | - }while( x ); |
| 34443 | | - if( v<0 ) zTemp[i--] = '-'; |
| 34444 | | - memcpy(zOut, &zTemp[i+1], sizeof(zTemp)-1-i); |
| 34445 | | - return sizeof(zTemp)-2-i; |
| 34475 | + if( x==0 ) break; |
| 34476 | + i--; |
| 34477 | + }; |
| 34478 | + if( v<0 ) zTemp[--i] = '-'; |
| 34479 | + memcpy(zOut, &zTemp[i], sizeof(zTemp)-i); |
| 34480 | + return sizeof(zTemp)-1-i; |
| 34446 | 34481 | } |
| 34447 | 34482 | |
| 34448 | 34483 | /* |
| 34449 | 34484 | ** Compare the 19-character string zNum against the text representation |
| 34450 | 34485 | ** value 2^63: 9223372036854775808. Return negative, zero, or positive |
| | @@ -34605,11 +34640,13 @@ |
| 34605 | 34640 | for(i=2; z[i]=='0'; i++){} |
| 34606 | 34641 | for(k=i; sqlite3Isxdigit(z[k]); k++){ |
| 34607 | 34642 | u = u*16 + sqlite3HexToInt(z[k]); |
| 34608 | 34643 | } |
| 34609 | 34644 | memcpy(pOut, &u, 8); |
| 34610 | | - return (z[k]==0 && k-i<=16) ? 0 : 2; |
| 34645 | + if( k-i>16 ) return 2; |
| 34646 | + if( z[k]!=0 ) return 1; |
| 34647 | + return 0; |
| 34611 | 34648 | }else |
| 34612 | 34649 | #endif /* SQLITE_OMIT_HEX_INTEGER */ |
| 34613 | 34650 | { |
| 34614 | 34651 | return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8); |
| 34615 | 34652 | } |
| | @@ -34641,11 +34678,11 @@ |
| 34641 | 34678 | && sqlite3Isxdigit(zNum[2]) |
| 34642 | 34679 | ){ |
| 34643 | 34680 | u32 u = 0; |
| 34644 | 34681 | zNum += 2; |
| 34645 | 34682 | while( zNum[0]=='0' ) zNum++; |
| 34646 | | - for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){ |
| 34683 | + for(i=0; i<8 && sqlite3Isxdigit(zNum[i]); i++){ |
| 34647 | 34684 | u = u*16 + sqlite3HexToInt(zNum[i]); |
| 34648 | 34685 | } |
| 34649 | 34686 | if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){ |
| 34650 | 34687 | memcpy(pValue, &u, 4); |
| 34651 | 34688 | return 1; |
| | @@ -37137,11 +37174,11 @@ |
| 37137 | 37174 | # define SQLITE_ENABLE_LOCKING_STYLE 0 |
| 37138 | 37175 | # endif |
| 37139 | 37176 | #endif |
| 37140 | 37177 | |
| 37141 | 37178 | /* Use pread() and pwrite() if they are available */ |
| 37142 | | -#if defined(__APPLE__) |
| 37179 | +#if defined(__APPLE__) || defined(__linux__) |
| 37143 | 37180 | # define HAVE_PREAD 1 |
| 37144 | 37181 | # define HAVE_PWRITE 1 |
| 37145 | 37182 | #endif |
| 37146 | 37183 | #if defined(HAVE_PREAD64) && defined(HAVE_PWRITE64) |
| 37147 | 37184 | # undef USE_PREAD |
| | @@ -40387,16 +40424,10 @@ |
| 40387 | 40424 | |
| 40388 | 40425 | /* |
| 40389 | 40426 | ** Seek to the offset passed as the second argument, then read cnt |
| 40390 | 40427 | ** bytes into pBuf. Return the number of bytes actually read. |
| 40391 | 40428 | ** |
| 40392 | | -** NB: If you define USE_PREAD or USE_PREAD64, then it might also |
| 40393 | | -** be necessary to define _XOPEN_SOURCE to be 500. This varies from |
| 40394 | | -** one system to another. Since SQLite does not define USE_PREAD |
| 40395 | | -** in any form by default, we will not attempt to define _XOPEN_SOURCE. |
| 40396 | | -** See tickets #2741 and #2681. |
| 40397 | | -** |
| 40398 | 40429 | ** To avoid stomping the errno value on a failed read the lastErrno value |
| 40399 | 40430 | ** is set before returning. |
| 40400 | 40431 | */ |
| 40401 | 40432 | static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){ |
| 40402 | 40433 | int got; |
| | @@ -50419,11 +50450,11 @@ |
| 50419 | 50450 | &extendedParameters); |
| 50420 | 50451 | if( h!=INVALID_HANDLE_VALUE ) break; |
| 50421 | 50452 | if( isReadWrite ){ |
| 50422 | 50453 | int rc2, isRO = 0; |
| 50423 | 50454 | sqlite3BeginBenignMalloc(); |
| 50424 | | - rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); |
| 50455 | + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); |
| 50425 | 50456 | sqlite3EndBenignMalloc(); |
| 50426 | 50457 | if( rc2==SQLITE_OK && isRO ) break; |
| 50427 | 50458 | } |
| 50428 | 50459 | }while( winRetryIoerr(&cnt, &lastErrno) ); |
| 50429 | 50460 | #else |
| | @@ -50436,11 +50467,11 @@ |
| 50436 | 50467 | NULL); |
| 50437 | 50468 | if( h!=INVALID_HANDLE_VALUE ) break; |
| 50438 | 50469 | if( isReadWrite ){ |
| 50439 | 50470 | int rc2, isRO = 0; |
| 50440 | 50471 | sqlite3BeginBenignMalloc(); |
| 50441 | | - rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); |
| 50472 | + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); |
| 50442 | 50473 | sqlite3EndBenignMalloc(); |
| 50443 | 50474 | if( rc2==SQLITE_OK && isRO ) break; |
| 50444 | 50475 | } |
| 50445 | 50476 | }while( winRetryIoerr(&cnt, &lastErrno) ); |
| 50446 | 50477 | #endif |
| | @@ -50456,11 +50487,11 @@ |
| 50456 | 50487 | NULL); |
| 50457 | 50488 | if( h!=INVALID_HANDLE_VALUE ) break; |
| 50458 | 50489 | if( isReadWrite ){ |
| 50459 | 50490 | int rc2, isRO = 0; |
| 50460 | 50491 | sqlite3BeginBenignMalloc(); |
| 50461 | | - rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO); |
| 50492 | + rc2 = winAccess(pVfs, zUtf8Name, SQLITE_ACCESS_READ, &isRO); |
| 50462 | 50493 | sqlite3EndBenignMalloc(); |
| 50463 | 50494 | if( rc2==SQLITE_OK && isRO ) break; |
| 50464 | 50495 | } |
| 50465 | 50496 | }while( winRetryIoerr(&cnt, &lastErrno) ); |
| 50466 | 50497 | } |
| | @@ -50678,10 +50709,17 @@ |
| 50678 | 50709 | UNUSED_PARAMETER(pVfs); |
| 50679 | 50710 | |
| 50680 | 50711 | SimulateIOError( return SQLITE_IOERR_ACCESS; ); |
| 50681 | 50712 | OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n", |
| 50682 | 50713 | zFilename, flags, pResOut)); |
| 50714 | + |
| 50715 | + if( zFilename==0 ){ |
| 50716 | + *pResOut = 0; |
| 50717 | + OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n", |
| 50718 | + zFilename, pResOut, *pResOut)); |
| 50719 | + return SQLITE_OK; |
| 50720 | + } |
| 50683 | 50721 | |
| 50684 | 50722 | zConverted = winConvertFromUtf8Filename(zFilename); |
| 50685 | 50723 | if( zConverted==0 ){ |
| 50686 | 50724 | OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); |
| 50687 | 50725 | return SQLITE_IOERR_NOMEM_BKPT; |
| | @@ -52835,15 +52873,19 @@ |
| 52835 | 52873 | # define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} |
| 52836 | 52874 | static void pcachePageTrace(int i, sqlite3_pcache_page *pLower){ |
| 52837 | 52875 | PgHdr *pPg; |
| 52838 | 52876 | unsigned char *a; |
| 52839 | 52877 | int j; |
| 52840 | | - pPg = (PgHdr*)pLower->pExtra; |
| 52841 | | - printf("%3lld: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags); |
| 52842 | | - a = (unsigned char *)pLower->pBuf; |
| 52843 | | - for(j=0; j<12; j++) printf("%02x", a[j]); |
| 52844 | | - printf(" ptr %p\n", pPg); |
| 52878 | + if( pLower==0 ){ |
| 52879 | + printf("%3d: NULL\n", i); |
| 52880 | + }else{ |
| 52881 | + pPg = (PgHdr*)pLower->pExtra; |
| 52882 | + printf("%3d: nRef %2lld flgs %02x data ", i, pPg->nRef, pPg->flags); |
| 52883 | + a = (unsigned char *)pLower->pBuf; |
| 52884 | + for(j=0; j<12; j++) printf("%02x", a[j]); |
| 52885 | + printf(" ptr %p\n", pPg); |
| 52886 | + } |
| 52845 | 52887 | } |
| 52846 | 52888 | static void pcacheDump(PCache *pCache){ |
| 52847 | 52889 | int N; |
| 52848 | 52890 | int i; |
| 52849 | 52891 | sqlite3_pcache_page *pLower; |
| | @@ -52852,13 +52894,12 @@ |
| 52852 | 52894 | if( pCache->pCache==0 ) return; |
| 52853 | 52895 | N = sqlite3PcachePagecount(pCache); |
| 52854 | 52896 | if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump; |
| 52855 | 52897 | for(i=1; i<=N; i++){ |
| 52856 | 52898 | pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0); |
| 52857 | | - if( pLower==0 ) continue; |
| 52858 | 52899 | pcachePageTrace(i, pLower); |
| 52859 | | - if( ((PgHdr*)pLower)->pPage==0 ){ |
| 52900 | + if( pLower && ((PgHdr*)pLower)->pPage==0 ){ |
| 52860 | 52901 | sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0); |
| 52861 | 52902 | } |
| 52862 | 52903 | } |
| 52863 | 52904 | } |
| 52864 | 52905 | #else |
| | @@ -58242,10 +58283,12 @@ |
| 58242 | 58283 | */ |
| 58243 | 58284 | static int pager_truncate(Pager *pPager, Pgno nPage){ |
| 58244 | 58285 | int rc = SQLITE_OK; |
| 58245 | 58286 | assert( pPager->eState!=PAGER_ERROR ); |
| 58246 | 58287 | assert( pPager->eState!=PAGER_READER ); |
| 58288 | + PAGERTRACE(("Truncate %d npage %u\n", PAGERID(pPager), nPage)); |
| 58289 | + |
| 58247 | 58290 | |
| 58248 | 58291 | if( isOpen(pPager->fd) |
| 58249 | 58292 | && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) |
| 58250 | 58293 | ){ |
| 58251 | 58294 | i64 currentSize, newSize; |
| | @@ -61159,10 +61202,14 @@ |
| 61159 | 61202 | |
| 61160 | 61203 | assert( !isOpen(pPager->fd) || !MEMDB ); |
| 61161 | 61204 | if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){ |
| 61162 | 61205 | if( pgno>pPager->mxPgno ){ |
| 61163 | 61206 | rc = SQLITE_FULL; |
| 61207 | + if( pgno<=pPager->dbSize ){ |
| 61208 | + sqlite3PcacheRelease(pPg); |
| 61209 | + pPg = 0; |
| 61210 | + } |
| 61164 | 61211 | goto pager_acquire_err; |
| 61165 | 61212 | } |
| 61166 | 61213 | if( noContent ){ |
| 61167 | 61214 | /* Failure to set the bits in the InJournal bit-vectors is benign. |
| 61168 | 61215 | ** It merely means that we might do some extra work to journal a |
| | @@ -61323,14 +61370,16 @@ |
| 61323 | 61370 | } |
| 61324 | 61371 | |
| 61325 | 61372 | /* |
| 61326 | 61373 | ** Release a page reference. |
| 61327 | 61374 | ** |
| 61328 | | -** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be |
| 61329 | | -** used if we know that the page being released is not the last page. |
| 61375 | +** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be used |
| 61376 | +** if we know that the page being released is not the last reference to page1. |
| 61330 | 61377 | ** The btree layer always holds page1 open until the end, so these first |
| 61331 | | -** to routines can be used to release any page other than BtShared.pPage1. |
| 61378 | +** two routines can be used to release any page other than BtShared.pPage1. |
| 61379 | +** The assert() at tag-20230419-2 proves that this constraint is always |
| 61380 | +** honored. |
| 61332 | 61381 | ** |
| 61333 | 61382 | ** Use sqlite3PagerUnrefPageOne() to release page1. This latter routine |
| 61334 | 61383 | ** checks the total number of outstanding pages and if the number of |
| 61335 | 61384 | ** pages reaches zero it drops the database lock. |
| 61336 | 61385 | */ |
| | @@ -61342,11 +61391,11 @@ |
| 61342 | 61391 | pagerReleaseMapPage(pPg); |
| 61343 | 61392 | }else{ |
| 61344 | 61393 | sqlite3PcacheRelease(pPg); |
| 61345 | 61394 | } |
| 61346 | 61395 | /* Do not use this routine to release the last reference to page1 */ |
| 61347 | | - assert( sqlite3PcacheRefCount(pPager->pPCache)>0 ); |
| 61396 | + assert( sqlite3PcacheRefCount(pPager->pPCache)>0 ); /* tag-20230419-2 */ |
| 61348 | 61397 | } |
| 61349 | 61398 | SQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){ |
| 61350 | 61399 | if( pPg ) sqlite3PagerUnrefNotNull(pPg); |
| 61351 | 61400 | } |
| 61352 | 61401 | SQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){ |
| | @@ -64113,23 +64162,44 @@ |
| 64113 | 64162 | } |
| 64114 | 64163 | |
| 64115 | 64164 | assert( nByte>=8 ); |
| 64116 | 64165 | assert( (nByte&0x00000007)==0 ); |
| 64117 | 64166 | assert( nByte<=65536 ); |
| 64167 | + assert( nByte%4==0 ); |
| 64118 | 64168 | |
| 64119 | | - if( nativeCksum ){ |
| 64120 | | - do { |
| 64121 | | - s1 += *aData++ + s2; |
| 64122 | | - s2 += *aData++ + s1; |
| 64123 | | - }while( aData<aEnd ); |
| 64124 | | - }else{ |
| 64169 | + if( !nativeCksum ){ |
| 64125 | 64170 | do { |
| 64126 | 64171 | s1 += BYTESWAP32(aData[0]) + s2; |
| 64127 | 64172 | s2 += BYTESWAP32(aData[1]) + s1; |
| 64128 | 64173 | aData += 2; |
| 64129 | 64174 | }while( aData<aEnd ); |
| 64175 | + }else if( nByte%64==0 ){ |
| 64176 | + do { |
| 64177 | + s1 += *aData++ + s2; |
| 64178 | + s2 += *aData++ + s1; |
| 64179 | + s1 += *aData++ + s2; |
| 64180 | + s2 += *aData++ + s1; |
| 64181 | + s1 += *aData++ + s2; |
| 64182 | + s2 += *aData++ + s1; |
| 64183 | + s1 += *aData++ + s2; |
| 64184 | + s2 += *aData++ + s1; |
| 64185 | + s1 += *aData++ + s2; |
| 64186 | + s2 += *aData++ + s1; |
| 64187 | + s1 += *aData++ + s2; |
| 64188 | + s2 += *aData++ + s1; |
| 64189 | + s1 += *aData++ + s2; |
| 64190 | + s2 += *aData++ + s1; |
| 64191 | + s1 += *aData++ + s2; |
| 64192 | + s2 += *aData++ + s1; |
| 64193 | + }while( aData<aEnd ); |
| 64194 | + }else{ |
| 64195 | + do { |
| 64196 | + s1 += *aData++ + s2; |
| 64197 | + s2 += *aData++ + s1; |
| 64198 | + }while( aData<aEnd ); |
| 64130 | 64199 | } |
| 64200 | + assert( aData==aEnd ); |
| 64131 | 64201 | |
| 64132 | 64202 | aOut[0] = s1; |
| 64133 | 64203 | aOut[1] = s2; |
| 64134 | 64204 | } |
| 64135 | 64205 | |
| | @@ -76202,11 +76272,11 @@ |
| 76202 | 76272 | aAfter[j] = iAfter; |
| 76203 | 76273 | break; |
| 76204 | 76274 | } |
| 76205 | 76275 | } |
| 76206 | 76276 | if( j>=nFree ){ |
| 76207 | | - if( nFree>=sizeof(aOfst)/sizeof(aOfst[0]) ){ |
| 76277 | + if( nFree>=(int)(sizeof(aOfst)/sizeof(aOfst[0])) ){ |
| 76208 | 76278 | for(j=0; j<nFree; j++){ |
| 76209 | 76279 | freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]); |
| 76210 | 76280 | } |
| 76211 | 76281 | nFree = 0; |
| 76212 | 76282 | } |
| | @@ -77907,11 +77977,11 @@ |
| 77907 | 77977 | return btreeOverwriteCell(pCur, &x2); |
| 77908 | 77978 | } |
| 77909 | 77979 | } |
| 77910 | 77980 | } |
| 77911 | 77981 | assert( pCur->eState==CURSOR_VALID |
| 77912 | | - || (pCur->eState==CURSOR_INVALID && loc) ); |
| 77982 | + || (pCur->eState==CURSOR_INVALID && loc) || CORRUPT_DB ); |
| 77913 | 77983 | |
| 77914 | 77984 | pPage = pCur->pPage; |
| 77915 | 77985 | assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) ); |
| 77916 | 77986 | assert( pPage->leaf || !pPage->intKey ); |
| 77917 | 77987 | if( pPage->nFree<0 ){ |
| | @@ -80157,17 +80227,11 @@ |
| 80157 | 80227 | assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 ); |
| 80158 | 80228 | assert( p->bDestLocked ); |
| 80159 | 80229 | assert( !isFatalError(p->rc) ); |
| 80160 | 80230 | assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ); |
| 80161 | 80231 | assert( zSrcData ); |
| 80162 | | - |
| 80163 | | - /* Catch the case where the destination is an in-memory database and the |
| 80164 | | - ** page sizes of the source and destination differ. |
| 80165 | | - */ |
| 80166 | | - if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){ |
| 80167 | | - rc = SQLITE_READONLY; |
| 80168 | | - } |
| 80232 | + assert( nSrcPgsz==nDestPgsz || sqlite3PagerIsMemdb(pDestPager)==0 ); |
| 80169 | 80233 | |
| 80170 | 80234 | /* This loop runs once for each destination page spanned by the source |
| 80171 | 80235 | ** page. For each iteration, variable iOff is set to the byte offset |
| 80172 | 80236 | ** of the destination page. |
| 80173 | 80237 | */ |
| | @@ -80296,11 +80360,14 @@ |
| 80296 | 80360 | /* Do not allow backup if the destination database is in WAL mode |
| 80297 | 80361 | ** and the page sizes are different between source and destination */ |
| 80298 | 80362 | pgszSrc = sqlite3BtreeGetPageSize(p->pSrc); |
| 80299 | 80363 | pgszDest = sqlite3BtreeGetPageSize(p->pDest); |
| 80300 | 80364 | destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest)); |
| 80301 | | - if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){ |
| 80365 | + if( SQLITE_OK==rc |
| 80366 | + && (destMode==PAGER_JOURNALMODE_WAL || sqlite3PagerIsMemdb(pDestPager)) |
| 80367 | + && pgszSrc!=pgszDest |
| 80368 | + ){ |
| 80302 | 80369 | rc = SQLITE_READONLY; |
| 80303 | 80370 | } |
| 80304 | 80371 | |
| 80305 | 80372 | /* Now that there is a read-lock on the source database, query the |
| 80306 | 80373 | ** source pager for the number of pages in the database. |
| | @@ -80845,10 +80912,11 @@ |
| 80845 | 80912 | Mem tmp; |
| 80846 | 80913 | char zBuf[100]; |
| 80847 | 80914 | char *z; |
| 80848 | 80915 | int i, j, incr; |
| 80849 | 80916 | if( (p->flags & MEM_Str)==0 ) return 1; |
| 80917 | + if( p->db && p->db->mallocFailed ) return 1; |
| 80850 | 80918 | if( p->flags & MEM_Term ){ |
| 80851 | 80919 | /* Insure that the string is properly zero-terminated. Pay particular |
| 80852 | 80920 | ** attention to the case where p->n is odd */ |
| 80853 | 80921 | if( p->szMalloc>0 && p->z==p->zMalloc ){ |
| 80854 | 80922 | assert( p->enc==SQLITE_UTF8 || p->szMalloc >= ((p->n+1)&~1)+2 ); |
| | @@ -83508,10 +83576,12 @@ |
| 83508 | 83576 | static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ |
| 83509 | 83577 | int nMaxArgs = *pMaxFuncArgs; |
| 83510 | 83578 | Op *pOp; |
| 83511 | 83579 | Parse *pParse = p->pParse; |
| 83512 | 83580 | int *aLabel = pParse->aLabel; |
| 83581 | + |
| 83582 | + assert( pParse->db->mallocFailed==0 ); /* tag-20230419-1 */ |
| 83513 | 83583 | p->readOnly = 1; |
| 83514 | 83584 | p->bIsReader = 0; |
| 83515 | 83585 | pOp = &p->aOp[p->nOp-1]; |
| 83516 | 83586 | assert( p->aOp[0].opcode==OP_Init ); |
| 83517 | 83587 | while( 1 /* Loop termates when it reaches the OP_Init opcode */ ){ |
| | @@ -83567,10 +83637,11 @@ |
| 83567 | 83637 | /* The mkopcodeh.tcl script has so arranged things that the only |
| 83568 | 83638 | ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to |
| 83569 | 83639 | ** have non-negative values for P2. */ |
| 83570 | 83640 | assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ); |
| 83571 | 83641 | assert( ADDR(pOp->p2)<-pParse->nLabel ); |
| 83642 | + assert( aLabel!=0 ); /* True because of tag-20230419-1 */ |
| 83572 | 83643 | pOp->p2 = aLabel[ADDR(pOp->p2)]; |
| 83573 | 83644 | } |
| 83574 | 83645 | break; |
| 83575 | 83646 | } |
| 83576 | 83647 | } |
| | @@ -84310,11 +84381,11 @@ |
| 84310 | 84381 | } |
| 84311 | 84382 | } |
| 84312 | 84383 | |
| 84313 | 84384 | /* Return the most recently added opcode |
| 84314 | 84385 | */ |
| 84315 | | -VdbeOp * sqlite3VdbeGetLastOp(Vdbe *p){ |
| 84386 | +SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetLastOp(Vdbe *p){ |
| 84316 | 84387 | return sqlite3VdbeGetOp(p, p->nOp - 1); |
| 84317 | 84388 | } |
| 84318 | 84389 | |
| 84319 | 84390 | #if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) |
| 84320 | 84391 | /* |
| | @@ -88039,10 +88110,20 @@ |
| 88039 | 88110 | sqlite3 *db = v->db; |
| 88040 | 88111 | i64 iKey2; |
| 88041 | 88112 | PreUpdate preupdate; |
| 88042 | 88113 | const char *zTbl = pTab->zName; |
| 88043 | 88114 | static const u8 fakeSortOrder = 0; |
| 88115 | +#ifdef SQLITE_DEBUG |
| 88116 | + int nRealCol; |
| 88117 | + if( pTab->tabFlags & TF_WithoutRowid ){ |
| 88118 | + nRealCol = sqlite3PrimaryKeyIndex(pTab)->nColumn; |
| 88119 | + }else if( pTab->tabFlags & TF_HasVirtual ){ |
| 88120 | + nRealCol = pTab->nNVCol; |
| 88121 | + }else{ |
| 88122 | + nRealCol = pTab->nCol; |
| 88123 | + } |
| 88124 | +#endif |
| 88044 | 88125 | |
| 88045 | 88126 | assert( db->pPreUpdate==0 ); |
| 88046 | 88127 | memset(&preupdate, 0, sizeof(PreUpdate)); |
| 88047 | 88128 | if( HasRowid(pTab)==0 ){ |
| 88048 | 88129 | iKey1 = iKey2 = 0; |
| | @@ -88055,12 +88136,12 @@ |
| 88055 | 88136 | } |
| 88056 | 88137 | } |
| 88057 | 88138 | |
| 88058 | 88139 | assert( pCsr!=0 ); |
| 88059 | 88140 | assert( pCsr->eCurType==CURTYPE_BTREE ); |
| 88060 | | - assert( pCsr->nField==pTab->nCol |
| 88061 | | - || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1) |
| 88141 | + assert( pCsr->nField==nRealCol |
| 88142 | + || (pCsr->nField==nRealCol+1 && op==SQLITE_DELETE && iReg==-1) |
| 88062 | 88143 | ); |
| 88063 | 88144 | |
| 88064 | 88145 | preupdate.v = v; |
| 88065 | 88146 | preupdate.pCsr = pCsr; |
| 88066 | 88147 | preupdate.op = op; |
| | @@ -89429,13 +89510,13 @@ |
| 89429 | 89510 | p = (Vdbe *)pStmt; |
| 89430 | 89511 | db = p->db; |
| 89431 | 89512 | assert( db!=0 ); |
| 89432 | 89513 | n = sqlite3_column_count(pStmt); |
| 89433 | 89514 | if( N<n && N>=0 ){ |
| 89515 | + u8 prior_mallocFailed = db->mallocFailed; |
| 89434 | 89516 | N += useType*n; |
| 89435 | 89517 | sqlite3_mutex_enter(db->mutex); |
| 89436 | | - assert( db->mallocFailed==0 ); |
| 89437 | 89518 | #ifndef SQLITE_OMIT_UTF16 |
| 89438 | 89519 | if( useUtf16 ){ |
| 89439 | 89520 | ret = sqlite3_value_text16((sqlite3_value*)&p->aColName[N]); |
| 89440 | 89521 | }else |
| 89441 | 89522 | #endif |
| | @@ -89443,11 +89524,12 @@ |
| 89443 | 89524 | ret = sqlite3_value_text((sqlite3_value*)&p->aColName[N]); |
| 89444 | 89525 | } |
| 89445 | 89526 | /* A malloc may have failed inside of the _text() call. If this |
| 89446 | 89527 | ** is the case, clear the mallocFailed flag and return NULL. |
| 89447 | 89528 | */ |
| 89448 | | - if( db->mallocFailed ){ |
| 89529 | + assert( db->mallocFailed==0 || db->mallocFailed==1 ); |
| 89530 | + if( db->mallocFailed > prior_mallocFailed ){ |
| 89449 | 89531 | sqlite3OomClear(db); |
| 89450 | 89532 | ret = 0; |
| 89451 | 89533 | } |
| 89452 | 89534 | sqlite3_mutex_leave(db->mutex); |
| 89453 | 89535 | } |
| | @@ -93333,11 +93415,11 @@ |
| 93333 | 93415 | */ |
| 93334 | 93416 | case OP_IfNullRow: { /* jump */ |
| 93335 | 93417 | VdbeCursor *pC; |
| 93336 | 93418 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 93337 | 93419 | pC = p->apCsr[pOp->p1]; |
| 93338 | | - if( ALWAYS(pC) && pC->nullRow ){ |
| 93420 | + if( pC && pC->nullRow ){ |
| 93339 | 93421 | sqlite3VdbeMemSetNull(aMem + pOp->p3); |
| 93340 | 93422 | goto jump_to_p2; |
| 93341 | 93423 | } |
| 93342 | 93424 | break; |
| 93343 | 93425 | } |
| | @@ -93828,11 +93910,11 @@ |
| 93828 | 93910 | pIn1->flags |= MEM_IntReal; |
| 93829 | 93911 | pIn1->flags &= ~MEM_Int; |
| 93830 | 93912 | }else{ |
| 93831 | 93913 | pIn1->u.r = (double)pIn1->u.i; |
| 93832 | 93914 | pIn1->flags |= MEM_Real; |
| 93833 | | - pIn1->flags &= ~MEM_Int; |
| 93915 | + pIn1->flags &= ~(MEM_Int|MEM_Str); |
| 93834 | 93916 | } |
| 93835 | 93917 | } |
| 93836 | 93918 | REGISTER_TRACE((int)(pIn1-aMem), pIn1); |
| 93837 | 93919 | zAffinity++; |
| 93838 | 93920 | if( zAffinity[0]==0 ) break; |
| | @@ -107198,28 +107280,31 @@ |
| 107198 | 107280 | |
| 107199 | 107281 | /* |
| 107200 | 107282 | ** Join two expressions using an AND operator. If either expression is |
| 107201 | 107283 | ** NULL, then just return the other expression. |
| 107202 | 107284 | ** |
| 107203 | | -** If one side or the other of the AND is known to be false, then instead |
| 107204 | | -** of returning an AND expression, just return a constant expression with |
| 107205 | | -** a value of false. |
| 107285 | +** If one side or the other of the AND is known to be false, and neither side |
| 107286 | +** is part of an ON clause, then instead of returning an AND expression, |
| 107287 | +** just return a constant expression with a value of false. |
| 107206 | 107288 | */ |
| 107207 | 107289 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){ |
| 107208 | 107290 | sqlite3 *db = pParse->db; |
| 107209 | 107291 | if( pLeft==0 ){ |
| 107210 | 107292 | return pRight; |
| 107211 | 107293 | }else if( pRight==0 ){ |
| 107212 | 107294 | return pLeft; |
| 107213 | | - }else if( (ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight)) |
| 107214 | | - && !IN_RENAME_OBJECT |
| 107215 | | - ){ |
| 107216 | | - sqlite3ExprDeferredDelete(pParse, pLeft); |
| 107217 | | - sqlite3ExprDeferredDelete(pParse, pRight); |
| 107218 | | - return sqlite3Expr(db, TK_INTEGER, "0"); |
| 107219 | 107295 | }else{ |
| 107220 | | - return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); |
| 107296 | + u32 f = pLeft->flags | pRight->flags; |
| 107297 | + if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse |
| 107298 | + && !IN_RENAME_OBJECT |
| 107299 | + ){ |
| 107300 | + sqlite3ExprDeferredDelete(pParse, pLeft); |
| 107301 | + sqlite3ExprDeferredDelete(pParse, pRight); |
| 107302 | + return sqlite3Expr(db, TK_INTEGER, "0"); |
| 107303 | + }else{ |
| 107304 | + return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); |
| 107305 | + } |
| 107221 | 107306 | } |
| 107222 | 107307 | } |
| 107223 | 107308 | |
| 107224 | 107309 | /* |
| 107225 | 107310 | ** Construct a new expression node for a function with multiple |
| | @@ -112373,11 +112458,11 @@ |
| 112373 | 112458 | int iAgg = pExpr->iAgg; |
| 112374 | 112459 | Parse *pParse = pWalker->pParse; |
| 112375 | 112460 | sqlite3 *db = pParse->db; |
| 112376 | 112461 | assert( iAgg>=0 ); |
| 112377 | 112462 | if( pExpr->op!=TK_AGG_FUNCTION ){ |
| 112378 | | - if( ALWAYS(iAgg<pAggInfo->nColumn) |
| 112463 | + if( iAgg<pAggInfo->nColumn |
| 112379 | 112464 | && pAggInfo->aCol[iAgg].pCExpr==pExpr |
| 112380 | 112465 | ){ |
| 112381 | 112466 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112382 | 112467 | if( pExpr ){ |
| 112383 | 112468 | pAggInfo->aCol[iAgg].pCExpr = pExpr; |
| | @@ -112578,11 +112663,11 @@ |
| 112578 | 112663 | findOrCreateAggInfoColumn(pParse, pAggInfo, pExpr); |
| 112579 | 112664 | break; |
| 112580 | 112665 | } /* endif pExpr->iTable==pItem->iCursor */ |
| 112581 | 112666 | } /* end loop over pSrcList */ |
| 112582 | 112667 | } |
| 112583 | | - return WRC_Prune; |
| 112668 | + return WRC_Continue; |
| 112584 | 112669 | } |
| 112585 | 112670 | case TK_AGG_FUNCTION: { |
| 112586 | 112671 | if( (pNC->ncFlags & NC_InAggFunc)==0 |
| 112587 | 112672 | && pWalker->walkerDepth==pExpr->op2 |
| 112588 | 112673 | ){ |
| | @@ -114075,10 +114160,23 @@ |
| 114075 | 114160 | } |
| 114076 | 114161 | |
| 114077 | 114162 | sqlite3_free(zQuot); |
| 114078 | 114163 | return rc; |
| 114079 | 114164 | } |
| 114165 | + |
| 114166 | +/* |
| 114167 | +** Set all pEList->a[].fg.eEName fields in the expression-list to val. |
| 114168 | +*/ |
| 114169 | +static void renameSetENames(ExprList *pEList, int val){ |
| 114170 | + if( pEList ){ |
| 114171 | + int i; |
| 114172 | + for(i=0; i<pEList->nExpr; i++){ |
| 114173 | + assert( val==ENAME_NAME || pEList->a[i].fg.eEName==ENAME_NAME ); |
| 114174 | + pEList->a[i].fg.eEName = val; |
| 114175 | + } |
| 114176 | + } |
| 114177 | +} |
| 114080 | 114178 | |
| 114081 | 114179 | /* |
| 114082 | 114180 | ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming |
| 114083 | 114181 | ** it was read from the schema of database zDb. Return SQLITE_OK if |
| 114084 | 114182 | ** successful. Otherwise, return an SQLite error code and leave an error |
| | @@ -114123,11 +114221,21 @@ |
| 114123 | 114221 | if( pSel==0 ){ |
| 114124 | 114222 | pStep->pExprList = 0; |
| 114125 | 114223 | pSrc = 0; |
| 114126 | 114224 | rc = SQLITE_NOMEM; |
| 114127 | 114225 | }else{ |
| 114226 | + /* pStep->pExprList contains an expression-list used for an UPDATE |
| 114227 | + ** statement. So the a[].zEName values are the RHS of the |
| 114228 | + ** "<col> = <expr>" clauses of the UPDATE statement. So, before |
| 114229 | + ** running SelectPrep(), change all the eEName values in |
| 114230 | + ** pStep->pExprList to ENAME_SPAN (from their current value of |
| 114231 | + ** ENAME_NAME). This is to prevent any ids in ON() clauses that are |
| 114232 | + ** part of pSrc from being incorrectly resolved against the |
| 114233 | + ** a[].zEName values as if they were column aliases. */ |
| 114234 | + renameSetENames(pStep->pExprList, ENAME_SPAN); |
| 114128 | 114235 | sqlite3SelectPrep(pParse, pSel, 0); |
| 114236 | + renameSetENames(pStep->pExprList, ENAME_NAME); |
| 114129 | 114237 | rc = pParse->nErr ? SQLITE_ERROR : SQLITE_OK; |
| 114130 | 114238 | assert( pStep->pExprList==0 || pStep->pExprList==pSel->pEList ); |
| 114131 | 114239 | assert( pSrc==pSel->pSrc ); |
| 114132 | 114240 | if( pStep->pExprList ) pSel->pEList = 0; |
| 114133 | 114241 | pSel->pSrc = 0; |
| | @@ -116952,11 +117060,11 @@ |
| 116952 | 117060 | assert( db->lookaside.bDisable ); |
| 116953 | 117061 | if( (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0 |
| 116954 | 117062 | && IsOrdinaryTable(pStat4) |
| 116955 | 117063 | ){ |
| 116956 | 117064 | rc = loadStatTbl(db, |
| 116957 | | - "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx", |
| 117065 | + "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx COLLATE nocase", |
| 116958 | 117066 | "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4", |
| 116959 | 117067 | zDb |
| 116960 | 117068 | ); |
| 116961 | 117069 | } |
| 116962 | 117070 | return rc; |
| | @@ -129027,26 +129135,26 @@ |
| 129027 | 129135 | zFrom = pFKey->pFrom->zName; |
| 129028 | 129136 | nFrom = sqlite3Strlen30(zFrom); |
| 129029 | 129137 | |
| 129030 | 129138 | if( action==OE_Restrict ){ |
| 129031 | 129139 | int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 129032 | | - Token tFrom; |
| 129033 | | - Token tDb; |
| 129140 | + SrcList *pSrc; |
| 129034 | 129141 | Expr *pRaise; |
| 129035 | 129142 | |
| 129036 | | - tFrom.z = zFrom; |
| 129037 | | - tFrom.n = nFrom; |
| 129038 | | - tDb.z = db->aDb[iDb].zDbSName; |
| 129039 | | - tDb.n = sqlite3Strlen30(tDb.z); |
| 129040 | | - |
| 129041 | 129143 | pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); |
| 129042 | 129144 | if( pRaise ){ |
| 129043 | 129145 | pRaise->affExpr = OE_Abort; |
| 129044 | 129146 | } |
| 129147 | + pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 129148 | + if( pSrc ){ |
| 129149 | + assert( pSrc->nSrc==1 ); |
| 129150 | + pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom); |
| 129151 | + pSrc->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName); |
| 129152 | + } |
| 129045 | 129153 | pSelect = sqlite3SelectNew(pParse, |
| 129046 | 129154 | sqlite3ExprListAppend(pParse, 0, pRaise), |
| 129047 | | - sqlite3SrcListAppend(pParse, 0, &tDb, &tFrom), |
| 129155 | + pSrc, |
| 129048 | 129156 | pWhere, |
| 129049 | 129157 | 0, 0, 0, 0, 0 |
| 129050 | 129158 | ); |
| 129051 | 129159 | pWhere = 0; |
| 129052 | 129160 | } |
| | @@ -137995,11 +138103,13 @@ |
| 137995 | 138103 | encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; |
| 137996 | 138104 | if( encoding==0 ) encoding = SQLITE_UTF8; |
| 137997 | 138105 | #else |
| 137998 | 138106 | encoding = SQLITE_UTF8; |
| 137999 | 138107 | #endif |
| 138000 | | - if( db->nVdbeActive>0 && encoding!=ENC(db) ){ |
| 138108 | + if( db->nVdbeActive>0 && encoding!=ENC(db) |
| 138109 | + && (db->mDbFlags & DBFLAG_Vacuum)==0 |
| 138110 | + ){ |
| 138001 | 138111 | rc = SQLITE_LOCKED; |
| 138002 | 138112 | goto initone_error_out; |
| 138003 | 138113 | }else{ |
| 138004 | 138114 | sqlite3SetTextEncoding(db, encoding); |
| 138005 | 138115 | } |
| | @@ -138389,11 +138499,15 @@ |
| 138389 | 138499 | sParse.pOuterParse = db->pParse; |
| 138390 | 138500 | db->pParse = &sParse; |
| 138391 | 138501 | sParse.db = db; |
| 138392 | 138502 | sParse.pReprepare = pReprepare; |
| 138393 | 138503 | assert( ppStmt && *ppStmt==0 ); |
| 138394 | | - if( db->mallocFailed ) sqlite3ErrorMsg(&sParse, "out of memory"); |
| 138504 | + if( db->mallocFailed ){ |
| 138505 | + sqlite3ErrorMsg(&sParse, "out of memory"); |
| 138506 | + db->errCode = rc = SQLITE_NOMEM; |
| 138507 | + goto end_prepare; |
| 138508 | + } |
| 138395 | 138509 | assert( sqlite3_mutex_held(db->mutex) ); |
| 138396 | 138510 | |
| 138397 | 138511 | /* For a long-term use prepared statement avoid the use of |
| 138398 | 138512 | ** lookaside memory. |
| 138399 | 138513 | */ |
| | @@ -141079,11 +141193,11 @@ |
| 141079 | 141193 | |
| 141080 | 141194 | assert( pSelect!=0 ); |
| 141081 | 141195 | assert( (pSelect->selFlags & SF_Resolved)!=0 ); |
| 141082 | 141196 | assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); |
| 141083 | 141197 | assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); |
| 141084 | | - if( db->mallocFailed ) return; |
| 141198 | + if( db->mallocFailed || IN_RENAME_OBJECT ) return; |
| 141085 | 141199 | while( pSelect->pPrior ) pSelect = pSelect->pPrior; |
| 141086 | 141200 | a = pSelect->pEList->a; |
| 141087 | 141201 | memset(&sNC, 0, sizeof(sNC)); |
| 141088 | 141202 | sNC.pSrcList = pSelect->pSrc; |
| 141089 | 141203 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| | @@ -141124,22 +141238,20 @@ |
| 141124 | 141238 | if( sqlite3StdTypeAffinity[j]==pCol->affinity ){ |
| 141125 | 141239 | zType = sqlite3StdType[j]; |
| 141126 | 141240 | break; |
| 141127 | 141241 | } |
| 141128 | 141242 | } |
| 141129 | | - } |
| 141130 | | - } |
| 141131 | | - if( zType ){ |
| 141132 | | - i64 m = sqlite3Strlen30(zType); |
| 141133 | | - n = sqlite3Strlen30(pCol->zCnName); |
| 141134 | | - pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); |
| 141135 | | - if( pCol->zCnName ){ |
| 141136 | | - memcpy(&pCol->zCnName[n+1], zType, m+1); |
| 141137 | | - pCol->colFlags |= COLFLAG_HASTYPE; |
| 141138 | | - }else{ |
| 141139 | | - testcase( pCol->colFlags & COLFLAG_HASTYPE ); |
| 141140 | | - pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); |
| 141243 | + } |
| 141244 | + } |
| 141245 | + if( zType ){ |
| 141246 | + i64 m = sqlite3Strlen30(zType); |
| 141247 | + n = sqlite3Strlen30(pCol->zCnName); |
| 141248 | + pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); |
| 141249 | + pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); |
| 141250 | + if( pCol->zCnName ){ |
| 141251 | + memcpy(&pCol->zCnName[n+1], zType, m+1); |
| 141252 | + pCol->colFlags |= COLFLAG_HASTYPE; |
| 141141 | 141253 | } |
| 141142 | 141254 | } |
| 141143 | 141255 | pColl = sqlite3ExprCollSeq(pParse, p); |
| 141144 | 141256 | if( pColl ){ |
| 141145 | 141257 | assert( pTab->pIndex==0 ); |
| | @@ -144027,15 +144139,17 @@ |
| 144027 | 144139 | if( pX->pPrior && pX->op!=TK_ALL ){ |
| 144028 | 144140 | /* This optimization does not work for compound subqueries that |
| 144029 | 144141 | ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ |
| 144030 | 144142 | return 0; |
| 144031 | 144143 | } |
| 144144 | +#ifndef SQLITE_OMIT_WINDOWFUNC |
| 144032 | 144145 | if( pX->pWin ){ |
| 144033 | 144146 | /* This optimization does not work for subqueries that use window |
| 144034 | 144147 | ** functions. */ |
| 144035 | 144148 | return 0; |
| 144036 | 144149 | } |
| 144150 | +#endif |
| 144037 | 144151 | } |
| 144038 | 144152 | colUsed = pItem->colUsed; |
| 144039 | 144153 | if( pSub->pOrderBy ){ |
| 144040 | 144154 | ExprList *pList = pSub->pOrderBy; |
| 144041 | 144155 | for(j=0; j<pList->nExpr; j++){ |
| | @@ -145207,16 +145321,17 @@ |
| 145207 | 145321 | assert( pAggInfo->iFirstReg==0 ); |
| 145208 | 145322 | assert( pSelect!=0 ); |
| 145209 | 145323 | assert( pSelect->pGroupBy!=0 ); |
| 145210 | 145324 | pAggInfo->nColumn = pAggInfo->nAccumulator; |
| 145211 | 145325 | if( ALWAYS(pAggInfo->nSortingColumn>0) ){ |
| 145212 | | - if( pAggInfo->nColumn==0 ){ |
| 145213 | | - pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr; |
| 145214 | | - }else{ |
| 145215 | | - pAggInfo->nSortingColumn = |
| 145216 | | - pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1; |
| 145326 | + int mx = pSelect->pGroupBy->nExpr - 1; |
| 145327 | + int j, k; |
| 145328 | + for(j=0; j<pAggInfo->nColumn; j++){ |
| 145329 | + k = pAggInfo->aCol[j].iSorterColumn; |
| 145330 | + if( k>mx ) mx = k; |
| 145217 | 145331 | } |
| 145332 | + pAggInfo->nSortingColumn = mx+1; |
| 145218 | 145333 | } |
| 145219 | 145334 | analyzeAggFuncArgs(pAggInfo, pNC); |
| 145220 | 145335 | #if TREETRACE_ENABLED |
| 145221 | 145336 | if( sqlite3TreeTrace & 0x20 ){ |
| 145222 | 145337 | IndexedExpr *pIEpr; |
| | @@ -153970,11 +154085,11 @@ |
| 153970 | 154085 | /* If we survive all prior tests, that means this term is worth hinting */ |
| 153971 | 154086 | pExpr = sqlite3ExprAnd(pParse, pExpr, sqlite3ExprDup(db, pTerm->pExpr, 0)); |
| 153972 | 154087 | } |
| 153973 | 154088 | if( pExpr!=0 ){ |
| 153974 | 154089 | sWalker.xExprCallback = codeCursorHintFixExpr; |
| 153975 | | - sqlite3WalkExpr(&sWalker, pExpr); |
| 154090 | + if( pParse->nErr==0 ) sqlite3WalkExpr(&sWalker, pExpr); |
| 153976 | 154091 | sqlite3VdbeAddOp4(v, OP_CursorHint, |
| 153977 | 154092 | (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0, |
| 153978 | 154093 | (const char*)pExpr, P4_EXPR); |
| 153979 | 154094 | } |
| 153980 | 154095 | } |
| | @@ -163480,26 +163595,49 @@ |
| 163480 | 163595 | if( pSelect && pSelect->pLimit ){ |
| 163481 | 163596 | sqlite3WhereAddLimit(&pWInfo->sWC, pSelect); |
| 163482 | 163597 | } |
| 163483 | 163598 | if( pParse->nErr ) goto whereBeginError; |
| 163484 | 163599 | |
| 163485 | | - /* Special case: WHERE terms that do not refer to any tables in the join |
| 163486 | | - ** (constant expressions). Evaluate each such term, and jump over all the |
| 163487 | | - ** generated code if the result is not true. |
| 163488 | | - ** |
| 163489 | | - ** Do not do this if the expression contains non-deterministic functions |
| 163490 | | - ** that are not within a sub-select. This is not strictly required, but |
| 163491 | | - ** preserves SQLite's legacy behaviour in the following two cases: |
| 163492 | | - ** |
| 163493 | | - ** FROM ... WHERE random()>0; -- eval random() once per row |
| 163494 | | - ** FROM ... WHERE (SELECT random())>0; -- eval random() once overall |
| 163600 | + /* The False-WHERE-Term-Bypass optimization: |
| 163601 | + ** |
| 163602 | + ** If there are WHERE terms that are false, then no rows will be output, |
| 163603 | + ** so skip over all of the code generated here. |
| 163604 | + ** |
| 163605 | + ** Conditions: |
| 163606 | + ** |
| 163607 | + ** (1) The WHERE term must not refer to any tables in the join. |
| 163608 | + ** (2) The term must not come from an ON clause on the |
| 163609 | + ** right-hand side of a LEFT or FULL JOIN. |
| 163610 | + ** (3) The term must not come from an ON clause, or there must be |
| 163611 | + ** no RIGHT or FULL OUTER joins in pTabList. |
| 163612 | + ** (4) If the expression contains non-deterministic functions |
| 163613 | + ** that are not within a sub-select. This is not required |
| 163614 | + ** for correctness but rather to preserves SQLite's legacy |
| 163615 | + ** behaviour in the following two cases: |
| 163616 | + ** |
| 163617 | + ** WHERE random()>0; -- eval random() once per row |
| 163618 | + ** WHERE (SELECT random())>0; -- eval random() just once overall |
| 163619 | + ** |
| 163620 | + ** Note that the Where term need not be a constant in order for this |
| 163621 | + ** optimization to apply, though it does need to be constant relative to |
| 163622 | + ** the current subquery (condition 1). The term might include variables |
| 163623 | + ** from outer queries so that the value of the term changes from one |
| 163624 | + ** invocation of the current subquery to the next. |
| 163495 | 163625 | */ |
| 163496 | 163626 | for(ii=0; ii<sWLB.pWC->nBase; ii++){ |
| 163497 | | - WhereTerm *pT = &sWLB.pWC->a[ii]; |
| 163627 | + WhereTerm *pT = &sWLB.pWC->a[ii]; /* A term of the WHERE clause */ |
| 163628 | + Expr *pX; /* The expression of pT */ |
| 163498 | 163629 | if( pT->wtFlags & TERM_VIRTUAL ) continue; |
| 163499 | | - if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){ |
| 163500 | | - sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL); |
| 163630 | + pX = pT->pExpr; |
| 163631 | + assert( pX!=0 ); |
| 163632 | + assert( pT->prereqAll!=0 || !ExprHasProperty(pX, EP_OuterON) ); |
| 163633 | + if( pT->prereqAll==0 /* Conditions (1) and (2) */ |
| 163634 | + && (nTabList==0 || exprIsDeterministic(pX)) /* Condition (4) */ |
| 163635 | + && !(ExprHasProperty(pX, EP_InnerON) /* Condition (3) */ |
| 163636 | + && (pTabList->a[0].fg.jointype & JT_LTORJ)!=0 ) |
| 163637 | + ){ |
| 163638 | + sqlite3ExprIfFalse(pParse, pX, pWInfo->iBreak, SQLITE_JUMPIFNULL); |
| 163501 | 163639 | pT->wtFlags |= TERM_CODED; |
| 163502 | 163640 | } |
| 163503 | 163641 | } |
| 163504 | 163642 | |
| 163505 | 163643 | if( wctrlFlags & WHERE_WANT_DISTINCT ){ |
| | @@ -165072,10 +165210,11 @@ |
| 165072 | 165210 | } |
| 165073 | 165211 | } |
| 165074 | 165212 | } |
| 165075 | 165213 | /* no break */ deliberate_fall_through |
| 165076 | 165214 | |
| 165215 | + case TK_IF_NULL_ROW: |
| 165077 | 165216 | case TK_AGG_FUNCTION: |
| 165078 | 165217 | case TK_COLUMN: { |
| 165079 | 165218 | int iCol = -1; |
| 165080 | 165219 | if( pParse->db->mallocFailed ) return WRC_Abort; |
| 165081 | 165220 | if( p->pSub ){ |
| | @@ -167902,11 +168041,11 @@ |
| 167902 | 168041 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 167903 | 168042 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 167904 | 168043 | #define YYFALLBACK 1 |
| 167905 | 168044 | #define YYNSTATE 575 |
| 167906 | 168045 | #define YYNRULE 403 |
| 167907 | | -#define YYNRULE_WITH_ACTION 341 |
| 168046 | +#define YYNRULE_WITH_ACTION 340 |
| 167908 | 168047 | #define YYNTOKEN 185 |
| 167909 | 168048 | #define YY_MAX_SHIFT 574 |
| 167910 | 168049 | #define YY_MIN_SHIFTREDUCE 833 |
| 167911 | 168050 | #define YY_MAX_SHIFTREDUCE 1235 |
| 167912 | 168051 | #define YY_ERROR_ACTION 1236 |
| | @@ -167982,145 +168121,145 @@ |
| 167982 | 168121 | *********** Begin parsing tables **********************************************/ |
| 167983 | 168122 | #define YY_ACTTAB_COUNT (2096) |
| 167984 | 168123 | static const YYACTIONTYPE yy_action[] = { |
| 167985 | 168124 | /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, |
| 167986 | 168125 | /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, |
| 167987 | | - /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1521, 71, |
| 168126 | + /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, |
| 167988 | 168127 | /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, |
| 167989 | | - /* 40 */ 397, 71, 71, 125, 126, 80, 1213, 1213, 1047, 1050, |
| 168128 | + /* 40 */ 397, 71, 71, 125, 126, 80, 1212, 1212, 1047, 1050, |
| 167990 | 168129 | /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, |
| 167991 | 168130 | /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, |
| 167992 | 168131 | /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, |
| 167993 | | - /* 80 */ 417, 523, 142, 125, 126, 80, 1213, 1213, 1047, 1050, |
| 168132 | + /* 80 */ 417, 523, 142, 125, 126, 80, 1212, 1212, 1047, 1050, |
| 167994 | 168133 | /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, |
| 167995 | 168134 | /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, |
| 167996 | 168135 | /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, |
| 167997 | | - /* 120 */ 442, 1562, 376, 1564, 1189, 375, 1160, 565, 1160, 565, |
| 167998 | | - /* 130 */ 409, 1562, 537, 259, 226, 444, 101, 145, 449, 316, |
| 168136 | + /* 120 */ 442, 1561, 376, 1563, 1188, 375, 1159, 565, 1159, 565, |
| 168137 | + /* 130 */ 409, 1561, 537, 259, 226, 444, 101, 145, 449, 316, |
| 167999 | 168138 | /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, |
| 168000 | | - /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1213, 1213, 1047, |
| 168139 | + /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1212, 1212, 1047, |
| 168001 | 168140 | /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, |
| 168002 | | - /* 170 */ 294, 1189, 339, 448, 120, 120, 120, 119, 116, 444, |
| 168003 | | - /* 180 */ 127, 1189, 1190, 1189, 148, 441, 440, 568, 119, 116, |
| 168141 | + /* 170 */ 294, 1188, 339, 448, 120, 120, 120, 119, 116, 444, |
| 168142 | + /* 180 */ 127, 1188, 1189, 1188, 148, 441, 440, 568, 119, 116, |
| 168004 | 168143 | /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, |
| 168005 | 168144 | /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, |
| 168006 | 168145 | /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, |
| 168007 | | - /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1189, 1190, |
| 168008 | | - /* 230 */ 1189, 149, 1220, 409, 1220, 124, 124, 124, 124, 122, |
| 168146 | + /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1188, 1189, |
| 168147 | + /* 230 */ 1188, 149, 1220, 409, 1220, 124, 124, 124, 124, 122, |
| 168009 | 168148 | /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, |
| 168010 | 168149 | /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, |
| 168011 | | - /* 260 */ 1213, 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, |
| 168012 | | - /* 270 */ 124, 124, 1275, 522, 222, 1189, 568, 409, 224, 514, |
| 168150 | + /* 260 */ 1212, 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, |
| 168151 | + /* 270 */ 124, 124, 1275, 522, 222, 1188, 568, 409, 224, 514, |
| 168013 | 168152 | /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, |
| 168014 | | - /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1189, 133, |
| 168015 | | - /* 300 */ 133, 125, 126, 80, 1213, 1213, 1047, 1050, 1037, 1037, |
| 168153 | + /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1188, 133, |
| 168154 | + /* 300 */ 133, 125, 126, 80, 1212, 1212, 1047, 1050, 1037, 1037, |
| 168016 | 168155 | /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, |
| 168017 | 168156 | /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, |
| 168018 | | - /* 330 */ 1189, 373, 1189, 1190, 1189, 252, 1429, 399, 504, 501, |
| 168157 | + /* 330 */ 1188, 373, 1188, 1189, 1188, 252, 1429, 399, 504, 501, |
| 168019 | 168158 | /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, |
| 168020 | | - /* 350 */ 460, 328, 360, 394, 1233, 1189, 1190, 1189, 563, 568, |
| 168159 | + /* 350 */ 460, 328, 360, 394, 1233, 1188, 1189, 1188, 563, 568, |
| 168021 | 168160 | /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, |
| 168022 | | - /* 370 */ 116, 444, 284, 284, 369, 1575, 1601, 441, 440, 154, |
| 168023 | | - /* 380 */ 409, 445, 71, 71, 1282, 565, 1217, 1189, 1190, 1189, |
| 168024 | | - /* 390 */ 85, 1219, 271, 557, 543, 515, 1556, 568, 98, 1218, |
| 168025 | | - /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1213, 1213, 1047, |
| 168161 | + /* 370 */ 116, 444, 284, 284, 369, 1574, 1600, 441, 440, 154, |
| 168162 | + /* 380 */ 409, 445, 71, 71, 1282, 565, 1217, 1188, 1189, 1188, |
| 168163 | + /* 390 */ 85, 1219, 271, 557, 543, 515, 1555, 568, 98, 1218, |
| 168164 | + /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1212, 1212, 1047, |
| 168026 | 168165 | /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, |
| 168027 | | - /* 420 */ 13, 13, 1024, 507, 1220, 1189, 1220, 549, 109, 109, |
| 168166 | + /* 420 */ 13, 13, 1024, 507, 1220, 1188, 1220, 549, 109, 109, |
| 168028 | 168167 | /* 430 */ 222, 568, 1234, 175, 568, 427, 110, 197, 445, 569, |
| 168029 | | - /* 440 */ 445, 430, 1547, 1014, 325, 551, 1189, 270, 287, 368, |
| 168168 | + /* 440 */ 445, 430, 1546, 1014, 325, 551, 1188, 270, 287, 368, |
| 168030 | 168169 | /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, |
| 168031 | | - /* 460 */ 316, 559, 1607, 122, 122, 122, 122, 121, 121, 120, |
| 168170 | + /* 460 */ 316, 559, 1606, 122, 122, 122, 122, 121, 121, 120, |
| 168032 | 168171 | /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, |
| 168033 | | - /* 480 */ 284, 284, 1189, 1190, 1189, 1155, 568, 1606, 409, 899, |
| 168034 | | - /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1155, 516, |
| 168035 | | - /* 500 */ 413, 1155, 552, 1189, 1190, 1189, 568, 544, 1549, 51, |
| 168036 | | - /* 510 */ 51, 214, 125, 126, 80, 1213, 1213, 1047, 1050, 1037, |
| 168037 | | - /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1189, 474, 135, |
| 168038 | | - /* 530 */ 135, 409, 284, 284, 1485, 505, 121, 121, 120, 120, |
| 168039 | | - /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 1556, |
| 168040 | | - /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1213, 1213, |
| 168172 | + /* 480 */ 284, 284, 1188, 1189, 1188, 1154, 568, 1605, 409, 899, |
| 168173 | + /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1154, 516, |
| 168174 | + /* 500 */ 413, 1154, 552, 1188, 1189, 1188, 568, 544, 1548, 51, |
| 168175 | + /* 510 */ 51, 214, 125, 126, 80, 1212, 1212, 1047, 1050, 1037, |
| 168176 | + /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1188, 474, 135, |
| 168177 | + /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, |
| 168178 | + /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 1555, |
| 168179 | + /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1212, 1212, |
| 168041 | 168180 | /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 168042 | | - /* 570 */ 1550, 122, 122, 122, 122, 121, 121, 120, 120, 120, |
| 168043 | | - /* 580 */ 119, 116, 444, 485, 1189, 1190, 1189, 482, 281, 1263, |
| 168044 | | - /* 590 */ 955, 252, 1189, 373, 504, 501, 500, 1189, 340, 570, |
| 168045 | | - /* 600 */ 1189, 570, 409, 292, 499, 955, 874, 191, 480, 316, |
| 168181 | + /* 570 */ 1549, 122, 122, 122, 122, 121, 121, 120, 120, 120, |
| 168182 | + /* 580 */ 119, 116, 444, 485, 1188, 1189, 1188, 482, 281, 1263, |
| 168183 | + /* 590 */ 955, 252, 1188, 373, 504, 501, 500, 1188, 340, 570, |
| 168184 | + /* 600 */ 1188, 570, 409, 292, 499, 955, 874, 191, 480, 316, |
| 168046 | 168185 | /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, |
| 168047 | | - /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1213, |
| 168048 | | - /* 630 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168049 | | - /* 640 */ 124, 409, 394, 1133, 1189, 867, 100, 284, 284, 1189, |
| 168050 | | - /* 650 */ 1190, 1189, 373, 1090, 1189, 1190, 1189, 1189, 1190, 1189, |
| 168051 | | - /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1213, 1213, |
| 168186 | + /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, |
| 168187 | + /* 630 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168188 | + /* 640 */ 124, 409, 394, 1132, 1188, 867, 100, 284, 284, 1188, |
| 168189 | + /* 650 */ 1189, 1188, 373, 1089, 1188, 1189, 1188, 1188, 1189, 1188, |
| 168190 | + /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1212, 1212, |
| 168052 | 168191 | /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 168053 | 168192 | /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, |
| 168054 | | - /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1155, 228, 1189, |
| 168055 | | - /* 700 */ 157, 1189, 1190, 1189, 1548, 13, 13, 301, 955, 1228, |
| 168056 | | - /* 710 */ 1155, 153, 409, 1155, 373, 1578, 1173, 5, 369, 1575, |
| 168193 | + /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1154, 228, 1188, |
| 168194 | + /* 700 */ 157, 1188, 1189, 1188, 1547, 13, 13, 301, 955, 1228, |
| 168195 | + /* 710 */ 1154, 153, 409, 1154, 373, 1577, 1172, 5, 369, 1574, |
| 168057 | 168196 | /* 720 */ 429, 1234, 3, 955, 122, 122, 122, 122, 121, 121, |
| 168058 | | - /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1213, |
| 168059 | | - /* 740 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168060 | | - /* 750 */ 124, 409, 208, 567, 1189, 1025, 1189, 1190, 1189, 1189, |
| 168061 | | - /* 760 */ 388, 850, 155, 1547, 286, 402, 1095, 1095, 488, 568, |
| 168062 | | - /* 770 */ 465, 342, 1315, 1315, 1547, 125, 126, 80, 1213, 1213, |
| 168197 | + /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, |
| 168198 | + /* 740 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168199 | + /* 750 */ 124, 409, 208, 567, 1188, 1025, 1188, 1189, 1188, 1188, |
| 168200 | + /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, |
| 168201 | + /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1212, 1212, |
| 168063 | 168202 | /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 168064 | 168203 | /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, |
| 168065 | 168204 | /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, |
| 168066 | | - /* 810 */ 528, 1189, 1190, 1189, 13, 13, 1189, 1190, 1189, 1293, |
| 168067 | | - /* 820 */ 463, 1263, 409, 1313, 1313, 1547, 1010, 453, 452, 200, |
| 168205 | + /* 810 */ 528, 1188, 1189, 1188, 13, 13, 1188, 1189, 1188, 1293, |
| 168206 | + /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, |
| 168068 | 168207 | /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, |
| 168069 | | - /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1213, |
| 168070 | | - /* 850 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168071 | | - /* 860 */ 124, 409, 227, 1070, 1155, 284, 284, 419, 312, 278, |
| 168072 | | - /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1155, 565, 568, |
| 168073 | | - /* 880 */ 1155, 1192, 565, 1595, 565, 125, 126, 80, 1213, 1213, |
| 168208 | + /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, |
| 168209 | + /* 850 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168210 | + /* 860 */ 124, 409, 227, 1069, 1154, 284, 284, 419, 312, 278, |
| 168211 | + /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1154, 565, 568, |
| 168212 | + /* 880 */ 1154, 1191, 565, 1594, 565, 125, 126, 80, 1212, 1212, |
| 168074 | 168213 | /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, |
| 168075 | | - /* 900 */ 453, 1477, 13, 13, 1531, 122, 122, 122, 122, 121, |
| 168214 | + /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, |
| 168076 | 168215 | /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, |
| 168077 | | - /* 920 */ 1581, 574, 2, 1241, 838, 839, 840, 1557, 317, 1208, |
| 168078 | | - /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1192, |
| 168216 | + /* 920 */ 1580, 574, 2, 1241, 838, 839, 840, 1556, 317, 1207, |
| 168217 | + /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1191, |
| 168079 | 168218 | /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, |
| 168080 | | - /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1213, |
| 168081 | | - /* 960 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168082 | | - /* 970 */ 124, 568, 284, 284, 568, 1209, 409, 573, 313, 1241, |
| 168219 | + /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, |
| 168220 | + /* 960 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168221 | + /* 970 */ 124, 568, 284, 284, 568, 1208, 409, 573, 313, 1241, |
| 168083 | 168222 | /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1637, |
| 168084 | 168223 | /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, |
| 168085 | | - /* 1000 */ 1321, 104, 80, 1213, 1213, 1047, 1050, 1037, 1037, 123, |
| 168224 | + /* 1000 */ 1321, 104, 80, 1212, 1212, 1047, 1050, 1037, 1037, 123, |
| 168086 | 168225 | /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, |
| 168087 | | - /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1111, 284, 284, |
| 168088 | | - /* 1030 */ 428, 448, 1520, 1209, 439, 284, 284, 1484, 1348, 311, |
| 168089 | | - /* 1040 */ 474, 565, 1112, 969, 491, 491, 217, 1259, 565, 1533, |
| 168090 | | - /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1113, 519, 122, |
| 168226 | + /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, |
| 168227 | + /* 1030 */ 428, 448, 1519, 1208, 439, 284, 284, 1483, 1348, 311, |
| 168228 | + /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, |
| 168229 | + /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, |
| 168091 | 168230 | /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, |
| 168092 | 168231 | /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, |
| 168093 | | - /* 1080 */ 1490, 568, 284, 284, 97, 526, 491, 448, 911, 1322, |
| 168094 | | - /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1490, 1492, |
| 168232 | + /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, |
| 168233 | + /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, |
| 168095 | 168234 | /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, |
| 168096 | | - /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1213, |
| 168097 | | - /* 1120 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168098 | | - /* 1130 */ 124, 347, 409, 862, 1529, 1209, 125, 126, 80, 1213, |
| 168099 | | - /* 1140 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168100 | | - /* 1150 */ 124, 1134, 1635, 474, 1635, 371, 125, 114, 80, 1213, |
| 168101 | | - /* 1160 */ 1213, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168102 | | - /* 1170 */ 124, 1490, 329, 474, 331, 122, 122, 122, 122, 121, |
| 168235 | + /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1212, |
| 168236 | + /* 1120 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168237 | + /* 1130 */ 124, 347, 409, 862, 1528, 1208, 125, 126, 80, 1212, |
| 168238 | + /* 1140 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168239 | + /* 1150 */ 124, 1133, 1635, 474, 1635, 371, 125, 114, 80, 1212, |
| 168240 | + /* 1160 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, |
| 168241 | + /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, |
| 168103 | 168242 | /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, |
| 168104 | | - /* 1190 */ 1290, 862, 464, 1209, 436, 122, 122, 122, 122, 121, |
| 168105 | | - /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1134, 1636, |
| 168243 | + /* 1190 */ 1290, 862, 464, 1208, 436, 122, 122, 122, 122, 121, |
| 168244 | + /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1636, |
| 168106 | 168245 | /* 1210 */ 539, 1636, 15, 15, 890, 122, 122, 122, 122, 121, |
| 168107 | 168246 | /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, |
| 168108 | | - /* 1230 */ 1132, 1415, 1554, 1555, 1327, 409, 6, 6, 1166, 1264, |
| 168247 | + /* 1230 */ 1131, 1415, 1553, 1554, 1327, 409, 6, 6, 1165, 1264, |
| 168109 | 168248 | /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, |
| 168110 | 168249 | /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, |
| 168111 | | - /* 1260 */ 126, 80, 1213, 1213, 1047, 1050, 1037, 1037, 123, 123, |
| 168112 | | - /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1189, 1415, |
| 168113 | | - /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1132, 1553, 847, |
| 168114 | | - /* 1290 */ 1166, 407, 6, 568, 321, 1155, 470, 44, 44, 1552, |
| 168115 | | - /* 1300 */ 1111, 426, 234, 6, 323, 256, 540, 256, 1155, 431, |
| 168116 | | - /* 1310 */ 568, 1155, 322, 17, 487, 1112, 58, 58, 122, 122, |
| 168250 | + /* 1260 */ 126, 80, 1212, 1212, 1047, 1050, 1037, 1037, 123, 123, |
| 168251 | + /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1188, 1415, |
| 168252 | + /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1552, 847, |
| 168253 | + /* 1290 */ 1165, 407, 6, 568, 321, 1154, 470, 44, 44, 1551, |
| 168254 | + /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1154, 431, |
| 168255 | + /* 1310 */ 568, 1154, 322, 17, 487, 1111, 58, 58, 122, 122, |
| 168117 | 168256 | /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, |
| 168118 | | - /* 1330 */ 1113, 216, 481, 59, 59, 1189, 1190, 1189, 111, 560, |
| 168257 | + /* 1330 */ 1112, 216, 481, 59, 59, 1188, 1189, 1188, 111, 560, |
| 168119 | 168258 | /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, |
| 168120 | | - /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1092, |
| 168121 | | - /* 1360 */ 568, 293, 568, 1092, 531, 568, 870, 8, 60, 60, |
| 168259 | + /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, |
| 168260 | + /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, |
| 168122 | 168261 | /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, |
| 168123 | 168262 | /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, |
| 168124 | 168263 | /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, |
| 168125 | 168264 | /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, |
| 168126 | 168265 | /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, |
| | @@ -168127,73 +168266,73 @@ |
| 168127 | 168266 | /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, |
| 168128 | 168267 | /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, |
| 168129 | 168268 | /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, |
| 168130 | 168269 | /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, |
| 168131 | 168270 | /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, |
| 168132 | | - /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1580, 1177, 447, |
| 168133 | | - /* 1480 */ 69, 69, 288, 97, 108, 1536, 106, 392, 392, 391, |
| 168271 | + /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1579, 1176, 447, |
| 168272 | + /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, |
| 168134 | 168273 | /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, |
| 168135 | | - /* 1500 */ 4, 568, 152, 30, 38, 568, 1129, 234, 396, 323, |
| 168274 | + /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, |
| 168136 | 168275 | /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, |
| 168137 | 168276 | /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, |
| 168138 | | - /* 1530 */ 568, 289, 1509, 568, 31, 1508, 568, 445, 338, 483, |
| 168139 | | - /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1077, 557, |
| 168277 | + /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, |
| 168278 | + /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, |
| 168140 | 168279 | /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, |
| 168141 | | - /* 1560 */ 161, 1569, 557, 535, 568, 319, 568, 348, 536, 1007, |
| 168280 | + /* 1560 */ 161, 1568, 557, 535, 568, 319, 568, 348, 536, 1007, |
| 168142 | 168281 | /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, |
| 168143 | 168282 | /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, |
| 168144 | 168283 | /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, |
| 168145 | | - /* 1600 */ 162, 162, 156, 156, 568, 110, 1077, 445, 569, 445, |
| 168284 | + /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, |
| 168146 | 168285 | /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, |
| 168147 | 168286 | /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, |
| 168148 | 168287 | /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, |
| 168149 | | - /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1177, |
| 168288 | + /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1176, |
| 168150 | 168289 | /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, |
| 168151 | | - /* 1660 */ 391, 273, 389, 568, 1138, 847, 568, 1073, 568, 258, |
| 168290 | + /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, |
| 168152 | 168291 | /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, |
| 168153 | 168292 | /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, |
| 168154 | 168293 | /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, |
| 168155 | | - /* 1700 */ 973, 1089, 1088, 1089, 1088, 860, 557, 150, 928, 1342, |
| 168294 | + /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, |
| 168156 | 168295 | /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, |
| 168157 | | - /* 1720 */ 1251, 445, 1588, 1339, 308, 276, 168, 309, 11, 141, |
| 168296 | + /* 1720 */ 1251, 445, 1587, 1339, 308, 276, 168, 309, 11, 141, |
| 168158 | 168297 | /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, |
| 168159 | 168298 | /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, |
| 168160 | 168299 | /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, |
| 168161 | | - /* 1760 */ 223, 1481, 1024, 1480, 1351, 1352, 1350, 1349, 109, 109, |
| 168162 | | - /* 1770 */ 204, 1591, 1228, 558, 265, 218, 110, 205, 445, 569, |
| 168163 | | - /* 1780 */ 445, 410, 387, 1014, 1528, 179, 316, 559, 1014, 1014, |
| 168164 | | - /* 1790 */ 1016, 1017, 27, 230, 1526, 1225, 79, 560, 85, 4, |
| 168300 | + /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, |
| 168301 | + /* 1770 */ 204, 1590, 1228, 558, 265, 218, 110, 205, 445, 569, |
| 168302 | + /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, |
| 168303 | + /* 1790 */ 1016, 1017, 27, 230, 1525, 1225, 79, 560, 85, 4, |
| 168165 | 168304 | /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, |
| 168166 | 168305 | /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, |
| 168167 | | - /* 1820 */ 184, 1486, 185, 186, 495, 242, 98, 398, 1408, 36, |
| 168168 | | - /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1475, 246, |
| 168169 | | - /* 1840 */ 1497, 490, 346, 277, 248, 196, 493, 511, 557, 350, |
| 168306 | + /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, |
| 168307 | + /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, |
| 168308 | + /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, |
| 168170 | 168309 | /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, |
| 168171 | | - /* 1860 */ 1307, 1300, 93, 1605, 881, 1604, 224, 404, 434, 520, |
| 168172 | | - /* 1870 */ 263, 435, 1574, 563, 1279, 1278, 364, 1024, 306, 1277, |
| 168173 | | - /* 1880 */ 264, 1603, 1560, 109, 109, 370, 1299, 307, 1559, 438, |
| 168310 | + /* 1860 */ 1307, 1300, 93, 1604, 881, 1603, 224, 404, 434, 520, |
| 168311 | + /* 1870 */ 263, 435, 1573, 563, 1279, 1278, 364, 1024, 306, 1277, |
| 168312 | + /* 1880 */ 264, 1602, 1559, 109, 109, 370, 1299, 307, 1558, 438, |
| 168174 | 168313 | /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, |
| 168175 | 168314 | /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, |
| 168176 | | - /* 1910 */ 1183, 530, 272, 274, 379, 210, 1331, 547, 385, 386, |
| 168177 | | - /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1513, 165, 178, 1514, |
| 168178 | | - /* 1930 */ 1014, 1014, 1016, 1017, 27, 1512, 1511, 1024, 78, 147, |
| 168315 | + /* 1910 */ 1182, 530, 272, 274, 379, 210, 1331, 547, 385, 386, |
| 168316 | + /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, |
| 168317 | + /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, |
| 168179 | 168318 | /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, |
| 168180 | | - /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1087, 1014, 1085, |
| 168181 | | - /* 1960 */ 326, 180, 169, 1208, 182, 334, 238, 913, 241, 1101, |
| 168319 | + /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, |
| 168320 | + /* 1960 */ 326, 180, 169, 1207, 182, 334, 238, 913, 241, 1100, |
| 168182 | 168321 | /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, |
| 168183 | | - /* 1980 */ 172, 1104, 243, 1100, 244, 158, 18, 245, 345, 247, |
| 168184 | | - /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1093, 193, 1222, 489, |
| 168322 | + /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, |
| 168323 | + /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1222, 489, |
| 168185 | 168324 | /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, |
| 168186 | 168325 | /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, |
| 168187 | | - /* 2020 */ 513, 39, 95, 1171, 160, 1053, 964, 1140, 96, 174, |
| 168188 | | - /* 2030 */ 1139, 225, 280, 282, 198, 958, 113, 1161, 1157, 260, |
| 168189 | | - /* 2040 */ 21, 22, 23, 1159, 1165, 1164, 1145, 24, 33, 25, |
| 168190 | | - /* 2050 */ 202, 542, 26, 100, 1068, 102, 1054, 103, 7, 1052, |
| 168191 | | - /* 2060 */ 1056, 1110, 1057, 1109, 266, 267, 28, 40, 390, 1019, |
| 168192 | | - /* 2070 */ 861, 112, 29, 564, 1179, 1178, 268, 176, 143, 923, |
| 168326 | + /* 2020 */ 513, 39, 95, 1170, 160, 1053, 964, 1139, 96, 174, |
| 168327 | + /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1160, 1156, 260, |
| 168328 | + /* 2040 */ 21, 22, 23, 1158, 1164, 1163, 1144, 24, 33, 25, |
| 168329 | + /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, |
| 168330 | + /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, |
| 168331 | + /* 2070 */ 861, 112, 29, 564, 1178, 1177, 268, 176, 143, 923, |
| 168193 | 168332 | /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, |
| 168194 | | - /* 2090 */ 1238, 1238, 1238, 1238, 269, 1596, |
| 168333 | + /* 2090 */ 1238, 1238, 1238, 1238, 269, 1595, |
| 168195 | 168334 | }; |
| 168196 | 168335 | static const YYCODETYPE yy_lookahead[] = { |
| 168197 | 168336 | /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, |
| 168198 | 168337 | /* 10 */ 193, 223, 219, 225, 206, 210, 211, 212, 193, 19, |
| 168199 | 168338 | /* 20 */ 219, 233, 216, 216, 217, 216, 217, 193, 295, 216, |
| | @@ -168532,67 +168671,67 @@ |
| 168532 | 168671 | /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, |
| 168533 | 168672 | /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, |
| 168534 | 168673 | /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, |
| 168535 | 168674 | }; |
| 168536 | 168675 | static const YYACTIONTYPE yy_default[] = { |
| 168537 | | - /* 0 */ 1641, 1641, 1641, 1470, 1236, 1347, 1236, 1236, 1236, 1470, |
| 168538 | | - /* 10 */ 1470, 1470, 1236, 1377, 1377, 1523, 1269, 1236, 1236, 1236, |
| 168539 | | - /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1469, 1236, 1236, |
| 168540 | | - /* 30 */ 1236, 1236, 1558, 1558, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168676 | + /* 0 */ 1641, 1641, 1641, 1469, 1236, 1347, 1236, 1236, 1236, 1469, |
| 168677 | + /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, |
| 168678 | + /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, |
| 168679 | + /* 30 */ 1236, 1236, 1557, 1557, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168541 | 168680 | /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, |
| 168542 | | - /* 50 */ 1471, 1472, 1236, 1236, 1236, 1522, 1524, 1487, 1400, 1399, |
| 168543 | | - /* 60 */ 1398, 1397, 1505, 1365, 1391, 1384, 1388, 1465, 1466, 1464, |
| 168544 | | - /* 70 */ 1468, 1472, 1471, 1236, 1387, 1433, 1449, 1432, 1236, 1236, |
| 168681 | + /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, |
| 168682 | + /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, |
| 168683 | + /* 70 */ 1619, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, |
| 168545 | 168684 | /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168546 | 168685 | /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168547 | 168686 | /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168548 | 168687 | /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168549 | 168688 | /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168550 | 168689 | /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, |
| 168551 | 168690 | /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, |
| 168552 | | - /* 150 */ 1236, 1236, 1236, 1542, 1541, 1236, 1438, 1236, 1269, 1427, |
| 168553 | | - /* 160 */ 1426, 1452, 1439, 1451, 1450, 1530, 1594, 1593, 1488, 1236, |
| 168554 | | - /* 170 */ 1236, 1236, 1236, 1236, 1236, 1558, 1236, 1236, 1236, 1236, |
| 168691 | + /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, |
| 168692 | + /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1593, 1592, 1487, 1236, |
| 168693 | + /* 170 */ 1236, 1236, 1236, 1236, 1236, 1557, 1236, 1236, 1236, 1236, |
| 168555 | 168694 | /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168556 | 168695 | /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, |
| 168557 | | - /* 200 */ 1558, 1558, 1236, 1269, 1558, 1558, 1368, 1368, 1265, 1265, |
| 168558 | | - /* 210 */ 1371, 1236, 1537, 1338, 1338, 1338, 1338, 1347, 1338, 1236, |
| 168696 | + /* 200 */ 1557, 1557, 1236, 1269, 1557, 1557, 1368, 1368, 1265, 1265, |
| 168697 | + /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, |
| 168559 | 168698 | /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168560 | | - /* 230 */ 1236, 1236, 1236, 1236, 1527, 1525, 1236, 1236, 1236, 1236, |
| 168699 | + /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, |
| 168561 | 168700 | /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168562 | 168701 | /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168563 | 168702 | /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168564 | | - /* 270 */ 1236, 1236, 1236, 1236, 1236, 1587, 1236, 1500, 1325, 1343, |
| 168703 | + /* 270 */ 1236, 1236, 1236, 1236, 1236, 1586, 1236, 1499, 1325, 1343, |
| 168565 | 168704 | /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1633, |
| 168566 | 168705 | /* 290 */ 1403, 1392, 1344, 1392, 1630, 1390, 1403, 1403, 1390, 1403, |
| 168567 | | - /* 300 */ 1344, 1630, 1286, 1609, 1281, 1377, 1377, 1377, 1367, 1367, |
| 168706 | + /* 300 */ 1344, 1630, 1286, 1608, 1281, 1377, 1377, 1377, 1367, 1367, |
| 168568 | 168707 | /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1633, 1633, |
| 168569 | | - /* 320 */ 1353, 1353, 1632, 1632, 1353, 1488, 1617, 1412, 1314, 1320, |
| 168570 | | - /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1617, 1617, 1390, 1412, |
| 168571 | | - /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1504, 1627, 1353, 1254, |
| 168572 | | - /* 350 */ 1478, 1353, 1254, 1353, 1254, 1478, 1312, 1312, 1312, 1301, |
| 168573 | | - /* 360 */ 1236, 1236, 1478, 1312, 1286, 1312, 1301, 1312, 1312, 1576, |
| 168574 | | - /* 370 */ 1236, 1482, 1482, 1478, 1353, 1568, 1568, 1380, 1380, 1385, |
| 168575 | | - /* 380 */ 1371, 1473, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1590, |
| 168576 | | - /* 390 */ 1590, 1586, 1586, 1586, 1638, 1638, 1537, 1602, 1269, 1269, |
| 168577 | | - /* 400 */ 1269, 1269, 1602, 1288, 1288, 1270, 1270, 1269, 1602, 1236, |
| 168578 | | - /* 410 */ 1236, 1236, 1236, 1236, 1236, 1597, 1236, 1532, 1489, 1357, |
| 168708 | + /* 320 */ 1353, 1353, 1632, 1632, 1353, 1487, 1616, 1412, 1314, 1320, |
| 168709 | + /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1616, 1616, 1390, 1412, |
| 168710 | + /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1627, 1353, 1254, |
| 168711 | + /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, |
| 168712 | + /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1575, |
| 168713 | + /* 370 */ 1236, 1481, 1481, 1477, 1353, 1567, 1567, 1380, 1380, 1385, |
| 168714 | + /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1589, |
| 168715 | + /* 390 */ 1589, 1585, 1585, 1585, 1638, 1638, 1536, 1601, 1269, 1269, |
| 168716 | + /* 400 */ 1269, 1269, 1601, 1288, 1288, 1270, 1270, 1269, 1601, 1236, |
| 168717 | + /* 410 */ 1236, 1236, 1236, 1236, 1236, 1596, 1236, 1531, 1488, 1357, |
| 168579 | 168718 | /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168580 | | - /* 430 */ 1236, 1236, 1236, 1236, 1543, 1236, 1236, 1236, 1236, 1236, |
| 168581 | | - /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1534, 1236, |
| 168719 | + /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, |
| 168720 | + /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, |
| 168582 | 168721 | /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, |
| 168583 | 168722 | /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, |
| 168584 | 168723 | /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168585 | | - /* 480 */ 1629, 1236, 1236, 1236, 1236, 1236, 1236, 1503, 1502, 1236, |
| 168724 | + /* 480 */ 1629, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, |
| 168586 | 168725 | /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168587 | 168726 | /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, |
| 168588 | 168727 | /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168589 | 168728 | /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, |
| 168590 | 168729 | /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168591 | | - /* 540 */ 1236, 1236, 1236, 1236, 1573, 1372, 1236, 1236, 1236, 1236, |
| 168730 | + /* 540 */ 1236, 1236, 1236, 1236, 1572, 1372, 1236, 1236, 1236, 1236, |
| 168592 | 168731 | /* 550 */ 1620, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, |
| 168593 | | - /* 560 */ 1236, 1236, 1236, 1236, 1236, 1613, 1328, 1418, 1236, 1421, |
| 168732 | + /* 560 */ 1236, 1236, 1236, 1236, 1236, 1612, 1328, 1418, 1236, 1421, |
| 168594 | 168733 | /* 570 */ 1258, 1236, 1248, 1236, 1236, |
| 168595 | 168734 | }; |
| 168596 | 168735 | /********** End of lemon-generated parsing tables *****************************/ |
| 168597 | 168736 | |
| 168598 | 168737 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| | @@ -169437,162 +169576,162 @@ |
| 169437 | 169576 | /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 169438 | 169577 | /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 169439 | 169578 | /* 226 */ "case_exprlist ::= WHEN expr THEN expr", |
| 169440 | 169579 | /* 227 */ "case_else ::= ELSE expr", |
| 169441 | 169580 | /* 228 */ "case_else ::=", |
| 169442 | | - /* 229 */ "case_operand ::= expr", |
| 169443 | | - /* 230 */ "case_operand ::=", |
| 169444 | | - /* 231 */ "exprlist ::=", |
| 169445 | | - /* 232 */ "nexprlist ::= nexprlist COMMA expr", |
| 169446 | | - /* 233 */ "nexprlist ::= expr", |
| 169447 | | - /* 234 */ "paren_exprlist ::=", |
| 169448 | | - /* 235 */ "paren_exprlist ::= LP exprlist RP", |
| 169449 | | - /* 236 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 169450 | | - /* 237 */ "uniqueflag ::= UNIQUE", |
| 169451 | | - /* 238 */ "uniqueflag ::=", |
| 169452 | | - /* 239 */ "eidlist_opt ::=", |
| 169453 | | - /* 240 */ "eidlist_opt ::= LP eidlist RP", |
| 169454 | | - /* 241 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 169455 | | - /* 242 */ "eidlist ::= nm collate sortorder", |
| 169456 | | - /* 243 */ "collate ::=", |
| 169457 | | - /* 244 */ "collate ::= COLLATE ID|STRING", |
| 169458 | | - /* 245 */ "cmd ::= DROP INDEX ifexists fullname", |
| 169459 | | - /* 246 */ "cmd ::= VACUUM vinto", |
| 169460 | | - /* 247 */ "cmd ::= VACUUM nm vinto", |
| 169461 | | - /* 248 */ "vinto ::= INTO expr", |
| 169462 | | - /* 249 */ "vinto ::=", |
| 169463 | | - /* 250 */ "cmd ::= PRAGMA nm dbnm", |
| 169464 | | - /* 251 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 169465 | | - /* 252 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 169466 | | - /* 253 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 169467 | | - /* 254 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 169468 | | - /* 255 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 169469 | | - /* 256 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 169470 | | - /* 257 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 169471 | | - /* 258 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 169472 | | - /* 259 */ "trigger_time ::= BEFORE|AFTER", |
| 169473 | | - /* 260 */ "trigger_time ::= INSTEAD OF", |
| 169474 | | - /* 261 */ "trigger_time ::=", |
| 169475 | | - /* 262 */ "trigger_event ::= DELETE|INSERT", |
| 169476 | | - /* 263 */ "trigger_event ::= UPDATE", |
| 169477 | | - /* 264 */ "trigger_event ::= UPDATE OF idlist", |
| 169478 | | - /* 265 */ "when_clause ::=", |
| 169479 | | - /* 266 */ "when_clause ::= WHEN expr", |
| 169480 | | - /* 267 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 169481 | | - /* 268 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 169482 | | - /* 269 */ "trnm ::= nm DOT nm", |
| 169483 | | - /* 270 */ "tridxby ::= INDEXED BY nm", |
| 169484 | | - /* 271 */ "tridxby ::= NOT INDEXED", |
| 169485 | | - /* 272 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 169486 | | - /* 273 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 169487 | | - /* 274 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 169488 | | - /* 275 */ "trigger_cmd ::= scanpt select scanpt", |
| 169489 | | - /* 276 */ "expr ::= RAISE LP IGNORE RP", |
| 169490 | | - /* 277 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 169491 | | - /* 278 */ "raisetype ::= ROLLBACK", |
| 169492 | | - /* 279 */ "raisetype ::= ABORT", |
| 169493 | | - /* 280 */ "raisetype ::= FAIL", |
| 169494 | | - /* 281 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 169495 | | - /* 282 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 169496 | | - /* 283 */ "cmd ::= DETACH database_kw_opt expr", |
| 169497 | | - /* 284 */ "key_opt ::=", |
| 169498 | | - /* 285 */ "key_opt ::= KEY expr", |
| 169499 | | - /* 286 */ "cmd ::= REINDEX", |
| 169500 | | - /* 287 */ "cmd ::= REINDEX nm dbnm", |
| 169501 | | - /* 288 */ "cmd ::= ANALYZE", |
| 169502 | | - /* 289 */ "cmd ::= ANALYZE nm dbnm", |
| 169503 | | - /* 290 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 169504 | | - /* 291 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 169505 | | - /* 292 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 169506 | | - /* 293 */ "add_column_fullname ::= fullname", |
| 169507 | | - /* 294 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 169508 | | - /* 295 */ "cmd ::= create_vtab", |
| 169509 | | - /* 296 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 169510 | | - /* 297 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 169511 | | - /* 298 */ "vtabarg ::=", |
| 169512 | | - /* 299 */ "vtabargtoken ::= ANY", |
| 169513 | | - /* 300 */ "vtabargtoken ::= lp anylist RP", |
| 169514 | | - /* 301 */ "lp ::= LP", |
| 169515 | | - /* 302 */ "with ::= WITH wqlist", |
| 169516 | | - /* 303 */ "with ::= WITH RECURSIVE wqlist", |
| 169517 | | - /* 304 */ "wqas ::= AS", |
| 169518 | | - /* 305 */ "wqas ::= AS MATERIALIZED", |
| 169519 | | - /* 306 */ "wqas ::= AS NOT MATERIALIZED", |
| 169520 | | - /* 307 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 169521 | | - /* 308 */ "wqlist ::= wqitem", |
| 169522 | | - /* 309 */ "wqlist ::= wqlist COMMA wqitem", |
| 169523 | | - /* 310 */ "windowdefn_list ::= windowdefn", |
| 169524 | | - /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 169525 | | - /* 312 */ "windowdefn ::= nm AS LP window RP", |
| 169526 | | - /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 169527 | | - /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 169528 | | - /* 315 */ "window ::= ORDER BY sortlist frame_opt", |
| 169529 | | - /* 316 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 169530 | | - /* 317 */ "window ::= frame_opt", |
| 169531 | | - /* 318 */ "window ::= nm frame_opt", |
| 169532 | | - /* 319 */ "frame_opt ::=", |
| 169533 | | - /* 320 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 169534 | | - /* 321 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 169535 | | - /* 322 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 169536 | | - /* 323 */ "frame_bound_s ::= frame_bound", |
| 169537 | | - /* 324 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 169538 | | - /* 325 */ "frame_bound_e ::= frame_bound", |
| 169539 | | - /* 326 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 169540 | | - /* 327 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 169541 | | - /* 328 */ "frame_bound ::= CURRENT ROW", |
| 169542 | | - /* 329 */ "frame_exclude_opt ::=", |
| 169543 | | - /* 330 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 169544 | | - /* 331 */ "frame_exclude ::= NO OTHERS", |
| 169545 | | - /* 332 */ "frame_exclude ::= CURRENT ROW", |
| 169546 | | - /* 333 */ "frame_exclude ::= GROUP|TIES", |
| 169547 | | - /* 334 */ "window_clause ::= WINDOW windowdefn_list", |
| 169548 | | - /* 335 */ "filter_over ::= filter_clause over_clause", |
| 169549 | | - /* 336 */ "filter_over ::= over_clause", |
| 169550 | | - /* 337 */ "filter_over ::= filter_clause", |
| 169551 | | - /* 338 */ "over_clause ::= OVER LP window RP", |
| 169552 | | - /* 339 */ "over_clause ::= OVER nm", |
| 169553 | | - /* 340 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 169554 | | - /* 341 */ "input ::= cmdlist", |
| 169555 | | - /* 342 */ "cmdlist ::= cmdlist ecmd", |
| 169556 | | - /* 343 */ "cmdlist ::= ecmd", |
| 169557 | | - /* 344 */ "ecmd ::= SEMI", |
| 169558 | | - /* 345 */ "ecmd ::= cmdx SEMI", |
| 169559 | | - /* 346 */ "ecmd ::= explain cmdx SEMI", |
| 169560 | | - /* 347 */ "trans_opt ::=", |
| 169561 | | - /* 348 */ "trans_opt ::= TRANSACTION", |
| 169562 | | - /* 349 */ "trans_opt ::= TRANSACTION nm", |
| 169563 | | - /* 350 */ "savepoint_opt ::= SAVEPOINT", |
| 169564 | | - /* 351 */ "savepoint_opt ::=", |
| 169565 | | - /* 352 */ "cmd ::= create_table create_table_args", |
| 169566 | | - /* 353 */ "table_option_set ::= table_option", |
| 169567 | | - /* 354 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 169568 | | - /* 355 */ "columnlist ::= columnname carglist", |
| 169569 | | - /* 356 */ "nm ::= ID|INDEXED|JOIN_KW", |
| 169570 | | - /* 357 */ "nm ::= STRING", |
| 169571 | | - /* 358 */ "typetoken ::= typename", |
| 169572 | | - /* 359 */ "typename ::= ID|STRING", |
| 169573 | | - /* 360 */ "signed ::= plus_num", |
| 169574 | | - /* 361 */ "signed ::= minus_num", |
| 169575 | | - /* 362 */ "carglist ::= carglist ccons", |
| 169576 | | - /* 363 */ "carglist ::=", |
| 169577 | | - /* 364 */ "ccons ::= NULL onconf", |
| 169578 | | - /* 365 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 169579 | | - /* 366 */ "ccons ::= AS generated", |
| 169580 | | - /* 367 */ "conslist_opt ::= COMMA conslist", |
| 169581 | | - /* 368 */ "conslist ::= conslist tconscomma tcons", |
| 169582 | | - /* 369 */ "conslist ::= tcons", |
| 169583 | | - /* 370 */ "tconscomma ::=", |
| 169584 | | - /* 371 */ "defer_subclause_opt ::= defer_subclause", |
| 169585 | | - /* 372 */ "resolvetype ::= raisetype", |
| 169586 | | - /* 373 */ "selectnowith ::= oneselect", |
| 169587 | | - /* 374 */ "oneselect ::= values", |
| 169588 | | - /* 375 */ "sclp ::= selcollist COMMA", |
| 169589 | | - /* 376 */ "as ::= ID|STRING", |
| 169590 | | - /* 377 */ "indexed_opt ::= indexed_by", |
| 169591 | | - /* 378 */ "returning ::=", |
| 169592 | | - /* 379 */ "expr ::= term", |
| 169593 | | - /* 380 */ "likeop ::= LIKE_KW|MATCH", |
| 169581 | + /* 229 */ "case_operand ::=", |
| 169582 | + /* 230 */ "exprlist ::=", |
| 169583 | + /* 231 */ "nexprlist ::= nexprlist COMMA expr", |
| 169584 | + /* 232 */ "nexprlist ::= expr", |
| 169585 | + /* 233 */ "paren_exprlist ::=", |
| 169586 | + /* 234 */ "paren_exprlist ::= LP exprlist RP", |
| 169587 | + /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 169588 | + /* 236 */ "uniqueflag ::= UNIQUE", |
| 169589 | + /* 237 */ "uniqueflag ::=", |
| 169590 | + /* 238 */ "eidlist_opt ::=", |
| 169591 | + /* 239 */ "eidlist_opt ::= LP eidlist RP", |
| 169592 | + /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 169593 | + /* 241 */ "eidlist ::= nm collate sortorder", |
| 169594 | + /* 242 */ "collate ::=", |
| 169595 | + /* 243 */ "collate ::= COLLATE ID|STRING", |
| 169596 | + /* 244 */ "cmd ::= DROP INDEX ifexists fullname", |
| 169597 | + /* 245 */ "cmd ::= VACUUM vinto", |
| 169598 | + /* 246 */ "cmd ::= VACUUM nm vinto", |
| 169599 | + /* 247 */ "vinto ::= INTO expr", |
| 169600 | + /* 248 */ "vinto ::=", |
| 169601 | + /* 249 */ "cmd ::= PRAGMA nm dbnm", |
| 169602 | + /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 169603 | + /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 169604 | + /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 169605 | + /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 169606 | + /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 169607 | + /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 169608 | + /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 169609 | + /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 169610 | + /* 258 */ "trigger_time ::= BEFORE|AFTER", |
| 169611 | + /* 259 */ "trigger_time ::= INSTEAD OF", |
| 169612 | + /* 260 */ "trigger_time ::=", |
| 169613 | + /* 261 */ "trigger_event ::= DELETE|INSERT", |
| 169614 | + /* 262 */ "trigger_event ::= UPDATE", |
| 169615 | + /* 263 */ "trigger_event ::= UPDATE OF idlist", |
| 169616 | + /* 264 */ "when_clause ::=", |
| 169617 | + /* 265 */ "when_clause ::= WHEN expr", |
| 169618 | + /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 169619 | + /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 169620 | + /* 268 */ "trnm ::= nm DOT nm", |
| 169621 | + /* 269 */ "tridxby ::= INDEXED BY nm", |
| 169622 | + /* 270 */ "tridxby ::= NOT INDEXED", |
| 169623 | + /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 169624 | + /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 169625 | + /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 169626 | + /* 274 */ "trigger_cmd ::= scanpt select scanpt", |
| 169627 | + /* 275 */ "expr ::= RAISE LP IGNORE RP", |
| 169628 | + /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 169629 | + /* 277 */ "raisetype ::= ROLLBACK", |
| 169630 | + /* 278 */ "raisetype ::= ABORT", |
| 169631 | + /* 279 */ "raisetype ::= FAIL", |
| 169632 | + /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 169633 | + /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 169634 | + /* 282 */ "cmd ::= DETACH database_kw_opt expr", |
| 169635 | + /* 283 */ "key_opt ::=", |
| 169636 | + /* 284 */ "key_opt ::= KEY expr", |
| 169637 | + /* 285 */ "cmd ::= REINDEX", |
| 169638 | + /* 286 */ "cmd ::= REINDEX nm dbnm", |
| 169639 | + /* 287 */ "cmd ::= ANALYZE", |
| 169640 | + /* 288 */ "cmd ::= ANALYZE nm dbnm", |
| 169641 | + /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 169642 | + /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 169643 | + /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 169644 | + /* 292 */ "add_column_fullname ::= fullname", |
| 169645 | + /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 169646 | + /* 294 */ "cmd ::= create_vtab", |
| 169647 | + /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 169648 | + /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 169649 | + /* 297 */ "vtabarg ::=", |
| 169650 | + /* 298 */ "vtabargtoken ::= ANY", |
| 169651 | + /* 299 */ "vtabargtoken ::= lp anylist RP", |
| 169652 | + /* 300 */ "lp ::= LP", |
| 169653 | + /* 301 */ "with ::= WITH wqlist", |
| 169654 | + /* 302 */ "with ::= WITH RECURSIVE wqlist", |
| 169655 | + /* 303 */ "wqas ::= AS", |
| 169656 | + /* 304 */ "wqas ::= AS MATERIALIZED", |
| 169657 | + /* 305 */ "wqas ::= AS NOT MATERIALIZED", |
| 169658 | + /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 169659 | + /* 307 */ "wqlist ::= wqitem", |
| 169660 | + /* 308 */ "wqlist ::= wqlist COMMA wqitem", |
| 169661 | + /* 309 */ "windowdefn_list ::= windowdefn", |
| 169662 | + /* 310 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 169663 | + /* 311 */ "windowdefn ::= nm AS LP window RP", |
| 169664 | + /* 312 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 169665 | + /* 313 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 169666 | + /* 314 */ "window ::= ORDER BY sortlist frame_opt", |
| 169667 | + /* 315 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 169668 | + /* 316 */ "window ::= frame_opt", |
| 169669 | + /* 317 */ "window ::= nm frame_opt", |
| 169670 | + /* 318 */ "frame_opt ::=", |
| 169671 | + /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 169672 | + /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 169673 | + /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 169674 | + /* 322 */ "frame_bound_s ::= frame_bound", |
| 169675 | + /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 169676 | + /* 324 */ "frame_bound_e ::= frame_bound", |
| 169677 | + /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 169678 | + /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 169679 | + /* 327 */ "frame_bound ::= CURRENT ROW", |
| 169680 | + /* 328 */ "frame_exclude_opt ::=", |
| 169681 | + /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 169682 | + /* 330 */ "frame_exclude ::= NO OTHERS", |
| 169683 | + /* 331 */ "frame_exclude ::= CURRENT ROW", |
| 169684 | + /* 332 */ "frame_exclude ::= GROUP|TIES", |
| 169685 | + /* 333 */ "window_clause ::= WINDOW windowdefn_list", |
| 169686 | + /* 334 */ "filter_over ::= filter_clause over_clause", |
| 169687 | + /* 335 */ "filter_over ::= over_clause", |
| 169688 | + /* 336 */ "filter_over ::= filter_clause", |
| 169689 | + /* 337 */ "over_clause ::= OVER LP window RP", |
| 169690 | + /* 338 */ "over_clause ::= OVER nm", |
| 169691 | + /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 169692 | + /* 340 */ "input ::= cmdlist", |
| 169693 | + /* 341 */ "cmdlist ::= cmdlist ecmd", |
| 169694 | + /* 342 */ "cmdlist ::= ecmd", |
| 169695 | + /* 343 */ "ecmd ::= SEMI", |
| 169696 | + /* 344 */ "ecmd ::= cmdx SEMI", |
| 169697 | + /* 345 */ "ecmd ::= explain cmdx SEMI", |
| 169698 | + /* 346 */ "trans_opt ::=", |
| 169699 | + /* 347 */ "trans_opt ::= TRANSACTION", |
| 169700 | + /* 348 */ "trans_opt ::= TRANSACTION nm", |
| 169701 | + /* 349 */ "savepoint_opt ::= SAVEPOINT", |
| 169702 | + /* 350 */ "savepoint_opt ::=", |
| 169703 | + /* 351 */ "cmd ::= create_table create_table_args", |
| 169704 | + /* 352 */ "table_option_set ::= table_option", |
| 169705 | + /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 169706 | + /* 354 */ "columnlist ::= columnname carglist", |
| 169707 | + /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", |
| 169708 | + /* 356 */ "nm ::= STRING", |
| 169709 | + /* 357 */ "typetoken ::= typename", |
| 169710 | + /* 358 */ "typename ::= ID|STRING", |
| 169711 | + /* 359 */ "signed ::= plus_num", |
| 169712 | + /* 360 */ "signed ::= minus_num", |
| 169713 | + /* 361 */ "carglist ::= carglist ccons", |
| 169714 | + /* 362 */ "carglist ::=", |
| 169715 | + /* 363 */ "ccons ::= NULL onconf", |
| 169716 | + /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 169717 | + /* 365 */ "ccons ::= AS generated", |
| 169718 | + /* 366 */ "conslist_opt ::= COMMA conslist", |
| 169719 | + /* 367 */ "conslist ::= conslist tconscomma tcons", |
| 169720 | + /* 368 */ "conslist ::= tcons", |
| 169721 | + /* 369 */ "tconscomma ::=", |
| 169722 | + /* 370 */ "defer_subclause_opt ::= defer_subclause", |
| 169723 | + /* 371 */ "resolvetype ::= raisetype", |
| 169724 | + /* 372 */ "selectnowith ::= oneselect", |
| 169725 | + /* 373 */ "oneselect ::= values", |
| 169726 | + /* 374 */ "sclp ::= selcollist COMMA", |
| 169727 | + /* 375 */ "as ::= ID|STRING", |
| 169728 | + /* 376 */ "indexed_opt ::= indexed_by", |
| 169729 | + /* 377 */ "returning ::=", |
| 169730 | + /* 378 */ "expr ::= term", |
| 169731 | + /* 379 */ "likeop ::= LIKE_KW|MATCH", |
| 169732 | + /* 380 */ "case_operand ::= expr", |
| 169594 | 169733 | /* 381 */ "exprlist ::= nexprlist", |
| 169595 | 169734 | /* 382 */ "nmnum ::= plus_num", |
| 169596 | 169735 | /* 383 */ "nmnum ::= nm", |
| 169597 | 169736 | /* 384 */ "nmnum ::= ON", |
| 169598 | 169737 | /* 385 */ "nmnum ::= DELETE", |
| | @@ -170346,162 +170485,162 @@ |
| 170346 | 170485 | 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ |
| 170347 | 170486 | 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 170348 | 170487 | 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ |
| 170349 | 170488 | 280, /* (227) case_else ::= ELSE expr */ |
| 170350 | 170489 | 280, /* (228) case_else ::= */ |
| 170351 | | - 278, /* (229) case_operand ::= expr */ |
| 170352 | | - 278, /* (230) case_operand ::= */ |
| 170353 | | - 261, /* (231) exprlist ::= */ |
| 170354 | | - 253, /* (232) nexprlist ::= nexprlist COMMA expr */ |
| 170355 | | - 253, /* (233) nexprlist ::= expr */ |
| 170356 | | - 277, /* (234) paren_exprlist ::= */ |
| 170357 | | - 277, /* (235) paren_exprlist ::= LP exprlist RP */ |
| 170358 | | - 190, /* (236) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 170359 | | - 281, /* (237) uniqueflag ::= UNIQUE */ |
| 170360 | | - 281, /* (238) uniqueflag ::= */ |
| 170361 | | - 221, /* (239) eidlist_opt ::= */ |
| 170362 | | - 221, /* (240) eidlist_opt ::= LP eidlist RP */ |
| 170363 | | - 232, /* (241) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 170364 | | - 232, /* (242) eidlist ::= nm collate sortorder */ |
| 170365 | | - 282, /* (243) collate ::= */ |
| 170366 | | - 282, /* (244) collate ::= COLLATE ID|STRING */ |
| 170367 | | - 190, /* (245) cmd ::= DROP INDEX ifexists fullname */ |
| 170368 | | - 190, /* (246) cmd ::= VACUUM vinto */ |
| 170369 | | - 190, /* (247) cmd ::= VACUUM nm vinto */ |
| 170370 | | - 283, /* (248) vinto ::= INTO expr */ |
| 170371 | | - 283, /* (249) vinto ::= */ |
| 170372 | | - 190, /* (250) cmd ::= PRAGMA nm dbnm */ |
| 170373 | | - 190, /* (251) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 170374 | | - 190, /* (252) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 170375 | | - 190, /* (253) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 170376 | | - 190, /* (254) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 170377 | | - 211, /* (255) plus_num ::= PLUS INTEGER|FLOAT */ |
| 170378 | | - 212, /* (256) minus_num ::= MINUS INTEGER|FLOAT */ |
| 170379 | | - 190, /* (257) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 170380 | | - 285, /* (258) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 170381 | | - 287, /* (259) trigger_time ::= BEFORE|AFTER */ |
| 170382 | | - 287, /* (260) trigger_time ::= INSTEAD OF */ |
| 170383 | | - 287, /* (261) trigger_time ::= */ |
| 170384 | | - 288, /* (262) trigger_event ::= DELETE|INSERT */ |
| 170385 | | - 288, /* (263) trigger_event ::= UPDATE */ |
| 170386 | | - 288, /* (264) trigger_event ::= UPDATE OF idlist */ |
| 170387 | | - 290, /* (265) when_clause ::= */ |
| 170388 | | - 290, /* (266) when_clause ::= WHEN expr */ |
| 170389 | | - 286, /* (267) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 170390 | | - 286, /* (268) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 170391 | | - 292, /* (269) trnm ::= nm DOT nm */ |
| 170392 | | - 293, /* (270) tridxby ::= INDEXED BY nm */ |
| 170393 | | - 293, /* (271) tridxby ::= NOT INDEXED */ |
| 170394 | | - 291, /* (272) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 170395 | | - 291, /* (273) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 170396 | | - 291, /* (274) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 170397 | | - 291, /* (275) trigger_cmd ::= scanpt select scanpt */ |
| 170398 | | - 217, /* (276) expr ::= RAISE LP IGNORE RP */ |
| 170399 | | - 217, /* (277) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 170400 | | - 236, /* (278) raisetype ::= ROLLBACK */ |
| 170401 | | - 236, /* (279) raisetype ::= ABORT */ |
| 170402 | | - 236, /* (280) raisetype ::= FAIL */ |
| 170403 | | - 190, /* (281) cmd ::= DROP TRIGGER ifexists fullname */ |
| 170404 | | - 190, /* (282) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 170405 | | - 190, /* (283) cmd ::= DETACH database_kw_opt expr */ |
| 170406 | | - 295, /* (284) key_opt ::= */ |
| 170407 | | - 295, /* (285) key_opt ::= KEY expr */ |
| 170408 | | - 190, /* (286) cmd ::= REINDEX */ |
| 170409 | | - 190, /* (287) cmd ::= REINDEX nm dbnm */ |
| 170410 | | - 190, /* (288) cmd ::= ANALYZE */ |
| 170411 | | - 190, /* (289) cmd ::= ANALYZE nm dbnm */ |
| 170412 | | - 190, /* (290) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 170413 | | - 190, /* (291) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 170414 | | - 190, /* (292) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 170415 | | - 296, /* (293) add_column_fullname ::= fullname */ |
| 170416 | | - 190, /* (294) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 170417 | | - 190, /* (295) cmd ::= create_vtab */ |
| 170418 | | - 190, /* (296) cmd ::= create_vtab LP vtabarglist RP */ |
| 170419 | | - 298, /* (297) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 170420 | | - 300, /* (298) vtabarg ::= */ |
| 170421 | | - 301, /* (299) vtabargtoken ::= ANY */ |
| 170422 | | - 301, /* (300) vtabargtoken ::= lp anylist RP */ |
| 170423 | | - 302, /* (301) lp ::= LP */ |
| 170424 | | - 266, /* (302) with ::= WITH wqlist */ |
| 170425 | | - 266, /* (303) with ::= WITH RECURSIVE wqlist */ |
| 170426 | | - 305, /* (304) wqas ::= AS */ |
| 170427 | | - 305, /* (305) wqas ::= AS MATERIALIZED */ |
| 170428 | | - 305, /* (306) wqas ::= AS NOT MATERIALIZED */ |
| 170429 | | - 304, /* (307) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 170430 | | - 241, /* (308) wqlist ::= wqitem */ |
| 170431 | | - 241, /* (309) wqlist ::= wqlist COMMA wqitem */ |
| 170432 | | - 306, /* (310) windowdefn_list ::= windowdefn */ |
| 170433 | | - 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 170434 | | - 307, /* (312) windowdefn ::= nm AS LP window RP */ |
| 170435 | | - 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170436 | | - 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170437 | | - 308, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 170438 | | - 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 170439 | | - 308, /* (317) window ::= frame_opt */ |
| 170440 | | - 308, /* (318) window ::= nm frame_opt */ |
| 170441 | | - 309, /* (319) frame_opt ::= */ |
| 170442 | | - 309, /* (320) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 170443 | | - 309, /* (321) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 170444 | | - 313, /* (322) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 170445 | | - 315, /* (323) frame_bound_s ::= frame_bound */ |
| 170446 | | - 315, /* (324) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 170447 | | - 316, /* (325) frame_bound_e ::= frame_bound */ |
| 170448 | | - 316, /* (326) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 170449 | | - 314, /* (327) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 170450 | | - 314, /* (328) frame_bound ::= CURRENT ROW */ |
| 170451 | | - 317, /* (329) frame_exclude_opt ::= */ |
| 170452 | | - 317, /* (330) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 170453 | | - 318, /* (331) frame_exclude ::= NO OTHERS */ |
| 170454 | | - 318, /* (332) frame_exclude ::= CURRENT ROW */ |
| 170455 | | - 318, /* (333) frame_exclude ::= GROUP|TIES */ |
| 170456 | | - 251, /* (334) window_clause ::= WINDOW windowdefn_list */ |
| 170457 | | - 273, /* (335) filter_over ::= filter_clause over_clause */ |
| 170458 | | - 273, /* (336) filter_over ::= over_clause */ |
| 170459 | | - 273, /* (337) filter_over ::= filter_clause */ |
| 170460 | | - 312, /* (338) over_clause ::= OVER LP window RP */ |
| 170461 | | - 312, /* (339) over_clause ::= OVER nm */ |
| 170462 | | - 311, /* (340) filter_clause ::= FILTER LP WHERE expr RP */ |
| 170463 | | - 185, /* (341) input ::= cmdlist */ |
| 170464 | | - 186, /* (342) cmdlist ::= cmdlist ecmd */ |
| 170465 | | - 186, /* (343) cmdlist ::= ecmd */ |
| 170466 | | - 187, /* (344) ecmd ::= SEMI */ |
| 170467 | | - 187, /* (345) ecmd ::= cmdx SEMI */ |
| 170468 | | - 187, /* (346) ecmd ::= explain cmdx SEMI */ |
| 170469 | | - 192, /* (347) trans_opt ::= */ |
| 170470 | | - 192, /* (348) trans_opt ::= TRANSACTION */ |
| 170471 | | - 192, /* (349) trans_opt ::= TRANSACTION nm */ |
| 170472 | | - 194, /* (350) savepoint_opt ::= SAVEPOINT */ |
| 170473 | | - 194, /* (351) savepoint_opt ::= */ |
| 170474 | | - 190, /* (352) cmd ::= create_table create_table_args */ |
| 170475 | | - 203, /* (353) table_option_set ::= table_option */ |
| 170476 | | - 201, /* (354) columnlist ::= columnlist COMMA columnname carglist */ |
| 170477 | | - 201, /* (355) columnlist ::= columnname carglist */ |
| 170478 | | - 193, /* (356) nm ::= ID|INDEXED|JOIN_KW */ |
| 170479 | | - 193, /* (357) nm ::= STRING */ |
| 170480 | | - 208, /* (358) typetoken ::= typename */ |
| 170481 | | - 209, /* (359) typename ::= ID|STRING */ |
| 170482 | | - 210, /* (360) signed ::= plus_num */ |
| 170483 | | - 210, /* (361) signed ::= minus_num */ |
| 170484 | | - 207, /* (362) carglist ::= carglist ccons */ |
| 170485 | | - 207, /* (363) carglist ::= */ |
| 170486 | | - 215, /* (364) ccons ::= NULL onconf */ |
| 170487 | | - 215, /* (365) ccons ::= GENERATED ALWAYS AS generated */ |
| 170488 | | - 215, /* (366) ccons ::= AS generated */ |
| 170489 | | - 202, /* (367) conslist_opt ::= COMMA conslist */ |
| 170490 | | - 228, /* (368) conslist ::= conslist tconscomma tcons */ |
| 170491 | | - 228, /* (369) conslist ::= tcons */ |
| 170492 | | - 229, /* (370) tconscomma ::= */ |
| 170493 | | - 233, /* (371) defer_subclause_opt ::= defer_subclause */ |
| 170494 | | - 235, /* (372) resolvetype ::= raisetype */ |
| 170495 | | - 239, /* (373) selectnowith ::= oneselect */ |
| 170496 | | - 240, /* (374) oneselect ::= values */ |
| 170497 | | - 254, /* (375) sclp ::= selcollist COMMA */ |
| 170498 | | - 255, /* (376) as ::= ID|STRING */ |
| 170499 | | - 264, /* (377) indexed_opt ::= indexed_by */ |
| 170500 | | - 272, /* (378) returning ::= */ |
| 170501 | | - 217, /* (379) expr ::= term */ |
| 170502 | | - 274, /* (380) likeop ::= LIKE_KW|MATCH */ |
| 170490 | + 278, /* (229) case_operand ::= */ |
| 170491 | + 261, /* (230) exprlist ::= */ |
| 170492 | + 253, /* (231) nexprlist ::= nexprlist COMMA expr */ |
| 170493 | + 253, /* (232) nexprlist ::= expr */ |
| 170494 | + 277, /* (233) paren_exprlist ::= */ |
| 170495 | + 277, /* (234) paren_exprlist ::= LP exprlist RP */ |
| 170496 | + 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 170497 | + 281, /* (236) uniqueflag ::= UNIQUE */ |
| 170498 | + 281, /* (237) uniqueflag ::= */ |
| 170499 | + 221, /* (238) eidlist_opt ::= */ |
| 170500 | + 221, /* (239) eidlist_opt ::= LP eidlist RP */ |
| 170501 | + 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 170502 | + 232, /* (241) eidlist ::= nm collate sortorder */ |
| 170503 | + 282, /* (242) collate ::= */ |
| 170504 | + 282, /* (243) collate ::= COLLATE ID|STRING */ |
| 170505 | + 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ |
| 170506 | + 190, /* (245) cmd ::= VACUUM vinto */ |
| 170507 | + 190, /* (246) cmd ::= VACUUM nm vinto */ |
| 170508 | + 283, /* (247) vinto ::= INTO expr */ |
| 170509 | + 283, /* (248) vinto ::= */ |
| 170510 | + 190, /* (249) cmd ::= PRAGMA nm dbnm */ |
| 170511 | + 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 170512 | + 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 170513 | + 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 170514 | + 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 170515 | + 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ |
| 170516 | + 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ |
| 170517 | + 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 170518 | + 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 170519 | + 287, /* (258) trigger_time ::= BEFORE|AFTER */ |
| 170520 | + 287, /* (259) trigger_time ::= INSTEAD OF */ |
| 170521 | + 287, /* (260) trigger_time ::= */ |
| 170522 | + 288, /* (261) trigger_event ::= DELETE|INSERT */ |
| 170523 | + 288, /* (262) trigger_event ::= UPDATE */ |
| 170524 | + 288, /* (263) trigger_event ::= UPDATE OF idlist */ |
| 170525 | + 290, /* (264) when_clause ::= */ |
| 170526 | + 290, /* (265) when_clause ::= WHEN expr */ |
| 170527 | + 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 170528 | + 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 170529 | + 292, /* (268) trnm ::= nm DOT nm */ |
| 170530 | + 293, /* (269) tridxby ::= INDEXED BY nm */ |
| 170531 | + 293, /* (270) tridxby ::= NOT INDEXED */ |
| 170532 | + 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 170533 | + 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 170534 | + 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 170535 | + 291, /* (274) trigger_cmd ::= scanpt select scanpt */ |
| 170536 | + 217, /* (275) expr ::= RAISE LP IGNORE RP */ |
| 170537 | + 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 170538 | + 236, /* (277) raisetype ::= ROLLBACK */ |
| 170539 | + 236, /* (278) raisetype ::= ABORT */ |
| 170540 | + 236, /* (279) raisetype ::= FAIL */ |
| 170541 | + 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ |
| 170542 | + 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 170543 | + 190, /* (282) cmd ::= DETACH database_kw_opt expr */ |
| 170544 | + 295, /* (283) key_opt ::= */ |
| 170545 | + 295, /* (284) key_opt ::= KEY expr */ |
| 170546 | + 190, /* (285) cmd ::= REINDEX */ |
| 170547 | + 190, /* (286) cmd ::= REINDEX nm dbnm */ |
| 170548 | + 190, /* (287) cmd ::= ANALYZE */ |
| 170549 | + 190, /* (288) cmd ::= ANALYZE nm dbnm */ |
| 170550 | + 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 170551 | + 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 170552 | + 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 170553 | + 296, /* (292) add_column_fullname ::= fullname */ |
| 170554 | + 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 170555 | + 190, /* (294) cmd ::= create_vtab */ |
| 170556 | + 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ |
| 170557 | + 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 170558 | + 300, /* (297) vtabarg ::= */ |
| 170559 | + 301, /* (298) vtabargtoken ::= ANY */ |
| 170560 | + 301, /* (299) vtabargtoken ::= lp anylist RP */ |
| 170561 | + 302, /* (300) lp ::= LP */ |
| 170562 | + 266, /* (301) with ::= WITH wqlist */ |
| 170563 | + 266, /* (302) with ::= WITH RECURSIVE wqlist */ |
| 170564 | + 305, /* (303) wqas ::= AS */ |
| 170565 | + 305, /* (304) wqas ::= AS MATERIALIZED */ |
| 170566 | + 305, /* (305) wqas ::= AS NOT MATERIALIZED */ |
| 170567 | + 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 170568 | + 241, /* (307) wqlist ::= wqitem */ |
| 170569 | + 241, /* (308) wqlist ::= wqlist COMMA wqitem */ |
| 170570 | + 306, /* (309) windowdefn_list ::= windowdefn */ |
| 170571 | + 306, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 170572 | + 307, /* (311) windowdefn ::= nm AS LP window RP */ |
| 170573 | + 308, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170574 | + 308, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170575 | + 308, /* (314) window ::= ORDER BY sortlist frame_opt */ |
| 170576 | + 308, /* (315) window ::= nm ORDER BY sortlist frame_opt */ |
| 170577 | + 308, /* (316) window ::= frame_opt */ |
| 170578 | + 308, /* (317) window ::= nm frame_opt */ |
| 170579 | + 309, /* (318) frame_opt ::= */ |
| 170580 | + 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 170581 | + 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 170582 | + 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 170583 | + 315, /* (322) frame_bound_s ::= frame_bound */ |
| 170584 | + 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 170585 | + 316, /* (324) frame_bound_e ::= frame_bound */ |
| 170586 | + 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 170587 | + 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 170588 | + 314, /* (327) frame_bound ::= CURRENT ROW */ |
| 170589 | + 317, /* (328) frame_exclude_opt ::= */ |
| 170590 | + 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 170591 | + 318, /* (330) frame_exclude ::= NO OTHERS */ |
| 170592 | + 318, /* (331) frame_exclude ::= CURRENT ROW */ |
| 170593 | + 318, /* (332) frame_exclude ::= GROUP|TIES */ |
| 170594 | + 251, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 170595 | + 273, /* (334) filter_over ::= filter_clause over_clause */ |
| 170596 | + 273, /* (335) filter_over ::= over_clause */ |
| 170597 | + 273, /* (336) filter_over ::= filter_clause */ |
| 170598 | + 312, /* (337) over_clause ::= OVER LP window RP */ |
| 170599 | + 312, /* (338) over_clause ::= OVER nm */ |
| 170600 | + 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 170601 | + 185, /* (340) input ::= cmdlist */ |
| 170602 | + 186, /* (341) cmdlist ::= cmdlist ecmd */ |
| 170603 | + 186, /* (342) cmdlist ::= ecmd */ |
| 170604 | + 187, /* (343) ecmd ::= SEMI */ |
| 170605 | + 187, /* (344) ecmd ::= cmdx SEMI */ |
| 170606 | + 187, /* (345) ecmd ::= explain cmdx SEMI */ |
| 170607 | + 192, /* (346) trans_opt ::= */ |
| 170608 | + 192, /* (347) trans_opt ::= TRANSACTION */ |
| 170609 | + 192, /* (348) trans_opt ::= TRANSACTION nm */ |
| 170610 | + 194, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 170611 | + 194, /* (350) savepoint_opt ::= */ |
| 170612 | + 190, /* (351) cmd ::= create_table create_table_args */ |
| 170613 | + 203, /* (352) table_option_set ::= table_option */ |
| 170614 | + 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 170615 | + 201, /* (354) columnlist ::= columnname carglist */ |
| 170616 | + 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 170617 | + 193, /* (356) nm ::= STRING */ |
| 170618 | + 208, /* (357) typetoken ::= typename */ |
| 170619 | + 209, /* (358) typename ::= ID|STRING */ |
| 170620 | + 210, /* (359) signed ::= plus_num */ |
| 170621 | + 210, /* (360) signed ::= minus_num */ |
| 170622 | + 207, /* (361) carglist ::= carglist ccons */ |
| 170623 | + 207, /* (362) carglist ::= */ |
| 170624 | + 215, /* (363) ccons ::= NULL onconf */ |
| 170625 | + 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 170626 | + 215, /* (365) ccons ::= AS generated */ |
| 170627 | + 202, /* (366) conslist_opt ::= COMMA conslist */ |
| 170628 | + 228, /* (367) conslist ::= conslist tconscomma tcons */ |
| 170629 | + 228, /* (368) conslist ::= tcons */ |
| 170630 | + 229, /* (369) tconscomma ::= */ |
| 170631 | + 233, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 170632 | + 235, /* (371) resolvetype ::= raisetype */ |
| 170633 | + 239, /* (372) selectnowith ::= oneselect */ |
| 170634 | + 240, /* (373) oneselect ::= values */ |
| 170635 | + 254, /* (374) sclp ::= selcollist COMMA */ |
| 170636 | + 255, /* (375) as ::= ID|STRING */ |
| 170637 | + 264, /* (376) indexed_opt ::= indexed_by */ |
| 170638 | + 272, /* (377) returning ::= */ |
| 170639 | + 217, /* (378) expr ::= term */ |
| 170640 | + 274, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 170641 | + 278, /* (380) case_operand ::= expr */ |
| 170503 | 170642 | 261, /* (381) exprlist ::= nexprlist */ |
| 170504 | 170643 | 284, /* (382) nmnum ::= plus_num */ |
| 170505 | 170644 | 284, /* (383) nmnum ::= nm */ |
| 170506 | 170645 | 284, /* (384) nmnum ::= ON */ |
| 170507 | 170646 | 284, /* (385) nmnum ::= DELETE */ |
| | @@ -170754,162 +170893,162 @@ |
| 170754 | 170893 | -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ |
| 170755 | 170894 | -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 170756 | 170895 | -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ |
| 170757 | 170896 | -2, /* (227) case_else ::= ELSE expr */ |
| 170758 | 170897 | 0, /* (228) case_else ::= */ |
| 170759 | | - -1, /* (229) case_operand ::= expr */ |
| 170760 | | - 0, /* (230) case_operand ::= */ |
| 170761 | | - 0, /* (231) exprlist ::= */ |
| 170762 | | - -3, /* (232) nexprlist ::= nexprlist COMMA expr */ |
| 170763 | | - -1, /* (233) nexprlist ::= expr */ |
| 170764 | | - 0, /* (234) paren_exprlist ::= */ |
| 170765 | | - -3, /* (235) paren_exprlist ::= LP exprlist RP */ |
| 170766 | | - -12, /* (236) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 170767 | | - -1, /* (237) uniqueflag ::= UNIQUE */ |
| 170768 | | - 0, /* (238) uniqueflag ::= */ |
| 170769 | | - 0, /* (239) eidlist_opt ::= */ |
| 170770 | | - -3, /* (240) eidlist_opt ::= LP eidlist RP */ |
| 170771 | | - -5, /* (241) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 170772 | | - -3, /* (242) eidlist ::= nm collate sortorder */ |
| 170773 | | - 0, /* (243) collate ::= */ |
| 170774 | | - -2, /* (244) collate ::= COLLATE ID|STRING */ |
| 170775 | | - -4, /* (245) cmd ::= DROP INDEX ifexists fullname */ |
| 170776 | | - -2, /* (246) cmd ::= VACUUM vinto */ |
| 170777 | | - -3, /* (247) cmd ::= VACUUM nm vinto */ |
| 170778 | | - -2, /* (248) vinto ::= INTO expr */ |
| 170779 | | - 0, /* (249) vinto ::= */ |
| 170780 | | - -3, /* (250) cmd ::= PRAGMA nm dbnm */ |
| 170781 | | - -5, /* (251) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 170782 | | - -6, /* (252) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 170783 | | - -5, /* (253) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 170784 | | - -6, /* (254) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 170785 | | - -2, /* (255) plus_num ::= PLUS INTEGER|FLOAT */ |
| 170786 | | - -2, /* (256) minus_num ::= MINUS INTEGER|FLOAT */ |
| 170787 | | - -5, /* (257) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 170788 | | - -11, /* (258) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 170789 | | - -1, /* (259) trigger_time ::= BEFORE|AFTER */ |
| 170790 | | - -2, /* (260) trigger_time ::= INSTEAD OF */ |
| 170791 | | - 0, /* (261) trigger_time ::= */ |
| 170792 | | - -1, /* (262) trigger_event ::= DELETE|INSERT */ |
| 170793 | | - -1, /* (263) trigger_event ::= UPDATE */ |
| 170794 | | - -3, /* (264) trigger_event ::= UPDATE OF idlist */ |
| 170795 | | - 0, /* (265) when_clause ::= */ |
| 170796 | | - -2, /* (266) when_clause ::= WHEN expr */ |
| 170797 | | - -3, /* (267) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 170798 | | - -2, /* (268) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 170799 | | - -3, /* (269) trnm ::= nm DOT nm */ |
| 170800 | | - -3, /* (270) tridxby ::= INDEXED BY nm */ |
| 170801 | | - -2, /* (271) tridxby ::= NOT INDEXED */ |
| 170802 | | - -9, /* (272) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 170803 | | - -8, /* (273) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 170804 | | - -6, /* (274) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 170805 | | - -3, /* (275) trigger_cmd ::= scanpt select scanpt */ |
| 170806 | | - -4, /* (276) expr ::= RAISE LP IGNORE RP */ |
| 170807 | | - -6, /* (277) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 170808 | | - -1, /* (278) raisetype ::= ROLLBACK */ |
| 170809 | | - -1, /* (279) raisetype ::= ABORT */ |
| 170810 | | - -1, /* (280) raisetype ::= FAIL */ |
| 170811 | | - -4, /* (281) cmd ::= DROP TRIGGER ifexists fullname */ |
| 170812 | | - -6, /* (282) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 170813 | | - -3, /* (283) cmd ::= DETACH database_kw_opt expr */ |
| 170814 | | - 0, /* (284) key_opt ::= */ |
| 170815 | | - -2, /* (285) key_opt ::= KEY expr */ |
| 170816 | | - -1, /* (286) cmd ::= REINDEX */ |
| 170817 | | - -3, /* (287) cmd ::= REINDEX nm dbnm */ |
| 170818 | | - -1, /* (288) cmd ::= ANALYZE */ |
| 170819 | | - -3, /* (289) cmd ::= ANALYZE nm dbnm */ |
| 170820 | | - -6, /* (290) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 170821 | | - -7, /* (291) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 170822 | | - -6, /* (292) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 170823 | | - -1, /* (293) add_column_fullname ::= fullname */ |
| 170824 | | - -8, /* (294) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 170825 | | - -1, /* (295) cmd ::= create_vtab */ |
| 170826 | | - -4, /* (296) cmd ::= create_vtab LP vtabarglist RP */ |
| 170827 | | - -8, /* (297) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 170828 | | - 0, /* (298) vtabarg ::= */ |
| 170829 | | - -1, /* (299) vtabargtoken ::= ANY */ |
| 170830 | | - -3, /* (300) vtabargtoken ::= lp anylist RP */ |
| 170831 | | - -1, /* (301) lp ::= LP */ |
| 170832 | | - -2, /* (302) with ::= WITH wqlist */ |
| 170833 | | - -3, /* (303) with ::= WITH RECURSIVE wqlist */ |
| 170834 | | - -1, /* (304) wqas ::= AS */ |
| 170835 | | - -2, /* (305) wqas ::= AS MATERIALIZED */ |
| 170836 | | - -3, /* (306) wqas ::= AS NOT MATERIALIZED */ |
| 170837 | | - -6, /* (307) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 170838 | | - -1, /* (308) wqlist ::= wqitem */ |
| 170839 | | - -3, /* (309) wqlist ::= wqlist COMMA wqitem */ |
| 170840 | | - -1, /* (310) windowdefn_list ::= windowdefn */ |
| 170841 | | - -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 170842 | | - -5, /* (312) windowdefn ::= nm AS LP window RP */ |
| 170843 | | - -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170844 | | - -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170845 | | - -4, /* (315) window ::= ORDER BY sortlist frame_opt */ |
| 170846 | | - -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */ |
| 170847 | | - -1, /* (317) window ::= frame_opt */ |
| 170848 | | - -2, /* (318) window ::= nm frame_opt */ |
| 170849 | | - 0, /* (319) frame_opt ::= */ |
| 170850 | | - -3, /* (320) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 170851 | | - -6, /* (321) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 170852 | | - -1, /* (322) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 170853 | | - -1, /* (323) frame_bound_s ::= frame_bound */ |
| 170854 | | - -2, /* (324) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 170855 | | - -1, /* (325) frame_bound_e ::= frame_bound */ |
| 170856 | | - -2, /* (326) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 170857 | | - -2, /* (327) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 170858 | | - -2, /* (328) frame_bound ::= CURRENT ROW */ |
| 170859 | | - 0, /* (329) frame_exclude_opt ::= */ |
| 170860 | | - -2, /* (330) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 170861 | | - -2, /* (331) frame_exclude ::= NO OTHERS */ |
| 170862 | | - -2, /* (332) frame_exclude ::= CURRENT ROW */ |
| 170863 | | - -1, /* (333) frame_exclude ::= GROUP|TIES */ |
| 170864 | | - -2, /* (334) window_clause ::= WINDOW windowdefn_list */ |
| 170865 | | - -2, /* (335) filter_over ::= filter_clause over_clause */ |
| 170866 | | - -1, /* (336) filter_over ::= over_clause */ |
| 170867 | | - -1, /* (337) filter_over ::= filter_clause */ |
| 170868 | | - -4, /* (338) over_clause ::= OVER LP window RP */ |
| 170869 | | - -2, /* (339) over_clause ::= OVER nm */ |
| 170870 | | - -5, /* (340) filter_clause ::= FILTER LP WHERE expr RP */ |
| 170871 | | - -1, /* (341) input ::= cmdlist */ |
| 170872 | | - -2, /* (342) cmdlist ::= cmdlist ecmd */ |
| 170873 | | - -1, /* (343) cmdlist ::= ecmd */ |
| 170874 | | - -1, /* (344) ecmd ::= SEMI */ |
| 170875 | | - -2, /* (345) ecmd ::= cmdx SEMI */ |
| 170876 | | - -3, /* (346) ecmd ::= explain cmdx SEMI */ |
| 170877 | | - 0, /* (347) trans_opt ::= */ |
| 170878 | | - -1, /* (348) trans_opt ::= TRANSACTION */ |
| 170879 | | - -2, /* (349) trans_opt ::= TRANSACTION nm */ |
| 170880 | | - -1, /* (350) savepoint_opt ::= SAVEPOINT */ |
| 170881 | | - 0, /* (351) savepoint_opt ::= */ |
| 170882 | | - -2, /* (352) cmd ::= create_table create_table_args */ |
| 170883 | | - -1, /* (353) table_option_set ::= table_option */ |
| 170884 | | - -4, /* (354) columnlist ::= columnlist COMMA columnname carglist */ |
| 170885 | | - -2, /* (355) columnlist ::= columnname carglist */ |
| 170886 | | - -1, /* (356) nm ::= ID|INDEXED|JOIN_KW */ |
| 170887 | | - -1, /* (357) nm ::= STRING */ |
| 170888 | | - -1, /* (358) typetoken ::= typename */ |
| 170889 | | - -1, /* (359) typename ::= ID|STRING */ |
| 170890 | | - -1, /* (360) signed ::= plus_num */ |
| 170891 | | - -1, /* (361) signed ::= minus_num */ |
| 170892 | | - -2, /* (362) carglist ::= carglist ccons */ |
| 170893 | | - 0, /* (363) carglist ::= */ |
| 170894 | | - -2, /* (364) ccons ::= NULL onconf */ |
| 170895 | | - -4, /* (365) ccons ::= GENERATED ALWAYS AS generated */ |
| 170896 | | - -2, /* (366) ccons ::= AS generated */ |
| 170897 | | - -2, /* (367) conslist_opt ::= COMMA conslist */ |
| 170898 | | - -3, /* (368) conslist ::= conslist tconscomma tcons */ |
| 170899 | | - -1, /* (369) conslist ::= tcons */ |
| 170900 | | - 0, /* (370) tconscomma ::= */ |
| 170901 | | - -1, /* (371) defer_subclause_opt ::= defer_subclause */ |
| 170902 | | - -1, /* (372) resolvetype ::= raisetype */ |
| 170903 | | - -1, /* (373) selectnowith ::= oneselect */ |
| 170904 | | - -1, /* (374) oneselect ::= values */ |
| 170905 | | - -2, /* (375) sclp ::= selcollist COMMA */ |
| 170906 | | - -1, /* (376) as ::= ID|STRING */ |
| 170907 | | - -1, /* (377) indexed_opt ::= indexed_by */ |
| 170908 | | - 0, /* (378) returning ::= */ |
| 170909 | | - -1, /* (379) expr ::= term */ |
| 170910 | | - -1, /* (380) likeop ::= LIKE_KW|MATCH */ |
| 170898 | + 0, /* (229) case_operand ::= */ |
| 170899 | + 0, /* (230) exprlist ::= */ |
| 170900 | + -3, /* (231) nexprlist ::= nexprlist COMMA expr */ |
| 170901 | + -1, /* (232) nexprlist ::= expr */ |
| 170902 | + 0, /* (233) paren_exprlist ::= */ |
| 170903 | + -3, /* (234) paren_exprlist ::= LP exprlist RP */ |
| 170904 | + -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 170905 | + -1, /* (236) uniqueflag ::= UNIQUE */ |
| 170906 | + 0, /* (237) uniqueflag ::= */ |
| 170907 | + 0, /* (238) eidlist_opt ::= */ |
| 170908 | + -3, /* (239) eidlist_opt ::= LP eidlist RP */ |
| 170909 | + -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 170910 | + -3, /* (241) eidlist ::= nm collate sortorder */ |
| 170911 | + 0, /* (242) collate ::= */ |
| 170912 | + -2, /* (243) collate ::= COLLATE ID|STRING */ |
| 170913 | + -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ |
| 170914 | + -2, /* (245) cmd ::= VACUUM vinto */ |
| 170915 | + -3, /* (246) cmd ::= VACUUM nm vinto */ |
| 170916 | + -2, /* (247) vinto ::= INTO expr */ |
| 170917 | + 0, /* (248) vinto ::= */ |
| 170918 | + -3, /* (249) cmd ::= PRAGMA nm dbnm */ |
| 170919 | + -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 170920 | + -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 170921 | + -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 170922 | + -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 170923 | + -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ |
| 170924 | + -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ |
| 170925 | + -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 170926 | + -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 170927 | + -1, /* (258) trigger_time ::= BEFORE|AFTER */ |
| 170928 | + -2, /* (259) trigger_time ::= INSTEAD OF */ |
| 170929 | + 0, /* (260) trigger_time ::= */ |
| 170930 | + -1, /* (261) trigger_event ::= DELETE|INSERT */ |
| 170931 | + -1, /* (262) trigger_event ::= UPDATE */ |
| 170932 | + -3, /* (263) trigger_event ::= UPDATE OF idlist */ |
| 170933 | + 0, /* (264) when_clause ::= */ |
| 170934 | + -2, /* (265) when_clause ::= WHEN expr */ |
| 170935 | + -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 170936 | + -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 170937 | + -3, /* (268) trnm ::= nm DOT nm */ |
| 170938 | + -3, /* (269) tridxby ::= INDEXED BY nm */ |
| 170939 | + -2, /* (270) tridxby ::= NOT INDEXED */ |
| 170940 | + -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 170941 | + -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 170942 | + -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 170943 | + -3, /* (274) trigger_cmd ::= scanpt select scanpt */ |
| 170944 | + -4, /* (275) expr ::= RAISE LP IGNORE RP */ |
| 170945 | + -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 170946 | + -1, /* (277) raisetype ::= ROLLBACK */ |
| 170947 | + -1, /* (278) raisetype ::= ABORT */ |
| 170948 | + -1, /* (279) raisetype ::= FAIL */ |
| 170949 | + -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ |
| 170950 | + -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 170951 | + -3, /* (282) cmd ::= DETACH database_kw_opt expr */ |
| 170952 | + 0, /* (283) key_opt ::= */ |
| 170953 | + -2, /* (284) key_opt ::= KEY expr */ |
| 170954 | + -1, /* (285) cmd ::= REINDEX */ |
| 170955 | + -3, /* (286) cmd ::= REINDEX nm dbnm */ |
| 170956 | + -1, /* (287) cmd ::= ANALYZE */ |
| 170957 | + -3, /* (288) cmd ::= ANALYZE nm dbnm */ |
| 170958 | + -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 170959 | + -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 170960 | + -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 170961 | + -1, /* (292) add_column_fullname ::= fullname */ |
| 170962 | + -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 170963 | + -1, /* (294) cmd ::= create_vtab */ |
| 170964 | + -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ |
| 170965 | + -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 170966 | + 0, /* (297) vtabarg ::= */ |
| 170967 | + -1, /* (298) vtabargtoken ::= ANY */ |
| 170968 | + -3, /* (299) vtabargtoken ::= lp anylist RP */ |
| 170969 | + -1, /* (300) lp ::= LP */ |
| 170970 | + -2, /* (301) with ::= WITH wqlist */ |
| 170971 | + -3, /* (302) with ::= WITH RECURSIVE wqlist */ |
| 170972 | + -1, /* (303) wqas ::= AS */ |
| 170973 | + -2, /* (304) wqas ::= AS MATERIALIZED */ |
| 170974 | + -3, /* (305) wqas ::= AS NOT MATERIALIZED */ |
| 170975 | + -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 170976 | + -1, /* (307) wqlist ::= wqitem */ |
| 170977 | + -3, /* (308) wqlist ::= wqlist COMMA wqitem */ |
| 170978 | + -1, /* (309) windowdefn_list ::= windowdefn */ |
| 170979 | + -3, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 170980 | + -5, /* (311) windowdefn ::= nm AS LP window RP */ |
| 170981 | + -5, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170982 | + -6, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 170983 | + -4, /* (314) window ::= ORDER BY sortlist frame_opt */ |
| 170984 | + -5, /* (315) window ::= nm ORDER BY sortlist frame_opt */ |
| 170985 | + -1, /* (316) window ::= frame_opt */ |
| 170986 | + -2, /* (317) window ::= nm frame_opt */ |
| 170987 | + 0, /* (318) frame_opt ::= */ |
| 170988 | + -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 170989 | + -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 170990 | + -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 170991 | + -1, /* (322) frame_bound_s ::= frame_bound */ |
| 170992 | + -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 170993 | + -1, /* (324) frame_bound_e ::= frame_bound */ |
| 170994 | + -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 170995 | + -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 170996 | + -2, /* (327) frame_bound ::= CURRENT ROW */ |
| 170997 | + 0, /* (328) frame_exclude_opt ::= */ |
| 170998 | + -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 170999 | + -2, /* (330) frame_exclude ::= NO OTHERS */ |
| 171000 | + -2, /* (331) frame_exclude ::= CURRENT ROW */ |
| 171001 | + -1, /* (332) frame_exclude ::= GROUP|TIES */ |
| 171002 | + -2, /* (333) window_clause ::= WINDOW windowdefn_list */ |
| 171003 | + -2, /* (334) filter_over ::= filter_clause over_clause */ |
| 171004 | + -1, /* (335) filter_over ::= over_clause */ |
| 171005 | + -1, /* (336) filter_over ::= filter_clause */ |
| 171006 | + -4, /* (337) over_clause ::= OVER LP window RP */ |
| 171007 | + -2, /* (338) over_clause ::= OVER nm */ |
| 171008 | + -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ |
| 171009 | + -1, /* (340) input ::= cmdlist */ |
| 171010 | + -2, /* (341) cmdlist ::= cmdlist ecmd */ |
| 171011 | + -1, /* (342) cmdlist ::= ecmd */ |
| 171012 | + -1, /* (343) ecmd ::= SEMI */ |
| 171013 | + -2, /* (344) ecmd ::= cmdx SEMI */ |
| 171014 | + -3, /* (345) ecmd ::= explain cmdx SEMI */ |
| 171015 | + 0, /* (346) trans_opt ::= */ |
| 171016 | + -1, /* (347) trans_opt ::= TRANSACTION */ |
| 171017 | + -2, /* (348) trans_opt ::= TRANSACTION nm */ |
| 171018 | + -1, /* (349) savepoint_opt ::= SAVEPOINT */ |
| 171019 | + 0, /* (350) savepoint_opt ::= */ |
| 171020 | + -2, /* (351) cmd ::= create_table create_table_args */ |
| 171021 | + -1, /* (352) table_option_set ::= table_option */ |
| 171022 | + -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ |
| 171023 | + -2, /* (354) columnlist ::= columnname carglist */ |
| 171024 | + -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ |
| 171025 | + -1, /* (356) nm ::= STRING */ |
| 171026 | + -1, /* (357) typetoken ::= typename */ |
| 171027 | + -1, /* (358) typename ::= ID|STRING */ |
| 171028 | + -1, /* (359) signed ::= plus_num */ |
| 171029 | + -1, /* (360) signed ::= minus_num */ |
| 171030 | + -2, /* (361) carglist ::= carglist ccons */ |
| 171031 | + 0, /* (362) carglist ::= */ |
| 171032 | + -2, /* (363) ccons ::= NULL onconf */ |
| 171033 | + -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 171034 | + -2, /* (365) ccons ::= AS generated */ |
| 171035 | + -2, /* (366) conslist_opt ::= COMMA conslist */ |
| 171036 | + -3, /* (367) conslist ::= conslist tconscomma tcons */ |
| 171037 | + -1, /* (368) conslist ::= tcons */ |
| 171038 | + 0, /* (369) tconscomma ::= */ |
| 171039 | + -1, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 171040 | + -1, /* (371) resolvetype ::= raisetype */ |
| 171041 | + -1, /* (372) selectnowith ::= oneselect */ |
| 171042 | + -1, /* (373) oneselect ::= values */ |
| 171043 | + -2, /* (374) sclp ::= selcollist COMMA */ |
| 171044 | + -1, /* (375) as ::= ID|STRING */ |
| 171045 | + -1, /* (376) indexed_opt ::= indexed_by */ |
| 171046 | + 0, /* (377) returning ::= */ |
| 171047 | + -1, /* (378) expr ::= term */ |
| 171048 | + -1, /* (379) likeop ::= LIKE_KW|MATCH */ |
| 171049 | + -1, /* (380) case_operand ::= expr */ |
| 170911 | 171050 | -1, /* (381) exprlist ::= nexprlist */ |
| 170912 | 171051 | -1, /* (382) nmnum ::= plus_num */ |
| 170913 | 171052 | -1, /* (383) nmnum ::= nm */ |
| 170914 | 171053 | -1, /* (384) nmnum ::= ON */ |
| 170915 | 171054 | -1, /* (385) nmnum ::= DELETE */ |
| | @@ -170987,11 +171126,11 @@ |
| 170987 | 171126 | {yymsp[1].minor.yy394 = TK_DEFERRED;} |
| 170988 | 171127 | break; |
| 170989 | 171128 | case 5: /* transtype ::= DEFERRED */ |
| 170990 | 171129 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 170991 | 171130 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 170992 | | - case 322: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==322); |
| 171131 | + case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); |
| 170993 | 171132 | {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} |
| 170994 | 171133 | break; |
| 170995 | 171134 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 170996 | 171135 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| 170997 | 171136 | {sqlite3EndTransaction(pParse,yymsp[-1].major);} |
| | @@ -171024,11 +171163,11 @@ |
| 171024 | 171163 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 171025 | 171164 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 171026 | 171165 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 171027 | 171166 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 171028 | 171167 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 171029 | | - case 243: /* collate ::= */ yytestcase(yyruleno==243); |
| 171168 | + case 242: /* collate ::= */ yytestcase(yyruleno==242); |
| 171030 | 171169 | {yymsp[1].minor.yy394 = 0;} |
| 171031 | 171170 | break; |
| 171032 | 171171 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 171033 | 171172 | {yymsp[-2].minor.yy394 = 1;} |
| 171034 | 171173 | break; |
| | @@ -171210,11 +171349,11 @@ |
| 171210 | 171349 | break; |
| 171211 | 171350 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 171212 | 171351 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 171213 | 171352 | case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); |
| 171214 | 171353 | case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); |
| 171215 | | - case 244: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==244); |
| 171354 | + case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); |
| 171216 | 171355 | {yymsp[-1].minor.yy394 = 1;} |
| 171217 | 171356 | break; |
| 171218 | 171357 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 171219 | 171358 | {yymsp[-1].minor.yy394 = 0;} |
| 171220 | 171359 | break; |
| | @@ -171360,13 +171499,13 @@ |
| 171360 | 171499 | {yymsp[0].minor.yy394 = SF_All;} |
| 171361 | 171500 | break; |
| 171362 | 171501 | case 99: /* sclp ::= */ |
| 171363 | 171502 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 171364 | 171503 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 171365 | | - case 231: /* exprlist ::= */ yytestcase(yyruleno==231); |
| 171366 | | - case 234: /* paren_exprlist ::= */ yytestcase(yyruleno==234); |
| 171367 | | - case 239: /* eidlist_opt ::= */ yytestcase(yyruleno==239); |
| 171504 | + case 230: /* exprlist ::= */ yytestcase(yyruleno==230); |
| 171505 | + case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); |
| 171506 | + case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); |
| 171368 | 171507 | {yymsp[1].minor.yy322 = 0;} |
| 171369 | 171508 | break; |
| 171370 | 171509 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 171371 | 171510 | { |
| 171372 | 171511 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); |
| | @@ -171388,12 +171527,12 @@ |
| 171388 | 171527 | yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); |
| 171389 | 171528 | } |
| 171390 | 171529 | break; |
| 171391 | 171530 | case 103: /* as ::= AS nm */ |
| 171392 | 171531 | case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); |
| 171393 | | - case 255: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==255); |
| 171394 | | - case 256: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==256); |
| 171532 | + case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); |
| 171533 | + case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); |
| 171395 | 171534 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 171396 | 171535 | break; |
| 171397 | 171536 | case 105: /* from ::= */ |
| 171398 | 171537 | case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108); |
| 171399 | 171538 | {yymsp[1].minor.yy131 = 0;} |
| | @@ -171433,11 +171572,11 @@ |
| 171433 | 171572 | break; |
| 171434 | 171573 | case 113: /* seltablist ::= stl_prefix LP seltablist RP as on_using */ |
| 171435 | 171574 | { |
| 171436 | 171575 | if( yymsp[-5].minor.yy131==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy561.pOn==0 && yymsp[0].minor.yy561.pUsing==0 ){ |
| 171437 | 171576 | yymsp[-5].minor.yy131 = yymsp[-3].minor.yy131; |
| 171438 | | - }else if( yymsp[-3].minor.yy131->nSrc==1 ){ |
| 171577 | + }else if( ALWAYS(yymsp[-3].minor.yy131!=0) && yymsp[-3].minor.yy131->nSrc==1 ){ |
| 171439 | 171578 | yymsp[-5].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy131,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy561); |
| 171440 | 171579 | if( yymsp[-5].minor.yy131 ){ |
| 171441 | 171580 | SrcItem *pNew = &yymsp[-5].minor.yy131->a[yymsp[-5].minor.yy131->nSrc-1]; |
| 171442 | 171581 | SrcItem *pOld = yymsp[-3].minor.yy131->a; |
| 171443 | 171582 | pNew->zName = pOld->zName; |
| | @@ -171562,19 +171701,19 @@ |
| 171562 | 171701 | case 144: /* having_opt ::= */ |
| 171563 | 171702 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 171564 | 171703 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 171565 | 171704 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 171566 | 171705 | case 228: /* case_else ::= */ yytestcase(yyruleno==228); |
| 171567 | | - case 230: /* case_operand ::= */ yytestcase(yyruleno==230); |
| 171568 | | - case 249: /* vinto ::= */ yytestcase(yyruleno==249); |
| 171706 | + case 229: /* case_operand ::= */ yytestcase(yyruleno==229); |
| 171707 | + case 248: /* vinto ::= */ yytestcase(yyruleno==248); |
| 171569 | 171708 | {yymsp[1].minor.yy528 = 0;} |
| 171570 | 171709 | break; |
| 171571 | 171710 | case 145: /* having_opt ::= HAVING expr */ |
| 171572 | 171711 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 171573 | 171712 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 171574 | 171713 | case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); |
| 171575 | | - case 248: /* vinto ::= INTO expr */ yytestcase(yyruleno==248); |
| 171714 | + case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); |
| 171576 | 171715 | {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} |
| 171577 | 171716 | break; |
| 171578 | 171717 | case 147: /* limit_opt ::= LIMIT expr */ |
| 171579 | 171718 | {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);} |
| 171580 | 171719 | break; |
| | @@ -172001,394 +172140,391 @@ |
| 172001 | 172140 | { |
| 172002 | 172141 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); |
| 172003 | 172142 | yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); |
| 172004 | 172143 | } |
| 172005 | 172144 | break; |
| 172006 | | - case 229: /* case_operand ::= expr */ |
| 172007 | | -{yymsp[0].minor.yy528 = yymsp[0].minor.yy528; /*A-overwrites-X*/} |
| 172008 | | - break; |
| 172009 | | - case 232: /* nexprlist ::= nexprlist COMMA expr */ |
| 172145 | + case 231: /* nexprlist ::= nexprlist COMMA expr */ |
| 172010 | 172146 | {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} |
| 172011 | 172147 | break; |
| 172012 | | - case 233: /* nexprlist ::= expr */ |
| 172148 | + case 232: /* nexprlist ::= expr */ |
| 172013 | 172149 | {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} |
| 172014 | 172150 | break; |
| 172015 | | - case 235: /* paren_exprlist ::= LP exprlist RP */ |
| 172016 | | - case 240: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==240); |
| 172151 | + case 234: /* paren_exprlist ::= LP exprlist RP */ |
| 172152 | + case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); |
| 172017 | 172153 | {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} |
| 172018 | 172154 | break; |
| 172019 | | - case 236: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172155 | + case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 172020 | 172156 | { |
| 172021 | 172157 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 172022 | 172158 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, |
| 172023 | 172159 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF); |
| 172024 | 172160 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 172025 | 172161 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 172026 | 172162 | } |
| 172027 | 172163 | } |
| 172028 | 172164 | break; |
| 172029 | | - case 237: /* uniqueflag ::= UNIQUE */ |
| 172030 | | - case 279: /* raisetype ::= ABORT */ yytestcase(yyruleno==279); |
| 172165 | + case 236: /* uniqueflag ::= UNIQUE */ |
| 172166 | + case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); |
| 172031 | 172167 | {yymsp[0].minor.yy394 = OE_Abort;} |
| 172032 | 172168 | break; |
| 172033 | | - case 238: /* uniqueflag ::= */ |
| 172169 | + case 237: /* uniqueflag ::= */ |
| 172034 | 172170 | {yymsp[1].minor.yy394 = OE_None;} |
| 172035 | 172171 | break; |
| 172036 | | - case 241: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172172 | + case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 172037 | 172173 | { |
| 172038 | 172174 | yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); |
| 172039 | 172175 | } |
| 172040 | 172176 | break; |
| 172041 | | - case 242: /* eidlist ::= nm collate sortorder */ |
| 172177 | + case 241: /* eidlist ::= nm collate sortorder */ |
| 172042 | 172178 | { |
| 172043 | 172179 | yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ |
| 172044 | 172180 | } |
| 172045 | 172181 | break; |
| 172046 | | - case 245: /* cmd ::= DROP INDEX ifexists fullname */ |
| 172182 | + case 244: /* cmd ::= DROP INDEX ifexists fullname */ |
| 172047 | 172183 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} |
| 172048 | 172184 | break; |
| 172049 | | - case 246: /* cmd ::= VACUUM vinto */ |
| 172185 | + case 245: /* cmd ::= VACUUM vinto */ |
| 172050 | 172186 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} |
| 172051 | 172187 | break; |
| 172052 | | - case 247: /* cmd ::= VACUUM nm vinto */ |
| 172188 | + case 246: /* cmd ::= VACUUM nm vinto */ |
| 172053 | 172189 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} |
| 172054 | 172190 | break; |
| 172055 | | - case 250: /* cmd ::= PRAGMA nm dbnm */ |
| 172191 | + case 249: /* cmd ::= PRAGMA nm dbnm */ |
| 172056 | 172192 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 172057 | 172193 | break; |
| 172058 | | - case 251: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172194 | + case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 172059 | 172195 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 172060 | 172196 | break; |
| 172061 | | - case 252: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172197 | + case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 172062 | 172198 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 172063 | 172199 | break; |
| 172064 | | - case 253: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172200 | + case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 172065 | 172201 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 172066 | 172202 | break; |
| 172067 | | - case 254: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172203 | + case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 172068 | 172204 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 172069 | 172205 | break; |
| 172070 | | - case 257: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172206 | + case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 172071 | 172207 | { |
| 172072 | 172208 | Token all; |
| 172073 | 172209 | all.z = yymsp[-3].minor.yy0.z; |
| 172074 | 172210 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 172075 | 172211 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); |
| 172076 | 172212 | } |
| 172077 | 172213 | break; |
| 172078 | | - case 258: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172214 | + case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 172079 | 172215 | { |
| 172080 | 172216 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394); |
| 172081 | 172217 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 172082 | 172218 | } |
| 172083 | 172219 | break; |
| 172084 | | - case 259: /* trigger_time ::= BEFORE|AFTER */ |
| 172220 | + case 258: /* trigger_time ::= BEFORE|AFTER */ |
| 172085 | 172221 | { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } |
| 172086 | 172222 | break; |
| 172087 | | - case 260: /* trigger_time ::= INSTEAD OF */ |
| 172223 | + case 259: /* trigger_time ::= INSTEAD OF */ |
| 172088 | 172224 | { yymsp[-1].minor.yy394 = TK_INSTEAD;} |
| 172089 | 172225 | break; |
| 172090 | | - case 261: /* trigger_time ::= */ |
| 172226 | + case 260: /* trigger_time ::= */ |
| 172091 | 172227 | { yymsp[1].minor.yy394 = TK_BEFORE; } |
| 172092 | 172228 | break; |
| 172093 | | - case 262: /* trigger_event ::= DELETE|INSERT */ |
| 172094 | | - case 263: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==263); |
| 172229 | + case 261: /* trigger_event ::= DELETE|INSERT */ |
| 172230 | + case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); |
| 172095 | 172231 | {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} |
| 172096 | 172232 | break; |
| 172097 | | - case 264: /* trigger_event ::= UPDATE OF idlist */ |
| 172233 | + case 263: /* trigger_event ::= UPDATE OF idlist */ |
| 172098 | 172234 | {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} |
| 172099 | 172235 | break; |
| 172100 | | - case 265: /* when_clause ::= */ |
| 172101 | | - case 284: /* key_opt ::= */ yytestcase(yyruleno==284); |
| 172236 | + case 264: /* when_clause ::= */ |
| 172237 | + case 283: /* key_opt ::= */ yytestcase(yyruleno==283); |
| 172102 | 172238 | { yymsp[1].minor.yy528 = 0; } |
| 172103 | 172239 | break; |
| 172104 | | - case 266: /* when_clause ::= WHEN expr */ |
| 172105 | | - case 285: /* key_opt ::= KEY expr */ yytestcase(yyruleno==285); |
| 172240 | + case 265: /* when_clause ::= WHEN expr */ |
| 172241 | + case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); |
| 172106 | 172242 | { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } |
| 172107 | 172243 | break; |
| 172108 | | - case 267: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172244 | + case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 172109 | 172245 | { |
| 172110 | 172246 | assert( yymsp[-2].minor.yy33!=0 ); |
| 172111 | 172247 | yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; |
| 172112 | 172248 | yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 172113 | 172249 | } |
| 172114 | 172250 | break; |
| 172115 | | - case 268: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172251 | + case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 172116 | 172252 | { |
| 172117 | 172253 | assert( yymsp[-1].minor.yy33!=0 ); |
| 172118 | 172254 | yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; |
| 172119 | 172255 | } |
| 172120 | 172256 | break; |
| 172121 | | - case 269: /* trnm ::= nm DOT nm */ |
| 172257 | + case 268: /* trnm ::= nm DOT nm */ |
| 172122 | 172258 | { |
| 172123 | 172259 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 172124 | 172260 | sqlite3ErrorMsg(pParse, |
| 172125 | 172261 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 172126 | 172262 | "statements within triggers"); |
| 172127 | 172263 | } |
| 172128 | 172264 | break; |
| 172129 | | - case 270: /* tridxby ::= INDEXED BY nm */ |
| 172265 | + case 269: /* tridxby ::= INDEXED BY nm */ |
| 172130 | 172266 | { |
| 172131 | 172267 | sqlite3ErrorMsg(pParse, |
| 172132 | 172268 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 172133 | 172269 | "within triggers"); |
| 172134 | 172270 | } |
| 172135 | 172271 | break; |
| 172136 | | - case 271: /* tridxby ::= NOT INDEXED */ |
| 172272 | + case 270: /* tridxby ::= NOT INDEXED */ |
| 172137 | 172273 | { |
| 172138 | 172274 | sqlite3ErrorMsg(pParse, |
| 172139 | 172275 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 172140 | 172276 | "within triggers"); |
| 172141 | 172277 | } |
| 172142 | 172278 | break; |
| 172143 | | - case 272: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172279 | + case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 172144 | 172280 | {yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);} |
| 172145 | 172281 | yymsp[-8].minor.yy33 = yylhsminor.yy33; |
| 172146 | 172282 | break; |
| 172147 | | - case 273: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172283 | + case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 172148 | 172284 | { |
| 172149 | 172285 | yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/ |
| 172150 | 172286 | } |
| 172151 | 172287 | yymsp[-7].minor.yy33 = yylhsminor.yy33; |
| 172152 | 172288 | break; |
| 172153 | | - case 274: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172289 | + case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 172154 | 172290 | {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} |
| 172155 | 172291 | yymsp[-5].minor.yy33 = yylhsminor.yy33; |
| 172156 | 172292 | break; |
| 172157 | | - case 275: /* trigger_cmd ::= scanpt select scanpt */ |
| 172293 | + case 274: /* trigger_cmd ::= scanpt select scanpt */ |
| 172158 | 172294 | {yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} |
| 172159 | 172295 | yymsp[-2].minor.yy33 = yylhsminor.yy33; |
| 172160 | 172296 | break; |
| 172161 | | - case 276: /* expr ::= RAISE LP IGNORE RP */ |
| 172297 | + case 275: /* expr ::= RAISE LP IGNORE RP */ |
| 172162 | 172298 | { |
| 172163 | 172299 | yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 172164 | 172300 | if( yymsp[-3].minor.yy528 ){ |
| 172165 | 172301 | yymsp[-3].minor.yy528->affExpr = OE_Ignore; |
| 172166 | 172302 | } |
| 172167 | 172303 | } |
| 172168 | 172304 | break; |
| 172169 | | - case 277: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172305 | + case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 172170 | 172306 | { |
| 172171 | 172307 | yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 172172 | 172308 | if( yymsp[-5].minor.yy528 ) { |
| 172173 | 172309 | yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394; |
| 172174 | 172310 | } |
| 172175 | 172311 | } |
| 172176 | 172312 | break; |
| 172177 | | - case 278: /* raisetype ::= ROLLBACK */ |
| 172313 | + case 277: /* raisetype ::= ROLLBACK */ |
| 172178 | 172314 | {yymsp[0].minor.yy394 = OE_Rollback;} |
| 172179 | 172315 | break; |
| 172180 | | - case 280: /* raisetype ::= FAIL */ |
| 172316 | + case 279: /* raisetype ::= FAIL */ |
| 172181 | 172317 | {yymsp[0].minor.yy394 = OE_Fail;} |
| 172182 | 172318 | break; |
| 172183 | | - case 281: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 172319 | + case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 172184 | 172320 | { |
| 172185 | 172321 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); |
| 172186 | 172322 | } |
| 172187 | 172323 | break; |
| 172188 | | - case 282: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172324 | + case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 172189 | 172325 | { |
| 172190 | 172326 | sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); |
| 172191 | 172327 | } |
| 172192 | 172328 | break; |
| 172193 | | - case 283: /* cmd ::= DETACH database_kw_opt expr */ |
| 172329 | + case 282: /* cmd ::= DETACH database_kw_opt expr */ |
| 172194 | 172330 | { |
| 172195 | 172331 | sqlite3Detach(pParse, yymsp[0].minor.yy528); |
| 172196 | 172332 | } |
| 172197 | 172333 | break; |
| 172198 | | - case 286: /* cmd ::= REINDEX */ |
| 172334 | + case 285: /* cmd ::= REINDEX */ |
| 172199 | 172335 | {sqlite3Reindex(pParse, 0, 0);} |
| 172200 | 172336 | break; |
| 172201 | | - case 287: /* cmd ::= REINDEX nm dbnm */ |
| 172337 | + case 286: /* cmd ::= REINDEX nm dbnm */ |
| 172202 | 172338 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 172203 | 172339 | break; |
| 172204 | | - case 288: /* cmd ::= ANALYZE */ |
| 172340 | + case 287: /* cmd ::= ANALYZE */ |
| 172205 | 172341 | {sqlite3Analyze(pParse, 0, 0);} |
| 172206 | 172342 | break; |
| 172207 | | - case 289: /* cmd ::= ANALYZE nm dbnm */ |
| 172343 | + case 288: /* cmd ::= ANALYZE nm dbnm */ |
| 172208 | 172344 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 172209 | 172345 | break; |
| 172210 | | - case 290: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172346 | + case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 172211 | 172347 | { |
| 172212 | 172348 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); |
| 172213 | 172349 | } |
| 172214 | 172350 | break; |
| 172215 | | - case 291: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172351 | + case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 172216 | 172352 | { |
| 172217 | 172353 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 172218 | 172354 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 172219 | 172355 | } |
| 172220 | 172356 | break; |
| 172221 | | - case 292: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172357 | + case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 172222 | 172358 | { |
| 172223 | 172359 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); |
| 172224 | 172360 | } |
| 172225 | 172361 | break; |
| 172226 | | - case 293: /* add_column_fullname ::= fullname */ |
| 172362 | + case 292: /* add_column_fullname ::= fullname */ |
| 172227 | 172363 | { |
| 172228 | 172364 | disableLookaside(pParse); |
| 172229 | 172365 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); |
| 172230 | 172366 | } |
| 172231 | 172367 | break; |
| 172232 | | - case 294: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172368 | + case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 172233 | 172369 | { |
| 172234 | 172370 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 172235 | 172371 | } |
| 172236 | 172372 | break; |
| 172237 | | - case 295: /* cmd ::= create_vtab */ |
| 172373 | + case 294: /* cmd ::= create_vtab */ |
| 172238 | 172374 | {sqlite3VtabFinishParse(pParse,0);} |
| 172239 | 172375 | break; |
| 172240 | | - case 296: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 172376 | + case 295: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 172241 | 172377 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 172242 | 172378 | break; |
| 172243 | | - case 297: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172379 | + case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 172244 | 172380 | { |
| 172245 | 172381 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); |
| 172246 | 172382 | } |
| 172247 | 172383 | break; |
| 172248 | | - case 298: /* vtabarg ::= */ |
| 172384 | + case 297: /* vtabarg ::= */ |
| 172249 | 172385 | {sqlite3VtabArgInit(pParse);} |
| 172250 | 172386 | break; |
| 172251 | | - case 299: /* vtabargtoken ::= ANY */ |
| 172252 | | - case 300: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==300); |
| 172253 | | - case 301: /* lp ::= LP */ yytestcase(yyruleno==301); |
| 172387 | + case 298: /* vtabargtoken ::= ANY */ |
| 172388 | + case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); |
| 172389 | + case 300: /* lp ::= LP */ yytestcase(yyruleno==300); |
| 172254 | 172390 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 172255 | 172391 | break; |
| 172256 | | - case 302: /* with ::= WITH wqlist */ |
| 172257 | | - case 303: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==303); |
| 172392 | + case 301: /* with ::= WITH wqlist */ |
| 172393 | + case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); |
| 172258 | 172394 | { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } |
| 172259 | 172395 | break; |
| 172260 | | - case 304: /* wqas ::= AS */ |
| 172396 | + case 303: /* wqas ::= AS */ |
| 172261 | 172397 | {yymsp[0].minor.yy516 = M10d_Any;} |
| 172262 | 172398 | break; |
| 172263 | | - case 305: /* wqas ::= AS MATERIALIZED */ |
| 172399 | + case 304: /* wqas ::= AS MATERIALIZED */ |
| 172264 | 172400 | {yymsp[-1].minor.yy516 = M10d_Yes;} |
| 172265 | 172401 | break; |
| 172266 | | - case 306: /* wqas ::= AS NOT MATERIALIZED */ |
| 172402 | + case 305: /* wqas ::= AS NOT MATERIALIZED */ |
| 172267 | 172403 | {yymsp[-2].minor.yy516 = M10d_No;} |
| 172268 | 172404 | break; |
| 172269 | | - case 307: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172405 | + case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 172270 | 172406 | { |
| 172271 | 172407 | yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/ |
| 172272 | 172408 | } |
| 172273 | 172409 | break; |
| 172274 | | - case 308: /* wqlist ::= wqitem */ |
| 172410 | + case 307: /* wqlist ::= wqitem */ |
| 172275 | 172411 | { |
| 172276 | 172412 | yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ |
| 172277 | 172413 | } |
| 172278 | 172414 | break; |
| 172279 | | - case 309: /* wqlist ::= wqlist COMMA wqitem */ |
| 172415 | + case 308: /* wqlist ::= wqlist COMMA wqitem */ |
| 172280 | 172416 | { |
| 172281 | 172417 | yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); |
| 172282 | 172418 | } |
| 172283 | 172419 | break; |
| 172284 | | - case 310: /* windowdefn_list ::= windowdefn */ |
| 172420 | + case 309: /* windowdefn_list ::= windowdefn */ |
| 172285 | 172421 | { yylhsminor.yy41 = yymsp[0].minor.yy41; } |
| 172286 | 172422 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 172287 | 172423 | break; |
| 172288 | | - case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172424 | + case 310: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 172289 | 172425 | { |
| 172290 | 172426 | assert( yymsp[0].minor.yy41!=0 ); |
| 172291 | 172427 | sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); |
| 172292 | 172428 | yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41; |
| 172293 | 172429 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 172294 | 172430 | } |
| 172295 | 172431 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 172296 | 172432 | break; |
| 172297 | | - case 312: /* windowdefn ::= nm AS LP window RP */ |
| 172433 | + case 311: /* windowdefn ::= nm AS LP window RP */ |
| 172298 | 172434 | { |
| 172299 | 172435 | if( ALWAYS(yymsp[-1].minor.yy41) ){ |
| 172300 | 172436 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 172301 | 172437 | } |
| 172302 | 172438 | yylhsminor.yy41 = yymsp[-1].minor.yy41; |
| 172303 | 172439 | } |
| 172304 | 172440 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 172305 | 172441 | break; |
| 172306 | | - case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172442 | + case 312: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172307 | 172443 | { |
| 172308 | 172444 | yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); |
| 172309 | 172445 | } |
| 172310 | 172446 | break; |
| 172311 | | - case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172447 | + case 313: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 172312 | 172448 | { |
| 172313 | 172449 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); |
| 172314 | 172450 | } |
| 172315 | 172451 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 172316 | 172452 | break; |
| 172317 | | - case 315: /* window ::= ORDER BY sortlist frame_opt */ |
| 172453 | + case 314: /* window ::= ORDER BY sortlist frame_opt */ |
| 172318 | 172454 | { |
| 172319 | 172455 | yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); |
| 172320 | 172456 | } |
| 172321 | 172457 | break; |
| 172322 | | - case 316: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 172458 | + case 315: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 172323 | 172459 | { |
| 172324 | 172460 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 172325 | 172461 | } |
| 172326 | 172462 | yymsp[-4].minor.yy41 = yylhsminor.yy41; |
| 172327 | 172463 | break; |
| 172328 | | - case 317: /* window ::= frame_opt */ |
| 172329 | | - case 336: /* filter_over ::= over_clause */ yytestcase(yyruleno==336); |
| 172464 | + case 316: /* window ::= frame_opt */ |
| 172465 | + case 335: /* filter_over ::= over_clause */ yytestcase(yyruleno==335); |
| 172330 | 172466 | { |
| 172331 | 172467 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 172332 | 172468 | } |
| 172333 | 172469 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 172334 | 172470 | break; |
| 172335 | | - case 318: /* window ::= nm frame_opt */ |
| 172471 | + case 317: /* window ::= nm frame_opt */ |
| 172336 | 172472 | { |
| 172337 | 172473 | yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); |
| 172338 | 172474 | } |
| 172339 | 172475 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 172340 | 172476 | break; |
| 172341 | | - case 319: /* frame_opt ::= */ |
| 172477 | + case 318: /* frame_opt ::= */ |
| 172342 | 172478 | { |
| 172343 | 172479 | yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 172344 | 172480 | } |
| 172345 | 172481 | break; |
| 172346 | | - case 320: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172482 | + case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 172347 | 172483 | { |
| 172348 | 172484 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); |
| 172349 | 172485 | } |
| 172350 | 172486 | yymsp[-2].minor.yy41 = yylhsminor.yy41; |
| 172351 | 172487 | break; |
| 172352 | | - case 321: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172488 | + case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 172353 | 172489 | { |
| 172354 | 172490 | yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); |
| 172355 | 172491 | } |
| 172356 | 172492 | yymsp[-5].minor.yy41 = yylhsminor.yy41; |
| 172357 | 172493 | break; |
| 172358 | | - case 323: /* frame_bound_s ::= frame_bound */ |
| 172359 | | - case 325: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==325); |
| 172494 | + case 322: /* frame_bound_s ::= frame_bound */ |
| 172495 | + case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); |
| 172360 | 172496 | {yylhsminor.yy595 = yymsp[0].minor.yy595;} |
| 172361 | 172497 | yymsp[0].minor.yy595 = yylhsminor.yy595; |
| 172362 | 172498 | break; |
| 172363 | | - case 324: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172364 | | - case 326: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==326); |
| 172365 | | - case 328: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==328); |
| 172499 | + case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 172500 | + case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); |
| 172501 | + case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); |
| 172366 | 172502 | {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} |
| 172367 | 172503 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 172368 | 172504 | break; |
| 172369 | | - case 327: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172505 | + case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 172370 | 172506 | {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} |
| 172371 | 172507 | yymsp[-1].minor.yy595 = yylhsminor.yy595; |
| 172372 | 172508 | break; |
| 172373 | | - case 329: /* frame_exclude_opt ::= */ |
| 172509 | + case 328: /* frame_exclude_opt ::= */ |
| 172374 | 172510 | {yymsp[1].minor.yy516 = 0;} |
| 172375 | 172511 | break; |
| 172376 | | - case 330: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172512 | + case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 172377 | 172513 | {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} |
| 172378 | 172514 | break; |
| 172379 | | - case 331: /* frame_exclude ::= NO OTHERS */ |
| 172380 | | - case 332: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==332); |
| 172515 | + case 330: /* frame_exclude ::= NO OTHERS */ |
| 172516 | + case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); |
| 172381 | 172517 | {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} |
| 172382 | 172518 | break; |
| 172383 | | - case 333: /* frame_exclude ::= GROUP|TIES */ |
| 172519 | + case 332: /* frame_exclude ::= GROUP|TIES */ |
| 172384 | 172520 | {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} |
| 172385 | 172521 | break; |
| 172386 | | - case 334: /* window_clause ::= WINDOW windowdefn_list */ |
| 172522 | + case 333: /* window_clause ::= WINDOW windowdefn_list */ |
| 172387 | 172523 | { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } |
| 172388 | 172524 | break; |
| 172389 | | - case 335: /* filter_over ::= filter_clause over_clause */ |
| 172525 | + case 334: /* filter_over ::= filter_clause over_clause */ |
| 172390 | 172526 | { |
| 172391 | 172527 | if( yymsp[0].minor.yy41 ){ |
| 172392 | 172528 | yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; |
| 172393 | 172529 | }else{ |
| 172394 | 172530 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528); |
| | @@ -172395,11 +172531,11 @@ |
| 172395 | 172531 | } |
| 172396 | 172532 | yylhsminor.yy41 = yymsp[0].minor.yy41; |
| 172397 | 172533 | } |
| 172398 | 172534 | yymsp[-1].minor.yy41 = yylhsminor.yy41; |
| 172399 | 172535 | break; |
| 172400 | | - case 337: /* filter_over ::= filter_clause */ |
| 172536 | + case 336: /* filter_over ::= filter_clause */ |
| 172401 | 172537 | { |
| 172402 | 172538 | yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 172403 | 172539 | if( yylhsminor.yy41 ){ |
| 172404 | 172540 | yylhsminor.yy41->eFrmType = TK_FILTER; |
| 172405 | 172541 | yylhsminor.yy41->pFilter = yymsp[0].minor.yy528; |
| | @@ -172407,68 +172543,69 @@ |
| 172407 | 172543 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528); |
| 172408 | 172544 | } |
| 172409 | 172545 | } |
| 172410 | 172546 | yymsp[0].minor.yy41 = yylhsminor.yy41; |
| 172411 | 172547 | break; |
| 172412 | | - case 338: /* over_clause ::= OVER LP window RP */ |
| 172548 | + case 337: /* over_clause ::= OVER LP window RP */ |
| 172413 | 172549 | { |
| 172414 | 172550 | yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; |
| 172415 | 172551 | assert( yymsp[-3].minor.yy41!=0 ); |
| 172416 | 172552 | } |
| 172417 | 172553 | break; |
| 172418 | | - case 339: /* over_clause ::= OVER nm */ |
| 172554 | + case 338: /* over_clause ::= OVER nm */ |
| 172419 | 172555 | { |
| 172420 | 172556 | yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 172421 | 172557 | if( yymsp[-1].minor.yy41 ){ |
| 172422 | 172558 | yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 172423 | 172559 | } |
| 172424 | 172560 | } |
| 172425 | 172561 | break; |
| 172426 | | - case 340: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 172562 | + case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 172427 | 172563 | { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } |
| 172428 | 172564 | break; |
| 172429 | 172565 | default: |
| 172430 | | - /* (341) input ::= cmdlist */ yytestcase(yyruleno==341); |
| 172431 | | - /* (342) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==342); |
| 172432 | | - /* (343) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=343); |
| 172433 | | - /* (344) ecmd ::= SEMI */ yytestcase(yyruleno==344); |
| 172434 | | - /* (345) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==345); |
| 172435 | | - /* (346) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=346); |
| 172436 | | - /* (347) trans_opt ::= */ yytestcase(yyruleno==347); |
| 172437 | | - /* (348) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==348); |
| 172438 | | - /* (349) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==349); |
| 172439 | | - /* (350) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==350); |
| 172440 | | - /* (351) savepoint_opt ::= */ yytestcase(yyruleno==351); |
| 172441 | | - /* (352) cmd ::= create_table create_table_args */ yytestcase(yyruleno==352); |
| 172442 | | - /* (353) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=353); |
| 172443 | | - /* (354) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==354); |
| 172444 | | - /* (355) columnlist ::= columnname carglist */ yytestcase(yyruleno==355); |
| 172445 | | - /* (356) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==356); |
| 172446 | | - /* (357) nm ::= STRING */ yytestcase(yyruleno==357); |
| 172447 | | - /* (358) typetoken ::= typename */ yytestcase(yyruleno==358); |
| 172448 | | - /* (359) typename ::= ID|STRING */ yytestcase(yyruleno==359); |
| 172449 | | - /* (360) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); |
| 172450 | | - /* (361) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=361); |
| 172451 | | - /* (362) carglist ::= carglist ccons */ yytestcase(yyruleno==362); |
| 172452 | | - /* (363) carglist ::= */ yytestcase(yyruleno==363); |
| 172453 | | - /* (364) ccons ::= NULL onconf */ yytestcase(yyruleno==364); |
| 172454 | | - /* (365) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==365); |
| 172455 | | - /* (366) ccons ::= AS generated */ yytestcase(yyruleno==366); |
| 172456 | | - /* (367) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==367); |
| 172457 | | - /* (368) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==368); |
| 172458 | | - /* (369) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=369); |
| 172459 | | - /* (370) tconscomma ::= */ yytestcase(yyruleno==370); |
| 172460 | | - /* (371) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=371); |
| 172461 | | - /* (372) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 172462 | | - /* (373) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=373); |
| 172463 | | - /* (374) oneselect ::= values */ yytestcase(yyruleno==374); |
| 172464 | | - /* (375) sclp ::= selcollist COMMA */ yytestcase(yyruleno==375); |
| 172465 | | - /* (376) as ::= ID|STRING */ yytestcase(yyruleno==376); |
| 172466 | | - /* (377) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=377); |
| 172467 | | - /* (378) returning ::= */ yytestcase(yyruleno==378); |
| 172468 | | - /* (379) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=379); |
| 172469 | | - /* (380) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==380); |
| 172566 | + /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); |
| 172567 | + /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); |
| 172568 | + /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); |
| 172569 | + /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); |
| 172570 | + /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); |
| 172571 | + /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); |
| 172572 | + /* (346) trans_opt ::= */ yytestcase(yyruleno==346); |
| 172573 | + /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); |
| 172574 | + /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); |
| 172575 | + /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); |
| 172576 | + /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); |
| 172577 | + /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); |
| 172578 | + /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); |
| 172579 | + /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); |
| 172580 | + /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); |
| 172581 | + /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); |
| 172582 | + /* (356) nm ::= STRING */ yytestcase(yyruleno==356); |
| 172583 | + /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); |
| 172584 | + /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); |
| 172585 | + /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); |
| 172586 | + /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); |
| 172587 | + /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); |
| 172588 | + /* (362) carglist ::= */ yytestcase(yyruleno==362); |
| 172589 | + /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); |
| 172590 | + /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); |
| 172591 | + /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); |
| 172592 | + /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); |
| 172593 | + /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); |
| 172594 | + /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 172595 | + /* (369) tconscomma ::= */ yytestcase(yyruleno==369); |
| 172596 | + /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); |
| 172597 | + /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); |
| 172598 | + /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 172599 | + /* (373) oneselect ::= values */ yytestcase(yyruleno==373); |
| 172600 | + /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); |
| 172601 | + /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); |
| 172602 | + /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); |
| 172603 | + /* (377) returning ::= */ yytestcase(yyruleno==377); |
| 172604 | + /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); |
| 172605 | + /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); |
| 172606 | + /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); |
| 172470 | 172607 | /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); |
| 172471 | 172608 | /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); |
| 172472 | 172609 | /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); |
| 172473 | 172610 | /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); |
| 172474 | 172611 | /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); |
| | @@ -199500,10 +199637,11 @@ |
| 199500 | 199637 | #define JNODE_REMOVE 0x04 /* Do not output */ |
| 199501 | 199638 | #define JNODE_REPLACE 0x08 /* Replace with JsonNode.u.iReplace */ |
| 199502 | 199639 | #define JNODE_PATCH 0x10 /* Patch with JsonNode.u.pPatch */ |
| 199503 | 199640 | #define JNODE_APPEND 0x20 /* More ARRAY/OBJECT entries at u.iAppend */ |
| 199504 | 199641 | #define JNODE_LABEL 0x40 /* Is a label of an object */ |
| 199642 | +#define JNODE_JSON5 0x80 /* Node contains JSON5 enhancements */ |
| 199505 | 199643 | |
| 199506 | 199644 | |
| 199507 | 199645 | /* A single node of parsed JSON |
| 199508 | 199646 | */ |
| 199509 | 199647 | struct JsonNode { |
| | @@ -199526,14 +199664,16 @@ |
| 199526 | 199664 | u32 nNode; /* Number of slots of aNode[] used */ |
| 199527 | 199665 | u32 nAlloc; /* Number of slots of aNode[] allocated */ |
| 199528 | 199666 | JsonNode *aNode; /* Array of nodes containing the parse */ |
| 199529 | 199667 | const char *zJson; /* Original JSON string */ |
| 199530 | 199668 | u32 *aUp; /* Index of parent of each node */ |
| 199531 | | - u8 oom; /* Set to true if out of memory */ |
| 199669 | + u16 iDepth; /* Nesting depth */ |
| 199532 | 199670 | u8 nErr; /* Number of errors seen */ |
| 199533 | | - u16 iDepth; /* Nesting depth */ |
| 199671 | + u8 oom; /* Set to true if out of memory */ |
| 199672 | + u8 hasNonstd; /* True if input uses non-standard features like JSON5 */ |
| 199534 | 199673 | int nJson; /* Length of the zJson string in bytes */ |
| 199674 | + u32 iErr; /* Error location in zJson[] */ |
| 199535 | 199675 | u32 iHold; /* Replace cache line with the lowest iHold value */ |
| 199536 | 199676 | }; |
| 199537 | 199677 | |
| 199538 | 199678 | /* |
| 199539 | 199679 | ** Maximum nesting depth of JSON for this implementation. |
| | @@ -199689,10 +199829,133 @@ |
| 199689 | 199829 | p->zBuf[p->nUsed++] = c; |
| 199690 | 199830 | } |
| 199691 | 199831 | p->zBuf[p->nUsed++] = '"'; |
| 199692 | 199832 | assert( p->nUsed<p->nAlloc ); |
| 199693 | 199833 | } |
| 199834 | + |
| 199835 | +/* |
| 199836 | +** The zIn[0..N] string is a JSON5 string literal. Append to p a translation |
| 199837 | +** of the string literal that standard JSON and that omits all JSON5 |
| 199838 | +** features. |
| 199839 | +*/ |
| 199840 | +static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ |
| 199841 | + u32 i; |
| 199842 | + jsonAppendChar(p, '"'); |
| 199843 | + zIn++; |
| 199844 | + N -= 2; |
| 199845 | + while( N>0 ){ |
| 199846 | + for(i=0; i<N && zIn[i]!='\\'; i++){} |
| 199847 | + if( i>0 ){ |
| 199848 | + jsonAppendRaw(p, zIn, i); |
| 199849 | + zIn += i; |
| 199850 | + N -= i; |
| 199851 | + if( N==0 ) break; |
| 199852 | + } |
| 199853 | + assert( zIn[0]=='\\' ); |
| 199854 | + switch( (u8)zIn[1] ){ |
| 199855 | + case '\'': |
| 199856 | + jsonAppendChar(p, '\''); |
| 199857 | + break; |
| 199858 | + case 'v': |
| 199859 | + jsonAppendRaw(p, "\\u0009", 6); |
| 199860 | + break; |
| 199861 | + case 'x': |
| 199862 | + jsonAppendRaw(p, "\\u00", 4); |
| 199863 | + jsonAppendRaw(p, &zIn[2], 2); |
| 199864 | + zIn += 2; |
| 199865 | + N -= 2; |
| 199866 | + break; |
| 199867 | + case '0': |
| 199868 | + jsonAppendRaw(p, "\\u0000", 6); |
| 199869 | + break; |
| 199870 | + case '\r': |
| 199871 | + if( zIn[2]=='\n' ){ |
| 199872 | + zIn++; |
| 199873 | + N--; |
| 199874 | + } |
| 199875 | + break; |
| 199876 | + case '\n': |
| 199877 | + break; |
| 199878 | + case 0xe2: |
| 199879 | + assert( N>=4 ); |
| 199880 | + assert( 0x80==(u8)zIn[2] ); |
| 199881 | + assert( 0xa8==(u8)zIn[3] || 0xa9==(u8)zIn[3] ); |
| 199882 | + zIn += 2; |
| 199883 | + N -= 2; |
| 199884 | + break; |
| 199885 | + default: |
| 199886 | + jsonAppendRaw(p, zIn, 2); |
| 199887 | + break; |
| 199888 | + } |
| 199889 | + zIn += 2; |
| 199890 | + N -= 2; |
| 199891 | + } |
| 199892 | + jsonAppendChar(p, '"'); |
| 199893 | +} |
| 199894 | + |
| 199895 | +/* |
| 199896 | +** The zIn[0..N] string is a JSON5 integer literal. Append to p a translation |
| 199897 | +** of the string literal that standard JSON and that omits all JSON5 |
| 199898 | +** features. |
| 199899 | +*/ |
| 199900 | +static void jsonAppendNormalizedInt(JsonString *p, const char *zIn, u32 N){ |
| 199901 | + if( zIn[0]=='+' ){ |
| 199902 | + zIn++; |
| 199903 | + N--; |
| 199904 | + }else if( zIn[0]=='-' ){ |
| 199905 | + jsonAppendChar(p, '-'); |
| 199906 | + zIn++; |
| 199907 | + N--; |
| 199908 | + } |
| 199909 | + if( zIn[0]=='0' && (zIn[1]=='x' || zIn[1]=='X') ){ |
| 199910 | + sqlite3_int64 i = 0; |
| 199911 | + int rc = sqlite3DecOrHexToI64(zIn, &i); |
| 199912 | + if( rc<=1 ){ |
| 199913 | + jsonPrintf(100,p,"%lld",i); |
| 199914 | + }else{ |
| 199915 | + assert( rc==2 ); |
| 199916 | + jsonAppendRaw(p, "9.0e999", 7); |
| 199917 | + } |
| 199918 | + return; |
| 199919 | + } |
| 199920 | + jsonAppendRaw(p, zIn, N); |
| 199921 | +} |
| 199922 | + |
| 199923 | +/* |
| 199924 | +** The zIn[0..N] string is a JSON5 real literal. Append to p a translation |
| 199925 | +** of the string literal that standard JSON and that omits all JSON5 |
| 199926 | +** features. |
| 199927 | +*/ |
| 199928 | +static void jsonAppendNormalizedReal(JsonString *p, const char *zIn, u32 N){ |
| 199929 | + u32 i; |
| 199930 | + if( zIn[0]=='+' ){ |
| 199931 | + zIn++; |
| 199932 | + N--; |
| 199933 | + }else if( zIn[0]=='-' ){ |
| 199934 | + jsonAppendChar(p, '-'); |
| 199935 | + zIn++; |
| 199936 | + N--; |
| 199937 | + } |
| 199938 | + if( zIn[0]=='.' ){ |
| 199939 | + jsonAppendChar(p, '0'); |
| 199940 | + } |
| 199941 | + for(i=0; i<N; i++){ |
| 199942 | + if( zIn[i]=='.' && (i+1==N || !sqlite3Isdigit(zIn[i+1])) ){ |
| 199943 | + i++; |
| 199944 | + jsonAppendRaw(p, zIn, i); |
| 199945 | + zIn += i; |
| 199946 | + N -= i; |
| 199947 | + jsonAppendChar(p, '0'); |
| 199948 | + break; |
| 199949 | + } |
| 199950 | + } |
| 199951 | + if( N>0 ){ |
| 199952 | + jsonAppendRaw(p, zIn, N); |
| 199953 | + } |
| 199954 | +} |
| 199955 | + |
| 199956 | + |
| 199694 | 199957 | |
| 199695 | 199958 | /* |
| 199696 | 199959 | ** Append a function parameter value to the JSON string under |
| 199697 | 199960 | ** construction. |
| 199698 | 199961 | */ |
| | @@ -199820,21 +200083,42 @@ |
| 199820 | 200083 | case JSON_FALSE: { |
| 199821 | 200084 | jsonAppendRaw(pOut, "false", 5); |
| 199822 | 200085 | break; |
| 199823 | 200086 | } |
| 199824 | 200087 | case JSON_STRING: { |
| 200088 | + assert( pNode->eU==1 ); |
| 199825 | 200089 | if( pNode->jnFlags & JNODE_RAW ){ |
| 199826 | | - assert( pNode->eU==1 ); |
| 199827 | | - jsonAppendString(pOut, pNode->u.zJContent, pNode->n); |
| 199828 | | - break; |
| 200090 | + if( pNode->jnFlags & JNODE_LABEL ){ |
| 200091 | + jsonAppendChar(pOut, '"'); |
| 200092 | + jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 200093 | + jsonAppendChar(pOut, '"'); |
| 200094 | + }else{ |
| 200095 | + jsonAppendString(pOut, pNode->u.zJContent, pNode->n); |
| 200096 | + } |
| 200097 | + }else if( pNode->jnFlags & JNODE_JSON5 ){ |
| 200098 | + jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n); |
| 200099 | + }else{ |
| 200100 | + jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 199829 | 200101 | } |
| 199830 | | - /* no break */ deliberate_fall_through |
| 200102 | + break; |
| 199831 | 200103 | } |
| 199832 | | - case JSON_REAL: |
| 200104 | + case JSON_REAL: { |
| 200105 | + assert( pNode->eU==1 ); |
| 200106 | + if( pNode->jnFlags & JNODE_JSON5 ){ |
| 200107 | + jsonAppendNormalizedReal(pOut, pNode->u.zJContent, pNode->n); |
| 200108 | + }else{ |
| 200109 | + jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 200110 | + } |
| 200111 | + break; |
| 200112 | + } |
| 199833 | 200113 | case JSON_INT: { |
| 199834 | 200114 | assert( pNode->eU==1 ); |
| 199835 | | - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 200115 | + if( pNode->jnFlags & JNODE_JSON5 ){ |
| 200116 | + jsonAppendNormalizedInt(pOut, pNode->u.zJContent, pNode->n); |
| 200117 | + }else{ |
| 200118 | + jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 200119 | + } |
| 199836 | 200120 | break; |
| 199837 | 200121 | } |
| 199838 | 200122 | case JSON_ARRAY: { |
| 199839 | 200123 | u32 j = 1; |
| 199840 | 200124 | jsonAppendChar(pOut, '['); |
| | @@ -199946,63 +200230,45 @@ |
| 199946 | 200230 | sqlite3_result_int(pCtx, 0); |
| 199947 | 200231 | break; |
| 199948 | 200232 | } |
| 199949 | 200233 | case JSON_INT: { |
| 199950 | 200234 | sqlite3_int64 i = 0; |
| 200235 | + int rc; |
| 200236 | + int bNeg = 0; |
| 199951 | 200237 | const char *z; |
| 200238 | + |
| 200239 | + |
| 199952 | 200240 | assert( pNode->eU==1 ); |
| 199953 | 200241 | z = pNode->u.zJContent; |
| 199954 | | - if( z[0]=='-' ){ z++; } |
| 199955 | | - while( z[0]>='0' && z[0]<='9' ){ |
| 199956 | | - unsigned v = *(z++) - '0'; |
| 199957 | | - if( i>=LARGEST_INT64/10 ){ |
| 199958 | | - if( i>LARGEST_INT64/10 ) goto int_as_real; |
| 199959 | | - if( z[0]>='0' && z[0]<='9' ) goto int_as_real; |
| 199960 | | - if( v==9 ) goto int_as_real; |
| 199961 | | - if( v==8 ){ |
| 199962 | | - if( pNode->u.zJContent[0]=='-' ){ |
| 199963 | | - sqlite3_result_int64(pCtx, SMALLEST_INT64); |
| 199964 | | - goto int_done; |
| 199965 | | - }else{ |
| 199966 | | - goto int_as_real; |
| 199967 | | - } |
| 199968 | | - } |
| 199969 | | - } |
| 199970 | | - i = i*10 + v; |
| 199971 | | - } |
| 199972 | | - if( pNode->u.zJContent[0]=='-' ){ i = -i; } |
| 199973 | | - sqlite3_result_int64(pCtx, i); |
| 199974 | | - int_done: |
| 199975 | | - break; |
| 199976 | | - int_as_real: ; /* no break */ deliberate_fall_through |
| 200242 | + if( z[0]=='-' ){ z++; bNeg = 1; } |
| 200243 | + else if( z[0]=='+' ){ z++; } |
| 200244 | + rc = sqlite3DecOrHexToI64(z, &i); |
| 200245 | + if( rc<=1 ){ |
| 200246 | + sqlite3_result_int64(pCtx, bNeg ? -i : i); |
| 200247 | + }else if( rc==3 && bNeg ){ |
| 200248 | + sqlite3_result_int64(pCtx, SMALLEST_INT64); |
| 200249 | + }else{ |
| 200250 | + goto to_double; |
| 200251 | + } |
| 200252 | + break; |
| 199977 | 200253 | } |
| 199978 | 200254 | case JSON_REAL: { |
| 199979 | 200255 | double r; |
| 199980 | | -#ifdef SQLITE_AMALGAMATION |
| 199981 | 200256 | const char *z; |
| 199982 | 200257 | assert( pNode->eU==1 ); |
| 200258 | + to_double: |
| 199983 | 200259 | z = pNode->u.zJContent; |
| 199984 | 200260 | sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); |
| 199985 | | -#else |
| 199986 | | - assert( pNode->eU==1 ); |
| 199987 | | - r = strtod(pNode->u.zJContent, 0); |
| 199988 | | -#endif |
| 199989 | 200261 | sqlite3_result_double(pCtx, r); |
| 199990 | 200262 | break; |
| 199991 | 200263 | } |
| 199992 | 200264 | case JSON_STRING: { |
| 199993 | | -#if 0 /* Never happens because JNODE_RAW is only set by json_set(), |
| 199994 | | - ** json_insert() and json_replace() and those routines do not |
| 199995 | | - ** call jsonReturn() */ |
| 199996 | 200265 | if( pNode->jnFlags & JNODE_RAW ){ |
| 199997 | 200266 | assert( pNode->eU==1 ); |
| 199998 | 200267 | sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, |
| 199999 | 200268 | SQLITE_TRANSIENT); |
| 200000 | | - }else |
| 200001 | | -#endif |
| 200002 | | - assert( (pNode->jnFlags & JNODE_RAW)==0 ); |
| 200003 | | - if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ |
| 200269 | + }else if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ |
| 200004 | 200270 | /* JSON formatted without any backslash-escapes */ |
| 200005 | 200271 | assert( pNode->eU==1 ); |
| 200006 | 200272 | sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, |
| 200007 | 200273 | SQLITE_TRANSIENT); |
| 200008 | 200274 | }else{ |
| | @@ -200010,22 +200276,21 @@ |
| 200010 | 200276 | u32 i; |
| 200011 | 200277 | u32 n = pNode->n; |
| 200012 | 200278 | const char *z; |
| 200013 | 200279 | char *zOut; |
| 200014 | 200280 | u32 j; |
| 200281 | + u32 nOut = n; |
| 200015 | 200282 | assert( pNode->eU==1 ); |
| 200016 | 200283 | z = pNode->u.zJContent; |
| 200017 | | - zOut = sqlite3_malloc( n+1 ); |
| 200284 | + zOut = sqlite3_malloc( nOut+1 ); |
| 200018 | 200285 | if( zOut==0 ){ |
| 200019 | 200286 | sqlite3_result_error_nomem(pCtx); |
| 200020 | 200287 | break; |
| 200021 | 200288 | } |
| 200022 | 200289 | for(i=1, j=0; i<n-1; i++){ |
| 200023 | 200290 | char c = z[i]; |
| 200024 | | - if( c!='\\' ){ |
| 200025 | | - zOut[j++] = c; |
| 200026 | | - }else{ |
| 200291 | + if( c=='\\' ){ |
| 200027 | 200292 | c = z[++i]; |
| 200028 | 200293 | if( c=='u' ){ |
| 200029 | 200294 | u32 v = jsonHexToInt4(z+i+1); |
| 200030 | 200295 | i += 4; |
| 200031 | 200296 | if( v==0 ) break; |
| | @@ -200053,26 +200318,44 @@ |
| 200053 | 200318 | zOut[j++] = 0xe0 | (v>>12); |
| 200054 | 200319 | zOut[j++] = 0x80 | ((v>>6)&0x3f); |
| 200055 | 200320 | zOut[j++] = 0x80 | (v&0x3f); |
| 200056 | 200321 | } |
| 200057 | 200322 | } |
| 200323 | + continue; |
| 200324 | + }else if( c=='b' ){ |
| 200325 | + c = '\b'; |
| 200326 | + }else if( c=='f' ){ |
| 200327 | + c = '\f'; |
| 200328 | + }else if( c=='n' ){ |
| 200329 | + c = '\n'; |
| 200330 | + }else if( c=='r' ){ |
| 200331 | + c = '\r'; |
| 200332 | + }else if( c=='t' ){ |
| 200333 | + c = '\t'; |
| 200334 | + }else if( c=='v' ){ |
| 200335 | + c = '\v'; |
| 200336 | + }else if( c=='\'' || c=='"' || c=='/' || c=='\\' ){ |
| 200337 | + /* pass through unchanged */ |
| 200338 | + }else if( c=='0' ){ |
| 200339 | + c = 0; |
| 200340 | + }else if( c=='x' ){ |
| 200341 | + c = (jsonHexToInt(z[i+1])<<4) | jsonHexToInt(z[i+2]); |
| 200342 | + i += 2; |
| 200343 | + }else if( c=='\r' && z[i+1]=='\n' ){ |
| 200344 | + i++; |
| 200345 | + continue; |
| 200346 | + }else if( 0xe2==(u8)c ){ |
| 200347 | + assert( 0x80==(u8)z[i+1] ); |
| 200348 | + assert( 0xa8==(u8)z[i+2] || 0xa9==(u8)z[i+2] ); |
| 200349 | + i += 2; |
| 200350 | + continue; |
| 200058 | 200351 | }else{ |
| 200059 | | - if( c=='b' ){ |
| 200060 | | - c = '\b'; |
| 200061 | | - }else if( c=='f' ){ |
| 200062 | | - c = '\f'; |
| 200063 | | - }else if( c=='n' ){ |
| 200064 | | - c = '\n'; |
| 200065 | | - }else if( c=='r' ){ |
| 200066 | | - c = '\r'; |
| 200067 | | - }else if( c=='t' ){ |
| 200068 | | - c = '\t'; |
| 200069 | | - } |
| 200070 | | - zOut[j++] = c; |
| 200071 | | - } |
| 200072 | | - } |
| 200073 | | - } |
| 200352 | + continue; |
| 200353 | + } |
| 200354 | + } /* end if( c=='\\' ) */ |
| 200355 | + zOut[j++] = c; |
| 200356 | + } /* end for() */ |
| 200074 | 200357 | zOut[j] = 0; |
| 200075 | 200358 | sqlite3_result_text(pCtx, zOut, j, sqlite3_free); |
| 200076 | 200359 | } |
| 200077 | 200360 | break; |
| 200078 | 200361 | } |
| | @@ -200136,28 +200419,159 @@ |
| 200136 | 200419 | JsonNode *p; |
| 200137 | 200420 | if( pParse->aNode==0 || pParse->nNode>=pParse->nAlloc ){ |
| 200138 | 200421 | return jsonParseAddNodeExpand(pParse, eType, n, zContent); |
| 200139 | 200422 | } |
| 200140 | 200423 | p = &pParse->aNode[pParse->nNode]; |
| 200141 | | - p->eType = (u8)eType; |
| 200142 | | - p->jnFlags = 0; |
| 200424 | + p->eType = (u8)(eType & 0xff); |
| 200425 | + p->jnFlags = (u8)(eType >> 8); |
| 200143 | 200426 | VVA( p->eU = zContent ? 1 : 0 ); |
| 200144 | 200427 | p->n = n; |
| 200145 | 200428 | p->u.zJContent = zContent; |
| 200146 | 200429 | return pParse->nNode++; |
| 200147 | 200430 | } |
| 200431 | + |
| 200432 | +/* |
| 200433 | +** Return true if z[] begins with 2 (or more) hexadecimal digits |
| 200434 | +*/ |
| 200435 | +static int jsonIs2Hex(const char *z){ |
| 200436 | + return sqlite3Isxdigit(z[0]) && sqlite3Isxdigit(z[1]); |
| 200437 | +} |
| 200148 | 200438 | |
| 200149 | 200439 | /* |
| 200150 | 200440 | ** Return true if z[] begins with 4 (or more) hexadecimal digits |
| 200151 | 200441 | */ |
| 200152 | 200442 | static int jsonIs4Hex(const char *z){ |
| 200153 | | - int i; |
| 200154 | | - for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0; |
| 200155 | | - return 1; |
| 200443 | + return jsonIs2Hex(z) && jsonIs2Hex(&z[2]); |
| 200156 | 200444 | } |
| 200157 | 200445 | |
| 200158 | | -#ifdef SQLITE_ENABLE_JSON_NAN_INF |
| 200446 | +/* |
| 200447 | +** Return the number of bytes of JSON5 whitespace at the beginning of |
| 200448 | +** the input string z[]. |
| 200449 | +** |
| 200450 | +** JSON5 whitespace consists of any of the following characters: |
| 200451 | +** |
| 200452 | +** Unicode UTF-8 Name |
| 200453 | +** U+0009 09 horizontal tab |
| 200454 | +** U+000a 0a line feed |
| 200455 | +** U+000b 0b vertical tab |
| 200456 | +** U+000c 0c form feed |
| 200457 | +** U+000d 0d carriage return |
| 200458 | +** U+0020 20 space |
| 200459 | +** U+00a0 c2 a0 non-breaking space |
| 200460 | +** U+1680 e1 9a 80 ogham space mark |
| 200461 | +** U+2000 e2 80 80 en quad |
| 200462 | +** U+2001 e2 80 81 em quad |
| 200463 | +** U+2002 e2 80 82 en space |
| 200464 | +** U+2003 e2 80 83 em space |
| 200465 | +** U+2004 e2 80 84 three-per-em space |
| 200466 | +** U+2005 e2 80 85 four-per-em space |
| 200467 | +** U+2006 e2 80 86 six-per-em space |
| 200468 | +** U+2007 e2 80 87 figure space |
| 200469 | +** U+2008 e2 80 88 punctuation space |
| 200470 | +** U+2009 e2 80 89 thin space |
| 200471 | +** U+200a e2 80 8a hair space |
| 200472 | +** U+2028 e2 80 a8 line separator |
| 200473 | +** U+2029 e2 80 a9 paragraph separator |
| 200474 | +** U+202f e2 80 af narrow no-break space (NNBSP) |
| 200475 | +** U+205f e2 81 9f medium mathematical space (MMSP) |
| 200476 | +** U+3000 e3 80 80 ideographical space |
| 200477 | +** U+FEFF ef bb bf byte order mark |
| 200478 | +** |
| 200479 | +** In addition, comments between '/', '*' and '*', '/' and |
| 200480 | +** from '/', '/' to end-of-line are also considered to be whitespace. |
| 200481 | +*/ |
| 200482 | +static int json5Whitespace(const char *zIn){ |
| 200483 | + int n = 0; |
| 200484 | + const u8 *z = (u8*)zIn; |
| 200485 | + while( 1 /*exit by "goto whitespace_done"*/ ){ |
| 200486 | + switch( z[n] ){ |
| 200487 | + case 0x09: |
| 200488 | + case 0x0a: |
| 200489 | + case 0x0b: |
| 200490 | + case 0x0c: |
| 200491 | + case 0x0d: |
| 200492 | + case 0x20: { |
| 200493 | + n++; |
| 200494 | + break; |
| 200495 | + } |
| 200496 | + case '/': { |
| 200497 | + if( z[n+1]=='*' && z[n+2]!=0 ){ |
| 200498 | + int j; |
| 200499 | + for(j=n+3; z[j]!='/' || z[j-1]!='*'; j++){ |
| 200500 | + if( z[j]==0 ) goto whitespace_done; |
| 200501 | + } |
| 200502 | + n = j+1; |
| 200503 | + break; |
| 200504 | + }else if( z[n+1]=='/' ){ |
| 200505 | + int j; |
| 200506 | + char c; |
| 200507 | + for(j=n+2; (c = z[j])!=0; j++){ |
| 200508 | + if( c=='\n' || c=='\r' ) break; |
| 200509 | + if( 0xe2==(u8)c && 0x80==(u8)z[j+1] |
| 200510 | + && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2]) |
| 200511 | + ){ |
| 200512 | + j += 2; |
| 200513 | + break; |
| 200514 | + } |
| 200515 | + } |
| 200516 | + n = j; |
| 200517 | + if( z[n] ) n++; |
| 200518 | + break; |
| 200519 | + } |
| 200520 | + goto whitespace_done; |
| 200521 | + } |
| 200522 | + case 0xc2: { |
| 200523 | + if( z[n+1]==0xa0 ){ |
| 200524 | + n += 2; |
| 200525 | + break; |
| 200526 | + } |
| 200527 | + goto whitespace_done; |
| 200528 | + } |
| 200529 | + case 0xe1: { |
| 200530 | + if( z[n+1]==0x9a && z[n+2]==0x80 ){ |
| 200531 | + n += 3; |
| 200532 | + break; |
| 200533 | + } |
| 200534 | + goto whitespace_done; |
| 200535 | + } |
| 200536 | + case 0xe2: { |
| 200537 | + if( z[n+1]==0x80 ){ |
| 200538 | + u8 c = z[n+2]; |
| 200539 | + if( c<0x80 ) goto whitespace_done; |
| 200540 | + if( c<=0x8a || c==0xa8 || c==0xa9 || c==0xaf ){ |
| 200541 | + n += 3; |
| 200542 | + break; |
| 200543 | + } |
| 200544 | + }else if( z[n+1]==0x81 && z[n+2]==0x9f ){ |
| 200545 | + n += 3; |
| 200546 | + break; |
| 200547 | + } |
| 200548 | + goto whitespace_done; |
| 200549 | + } |
| 200550 | + case 0xe3: { |
| 200551 | + if( z[n+1]==0x80 && z[n+2]==0x80 ){ |
| 200552 | + n += 3; |
| 200553 | + break; |
| 200554 | + } |
| 200555 | + goto whitespace_done; |
| 200556 | + } |
| 200557 | + case 0xef: { |
| 200558 | + if( z[n+1]==0xbb && z[n+2]==0xbf ){ |
| 200559 | + n += 3; |
| 200560 | + break; |
| 200561 | + } |
| 200562 | + goto whitespace_done; |
| 200563 | + } |
| 200564 | + default: { |
| 200565 | + goto whitespace_done; |
| 200566 | + } |
| 200567 | + } |
| 200568 | + } |
| 200569 | + whitespace_done: |
| 200570 | + return n; |
| 200571 | +} |
| 200572 | + |
| 200159 | 200573 | /* |
| 200160 | 200574 | ** Extra floating-point literals to allow in JSON. |
| 200161 | 200575 | */ |
| 200162 | 200576 | static const struct NanInfName { |
| 200163 | 200577 | char c1; |
| | @@ -200172,204 +200586,456 @@ |
| 200172 | 200586 | { 'i', 'I', 8, JSON_REAL, 7, "infinity", "9.0e999" }, |
| 200173 | 200587 | { 'n', 'N', 3, JSON_NULL, 4, "NaN", "null" }, |
| 200174 | 200588 | { 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" }, |
| 200175 | 200589 | { 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" }, |
| 200176 | 200590 | }; |
| 200177 | | -#endif /* SQLITE_ENABLE_JSON_NAN_INF */ |
| 200178 | 200591 | |
| 200179 | 200592 | /* |
| 200180 | 200593 | ** Parse a single JSON value which begins at pParse->zJson[i]. Return the |
| 200181 | 200594 | ** index of the first character past the end of the value parsed. |
| 200182 | 200595 | ** |
| 200183 | | -** Return negative for a syntax error. Special cases: return -2 if the |
| 200184 | | -** first non-whitespace character is '}' and return -3 if the first |
| 200185 | | -** non-whitespace character is ']'. |
| 200596 | +** Special return values: |
| 200597 | +** |
| 200598 | +** 0 End if input |
| 200599 | +** -1 Syntax error |
| 200600 | +** -2 '}' seen |
| 200601 | +** -3 ']' seen |
| 200602 | +** -4 ',' seen |
| 200603 | +** -5 ':' seen |
| 200186 | 200604 | */ |
| 200187 | 200605 | static int jsonParseValue(JsonParse *pParse, u32 i){ |
| 200188 | 200606 | char c; |
| 200189 | 200607 | u32 j; |
| 200190 | 200608 | int iThis; |
| 200191 | 200609 | int x; |
| 200192 | 200610 | JsonNode *pNode; |
| 200193 | 200611 | const char *z = pParse->zJson; |
| 200194 | | - while( fast_isspace(z[i]) ){ i++; } |
| 200195 | | - if( (c = z[i])=='{' ){ |
| 200612 | +json_parse_restart: |
| 200613 | + switch( (u8)z[i] ){ |
| 200614 | + case '{': { |
| 200196 | 200615 | /* Parse object */ |
| 200197 | 200616 | iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); |
| 200198 | 200617 | if( iThis<0 ) return -1; |
| 200199 | 200618 | for(j=i+1;;j++){ |
| 200200 | | - while( fast_isspace(z[j]) ){ j++; } |
| 200201 | | - if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 200619 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ){ |
| 200620 | + pParse->iErr = j; |
| 200621 | + return -1; |
| 200622 | + } |
| 200202 | 200623 | x = jsonParseValue(pParse, j); |
| 200203 | | - if( x<0 ){ |
| 200204 | | - pParse->iDepth--; |
| 200205 | | - if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 200206 | | - return -1; |
| 200624 | + if( x<=0 ){ |
| 200625 | + if( x==(-2) ){ |
| 200626 | + j = pParse->iErr; |
| 200627 | + if( pParse->nNode!=(u32)iThis+1 ) pParse->hasNonstd = 1; |
| 200628 | + pParse->iDepth--; |
| 200629 | + break; |
| 200630 | + } |
| 200631 | + j += json5Whitespace(&z[j]); |
| 200632 | + if( sqlite3JsonId1(z[j]) |
| 200633 | + || (z[j]=='\\' && z[j+1]=='u' && jsonIs4Hex(&z[j+2])) |
| 200634 | + ){ |
| 200635 | + int k = j+1; |
| 200636 | + while( (sqlite3JsonId2(z[k]) && json5Whitespace(&z[k])==0) |
| 200637 | + || (z[k]=='\\' && z[k+1]=='u' && jsonIs4Hex(&z[k+2])) |
| 200638 | + ){ |
| 200639 | + k++; |
| 200640 | + } |
| 200641 | + jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), k-j, &z[j]); |
| 200642 | + pParse->hasNonstd = 1; |
| 200643 | + x = k; |
| 200644 | + }else{ |
| 200645 | + if( x!=-1 ) pParse->iErr = j; |
| 200646 | + return -1; |
| 200647 | + } |
| 200207 | 200648 | } |
| 200208 | 200649 | if( pParse->oom ) return -1; |
| 200209 | 200650 | pNode = &pParse->aNode[pParse->nNode-1]; |
| 200210 | | - if( pNode->eType!=JSON_STRING ) return -1; |
| 200651 | + if( pNode->eType!=JSON_STRING ){ |
| 200652 | + pParse->iErr = j; |
| 200653 | + return -1; |
| 200654 | + } |
| 200211 | 200655 | pNode->jnFlags |= JNODE_LABEL; |
| 200212 | 200656 | j = x; |
| 200213 | | - while( fast_isspace(z[j]) ){ j++; } |
| 200214 | | - if( z[j]!=':' ) return -1; |
| 200215 | | - j++; |
| 200657 | + if( z[j]==':' ){ |
| 200658 | + j++; |
| 200659 | + }else{ |
| 200660 | + if( fast_isspace(z[j]) ){ |
| 200661 | + do{ j++; }while( fast_isspace(z[j]) ); |
| 200662 | + if( z[j]==':' ){ |
| 200663 | + j++; |
| 200664 | + goto parse_object_value; |
| 200665 | + } |
| 200666 | + } |
| 200667 | + x = jsonParseValue(pParse, j); |
| 200668 | + if( x!=(-5) ){ |
| 200669 | + if( x!=(-1) ) pParse->iErr = j; |
| 200670 | + return -1; |
| 200671 | + } |
| 200672 | + j = pParse->iErr+1; |
| 200673 | + } |
| 200674 | + parse_object_value: |
| 200216 | 200675 | x = jsonParseValue(pParse, j); |
| 200217 | 200676 | pParse->iDepth--; |
| 200218 | | - if( x<0 ) return -1; |
| 200677 | + if( x<=0 ){ |
| 200678 | + if( x!=(-1) ) pParse->iErr = j; |
| 200679 | + return -1; |
| 200680 | + } |
| 200219 | 200681 | j = x; |
| 200220 | | - while( fast_isspace(z[j]) ){ j++; } |
| 200221 | | - c = z[j]; |
| 200222 | | - if( c==',' ) continue; |
| 200223 | | - if( c!='}' ) return -1; |
| 200224 | | - break; |
| 200682 | + if( z[j]==',' ){ |
| 200683 | + continue; |
| 200684 | + }else if( z[j]=='}' ){ |
| 200685 | + break; |
| 200686 | + }else{ |
| 200687 | + if( fast_isspace(z[j]) ){ |
| 200688 | + do{ j++; }while( fast_isspace(z[j]) ); |
| 200689 | + if( z[j]==',' ){ |
| 200690 | + continue; |
| 200691 | + }else if( z[j]=='}' ){ |
| 200692 | + break; |
| 200693 | + } |
| 200694 | + } |
| 200695 | + x = jsonParseValue(pParse, j); |
| 200696 | + if( x==(-4) ){ |
| 200697 | + j = pParse->iErr; |
| 200698 | + continue; |
| 200699 | + } |
| 200700 | + if( x==(-2) ){ |
| 200701 | + j = pParse->iErr; |
| 200702 | + break; |
| 200703 | + } |
| 200704 | + } |
| 200705 | + pParse->iErr = j; |
| 200706 | + return -1; |
| 200225 | 200707 | } |
| 200226 | 200708 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| 200227 | 200709 | return j+1; |
| 200228 | | - }else if( c=='[' ){ |
| 200710 | + } |
| 200711 | + case '[': { |
| 200229 | 200712 | /* Parse array */ |
| 200230 | 200713 | iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); |
| 200231 | 200714 | if( iThis<0 ) return -1; |
| 200232 | 200715 | memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u)); |
| 200233 | 200716 | for(j=i+1;;j++){ |
| 200234 | | - while( fast_isspace(z[j]) ){ j++; } |
| 200235 | | - if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 200717 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ){ |
| 200718 | + pParse->iErr = j; |
| 200719 | + return -1; |
| 200720 | + } |
| 200236 | 200721 | x = jsonParseValue(pParse, j); |
| 200237 | 200722 | pParse->iDepth--; |
| 200238 | | - if( x<0 ){ |
| 200239 | | - if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 200723 | + if( x<=0 ){ |
| 200724 | + if( x==(-3) ){ |
| 200725 | + j = pParse->iErr; |
| 200726 | + if( pParse->nNode!=(u32)iThis+1 ) pParse->hasNonstd = 1; |
| 200727 | + break; |
| 200728 | + } |
| 200729 | + if( x!=(-1) ) pParse->iErr = j; |
| 200240 | 200730 | return -1; |
| 200241 | 200731 | } |
| 200242 | 200732 | j = x; |
| 200243 | | - while( fast_isspace(z[j]) ){ j++; } |
| 200244 | | - c = z[j]; |
| 200245 | | - if( c==',' ) continue; |
| 200246 | | - if( c!=']' ) return -1; |
| 200247 | | - break; |
| 200733 | + if( z[j]==',' ){ |
| 200734 | + continue; |
| 200735 | + }else if( z[j]==']' ){ |
| 200736 | + break; |
| 200737 | + }else{ |
| 200738 | + if( fast_isspace(z[j]) ){ |
| 200739 | + do{ j++; }while( fast_isspace(z[j]) ); |
| 200740 | + if( z[j]==',' ){ |
| 200741 | + continue; |
| 200742 | + }else if( z[j]==']' ){ |
| 200743 | + break; |
| 200744 | + } |
| 200745 | + } |
| 200746 | + x = jsonParseValue(pParse, j); |
| 200747 | + if( x==(-4) ){ |
| 200748 | + j = pParse->iErr; |
| 200749 | + continue; |
| 200750 | + } |
| 200751 | + if( x==(-3) ){ |
| 200752 | + j = pParse->iErr; |
| 200753 | + break; |
| 200754 | + } |
| 200755 | + } |
| 200756 | + pParse->iErr = j; |
| 200757 | + return -1; |
| 200248 | 200758 | } |
| 200249 | 200759 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| 200250 | 200760 | return j+1; |
| 200251 | | - }else if( c=='"' ){ |
| 200761 | + } |
| 200762 | + case '\'': { |
| 200763 | + u8 jnFlags; |
| 200764 | + char cDelim; |
| 200765 | + pParse->hasNonstd = 1; |
| 200766 | + jnFlags = JNODE_JSON5; |
| 200767 | + goto parse_string; |
| 200768 | + case '"': |
| 200252 | 200769 | /* Parse string */ |
| 200253 | | - u8 jnFlags = 0; |
| 200770 | + jnFlags = 0; |
| 200771 | + parse_string: |
| 200772 | + cDelim = z[i]; |
| 200254 | 200773 | j = i+1; |
| 200255 | 200774 | for(;;){ |
| 200256 | 200775 | c = z[j]; |
| 200257 | 200776 | if( (c & ~0x1f)==0 ){ |
| 200258 | 200777 | /* Control characters are not allowed in strings */ |
| 200778 | + pParse->iErr = j; |
| 200259 | 200779 | return -1; |
| 200260 | 200780 | } |
| 200261 | 200781 | if( c=='\\' ){ |
| 200262 | 200782 | c = z[++j]; |
| 200263 | 200783 | if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' |
| 200264 | 200784 | || c=='n' || c=='r' || c=='t' |
| 200265 | | - || (c=='u' && jsonIs4Hex(z+j+1)) ){ |
| 200266 | | - jnFlags = JNODE_ESCAPE; |
| 200785 | + || (c=='u' && jsonIs4Hex(&z[j+1])) ){ |
| 200786 | + jnFlags |= JNODE_ESCAPE; |
| 200787 | + }else if( c=='\'' || c=='0' || c=='v' || c=='\n' |
| 200788 | + || (0xe2==(u8)c && 0x80==(u8)z[j+1] |
| 200789 | + && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2])) |
| 200790 | + || (c=='x' && jsonIs2Hex(&z[j+1])) ){ |
| 200791 | + jnFlags |= (JNODE_ESCAPE|JNODE_JSON5); |
| 200792 | + pParse->hasNonstd = 1; |
| 200793 | + }else if( c=='\r' ){ |
| 200794 | + if( z[j+1]=='\n' ) j++; |
| 200795 | + jnFlags |= (JNODE_ESCAPE|JNODE_JSON5); |
| 200796 | + pParse->hasNonstd = 1; |
| 200267 | 200797 | }else{ |
| 200798 | + pParse->iErr = j; |
| 200268 | 200799 | return -1; |
| 200269 | 200800 | } |
| 200270 | | - }else if( c=='"' ){ |
| 200801 | + }else if( c==cDelim ){ |
| 200271 | 200802 | break; |
| 200272 | 200803 | } |
| 200273 | 200804 | j++; |
| 200274 | 200805 | } |
| 200275 | | - jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]); |
| 200276 | | - if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; |
| 200806 | + jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j+1-i, &z[i]); |
| 200277 | 200807 | return j+1; |
| 200278 | | - }else if( c=='n' |
| 200279 | | - && strncmp(z+i,"null",4)==0 |
| 200280 | | - && !sqlite3Isalnum(z[i+4]) ){ |
| 200281 | | - jsonParseAddNode(pParse, JSON_NULL, 0, 0); |
| 200282 | | - return i+4; |
| 200283 | | - }else if( c=='t' |
| 200284 | | - && strncmp(z+i,"true",4)==0 |
| 200285 | | - && !sqlite3Isalnum(z[i+4]) ){ |
| 200286 | | - jsonParseAddNode(pParse, JSON_TRUE, 0, 0); |
| 200287 | | - return i+4; |
| 200288 | | - }else if( c=='f' |
| 200289 | | - && strncmp(z+i,"false",5)==0 |
| 200290 | | - && !sqlite3Isalnum(z[i+5]) ){ |
| 200291 | | - jsonParseAddNode(pParse, JSON_FALSE, 0, 0); |
| 200292 | | - return i+5; |
| 200293 | | - }else if( c=='-' || (c>='0' && c<='9') ){ |
| 200808 | + } |
| 200809 | + case 'n': { |
| 200810 | + if( strncmp(z+i,"null",4)==0 && !sqlite3Isalnum(z[i+4]) ){ |
| 200811 | + jsonParseAddNode(pParse, JSON_NULL, 0, 0); |
| 200812 | + return i+4; |
| 200813 | + } |
| 200814 | + pParse->iErr = i; |
| 200815 | + return -1; |
| 200816 | + } |
| 200817 | + case 't': { |
| 200818 | + if( strncmp(z+i,"true",4)==0 && !sqlite3Isalnum(z[i+4]) ){ |
| 200819 | + jsonParseAddNode(pParse, JSON_TRUE, 0, 0); |
| 200820 | + return i+4; |
| 200821 | + } |
| 200822 | + pParse->iErr = i; |
| 200823 | + return -1; |
| 200824 | + } |
| 200825 | + case 'f': { |
| 200826 | + if( strncmp(z+i,"false",5)==0 && !sqlite3Isalnum(z[i+5]) ){ |
| 200827 | + jsonParseAddNode(pParse, JSON_FALSE, 0, 0); |
| 200828 | + return i+5; |
| 200829 | + } |
| 200830 | + pParse->iErr = i; |
| 200831 | + return -1; |
| 200832 | + } |
| 200833 | + case '+': { |
| 200834 | + u8 seenDP, seenE, jnFlags; |
| 200835 | + pParse->hasNonstd = 1; |
| 200836 | + jnFlags = JNODE_JSON5; |
| 200837 | + goto parse_number; |
| 200838 | + case '.': |
| 200839 | + if( sqlite3Isdigit(z[i+1]) ){ |
| 200840 | + pParse->hasNonstd = 1; |
| 200841 | + jnFlags = JNODE_JSON5; |
| 200842 | + seenE = 0; |
| 200843 | + seenDP = JSON_REAL; |
| 200844 | + goto parse_number_2; |
| 200845 | + } |
| 200846 | + pParse->iErr = i; |
| 200847 | + return -1; |
| 200848 | + case '-': |
| 200849 | + case '0': |
| 200850 | + case '1': |
| 200851 | + case '2': |
| 200852 | + case '3': |
| 200853 | + case '4': |
| 200854 | + case '5': |
| 200855 | + case '6': |
| 200856 | + case '7': |
| 200857 | + case '8': |
| 200858 | + case '9': |
| 200294 | 200859 | /* Parse number */ |
| 200295 | | - u8 seenDP = 0; |
| 200296 | | - u8 seenE = 0; |
| 200860 | + jnFlags = 0; |
| 200861 | + parse_number: |
| 200862 | + seenDP = JSON_INT; |
| 200863 | + seenE = 0; |
| 200297 | 200864 | assert( '-' < '0' ); |
| 200865 | + assert( '+' < '0' ); |
| 200866 | + assert( '.' < '0' ); |
| 200867 | + c = z[i]; |
| 200868 | + |
| 200298 | 200869 | if( c<='0' ){ |
| 200299 | | - j = c=='-' ? i+1 : i; |
| 200300 | | - if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1; |
| 200870 | + if( c=='0' ){ |
| 200871 | + if( (z[i+1]=='x' || z[i+1]=='X') && sqlite3Isxdigit(z[i+2]) ){ |
| 200872 | + assert( seenDP==JSON_INT ); |
| 200873 | + pParse->hasNonstd = 1; |
| 200874 | + jnFlags |= JNODE_JSON5; |
| 200875 | + for(j=i+3; sqlite3Isxdigit(z[j]); j++){} |
| 200876 | + goto parse_number_finish; |
| 200877 | + }else if( sqlite3Isdigit(z[i+1]) ){ |
| 200878 | + pParse->iErr = i+1; |
| 200879 | + return -1; |
| 200880 | + } |
| 200881 | + }else{ |
| 200882 | + if( !sqlite3Isdigit(z[i+1]) ){ |
| 200883 | + /* JSON5 allows for "+Infinity" and "-Infinity" using exactly |
| 200884 | + ** that case. SQLite also allows these in any case and it allows |
| 200885 | + ** "+inf" and "-inf". */ |
| 200886 | + if( (z[i+1]=='I' || z[i+1]=='i') |
| 200887 | + && sqlite3StrNICmp(&z[i+1], "inf",3)==0 |
| 200888 | + ){ |
| 200889 | + pParse->hasNonstd = 1; |
| 200890 | + if( z[i]=='-' ){ |
| 200891 | + jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); |
| 200892 | + }else{ |
| 200893 | + jsonParseAddNode(pParse, JSON_REAL, 7, "9.0e999"); |
| 200894 | + } |
| 200895 | + return i + (sqlite3StrNICmp(&z[i+4],"inity",5)==0 ? 9 : 4); |
| 200896 | + } |
| 200897 | + if( z[i+1]=='.' ){ |
| 200898 | + pParse->hasNonstd = 1; |
| 200899 | + jnFlags |= JNODE_JSON5; |
| 200900 | + goto parse_number_2; |
| 200901 | + } |
| 200902 | + pParse->iErr = i; |
| 200903 | + return -1; |
| 200904 | + } |
| 200905 | + if( z[i+1]=='0' ){ |
| 200906 | + if( sqlite3Isdigit(z[i+2]) ){ |
| 200907 | + pParse->iErr = i+1; |
| 200908 | + return -1; |
| 200909 | + }else if( (z[i+2]=='x' || z[i+2]=='X') && sqlite3Isxdigit(z[i+3]) ){ |
| 200910 | + pParse->hasNonstd = 1; |
| 200911 | + jnFlags |= JNODE_JSON5; |
| 200912 | + for(j=i+4; sqlite3Isxdigit(z[j]); j++){} |
| 200913 | + goto parse_number_finish; |
| 200914 | + } |
| 200915 | + } |
| 200916 | + } |
| 200301 | 200917 | } |
| 200302 | | - j = i+1; |
| 200303 | | - for(;; j++){ |
| 200918 | + parse_number_2: |
| 200919 | + for(j=i+1;; j++){ |
| 200304 | 200920 | c = z[j]; |
| 200305 | | - if( c>='0' && c<='9' ) continue; |
| 200921 | + if( sqlite3Isdigit(c) ) continue; |
| 200306 | 200922 | if( c=='.' ){ |
| 200307 | | - if( z[j-1]=='-' ) return -1; |
| 200308 | | - if( seenDP ) return -1; |
| 200309 | | - seenDP = 1; |
| 200923 | + if( seenDP==JSON_REAL ){ |
| 200924 | + pParse->iErr = j; |
| 200925 | + return -1; |
| 200926 | + } |
| 200927 | + seenDP = JSON_REAL; |
| 200310 | 200928 | continue; |
| 200311 | 200929 | } |
| 200312 | 200930 | if( c=='e' || c=='E' ){ |
| 200313 | | - if( z[j-1]<'0' ) return -1; |
| 200314 | | - if( seenE ) return -1; |
| 200315 | | - seenDP = seenE = 1; |
| 200931 | + if( z[j-1]<'0' ){ |
| 200932 | + if( ALWAYS(z[j-1]=='.') && ALWAYS(j-2>=i) && sqlite3Isdigit(z[j-2]) ){ |
| 200933 | + pParse->hasNonstd = 1; |
| 200934 | + jnFlags |= JNODE_JSON5; |
| 200935 | + }else{ |
| 200936 | + pParse->iErr = j; |
| 200937 | + return -1; |
| 200938 | + } |
| 200939 | + } |
| 200940 | + if( seenE ){ |
| 200941 | + pParse->iErr = j; |
| 200942 | + return -1; |
| 200943 | + } |
| 200944 | + seenDP = JSON_REAL; |
| 200945 | + seenE = 1; |
| 200316 | 200946 | c = z[j+1]; |
| 200317 | 200947 | if( c=='+' || c=='-' ){ |
| 200318 | 200948 | j++; |
| 200319 | 200949 | c = z[j+1]; |
| 200320 | 200950 | } |
| 200321 | | - if( c<'0' || c>'9' ) return -1; |
| 200951 | + if( c<'0' || c>'9' ){ |
| 200952 | + pParse->iErr = j; |
| 200953 | + return -1; |
| 200954 | + } |
| 200322 | 200955 | continue; |
| 200323 | 200956 | } |
| 200324 | | -#ifdef SQLITE_ENABLE_JSON_NAN_INF |
| 200325 | | - /* Non-standard JSON: Allow "-Inf" (in any case) |
| 200326 | | - ** to be understood as floating point literals. */ |
| 200327 | | - if( (c=='i' || c=='I') |
| 200328 | | - && j==i+1 |
| 200329 | | - && z[i]=='-' |
| 200330 | | - && sqlite3StrNICmp(&z[j], "inf",3)==0 |
| 200331 | | - ){ |
| 200332 | | - if( !sqlite3Isalnum(z[j+3]) ){ |
| 200333 | | - jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); |
| 200334 | | - return i+4; |
| 200335 | | - }else if( (sqlite3StrNICmp(&z[j],"infinity",8)==0 && |
| 200336 | | - !sqlite3Isalnum(z[j+8])) ){ |
| 200337 | | - jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); |
| 200338 | | - return i+9; |
| 200339 | | - } |
| 200340 | | - } |
| 200341 | | -#endif |
| 200342 | 200957 | break; |
| 200343 | 200958 | } |
| 200344 | | - if( z[j-1]<'0' ) return -1; |
| 200345 | | - jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, |
| 200346 | | - j - i, &z[i]); |
| 200959 | + if( z[j-1]<'0' ){ |
| 200960 | + if( ALWAYS(z[j-1]=='.') && ALWAYS(j-2>=i) && sqlite3Isdigit(z[j-2]) ){ |
| 200961 | + pParse->hasNonstd = 1; |
| 200962 | + jnFlags |= JNODE_JSON5; |
| 200963 | + }else{ |
| 200964 | + pParse->iErr = j; |
| 200965 | + return -1; |
| 200966 | + } |
| 200967 | + } |
| 200968 | + parse_number_finish: |
| 200969 | + jsonParseAddNode(pParse, seenDP | (jnFlags<<8), j - i, &z[i]); |
| 200347 | 200970 | return j; |
| 200348 | | - }else if( c=='}' ){ |
| 200971 | + } |
| 200972 | + case '}': { |
| 200973 | + pParse->iErr = i; |
| 200349 | 200974 | return -2; /* End of {...} */ |
| 200350 | | - }else if( c==']' ){ |
| 200975 | + } |
| 200976 | + case ']': { |
| 200977 | + pParse->iErr = i; |
| 200351 | 200978 | return -3; /* End of [...] */ |
| 200352 | | - }else if( c==0 ){ |
| 200979 | + } |
| 200980 | + case ',': { |
| 200981 | + pParse->iErr = i; |
| 200982 | + return -4; /* List separator */ |
| 200983 | + } |
| 200984 | + case ':': { |
| 200985 | + pParse->iErr = i; |
| 200986 | + return -5; /* Object label/value separator */ |
| 200987 | + } |
| 200988 | + case 0: { |
| 200353 | 200989 | return 0; /* End of file */ |
| 200354 | | - }else{ |
| 200355 | | -#ifdef SQLITE_ENABLE_JSON_NAN_INF |
| 200356 | | - int k, nn; |
| 200990 | + } |
| 200991 | + case 0x09: |
| 200992 | + case 0x0a: |
| 200993 | + case 0x0d: |
| 200994 | + case 0x20: { |
| 200995 | + do{ |
| 200996 | + i++; |
| 200997 | + }while( fast_isspace(z[i]) ); |
| 200998 | + goto json_parse_restart; |
| 200999 | + } |
| 201000 | + case 0x0b: |
| 201001 | + case 0x0c: |
| 201002 | + case '/': |
| 201003 | + case 0xc2: |
| 201004 | + case 0xe1: |
| 201005 | + case 0xe2: |
| 201006 | + case 0xe3: |
| 201007 | + case 0xef: { |
| 201008 | + j = json5Whitespace(&z[i]); |
| 201009 | + if( j>0 ){ |
| 201010 | + i += j; |
| 201011 | + pParse->hasNonstd = 1; |
| 201012 | + goto json_parse_restart; |
| 201013 | + } |
| 201014 | + pParse->iErr = i; |
| 201015 | + return -1; |
| 201016 | + } |
| 201017 | + default: { |
| 201018 | + u32 k; |
| 201019 | + int nn; |
| 201020 | + c = z[i]; |
| 200357 | 201021 | for(k=0; k<sizeof(aNanInfName)/sizeof(aNanInfName[0]); k++){ |
| 200358 | 201022 | if( c!=aNanInfName[k].c1 && c!=aNanInfName[k].c2 ) continue; |
| 200359 | 201023 | nn = aNanInfName[k].n; |
| 200360 | 201024 | if( sqlite3StrNICmp(&z[i], aNanInfName[k].zMatch, nn)!=0 ){ |
| 200361 | 201025 | continue; |
| 200362 | 201026 | } |
| 200363 | 201027 | if( sqlite3Isalnum(z[i+nn]) ) continue; |
| 200364 | 201028 | jsonParseAddNode(pParse, aNanInfName[k].eType, |
| 200365 | 201029 | aNanInfName[k].nRepl, aNanInfName[k].zRepl); |
| 201030 | + pParse->hasNonstd = 1; |
| 200366 | 201031 | return i + nn; |
| 200367 | 201032 | } |
| 200368 | | -#endif |
| 201033 | + pParse->iErr = i; |
| 200369 | 201034 | return -1; /* Syntax error */ |
| 200370 | 201035 | } |
| 201036 | + } /* End switch(z[i]) */ |
| 200371 | 201037 | } |
| 200372 | 201038 | |
| 200373 | 201039 | /* |
| 200374 | 201040 | ** Parse a complete JSON string. Return 0 on success or non-zero if there |
| 200375 | 201041 | ** are any errors. If an error occurs, free all memory associated with |
| | @@ -200389,11 +201055,18 @@ |
| 200389 | 201055 | i = jsonParseValue(pParse, 0); |
| 200390 | 201056 | if( pParse->oom ) i = -1; |
| 200391 | 201057 | if( i>0 ){ |
| 200392 | 201058 | assert( pParse->iDepth==0 ); |
| 200393 | 201059 | while( fast_isspace(zJson[i]) ) i++; |
| 200394 | | - if( zJson[i] ) i = -1; |
| 201060 | + if( zJson[i] ){ |
| 201061 | + i += json5Whitespace(&zJson[i]); |
| 201062 | + if( zJson[i] ){ |
| 201063 | + jsonParseReset(pParse); |
| 201064 | + return 1; |
| 201065 | + } |
| 201066 | + pParse->hasNonstd = 1; |
| 201067 | + } |
| 200395 | 201068 | } |
| 200396 | 201069 | if( i<=0 ){ |
| 200397 | 201070 | if( pCtx!=0 ){ |
| 200398 | 201071 | if( pParse->oom ){ |
| 200399 | 201072 | sqlite3_result_error_nomem(pCtx); |
| | @@ -200460,10 +201133,19 @@ |
| 200460 | 201133 | ** of the argv array. Use the sqlite3_get_auxdata() cache for this |
| 200461 | 201134 | ** parse if it is available. If the cache is not available or if it |
| 200462 | 201135 | ** is no longer valid, parse the JSON again and return the new parse, |
| 200463 | 201136 | ** and also register the new parse so that it will be available for |
| 200464 | 201137 | ** future sqlite3_get_auxdata() calls. |
| 201138 | +** |
| 201139 | +** If an error occurs and pErrCtx!=0 then report the error on pErrCtx |
| 201140 | +** and return NULL. |
| 201141 | +** |
| 201142 | +** If an error occurs and pErrCtx==0 then return the Parse object with |
| 201143 | +** JsonParse.nErr non-zero. If the caller invokes this routine with |
| 201144 | +** pErrCtx==0 and it gets back a JsonParse with nErr!=0, then the caller |
| 201145 | +** is responsible for invoking jsonParseFree() on the returned value. |
| 201146 | +** But the caller may invoke jsonParseFree() *only* if pParse->nErr!=0. |
| 200465 | 201147 | */ |
| 200466 | 201148 | static JsonParse *jsonParseCached( |
| 200467 | 201149 | sqlite3_context *pCtx, |
| 200468 | 201150 | sqlite3_value **argv, |
| 200469 | 201151 | sqlite3_context *pErrCtx |
| | @@ -200509,10 +201191,14 @@ |
| 200509 | 201191 | } |
| 200510 | 201192 | memset(p, 0, sizeof(*p)); |
| 200511 | 201193 | p->zJson = (char*)&p[1]; |
| 200512 | 201194 | memcpy((char*)p->zJson, zJson, nJson+1); |
| 200513 | 201195 | if( jsonParse(p, pErrCtx, p->zJson) ){ |
| 201196 | + if( pErrCtx==0 ){ |
| 201197 | + p->nErr = 1; |
| 201198 | + return p; |
| 201199 | + } |
| 200514 | 201200 | sqlite3_free(p); |
| 200515 | 201201 | return 0; |
| 200516 | 201202 | } |
| 200517 | 201203 | p->nJson = nJson; |
| 200518 | 201204 | p->iHold = iMaxHold+1; |
| | @@ -200523,19 +201209,28 @@ |
| 200523 | 201209 | |
| 200524 | 201210 | /* |
| 200525 | 201211 | ** Compare the OBJECT label at pNode against zKey,nKey. Return true on |
| 200526 | 201212 | ** a match. |
| 200527 | 201213 | */ |
| 200528 | | -static int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){ |
| 201214 | +static int jsonLabelCompare(const JsonNode *pNode, const char *zKey, u32 nKey){ |
| 200529 | 201215 | assert( pNode->eU==1 ); |
| 200530 | 201216 | if( pNode->jnFlags & JNODE_RAW ){ |
| 200531 | 201217 | if( pNode->n!=nKey ) return 0; |
| 200532 | 201218 | return strncmp(pNode->u.zJContent, zKey, nKey)==0; |
| 200533 | 201219 | }else{ |
| 200534 | 201220 | if( pNode->n!=nKey+2 ) return 0; |
| 200535 | 201221 | return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; |
| 200536 | 201222 | } |
| 201223 | +} |
| 201224 | +static int jsonSameLabel(const JsonNode *p1, const JsonNode *p2){ |
| 201225 | + if( p1->jnFlags & JNODE_RAW ){ |
| 201226 | + return jsonLabelCompare(p2, p1->u.zJContent, p1->n); |
| 201227 | + }else if( p2->jnFlags & JNODE_RAW ){ |
| 201228 | + return jsonLabelCompare(p1, p2->u.zJContent, p2->n); |
| 201229 | + }else{ |
| 201230 | + return p1->n==p2->n && strncmp(p1->u.zJContent,p2->u.zJContent,p1->n)==0; |
| 201231 | + } |
| 200537 | 201232 | } |
| 200538 | 201233 | |
| 200539 | 201234 | /* forward declaration */ |
| 200540 | 201235 | static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); |
| 200541 | 201236 | |
| | @@ -201003,11 +201698,11 @@ |
| 201003 | 201698 | if( argc==2 ){ |
| 201004 | 201699 | /* With a single PATH argument */ |
| 201005 | 201700 | zPath = (const char*)sqlite3_value_text(argv[1]); |
| 201006 | 201701 | if( zPath==0 ) return; |
| 201007 | 201702 | if( flags & JSON_ABPATH ){ |
| 201008 | | - if( zPath[0]!='$' ){ |
| 201703 | + if( zPath[0]!='$' || (zPath[1]!='.' && zPath[1]!='[' && zPath[1]!=0) ){ |
| 201009 | 201704 | /* The -> and ->> operators accept abbreviated PATH arguments. This |
| 201010 | 201705 | ** is mostly for compatibility with PostgreSQL, but also for |
| 201011 | 201706 | ** convenience. |
| 201012 | 201707 | ** |
| 201013 | 201708 | ** NUMBER ==> $[NUMBER] // PG compatible |
| | @@ -201094,16 +201789,14 @@ |
| 201094 | 201789 | assert( pPatch[i].eType==JSON_STRING ); |
| 201095 | 201790 | assert( pPatch[i].jnFlags & JNODE_LABEL ); |
| 201096 | 201791 | assert( pPatch[i].eU==1 ); |
| 201097 | 201792 | nKey = pPatch[i].n; |
| 201098 | 201793 | zKey = pPatch[i].u.zJContent; |
| 201099 | | - assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); |
| 201100 | 201794 | for(j=1; j<pTarget->n; j += jsonNodeSize(&pTarget[j+1])+1 ){ |
| 201101 | 201795 | assert( pTarget[j].eType==JSON_STRING ); |
| 201102 | 201796 | assert( pTarget[j].jnFlags & JNODE_LABEL ); |
| 201103 | | - assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); |
| 201104 | | - if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){ |
| 201797 | + if( jsonSameLabel(&pPatch[i], &pTarget[j]) ){ |
| 201105 | 201798 | if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break; |
| 201106 | 201799 | if( pPatch[i+1].eType==JSON_NULL ){ |
| 201107 | 201800 | pTarget[j+1].jnFlags |= JNODE_REMOVE; |
| 201108 | 201801 | }else{ |
| 201109 | 201802 | JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]); |
| | @@ -201386,22 +202079,81 @@ |
| 201386 | 202079 | } |
| 201387 | 202080 | |
| 201388 | 202081 | /* |
| 201389 | 202082 | ** json_valid(JSON) |
| 201390 | 202083 | ** |
| 201391 | | -** Return 1 if JSON is a well-formed JSON string according to RFC-7159. |
| 201392 | | -** Return 0 otherwise. |
| 202084 | +** Return 1 if JSON is a well-formed canonical JSON string according |
| 202085 | +** to RFC-7159. Return 0 otherwise. |
| 201393 | 202086 | */ |
| 201394 | 202087 | static void jsonValidFunc( |
| 201395 | 202088 | sqlite3_context *ctx, |
| 201396 | 202089 | int argc, |
| 201397 | 202090 | sqlite3_value **argv |
| 201398 | 202091 | ){ |
| 201399 | 202092 | JsonParse *p; /* The parse */ |
| 201400 | 202093 | UNUSED_PARAMETER(argc); |
| 201401 | 202094 | p = jsonParseCached(ctx, argv, 0); |
| 201402 | | - sqlite3_result_int(ctx, p!=0); |
| 202095 | + if( p==0 || p->oom ){ |
| 202096 | + sqlite3_result_error_nomem(ctx); |
| 202097 | + sqlite3_free(p); |
| 202098 | + }else{ |
| 202099 | + sqlite3_result_int(ctx, p->nErr==0 && p->hasNonstd==0); |
| 202100 | + if( p->nErr ) jsonParseFree(p); |
| 202101 | + } |
| 202102 | +} |
| 202103 | + |
| 202104 | +/* |
| 202105 | +** json_error_position(JSON) |
| 202106 | +** |
| 202107 | +** If the argument is not an interpretable JSON string, then return the 1-based |
| 202108 | +** character position at which the parser first recognized that the input |
| 202109 | +** was in error. The left-most character is 1. If the string is valid |
| 202110 | +** JSON, then return 0. |
| 202111 | +** |
| 202112 | +** Note that json_valid() is only true for strictly conforming canonical JSON. |
| 202113 | +** But this routine returns zero if the input contains extension. Thus: |
| 202114 | +** |
| 202115 | +** (1) If the input X is strictly conforming canonical JSON: |
| 202116 | +** |
| 202117 | +** json_valid(X) returns true |
| 202118 | +** json_error_position(X) returns 0 |
| 202119 | +** |
| 202120 | +** (2) If the input X is JSON but it includes extension (such as JSON5) that |
| 202121 | +** are not part of RFC-8259: |
| 202122 | +** |
| 202123 | +** json_valid(X) returns false |
| 202124 | +** json_error_position(X) return 0 |
| 202125 | +** |
| 202126 | +** (3) If the input X cannot be interpreted as JSON even taking extensions |
| 202127 | +** into account: |
| 202128 | +** |
| 202129 | +** json_valid(X) return false |
| 202130 | +** json_error_position(X) returns 1 or more |
| 202131 | +*/ |
| 202132 | +static void jsonErrorFunc( |
| 202133 | + sqlite3_context *ctx, |
| 202134 | + int argc, |
| 202135 | + sqlite3_value **argv |
| 202136 | +){ |
| 202137 | + JsonParse *p; /* The parse */ |
| 202138 | + UNUSED_PARAMETER(argc); |
| 202139 | + p = jsonParseCached(ctx, argv, 0); |
| 202140 | + if( p==0 || p->oom ){ |
| 202141 | + sqlite3_result_error_nomem(ctx); |
| 202142 | + sqlite3_free(p); |
| 202143 | + }else if( p->nErr==0 ){ |
| 202144 | + sqlite3_result_int(ctx, 0); |
| 202145 | + }else{ |
| 202146 | + int n = 1; |
| 202147 | + u32 i; |
| 202148 | + const char *z = p->zJson; |
| 202149 | + for(i=0; i<p->iErr && ALWAYS(z[i]); i++){ |
| 202150 | + if( (z[i]&0xc0)!=0x80 ) n++; |
| 202151 | + } |
| 202152 | + sqlite3_result_int(ctx, n); |
| 202153 | + jsonParseFree(p); |
| 202154 | + } |
| 201403 | 202155 | } |
| 201404 | 202156 | |
| 201405 | 202157 | |
| 201406 | 202158 | /**************************************************************************** |
| 201407 | 202159 | ** Aggregate SQL function implementations |
| | @@ -201741,18 +202493,20 @@ |
| 201741 | 202493 | assert( pNode->eType==JSON_STRING ); |
| 201742 | 202494 | assert( pNode->jnFlags & JNODE_LABEL ); |
| 201743 | 202495 | assert( pNode->eU==1 ); |
| 201744 | 202496 | z = pNode->u.zJContent; |
| 201745 | 202497 | nn = pNode->n; |
| 201746 | | - assert( nn>=2 ); |
| 201747 | | - assert( z[0]=='"' ); |
| 201748 | | - assert( z[nn-1]=='"' ); |
| 201749 | | - if( nn>2 && sqlite3Isalpha(z[1]) ){ |
| 201750 | | - for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){} |
| 201751 | | - if( jj==nn-1 ){ |
| 201752 | | - z++; |
| 201753 | | - nn -= 2; |
| 202498 | + if( (pNode->jnFlags & JNODE_RAW)==0 ){ |
| 202499 | + assert( nn>=2 ); |
| 202500 | + assert( z[0]=='"' || z[0]=='\'' ); |
| 202501 | + assert( z[nn-1]=='"' || z[0]=='\'' ); |
| 202502 | + if( nn>2 && sqlite3Isalpha(z[1]) ){ |
| 202503 | + for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){} |
| 202504 | + if( jj==nn-1 ){ |
| 202505 | + z++; |
| 202506 | + nn -= 2; |
| 202507 | + } |
| 201754 | 202508 | } |
| 201755 | 202509 | } |
| 201756 | 202510 | jsonPrintf(nn+2, pStr, ".%.*s", nn, z); |
| 201757 | 202511 | } |
| 201758 | 202512 | |
| | @@ -202108,10 +202862,11 @@ |
| 202108 | 202862 | static FuncDef aJsonFunc[] = { |
| 202109 | 202863 | JFUNCTION(json, 1, 0, jsonRemoveFunc), |
| 202110 | 202864 | JFUNCTION(json_array, -1, 0, jsonArrayFunc), |
| 202111 | 202865 | JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc), |
| 202112 | 202866 | JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc), |
| 202867 | + JFUNCTION(json_error_position,1, 0, jsonErrorFunc), |
| 202113 | 202868 | JFUNCTION(json_extract, -1, 0, jsonExtractFunc), |
| 202114 | 202869 | JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc), |
| 202115 | 202870 | JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc), |
| 202116 | 202871 | JFUNCTION(json_insert, -1, 0, jsonSetFunc), |
| 202117 | 202872 | JFUNCTION(json_object, -1, 0, jsonObjectFunc), |
| | @@ -202632,20 +203387,21 @@ |
| 202632 | 203387 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 202633 | 203388 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 202634 | 203389 | ** at run-time. |
| 202635 | 203390 | */ |
| 202636 | 203391 | #ifndef SQLITE_BYTEORDER |
| 202637 | | -#if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 202638 | | - defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 202639 | | - defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 202640 | | - defined(__arm__) |
| 202641 | | -# define SQLITE_BYTEORDER 1234 |
| 202642 | | -#elif defined(sparc) || defined(__ppc__) |
| 202643 | | -# define SQLITE_BYTEORDER 4321 |
| 202644 | | -#else |
| 202645 | | -# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ |
| 202646 | | -#endif |
| 203392 | +# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 203393 | + defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 203394 | + defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 203395 | + defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) |
| 203396 | +# define SQLITE_BYTEORDER 1234 |
| 203397 | +# elif defined(sparc) || defined(__ppc__) || \ |
| 203398 | + defined(__ARMEB__) || defined(__AARCH64EB__) |
| 203399 | +# define SQLITE_BYTEORDER 4321 |
| 203400 | +# else |
| 203401 | +# define SQLITE_BYTEORDER 0 |
| 203402 | +# endif |
| 202647 | 203403 | #endif |
| 202648 | 203404 | |
| 202649 | 203405 | |
| 202650 | 203406 | /* What version of MSVC is being used. 0 means MSVC is not being used */ |
| 202651 | 203407 | #ifndef MSVC_VERSION |
| | @@ -216825,10 +217581,12 @@ |
| 216825 | 217581 | # define SESSIONS_STRM_CHUNK_SIZE 64 |
| 216826 | 217582 | # else |
| 216827 | 217583 | # define SESSIONS_STRM_CHUNK_SIZE 1024 |
| 216828 | 217584 | # endif |
| 216829 | 217585 | #endif |
| 217586 | + |
| 217587 | +#define SESSIONS_ROWID "_rowid_" |
| 216830 | 217588 | |
| 216831 | 217589 | static int sessions_strm_chunk_size = SESSIONS_STRM_CHUNK_SIZE; |
| 216832 | 217590 | |
| 216833 | 217591 | typedef struct SessionHook SessionHook; |
| 216834 | 217592 | struct SessionHook { |
| | @@ -216847,10 +217605,11 @@ |
| 216847 | 217605 | char *zDb; /* Name of database session is attached to */ |
| 216848 | 217606 | int bEnableSize; /* True if changeset_size() enabled */ |
| 216849 | 217607 | int bEnable; /* True if currently recording */ |
| 216850 | 217608 | int bIndirect; /* True if all changes are indirect */ |
| 216851 | 217609 | int bAutoAttach; /* True to auto-attach tables */ |
| 217610 | + int bImplicitPK; /* True to handle tables with implicit PK */ |
| 216852 | 217611 | int rc; /* Non-zero if an error has occurred */ |
| 216853 | 217612 | void *pFilterCtx; /* First argument to pass to xTableFilter */ |
| 216854 | 217613 | int (*xTableFilter)(void *pCtx, const char *zTab); |
| 216855 | 217614 | i64 nMalloc; /* Number of bytes of data allocated */ |
| 216856 | 217615 | i64 nMaxChangesetSize; |
| | @@ -216923,10 +217682,11 @@ |
| 216923 | 217682 | struct SessionTable { |
| 216924 | 217683 | SessionTable *pNext; |
| 216925 | 217684 | char *zName; /* Local name of table */ |
| 216926 | 217685 | int nCol; /* Number of columns in table zName */ |
| 216927 | 217686 | int bStat1; /* True if this is sqlite_stat1 */ |
| 217687 | + int bRowid; /* True if this table uses rowid for PK */ |
| 216928 | 217688 | const char **azCol; /* Column names */ |
| 216929 | 217689 | u8 *abPK; /* Array of primary key flags */ |
| 216930 | 217690 | int nEntry; /* Total number of entries in hash table */ |
| 216931 | 217691 | int nChange; /* Size of apChange[] array */ |
| 216932 | 217692 | SessionChange **apChange; /* Hash table buckets */ |
| | @@ -217315,60 +218075,66 @@ |
| 217315 | 218075 | ** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned |
| 217316 | 218076 | ** and the output variables are set as described above. |
| 217317 | 218077 | */ |
| 217318 | 218078 | static int sessionPreupdateHash( |
| 217319 | 218079 | sqlite3_session *pSession, /* Session object that owns pTab */ |
| 218080 | + i64 iRowid, |
| 217320 | 218081 | SessionTable *pTab, /* Session table handle */ |
| 217321 | 218082 | int bNew, /* True to hash the new.* PK */ |
| 217322 | 218083 | int *piHash, /* OUT: Hash value */ |
| 217323 | 218084 | int *pbNullPK /* OUT: True if there are NULL values in PK */ |
| 217324 | 218085 | ){ |
| 217325 | 218086 | unsigned int h = 0; /* Hash value to return */ |
| 217326 | 218087 | int i; /* Used to iterate through columns */ |
| 217327 | 218088 | |
| 217328 | | - assert( *pbNullPK==0 ); |
| 217329 | | - assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) ); |
| 217330 | | - for(i=0; i<pTab->nCol; i++){ |
| 217331 | | - if( pTab->abPK[i] ){ |
| 217332 | | - int rc; |
| 217333 | | - int eType; |
| 217334 | | - sqlite3_value *pVal; |
| 217335 | | - |
| 217336 | | - if( bNew ){ |
| 217337 | | - rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal); |
| 217338 | | - }else{ |
| 217339 | | - rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal); |
| 217340 | | - } |
| 217341 | | - if( rc!=SQLITE_OK ) return rc; |
| 217342 | | - |
| 217343 | | - eType = sqlite3_value_type(pVal); |
| 217344 | | - h = sessionHashAppendType(h, eType); |
| 217345 | | - if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 217346 | | - i64 iVal; |
| 217347 | | - if( eType==SQLITE_INTEGER ){ |
| 217348 | | - iVal = sqlite3_value_int64(pVal); |
| 217349 | | - }else{ |
| 217350 | | - double rVal = sqlite3_value_double(pVal); |
| 217351 | | - assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); |
| 217352 | | - memcpy(&iVal, &rVal, 8); |
| 217353 | | - } |
| 217354 | | - h = sessionHashAppendI64(h, iVal); |
| 217355 | | - }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ |
| 217356 | | - const u8 *z; |
| 217357 | | - int n; |
| 217358 | | - if( eType==SQLITE_TEXT ){ |
| 217359 | | - z = (const u8 *)sqlite3_value_text(pVal); |
| 217360 | | - }else{ |
| 217361 | | - z = (const u8 *)sqlite3_value_blob(pVal); |
| 217362 | | - } |
| 217363 | | - n = sqlite3_value_bytes(pVal); |
| 217364 | | - if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; |
| 217365 | | - h = sessionHashAppendBlob(h, n, z); |
| 217366 | | - }else{ |
| 217367 | | - assert( eType==SQLITE_NULL ); |
| 217368 | | - assert( pTab->bStat1==0 || i!=1 ); |
| 217369 | | - *pbNullPK = 1; |
| 218089 | + if( pTab->bRowid ){ |
| 218090 | + assert( pTab->nCol-1==pSession->hook.xCount(pSession->hook.pCtx) ); |
| 218091 | + h = sessionHashAppendI64(h, iRowid); |
| 218092 | + }else{ |
| 218093 | + assert( *pbNullPK==0 ); |
| 218094 | + assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) ); |
| 218095 | + for(i=0; i<pTab->nCol; i++){ |
| 218096 | + if( pTab->abPK[i] ){ |
| 218097 | + int rc; |
| 218098 | + int eType; |
| 218099 | + sqlite3_value *pVal; |
| 218100 | + |
| 218101 | + if( bNew ){ |
| 218102 | + rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal); |
| 218103 | + }else{ |
| 218104 | + rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal); |
| 218105 | + } |
| 218106 | + if( rc!=SQLITE_OK ) return rc; |
| 218107 | + |
| 218108 | + eType = sqlite3_value_type(pVal); |
| 218109 | + h = sessionHashAppendType(h, eType); |
| 218110 | + if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 218111 | + i64 iVal; |
| 218112 | + if( eType==SQLITE_INTEGER ){ |
| 218113 | + iVal = sqlite3_value_int64(pVal); |
| 218114 | + }else{ |
| 218115 | + double rVal = sqlite3_value_double(pVal); |
| 218116 | + assert( sizeof(iVal)==8 && sizeof(rVal)==8 ); |
| 218117 | + memcpy(&iVal, &rVal, 8); |
| 218118 | + } |
| 218119 | + h = sessionHashAppendI64(h, iVal); |
| 218120 | + }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ |
| 218121 | + const u8 *z; |
| 218122 | + int n; |
| 218123 | + if( eType==SQLITE_TEXT ){ |
| 218124 | + z = (const u8 *)sqlite3_value_text(pVal); |
| 218125 | + }else{ |
| 218126 | + z = (const u8 *)sqlite3_value_blob(pVal); |
| 218127 | + } |
| 218128 | + n = sqlite3_value_bytes(pVal); |
| 218129 | + if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM; |
| 218130 | + h = sessionHashAppendBlob(h, n, z); |
| 218131 | + }else{ |
| 218132 | + assert( eType==SQLITE_NULL ); |
| 218133 | + assert( pTab->bStat1==0 || i!=1 ); |
| 218134 | + *pbNullPK = 1; |
| 218135 | + } |
| 217370 | 218136 | } |
| 217371 | 218137 | } |
| 217372 | 218138 | } |
| 217373 | 218139 | |
| 217374 | 218140 | *piHash = (h % pTab->nChange); |
| | @@ -217647,16 +218413,22 @@ |
| 217647 | 218413 | ** if the pre-update-hook does not affect the same row as pChange, it returns |
| 217648 | 218414 | ** false. |
| 217649 | 218415 | */ |
| 217650 | 218416 | static int sessionPreupdateEqual( |
| 217651 | 218417 | sqlite3_session *pSession, /* Session object that owns SessionTable */ |
| 218418 | + i64 iRowid, /* Rowid value if pTab->bRowid */ |
| 217652 | 218419 | SessionTable *pTab, /* Table associated with change */ |
| 217653 | 218420 | SessionChange *pChange, /* Change to compare to */ |
| 217654 | 218421 | int op /* Current pre-update operation */ |
| 217655 | 218422 | ){ |
| 217656 | 218423 | int iCol; /* Used to iterate through columns */ |
| 217657 | 218424 | u8 *a = pChange->aRecord; /* Cursor used to scan change record */ |
| 218425 | + |
| 218426 | + if( pTab->bRowid ){ |
| 218427 | + if( a[0]!=SQLITE_INTEGER ) return 0; |
| 218428 | + return sessionGetI64(&a[1])==iRowid; |
| 218429 | + } |
| 217658 | 218430 | |
| 217659 | 218431 | assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE ); |
| 217660 | 218432 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 217661 | 218433 | if( !pTab->abPK[iCol] ){ |
| 217662 | 218434 | a += sessionSerialLen(a); |
| | @@ -217798,11 +218570,12 @@ |
| 217798 | 218570 | const char *zDb, /* Name of attached database (e.g. "main") */ |
| 217799 | 218571 | const char *zThis, /* Table name */ |
| 217800 | 218572 | int *pnCol, /* OUT: number of columns */ |
| 217801 | 218573 | const char **pzTab, /* OUT: Copy of zThis */ |
| 217802 | 218574 | const char ***pazCol, /* OUT: Array of column names for table */ |
| 217803 | | - u8 **pabPK /* OUT: Array of booleans - true for PK col */ |
| 218575 | + u8 **pabPK, /* OUT: Array of booleans - true for PK col */ |
| 218576 | + int *pbRowid /* OUT: True if only PK is a rowid */ |
| 217804 | 218577 | ){ |
| 217805 | 218578 | char *zPragma; |
| 217806 | 218579 | sqlite3_stmt *pStmt; |
| 217807 | 218580 | int rc; |
| 217808 | 218581 | sqlite3_int64 nByte; |
| | @@ -217810,10 +218583,11 @@ |
| 217810 | 218583 | int nThis; |
| 217811 | 218584 | int i; |
| 217812 | 218585 | u8 *pAlloc = 0; |
| 217813 | 218586 | char **azCol = 0; |
| 217814 | 218587 | u8 *abPK = 0; |
| 218588 | + int bRowid = 0; /* Set to true to use rowid as PK */ |
| 217815 | 218589 | |
| 217816 | 218590 | assert( pazCol && pabPK ); |
| 217817 | 218591 | |
| 217818 | 218592 | nThis = sqlite3Strlen30(zThis); |
| 217819 | 218593 | if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ |
| | @@ -217854,14 +218628,19 @@ |
| 217854 | 218628 | if( pzTab ) *pzTab = 0; |
| 217855 | 218629 | return rc; |
| 217856 | 218630 | } |
| 217857 | 218631 | |
| 217858 | 218632 | nByte = nThis + 1; |
| 218633 | + bRowid = (pbRowid!=0); |
| 217859 | 218634 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 217860 | 218635 | nByte += sqlite3_column_bytes(pStmt, 1); |
| 217861 | 218636 | nDbCol++; |
| 218637 | + if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; |
| 217862 | 218638 | } |
| 218639 | + if( nDbCol==0 ) bRowid = 0; |
| 218640 | + nDbCol += bRowid; |
| 218641 | + nByte += strlen(SESSIONS_ROWID); |
| 217863 | 218642 | rc = sqlite3_reset(pStmt); |
| 217864 | 218643 | |
| 217865 | 218644 | if( rc==SQLITE_OK ){ |
| 217866 | 218645 | nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); |
| 217867 | 218646 | pAlloc = sessionMalloc64(pSession, nByte); |
| | @@ -217879,10 +218658,18 @@ |
| 217879 | 218658 | *pzTab = (char *)pAlloc; |
| 217880 | 218659 | pAlloc += nThis+1; |
| 217881 | 218660 | } |
| 217882 | 218661 | |
| 217883 | 218662 | i = 0; |
| 218663 | + if( bRowid ){ |
| 218664 | + size_t nName = strlen(SESSIONS_ROWID); |
| 218665 | + memcpy(pAlloc, SESSIONS_ROWID, nName+1); |
| 218666 | + azCol[i] = (char*)pAlloc; |
| 218667 | + pAlloc += nName+1; |
| 218668 | + abPK[i] = 1; |
| 218669 | + i++; |
| 218670 | + } |
| 217884 | 218671 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 217885 | 218672 | int nName = sqlite3_column_bytes(pStmt, 1); |
| 217886 | 218673 | const unsigned char *zName = sqlite3_column_text(pStmt, 1); |
| 217887 | 218674 | if( zName==0 ) break; |
| 217888 | 218675 | memcpy(pAlloc, zName, nName+1); |
| | @@ -217890,11 +218677,10 @@ |
| 217890 | 218677 | pAlloc += nName+1; |
| 217891 | 218678 | abPK[i] = sqlite3_column_int(pStmt, 5); |
| 217892 | 218679 | i++; |
| 217893 | 218680 | } |
| 217894 | 218681 | rc = sqlite3_reset(pStmt); |
| 217895 | | - |
| 217896 | 218682 | } |
| 217897 | 218683 | |
| 217898 | 218684 | /* If successful, populate the output variables. Otherwise, zero them and |
| 217899 | 218685 | ** free any allocation made. An error code will be returned in this case. |
| 217900 | 218686 | */ |
| | @@ -217907,10 +218693,11 @@ |
| 217907 | 218693 | *pabPK = 0; |
| 217908 | 218694 | *pnCol = 0; |
| 217909 | 218695 | if( pzTab ) *pzTab = 0; |
| 217910 | 218696 | sessionFree(pSession, azCol); |
| 217911 | 218697 | } |
| 218698 | + if( pbRowid ) *pbRowid = bRowid; |
| 217912 | 218699 | sqlite3_finalize(pStmt); |
| 217913 | 218700 | return rc; |
| 217914 | 218701 | } |
| 217915 | 218702 | |
| 217916 | 218703 | /* |
| | @@ -217928,11 +218715,12 @@ |
| 217928 | 218715 | static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ |
| 217929 | 218716 | if( pTab->nCol==0 ){ |
| 217930 | 218717 | u8 *abPK; |
| 217931 | 218718 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 217932 | 218719 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, |
| 217933 | | - pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK |
| 218720 | + pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, |
| 218721 | + (pSession->bImplicitPK ? &pTab->bRowid : 0) |
| 217934 | 218722 | ); |
| 217935 | 218723 | if( pSession->rc==SQLITE_OK ){ |
| 217936 | 218724 | int i; |
| 217937 | 218725 | for(i=0; i<pTab->nCol; i++){ |
| 217938 | 218726 | if( abPK[i] ){ |
| | @@ -218000,10 +218788,11 @@ |
| 218000 | 218788 | SessionTable *pTab, /* Table that change applies to */ |
| 218001 | 218789 | SessionChange *pC /* Update pC->nMaxSize */ |
| 218002 | 218790 | ){ |
| 218003 | 218791 | i64 nNew = 2; |
| 218004 | 218792 | if( pC->op==SQLITE_INSERT ){ |
| 218793 | + if( pTab->bRowid ) nNew += 9; |
| 218005 | 218794 | if( op!=SQLITE_DELETE ){ |
| 218006 | 218795 | int ii; |
| 218007 | 218796 | for(ii=0; ii<pTab->nCol; ii++){ |
| 218008 | 218797 | sqlite3_value *p = 0; |
| 218009 | 218798 | pSession->hook.xNew(pSession->hook.pCtx, ii, &p); |
| | @@ -218016,11 +218805,15 @@ |
| 218016 | 218805 | nNew += pC->nRecord; |
| 218017 | 218806 | } |
| 218018 | 218807 | }else{ |
| 218019 | 218808 | int ii; |
| 218020 | 218809 | u8 *pCsr = pC->aRecord; |
| 218021 | | - for(ii=0; ii<pTab->nCol; ii++){ |
| 218810 | + if( pTab->bRowid ){ |
| 218811 | + nNew += 9; |
| 218812 | + pCsr += 9; |
| 218813 | + } |
| 218814 | + for(ii=0; ii<(pTab->nCol-pTab->bRowid); ii++){ |
| 218022 | 218815 | int bChanged = 1; |
| 218023 | 218816 | int nOld = 0; |
| 218024 | 218817 | int eType; |
| 218025 | 218818 | sqlite3_value *p = 0; |
| 218026 | 218819 | pSession->hook.xNew(pSession->hook.pCtx, ii, &p); |
| | @@ -218100,10 +218893,11 @@ |
| 218100 | 218893 | ** Unless one is already present or an error occurs, an entry is added |
| 218101 | 218894 | ** to the changed-rows hash table associated with table pTab. |
| 218102 | 218895 | */ |
| 218103 | 218896 | static void sessionPreupdateOneChange( |
| 218104 | 218897 | int op, /* One of SQLITE_UPDATE, INSERT, DELETE */ |
| 218898 | + i64 iRowid, |
| 218105 | 218899 | sqlite3_session *pSession, /* Session object pTab is attached to */ |
| 218106 | 218900 | SessionTable *pTab /* Table that change applies to */ |
| 218107 | 218901 | ){ |
| 218108 | 218902 | int iHash; |
| 218109 | 218903 | int bNull = 0; |
| | @@ -218115,11 +218909,11 @@ |
| 218115 | 218909 | /* Load table details if required */ |
| 218116 | 218910 | if( sessionInitTable(pSession, pTab) ) return; |
| 218117 | 218911 | |
| 218118 | 218912 | /* Check the number of columns in this xPreUpdate call matches the |
| 218119 | 218913 | ** number of columns in the table. */ |
| 218120 | | - if( pTab->nCol!=pSession->hook.xCount(pSession->hook.pCtx) ){ |
| 218914 | + if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ |
| 218121 | 218915 | pSession->rc = SQLITE_SCHEMA; |
| 218122 | 218916 | return; |
| 218123 | 218917 | } |
| 218124 | 218918 | |
| 218125 | 218919 | /* Grow the hash table if required */ |
| | @@ -218148,18 +218942,20 @@ |
| 218148 | 218942 | } |
| 218149 | 218943 | |
| 218150 | 218944 | /* Calculate the hash-key for this change. If the primary key of the row |
| 218151 | 218945 | ** includes a NULL value, exit early. Such changes are ignored by the |
| 218152 | 218946 | ** session module. */ |
| 218153 | | - rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull); |
| 218947 | + rc = sessionPreupdateHash( |
| 218948 | + pSession, iRowid, pTab, op==SQLITE_INSERT, &iHash, &bNull |
| 218949 | + ); |
| 218154 | 218950 | if( rc!=SQLITE_OK ) goto error_out; |
| 218155 | 218951 | |
| 218156 | 218952 | if( bNull==0 ){ |
| 218157 | 218953 | /* Search the hash table for an existing record for this row. */ |
| 218158 | 218954 | SessionChange *pC; |
| 218159 | 218955 | for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){ |
| 218160 | | - if( sessionPreupdateEqual(pSession, pTab, pC, op) ) break; |
| 218956 | + if( sessionPreupdateEqual(pSession, iRowid, pTab, pC, op) ) break; |
| 218161 | 218957 | } |
| 218162 | 218958 | |
| 218163 | 218959 | if( pC==0 ){ |
| 218164 | 218960 | /* Create a new change object containing all the old values (if |
| 218165 | 218961 | ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK |
| | @@ -218170,11 +218966,11 @@ |
| 218170 | 218966 | assert( rc==SQLITE_OK ); |
| 218171 | 218967 | pTab->nEntry++; |
| 218172 | 218968 | |
| 218173 | 218969 | /* Figure out how large an allocation is required */ |
| 218174 | 218970 | nByte = sizeof(SessionChange); |
| 218175 | | - for(i=0; i<pTab->nCol; i++){ |
| 218971 | + for(i=0; i<(pTab->nCol-pTab->bRowid); i++){ |
| 218176 | 218972 | sqlite3_value *p = 0; |
| 218177 | 218973 | if( op!=SQLITE_INSERT ){ |
| 218178 | 218974 | TESTONLY(int trc = ) pSession->hook.xOld(pSession->hook.pCtx, i, &p); |
| 218179 | 218975 | assert( trc==SQLITE_OK ); |
| 218180 | 218976 | }else if( pTab->abPK[i] ){ |
| | @@ -218185,10 +218981,13 @@ |
| 218185 | 218981 | /* This may fail if SQLite value p contains a utf-16 string that must |
| 218186 | 218982 | ** be converted to utf-8 and an OOM error occurs while doing so. */ |
| 218187 | 218983 | rc = sessionSerializeValue(0, p, &nByte); |
| 218188 | 218984 | if( rc!=SQLITE_OK ) goto error_out; |
| 218189 | 218985 | } |
| 218986 | + if( pTab->bRowid ){ |
| 218987 | + nByte += 9; /* Size of rowid field - an integer */ |
| 218988 | + } |
| 218190 | 218989 | |
| 218191 | 218990 | /* Allocate the change object */ |
| 218192 | 218991 | pC = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 218193 | 218992 | if( !pC ){ |
| 218194 | 218993 | rc = SQLITE_NOMEM; |
| | @@ -218201,11 +219000,16 @@ |
| 218201 | 219000 | /* Populate the change object. None of the preupdate_old(), |
| 218202 | 219001 | ** preupdate_new() or SerializeValue() calls below may fail as all |
| 218203 | 219002 | ** required values and encodings have already been cached in memory. |
| 218204 | 219003 | ** It is not possible for an OOM to occur in this block. */ |
| 218205 | 219004 | nByte = 0; |
| 218206 | | - for(i=0; i<pTab->nCol; i++){ |
| 219005 | + if( pTab->bRowid ){ |
| 219006 | + pC->aRecord[0] = SQLITE_INTEGER; |
| 219007 | + sessionPutI64(&pC->aRecord[1], iRowid); |
| 219008 | + nByte = 9; |
| 219009 | + } |
| 219010 | + for(i=0; i<(pTab->nCol-pTab->bRowid); i++){ |
| 218207 | 219011 | sqlite3_value *p = 0; |
| 218208 | 219012 | if( op!=SQLITE_INSERT ){ |
| 218209 | 219013 | pSession->hook.xOld(pSession->hook.pCtx, i, &p); |
| 218210 | 219014 | }else if( pTab->abPK[i] ){ |
| 218211 | 219015 | pSession->hook.xNew(pSession->hook.pCtx, i, &p); |
| | @@ -218316,13 +219120,14 @@ |
| 218316 | 219120 | if( sqlite3_strnicmp(zDb, pSession->zDb, nDb+1) ) continue; |
| 218317 | 219121 | |
| 218318 | 219122 | pSession->rc = sessionFindTable(pSession, zName, &pTab); |
| 218319 | 219123 | if( pTab ){ |
| 218320 | 219124 | assert( pSession->rc==SQLITE_OK ); |
| 218321 | | - sessionPreupdateOneChange(op, pSession, pTab); |
| 219125 | + assert( op==SQLITE_UPDATE || iKey1==iKey2 ); |
| 219126 | + sessionPreupdateOneChange(op, iKey1, pSession, pTab); |
| 218322 | 219127 | if( op==SQLITE_UPDATE ){ |
| 218323 | | - sessionPreupdateOneChange(SQLITE_INSERT, pSession, pTab); |
| 219128 | + sessionPreupdateOneChange(SQLITE_INSERT, iKey2, pSession, pTab); |
| 218324 | 219129 | } |
| 218325 | 219130 | } |
| 218326 | 219131 | } |
| 218327 | 219132 | } |
| 218328 | 219133 | |
| | @@ -218357,29 +219162,30 @@ |
| 218357 | 219162 | } |
| 218358 | 219163 | |
| 218359 | 219164 | typedef struct SessionDiffCtx SessionDiffCtx; |
| 218360 | 219165 | struct SessionDiffCtx { |
| 218361 | 219166 | sqlite3_stmt *pStmt; |
| 219167 | + int bRowid; |
| 218362 | 219168 | int nOldOff; |
| 218363 | 219169 | }; |
| 218364 | 219170 | |
| 218365 | 219171 | /* |
| 218366 | 219172 | ** The diff hook implementations. |
| 218367 | 219173 | */ |
| 218368 | 219174 | static int sessionDiffOld(void *pCtx, int iVal, sqlite3_value **ppVal){ |
| 218369 | 219175 | SessionDiffCtx *p = (SessionDiffCtx*)pCtx; |
| 218370 | | - *ppVal = sqlite3_column_value(p->pStmt, iVal+p->nOldOff); |
| 219176 | + *ppVal = sqlite3_column_value(p->pStmt, iVal+p->nOldOff+p->bRowid); |
| 218371 | 219177 | return SQLITE_OK; |
| 218372 | 219178 | } |
| 218373 | 219179 | static int sessionDiffNew(void *pCtx, int iVal, sqlite3_value **ppVal){ |
| 218374 | 219180 | SessionDiffCtx *p = (SessionDiffCtx*)pCtx; |
| 218375 | | - *ppVal = sqlite3_column_value(p->pStmt, iVal); |
| 219181 | + *ppVal = sqlite3_column_value(p->pStmt, iVal+p->bRowid); |
| 218376 | 219182 | return SQLITE_OK; |
| 218377 | 219183 | } |
| 218378 | 219184 | static int sessionDiffCount(void *pCtx){ |
| 218379 | 219185 | SessionDiffCtx *p = (SessionDiffCtx*)pCtx; |
| 218380 | | - return p->nOldOff ? p->nOldOff : sqlite3_column_count(p->pStmt); |
| 219186 | + return (p->nOldOff ? p->nOldOff : sqlite3_column_count(p->pStmt)) - p->bRowid; |
| 218381 | 219187 | } |
| 218382 | 219188 | static int sessionDiffDepth(void *pCtx){ |
| 218383 | 219189 | (void)pCtx; |
| 218384 | 219190 | return 0; |
| 218385 | 219191 | } |
| | @@ -218454,18 +219260,20 @@ |
| 218454 | 219260 | } |
| 218455 | 219261 | |
| 218456 | 219262 | static char *sessionSelectFindNew( |
| 218457 | 219263 | const char *zDb1, /* Pick rows in this db only */ |
| 218458 | 219264 | const char *zDb2, /* But not in this one */ |
| 219265 | + int bRowid, |
| 218459 | 219266 | const char *zTbl, /* Table name */ |
| 218460 | 219267 | const char *zExpr |
| 218461 | 219268 | ){ |
| 219269 | + const char *zSel = (bRowid ? SESSIONS_ROWID ", *" : "*"); |
| 218462 | 219270 | char *zRet = sqlite3_mprintf( |
| 218463 | | - "SELECT * FROM \"%w\".\"%w\" WHERE NOT EXISTS (" |
| 219271 | + "SELECT %s FROM \"%w\".\"%w\" WHERE NOT EXISTS (" |
| 218464 | 219272 | " SELECT 1 FROM \"%w\".\"%w\" WHERE %s" |
| 218465 | 219273 | ")", |
| 218466 | | - zDb1, zTbl, zDb2, zTbl, zExpr |
| 219274 | + zSel, zDb1, zTbl, zDb2, zTbl, zExpr |
| 218467 | 219275 | ); |
| 218468 | 219276 | return zRet; |
| 218469 | 219277 | } |
| 218470 | 219278 | |
| 218471 | 219279 | static int sessionDiffFindNew( |
| | @@ -218475,11 +219283,13 @@ |
| 218475 | 219283 | const char *zDb1, |
| 218476 | 219284 | const char *zDb2, |
| 218477 | 219285 | char *zExpr |
| 218478 | 219286 | ){ |
| 218479 | 219287 | int rc = SQLITE_OK; |
| 218480 | | - char *zStmt = sessionSelectFindNew(zDb1, zDb2, pTab->zName,zExpr); |
| 219288 | + char *zStmt = sessionSelectFindNew( |
| 219289 | + zDb1, zDb2, pTab->bRowid, pTab->zName, zExpr |
| 219290 | + ); |
| 218481 | 219291 | |
| 218482 | 219292 | if( zStmt==0 ){ |
| 218483 | 219293 | rc = SQLITE_NOMEM; |
| 218484 | 219294 | }else{ |
| 218485 | 219295 | sqlite3_stmt *pStmt; |
| | @@ -218486,20 +219296,43 @@ |
| 218486 | 219296 | rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0); |
| 218487 | 219297 | if( rc==SQLITE_OK ){ |
| 218488 | 219298 | SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx; |
| 218489 | 219299 | pDiffCtx->pStmt = pStmt; |
| 218490 | 219300 | pDiffCtx->nOldOff = 0; |
| 219301 | + pDiffCtx->bRowid = pTab->bRowid; |
| 218491 | 219302 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 218492 | | - sessionPreupdateOneChange(op, pSession, pTab); |
| 219303 | + i64 iRowid = (pTab->bRowid ? sqlite3_column_int64(pStmt, 0) : 0); |
| 219304 | + sessionPreupdateOneChange(op, iRowid, pSession, pTab); |
| 218493 | 219305 | } |
| 218494 | 219306 | rc = sqlite3_finalize(pStmt); |
| 218495 | 219307 | } |
| 218496 | 219308 | sqlite3_free(zStmt); |
| 218497 | 219309 | } |
| 218498 | 219310 | |
| 218499 | 219311 | return rc; |
| 218500 | 219312 | } |
| 219313 | + |
| 219314 | +/* |
| 219315 | +** Return a comma-separated list of the fully-qualified (with both database |
| 219316 | +** and table name) column names from table pTab. e.g. |
| 219317 | +** |
| 219318 | +** "main"."t1"."a", "main"."t1"."b", "main"."t1"."c" |
| 219319 | +*/ |
| 219320 | +static char *sessionAllCols( |
| 219321 | + const char *zDb, |
| 219322 | + SessionTable *pTab |
| 219323 | +){ |
| 219324 | + int ii; |
| 219325 | + char *zRet = 0; |
| 219326 | + for(ii=0; ii<pTab->nCol; ii++){ |
| 219327 | + zRet = sqlite3_mprintf("%z%s\"%w\".\"%w\".\"%w\"", |
| 219328 | + zRet, (zRet ? ", " : ""), zDb, pTab->zName, pTab->azCol[ii] |
| 219329 | + ); |
| 219330 | + if( !zRet ) break; |
| 219331 | + } |
| 219332 | + return zRet; |
| 219333 | +} |
| 218501 | 219334 | |
| 218502 | 219335 | static int sessionDiffFindModified( |
| 218503 | 219336 | sqlite3_session *pSession, |
| 218504 | 219337 | SessionTable *pTab, |
| 218505 | 219338 | const char *zFrom, |
| | @@ -218511,15 +219344,17 @@ |
| 218511 | 219344 | pSession->zDb, zFrom, pTab->zName, pTab->azCol, pTab->abPK |
| 218512 | 219345 | ); |
| 218513 | 219346 | if( zExpr2==0 ){ |
| 218514 | 219347 | rc = SQLITE_NOMEM; |
| 218515 | 219348 | }else{ |
| 219349 | + char *z1 = sessionAllCols(pSession->zDb, pTab); |
| 219350 | + char *z2 = sessionAllCols(zFrom, pTab); |
| 218516 | 219351 | char *zStmt = sqlite3_mprintf( |
| 218517 | | - "SELECT * FROM \"%w\".\"%w\", \"%w\".\"%w\" WHERE %s AND (%z)", |
| 218518 | | - pSession->zDb, pTab->zName, zFrom, pTab->zName, zExpr, zExpr2 |
| 219352 | + "SELECT %s,%s FROM \"%w\".\"%w\", \"%w\".\"%w\" WHERE %s AND (%z)", |
| 219353 | + z1, z2, pSession->zDb, pTab->zName, zFrom, pTab->zName, zExpr, zExpr2 |
| 218519 | 219354 | ); |
| 218520 | | - if( zStmt==0 ){ |
| 219355 | + if( zStmt==0 || z1==0 || z2==0 ){ |
| 218521 | 219356 | rc = SQLITE_NOMEM; |
| 218522 | 219357 | }else{ |
| 218523 | 219358 | sqlite3_stmt *pStmt; |
| 218524 | 219359 | rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0); |
| 218525 | 219360 | |
| | @@ -218526,16 +219361,19 @@ |
| 218526 | 219361 | if( rc==SQLITE_OK ){ |
| 218527 | 219362 | SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx; |
| 218528 | 219363 | pDiffCtx->pStmt = pStmt; |
| 218529 | 219364 | pDiffCtx->nOldOff = pTab->nCol; |
| 218530 | 219365 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 218531 | | - sessionPreupdateOneChange(SQLITE_UPDATE, pSession, pTab); |
| 219366 | + i64 iRowid = (pTab->bRowid ? sqlite3_column_int64(pStmt, 0) : 0); |
| 219367 | + sessionPreupdateOneChange(SQLITE_UPDATE, iRowid, pSession, pTab); |
| 218532 | 219368 | } |
| 218533 | 219369 | rc = sqlite3_finalize(pStmt); |
| 218534 | 219370 | } |
| 218535 | | - sqlite3_free(zStmt); |
| 218536 | 219371 | } |
| 219372 | + sqlite3_free(zStmt); |
| 219373 | + sqlite3_free(z1); |
| 219374 | + sqlite3_free(z2); |
| 218537 | 219375 | } |
| 218538 | 219376 | |
| 218539 | 219377 | return rc; |
| 218540 | 219378 | } |
| 218541 | 219379 | |
| | @@ -218570,13 +219408,16 @@ |
| 218570 | 219408 | /* Check the table schemas match */ |
| 218571 | 219409 | if( rc==SQLITE_OK ){ |
| 218572 | 219410 | int bHasPk = 0; |
| 218573 | 219411 | int bMismatch = 0; |
| 218574 | 219412 | int nCol; /* Columns in zFrom.zTbl */ |
| 219413 | + int bRowid = 0; |
| 218575 | 219414 | u8 *abPK; |
| 218576 | 219415 | const char **azCol = 0; |
| 218577 | | - rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK); |
| 219416 | + rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, |
| 219417 | + pSession->bImplicitPK ? &bRowid : 0 |
| 219418 | + ); |
| 218578 | 219419 | if( rc==SQLITE_OK ){ |
| 218579 | 219420 | if( pTo->nCol!=nCol ){ |
| 218580 | 219421 | bMismatch = 1; |
| 218581 | 219422 | }else{ |
| 218582 | 219423 | int i; |
| | @@ -219223,19 +220064,20 @@ |
| 219223 | 220064 | static int sessionSelectStmt( |
| 219224 | 220065 | sqlite3 *db, /* Database handle */ |
| 219225 | 220066 | int bIgnoreNoop, |
| 219226 | 220067 | const char *zDb, /* Database name */ |
| 219227 | 220068 | const char *zTab, /* Table name */ |
| 220069 | + int bRowid, |
| 219228 | 220070 | int nCol, /* Number of columns in table */ |
| 219229 | 220071 | const char **azCol, /* Names of table columns */ |
| 219230 | 220072 | u8 *abPK, /* PRIMARY KEY array */ |
| 219231 | 220073 | sqlite3_stmt **ppStmt /* OUT: Prepared SELECT statement */ |
| 219232 | 220074 | ){ |
| 219233 | 220075 | int rc = SQLITE_OK; |
| 219234 | 220076 | char *zSql = 0; |
| 219235 | 220077 | const char *zSep = ""; |
| 219236 | | - const char *zCols = "*"; |
| 220078 | + const char *zCols = bRowid ? SESSIONS_ROWID ", *" : "*"; |
| 219237 | 220079 | int nSql = -1; |
| 219238 | 220080 | int i; |
| 219239 | 220081 | |
| 219240 | 220082 | SessionBuffer nooptest = {0, 0, 0}; |
| 219241 | 220083 | SessionBuffer pkfield = {0, 0, 0}; |
| | @@ -219250,11 +220092,10 @@ |
| 219250 | 220092 | "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc |
| 219251 | 220093 | ); |
| 219252 | 220094 | zCols = "tbl, ?2, stat"; |
| 219253 | 220095 | }else{ |
| 219254 | 220096 | for(i=0; i<nCol; i++){ |
| 219255 | | - |
| 219256 | 220097 | if( abPK[i] ){ |
| 219257 | 220098 | sessionAppendStr(&pkfield, zSep, &rc); |
| 219258 | 220099 | sessionAppendStr(&pkvar, zSep, &rc); |
| 219259 | 220100 | zSep = ", "; |
| 219260 | 220101 | sessionAppendIdent(&pkfield, azCol[i], &rc); |
| | @@ -219457,24 +220298,32 @@ |
| 219457 | 220298 | const char **azCol = 0; /* Table columns */ |
| 219458 | 220299 | int i; /* Used to iterate through hash buckets */ |
| 219459 | 220300 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| 219460 | 220301 | int nRewind = buf.nBuf; /* Initial size of write buffer */ |
| 219461 | 220302 | int nNoop; /* Size of buffer after writing tbl header */ |
| 220303 | + int bRowid = 0; |
| 219462 | 220304 | |
| 219463 | 220305 | /* Check the table schema is still Ok. */ |
| 219464 | | - rc = sessionTableInfo(0, db, pSession->zDb, zName, &nCol, 0,&azCol,&abPK); |
| 219465 | | - if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){ |
| 220306 | + rc = sessionTableInfo( |
| 220307 | + 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, |
| 220308 | + (pSession->bImplicitPK ? &bRowid : 0) |
| 220309 | + ); |
| 220310 | + if( rc==SQLITE_OK && ( |
| 220311 | + pTab->nCol!=nCol |
| 220312 | + || pTab->bRowid!=bRowid |
| 220313 | + || memcmp(abPK, pTab->abPK, nCol) |
| 220314 | + )){ |
| 219466 | 220315 | rc = SQLITE_SCHEMA; |
| 219467 | 220316 | } |
| 219468 | 220317 | |
| 219469 | 220318 | /* Write a table header */ |
| 219470 | 220319 | sessionAppendTableHdr(&buf, bPatchset, pTab, &rc); |
| 219471 | 220320 | |
| 219472 | 220321 | /* Build and compile a statement to execute: */ |
| 219473 | 220322 | if( rc==SQLITE_OK ){ |
| 219474 | 220323 | rc = sessionSelectStmt( |
| 219475 | | - db, 0, pSession->zDb, zName, nCol, azCol, abPK, &pSel |
| 220324 | + db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel |
| 219476 | 220325 | ); |
| 219477 | 220326 | } |
| 219478 | 220327 | |
| 219479 | 220328 | nNoop = buf.nBuf; |
| 219480 | 220329 | for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){ |
| | @@ -219554,12 +220403,12 @@ |
| 219554 | 220403 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 219555 | 220404 | ){ |
| 219556 | 220405 | int rc; |
| 219557 | 220406 | |
| 219558 | 220407 | if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE; |
| 219559 | | - rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset); |
| 219560 | | - assert( rc || pnChangeset==0 |
| 220408 | + rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset); |
| 220409 | + assert( 1 || rc || pnChangeset==0 |
| 219561 | 220410 | || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize |
| 219562 | 220411 | ); |
| 219563 | 220412 | return rc; |
| 219564 | 220413 | } |
| 219565 | 220414 | |
| | @@ -219671,10 +220520,23 @@ |
| 219671 | 220520 | } |
| 219672 | 220521 | } |
| 219673 | 220522 | *(int*)pArg = pSession->bEnableSize; |
| 219674 | 220523 | break; |
| 219675 | 220524 | } |
| 220525 | + |
| 220526 | + case SQLITE_SESSION_OBJCONFIG_ROWID: { |
| 220527 | + int iArg = *(int*)pArg; |
| 220528 | + if( iArg>=0 ){ |
| 220529 | + if( pSession->pTable ){ |
| 220530 | + rc = SQLITE_MISUSE; |
| 220531 | + }else{ |
| 220532 | + pSession->bImplicitPK = (iArg!=0); |
| 220533 | + } |
| 220534 | + } |
| 220535 | + *(int*)pArg = pSession->bImplicitPK; |
| 220536 | + break; |
| 220537 | + } |
| 219676 | 220538 | |
| 219677 | 220539 | default: |
| 219678 | 220540 | rc = SQLITE_MISUSE; |
| 219679 | 220541 | } |
| 219680 | 220542 | |
| | @@ -220661,10 +221523,11 @@ |
| 220661 | 221523 | SessionBuffer constraints; /* Deferred constraints are stored here */ |
| 220662 | 221524 | SessionBuffer rebase; /* Rebase information (if any) here */ |
| 220663 | 221525 | u8 bRebaseStarted; /* If table header is already in rebase */ |
| 220664 | 221526 | u8 bRebase; /* True to collect rebase information */ |
| 220665 | 221527 | u8 bIgnoreNoop; /* True to ignore no-op conflicts */ |
| 221528 | + int bRowid; |
| 220666 | 221529 | }; |
| 220667 | 221530 | |
| 220668 | 221531 | /* Number of prepared UPDATE statements to cache. */ |
| 220669 | 221532 | #define SESSION_UPDATE_CACHE_SZ 12 |
| 220670 | 221533 | |
| | @@ -220911,12 +221774,13 @@ |
| 220911 | 221774 | static int sessionSelectRow( |
| 220912 | 221775 | sqlite3 *db, /* Database handle */ |
| 220913 | 221776 | const char *zTab, /* Table name */ |
| 220914 | 221777 | SessionApplyCtx *p /* Session changeset-apply context */ |
| 220915 | 221778 | ){ |
| 221779 | + /* TODO */ |
| 220916 | 221780 | return sessionSelectStmt(db, p->bIgnoreNoop, |
| 220917 | | - "main", zTab, p->nCol, p->azCol, p->abPK, &p->pSelect |
| 221781 | + "main", zTab, p->bRowid, p->nCol, p->azCol, p->abPK, &p->pSelect |
| 220918 | 221782 | ); |
| 220919 | 221783 | } |
| 220920 | 221784 | |
| 220921 | 221785 | /* |
| 220922 | 221786 | ** Formulate and prepare an INSERT statement to add a record to table zTab. |
| | @@ -221608,10 +222472,11 @@ |
| 221608 | 222472 | sApply.azCol = 0; |
| 221609 | 222473 | sApply.abPK = 0; |
| 221610 | 222474 | sApply.bStat1 = 0; |
| 221611 | 222475 | sApply.bDeferConstraints = 1; |
| 221612 | 222476 | sApply.bRebaseStarted = 0; |
| 222477 | + sApply.bRowid = 0; |
| 221613 | 222478 | memset(&sApply.constraints, 0, sizeof(SessionBuffer)); |
| 221614 | 222479 | |
| 221615 | 222480 | /* If an xFilter() callback was specified, invoke it now. If the |
| 221616 | 222481 | ** xFilter callback returns zero, skip this table. If it returns |
| 221617 | 222482 | ** non-zero, proceed. */ |
| | @@ -221627,12 +222492,12 @@ |
| 221627 | 222492 | }else{ |
| 221628 | 222493 | int nMinCol = 0; |
| 221629 | 222494 | int i; |
| 221630 | 222495 | |
| 221631 | 222496 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 221632 | | - rc = sessionTableInfo(0, |
| 221633 | | - db, "main", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK |
| 222497 | + rc = sessionTableInfo(0, db, "main", zNew, |
| 222498 | + &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid |
| 221634 | 222499 | ); |
| 221635 | 222500 | if( rc!=SQLITE_OK ) break; |
| 221636 | 222501 | for(i=0; i<sApply.nCol; i++){ |
| 221637 | 222502 | if( sApply.abPK[i] ) nMinCol = i+1; |
| 221638 | 222503 | } |
| | @@ -223510,29 +224375,34 @@ |
| 223510 | 224375 | fts5_tokenizer *pTokApi; |
| 223511 | 224376 | int bLock; /* True when table is preparing statement */ |
| 223512 | 224377 | int ePattern; /* FTS_PATTERN_XXX constant */ |
| 223513 | 224378 | |
| 223514 | 224379 | /* Values loaded from the %_config table */ |
| 224380 | + int iVersion; /* fts5 file format 'version' */ |
| 223515 | 224381 | int iCookie; /* Incremented when %_config is modified */ |
| 223516 | 224382 | int pgsz; /* Approximate page size used in %_data */ |
| 223517 | 224383 | int nAutomerge; /* 'automerge' setting */ |
| 223518 | 224384 | int nCrisisMerge; /* Maximum allowed segments per level */ |
| 223519 | 224385 | int nUsermerge; /* 'usermerge' setting */ |
| 223520 | 224386 | int nHashSize; /* Bytes of memory for in-memory hash */ |
| 223521 | 224387 | char *zRank; /* Name of rank function */ |
| 223522 | 224388 | char *zRankArgs; /* Arguments to rank function */ |
| 224389 | + int bSecureDelete; /* 'secure-delete' */ |
| 223523 | 224390 | |
| 223524 | 224391 | /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */ |
| 223525 | 224392 | char **pzErrmsg; |
| 223526 | 224393 | |
| 223527 | 224394 | #ifdef SQLITE_DEBUG |
| 223528 | 224395 | int bPrefixIndex; /* True to use prefix-indexes */ |
| 223529 | 224396 | #endif |
| 223530 | 224397 | }; |
| 223531 | 224398 | |
| 223532 | | -/* Current expected value of %_config table 'version' field */ |
| 223533 | | -#define FTS5_CURRENT_VERSION 4 |
| 224399 | +/* Current expected value of %_config table 'version' field. And |
| 224400 | +** the expected version if the 'secure-delete' option has ever been |
| 224401 | +** set on the table. */ |
| 224402 | +#define FTS5_CURRENT_VERSION 4 |
| 224403 | +#define FTS5_CURRENT_VERSION_SECUREDELETE 5 |
| 223534 | 224404 | |
| 223535 | 224405 | #define FTS5_CONTENT_NORMAL 0 |
| 223536 | 224406 | #define FTS5_CONTENT_NONE 1 |
| 223537 | 224407 | #define FTS5_CONTENT_EXTERNAL 2 |
| 223538 | 224408 | |
| | @@ -223694,10 +224564,11 @@ |
| 223694 | 224564 | /* The following are used internally by the fts5_index.c module. They are |
| 223695 | 224565 | ** defined here only to make it easier to avoid clashes with the flags |
| 223696 | 224566 | ** above. */ |
| 223697 | 224567 | #define FTS5INDEX_QUERY_SKIPEMPTY 0x0010 |
| 223698 | 224568 | #define FTS5INDEX_QUERY_NOOUTPUT 0x0020 |
| 224569 | +#define FTS5INDEX_QUERY_SKIPHASH 0x0040 |
| 223699 | 224570 | |
| 223700 | 224571 | /* |
| 223701 | 224572 | ** Create/destroy an Fts5Index object. |
| 223702 | 224573 | */ |
| 223703 | 224574 | static int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**); |
| | @@ -227693,10 +228564,22 @@ |
| 227693 | 228564 | pConfig->zRankArgs = zRankArgs; |
| 227694 | 228565 | }else if( rc==SQLITE_ERROR ){ |
| 227695 | 228566 | rc = SQLITE_OK; |
| 227696 | 228567 | *pbBadkey = 1; |
| 227697 | 228568 | } |
| 228569 | + } |
| 228570 | + |
| 228571 | + else if( 0==sqlite3_stricmp(zKey, "secure-delete") ){ |
| 228572 | + int bVal = -1; |
| 228573 | + if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){ |
| 228574 | + bVal = sqlite3_value_int(pVal); |
| 228575 | + } |
| 228576 | + if( bVal<0 ){ |
| 228577 | + *pbBadkey = 1; |
| 228578 | + }else{ |
| 228579 | + pConfig->bSecureDelete = (bVal ? 1 : 0); |
| 228580 | + } |
| 227698 | 228581 | }else{ |
| 227699 | 228582 | *pbBadkey = 1; |
| 227700 | 228583 | } |
| 227701 | 228584 | return rc; |
| 227702 | 228585 | } |
| | @@ -227737,19 +228620,24 @@ |
| 227737 | 228620 | } |
| 227738 | 228621 | } |
| 227739 | 228622 | rc = sqlite3_finalize(p); |
| 227740 | 228623 | } |
| 227741 | 228624 | |
| 227742 | | - if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){ |
| 228625 | + if( rc==SQLITE_OK |
| 228626 | + && iVersion!=FTS5_CURRENT_VERSION |
| 228627 | + && iVersion!=FTS5_CURRENT_VERSION_SECUREDELETE |
| 228628 | + ){ |
| 227743 | 228629 | rc = SQLITE_ERROR; |
| 227744 | 228630 | if( pConfig->pzErrmsg ){ |
| 227745 | 228631 | assert( 0==*pConfig->pzErrmsg ); |
| 227746 | | - *pConfig->pzErrmsg = sqlite3_mprintf( |
| 227747 | | - "invalid fts5 file format (found %d, expected %d) - run 'rebuild'", |
| 227748 | | - iVersion, FTS5_CURRENT_VERSION |
| 228632 | + *pConfig->pzErrmsg = sqlite3_mprintf("invalid fts5 file format " |
| 228633 | + "(found %d, expected %d or %d) - run 'rebuild'", |
| 228634 | + iVersion, FTS5_CURRENT_VERSION, FTS5_CURRENT_VERSION_SECUREDELETE |
| 227749 | 228635 | ); |
| 227750 | 228636 | } |
| 228637 | + }else{ |
| 228638 | + pConfig->iVersion = iVersion; |
| 227751 | 228639 | } |
| 227752 | 228640 | |
| 227753 | 228641 | if( rc==SQLITE_OK ){ |
| 227754 | 228642 | pConfig->iCookie = iCookie; |
| 227755 | 228643 | } |
| | @@ -228163,11 +229051,11 @@ |
| 228163 | 229051 | |
| 228164 | 229052 | static int sqlite3Fts5ExprAnd(Fts5Expr **pp1, Fts5Expr *p2){ |
| 228165 | 229053 | Fts5Parse sParse; |
| 228166 | 229054 | memset(&sParse, 0, sizeof(sParse)); |
| 228167 | 229055 | |
| 228168 | | - if( *pp1 ){ |
| 229056 | + if( *pp1 && p2 ){ |
| 228169 | 229057 | Fts5Expr *p1 = *pp1; |
| 228170 | 229058 | int nPhrase = p1->nPhrase + p2->nPhrase; |
| 228171 | 229059 | |
| 228172 | 229060 | p1->pRoot = sqlite3Fts5ParseNode(&sParse, FTS5_AND, p1->pRoot, p2->pRoot,0); |
| 228173 | 229061 | p2->pRoot = 0; |
| | @@ -228188,11 +229076,11 @@ |
| 228188 | 229076 | p1->apExprPhrase = ap; |
| 228189 | 229077 | } |
| 228190 | 229078 | } |
| 228191 | 229079 | sqlite3_free(p2->apExprPhrase); |
| 228192 | 229080 | sqlite3_free(p2); |
| 228193 | | - }else{ |
| 229081 | + }else if( p2 ){ |
| 228194 | 229082 | *pp1 = p2; |
| 228195 | 229083 | } |
| 228196 | 229084 | |
| 228197 | 229085 | return sParse.rc; |
| 228198 | 229086 | } |
| | @@ -231705,10 +232593,12 @@ |
| 231705 | 232593 | sqlite3_stmt *pIdxWriter; /* "INSERT ... %_idx VALUES(?,?,?,?)" */ |
| 231706 | 232594 | sqlite3_stmt *pIdxDeleter; /* "DELETE FROM %_idx WHERE segid=?" */ |
| 231707 | 232595 | sqlite3_stmt *pIdxSelect; |
| 231708 | 232596 | int nRead; /* Total number of blocks read */ |
| 231709 | 232597 | |
| 232598 | + sqlite3_stmt *pDeleteFromIdx; |
| 232599 | + |
| 231710 | 232600 | sqlite3_stmt *pDataVersion; |
| 231711 | 232601 | i64 iStructVersion; /* data_version when pStruct read */ |
| 231712 | 232602 | Fts5Structure *pStruct; /* Current db structure (or NULL) */ |
| 231713 | 232603 | }; |
| 231714 | 232604 | |
| | @@ -231797,13 +232687,10 @@ |
| 231797 | 232687 | ** Current leaf page number within segment. |
| 231798 | 232688 | ** |
| 231799 | 232689 | ** iLeafOffset: |
| 231800 | 232690 | ** Byte offset within the current leaf that is the first byte of the |
| 231801 | 232691 | ** position list data (one byte passed the position-list size field). |
| 231802 | | -** rowid field of the current entry. Usually this is the size field of the |
| 231803 | | -** position list data. The exception is if the rowid for the current entry |
| 231804 | | -** is the last thing on the leaf page. |
| 231805 | 232692 | ** |
| 231806 | 232693 | ** pLeaf: |
| 231807 | 232694 | ** Buffer containing current leaf page data. Set to NULL at EOF. |
| 231808 | 232695 | ** |
| 231809 | 232696 | ** iTermLeafPgno, iTermLeafOffset: |
| | @@ -232388,10 +233275,11 @@ |
| 232388 | 233275 | ** Add a level to the Fts5Structure.aLevel[] array of structure object |
| 232389 | 233276 | ** (*ppStruct). |
| 232390 | 233277 | */ |
| 232391 | 233278 | static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){ |
| 232392 | 233279 | fts5StructureMakeWritable(pRc, ppStruct); |
| 233280 | + assert( (ppStruct!=0 && (*ppStruct)!=0) || (*pRc)!=SQLITE_OK ); |
| 232393 | 233281 | if( *pRc==SQLITE_OK ){ |
| 232394 | 233282 | Fts5Structure *pStruct = *ppStruct; |
| 232395 | 233283 | int nLevel = pStruct->nLevel; |
| 232396 | 233284 | sqlite3_int64 nByte = ( |
| 232397 | 233285 | sizeof(Fts5Structure) + /* Main structure */ |
| | @@ -232846,46 +233734,29 @@ |
| 232846 | 233734 | assert( pLvl->bEof==0 ); |
| 232847 | 233735 | if( iOff<=pLvl->iFirstOff ){ |
| 232848 | 233736 | pLvl->bEof = 1; |
| 232849 | 233737 | }else{ |
| 232850 | 233738 | u8 *a = pLvl->pData->p; |
| 232851 | | - i64 iVal; |
| 232852 | | - int iLimit; |
| 232853 | | - int ii; |
| 232854 | | - int nZero = 0; |
| 232855 | | - |
| 232856 | | - /* Currently iOff points to the first byte of a varint. This block |
| 232857 | | - ** decrements iOff until it points to the first byte of the previous |
| 232858 | | - ** varint. Taking care not to read any memory locations that occur |
| 232859 | | - ** before the buffer in memory. */ |
| 232860 | | - iLimit = (iOff>9 ? iOff-9 : 0); |
| 232861 | | - for(iOff--; iOff>iLimit; iOff--){ |
| 232862 | | - if( (a[iOff-1] & 0x80)==0 ) break; |
| 232863 | | - } |
| 232864 | | - |
| 232865 | | - fts5GetVarint(&a[iOff], (u64*)&iVal); |
| 232866 | | - pLvl->iRowid -= iVal; |
| 232867 | | - pLvl->iLeafPgno--; |
| 232868 | | - |
| 232869 | | - /* Skip backwards past any 0x00 varints. */ |
| 232870 | | - for(ii=iOff-1; ii>=pLvl->iFirstOff && a[ii]==0x00; ii--){ |
| 232871 | | - nZero++; |
| 232872 | | - } |
| 232873 | | - if( ii>=pLvl->iFirstOff && (a[ii] & 0x80) ){ |
| 232874 | | - /* The byte immediately before the last 0x00 byte has the 0x80 bit |
| 232875 | | - ** set. So the last 0x00 is only a varint 0 if there are 8 more 0x80 |
| 232876 | | - ** bytes before a[ii]. */ |
| 232877 | | - int bZero = 0; /* True if last 0x00 counts */ |
| 232878 | | - if( (ii-8)>=pLvl->iFirstOff ){ |
| 232879 | | - int j; |
| 232880 | | - for(j=1; j<=8 && (a[ii-j] & 0x80); j++); |
| 232881 | | - bZero = (j>8); |
| 232882 | | - } |
| 232883 | | - if( bZero==0 ) nZero--; |
| 232884 | | - } |
| 232885 | | - pLvl->iLeafPgno -= nZero; |
| 232886 | | - pLvl->iOff = iOff - nZero; |
| 233739 | + |
| 233740 | + pLvl->iOff = 0; |
| 233741 | + fts5DlidxLvlNext(pLvl); |
| 233742 | + while( 1 ){ |
| 233743 | + int nZero = 0; |
| 233744 | + int ii = pLvl->iOff; |
| 233745 | + u64 delta = 0; |
| 233746 | + |
| 233747 | + while( a[ii]==0 ){ |
| 233748 | + nZero++; |
| 233749 | + ii++; |
| 233750 | + } |
| 233751 | + ii += sqlite3Fts5GetVarint(&a[ii], &delta); |
| 233752 | + |
| 233753 | + if( ii>=iOff ) break; |
| 233754 | + pLvl->iLeafPgno += nZero+1; |
| 233755 | + pLvl->iRowid += delta; |
| 233756 | + pLvl->iOff = ii; |
| 233757 | + } |
| 232887 | 233758 | } |
| 232888 | 233759 | |
| 232889 | 233760 | return pLvl->bEof; |
| 232890 | 233761 | } |
| 232891 | 233762 | |
| | @@ -233077,11 +233948,11 @@ |
| 233077 | 233948 | static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){ |
| 233078 | 233949 | u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ |
| 233079 | 233950 | i64 iOff = pIter->iLeafOffset; |
| 233080 | 233951 | |
| 233081 | 233952 | ASSERT_SZLEAF_OK(pIter->pLeaf); |
| 233082 | | - if( iOff>=pIter->pLeaf->szLeaf ){ |
| 233953 | + while( iOff>=pIter->pLeaf->szLeaf ){ |
| 233083 | 233954 | fts5SegIterNextPage(p, pIter); |
| 233084 | 233955 | if( pIter->pLeaf==0 ){ |
| 233085 | 233956 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; |
| 233086 | 233957 | return; |
| 233087 | 233958 | } |
| | @@ -233176,14 +234047,16 @@ |
| 233176 | 234047 | if( p->rc==SQLITE_OK ){ |
| 233177 | 234048 | memset(pIter, 0, sizeof(*pIter)); |
| 233178 | 234049 | fts5SegIterSetNext(p, pIter); |
| 233179 | 234050 | pIter->pSeg = pSeg; |
| 233180 | 234051 | pIter->iLeafPgno = pSeg->pgnoFirst-1; |
| 233181 | | - fts5SegIterNextPage(p, pIter); |
| 234052 | + do { |
| 234053 | + fts5SegIterNextPage(p, pIter); |
| 234054 | + }while( p->rc==SQLITE_OK && pIter->pLeaf && pIter->pLeaf->nn==4 ); |
| 233182 | 234055 | } |
| 233183 | 234056 | |
| 233184 | | - if( p->rc==SQLITE_OK ){ |
| 234057 | + if( p->rc==SQLITE_OK && pIter->pLeaf ){ |
| 233185 | 234058 | pIter->iLeafOffset = 4; |
| 233186 | 234059 | assert( pIter->pLeaf!=0 ); |
| 233187 | 234060 | assert_nc( pIter->pLeaf->nn>4 ); |
| 233188 | 234061 | assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 ); |
| 233189 | 234062 | pIter->iPgidxOff = pIter->pLeaf->szLeaf+1; |
| | @@ -233373,11 +234246,11 @@ |
| 233373 | 234246 | |
| 233374 | 234247 | ASSERT_SZLEAF_OK(pIter->pLeaf); |
| 233375 | 234248 | iOff = pIter->iLeafOffset; |
| 233376 | 234249 | |
| 233377 | 234250 | /* Next entry is on the next page */ |
| 233378 | | - if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){ |
| 234251 | + while( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){ |
| 233379 | 234252 | fts5SegIterNextPage(p, pIter); |
| 233380 | 234253 | if( p->rc || pIter->pLeaf==0 ) return; |
| 233381 | 234254 | pIter->iRowid = 0; |
| 233382 | 234255 | iOff = 4; |
| 233383 | 234256 | } |
| | @@ -233566,11 +234439,11 @@ |
| 233566 | 234439 | static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ |
| 233567 | 234440 | Fts5DlidxIter *pDlidx = pIter->pDlidx; |
| 233568 | 234441 | Fts5Data *pLast = 0; |
| 233569 | 234442 | int pgnoLast = 0; |
| 233570 | 234443 | |
| 233571 | | - if( pDlidx ){ |
| 234444 | + if( pDlidx && p->pConfig->iVersion==FTS5_CURRENT_VERSION ){ |
| 233572 | 234445 | int iSegid = pIter->pSeg->iSegid; |
| 233573 | 234446 | pgnoLast = fts5DlidxIterPgno(pDlidx); |
| 233574 | 234447 | pLast = fts5LeafRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast)); |
| 233575 | 234448 | }else{ |
| 233576 | 234449 | Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */ |
| | @@ -234127,11 +235000,12 @@ |
| 234127 | 235000 | return 0; |
| 234128 | 235001 | } |
| 234129 | 235002 | |
| 234130 | 235003 | /* |
| 234131 | 235004 | ** Move the seg-iter so that it points to the first rowid on page iLeafPgno. |
| 234132 | | -** It is an error if leaf iLeafPgno does not exist or contains no rowids. |
| 235005 | +** It is an error if leaf iLeafPgno does not exist. Unless the db is |
| 235006 | +** a 'secure-delete' db, if it contains no rowids then this is also an error. |
| 234133 | 235007 | */ |
| 234134 | 235008 | static void fts5SegIterGotoPage( |
| 234135 | 235009 | Fts5Index *p, /* FTS5 backend object */ |
| 234136 | 235010 | Fts5SegIter *pIter, /* Iterator to advance */ |
| 234137 | 235011 | int iLeafPgno |
| | @@ -234142,25 +235016,27 @@ |
| 234142 | 235016 | p->rc = FTS5_CORRUPT; |
| 234143 | 235017 | }else{ |
| 234144 | 235018 | fts5DataRelease(pIter->pNextLeaf); |
| 234145 | 235019 | pIter->pNextLeaf = 0; |
| 234146 | 235020 | pIter->iLeafPgno = iLeafPgno-1; |
| 234147 | | - fts5SegIterNextPage(p, pIter); |
| 234148 | | - assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno ); |
| 234149 | 235021 | |
| 234150 | | - if( p->rc==SQLITE_OK && ALWAYS(pIter->pLeaf!=0) ){ |
| 235022 | + while( p->rc==SQLITE_OK ){ |
| 234151 | 235023 | int iOff; |
| 234152 | | - u8 *a = pIter->pLeaf->p; |
| 234153 | | - int n = pIter->pLeaf->szLeaf; |
| 234154 | | - |
| 235024 | + fts5SegIterNextPage(p, pIter); |
| 235025 | + if( pIter->pLeaf==0 ) break; |
| 234155 | 235026 | iOff = fts5LeafFirstRowidOff(pIter->pLeaf); |
| 234156 | | - if( iOff<4 || iOff>=n ){ |
| 234157 | | - p->rc = FTS5_CORRUPT; |
| 234158 | | - }else{ |
| 234159 | | - iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid); |
| 234160 | | - pIter->iLeafOffset = iOff; |
| 234161 | | - fts5SegIterLoadNPos(p, pIter); |
| 235027 | + if( iOff>0 ){ |
| 235028 | + u8 *a = pIter->pLeaf->p; |
| 235029 | + int n = pIter->pLeaf->szLeaf; |
| 235030 | + if( iOff<4 || iOff>=n ){ |
| 235031 | + p->rc = FTS5_CORRUPT; |
| 235032 | + }else{ |
| 235033 | + iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid); |
| 235034 | + pIter->iLeafOffset = iOff; |
| 235035 | + fts5SegIterLoadNPos(p, pIter); |
| 235036 | + } |
| 235037 | + break; |
| 234162 | 235038 | } |
| 234163 | 235039 | } |
| 234164 | 235040 | } |
| 234165 | 235041 | } |
| 234166 | 235042 | |
| | @@ -234871,11 +235747,11 @@ |
| 234871 | 235747 | /* Allocate space for the new multi-seg-iterator. */ |
| 234872 | 235748 | if( p->rc==SQLITE_OK ){ |
| 234873 | 235749 | if( iLevel<0 ){ |
| 234874 | 235750 | assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) ); |
| 234875 | 235751 | nSeg = pStruct->nSegment; |
| 234876 | | - nSeg += (p->pHash ? 1 : 0); |
| 235752 | + nSeg += (p->pHash && 0==(flags & FTS5INDEX_QUERY_SKIPHASH)); |
| 234877 | 235753 | }else{ |
| 234878 | 235754 | nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment); |
| 234879 | 235755 | } |
| 234880 | 235756 | } |
| 234881 | 235757 | *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); |
| | @@ -234892,11 +235768,11 @@ |
| 234892 | 235768 | |
| 234893 | 235769 | /* Initialize each of the component segment iterators. */ |
| 234894 | 235770 | if( p->rc==SQLITE_OK ){ |
| 234895 | 235771 | if( iLevel<0 ){ |
| 234896 | 235772 | Fts5StructureLevel *pEnd = &pStruct->aLevel[pStruct->nLevel]; |
| 234897 | | - if( p->pHash ){ |
| 235773 | + if( p->pHash && 0==(flags & FTS5INDEX_QUERY_SKIPHASH) ){ |
| 234898 | 235774 | /* Add a segment iterator for the current contents of the hash table. */ |
| 234899 | 235775 | Fts5SegIter *pIter = &pNew->aSeg[iIter++]; |
| 234900 | 235776 | fts5SegIterHashInit(p, pTerm, nTerm, flags, pIter); |
| 234901 | 235777 | } |
| 234902 | 235778 | for(pLvl=&pStruct->aLevel[0]; pLvl<pEnd; pLvl++){ |
| | @@ -235647,11 +236523,11 @@ |
| 235647 | 236523 | fts5BufferZero(&buf); |
| 235648 | 236524 | fts5BufferGrow(&p->rc, &buf, pData->nn); |
| 235649 | 236525 | fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr); |
| 235650 | 236526 | fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n); |
| 235651 | 236527 | fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p); |
| 235652 | | - fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]); |
| 236528 | + fts5BufferAppendBlob(&p->rc, &buf,pData->szLeaf-iOff,&pData->p[iOff]); |
| 235653 | 236529 | if( p->rc==SQLITE_OK ){ |
| 235654 | 236530 | /* Set the szLeaf field */ |
| 235655 | 236531 | fts5PutU16(&buf.p[2], (u16)buf.n); |
| 235656 | 236532 | } |
| 235657 | 236533 | |
| | @@ -235925,20 +236801,20 @@ |
| 235925 | 236801 | Fts5Index *p, /* FTS5 backend object */ |
| 235926 | 236802 | Fts5Structure **ppStruct /* IN/OUT: Current structure of index */ |
| 235927 | 236803 | ){ |
| 235928 | 236804 | const int nCrisis = p->pConfig->nCrisisMerge; |
| 235929 | 236805 | Fts5Structure *pStruct = *ppStruct; |
| 235930 | | - int iLvl = 0; |
| 235931 | | - |
| 235932 | | - assert( p->rc!=SQLITE_OK || pStruct->nLevel>0 ); |
| 235933 | | - while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){ |
| 235934 | | - fts5IndexMergeLevel(p, &pStruct, iLvl, 0); |
| 235935 | | - assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) ); |
| 235936 | | - fts5StructurePromote(p, iLvl+1, pStruct); |
| 235937 | | - iLvl++; |
| 235938 | | - } |
| 235939 | | - *ppStruct = pStruct; |
| 236806 | + if( pStruct && pStruct->nLevel>0 ){ |
| 236807 | + int iLvl = 0; |
| 236808 | + while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){ |
| 236809 | + fts5IndexMergeLevel(p, &pStruct, iLvl, 0); |
| 236810 | + assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) ); |
| 236811 | + fts5StructurePromote(p, iLvl+1, pStruct); |
| 236812 | + iLvl++; |
| 236813 | + } |
| 236814 | + *ppStruct = pStruct; |
| 236815 | + } |
| 235940 | 236816 | } |
| 235941 | 236817 | |
| 235942 | 236818 | static int fts5IndexReturn(Fts5Index *p){ |
| 235943 | 236819 | int rc = p->rc; |
| 235944 | 236820 | p->rc = SQLITE_OK; |
| | @@ -235967,10 +236843,417 @@ |
| 235967 | 236843 | ret += i; |
| 235968 | 236844 | } |
| 235969 | 236845 | } |
| 235970 | 236846 | return ret; |
| 235971 | 236847 | } |
| 236848 | + |
| 236849 | +/* |
| 236850 | +** Execute the SQL statement: |
| 236851 | +** |
| 236852 | +** DELETE FROM %_idx WHERE (segid, (pgno/2)) = ($iSegid, $iPgno); |
| 236853 | +** |
| 236854 | +** This is used when a secure-delete operation removes the last term |
| 236855 | +** from a segment leaf page. In that case the %_idx entry is removed |
| 236856 | +** too. This is done to ensure that if all instances of a token are |
| 236857 | +** removed from an fts5 database in secure-delete mode, no trace of |
| 236858 | +** the token itself remains in the database. |
| 236859 | +*/ |
| 236860 | +static void fts5SecureDeleteIdxEntry( |
| 236861 | + Fts5Index *p, /* FTS5 backend object */ |
| 236862 | + int iSegid, /* Id of segment to delete entry for */ |
| 236863 | + int iPgno /* Page number within segment */ |
| 236864 | +){ |
| 236865 | + if( iPgno!=1 ){ |
| 236866 | + assert( p->pConfig->iVersion==FTS5_CURRENT_VERSION_SECUREDELETE ); |
| 236867 | + if( p->pDeleteFromIdx==0 ){ |
| 236868 | + fts5IndexPrepareStmt(p, &p->pDeleteFromIdx, sqlite3_mprintf( |
| 236869 | + "DELETE FROM '%q'.'%q_idx' WHERE (segid, (pgno/2)) = (?1, ?2)", |
| 236870 | + p->pConfig->zDb, p->pConfig->zName |
| 236871 | + )); |
| 236872 | + } |
| 236873 | + if( p->rc==SQLITE_OK ){ |
| 236874 | + sqlite3_bind_int(p->pDeleteFromIdx, 1, iSegid); |
| 236875 | + sqlite3_bind_int(p->pDeleteFromIdx, 2, iPgno); |
| 236876 | + sqlite3_step(p->pDeleteFromIdx); |
| 236877 | + p->rc = sqlite3_reset(p->pDeleteFromIdx); |
| 236878 | + } |
| 236879 | + } |
| 236880 | +} |
| 236881 | + |
| 236882 | +/* |
| 236883 | +** This is called when a secure-delete operation removes a position-list |
| 236884 | +** that overflows onto segment page iPgno of segment pSeg. This function |
| 236885 | +** rewrites node iPgno, and possibly one or more of its right-hand peers, |
| 236886 | +** to remove this portion of the position list. |
| 236887 | +** |
| 236888 | +** Output variable (*pbLastInDoclist) is set to true if the position-list |
| 236889 | +** removed is followed by a new term or the end-of-segment, or false if |
| 236890 | +** it is followed by another rowid/position list. |
| 236891 | +*/ |
| 236892 | +static void fts5SecureDeleteOverflow( |
| 236893 | + Fts5Index *p, |
| 236894 | + Fts5StructureSegment *pSeg, |
| 236895 | + int iPgno, |
| 236896 | + int *pbLastInDoclist |
| 236897 | +){ |
| 236898 | + const int bDetailNone = (p->pConfig->eDetail==FTS5_DETAIL_NONE); |
| 236899 | + int pgno; |
| 236900 | + Fts5Data *pLeaf = 0; |
| 236901 | + assert( iPgno!=1 ); |
| 236902 | + |
| 236903 | + *pbLastInDoclist = 1; |
| 236904 | + for(pgno=iPgno; p->rc==SQLITE_OK && pgno<=pSeg->pgnoLast; pgno++){ |
| 236905 | + i64 iRowid = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno); |
| 236906 | + int iNext = 0; |
| 236907 | + u8 *aPg = 0; |
| 236908 | + |
| 236909 | + pLeaf = fts5DataRead(p, iRowid); |
| 236910 | + if( pLeaf==0 ) break; |
| 236911 | + aPg = pLeaf->p; |
| 236912 | + |
| 236913 | + iNext = fts5GetU16(&aPg[0]); |
| 236914 | + if( iNext!=0 ){ |
| 236915 | + *pbLastInDoclist = 0; |
| 236916 | + } |
| 236917 | + if( iNext==0 && pLeaf->szLeaf!=pLeaf->nn ){ |
| 236918 | + fts5GetVarint32(&aPg[pLeaf->szLeaf], iNext); |
| 236919 | + } |
| 236920 | + |
| 236921 | + if( iNext==0 ){ |
| 236922 | + /* The page contains no terms or rowids. Replace it with an empty |
| 236923 | + ** page and move on to the right-hand peer. */ |
| 236924 | + const u8 aEmpty[] = {0x00, 0x00, 0x00, 0x04}; |
| 236925 | + assert_nc( bDetailNone==0 || pLeaf->nn==4 ); |
| 236926 | + if( bDetailNone==0 ) fts5DataWrite(p, iRowid, aEmpty, sizeof(aEmpty)); |
| 236927 | + fts5DataRelease(pLeaf); |
| 236928 | + pLeaf = 0; |
| 236929 | + }else if( bDetailNone ){ |
| 236930 | + break; |
| 236931 | + }else if( iNext>=pLeaf->szLeaf || iNext<4 ){ |
| 236932 | + p->rc = FTS5_CORRUPT; |
| 236933 | + break; |
| 236934 | + }else{ |
| 236935 | + int nShift = iNext - 4; |
| 236936 | + int nPg; |
| 236937 | + |
| 236938 | + int nIdx = 0; |
| 236939 | + u8 *aIdx = 0; |
| 236940 | + |
| 236941 | + /* Unless the current page footer is 0 bytes in size (in which case |
| 236942 | + ** the new page footer will be as well), allocate and populate a |
| 236943 | + ** buffer containing the new page footer. Set stack variables aIdx |
| 236944 | + ** and nIdx accordingly. */ |
| 236945 | + if( pLeaf->nn>pLeaf->szLeaf ){ |
| 236946 | + int iFirst = 0; |
| 236947 | + int i1 = pLeaf->szLeaf; |
| 236948 | + int i2 = 0; |
| 236949 | + |
| 236950 | + aIdx = sqlite3Fts5MallocZero(&p->rc, (pLeaf->nn-pLeaf->szLeaf)+2); |
| 236951 | + if( aIdx==0 ) break; |
| 236952 | + i1 += fts5GetVarint32(&aPg[i1], iFirst); |
| 236953 | + i2 = sqlite3Fts5PutVarint(aIdx, iFirst-nShift); |
| 236954 | + if( i1<pLeaf->nn ){ |
| 236955 | + memcpy(&aIdx[i2], &aPg[i1], pLeaf->nn-i1); |
| 236956 | + i2 += (pLeaf->nn-i1); |
| 236957 | + } |
| 236958 | + nIdx = i2; |
| 236959 | + } |
| 236960 | + |
| 236961 | + /* Modify the contents of buffer aPg[]. Set nPg to the new size |
| 236962 | + ** in bytes. The new page is always smaller than the old. */ |
| 236963 | + nPg = pLeaf->szLeaf - nShift; |
| 236964 | + memmove(&aPg[4], &aPg[4+nShift], nPg-4); |
| 236965 | + fts5PutU16(&aPg[2], nPg); |
| 236966 | + if( fts5GetU16(&aPg[0]) ) fts5PutU16(&aPg[0], 4); |
| 236967 | + if( nIdx>0 ){ |
| 236968 | + memcpy(&aPg[nPg], aIdx, nIdx); |
| 236969 | + nPg += nIdx; |
| 236970 | + } |
| 236971 | + sqlite3_free(aIdx); |
| 236972 | + |
| 236973 | + /* Write the new page to disk and exit the loop */ |
| 236974 | + assert( nPg>4 || fts5GetU16(aPg)==0 ); |
| 236975 | + fts5DataWrite(p, iRowid, aPg, nPg); |
| 236976 | + break; |
| 236977 | + } |
| 236978 | + } |
| 236979 | + fts5DataRelease(pLeaf); |
| 236980 | +} |
| 236981 | + |
| 236982 | +/* |
| 236983 | +** Completely remove the entry that pSeg currently points to from |
| 236984 | +** the database. |
| 236985 | +*/ |
| 236986 | +static void fts5DoSecureDelete( |
| 236987 | + Fts5Index *p, |
| 236988 | + Fts5SegIter *pSeg |
| 236989 | +){ |
| 236990 | + const int bDetailNone = (p->pConfig->eDetail==FTS5_DETAIL_NONE); |
| 236991 | + int iSegid = pSeg->pSeg->iSegid; |
| 236992 | + u8 *aPg = pSeg->pLeaf->p; |
| 236993 | + int nPg = pSeg->pLeaf->nn; |
| 236994 | + int iPgIdx = pSeg->pLeaf->szLeaf; |
| 236995 | + |
| 236996 | + u64 iDelta = 0; |
| 236997 | + u64 iNextDelta = 0; |
| 236998 | + int iNextOff = 0; |
| 236999 | + int iOff = 0; |
| 237000 | + int nIdx = 0; |
| 237001 | + u8 *aIdx = 0; |
| 237002 | + int bLastInDoclist = 0; |
| 237003 | + int iIdx = 0; |
| 237004 | + int iStart = 0; |
| 237005 | + int iKeyOff = 0; |
| 237006 | + int iPrevKeyOff = 0; |
| 237007 | + int iDelKeyOff = 0; /* Offset of deleted key, if any */ |
| 237008 | + |
| 237009 | + nIdx = nPg-iPgIdx; |
| 237010 | + aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16); |
| 237011 | + if( p->rc ) return; |
| 237012 | + memcpy(aIdx, &aPg[iPgIdx], nIdx); |
| 237013 | + |
| 237014 | + /* At this point segment iterator pSeg points to the entry |
| 237015 | + ** this function should remove from the b-tree segment. |
| 237016 | + ** |
| 237017 | + ** In detail=full or detail=column mode, pSeg->iLeafOffset is the |
| 237018 | + ** offset of the first byte in the position-list for the entry to |
| 237019 | + ** remove. Immediately before this comes two varints that will also |
| 237020 | + ** need to be removed: |
| 237021 | + ** |
| 237022 | + ** + the rowid or delta rowid value for the entry, and |
| 237023 | + ** + the size of the position list in bytes. |
| 237024 | + ** |
| 237025 | + ** Or, in detail=none mode, there is a single varint prior to |
| 237026 | + ** pSeg->iLeafOffset - the rowid or delta rowid value. |
| 237027 | + ** |
| 237028 | + ** This block sets the following variables: |
| 237029 | + ** |
| 237030 | + ** iStart: |
| 237031 | + ** iDelta: |
| 237032 | + */ |
| 237033 | + { |
| 237034 | + int iSOP; |
| 237035 | + if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ |
| 237036 | + iStart = pSeg->iTermLeafOffset; |
| 237037 | + }else{ |
| 237038 | + iStart = fts5GetU16(&aPg[0]); |
| 237039 | + } |
| 237040 | + |
| 237041 | + iSOP = iStart + fts5GetVarint(&aPg[iStart], &iDelta); |
| 237042 | + assert_nc( iSOP<=pSeg->iLeafOffset ); |
| 237043 | + |
| 237044 | + if( bDetailNone ){ |
| 237045 | + while( iSOP<pSeg->iLeafOffset ){ |
| 237046 | + if( aPg[iSOP]==0x00 ) iSOP++; |
| 237047 | + if( aPg[iSOP]==0x00 ) iSOP++; |
| 237048 | + iStart = iSOP; |
| 237049 | + iSOP = iStart + fts5GetVarint(&aPg[iStart], &iDelta); |
| 237050 | + } |
| 237051 | + |
| 237052 | + iNextOff = iSOP; |
| 237053 | + if( iNextOff<pSeg->iEndofDoclist && aPg[iNextOff]==0x00 ) iNextOff++; |
| 237054 | + if( iNextOff<pSeg->iEndofDoclist && aPg[iNextOff]==0x00 ) iNextOff++; |
| 237055 | + |
| 237056 | + }else{ |
| 237057 | + int nPos = 0; |
| 237058 | + iSOP += fts5GetVarint32(&aPg[iSOP], nPos); |
| 237059 | + while( iSOP<pSeg->iLeafOffset ){ |
| 237060 | + iStart = iSOP + (nPos/2); |
| 237061 | + iSOP = iStart + fts5GetVarint(&aPg[iStart], &iDelta); |
| 237062 | + iSOP += fts5GetVarint32(&aPg[iSOP], nPos); |
| 237063 | + } |
| 237064 | + assert_nc( iSOP==pSeg->iLeafOffset ); |
| 237065 | + iNextOff = pSeg->iLeafOffset + pSeg->nPos; |
| 237066 | + } |
| 237067 | + } |
| 237068 | + |
| 237069 | + iOff = iStart; |
| 237070 | + if( iNextOff>=iPgIdx ){ |
| 237071 | + int pgno = pSeg->iLeafPgno+1; |
| 237072 | + fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); |
| 237073 | + iNextOff = iPgIdx; |
| 237074 | + }else{ |
| 237075 | + /* Set bLastInDoclist to true if the entry being removed is the last |
| 237076 | + ** in its doclist. */ |
| 237077 | + for(iIdx=0, iKeyOff=0; iIdx<nIdx; /* no-op */){ |
| 237078 | + u32 iVal = 0; |
| 237079 | + iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 237080 | + iKeyOff += iVal; |
| 237081 | + if( iKeyOff==iNextOff ){ |
| 237082 | + bLastInDoclist = 1; |
| 237083 | + } |
| 237084 | + } |
| 237085 | + } |
| 237086 | + |
| 237087 | + if( fts5GetU16(&aPg[0])==iStart && (bLastInDoclist||iNextOff==iPgIdx) ){ |
| 237088 | + fts5PutU16(&aPg[0], 0); |
| 237089 | + } |
| 237090 | + |
| 237091 | + if( bLastInDoclist==0 ){ |
| 237092 | + if( iNextOff!=iPgIdx ){ |
| 237093 | + iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); |
| 237094 | + iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); |
| 237095 | + } |
| 237096 | + }else if( |
| 237097 | + iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno |
| 237098 | + ){ |
| 237099 | + /* The entry being removed was the only position list in its |
| 237100 | + ** doclist. Therefore the term needs to be removed as well. */ |
| 237101 | + int iKey = 0; |
| 237102 | + for(iIdx=0, iKeyOff=0; iIdx<nIdx; iKey++){ |
| 237103 | + u32 iVal = 0; |
| 237104 | + iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 237105 | + if( (iKeyOff+iVal)>(u32)iStart ) break; |
| 237106 | + iKeyOff += iVal; |
| 237107 | + } |
| 237108 | + |
| 237109 | + iDelKeyOff = iOff = iKeyOff; |
| 237110 | + if( iNextOff!=iPgIdx ){ |
| 237111 | + int nPrefix = 0; |
| 237112 | + int nSuffix = 0; |
| 237113 | + int nPrefix2 = 0; |
| 237114 | + int nSuffix2 = 0; |
| 237115 | + |
| 237116 | + iDelKeyOff = iNextOff; |
| 237117 | + iNextOff += fts5GetVarint32(&aPg[iNextOff], nPrefix2); |
| 237118 | + iNextOff += fts5GetVarint32(&aPg[iNextOff], nSuffix2); |
| 237119 | + |
| 237120 | + if( iKey!=1 ){ |
| 237121 | + iKeyOff += fts5GetVarint32(&aPg[iKeyOff], nPrefix); |
| 237122 | + } |
| 237123 | + iKeyOff += fts5GetVarint32(&aPg[iKeyOff], nSuffix); |
| 237124 | + |
| 237125 | + nPrefix = MIN(nPrefix, nPrefix2); |
| 237126 | + nSuffix = (nPrefix2 + nSuffix2) - nPrefix; |
| 237127 | + |
| 237128 | + if( (iKeyOff+nSuffix)>iPgIdx || (iNextOff+nSuffix2)>iPgIdx ){ |
| 237129 | + p->rc = FTS5_CORRUPT; |
| 237130 | + }else{ |
| 237131 | + if( iKey!=1 ){ |
| 237132 | + iOff += sqlite3Fts5PutVarint(&aPg[iOff], nPrefix); |
| 237133 | + } |
| 237134 | + iOff += sqlite3Fts5PutVarint(&aPg[iOff], nSuffix); |
| 237135 | + if( nPrefix2>nPrefix ){ |
| 237136 | + memcpy(&aPg[iOff], &pSeg->term.p[nPrefix], nPrefix2-nPrefix); |
| 237137 | + iOff += (nPrefix2-nPrefix); |
| 237138 | + } |
| 237139 | + memmove(&aPg[iOff], &aPg[iNextOff], nSuffix2); |
| 237140 | + iOff += nSuffix2; |
| 237141 | + iNextOff += nSuffix2; |
| 237142 | + } |
| 237143 | + } |
| 237144 | + }else if( iStart==4 ){ |
| 237145 | + int iPgno; |
| 237146 | + |
| 237147 | + assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); |
| 237148 | + /* The entry being removed may be the only position list in |
| 237149 | + ** its doclist. */ |
| 237150 | + for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ |
| 237151 | + Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); |
| 237152 | + int bEmpty = (pPg && pPg->nn==4); |
| 237153 | + fts5DataRelease(pPg); |
| 237154 | + if( bEmpty==0 ) break; |
| 237155 | + } |
| 237156 | + |
| 237157 | + if( iPgno==pSeg->iTermLeafPgno ){ |
| 237158 | + i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); |
| 237159 | + Fts5Data *pTerm = fts5DataRead(p, iId); |
| 237160 | + if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ |
| 237161 | + u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; |
| 237162 | + int nTermIdx = pTerm->nn - pTerm->szLeaf; |
| 237163 | + int iTermIdx = 0; |
| 237164 | + int iTermOff = 0; |
| 237165 | + |
| 237166 | + while( 1 ){ |
| 237167 | + u32 iVal = 0; |
| 237168 | + int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); |
| 237169 | + iTermOff += iVal; |
| 237170 | + if( (iTermIdx+nByte)>=nTermIdx ) break; |
| 237171 | + iTermIdx += nByte; |
| 237172 | + } |
| 237173 | + nTermIdx = iTermIdx; |
| 237174 | + |
| 237175 | + memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); |
| 237176 | + fts5PutU16(&pTerm->p[2], iTermOff); |
| 237177 | + |
| 237178 | + fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); |
| 237179 | + if( nTermIdx==0 ){ |
| 237180 | + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); |
| 237181 | + } |
| 237182 | + } |
| 237183 | + fts5DataRelease(pTerm); |
| 237184 | + } |
| 237185 | + } |
| 237186 | + |
| 237187 | + if( p->rc==SQLITE_OK ){ |
| 237188 | + const int nMove = nPg - iNextOff; |
| 237189 | + int nShift = 0; |
| 237190 | + |
| 237191 | + memmove(&aPg[iOff], &aPg[iNextOff], nMove); |
| 237192 | + iPgIdx -= (iNextOff - iOff); |
| 237193 | + nPg = iPgIdx; |
| 237194 | + fts5PutU16(&aPg[2], iPgIdx); |
| 237195 | + |
| 237196 | + nShift = iNextOff - iOff; |
| 237197 | + for(iIdx=0, iKeyOff=0, iPrevKeyOff=0; iIdx<nIdx; /* no-op */){ |
| 237198 | + u32 iVal = 0; |
| 237199 | + iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); |
| 237200 | + iKeyOff += iVal; |
| 237201 | + if( iKeyOff!=iDelKeyOff ){ |
| 237202 | + if( iKeyOff>iOff ){ |
| 237203 | + iKeyOff -= nShift; |
| 237204 | + nShift = 0; |
| 237205 | + } |
| 237206 | + nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOff - iPrevKeyOff); |
| 237207 | + iPrevKeyOff = iKeyOff; |
| 237208 | + } |
| 237209 | + } |
| 237210 | + |
| 237211 | + if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ |
| 237212 | + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); |
| 237213 | + } |
| 237214 | + |
| 237215 | + assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); |
| 237216 | + fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg,nPg); |
| 237217 | + } |
| 237218 | + sqlite3_free(aIdx); |
| 237219 | +} |
| 237220 | + |
| 237221 | +/* |
| 237222 | +** This is called as part of flushing a delete to disk in 'secure-delete' |
| 237223 | +** mode. It edits the segments within the database described by argument |
| 237224 | +** pStruct to remove the entries for term zTerm, rowid iRowid. |
| 237225 | +*/ |
| 237226 | +static void fts5FlushSecureDelete( |
| 237227 | + Fts5Index *p, |
| 237228 | + Fts5Structure *pStruct, |
| 237229 | + const char *zTerm, |
| 237230 | + i64 iRowid |
| 237231 | +){ |
| 237232 | + const int f = FTS5INDEX_QUERY_SKIPHASH; |
| 237233 | + int nTerm = (int)strlen(zTerm); |
| 237234 | + Fts5Iter *pIter = 0; /* Used to find term instance */ |
| 237235 | + |
| 237236 | + fts5MultiIterNew(p, pStruct, f, 0, (const u8*)zTerm, nTerm, -1, 0, &pIter); |
| 237237 | + if( fts5MultiIterEof(p, pIter)==0 ){ |
| 237238 | + i64 iThis = fts5MultiIterRowid(pIter); |
| 237239 | + if( iThis<iRowid ){ |
| 237240 | + fts5MultiIterNextFrom(p, pIter, iRowid); |
| 237241 | + } |
| 237242 | + |
| 237243 | + if( p->rc==SQLITE_OK |
| 237244 | + && fts5MultiIterEof(p, pIter)==0 |
| 237245 | + && iRowid==fts5MultiIterRowid(pIter) |
| 237246 | + ){ |
| 237247 | + Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst]; |
| 237248 | + fts5DoSecureDelete(p, pSeg); |
| 237249 | + } |
| 237250 | + } |
| 237251 | + |
| 237252 | + fts5MultiIterFree(pIter); |
| 237253 | +} |
| 237254 | + |
| 235972 | 237255 | |
| 235973 | 237256 | /* |
| 235974 | 237257 | ** Flush the contents of in-memory hash table iHash to a new level-0 |
| 235975 | 237258 | ** segment on disk. Also update the corresponding structure record. |
| 235976 | 237259 | ** |
| | @@ -235990,10 +237273,11 @@ |
| 235990 | 237273 | fts5StructureInvalidate(p); |
| 235991 | 237274 | |
| 235992 | 237275 | if( iSegid ){ |
| 235993 | 237276 | const int pgsz = p->pConfig->pgsz; |
| 235994 | 237277 | int eDetail = p->pConfig->eDetail; |
| 237278 | + int bSecureDelete = p->pConfig->bSecureDelete; |
| 235995 | 237279 | Fts5StructureSegment *pSeg; /* New segment within pStruct */ |
| 235996 | 237280 | Fts5Buffer *pBuf; /* Buffer in which to assemble leaf page */ |
| 235997 | 237281 | Fts5Buffer *pPgidx; /* Buffer in which to assemble pgidx */ |
| 235998 | 237282 | |
| 235999 | 237283 | Fts5SegWriter writer; |
| | @@ -236012,44 +237296,81 @@ |
| 236012 | 237296 | if( p->rc==SQLITE_OK ){ |
| 236013 | 237297 | p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0); |
| 236014 | 237298 | } |
| 236015 | 237299 | while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){ |
| 236016 | 237300 | const char *zTerm; /* Buffer containing term */ |
| 237301 | + int nTerm; /* Size of zTerm in bytes */ |
| 236017 | 237302 | const u8 *pDoclist; /* Pointer to doclist for this term */ |
| 236018 | 237303 | int nDoclist; /* Size of doclist in bytes */ |
| 236019 | 237304 | |
| 236020 | | - /* Write the term for this entry to disk. */ |
| 237305 | + /* Get the term and doclist for this entry. */ |
| 236021 | 237306 | sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist); |
| 236022 | | - fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm); |
| 236023 | | - if( p->rc!=SQLITE_OK ) break; |
| 237307 | + nTerm = (int)strlen(zTerm); |
| 237308 | + if( bSecureDelete==0 ){ |
| 237309 | + fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); |
| 237310 | + if( p->rc!=SQLITE_OK ) break; |
| 237311 | + assert( writer.bFirstRowidInPage==0 ); |
| 237312 | + } |
| 236024 | 237313 | |
| 236025 | | - assert( writer.bFirstRowidInPage==0 ); |
| 236026 | | - if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ |
| 237314 | + if( !bSecureDelete && pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ |
| 236027 | 237315 | /* The entire doclist will fit on the current leaf. */ |
| 236028 | 237316 | fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); |
| 236029 | 237317 | }else{ |
| 237318 | + int bTermWritten = !bSecureDelete; |
| 236030 | 237319 | i64 iRowid = 0; |
| 236031 | | - u64 iDelta = 0; |
| 237320 | + i64 iPrev = 0; |
| 236032 | 237321 | int iOff = 0; |
| 236033 | 237322 | |
| 236034 | 237323 | /* The entire doclist will not fit on this leaf. The following |
| 236035 | 237324 | ** loop iterates through the poslists that make up the current |
| 236036 | 237325 | ** doclist. */ |
| 236037 | 237326 | while( p->rc==SQLITE_OK && iOff<nDoclist ){ |
| 237327 | + u64 iDelta = 0; |
| 236038 | 237328 | iOff += fts5GetVarint(&pDoclist[iOff], &iDelta); |
| 236039 | 237329 | iRowid += iDelta; |
| 237330 | + |
| 237331 | + /* If in secure delete mode, and if this entry in the poslist is |
| 237332 | + ** in fact a delete, then edit the existing segments directly |
| 237333 | + ** using fts5FlushSecureDelete(). */ |
| 237334 | + if( bSecureDelete ){ |
| 237335 | + if( eDetail==FTS5_DETAIL_NONE ){ |
| 237336 | + if( iOff<nDoclist && pDoclist[iOff]==0x00 ){ |
| 237337 | + fts5FlushSecureDelete(p, pStruct, zTerm, iRowid); |
| 237338 | + iOff++; |
| 237339 | + if( iOff<nDoclist && pDoclist[iOff]==0x00 ){ |
| 237340 | + iOff++; |
| 237341 | + nDoclist = 0; |
| 237342 | + }else{ |
| 237343 | + continue; |
| 237344 | + } |
| 237345 | + } |
| 237346 | + }else if( (pDoclist[iOff] & 0x01) ){ |
| 237347 | + fts5FlushSecureDelete(p, pStruct, zTerm, iRowid); |
| 237348 | + if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){ |
| 237349 | + iOff++; |
| 237350 | + continue; |
| 237351 | + } |
| 237352 | + } |
| 237353 | + } |
| 237354 | + |
| 237355 | + if( p->rc==SQLITE_OK && bTermWritten==0 ){ |
| 237356 | + fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); |
| 237357 | + bTermWritten = 1; |
| 237358 | + assert( p->rc!=SQLITE_OK || writer.bFirstRowidInPage==0 ); |
| 237359 | + } |
| 236040 | 237360 | |
| 236041 | 237361 | if( writer.bFirstRowidInPage ){ |
| 236042 | 237362 | fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ |
| 236043 | 237363 | pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); |
| 236044 | 237364 | writer.bFirstRowidInPage = 0; |
| 236045 | 237365 | fts5WriteDlidxAppend(p, &writer, iRowid); |
| 236046 | | - if( p->rc!=SQLITE_OK ) break; |
| 236047 | 237366 | }else{ |
| 236048 | | - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta); |
| 237367 | + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid-iPrev); |
| 236049 | 237368 | } |
| 237369 | + if( p->rc!=SQLITE_OK ) break; |
| 236050 | 237370 | assert( pBuf->n<=pBuf->nSpace ); |
| 237371 | + iPrev = iRowid; |
| 236051 | 237372 | |
| 236052 | 237373 | if( eDetail==FTS5_DETAIL_NONE ){ |
| 236053 | 237374 | if( iOff<nDoclist && pDoclist[iOff]==0 ){ |
| 236054 | 237375 | pBuf->p[pBuf->n++] = 0; |
| 236055 | 237376 | iOff++; |
| | @@ -236104,24 +237425,27 @@ |
| 236104 | 237425 | if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); |
| 236105 | 237426 | } |
| 236106 | 237427 | sqlite3Fts5HashClear(pHash); |
| 236107 | 237428 | fts5WriteFinish(p, &writer, &pgnoLast); |
| 236108 | 237429 | |
| 236109 | | - /* Update the Fts5Structure. It is written back to the database by the |
| 236110 | | - ** fts5StructureRelease() call below. */ |
| 236111 | | - if( pStruct->nLevel==0 ){ |
| 236112 | | - fts5StructureAddLevel(&p->rc, &pStruct); |
| 236113 | | - } |
| 236114 | | - fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0); |
| 236115 | | - if( p->rc==SQLITE_OK ){ |
| 236116 | | - pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ]; |
| 236117 | | - pSeg->iSegid = iSegid; |
| 236118 | | - pSeg->pgnoFirst = 1; |
| 236119 | | - pSeg->pgnoLast = pgnoLast; |
| 236120 | | - pStruct->nSegment++; |
| 236121 | | - } |
| 236122 | | - fts5StructurePromote(p, 0, pStruct); |
| 237430 | + assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); |
| 237431 | + if( pgnoLast>0 ){ |
| 237432 | + /* Update the Fts5Structure. It is written back to the database by the |
| 237433 | + ** fts5StructureRelease() call below. */ |
| 237434 | + if( pStruct->nLevel==0 ){ |
| 237435 | + fts5StructureAddLevel(&p->rc, &pStruct); |
| 237436 | + } |
| 237437 | + fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0); |
| 237438 | + if( p->rc==SQLITE_OK ){ |
| 237439 | + pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ]; |
| 237440 | + pSeg->iSegid = iSegid; |
| 237441 | + pSeg->pgnoFirst = 1; |
| 237442 | + pSeg->pgnoLast = pgnoLast; |
| 237443 | + pStruct->nSegment++; |
| 237444 | + } |
| 237445 | + fts5StructurePromote(p, 0, pStruct); |
| 237446 | + } |
| 236123 | 237447 | } |
| 236124 | 237448 | |
| 236125 | 237449 | fts5IndexAutomerge(p, &pStruct, pgnoLast); |
| 236126 | 237450 | fts5IndexCrisismerge(p, &pStruct); |
| 236127 | 237451 | fts5StructureWrite(p, pStruct); |
| | @@ -236858,10 +238182,11 @@ |
| 236858 | 238182 | sqlite3_finalize(p->pDeleter); |
| 236859 | 238183 | sqlite3_finalize(p->pIdxWriter); |
| 236860 | 238184 | sqlite3_finalize(p->pIdxDeleter); |
| 236861 | 238185 | sqlite3_finalize(p->pIdxSelect); |
| 236862 | 238186 | sqlite3_finalize(p->pDataVersion); |
| 238187 | + sqlite3_finalize(p->pDeleteFromIdx); |
| 236863 | 238188 | sqlite3Fts5HashFree(p->pHash); |
| 236864 | 238189 | sqlite3_free(p->zDataTbl); |
| 236865 | 238190 | sqlite3_free(p); |
| 236866 | 238191 | } |
| 236867 | 238192 | return rc; |
| | @@ -237488,10 +238813,11 @@ |
| 237488 | 238813 | static void fts5IndexIntegrityCheckSegment( |
| 237489 | 238814 | Fts5Index *p, /* FTS5 backend object */ |
| 237490 | 238815 | Fts5StructureSegment *pSeg /* Segment to check internal consistency */ |
| 237491 | 238816 | ){ |
| 237492 | 238817 | Fts5Config *pConfig = p->pConfig; |
| 238818 | + int bSecureDelete = (pConfig->iVersion==FTS5_CURRENT_VERSION_SECUREDELETE); |
| 237493 | 238819 | sqlite3_stmt *pStmt = 0; |
| 237494 | 238820 | int rc2; |
| 237495 | 238821 | int iIdxPrevLeaf = pSeg->pgnoFirst-1; |
| 237496 | 238822 | int iDlidxPrevLeaf = pSeg->pgnoLast; |
| 237497 | 238823 | |
| | @@ -237523,11 +238849,23 @@ |
| 237523 | 238849 | /* Check that the leaf contains at least one term, and that it is equal |
| 237524 | 238850 | ** to or larger than the split-key in zIdxTerm. Also check that if there |
| 237525 | 238851 | ** is also a rowid pointer within the leaf page header, it points to a |
| 237526 | 238852 | ** location before the term. */ |
| 237527 | 238853 | if( pLeaf->nn<=pLeaf->szLeaf ){ |
| 237528 | | - p->rc = FTS5_CORRUPT; |
| 238854 | + |
| 238855 | + if( nIdxTerm==0 |
| 238856 | + && pConfig->iVersion==FTS5_CURRENT_VERSION_SECUREDELETE |
| 238857 | + && pLeaf->nn==pLeaf->szLeaf |
| 238858 | + && pLeaf->nn==4 |
| 238859 | + ){ |
| 238860 | + /* special case - the very first page in a segment keeps its %_idx |
| 238861 | + ** entry even if all the terms are removed from it by secure-delete |
| 238862 | + ** operations. */ |
| 238863 | + }else{ |
| 238864 | + p->rc = FTS5_CORRUPT; |
| 238865 | + } |
| 238866 | + |
| 237529 | 238867 | }else{ |
| 237530 | 238868 | int iOff; /* Offset of first term on leaf */ |
| 237531 | 238869 | int iRowidOff; /* Offset of first rowid on leaf */ |
| 237532 | 238870 | int nTerm; /* Size of term on leaf in bytes */ |
| 237533 | 238871 | int res; /* Comparison of term and split-key */ |
| | @@ -237587,13 +238925,16 @@ |
| 237587 | 238925 | i64 iRowid; |
| 237588 | 238926 | int iRowidOff = fts5LeafFirstRowidOff(pLeaf); |
| 237589 | 238927 | ASSERT_SZLEAF_OK(pLeaf); |
| 237590 | 238928 | if( iRowidOff>=pLeaf->szLeaf ){ |
| 237591 | 238929 | p->rc = FTS5_CORRUPT; |
| 237592 | | - }else{ |
| 238930 | + }else if( bSecureDelete==0 || iRowidOff>0 ){ |
| 238931 | + i64 iDlRowid = fts5DlidxIterRowid(pDlidx); |
| 237593 | 238932 | fts5GetVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid); |
| 237594 | | - if( iRowid!=fts5DlidxIterRowid(pDlidx) ) p->rc = FTS5_CORRUPT; |
| 238933 | + if( iRowid<iDlRowid || (bSecureDelete==0 && iRowid!=iDlRowid) ){ |
| 238934 | + p->rc = FTS5_CORRUPT; |
| 238935 | + } |
| 237595 | 238936 | } |
| 237596 | 238937 | fts5DataRelease(pLeaf); |
| 237597 | 238938 | } |
| 237598 | 238939 | } |
| 237599 | 238940 | |
| | @@ -239851,10 +241192,12 @@ |
| 239851 | 241192 | ){ |
| 239852 | 241193 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 239853 | 241194 | Fts5Config *pConfig = pTab->p.pConfig; |
| 239854 | 241195 | int eType0; /* value_type() of apVal[0] */ |
| 239855 | 241196 | int rc = SQLITE_OK; /* Return code */ |
| 241197 | + int bUpdateOrDelete = 0; |
| 241198 | + |
| 239856 | 241199 | |
| 239857 | 241200 | /* A transaction must be open when this is called. */ |
| 239858 | 241201 | assert( pTab->ts.eState==1 || pTab->ts.eState==2 ); |
| 239859 | 241202 | |
| 239860 | 241203 | assert( pVtab->zErrMsg==0 ); |
| | @@ -239861,10 +241204,15 @@ |
| 239861 | 241204 | assert( nArg==1 || nArg==(2+pConfig->nCol+2) ); |
| 239862 | 241205 | assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER |
| 239863 | 241206 | || sqlite3_value_type(apVal[0])==SQLITE_NULL |
| 239864 | 241207 | ); |
| 239865 | 241208 | assert( pTab->p.pConfig->pzErrmsg==0 ); |
| 241209 | + if( pConfig->pgsz==0 ){ |
| 241210 | + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); |
| 241211 | + if( rc!=SQLITE_OK ) return rc; |
| 241212 | + } |
| 241213 | + |
| 239866 | 241214 | pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg; |
| 239867 | 241215 | |
| 239868 | 241216 | /* Put any active cursors into REQUIRE_SEEK state. */ |
| 239869 | 241217 | fts5TripCursors(pTab); |
| 239870 | 241218 | |
| | @@ -239913,10 +241261,11 @@ |
| 239913 | 241261 | |
| 239914 | 241262 | /* DELETE */ |
| 239915 | 241263 | else if( nArg==1 ){ |
| 239916 | 241264 | i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ |
| 239917 | 241265 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0); |
| 241266 | + bUpdateOrDelete = 1; |
| 239918 | 241267 | } |
| 239919 | 241268 | |
| 239920 | 241269 | /* INSERT or UPDATE */ |
| 239921 | 241270 | else{ |
| 239922 | 241271 | int eType1 = sqlite3_value_numeric_type(apVal[1]); |
| | @@ -239928,10 +241277,11 @@ |
| 239928 | 241277 | else if( eType0!=SQLITE_INTEGER ){ |
| 239929 | 241278 | /* If this is a REPLACE, first remove the current entry (if any) */ |
| 239930 | 241279 | if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ |
| 239931 | 241280 | i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ |
| 239932 | 241281 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); |
| 241282 | + bUpdateOrDelete = 1; |
| 239933 | 241283 | } |
| 239934 | 241284 | fts5StorageInsert(&rc, pTab, apVal, pRowid); |
| 239935 | 241285 | } |
| 239936 | 241286 | |
| 239937 | 241287 | /* UPDATE */ |
| | @@ -239956,13 +241306,27 @@ |
| 239956 | 241306 | } |
| 239957 | 241307 | }else{ |
| 239958 | 241308 | rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); |
| 239959 | 241309 | fts5StorageInsert(&rc, pTab, apVal, pRowid); |
| 239960 | 241310 | } |
| 241311 | + bUpdateOrDelete = 1; |
| 239961 | 241312 | } |
| 239962 | 241313 | } |
| 239963 | 241314 | } |
| 241315 | + |
| 241316 | + if( rc==SQLITE_OK |
| 241317 | + && bUpdateOrDelete |
| 241318 | + && pConfig->bSecureDelete |
| 241319 | + && pConfig->iVersion==FTS5_CURRENT_VERSION |
| 241320 | + ){ |
| 241321 | + rc = sqlite3Fts5StorageConfigValue( |
| 241322 | + pTab->pStorage, "version", 0, FTS5_CURRENT_VERSION_SECUREDELETE |
| 241323 | + ); |
| 241324 | + if( rc==SQLITE_OK ){ |
| 241325 | + pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE; |
| 241326 | + } |
| 241327 | + } |
| 239964 | 241328 | |
| 239965 | 241329 | pTab->p.pConfig->pzErrmsg = 0; |
| 239966 | 241330 | return rc; |
| 239967 | 241331 | } |
| 239968 | 241332 | |
| | @@ -240819,10 +242183,11 @@ |
| 240819 | 242183 | static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 240820 | 242184 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 240821 | 242185 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 240822 | 242186 | fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); |
| 240823 | 242187 | fts5TripCursors(pTab); |
| 242188 | + pTab->p.pConfig->pgsz = 0; |
| 240824 | 242189 | return sqlite3Fts5StorageRollback(pTab->pStorage); |
| 240825 | 242190 | } |
| 240826 | 242191 | |
| 240827 | 242192 | /* |
| 240828 | 242193 | ** Register a new auxiliary function with global context pGlobal. |
| | @@ -241021,11 +242386,11 @@ |
| 241021 | 242386 | int nArg, /* Number of args */ |
| 241022 | 242387 | sqlite3_value **apUnused /* Function arguments */ |
| 241023 | 242388 | ){ |
| 241024 | 242389 | assert( nArg==0 ); |
| 241025 | 242390 | UNUSED_PARAM2(nArg, apUnused); |
| 241026 | | - sqlite3_result_text(pCtx, "fts5: 2023-04-10 13:20:51 49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785", -1, SQLITE_TRANSIENT); |
| 242391 | + sqlite3_result_text(pCtx, "fts5: 2023-05-01 20:09:52 62d703d83cf8cf3358715792347c49315a82c659e475158e385746f4329a4f39", -1, SQLITE_TRANSIENT); |
| 241027 | 242392 | } |
| 241028 | 242393 | |
| 241029 | 242394 | /* |
| 241030 | 242395 | ** Return true if zName is the extension on one of the shadow tables used |
| 241031 | 242396 | ** by this module. |
| 241032 | 242397 | |