Fossil SCM

Update the built-in SQLite to the latest 3.20.0 beta, including support for tab-completion in the SQL shell.

drh 2017-07-11 14:35 trunk
Commit a314178a815645d3d248d1cf4e3b2738bf42dcd82a0ec761736707ea71109bb6
3 files changed +819 -87 +1590 -1279 +95 -27
+819 -87
--- src/shell.c
+++ src/shell.c
@@ -1,5 +1,23 @@
1
+/* DO NOT EDIT!
2
+** This file is automatically generated by the script in the canonical
3
+** SQLite source tree at tool/mkshellc.tcl. That script combines source
4
+** code from various constituent source files of SQLite into this single
5
+** "shell.c" file used to implement the SQLite command-line shell.
6
+**
7
+** Most of the code found below comes from the "src/shell.c.in" file in
8
+** the canonical SQLite source tree. That main file contains "INCLUDE"
9
+** lines that specify other files in the canonical source tree that are
10
+** inserted to getnerate this complete program source file.
11
+**
12
+** The code from multiple files is combined into this single "shell.c"
13
+** source file to help make the command-line program easier to compile.
14
+**
15
+** To modify this program, get a copy of the canonical SQLite source tree,
16
+** edit the src/shell.c.in" and/or some of the other files that are included
17
+** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
18
+*/
119
/*
220
** 2001 September 15
321
**
422
** The author disclaims copyright to this source code. In place of
523
** a legal notice, here is a blessing:
@@ -782,14 +800,57 @@
782800
}
783801
}
784802
sqlite3_result_value(pCtx, apVal[0]);
785803
}
786804
787
-/******************************************************************************
788
-** SHA3 hash implementation copied from ../ext/misc/shathree.c
805
+/*
806
+** The source code for several run-time loadable extensions is inserted
807
+** below by the ../tool/mkshellc.tcl script. Before processing that included
808
+** code, we need to override some macros to make the included program code
809
+** work here in the middle of this regular program.
789810
*/
811
+#define SQLITE_EXTENSION_INIT1
812
+#define SQLITE_EXTENSION_INIT2(X)
813
+
814
+/************************* Begin ../ext/misc/shathree.c ******************/
815
+/*
816
+** 2017-03-08
817
+**
818
+** The author disclaims copyright to this source code. In place of
819
+** a legal notice, here is a blessing:
820
+**
821
+** May you do good and not evil.
822
+** May you find forgiveness for yourself and forgive others.
823
+** May you share freely, never taking more than you give.
824
+**
825
+******************************************************************************
826
+**
827
+** This SQLite extension implements a functions that compute SHA1 hashes.
828
+** Two SQL functions are implemented:
829
+**
830
+** sha3(X,SIZE)
831
+** sha3_query(Y,SIZE)
832
+**
833
+** The sha3(X) function computes the SHA3 hash of the input X, or NULL if
834
+** X is NULL.
835
+**
836
+** The sha3_query(Y) function evalutes all queries in the SQL statements of Y
837
+** and returns a hash of their results.
838
+**
839
+** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm
840
+** is used. If SIZE is included it must be one of the integers 224, 256,
841
+** 384, or 512, to determine SHA3 hash variant that is computed.
842
+*/
843
+SQLITE_EXTENSION_INIT1
844
+#include <assert.h>
845
+#include <string.h>
846
+#include <stdarg.h>
790847
typedef sqlite3_uint64 u64;
848
+
849
+/******************************************************************************
850
+** The Hash Engine
851
+*/
791852
/*
792853
** Macros to determine whether the machine is big or little endian,
793854
** and whether or not that determination is run-time or compile-time.
794855
**
795856
** For best performance, an attempt is made to guess at the byte-order
@@ -823,14 +884,10 @@
823884
unsigned nRate; /* Bytes of input accepted per Keccak iteration */
824885
unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */
825886
unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */
826887
};
827888
828
-/* Allow the following routine to use the B0 variable, which is also
829
-** a macro in the termios.h header file */
830
-#undef B0
831
-
832889
/*
833890
** A single step of the Keccak mixing function for a 1600-bit state
834891
*/
835892
static void KeccakF1600Step(SHA3Context *p){
836893
int i;
@@ -1237,16 +1294,18 @@
12371294
for(i=0; i<p->nRate; i++){
12381295
p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
12391296
}
12401297
return &p->u.x[p->nRate];
12411298
}
1299
+/* End of the hashing logic
1300
+*****************************************************************************/
12421301
12431302
/*
12441303
** Implementation of the sha3(X,SIZE) function.
12451304
**
12461305
** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default
1247
-** size is 256. If X is a BLOB, it is hashed as is.
1306
+** size is 256. If X is a BLOB, it is hashed as is.
12481307
** For all other non-NULL types of input, X is converted into a UTF-8 string
12491308
** and the string is hashed without the trailing 0x00 terminator. The hash
12501309
** of a NULL value is NULL.
12511310
*/
12521311
static void sha3Func(
@@ -1373,14 +1432,10 @@
13731432
sqlite3_free(zMsg);
13741433
return;
13751434
}
13761435
nCol = sqlite3_column_count(pStmt);
13771436
z = sqlite3_sql(pStmt);
1378
- if( z==0 ){
1379
- sqlite3_finalize(pStmt);
1380
- continue;
1381
- }
13821437
n = (int)strlen(z);
13831438
hash_step_vformat(&cx,"S%d:",n);
13841439
SHA3Update(&cx,(unsigned char*)z,n);
13851440
13861441
/* Compute a hash over the result of the query */
@@ -1439,12 +1494,654 @@
14391494
}
14401495
sqlite3_finalize(pStmt);
14411496
}
14421497
sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
14431498
}
1444
-/* End of SHA3 hashing logic copy/pasted from ../ext/misc/shathree.c
1445
-********************************************************************************/
1499
+
1500
+
1501
+#ifdef _WIN32
1502
+__declspec(dllexport)
1503
+#endif
1504
+int sqlite3_shathree_init(
1505
+ sqlite3 *db,
1506
+ char **pzErrMsg,
1507
+ const sqlite3_api_routines *pApi
1508
+){
1509
+ int rc = SQLITE_OK;
1510
+ SQLITE_EXTENSION_INIT2(pApi);
1511
+ (void)pzErrMsg; /* Unused parameter */
1512
+ rc = sqlite3_create_function(db, "sha3", 1, SQLITE_UTF8, 0,
1513
+ sha3Func, 0, 0);
1514
+ if( rc==SQLITE_OK ){
1515
+ rc = sqlite3_create_function(db, "sha3", 2, SQLITE_UTF8, 0,
1516
+ sha3Func, 0, 0);
1517
+ }
1518
+ if( rc==SQLITE_OK ){
1519
+ rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8, 0,
1520
+ sha3QueryFunc, 0, 0);
1521
+ }
1522
+ if( rc==SQLITE_OK ){
1523
+ rc = sqlite3_create_function(db, "sha3_query", 2, SQLITE_UTF8, 0,
1524
+ sha3QueryFunc, 0, 0);
1525
+ }
1526
+ return rc;
1527
+}
1528
+
1529
+/************************* End ../ext/misc/shathree.c ********************/
1530
+/************************* Begin ../ext/misc/fileio.c ******************/
1531
+/*
1532
+** 2014-06-13
1533
+**
1534
+** The author disclaims copyright to this source code. In place of
1535
+** a legal notice, here is a blessing:
1536
+**
1537
+** May you do good and not evil.
1538
+** May you find forgiveness for yourself and forgive others.
1539
+** May you share freely, never taking more than you give.
1540
+**
1541
+******************************************************************************
1542
+**
1543
+** This SQLite extension implements SQL functions readfile() and
1544
+** writefile().
1545
+*/
1546
+SQLITE_EXTENSION_INIT1
1547
+#include <stdio.h>
1548
+
1549
+/*
1550
+** Implementation of the "readfile(X)" SQL function. The entire content
1551
+** of the file named X is read and returned as a BLOB. NULL is returned
1552
+** if the file does not exist or is unreadable.
1553
+*/
1554
+static void readfileFunc(
1555
+ sqlite3_context *context,
1556
+ int argc,
1557
+ sqlite3_value **argv
1558
+){
1559
+ const char *zName;
1560
+ FILE *in;
1561
+ long nIn;
1562
+ void *pBuf;
1563
+
1564
+ zName = (const char*)sqlite3_value_text(argv[0]);
1565
+ if( zName==0 ) return;
1566
+ in = fopen(zName, "rb");
1567
+ if( in==0 ) return;
1568
+ fseek(in, 0, SEEK_END);
1569
+ nIn = ftell(in);
1570
+ rewind(in);
1571
+ pBuf = sqlite3_malloc( nIn );
1572
+ if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
1573
+ sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
1574
+ }else{
1575
+ sqlite3_free(pBuf);
1576
+ }
1577
+ fclose(in);
1578
+}
1579
+
1580
+/*
1581
+** Implementation of the "writefile(X,Y)" SQL function. The argument Y
1582
+** is written into file X. The number of bytes written is returned. Or
1583
+** NULL is returned if something goes wrong, such as being unable to open
1584
+** file X for writing.
1585
+*/
1586
+static void writefileFunc(
1587
+ sqlite3_context *context,
1588
+ int argc,
1589
+ sqlite3_value **argv
1590
+){
1591
+ FILE *out;
1592
+ const char *z;
1593
+ sqlite3_int64 rc;
1594
+ const char *zFile;
1595
+
1596
+ zFile = (const char*)sqlite3_value_text(argv[0]);
1597
+ if( zFile==0 ) return;
1598
+ out = fopen(zFile, "wb");
1599
+ if( out==0 ) return;
1600
+ z = (const char*)sqlite3_value_blob(argv[1]);
1601
+ if( z==0 ){
1602
+ rc = 0;
1603
+ }else{
1604
+ rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
1605
+ }
1606
+ fclose(out);
1607
+ sqlite3_result_int64(context, rc);
1608
+}
1609
+
1610
+
1611
+#ifdef _WIN32
1612
+__declspec(dllexport)
1613
+#endif
1614
+int sqlite3_fileio_init(
1615
+ sqlite3 *db,
1616
+ char **pzErrMsg,
1617
+ const sqlite3_api_routines *pApi
1618
+){
1619
+ int rc = SQLITE_OK;
1620
+ SQLITE_EXTENSION_INIT2(pApi);
1621
+ (void)pzErrMsg; /* Unused parameter */
1622
+ rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
1623
+ readfileFunc, 0, 0);
1624
+ if( rc==SQLITE_OK ){
1625
+ rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
1626
+ writefileFunc, 0, 0);
1627
+ }
1628
+ return rc;
1629
+}
1630
+
1631
+/************************* End ../ext/misc/fileio.c ********************/
1632
+/************************* Begin ../ext/misc/completion.c ******************/
1633
+/*
1634
+** 2017-07-10
1635
+**
1636
+** The author disclaims copyright to this source code. In place of
1637
+** a legal notice, here is a blessing:
1638
+**
1639
+** May you do good and not evil.
1640
+** May you find forgiveness for yourself and forgive others.
1641
+** May you share freely, never taking more than you give.
1642
+**
1643
+*************************************************************************
1644
+**
1645
+** This file implements an eponymous virtual table that returns suggested
1646
+** completions for a partial SQL input.
1647
+**
1648
+** Suggested usage:
1649
+**
1650
+** SELECT DISTINCT candidate COLLATE nocase
1651
+** FROM completion($prefix,$wholeline)
1652
+** ORDER BY 1;
1653
+**
1654
+** The two query parameters are optional. $prefix is the text of the
1655
+** current word being typed and that is to be completed. $wholeline is
1656
+** the complete input line, used for context.
1657
+**
1658
+** The raw completion() table might return the same candidate multiple
1659
+** times, for example if the same column name is used to two or more
1660
+** tables. And the candidates are returned in an arbitrary order. Hence,
1661
+** the DISTINCT and ORDER BY are recommended.
1662
+**
1663
+** This virtual table operates at the speed of human typing, and so there
1664
+** is no attempt to make it fast. Even a slow implementation will be much
1665
+** faster than any human can type.
1666
+**
1667
+*/
1668
+SQLITE_EXTENSION_INIT1
1669
+#include <assert.h>
1670
+#include <string.h>
1671
+#include <ctype.h>
1672
+
1673
+#ifndef SQLITE_OMIT_VIRTUALTABLE
1674
+
1675
+/* completion_vtab is a subclass of sqlite3_vtab which will
1676
+** serve as the underlying representation of a completion virtual table
1677
+*/
1678
+typedef struct completion_vtab completion_vtab;
1679
+struct completion_vtab {
1680
+ sqlite3_vtab base; /* Base class - must be first */
1681
+ sqlite3 *db; /* Database connection for this completion vtab */
1682
+};
1683
+
1684
+/* completion_cursor is a subclass of sqlite3_vtab_cursor which will
1685
+** serve as the underlying representation of a cursor that scans
1686
+** over rows of the result
1687
+*/
1688
+typedef struct completion_cursor completion_cursor;
1689
+struct completion_cursor {
1690
+ sqlite3_vtab_cursor base; /* Base class - must be first */
1691
+ sqlite3 *db; /* Database connection for this cursor */
1692
+ int nPrefix, nLine; /* Number of bytes in zPrefix and zLine */
1693
+ char *zPrefix; /* The prefix for the word we want to complete */
1694
+ char *zLine; /* The whole that we want to complete */
1695
+ const char *zCurrentRow; /* Current output row */
1696
+ sqlite3_stmt *pStmt; /* Current statement */
1697
+ sqlite3_int64 iRowid; /* The rowid */
1698
+ int ePhase; /* Current phase */
1699
+ int j; /* inter-phase counter */
1700
+};
1701
+
1702
+/* Values for ePhase:
1703
+*/
1704
+#define COMPLETION_FIRST_PHASE 1
1705
+#define COMPLETION_KEYWORDS 1
1706
+#define COMPLETION_PRAGMAS 2
1707
+#define COMPLETION_FUNCTIONS 3
1708
+#define COMPLETION_COLLATIONS 4
1709
+#define COMPLETION_INDEXES 5
1710
+#define COMPLETION_TRIGGERS 6
1711
+#define COMPLETION_DATABASES 7
1712
+#define COMPLETION_TABLES 8
1713
+#define COMPLETION_COLUMNS 9
1714
+#define COMPLETION_MODULES 10
1715
+#define COMPLETION_EOF 11
1716
+
1717
+/*
1718
+** The completionConnect() method is invoked to create a new
1719
+** completion_vtab that describes the completion virtual table.
1720
+**
1721
+** Think of this routine as the constructor for completion_vtab objects.
1722
+**
1723
+** All this routine needs to do is:
1724
+**
1725
+** (1) Allocate the completion_vtab object and initialize all fields.
1726
+**
1727
+** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
1728
+** result set of queries against completion will look like.
1729
+*/
1730
+static int completionConnect(
1731
+ sqlite3 *db,
1732
+ void *pAux,
1733
+ int argc, const char *const*argv,
1734
+ sqlite3_vtab **ppVtab,
1735
+ char **pzErr
1736
+){
1737
+ completion_vtab *pNew;
1738
+ int rc;
1739
+
1740
+/* Column numbers */
1741
+#define COMPLETION_COLUMN_CANDIDATE 0 /* Suggested completion of the input */
1742
+#define COMPLETION_COLUMN_PREFIX 1 /* Prefix of the word to be completed */
1743
+#define COMPLETION_COLUMN_WHOLELINE 2 /* Entire line seen so far */
1744
+#define COMPLETION_COLUMN_PHASE 3 /* ePhase - used for debugging only */
1745
+
1746
+ rc = sqlite3_declare_vtab(db,
1747
+ "CREATE TABLE x("
1748
+ " candidate TEXT,"
1749
+ " prefix TEXT HIDDEN,"
1750
+ " wholeline TEXT HIDDEN,"
1751
+ " phase INT HIDDEN" /* Used for debugging only */
1752
+ ")");
1753
+ if( rc==SQLITE_OK ){
1754
+ pNew = sqlite3_malloc( sizeof(*pNew) );
1755
+ *ppVtab = (sqlite3_vtab*)pNew;
1756
+ if( pNew==0 ) return SQLITE_NOMEM;
1757
+ memset(pNew, 0, sizeof(*pNew));
1758
+ pNew->db = db;
1759
+ }
1760
+ return rc;
1761
+}
1762
+
1763
+/*
1764
+** This method is the destructor for completion_cursor objects.
1765
+*/
1766
+static int completionDisconnect(sqlite3_vtab *pVtab){
1767
+ sqlite3_free(pVtab);
1768
+ return SQLITE_OK;
1769
+}
1770
+
1771
+/*
1772
+** Constructor for a new completion_cursor object.
1773
+*/
1774
+static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
1775
+ completion_cursor *pCur;
1776
+ pCur = sqlite3_malloc( sizeof(*pCur) );
1777
+ if( pCur==0 ) return SQLITE_NOMEM;
1778
+ memset(pCur, 0, sizeof(*pCur));
1779
+ pCur->db = ((completion_vtab*)p)->db;
1780
+ *ppCursor = &pCur->base;
1781
+ return SQLITE_OK;
1782
+}
1783
+
1784
+/*
1785
+** Reset the completion_cursor.
1786
+*/
1787
+static void completionCursorReset(completion_cursor *pCur){
1788
+ sqlite3_free(pCur->zPrefix); pCur->zPrefix = 0; pCur->nPrefix = 0;
1789
+ sqlite3_free(pCur->zLine); pCur->zLine = 0; pCur->nLine = 0;
1790
+ sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;
1791
+ pCur->j = 0;
1792
+}
1793
+
1794
+/*
1795
+** Destructor for a completion_cursor.
1796
+*/
1797
+static int completionClose(sqlite3_vtab_cursor *cur){
1798
+ completionCursorReset((completion_cursor*)cur);
1799
+ sqlite3_free(cur);
1800
+ return SQLITE_OK;
1801
+}
1802
+
1803
+/*
1804
+** All SQL keywords understood by SQLite
1805
+*/
1806
+static const char *completionKwrds[] = {
1807
+ "ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ANALYZE", "AND", "AS",
1808
+ "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN", "BY",
1809
+ "CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT",
1810
+ "CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT_DATE",
1811
+ "CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE",
1812
+ "DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DROP", "EACH",
1813
+ "ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUSIVE", "EXISTS", "EXPLAIN",
1814
+ "FAIL", "FOR", "FOREIGN", "FROM", "FULL", "GLOB", "GROUP", "HAVING", "IF",
1815
+ "IGNORE", "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER",
1816
+ "INSERT", "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY",
1817
+ "LEFT", "LIKE", "LIMIT", "MATCH", "NATURAL", "NO", "NOT", "NOTNULL",
1818
+ "NULL", "OF", "OFFSET", "ON", "OR", "ORDER", "OUTER", "PLAN", "PRAGMA",
1819
+ "PRIMARY", "QUERY", "RAISE", "RECURSIVE", "REFERENCES", "REGEXP",
1820
+ "REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RIGHT",
1821
+ "ROLLBACK", "ROW", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP",
1822
+ "TEMPORARY", "THEN", "TO", "TRANSACTION", "TRIGGER", "UNION", "UNIQUE",
1823
+ "UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL", "WHEN", "WHERE",
1824
+ "WITH", "WITHOUT",
1825
+};
1826
+
1827
+/*
1828
+** Advance a completion_cursor to its next row of output.
1829
+**
1830
+** The ->ePhase, ->j, and ->pStmt fields of the completion_cursor object
1831
+** record the current state of the scan. This routine sets ->zCurrentRow
1832
+** to the current row of output and then returns. If no more rows remain,
1833
+** then ->ePhase is set to COMPLETION_EOF which will signal the virtual
1834
+** table that has reached the end of its scan.
1835
+**
1836
+** The current implementation just lists potential identifiers and
1837
+** keywords and filters them by zPrefix. Future enhancements should
1838
+** take zLine into account to try to restrict the set of identifiers and
1839
+** keywords based on what would be legal at the current point of input.
1840
+*/
1841
+static int completionNext(sqlite3_vtab_cursor *cur){
1842
+ completion_cursor *pCur = (completion_cursor*)cur;
1843
+ int eNextPhase = 0; /* Next phase to try if current phase reaches end */
1844
+ int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
1845
+ pCur->iRowid++;
1846
+ while( pCur->ePhase!=COMPLETION_EOF ){
1847
+ switch( pCur->ePhase ){
1848
+ case COMPLETION_KEYWORDS: {
1849
+ if( pCur->j >= sizeof(completionKwrds)/sizeof(completionKwrds[0]) ){
1850
+ pCur->zCurrentRow = 0;
1851
+ pCur->ePhase = COMPLETION_DATABASES;
1852
+ }else{
1853
+ pCur->zCurrentRow = completionKwrds[pCur->j++];
1854
+ }
1855
+ iCol = -1;
1856
+ break;
1857
+ }
1858
+ case COMPLETION_DATABASES: {
1859
+ if( pCur->pStmt==0 ){
1860
+ sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1,
1861
+ &pCur->pStmt, 0);
1862
+ }
1863
+ iCol = 1;
1864
+ eNextPhase = COMPLETION_TABLES;
1865
+ break;
1866
+ }
1867
+ case COMPLETION_TABLES: {
1868
+ if( pCur->pStmt==0 ){
1869
+ sqlite3_stmt *pS2;
1870
+ char *zSql = 0;
1871
+ const char *zSep = "";
1872
+ sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1873
+ while( sqlite3_step(pS2)==SQLITE_ROW ){
1874
+ const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
1875
+ zSql = sqlite3_mprintf(
1876
+ "%z%s"
1877
+ "SELECT name FROM \"%w\".sqlite_master"
1878
+ " WHERE type='table'",
1879
+ zSql, zSep, zDb
1880
+ );
1881
+ if( zSql==0 ) return SQLITE_NOMEM;
1882
+ zSep = " UNION ";
1883
+ }
1884
+ sqlite3_finalize(pS2);
1885
+ sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
1886
+ sqlite3_free(zSql);
1887
+ }
1888
+ iCol = 0;
1889
+ eNextPhase = COMPLETION_COLUMNS;
1890
+ break;
1891
+ }
1892
+ case COMPLETION_COLUMNS: {
1893
+ if( pCur->pStmt==0 ){
1894
+ sqlite3_stmt *pS2;
1895
+ char *zSql = 0;
1896
+ const char *zSep = "";
1897
+ sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1898
+ while( sqlite3_step(pS2)==SQLITE_ROW ){
1899
+ const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
1900
+ zSql = sqlite3_mprintf(
1901
+ "%z%s"
1902
+ "SELECT pti.name FROM \"%w\".sqlite_master AS sm"
1903
+ " JOIN pragma_table_info(sm.name,%Q) AS pti"
1904
+ " WHERE sm.type='table'",
1905
+ zSql, zSep, zDb, zDb
1906
+ );
1907
+ if( zSql==0 ) return SQLITE_NOMEM;
1908
+ zSep = " UNION ";
1909
+ }
1910
+ sqlite3_finalize(pS2);
1911
+ sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
1912
+ sqlite3_free(zSql);
1913
+ }
1914
+ iCol = 0;
1915
+ eNextPhase = COMPLETION_EOF;
1916
+ break;
1917
+ }
1918
+ }
1919
+ if( iCol<0 ){
1920
+ /* This case is when the phase presets zCurrentRow */
1921
+ if( pCur->zCurrentRow==0 ) continue;
1922
+ }else{
1923
+ if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){
1924
+ /* Extract the next row of content */
1925
+ pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
1926
+ }else{
1927
+ /* When all rows are finished, advance to the next phase */
1928
+ sqlite3_finalize(pCur->pStmt);
1929
+ pCur->pStmt = 0;
1930
+ pCur->ePhase = eNextPhase;
1931
+ continue;
1932
+ }
1933
+ }
1934
+ if( pCur->nPrefix==0 ) break;
1935
+ if( sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0 ){
1936
+ break;
1937
+ }
1938
+ }
1939
+
1940
+ return SQLITE_OK;
1941
+}
1942
+
1943
+/*
1944
+** Return values of columns for the row at which the completion_cursor
1945
+** is currently pointing.
1946
+*/
1947
+static int completionColumn(
1948
+ sqlite3_vtab_cursor *cur, /* The cursor */
1949
+ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
1950
+ int i /* Which column to return */
1951
+){
1952
+ completion_cursor *pCur = (completion_cursor*)cur;
1953
+ switch( i ){
1954
+ case COMPLETION_COLUMN_CANDIDATE: {
1955
+ sqlite3_result_text(ctx, pCur->zCurrentRow, -1, SQLITE_TRANSIENT);
1956
+ break;
1957
+ }
1958
+ case COMPLETION_COLUMN_PREFIX: {
1959
+ sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);
1960
+ break;
1961
+ }
1962
+ case COMPLETION_COLUMN_WHOLELINE: {
1963
+ sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);
1964
+ break;
1965
+ }
1966
+ case COMPLETION_COLUMN_PHASE: {
1967
+ sqlite3_result_int(ctx, pCur->ePhase);
1968
+ break;
1969
+ }
1970
+ }
1971
+ return SQLITE_OK;
1972
+}
1973
+
1974
+/*
1975
+** Return the rowid for the current row. In this implementation, the
1976
+** rowid is the same as the output value.
1977
+*/
1978
+static int completionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
1979
+ completion_cursor *pCur = (completion_cursor*)cur;
1980
+ *pRowid = pCur->iRowid;
1981
+ return SQLITE_OK;
1982
+}
1983
+
1984
+/*
1985
+** Return TRUE if the cursor has been moved off of the last
1986
+** row of output.
1987
+*/
1988
+static int completionEof(sqlite3_vtab_cursor *cur){
1989
+ completion_cursor *pCur = (completion_cursor*)cur;
1990
+ return pCur->ePhase >= COMPLETION_EOF;
1991
+}
1992
+
1993
+/*
1994
+** This method is called to "rewind" the completion_cursor object back
1995
+** to the first row of output. This method is always called at least
1996
+** once prior to any call to completionColumn() or completionRowid() or
1997
+** completionEof().
1998
+*/
1999
+static int completionFilter(
2000
+ sqlite3_vtab_cursor *pVtabCursor,
2001
+ int idxNum, const char *idxStr,
2002
+ int argc, sqlite3_value **argv
2003
+){
2004
+ completion_cursor *pCur = (completion_cursor *)pVtabCursor;
2005
+ int iArg = 0;
2006
+ completionCursorReset(pCur);
2007
+ if( idxNum & 1 ){
2008
+ pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);
2009
+ if( pCur->nPrefix>0 ){
2010
+ pCur->zPrefix = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
2011
+ if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
2012
+ }
2013
+ iArg++;
2014
+ }
2015
+ if( idxNum & 2 ){
2016
+ pCur->nLine = sqlite3_value_bytes(argv[iArg]);
2017
+ if( pCur->nLine>0 ){
2018
+ pCur->zLine = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
2019
+ if( pCur->zLine==0 ) return SQLITE_NOMEM;
2020
+ }
2021
+ iArg++;
2022
+ }
2023
+ if( pCur->zLine!=0 && pCur->zPrefix==0 ){
2024
+ int i = pCur->nLine;
2025
+ while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
2026
+ i--;
2027
+ }
2028
+ pCur->nPrefix = pCur->nLine - i;
2029
+ if( pCur->nPrefix>0 ){
2030
+ pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
2031
+ if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
2032
+ }
2033
+ }
2034
+ pCur->iRowid = 0;
2035
+ pCur->ePhase = COMPLETION_FIRST_PHASE;
2036
+ return completionNext(pVtabCursor);
2037
+}
2038
+
2039
+/*
2040
+** SQLite will invoke this method one or more times while planning a query
2041
+** that uses the completion virtual table. This routine needs to create
2042
+** a query plan for each invocation and compute an estimated cost for that
2043
+** plan.
2044
+**
2045
+** There are two hidden parameters that act as arguments to the table-valued
2046
+** function: "prefix" and "wholeline". Bit 0 of idxNum is set if "prefix"
2047
+** is available and bit 1 is set if "wholeline" is available.
2048
+*/
2049
+static int completionBestIndex(
2050
+ sqlite3_vtab *tab,
2051
+ sqlite3_index_info *pIdxInfo
2052
+){
2053
+ int i; /* Loop over constraints */
2054
+ int idxNum = 0; /* The query plan bitmask */
2055
+ int prefixIdx = -1; /* Index of the start= constraint, or -1 if none */
2056
+ int wholelineIdx = -1; /* Index of the stop= constraint, or -1 if none */
2057
+ int nArg = 0; /* Number of arguments that completeFilter() expects */
2058
+ const struct sqlite3_index_constraint *pConstraint;
2059
+
2060
+ pConstraint = pIdxInfo->aConstraint;
2061
+ for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
2062
+ if( pConstraint->usable==0 ) continue;
2063
+ if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
2064
+ switch( pConstraint->iColumn ){
2065
+ case COMPLETION_COLUMN_PREFIX:
2066
+ prefixIdx = i;
2067
+ idxNum |= 1;
2068
+ break;
2069
+ case COMPLETION_COLUMN_WHOLELINE:
2070
+ wholelineIdx = i;
2071
+ idxNum |= 2;
2072
+ break;
2073
+ }
2074
+ }
2075
+ if( prefixIdx>=0 ){
2076
+ pIdxInfo->aConstraintUsage[prefixIdx].argvIndex = ++nArg;
2077
+ pIdxInfo->aConstraintUsage[prefixIdx].omit = 1;
2078
+ }
2079
+ if( wholelineIdx>=0 ){
2080
+ pIdxInfo->aConstraintUsage[wholelineIdx].argvIndex = ++nArg;
2081
+ pIdxInfo->aConstraintUsage[wholelineIdx].omit = 1;
2082
+ }
2083
+ pIdxInfo->idxNum = idxNum;
2084
+ pIdxInfo->estimatedCost = (double)5000 - 1000*nArg;
2085
+ pIdxInfo->estimatedRows = 500 - 100*nArg;
2086
+ return SQLITE_OK;
2087
+}
2088
+
2089
+/*
2090
+** This following structure defines all the methods for the
2091
+** completion virtual table.
2092
+*/
2093
+static sqlite3_module completionModule = {
2094
+ 0, /* iVersion */
2095
+ 0, /* xCreate */
2096
+ completionConnect, /* xConnect */
2097
+ completionBestIndex, /* xBestIndex */
2098
+ completionDisconnect, /* xDisconnect */
2099
+ 0, /* xDestroy */
2100
+ completionOpen, /* xOpen - open a cursor */
2101
+ completionClose, /* xClose - close a cursor */
2102
+ completionFilter, /* xFilter - configure scan constraints */
2103
+ completionNext, /* xNext - advance a cursor */
2104
+ completionEof, /* xEof - check for end of scan */
2105
+ completionColumn, /* xColumn - read data */
2106
+ completionRowid, /* xRowid - read data */
2107
+ 0, /* xUpdate */
2108
+ 0, /* xBegin */
2109
+ 0, /* xSync */
2110
+ 0, /* xCommit */
2111
+ 0, /* xRollback */
2112
+ 0, /* xFindMethod */
2113
+ 0, /* xRename */
2114
+};
2115
+
2116
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
2117
+
2118
+int sqlite3CompletionVtabInit(sqlite3 *db){
2119
+ int rc = SQLITE_OK;
2120
+#ifndef SQLITE_OMIT_VIRTUALTABLE
2121
+ rc = sqlite3_create_module(db, "completion", &completionModule, 0);
2122
+#endif
2123
+ return rc;
2124
+}
2125
+
2126
+#ifdef _WIN32
2127
+__declspec(dllexport)
2128
+#endif
2129
+int sqlite3_completion_init(
2130
+ sqlite3 *db,
2131
+ char **pzErrMsg,
2132
+ const sqlite3_api_routines *pApi
2133
+){
2134
+ int rc = SQLITE_OK;
2135
+ SQLITE_EXTENSION_INIT2(pApi);
2136
+#ifndef SQLITE_OMIT_VIRTUALTABLE
2137
+ rc = sqlite3CompletionVtabInit(db);
2138
+#endif
2139
+ return rc;
2140
+}
2141
+
2142
+/************************* End ../ext/misc/completion.c ********************/
14462143
14472144
#if defined(SQLITE_ENABLE_SESSION)
14482145
/*
14492146
** State information for a single open session
14502147
*/
@@ -1521,12 +2218,13 @@
15212218
#define SHFLG_Scratch 0x00000001 /* The --scratch option is used */
15222219
#define SHFLG_Pagecache 0x00000002 /* The --pagecache option is used */
15232220
#define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */
15242221
#define SHFLG_Backslash 0x00000008 /* The --backslash option is used */
15252222
#define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */
1526
-#define SHFLG_CountChanges 0x00000020 /* .changes setting */
1527
-#define SHFLG_Echo 0x00000040 /* .echo or --echo setting */
2223
+#define SHFLG_Newlines 0x00000020 /* .dump --newline flag */
2224
+#define SHFLG_CountChanges 0x00000040 /* .changes setting */
2225
+#define SHFLG_Echo 0x00000080 /* .echo or --echo setting */
15282226
15292227
/*
15302228
** Macros for testing and setting shellFlgs
15312229
*/
15322230
#define ShellHasFlag(P,X) (((P)->shellFlgs & (X))!=0)
@@ -2193,11 +2891,15 @@
21932891
for(i=0; i<nArg; i++){
21942892
raw_printf(p->out, i>0 ? "," : " VALUES(");
21952893
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
21962894
utf8_printf(p->out,"NULL");
21972895
}else if( aiType && aiType[i]==SQLITE_TEXT ){
2198
- output_quoted_escaped_string(p->out, azArg[i]);
2896
+ if( ShellHasFlag(p, SHFLG_Newlines) ){
2897
+ output_quoted_string(p->out, azArg[i]);
2898
+ }else{
2899
+ output_quoted_escaped_string(p->out, azArg[i]);
2900
+ }
21992901
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
22002902
utf8_printf(p->out,"%s", azArg[i]);
22012903
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
22022904
char z[50];
22032905
double r = sqlite3_column_double(p->pStmt, i);
@@ -2207,10 +2909,12 @@
22072909
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
22082910
int nBlob = sqlite3_column_bytes(p->pStmt, i);
22092911
output_hex_blob(p->out, pBlob, nBlob);
22102912
}else if( isNumber(azArg[i], 0) ){
22112913
utf8_printf(p->out,"%s", azArg[i]);
2914
+ }else if( ShellHasFlag(p, SHFLG_Newlines) ){
2915
+ output_quoted_string(p->out, azArg[i]);
22122916
}else{
22132917
output_quoted_escaped_string(p->out, azArg[i]);
22142918
}
22152919
}
22162920
raw_printf(p->out,");\n");
@@ -3325,11 +4029,13 @@
33254029
" If TABLE specified, only dump tables matching\n"
33264030
" LIKE pattern TABLE.\n"
33274031
".echo on|off Turn command echo on or off\n"
33284032
".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
33294033
".exit Exit this program\n"
3330
- ".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"
4034
+/* Because explain mode comes on automatically now, the ".explain" mode
4035
+** is removed from the help screen. It is still supported for legacy, however */
4036
+/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/
33314037
".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
33324038
".headers on|off Turn display of headers on or off\n"
33334039
".help Show this message\n"
33344040
".import FILE TABLE Import data from FILE into TABLE\n"
33354041
#ifndef SQLITE_OMIT_TEST_CONTROL
@@ -3460,62 +4166,10 @@
34604166
pBuf[nIn] = 0;
34614167
if( pnByte ) *pnByte = nIn;
34624168
return pBuf;
34634169
}
34644170
3465
-/*
3466
-** Implementation of the "readfile(X)" SQL function. The entire content
3467
-** of the file named X is read and returned as a BLOB. NULL is returned
3468
-** if the file does not exist or is unreadable.
3469
-*/
3470
-static void readfileFunc(
3471
- sqlite3_context *context,
3472
- int argc,
3473
- sqlite3_value **argv
3474
-){
3475
- const char *zName;
3476
- void *pBuf;
3477
- int nBuf;
3478
-
3479
- UNUSED_PARAMETER(argc);
3480
- zName = (const char*)sqlite3_value_text(argv[0]);
3481
- if( zName==0 ) return;
3482
- pBuf = readFile(zName, &nBuf);
3483
- if( pBuf ) sqlite3_result_blob(context, pBuf, nBuf, sqlite3_free);
3484
-}
3485
-
3486
-/*
3487
-** Implementation of the "writefile(X,Y)" SQL function. The argument Y
3488
-** is written into file X. The number of bytes written is returned. Or
3489
-** NULL is returned if something goes wrong, such as being unable to open
3490
-** file X for writing.
3491
-*/
3492
-static void writefileFunc(
3493
- sqlite3_context *context,
3494
- int argc,
3495
- sqlite3_value **argv
3496
-){
3497
- FILE *out;
3498
- const char *z;
3499
- sqlite3_int64 rc;
3500
- const char *zFile;
3501
-
3502
- UNUSED_PARAMETER(argc);
3503
- zFile = (const char*)sqlite3_value_text(argv[0]);
3504
- if( zFile==0 ) return;
3505
- out = fopen(zFile, "wb");
3506
- if( out==0 ) return;
3507
- z = (const char*)sqlite3_value_blob(argv[1]);
3508
- if( z==0 ){
3509
- rc = 0;
3510
- }else{
3511
- rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
3512
- }
3513
- fclose(out);
3514
- sqlite3_result_int64(context, rc);
3515
-}
3516
-
35174171
#if defined(SQLITE_ENABLE_SESSION)
35184172
/*
35194173
** Close a single OpenSession object and release all of its associated
35204174
** resources.
35214175
*/
@@ -3577,22 +4231,76 @@
35774231
exit(1);
35784232
}
35794233
#ifndef SQLITE_OMIT_LOAD_EXTENSION
35804234
sqlite3_enable_load_extension(p->db, 1);
35814235
#endif
3582
- sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
3583
- readfileFunc, 0, 0);
3584
- sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
3585
- writefileFunc, 0, 0);
3586
- sqlite3_create_function(p->db, "sha3", 1, SQLITE_UTF8, 0,
3587
- sha3Func, 0, 0);
3588
- sqlite3_create_function(p->db, "sha3", 2, SQLITE_UTF8, 0,
3589
- sha3Func, 0, 0);
3590
- sqlite3_create_function(p->db, "sha3_query", 1, SQLITE_UTF8, 0,
3591
- sha3QueryFunc, 0, 0);
3592
- sqlite3_create_function(p->db, "sha3_query", 2, SQLITE_UTF8, 0,
3593
- sha3QueryFunc, 0, 0);
4236
+ sqlite3_fileio_init(p->db, 0, 0);
4237
+ sqlite3_shathree_init(p->db, 0, 0);
4238
+ sqlite3_completion_init(p->db, 0, 0);
35944239
sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
35954240
shellAddSchemaName, 0, 0);
3596
-
35974241
}
35984242
}
4243
+
4244
+#if HAVE_READLINE || HAVE_EDITLINE
4245
+/*
4246
+** Readline completion callbacks
4247
+*/
4248
+static char *readline_completion_generator(const char *text, int state){
4249
+ static sqlite3_stmt *pStmt = 0;
4250
+ char *zRet;
4251
+ if( state==0 ){
4252
+ char *zSql;
4253
+ int rc;
4254
+ sqlite3_finalize(pStmt);
4255
+ zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4256
+ " FROM completion(%Q) ORDER BY 1", text);
4257
+ sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4258
+ sqlite3_free(zSql);
4259
+ }
4260
+ if( sqlite3_step(pStmt)==SQLITE_ROW ){
4261
+ zRet = strdup(sqlite3_column_text(pStmt, 0));
4262
+ }else{
4263
+ sqlite3_finalize(pStmt);
4264
+ pStmt = 0;
4265
+ zRet = 0;
4266
+ }
4267
+ return zRet;
4268
+}
4269
+static char **readline_completion(const char *zText, int iStart, int iEnd){
4270
+ rl_attempted_completion_over = 1;
4271
+ return rl_completion_matches(zText, readline_completion_generator);
4272
+}
4273
+
4274
+#elif HAVE_LINENOISE
4275
+/*
4276
+** Linenoise completion callback
4277
+*/
4278
+static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
4279
+ int nLine = (int)strlen(zLine);
4280
+ int i, iStart;
4281
+ sqlite3_stmt *pStmt = 0;
4282
+ char *zSql;
4283
+ char zBuf[1000];
4284
+
4285
+ if( nLine>sizeof(zBuf)-30 ) return;
4286
+ if( zLine[0]=='.' ) return;
4287
+ for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
4288
+ if( i==nLine-1 ) return;
4289
+ iStart = i+1;
4290
+ memcpy(zBuf, zLine, iStart);
4291
+ zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4292
+ " FROM completion(%Q,%Q) ORDER BY 1",
4293
+ &zLine[iStart], zLine);
4294
+ sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4295
+ sqlite3_free(zSql);
4296
+ sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
4297
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
4298
+ const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
4299
+ int nCompletion = sqlite3_column_bytes(pStmt, 0);
4300
+ if( iStart+nCompletion < sizeof(zBuf)-1 ){
4301
+ memcpy(zBuf+iStart, zCompletion, nCompletion+1);
4302
+ linenoiseAddCompletion(lc, zBuf);
4303
+ }
4304
+ }
4305
+ sqlite3_finalize(pStmt);
4306
+}
@@ -3599,5 +4307,6 @@
4307
+#endif
35994308
36004309
/*
36014310
** Do C-language style dequoting.
36024311
**
36034312
** \a -> alarm
@@ -4926,11 +5635,11 @@
49265635
49275636
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
49285637
const char *zLike = 0;
49295638
int i;
49305639
int savedShowHeader = p->showHeader;
4931
- ShellClearFlag(p, SHFLG_PreserveRowid);
5640
+ ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
49325641
for(i=1; i<nArg; i++){
49335642
if( azArg[i][0]=='-' ){
49345643
const char *z = azArg[i]+1;
49355644
if( z[0]=='-' ) z++;
49365645
if( strcmp(z,"preserve-rowids")==0 ){
@@ -4941,17 +5650,21 @@
49415650
goto meta_command_exit;
49425651
#else
49435652
ShellSetFlag(p, SHFLG_PreserveRowid);
49445653
#endif
49455654
}else
5655
+ if( strcmp(z,"newlines")==0 ){
5656
+ ShellSetFlag(p, SHFLG_Newlines);
5657
+ }else
49465658
{
49475659
raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
49485660
rc = 1;
49495661
goto meta_command_exit;
49505662
}
49515663
}else if( zLike ){
4952
- raw_printf(stderr, "Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?\n");
5664
+ raw_printf(stderr, "Usage: .dump ?--preserve-rowids? "
5665
+ "?--newlines? ?LIKE-PATTERN?\n");
49535666
rc = 1;
49545667
goto meta_command_exit;
49555668
}else{
49565669
zLike = azArg[i];
49575670
}
@@ -5033,10 +5746,12 @@
50335746
if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
50345747
if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
50355748
rc = 2;
50365749
}else
50375750
5751
+ /* The ".explain" command is automatic now. It is largely pointless. It
5752
+ ** retained purely for backwards compatibility */
50385753
if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
50395754
int val = 1;
50405755
if( nArg>=2 ){
50415756
if( strcmp(azArg[1],"auto")==0 ){
50425757
val = 99;
@@ -5549,11 +6264,13 @@
55496264
p->mode = MODE_Quote;
55506265
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
55516266
p->mode = MODE_Ascii;
55526267
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
55536268
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
5554
- }else {
6269
+ }else if( nArg==1 ){
6270
+ raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
6271
+ }else{
55556272
raw_printf(stderr, "Error: mode should be one of: "
55566273
"ascii column csv html insert line list quote tabs tcl\n");
55576274
rc = 1;
55586275
}
55596276
p->cMode = p->mode;
@@ -5821,12 +6538,18 @@
58216538
rc = 1;
58226539
goto meta_command_exit;
58236540
}
58246541
if( zDiv ){
58256542
sqlite3_stmt *pStmt = 0;
5826
- sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list",
5827
- -1, &pStmt, 0);
6543
+ rc = sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list",
6544
+ -1, &pStmt, 0);
6545
+ if( rc ){
6546
+ utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
6547
+ sqlite3_finalize(pStmt);
6548
+ rc = 1;
6549
+ goto meta_command_exit;
6550
+ }
58286551
appendText(&sSelect, "SELECT sql FROM", 0);
58296552
iSchema = 0;
58306553
while( sqlite3_step(pStmt)==SQLITE_ROW ){
58316554
const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);
58326555
char zScNum[30];
@@ -7179,10 +7902,11 @@
71797902
" -multiplex enable the multiplexor VFS\n"
71807903
#endif
71817904
" -newline SEP set output row separator. Default: '\\n'\n"
71827905
" -nullvalue TEXT set text string for NULL values. Default ''\n"
71837906
" -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
7907
+ " -quote set output mode to 'quote'\n"
71847908
" -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
71857909
" -separator SEP set output column separator. Default: '|'\n"
71867910
" -stats print memory stats before each finalize\n"
71877911
" -version show SQLite version\n"
71887912
" -vfs NAME use NAME as the default VFS\n"
@@ -7474,10 +8198,12 @@
74748198
i++;
74758199
}else if( strcmp(z,"-html")==0 ){
74768200
data.mode = MODE_Html;
74778201
}else if( strcmp(z,"-list")==0 ){
74788202
data.mode = MODE_List;
8203
+ }else if( strcmp(z,"-quote")==0 ){
8204
+ data.mode = MODE_Quote;
74798205
}else if( strcmp(z,"-line")==0 ){
74808206
data.mode = MODE_Line;
74818207
}else if( strcmp(z,"-column")==0 ){
74828208
data.mode = MODE_Column;
74838209
}else if( strcmp(z,"-csv")==0 ){
@@ -7625,10 +8351,15 @@
76258351
if( (zHistory = malloc(nHistory))!=0 ){
76268352
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
76278353
}
76288354
}
76298355
if( zHistory ){ shell_read_history(zHistory); }
8356
+#if HAVE_READLINE || HAVE_EDITLINE
8357
+ rl_attempted_completion_function = readline_completion;
8358
+#elif HAVE_LINENOISE
8359
+ linenoiseSetCompletionCallback(linenoise_completion);
8360
+#endif
76308361
rc = process_input(&data, 0);
76318362
if( zHistory ){
76328363
shell_stifle_history(100);
76338364
shell_write_history(zHistory);
76348365
free(zHistory);
@@ -7648,5 +8379,6 @@
76488379
for(i=0; i<argc; i++) sqlite3_free(argv[i]);
76498380
sqlite3_free(argv);
76508381
#endif
76518382
return rc;
76528383
}
8384
+
76538385
--- src/shell.c
+++ src/shell.c
@@ -1,5 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1 /*
2 ** 2001 September 15
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
@@ -782,14 +800,57 @@
782 }
783 }
784 sqlite3_result_value(pCtx, apVal[0]);
785 }
786
787 /******************************************************************************
788 ** SHA3 hash implementation copied from ../ext/misc/shathree.c
 
 
 
789 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790 typedef sqlite3_uint64 u64;
 
 
 
 
791 /*
792 ** Macros to determine whether the machine is big or little endian,
793 ** and whether or not that determination is run-time or compile-time.
794 **
795 ** For best performance, an attempt is made to guess at the byte-order
@@ -823,14 +884,10 @@
823 unsigned nRate; /* Bytes of input accepted per Keccak iteration */
824 unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */
825 unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */
826 };
827
828 /* Allow the following routine to use the B0 variable, which is also
829 ** a macro in the termios.h header file */
830 #undef B0
831
832 /*
833 ** A single step of the Keccak mixing function for a 1600-bit state
834 */
835 static void KeccakF1600Step(SHA3Context *p){
836 int i;
@@ -1237,16 +1294,18 @@
1237 for(i=0; i<p->nRate; i++){
1238 p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
1239 }
1240 return &p->u.x[p->nRate];
1241 }
 
 
1242
1243 /*
1244 ** Implementation of the sha3(X,SIZE) function.
1245 **
1246 ** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default
1247 ** size is 256. If X is a BLOB, it is hashed as is.
1248 ** For all other non-NULL types of input, X is converted into a UTF-8 string
1249 ** and the string is hashed without the trailing 0x00 terminator. The hash
1250 ** of a NULL value is NULL.
1251 */
1252 static void sha3Func(
@@ -1373,14 +1432,10 @@
1373 sqlite3_free(zMsg);
1374 return;
1375 }
1376 nCol = sqlite3_column_count(pStmt);
1377 z = sqlite3_sql(pStmt);
1378 if( z==0 ){
1379 sqlite3_finalize(pStmt);
1380 continue;
1381 }
1382 n = (int)strlen(z);
1383 hash_step_vformat(&cx,"S%d:",n);
1384 SHA3Update(&cx,(unsigned char*)z,n);
1385
1386 /* Compute a hash over the result of the query */
@@ -1439,12 +1494,654 @@
1439 }
1440 sqlite3_finalize(pStmt);
1441 }
1442 sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
1443 }
1444 /* End of SHA3 hashing logic copy/pasted from ../ext/misc/shathree.c
1445 ********************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1446
1447 #if defined(SQLITE_ENABLE_SESSION)
1448 /*
1449 ** State information for a single open session
1450 */
@@ -1521,12 +2218,13 @@
1521 #define SHFLG_Scratch 0x00000001 /* The --scratch option is used */
1522 #define SHFLG_Pagecache 0x00000002 /* The --pagecache option is used */
1523 #define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */
1524 #define SHFLG_Backslash 0x00000008 /* The --backslash option is used */
1525 #define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */
1526 #define SHFLG_CountChanges 0x00000020 /* .changes setting */
1527 #define SHFLG_Echo 0x00000040 /* .echo or --echo setting */
 
1528
1529 /*
1530 ** Macros for testing and setting shellFlgs
1531 */
1532 #define ShellHasFlag(P,X) (((P)->shellFlgs & (X))!=0)
@@ -2193,11 +2891,15 @@
2193 for(i=0; i<nArg; i++){
2194 raw_printf(p->out, i>0 ? "," : " VALUES(");
2195 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
2196 utf8_printf(p->out,"NULL");
2197 }else if( aiType && aiType[i]==SQLITE_TEXT ){
2198 output_quoted_escaped_string(p->out, azArg[i]);
 
 
 
 
2199 }else if( aiType && aiType[i]==SQLITE_INTEGER ){
2200 utf8_printf(p->out,"%s", azArg[i]);
2201 }else if( aiType && aiType[i]==SQLITE_FLOAT ){
2202 char z[50];
2203 double r = sqlite3_column_double(p->pStmt, i);
@@ -2207,10 +2909,12 @@
2207 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
2208 int nBlob = sqlite3_column_bytes(p->pStmt, i);
2209 output_hex_blob(p->out, pBlob, nBlob);
2210 }else if( isNumber(azArg[i], 0) ){
2211 utf8_printf(p->out,"%s", azArg[i]);
 
 
2212 }else{
2213 output_quoted_escaped_string(p->out, azArg[i]);
2214 }
2215 }
2216 raw_printf(p->out,");\n");
@@ -3325,11 +4029,13 @@
3325 " If TABLE specified, only dump tables matching\n"
3326 " LIKE pattern TABLE.\n"
3327 ".echo on|off Turn command echo on or off\n"
3328 ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
3329 ".exit Exit this program\n"
3330 ".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"
 
 
3331 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
3332 ".headers on|off Turn display of headers on or off\n"
3333 ".help Show this message\n"
3334 ".import FILE TABLE Import data from FILE into TABLE\n"
3335 #ifndef SQLITE_OMIT_TEST_CONTROL
@@ -3460,62 +4166,10 @@
3460 pBuf[nIn] = 0;
3461 if( pnByte ) *pnByte = nIn;
3462 return pBuf;
3463 }
3464
3465 /*
3466 ** Implementation of the "readfile(X)" SQL function. The entire content
3467 ** of the file named X is read and returned as a BLOB. NULL is returned
3468 ** if the file does not exist or is unreadable.
3469 */
3470 static void readfileFunc(
3471 sqlite3_context *context,
3472 int argc,
3473 sqlite3_value **argv
3474 ){
3475 const char *zName;
3476 void *pBuf;
3477 int nBuf;
3478
3479 UNUSED_PARAMETER(argc);
3480 zName = (const char*)sqlite3_value_text(argv[0]);
3481 if( zName==0 ) return;
3482 pBuf = readFile(zName, &nBuf);
3483 if( pBuf ) sqlite3_result_blob(context, pBuf, nBuf, sqlite3_free);
3484 }
3485
3486 /*
3487 ** Implementation of the "writefile(X,Y)" SQL function. The argument Y
3488 ** is written into file X. The number of bytes written is returned. Or
3489 ** NULL is returned if something goes wrong, such as being unable to open
3490 ** file X for writing.
3491 */
3492 static void writefileFunc(
3493 sqlite3_context *context,
3494 int argc,
3495 sqlite3_value **argv
3496 ){
3497 FILE *out;
3498 const char *z;
3499 sqlite3_int64 rc;
3500 const char *zFile;
3501
3502 UNUSED_PARAMETER(argc);
3503 zFile = (const char*)sqlite3_value_text(argv[0]);
3504 if( zFile==0 ) return;
3505 out = fopen(zFile, "wb");
3506 if( out==0 ) return;
3507 z = (const char*)sqlite3_value_blob(argv[1]);
3508 if( z==0 ){
3509 rc = 0;
3510 }else{
3511 rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
3512 }
3513 fclose(out);
3514 sqlite3_result_int64(context, rc);
3515 }
3516
3517 #if defined(SQLITE_ENABLE_SESSION)
3518 /*
3519 ** Close a single OpenSession object and release all of its associated
3520 ** resources.
3521 */
@@ -3577,22 +4231,76 @@
3577 exit(1);
3578 }
3579 #ifndef SQLITE_OMIT_LOAD_EXTENSION
3580 sqlite3_enable_load_extension(p->db, 1);
3581 #endif
3582 sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
3583 readfileFunc, 0, 0);
3584 sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
3585 writefileFunc, 0, 0);
3586 sqlite3_create_function(p->db, "sha3", 1, SQLITE_UTF8, 0,
3587 sha3Func, 0, 0);
3588 sqlite3_create_function(p->db, "sha3", 2, SQLITE_UTF8, 0,
3589 sha3Func, 0, 0);
3590 sqlite3_create_function(p->db, "sha3_query", 1, SQLITE_UTF8, 0,
3591 sha3QueryFunc, 0, 0);
3592 sqlite3_create_function(p->db, "sha3_query", 2, SQLITE_UTF8, 0,
3593 sha3QueryFunc, 0, 0);
3594 sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
3595 shellAddSchemaName, 0, 0);
3596
3597 }
3598 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -3599,5 +4307,6 @@
 
3599
3600 /*
3601 ** Do C-language style dequoting.
3602 **
3603 ** \a -> alarm
@@ -4926,11 +5635,11 @@
4926
4927 if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
4928 const char *zLike = 0;
4929 int i;
4930 int savedShowHeader = p->showHeader;
4931 ShellClearFlag(p, SHFLG_PreserveRowid);
4932 for(i=1; i<nArg; i++){
4933 if( azArg[i][0]=='-' ){
4934 const char *z = azArg[i]+1;
4935 if( z[0]=='-' ) z++;
4936 if( strcmp(z,"preserve-rowids")==0 ){
@@ -4941,17 +5650,21 @@
4941 goto meta_command_exit;
4942 #else
4943 ShellSetFlag(p, SHFLG_PreserveRowid);
4944 #endif
4945 }else
 
 
 
4946 {
4947 raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
4948 rc = 1;
4949 goto meta_command_exit;
4950 }
4951 }else if( zLike ){
4952 raw_printf(stderr, "Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?\n");
 
4953 rc = 1;
4954 goto meta_command_exit;
4955 }else{
4956 zLike = azArg[i];
4957 }
@@ -5033,10 +5746,12 @@
5033 if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
5034 if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
5035 rc = 2;
5036 }else
5037
 
 
5038 if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
5039 int val = 1;
5040 if( nArg>=2 ){
5041 if( strcmp(azArg[1],"auto")==0 ){
5042 val = 99;
@@ -5549,11 +6264,13 @@
5549 p->mode = MODE_Quote;
5550 }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
5551 p->mode = MODE_Ascii;
5552 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
5553 sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
5554 }else {
 
 
5555 raw_printf(stderr, "Error: mode should be one of: "
5556 "ascii column csv html insert line list quote tabs tcl\n");
5557 rc = 1;
5558 }
5559 p->cMode = p->mode;
@@ -5821,12 +6538,18 @@
5821 rc = 1;
5822 goto meta_command_exit;
5823 }
5824 if( zDiv ){
5825 sqlite3_stmt *pStmt = 0;
5826 sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list",
5827 -1, &pStmt, 0);
 
 
 
 
 
 
5828 appendText(&sSelect, "SELECT sql FROM", 0);
5829 iSchema = 0;
5830 while( sqlite3_step(pStmt)==SQLITE_ROW ){
5831 const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);
5832 char zScNum[30];
@@ -7179,10 +7902,11 @@
7179 " -multiplex enable the multiplexor VFS\n"
7180 #endif
7181 " -newline SEP set output row separator. Default: '\\n'\n"
7182 " -nullvalue TEXT set text string for NULL values. Default ''\n"
7183 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
 
7184 " -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
7185 " -separator SEP set output column separator. Default: '|'\n"
7186 " -stats print memory stats before each finalize\n"
7187 " -version show SQLite version\n"
7188 " -vfs NAME use NAME as the default VFS\n"
@@ -7474,10 +8198,12 @@
7474 i++;
7475 }else if( strcmp(z,"-html")==0 ){
7476 data.mode = MODE_Html;
7477 }else if( strcmp(z,"-list")==0 ){
7478 data.mode = MODE_List;
 
 
7479 }else if( strcmp(z,"-line")==0 ){
7480 data.mode = MODE_Line;
7481 }else if( strcmp(z,"-column")==0 ){
7482 data.mode = MODE_Column;
7483 }else if( strcmp(z,"-csv")==0 ){
@@ -7625,10 +8351,15 @@
7625 if( (zHistory = malloc(nHistory))!=0 ){
7626 sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
7627 }
7628 }
7629 if( zHistory ){ shell_read_history(zHistory); }
 
 
 
 
 
7630 rc = process_input(&data, 0);
7631 if( zHistory ){
7632 shell_stifle_history(100);
7633 shell_write_history(zHistory);
7634 free(zHistory);
@@ -7648,5 +8379,6 @@
7648 for(i=0; i<argc; i++) sqlite3_free(argv[i]);
7649 sqlite3_free(argv);
7650 #endif
7651 return rc;
7652 }
 
7653
--- src/shell.c
+++ src/shell.c
@@ -1,5 +1,23 @@
1 /* DO NOT EDIT!
2 ** This file is automatically generated by the script in the canonical
3 ** SQLite source tree at tool/mkshellc.tcl. That script combines source
4 ** code from various constituent source files of SQLite into this single
5 ** "shell.c" file used to implement the SQLite command-line shell.
6 **
7 ** Most of the code found below comes from the "src/shell.c.in" file in
8 ** the canonical SQLite source tree. That main file contains "INCLUDE"
9 ** lines that specify other files in the canonical source tree that are
10 ** inserted to getnerate this complete program source file.
11 **
12 ** The code from multiple files is combined into this single "shell.c"
13 ** source file to help make the command-line program easier to compile.
14 **
15 ** To modify this program, get a copy of the canonical SQLite source tree,
16 ** edit the src/shell.c.in" and/or some of the other files that are included
17 ** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
18 */
19 /*
20 ** 2001 September 15
21 **
22 ** The author disclaims copyright to this source code. In place of
23 ** a legal notice, here is a blessing:
@@ -782,14 +800,57 @@
800 }
801 }
802 sqlite3_result_value(pCtx, apVal[0]);
803 }
804
805 /*
806 ** The source code for several run-time loadable extensions is inserted
807 ** below by the ../tool/mkshellc.tcl script. Before processing that included
808 ** code, we need to override some macros to make the included program code
809 ** work here in the middle of this regular program.
810 */
811 #define SQLITE_EXTENSION_INIT1
812 #define SQLITE_EXTENSION_INIT2(X)
813
814 /************************* Begin ../ext/misc/shathree.c ******************/
815 /*
816 ** 2017-03-08
817 **
818 ** The author disclaims copyright to this source code. In place of
819 ** a legal notice, here is a blessing:
820 **
821 ** May you do good and not evil.
822 ** May you find forgiveness for yourself and forgive others.
823 ** May you share freely, never taking more than you give.
824 **
825 ******************************************************************************
826 **
827 ** This SQLite extension implements a functions that compute SHA1 hashes.
828 ** Two SQL functions are implemented:
829 **
830 ** sha3(X,SIZE)
831 ** sha3_query(Y,SIZE)
832 **
833 ** The sha3(X) function computes the SHA3 hash of the input X, or NULL if
834 ** X is NULL.
835 **
836 ** The sha3_query(Y) function evalutes all queries in the SQL statements of Y
837 ** and returns a hash of their results.
838 **
839 ** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm
840 ** is used. If SIZE is included it must be one of the integers 224, 256,
841 ** 384, or 512, to determine SHA3 hash variant that is computed.
842 */
843 SQLITE_EXTENSION_INIT1
844 #include <assert.h>
845 #include <string.h>
846 #include <stdarg.h>
847 typedef sqlite3_uint64 u64;
848
849 /******************************************************************************
850 ** The Hash Engine
851 */
852 /*
853 ** Macros to determine whether the machine is big or little endian,
854 ** and whether or not that determination is run-time or compile-time.
855 **
856 ** For best performance, an attempt is made to guess at the byte-order
@@ -823,14 +884,10 @@
884 unsigned nRate; /* Bytes of input accepted per Keccak iteration */
885 unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */
886 unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */
887 };
888
 
 
 
 
889 /*
890 ** A single step of the Keccak mixing function for a 1600-bit state
891 */
892 static void KeccakF1600Step(SHA3Context *p){
893 int i;
@@ -1237,16 +1294,18 @@
1294 for(i=0; i<p->nRate; i++){
1295 p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
1296 }
1297 return &p->u.x[p->nRate];
1298 }
1299 /* End of the hashing logic
1300 *****************************************************************************/
1301
1302 /*
1303 ** Implementation of the sha3(X,SIZE) function.
1304 **
1305 ** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default
1306 ** size is 256. If X is a BLOB, it is hashed as is.
1307 ** For all other non-NULL types of input, X is converted into a UTF-8 string
1308 ** and the string is hashed without the trailing 0x00 terminator. The hash
1309 ** of a NULL value is NULL.
1310 */
1311 static void sha3Func(
@@ -1373,14 +1432,10 @@
1432 sqlite3_free(zMsg);
1433 return;
1434 }
1435 nCol = sqlite3_column_count(pStmt);
1436 z = sqlite3_sql(pStmt);
 
 
 
 
1437 n = (int)strlen(z);
1438 hash_step_vformat(&cx,"S%d:",n);
1439 SHA3Update(&cx,(unsigned char*)z,n);
1440
1441 /* Compute a hash over the result of the query */
@@ -1439,12 +1494,654 @@
1494 }
1495 sqlite3_finalize(pStmt);
1496 }
1497 sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
1498 }
1499
1500
1501 #ifdef _WIN32
1502 __declspec(dllexport)
1503 #endif
1504 int sqlite3_shathree_init(
1505 sqlite3 *db,
1506 char **pzErrMsg,
1507 const sqlite3_api_routines *pApi
1508 ){
1509 int rc = SQLITE_OK;
1510 SQLITE_EXTENSION_INIT2(pApi);
1511 (void)pzErrMsg; /* Unused parameter */
1512 rc = sqlite3_create_function(db, "sha3", 1, SQLITE_UTF8, 0,
1513 sha3Func, 0, 0);
1514 if( rc==SQLITE_OK ){
1515 rc = sqlite3_create_function(db, "sha3", 2, SQLITE_UTF8, 0,
1516 sha3Func, 0, 0);
1517 }
1518 if( rc==SQLITE_OK ){
1519 rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8, 0,
1520 sha3QueryFunc, 0, 0);
1521 }
1522 if( rc==SQLITE_OK ){
1523 rc = sqlite3_create_function(db, "sha3_query", 2, SQLITE_UTF8, 0,
1524 sha3QueryFunc, 0, 0);
1525 }
1526 return rc;
1527 }
1528
1529 /************************* End ../ext/misc/shathree.c ********************/
1530 /************************* Begin ../ext/misc/fileio.c ******************/
1531 /*
1532 ** 2014-06-13
1533 **
1534 ** The author disclaims copyright to this source code. In place of
1535 ** a legal notice, here is a blessing:
1536 **
1537 ** May you do good and not evil.
1538 ** May you find forgiveness for yourself and forgive others.
1539 ** May you share freely, never taking more than you give.
1540 **
1541 ******************************************************************************
1542 **
1543 ** This SQLite extension implements SQL functions readfile() and
1544 ** writefile().
1545 */
1546 SQLITE_EXTENSION_INIT1
1547 #include <stdio.h>
1548
1549 /*
1550 ** Implementation of the "readfile(X)" SQL function. The entire content
1551 ** of the file named X is read and returned as a BLOB. NULL is returned
1552 ** if the file does not exist or is unreadable.
1553 */
1554 static void readfileFunc(
1555 sqlite3_context *context,
1556 int argc,
1557 sqlite3_value **argv
1558 ){
1559 const char *zName;
1560 FILE *in;
1561 long nIn;
1562 void *pBuf;
1563
1564 zName = (const char*)sqlite3_value_text(argv[0]);
1565 if( zName==0 ) return;
1566 in = fopen(zName, "rb");
1567 if( in==0 ) return;
1568 fseek(in, 0, SEEK_END);
1569 nIn = ftell(in);
1570 rewind(in);
1571 pBuf = sqlite3_malloc( nIn );
1572 if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
1573 sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
1574 }else{
1575 sqlite3_free(pBuf);
1576 }
1577 fclose(in);
1578 }
1579
1580 /*
1581 ** Implementation of the "writefile(X,Y)" SQL function. The argument Y
1582 ** is written into file X. The number of bytes written is returned. Or
1583 ** NULL is returned if something goes wrong, such as being unable to open
1584 ** file X for writing.
1585 */
1586 static void writefileFunc(
1587 sqlite3_context *context,
1588 int argc,
1589 sqlite3_value **argv
1590 ){
1591 FILE *out;
1592 const char *z;
1593 sqlite3_int64 rc;
1594 const char *zFile;
1595
1596 zFile = (const char*)sqlite3_value_text(argv[0]);
1597 if( zFile==0 ) return;
1598 out = fopen(zFile, "wb");
1599 if( out==0 ) return;
1600 z = (const char*)sqlite3_value_blob(argv[1]);
1601 if( z==0 ){
1602 rc = 0;
1603 }else{
1604 rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
1605 }
1606 fclose(out);
1607 sqlite3_result_int64(context, rc);
1608 }
1609
1610
1611 #ifdef _WIN32
1612 __declspec(dllexport)
1613 #endif
1614 int sqlite3_fileio_init(
1615 sqlite3 *db,
1616 char **pzErrMsg,
1617 const sqlite3_api_routines *pApi
1618 ){
1619 int rc = SQLITE_OK;
1620 SQLITE_EXTENSION_INIT2(pApi);
1621 (void)pzErrMsg; /* Unused parameter */
1622 rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
1623 readfileFunc, 0, 0);
1624 if( rc==SQLITE_OK ){
1625 rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
1626 writefileFunc, 0, 0);
1627 }
1628 return rc;
1629 }
1630
1631 /************************* End ../ext/misc/fileio.c ********************/
1632 /************************* Begin ../ext/misc/completion.c ******************/
1633 /*
1634 ** 2017-07-10
1635 **
1636 ** The author disclaims copyright to this source code. In place of
1637 ** a legal notice, here is a blessing:
1638 **
1639 ** May you do good and not evil.
1640 ** May you find forgiveness for yourself and forgive others.
1641 ** May you share freely, never taking more than you give.
1642 **
1643 *************************************************************************
1644 **
1645 ** This file implements an eponymous virtual table that returns suggested
1646 ** completions for a partial SQL input.
1647 **
1648 ** Suggested usage:
1649 **
1650 ** SELECT DISTINCT candidate COLLATE nocase
1651 ** FROM completion($prefix,$wholeline)
1652 ** ORDER BY 1;
1653 **
1654 ** The two query parameters are optional. $prefix is the text of the
1655 ** current word being typed and that is to be completed. $wholeline is
1656 ** the complete input line, used for context.
1657 **
1658 ** The raw completion() table might return the same candidate multiple
1659 ** times, for example if the same column name is used to two or more
1660 ** tables. And the candidates are returned in an arbitrary order. Hence,
1661 ** the DISTINCT and ORDER BY are recommended.
1662 **
1663 ** This virtual table operates at the speed of human typing, and so there
1664 ** is no attempt to make it fast. Even a slow implementation will be much
1665 ** faster than any human can type.
1666 **
1667 */
1668 SQLITE_EXTENSION_INIT1
1669 #include <assert.h>
1670 #include <string.h>
1671 #include <ctype.h>
1672
1673 #ifndef SQLITE_OMIT_VIRTUALTABLE
1674
1675 /* completion_vtab is a subclass of sqlite3_vtab which will
1676 ** serve as the underlying representation of a completion virtual table
1677 */
1678 typedef struct completion_vtab completion_vtab;
1679 struct completion_vtab {
1680 sqlite3_vtab base; /* Base class - must be first */
1681 sqlite3 *db; /* Database connection for this completion vtab */
1682 };
1683
1684 /* completion_cursor is a subclass of sqlite3_vtab_cursor which will
1685 ** serve as the underlying representation of a cursor that scans
1686 ** over rows of the result
1687 */
1688 typedef struct completion_cursor completion_cursor;
1689 struct completion_cursor {
1690 sqlite3_vtab_cursor base; /* Base class - must be first */
1691 sqlite3 *db; /* Database connection for this cursor */
1692 int nPrefix, nLine; /* Number of bytes in zPrefix and zLine */
1693 char *zPrefix; /* The prefix for the word we want to complete */
1694 char *zLine; /* The whole that we want to complete */
1695 const char *zCurrentRow; /* Current output row */
1696 sqlite3_stmt *pStmt; /* Current statement */
1697 sqlite3_int64 iRowid; /* The rowid */
1698 int ePhase; /* Current phase */
1699 int j; /* inter-phase counter */
1700 };
1701
1702 /* Values for ePhase:
1703 */
1704 #define COMPLETION_FIRST_PHASE 1
1705 #define COMPLETION_KEYWORDS 1
1706 #define COMPLETION_PRAGMAS 2
1707 #define COMPLETION_FUNCTIONS 3
1708 #define COMPLETION_COLLATIONS 4
1709 #define COMPLETION_INDEXES 5
1710 #define COMPLETION_TRIGGERS 6
1711 #define COMPLETION_DATABASES 7
1712 #define COMPLETION_TABLES 8
1713 #define COMPLETION_COLUMNS 9
1714 #define COMPLETION_MODULES 10
1715 #define COMPLETION_EOF 11
1716
1717 /*
1718 ** The completionConnect() method is invoked to create a new
1719 ** completion_vtab that describes the completion virtual table.
1720 **
1721 ** Think of this routine as the constructor for completion_vtab objects.
1722 **
1723 ** All this routine needs to do is:
1724 **
1725 ** (1) Allocate the completion_vtab object and initialize all fields.
1726 **
1727 ** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
1728 ** result set of queries against completion will look like.
1729 */
1730 static int completionConnect(
1731 sqlite3 *db,
1732 void *pAux,
1733 int argc, const char *const*argv,
1734 sqlite3_vtab **ppVtab,
1735 char **pzErr
1736 ){
1737 completion_vtab *pNew;
1738 int rc;
1739
1740 /* Column numbers */
1741 #define COMPLETION_COLUMN_CANDIDATE 0 /* Suggested completion of the input */
1742 #define COMPLETION_COLUMN_PREFIX 1 /* Prefix of the word to be completed */
1743 #define COMPLETION_COLUMN_WHOLELINE 2 /* Entire line seen so far */
1744 #define COMPLETION_COLUMN_PHASE 3 /* ePhase - used for debugging only */
1745
1746 rc = sqlite3_declare_vtab(db,
1747 "CREATE TABLE x("
1748 " candidate TEXT,"
1749 " prefix TEXT HIDDEN,"
1750 " wholeline TEXT HIDDEN,"
1751 " phase INT HIDDEN" /* Used for debugging only */
1752 ")");
1753 if( rc==SQLITE_OK ){
1754 pNew = sqlite3_malloc( sizeof(*pNew) );
1755 *ppVtab = (sqlite3_vtab*)pNew;
1756 if( pNew==0 ) return SQLITE_NOMEM;
1757 memset(pNew, 0, sizeof(*pNew));
1758 pNew->db = db;
1759 }
1760 return rc;
1761 }
1762
1763 /*
1764 ** This method is the destructor for completion_cursor objects.
1765 */
1766 static int completionDisconnect(sqlite3_vtab *pVtab){
1767 sqlite3_free(pVtab);
1768 return SQLITE_OK;
1769 }
1770
1771 /*
1772 ** Constructor for a new completion_cursor object.
1773 */
1774 static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
1775 completion_cursor *pCur;
1776 pCur = sqlite3_malloc( sizeof(*pCur) );
1777 if( pCur==0 ) return SQLITE_NOMEM;
1778 memset(pCur, 0, sizeof(*pCur));
1779 pCur->db = ((completion_vtab*)p)->db;
1780 *ppCursor = &pCur->base;
1781 return SQLITE_OK;
1782 }
1783
1784 /*
1785 ** Reset the completion_cursor.
1786 */
1787 static void completionCursorReset(completion_cursor *pCur){
1788 sqlite3_free(pCur->zPrefix); pCur->zPrefix = 0; pCur->nPrefix = 0;
1789 sqlite3_free(pCur->zLine); pCur->zLine = 0; pCur->nLine = 0;
1790 sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;
1791 pCur->j = 0;
1792 }
1793
1794 /*
1795 ** Destructor for a completion_cursor.
1796 */
1797 static int completionClose(sqlite3_vtab_cursor *cur){
1798 completionCursorReset((completion_cursor*)cur);
1799 sqlite3_free(cur);
1800 return SQLITE_OK;
1801 }
1802
1803 /*
1804 ** All SQL keywords understood by SQLite
1805 */
1806 static const char *completionKwrds[] = {
1807 "ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ANALYZE", "AND", "AS",
1808 "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN", "BY",
1809 "CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT",
1810 "CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT_DATE",
1811 "CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE",
1812 "DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DROP", "EACH",
1813 "ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUSIVE", "EXISTS", "EXPLAIN",
1814 "FAIL", "FOR", "FOREIGN", "FROM", "FULL", "GLOB", "GROUP", "HAVING", "IF",
1815 "IGNORE", "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER",
1816 "INSERT", "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY",
1817 "LEFT", "LIKE", "LIMIT", "MATCH", "NATURAL", "NO", "NOT", "NOTNULL",
1818 "NULL", "OF", "OFFSET", "ON", "OR", "ORDER", "OUTER", "PLAN", "PRAGMA",
1819 "PRIMARY", "QUERY", "RAISE", "RECURSIVE", "REFERENCES", "REGEXP",
1820 "REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RIGHT",
1821 "ROLLBACK", "ROW", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP",
1822 "TEMPORARY", "THEN", "TO", "TRANSACTION", "TRIGGER", "UNION", "UNIQUE",
1823 "UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL", "WHEN", "WHERE",
1824 "WITH", "WITHOUT",
1825 };
1826
1827 /*
1828 ** Advance a completion_cursor to its next row of output.
1829 **
1830 ** The ->ePhase, ->j, and ->pStmt fields of the completion_cursor object
1831 ** record the current state of the scan. This routine sets ->zCurrentRow
1832 ** to the current row of output and then returns. If no more rows remain,
1833 ** then ->ePhase is set to COMPLETION_EOF which will signal the virtual
1834 ** table that has reached the end of its scan.
1835 **
1836 ** The current implementation just lists potential identifiers and
1837 ** keywords and filters them by zPrefix. Future enhancements should
1838 ** take zLine into account to try to restrict the set of identifiers and
1839 ** keywords based on what would be legal at the current point of input.
1840 */
1841 static int completionNext(sqlite3_vtab_cursor *cur){
1842 completion_cursor *pCur = (completion_cursor*)cur;
1843 int eNextPhase = 0; /* Next phase to try if current phase reaches end */
1844 int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
1845 pCur->iRowid++;
1846 while( pCur->ePhase!=COMPLETION_EOF ){
1847 switch( pCur->ePhase ){
1848 case COMPLETION_KEYWORDS: {
1849 if( pCur->j >= sizeof(completionKwrds)/sizeof(completionKwrds[0]) ){
1850 pCur->zCurrentRow = 0;
1851 pCur->ePhase = COMPLETION_DATABASES;
1852 }else{
1853 pCur->zCurrentRow = completionKwrds[pCur->j++];
1854 }
1855 iCol = -1;
1856 break;
1857 }
1858 case COMPLETION_DATABASES: {
1859 if( pCur->pStmt==0 ){
1860 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1,
1861 &pCur->pStmt, 0);
1862 }
1863 iCol = 1;
1864 eNextPhase = COMPLETION_TABLES;
1865 break;
1866 }
1867 case COMPLETION_TABLES: {
1868 if( pCur->pStmt==0 ){
1869 sqlite3_stmt *pS2;
1870 char *zSql = 0;
1871 const char *zSep = "";
1872 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1873 while( sqlite3_step(pS2)==SQLITE_ROW ){
1874 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
1875 zSql = sqlite3_mprintf(
1876 "%z%s"
1877 "SELECT name FROM \"%w\".sqlite_master"
1878 " WHERE type='table'",
1879 zSql, zSep, zDb
1880 );
1881 if( zSql==0 ) return SQLITE_NOMEM;
1882 zSep = " UNION ";
1883 }
1884 sqlite3_finalize(pS2);
1885 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
1886 sqlite3_free(zSql);
1887 }
1888 iCol = 0;
1889 eNextPhase = COMPLETION_COLUMNS;
1890 break;
1891 }
1892 case COMPLETION_COLUMNS: {
1893 if( pCur->pStmt==0 ){
1894 sqlite3_stmt *pS2;
1895 char *zSql = 0;
1896 const char *zSep = "";
1897 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1898 while( sqlite3_step(pS2)==SQLITE_ROW ){
1899 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
1900 zSql = sqlite3_mprintf(
1901 "%z%s"
1902 "SELECT pti.name FROM \"%w\".sqlite_master AS sm"
1903 " JOIN pragma_table_info(sm.name,%Q) AS pti"
1904 " WHERE sm.type='table'",
1905 zSql, zSep, zDb, zDb
1906 );
1907 if( zSql==0 ) return SQLITE_NOMEM;
1908 zSep = " UNION ";
1909 }
1910 sqlite3_finalize(pS2);
1911 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
1912 sqlite3_free(zSql);
1913 }
1914 iCol = 0;
1915 eNextPhase = COMPLETION_EOF;
1916 break;
1917 }
1918 }
1919 if( iCol<0 ){
1920 /* This case is when the phase presets zCurrentRow */
1921 if( pCur->zCurrentRow==0 ) continue;
1922 }else{
1923 if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){
1924 /* Extract the next row of content */
1925 pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
1926 }else{
1927 /* When all rows are finished, advance to the next phase */
1928 sqlite3_finalize(pCur->pStmt);
1929 pCur->pStmt = 0;
1930 pCur->ePhase = eNextPhase;
1931 continue;
1932 }
1933 }
1934 if( pCur->nPrefix==0 ) break;
1935 if( sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0 ){
1936 break;
1937 }
1938 }
1939
1940 return SQLITE_OK;
1941 }
1942
1943 /*
1944 ** Return values of columns for the row at which the completion_cursor
1945 ** is currently pointing.
1946 */
1947 static int completionColumn(
1948 sqlite3_vtab_cursor *cur, /* The cursor */
1949 sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
1950 int i /* Which column to return */
1951 ){
1952 completion_cursor *pCur = (completion_cursor*)cur;
1953 switch( i ){
1954 case COMPLETION_COLUMN_CANDIDATE: {
1955 sqlite3_result_text(ctx, pCur->zCurrentRow, -1, SQLITE_TRANSIENT);
1956 break;
1957 }
1958 case COMPLETION_COLUMN_PREFIX: {
1959 sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);
1960 break;
1961 }
1962 case COMPLETION_COLUMN_WHOLELINE: {
1963 sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);
1964 break;
1965 }
1966 case COMPLETION_COLUMN_PHASE: {
1967 sqlite3_result_int(ctx, pCur->ePhase);
1968 break;
1969 }
1970 }
1971 return SQLITE_OK;
1972 }
1973
1974 /*
1975 ** Return the rowid for the current row. In this implementation, the
1976 ** rowid is the same as the output value.
1977 */
1978 static int completionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
1979 completion_cursor *pCur = (completion_cursor*)cur;
1980 *pRowid = pCur->iRowid;
1981 return SQLITE_OK;
1982 }
1983
1984 /*
1985 ** Return TRUE if the cursor has been moved off of the last
1986 ** row of output.
1987 */
1988 static int completionEof(sqlite3_vtab_cursor *cur){
1989 completion_cursor *pCur = (completion_cursor*)cur;
1990 return pCur->ePhase >= COMPLETION_EOF;
1991 }
1992
1993 /*
1994 ** This method is called to "rewind" the completion_cursor object back
1995 ** to the first row of output. This method is always called at least
1996 ** once prior to any call to completionColumn() or completionRowid() or
1997 ** completionEof().
1998 */
1999 static int completionFilter(
2000 sqlite3_vtab_cursor *pVtabCursor,
2001 int idxNum, const char *idxStr,
2002 int argc, sqlite3_value **argv
2003 ){
2004 completion_cursor *pCur = (completion_cursor *)pVtabCursor;
2005 int iArg = 0;
2006 completionCursorReset(pCur);
2007 if( idxNum & 1 ){
2008 pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);
2009 if( pCur->nPrefix>0 ){
2010 pCur->zPrefix = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
2011 if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
2012 }
2013 iArg++;
2014 }
2015 if( idxNum & 2 ){
2016 pCur->nLine = sqlite3_value_bytes(argv[iArg]);
2017 if( pCur->nLine>0 ){
2018 pCur->zLine = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
2019 if( pCur->zLine==0 ) return SQLITE_NOMEM;
2020 }
2021 iArg++;
2022 }
2023 if( pCur->zLine!=0 && pCur->zPrefix==0 ){
2024 int i = pCur->nLine;
2025 while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
2026 i--;
2027 }
2028 pCur->nPrefix = pCur->nLine - i;
2029 if( pCur->nPrefix>0 ){
2030 pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
2031 if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
2032 }
2033 }
2034 pCur->iRowid = 0;
2035 pCur->ePhase = COMPLETION_FIRST_PHASE;
2036 return completionNext(pVtabCursor);
2037 }
2038
2039 /*
2040 ** SQLite will invoke this method one or more times while planning a query
2041 ** that uses the completion virtual table. This routine needs to create
2042 ** a query plan for each invocation and compute an estimated cost for that
2043 ** plan.
2044 **
2045 ** There are two hidden parameters that act as arguments to the table-valued
2046 ** function: "prefix" and "wholeline". Bit 0 of idxNum is set if "prefix"
2047 ** is available and bit 1 is set if "wholeline" is available.
2048 */
2049 static int completionBestIndex(
2050 sqlite3_vtab *tab,
2051 sqlite3_index_info *pIdxInfo
2052 ){
2053 int i; /* Loop over constraints */
2054 int idxNum = 0; /* The query plan bitmask */
2055 int prefixIdx = -1; /* Index of the start= constraint, or -1 if none */
2056 int wholelineIdx = -1; /* Index of the stop= constraint, or -1 if none */
2057 int nArg = 0; /* Number of arguments that completeFilter() expects */
2058 const struct sqlite3_index_constraint *pConstraint;
2059
2060 pConstraint = pIdxInfo->aConstraint;
2061 for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
2062 if( pConstraint->usable==0 ) continue;
2063 if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
2064 switch( pConstraint->iColumn ){
2065 case COMPLETION_COLUMN_PREFIX:
2066 prefixIdx = i;
2067 idxNum |= 1;
2068 break;
2069 case COMPLETION_COLUMN_WHOLELINE:
2070 wholelineIdx = i;
2071 idxNum |= 2;
2072 break;
2073 }
2074 }
2075 if( prefixIdx>=0 ){
2076 pIdxInfo->aConstraintUsage[prefixIdx].argvIndex = ++nArg;
2077 pIdxInfo->aConstraintUsage[prefixIdx].omit = 1;
2078 }
2079 if( wholelineIdx>=0 ){
2080 pIdxInfo->aConstraintUsage[wholelineIdx].argvIndex = ++nArg;
2081 pIdxInfo->aConstraintUsage[wholelineIdx].omit = 1;
2082 }
2083 pIdxInfo->idxNum = idxNum;
2084 pIdxInfo->estimatedCost = (double)5000 - 1000*nArg;
2085 pIdxInfo->estimatedRows = 500 - 100*nArg;
2086 return SQLITE_OK;
2087 }
2088
2089 /*
2090 ** This following structure defines all the methods for the
2091 ** completion virtual table.
2092 */
2093 static sqlite3_module completionModule = {
2094 0, /* iVersion */
2095 0, /* xCreate */
2096 completionConnect, /* xConnect */
2097 completionBestIndex, /* xBestIndex */
2098 completionDisconnect, /* xDisconnect */
2099 0, /* xDestroy */
2100 completionOpen, /* xOpen - open a cursor */
2101 completionClose, /* xClose - close a cursor */
2102 completionFilter, /* xFilter - configure scan constraints */
2103 completionNext, /* xNext - advance a cursor */
2104 completionEof, /* xEof - check for end of scan */
2105 completionColumn, /* xColumn - read data */
2106 completionRowid, /* xRowid - read data */
2107 0, /* xUpdate */
2108 0, /* xBegin */
2109 0, /* xSync */
2110 0, /* xCommit */
2111 0, /* xRollback */
2112 0, /* xFindMethod */
2113 0, /* xRename */
2114 };
2115
2116 #endif /* SQLITE_OMIT_VIRTUALTABLE */
2117
2118 int sqlite3CompletionVtabInit(sqlite3 *db){
2119 int rc = SQLITE_OK;
2120 #ifndef SQLITE_OMIT_VIRTUALTABLE
2121 rc = sqlite3_create_module(db, "completion", &completionModule, 0);
2122 #endif
2123 return rc;
2124 }
2125
2126 #ifdef _WIN32
2127 __declspec(dllexport)
2128 #endif
2129 int sqlite3_completion_init(
2130 sqlite3 *db,
2131 char **pzErrMsg,
2132 const sqlite3_api_routines *pApi
2133 ){
2134 int rc = SQLITE_OK;
2135 SQLITE_EXTENSION_INIT2(pApi);
2136 #ifndef SQLITE_OMIT_VIRTUALTABLE
2137 rc = sqlite3CompletionVtabInit(db);
2138 #endif
2139 return rc;
2140 }
2141
2142 /************************* End ../ext/misc/completion.c ********************/
2143
2144 #if defined(SQLITE_ENABLE_SESSION)
2145 /*
2146 ** State information for a single open session
2147 */
@@ -1521,12 +2218,13 @@
2218 #define SHFLG_Scratch 0x00000001 /* The --scratch option is used */
2219 #define SHFLG_Pagecache 0x00000002 /* The --pagecache option is used */
2220 #define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */
2221 #define SHFLG_Backslash 0x00000008 /* The --backslash option is used */
2222 #define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */
2223 #define SHFLG_Newlines 0x00000020 /* .dump --newline flag */
2224 #define SHFLG_CountChanges 0x00000040 /* .changes setting */
2225 #define SHFLG_Echo 0x00000080 /* .echo or --echo setting */
2226
2227 /*
2228 ** Macros for testing and setting shellFlgs
2229 */
2230 #define ShellHasFlag(P,X) (((P)->shellFlgs & (X))!=0)
@@ -2193,11 +2891,15 @@
2891 for(i=0; i<nArg; i++){
2892 raw_printf(p->out, i>0 ? "," : " VALUES(");
2893 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
2894 utf8_printf(p->out,"NULL");
2895 }else if( aiType && aiType[i]==SQLITE_TEXT ){
2896 if( ShellHasFlag(p, SHFLG_Newlines) ){
2897 output_quoted_string(p->out, azArg[i]);
2898 }else{
2899 output_quoted_escaped_string(p->out, azArg[i]);
2900 }
2901 }else if( aiType && aiType[i]==SQLITE_INTEGER ){
2902 utf8_printf(p->out,"%s", azArg[i]);
2903 }else if( aiType && aiType[i]==SQLITE_FLOAT ){
2904 char z[50];
2905 double r = sqlite3_column_double(p->pStmt, i);
@@ -2207,10 +2909,12 @@
2909 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
2910 int nBlob = sqlite3_column_bytes(p->pStmt, i);
2911 output_hex_blob(p->out, pBlob, nBlob);
2912 }else if( isNumber(azArg[i], 0) ){
2913 utf8_printf(p->out,"%s", azArg[i]);
2914 }else if( ShellHasFlag(p, SHFLG_Newlines) ){
2915 output_quoted_string(p->out, azArg[i]);
2916 }else{
2917 output_quoted_escaped_string(p->out, azArg[i]);
2918 }
2919 }
2920 raw_printf(p->out,");\n");
@@ -3325,11 +4029,13 @@
4029 " If TABLE specified, only dump tables matching\n"
4030 " LIKE pattern TABLE.\n"
4031 ".echo on|off Turn command echo on or off\n"
4032 ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
4033 ".exit Exit this program\n"
4034 /* Because explain mode comes on automatically now, the ".explain" mode
4035 ** is removed from the help screen. It is still supported for legacy, however */
4036 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/
4037 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n"
4038 ".headers on|off Turn display of headers on or off\n"
4039 ".help Show this message\n"
4040 ".import FILE TABLE Import data from FILE into TABLE\n"
4041 #ifndef SQLITE_OMIT_TEST_CONTROL
@@ -3460,62 +4166,10 @@
4166 pBuf[nIn] = 0;
4167 if( pnByte ) *pnByte = nIn;
4168 return pBuf;
4169 }
4170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4171 #if defined(SQLITE_ENABLE_SESSION)
4172 /*
4173 ** Close a single OpenSession object and release all of its associated
4174 ** resources.
4175 */
@@ -3577,22 +4231,76 @@
4231 exit(1);
4232 }
4233 #ifndef SQLITE_OMIT_LOAD_EXTENSION
4234 sqlite3_enable_load_extension(p->db, 1);
4235 #endif
4236 sqlite3_fileio_init(p->db, 0, 0);
4237 sqlite3_shathree_init(p->db, 0, 0);
4238 sqlite3_completion_init(p->db, 0, 0);
 
 
 
 
 
 
 
 
 
4239 sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
4240 shellAddSchemaName, 0, 0);
 
4241 }
4242 }
4243
4244 #if HAVE_READLINE || HAVE_EDITLINE
4245 /*
4246 ** Readline completion callbacks
4247 */
4248 static char *readline_completion_generator(const char *text, int state){
4249 static sqlite3_stmt *pStmt = 0;
4250 char *zRet;
4251 if( state==0 ){
4252 char *zSql;
4253 int rc;
4254 sqlite3_finalize(pStmt);
4255 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4256 " FROM completion(%Q) ORDER BY 1", text);
4257 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4258 sqlite3_free(zSql);
4259 }
4260 if( sqlite3_step(pStmt)==SQLITE_ROW ){
4261 zRet = strdup(sqlite3_column_text(pStmt, 0));
4262 }else{
4263 sqlite3_finalize(pStmt);
4264 pStmt = 0;
4265 zRet = 0;
4266 }
4267 return zRet;
4268 }
4269 static char **readline_completion(const char *zText, int iStart, int iEnd){
4270 rl_attempted_completion_over = 1;
4271 return rl_completion_matches(zText, readline_completion_generator);
4272 }
4273
4274 #elif HAVE_LINENOISE
4275 /*
4276 ** Linenoise completion callback
4277 */
4278 static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
4279 int nLine = (int)strlen(zLine);
4280 int i, iStart;
4281 sqlite3_stmt *pStmt = 0;
4282 char *zSql;
4283 char zBuf[1000];
4284
4285 if( nLine>sizeof(zBuf)-30 ) return;
4286 if( zLine[0]=='.' ) return;
4287 for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
4288 if( i==nLine-1 ) return;
4289 iStart = i+1;
4290 memcpy(zBuf, zLine, iStart);
4291 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
4292 " FROM completion(%Q,%Q) ORDER BY 1",
4293 &zLine[iStart], zLine);
4294 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
4295 sqlite3_free(zSql);
4296 sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
4297 while( sqlite3_step(pStmt)==SQLITE_ROW ){
4298 const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
4299 int nCompletion = sqlite3_column_bytes(pStmt, 0);
4300 if( iStart+nCompletion < sizeof(zBuf)-1 ){
4301 memcpy(zBuf+iStart, zCompletion, nCompletion+1);
4302 linenoiseAddCompletion(lc, zBuf);
4303 }
4304 }
4305 sqlite3_finalize(pStmt);
4306 }
@@ -3599,5 +4307,6 @@
4307 #endif
4308
4309 /*
4310 ** Do C-language style dequoting.
4311 **
4312 ** \a -> alarm
@@ -4926,11 +5635,11 @@
5635
5636 if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
5637 const char *zLike = 0;
5638 int i;
5639 int savedShowHeader = p->showHeader;
5640 ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
5641 for(i=1; i<nArg; i++){
5642 if( azArg[i][0]=='-' ){
5643 const char *z = azArg[i]+1;
5644 if( z[0]=='-' ) z++;
5645 if( strcmp(z,"preserve-rowids")==0 ){
@@ -4941,17 +5650,21 @@
5650 goto meta_command_exit;
5651 #else
5652 ShellSetFlag(p, SHFLG_PreserveRowid);
5653 #endif
5654 }else
5655 if( strcmp(z,"newlines")==0 ){
5656 ShellSetFlag(p, SHFLG_Newlines);
5657 }else
5658 {
5659 raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
5660 rc = 1;
5661 goto meta_command_exit;
5662 }
5663 }else if( zLike ){
5664 raw_printf(stderr, "Usage: .dump ?--preserve-rowids? "
5665 "?--newlines? ?LIKE-PATTERN?\n");
5666 rc = 1;
5667 goto meta_command_exit;
5668 }else{
5669 zLike = azArg[i];
5670 }
@@ -5033,10 +5746,12 @@
5746 if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
5747 if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
5748 rc = 2;
5749 }else
5750
5751 /* The ".explain" command is automatic now. It is largely pointless. It
5752 ** retained purely for backwards compatibility */
5753 if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
5754 int val = 1;
5755 if( nArg>=2 ){
5756 if( strcmp(azArg[1],"auto")==0 ){
5757 val = 99;
@@ -5549,11 +6264,13 @@
6264 p->mode = MODE_Quote;
6265 }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
6266 p->mode = MODE_Ascii;
6267 sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
6268 sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
6269 }else if( nArg==1 ){
6270 raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
6271 }else{
6272 raw_printf(stderr, "Error: mode should be one of: "
6273 "ascii column csv html insert line list quote tabs tcl\n");
6274 rc = 1;
6275 }
6276 p->cMode = p->mode;
@@ -5821,12 +6538,18 @@
6538 rc = 1;
6539 goto meta_command_exit;
6540 }
6541 if( zDiv ){
6542 sqlite3_stmt *pStmt = 0;
6543 rc = sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list",
6544 -1, &pStmt, 0);
6545 if( rc ){
6546 utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
6547 sqlite3_finalize(pStmt);
6548 rc = 1;
6549 goto meta_command_exit;
6550 }
6551 appendText(&sSelect, "SELECT sql FROM", 0);
6552 iSchema = 0;
6553 while( sqlite3_step(pStmt)==SQLITE_ROW ){
6554 const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);
6555 char zScNum[30];
@@ -7179,10 +7902,11 @@
7902 " -multiplex enable the multiplexor VFS\n"
7903 #endif
7904 " -newline SEP set output row separator. Default: '\\n'\n"
7905 " -nullvalue TEXT set text string for NULL values. Default ''\n"
7906 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
7907 " -quote set output mode to 'quote'\n"
7908 " -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
7909 " -separator SEP set output column separator. Default: '|'\n"
7910 " -stats print memory stats before each finalize\n"
7911 " -version show SQLite version\n"
7912 " -vfs NAME use NAME as the default VFS\n"
@@ -7474,10 +8198,12 @@
8198 i++;
8199 }else if( strcmp(z,"-html")==0 ){
8200 data.mode = MODE_Html;
8201 }else if( strcmp(z,"-list")==0 ){
8202 data.mode = MODE_List;
8203 }else if( strcmp(z,"-quote")==0 ){
8204 data.mode = MODE_Quote;
8205 }else if( strcmp(z,"-line")==0 ){
8206 data.mode = MODE_Line;
8207 }else if( strcmp(z,"-column")==0 ){
8208 data.mode = MODE_Column;
8209 }else if( strcmp(z,"-csv")==0 ){
@@ -7625,10 +8351,15 @@
8351 if( (zHistory = malloc(nHistory))!=0 ){
8352 sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
8353 }
8354 }
8355 if( zHistory ){ shell_read_history(zHistory); }
8356 #if HAVE_READLINE || HAVE_EDITLINE
8357 rl_attempted_completion_function = readline_completion;
8358 #elif HAVE_LINENOISE
8359 linenoiseSetCompletionCallback(linenoise_completion);
8360 #endif
8361 rc = process_input(&data, 0);
8362 if( zHistory ){
8363 shell_stifle_history(100);
8364 shell_write_history(zHistory);
8365 free(zHistory);
@@ -7648,5 +8379,6 @@
8379 for(i=0; i<argc; i++) sqlite3_free(argv[i]);
8380 sqlite3_free(argv);
8381 #endif
8382 return rc;
8383 }
8384
8385
+1590 -1279
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
11501150
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11511151
** [sqlite_version()] and [sqlite_source_id()].
11521152
*/
11531153
#define SQLITE_VERSION "3.20.0"
11541154
#define SQLITE_VERSION_NUMBER 3020000
1155
-#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
1155
+#define SQLITE_SOURCE_ID "2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40"
11561156
11571157
/*
11581158
** CAPI3REF: Run-Time Library Version Numbers
11591159
** KEYWORDS: sqlite3_version sqlite3_sourceid
11601160
**
@@ -1444,11 +1444,11 @@
14441444
**
14451445
** See also: [extended result code definitions]
14461446
*/
14471447
#define SQLITE_OK 0 /* Successful result */
14481448
/* beginning-of-error-codes */
1449
-#define SQLITE_ERROR 1 /* SQL error or missing database */
1449
+#define SQLITE_ERROR 1 /* Generic error */
14501450
#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
14511451
#define SQLITE_PERM 3 /* Access permission denied */
14521452
#define SQLITE_ABORT 4 /* Callback routine requested an abort */
14531453
#define SQLITE_BUSY 5 /* The database file is locked */
14541454
#define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -1459,19 +1459,19 @@
14591459
#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
14601460
#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
14611461
#define SQLITE_FULL 13 /* Insertion failed because database is full */
14621462
#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
14631463
#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
1464
-#define SQLITE_EMPTY 16 /* Database is empty */
1464
+#define SQLITE_EMPTY 16 /* Not used */
14651465
#define SQLITE_SCHEMA 17 /* The database schema changed */
14661466
#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
14671467
#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
14681468
#define SQLITE_MISMATCH 20 /* Data type mismatch */
14691469
#define SQLITE_MISUSE 21 /* Library used incorrectly */
14701470
#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
14711471
#define SQLITE_AUTH 23 /* Authorization denied */
1472
-#define SQLITE_FORMAT 24 /* Auxiliary database format error */
1472
+#define SQLITE_FORMAT 24 /* Not used */
14731473
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
14741474
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
14751475
#define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
14761476
#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
14771477
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -5294,10 +5294,32 @@
52945294
52955295
/*
52965296
** CAPI3REF: Result Values From A Query
52975297
** KEYWORDS: {column access functions}
52985298
** METHOD: sqlite3_stmt
5299
+**
5300
+** <b>Summary:</b>
5301
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5302
+** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
5303
+** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
5304
+** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
5305
+** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
5306
+** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
5307
+** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
5308
+** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
5309
+** [sqlite3_value|unprotected sqlite3_value] object.
5310
+** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
5311
+** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
5312
+** or a UTF-8 TEXT result in bytes
5313
+** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
5314
+** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
5315
+** TEXT in bytes
5316
+** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
5317
+** datatype of the result
5318
+** </table></blockquote>
5319
+**
5320
+** <b>Details:</b>
52995321
**
53005322
** ^These routines return information about a single column of the current
53015323
** result row of a query. ^In every case the first argument is a pointer
53025324
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
53035325
** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -5316,19 +5338,32 @@
53165338
** something other than [SQLITE_ROW], the results are undefined.
53175339
** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
53185340
** are called from a different thread while any of these routines
53195341
** are pending, then the results are undefined.
53205342
**
5343
+** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
5344
+** each return the value of a result column in a specific data format. If
5345
+** the result column is not initially in the requested format (for example,
5346
+** if the query returns an integer but the sqlite3_column_text() interface
5347
+** is used to extract the value) then an automatic type conversion is performed.
5348
+**
53215349
** ^The sqlite3_column_type() routine returns the
53225350
** [SQLITE_INTEGER | datatype code] for the initial data type
53235351
** of the result column. ^The returned value is one of [SQLITE_INTEGER],
5324
-** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
5325
-** returned by sqlite3_column_type() is only meaningful if no type
5326
-** conversions have occurred as described below. After a type conversion,
5327
-** the value returned by sqlite3_column_type() is undefined. Future
5352
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].
5353
+** The return value of sqlite3_column_type() can be used to decide which
5354
+** of the first six interface should be used to extract the column value.
5355
+** The value returned by sqlite3_column_type() is only meaningful if no
5356
+** automatic type conversions have occurred for the value in question.
5357
+** After a type conversion, the result of calling sqlite3_column_type()
5358
+** is undefined, though harmless. Future
53285359
** versions of SQLite may change the behavior of sqlite3_column_type()
53295360
** following a type conversion.
5361
+**
5362
+** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
5363
+** or sqlite3_column_bytes16() interfaces can be used to determine the size
5364
+** of that BLOB or string.
53305365
**
53315366
** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
53325367
** routine returns the number of bytes in that BLOB or string.
53335368
** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
53345369
** the string to UTF-8 and then returns the number of bytes.
@@ -5362,13 +5397,17 @@
53625397
** [sqlite3_bind_value()] and [sqlite3_result_value()].
53635398
** If the [unprotected sqlite3_value] object returned by
53645399
** [sqlite3_column_value()] is used in any other way, including calls
53655400
** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
53665401
** or [sqlite3_value_bytes()], the behavior is not threadsafe.
5402
+** Hence, the sqlite3_column_value() interface
5403
+** is normally only useful within the implementation of
5404
+** [application-defined SQL functions] or [virtual tables], not within
5405
+** top-level application code.
53675406
**
5368
-** These routines attempt to convert the value where appropriate. ^For
5369
-** example, if the internal representation is FLOAT and a text result
5407
+** The these routines may attempt to convert the datatype of the result.
5408
+** ^For example, if the internal representation is FLOAT and a text result
53705409
** is requested, [sqlite3_snprintf()] is used internally to perform the
53715410
** conversion automatically. ^(The following table details the conversions
53725411
** that are applied:
53735412
**
53745413
** <blockquote>
@@ -5436,11 +5475,11 @@
54365475
** with calls to sqlite3_column_bytes().
54375476
**
54385477
** ^The pointers returned are valid until a type conversion occurs as
54395478
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
54405479
** [sqlite3_finalize()] is called. ^The memory space used to hold strings
5441
-** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
5480
+** and BLOBs is freed automatically. Do not pass the pointers returned
54425481
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
54435482
** [sqlite3_free()].
54445483
**
54455484
** ^(If a memory allocation error occurs during the evaluation of any
54465485
** of these routines, a default value is returned. The default value
@@ -5447,19 +5486,19 @@
54475486
** is either the integer 0, the floating point number 0.0, or a NULL
54485487
** pointer. Subsequent calls to [sqlite3_errcode()] will return
54495488
** [SQLITE_NOMEM].)^
54505489
*/
54515490
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
5452
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
5453
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
54545491
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
54555492
SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
54565493
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
54575494
SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
54585495
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
5459
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
54605496
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
5497
+SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
5498
+SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
5499
+SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
54615500
54625501
/*
54635502
** CAPI3REF: Destroy A Prepared Statement Object
54645503
** DESTRUCTOR: sqlite3_stmt
54655504
**
@@ -5689,25 +5728,43 @@
56895728
56905729
/*
56915730
** CAPI3REF: Obtaining SQL Values
56925731
** METHOD: sqlite3_value
56935732
**
5694
-** The C-language implementation of SQL functions and aggregates uses
5695
-** this set of interface routines to access the parameter values on
5696
-** the function or aggregate.
5733
+** <b>Summary:</b>
5734
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5735
+** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
5736
+** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
5737
+** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
5738
+** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
5739
+** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
5740
+** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
5741
+** the native byteorder
5742
+** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
5743
+** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
5744
+** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
5745
+** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB
5746
+** or a UTF-8 TEXT in bytes
5747
+** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>
5748
+** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
5749
+** TEXT in bytes
5750
+** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default
5751
+** datatype of the value
5752
+** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
5753
+** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
5754
+** </table></blockquote>
56975755
**
5698
-** The xFunc (for scalar functions) or xStep (for aggregates) parameters
5699
-** to [sqlite3_create_function()] and [sqlite3_create_function16()]
5700
-** define callbacks that implement the SQL functions and aggregates.
5701
-** The 3rd parameter to these callbacks is an array of pointers to
5702
-** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
5703
-** each parameter to the SQL function. These routines are used to
5704
-** extract values from the [sqlite3_value] objects.
5756
+** <b>Details:</b>
5757
+**
5758
+** This routine extract type, size, and content information from
5759
+** [protected sqlite3_value] objects. Protected sqlite3_value objects
5760
+** are used to pass parameter information into implementation of
5761
+** [application-defined SQL functions] and [virtual tables].
57055762
**
57065763
** These routines work only with [protected sqlite3_value] objects.
57075764
** Any attempt to use these routines on an [unprotected sqlite3_value]
5708
-** object results in undefined behavior.
5765
+** is not threadsafe.
57095766
**
57105767
** ^These routines work just like the corresponding [column access functions]
57115768
** except that these routines take a single [protected sqlite3_value] object
57125769
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
57135770
**
@@ -5714,10 +5771,21 @@
57145771
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
57155772
** in the native byte-order of the host machine. ^The
57165773
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
57175774
** extract UTF-16 strings as big-endian and little-endian respectively.
57185775
**
5776
+** ^(The sqlite3_value_type(V) interface returns the
5777
+** [SQLITE_INTEGER | datatype code] for the initial datatype of the
5778
+** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
5779
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
5780
+** Other interfaces might change the datatype for an sqlite3_value object.
5781
+** For example, if the datatype is initially SQLITE_INTEGER and
5782
+** sqlite3_value_text(V) is called to extract a text value for that
5783
+** integer, then subsequent calls to sqlite3_value_type(V) might return
5784
+** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
5785
+** occurs is undefined and may change from one release of SQLite to the next.
5786
+**
57195787
** ^(The sqlite3_value_numeric_type() interface attempts to apply
57205788
** numeric affinity to the value. This means that an attempt is
57215789
** made to convert the value to an integer or floating point. If
57225790
** such a conversion is possible without loss of information (in other
57235791
** words, if the value is a string that looks like a number)
@@ -5732,19 +5800,19 @@
57325800
**
57335801
** These routines must be called from the same thread as
57345802
** the SQL function that supplied the [sqlite3_value*] parameters.
57355803
*/
57365804
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5737
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5738
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
57395805
SQLITE_API double sqlite3_value_double(sqlite3_value*);
57405806
SQLITE_API int sqlite3_value_int(sqlite3_value*);
57415807
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
57425808
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
57435809
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
57445810
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
57455811
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5812
+SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5813
+SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
57465814
SQLITE_API int sqlite3_value_type(sqlite3_value*);
57475815
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
57485816
57495817
/*
57505818
** CAPI3REF: Finding The Subtype Of SQL Values
@@ -15143,10 +15211,11 @@
1514315211
#define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
1514415212
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
1514515213
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
1514615214
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
1514715215
#define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
15216
+#define SQLITE_CountOfView 0x1000 /* The count-of-view optimization */
1514815217
#define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */
1514915218
#define SQLITE_AllOpts 0xffff /* All optimizations */
1515015219
1515115220
/*
1515215221
** Macros for testing whether or not optimizations are enabled or disabled.
@@ -17437,12 +17506,11 @@
1743717506
#endif
1743817507
SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);
1743917508
SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);
1744017509
SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
1744117510
SQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);
17442
-SQLITE_PRIVATE void sqlite3CommitTransaction(Parse*);
17443
-SQLITE_PRIVATE void sqlite3RollbackTransaction(Parse*);
17511
+SQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int);
1744417512
SQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);
1744517513
SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);
1744617514
SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
1744717515
SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
1744817516
SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
@@ -26962,21 +27030,21 @@
2696227030
}
2696327031
break;
2696427032
}
2696527033
#ifndef SQLITE_OMIT_SUBQUERY
2696627034
case TK_EXISTS: {
26967
- sqlite3TreeViewLine(pView, "EXISTS-expr");
27035
+ sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags);
2696827036
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
2696927037
break;
2697027038
}
2697127039
case TK_SELECT: {
26972
- sqlite3TreeViewLine(pView, "SELECT-expr");
27040
+ sqlite3TreeViewLine(pView, "SELECT-expr flags=0x%x", pExpr->flags);
2697327041
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
2697427042
break;
2697527043
}
2697627044
case TK_IN: {
26977
- sqlite3TreeViewLine(pView, "IN");
27045
+ sqlite3TreeViewLine(pView, "IN flags=0x%x", pExpr->flags);
2697827046
sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
2697927047
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
2698027048
sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
2698127049
}else{
2698227050
sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
@@ -29771,21 +29839,23 @@
2977129839
}
2977229840
return 1;
2977329841
}
2977429842
2977529843
/* This function (for internal use only) locates an element in an
29776
-** hash table that matches the given key. The hash for this key is
29777
-** also computed and returned in the *pH parameter.
29844
+** hash table that matches the given key. If no element is found,
29845
+** a pointer to a static null element with HashElem.data==0 is returned.
29846
+** If pH is not NULL, then the hash for this key is written to *pH.
2977829847
*/
2977929848
static HashElem *findElementWithHash(
2978029849
const Hash *pH, /* The pH to be searched */
2978129850
const char *pKey, /* The key we are searching for */
2978229851
unsigned int *pHash /* Write the hash value here */
2978329852
){
2978429853
HashElem *elem; /* Used to loop thru the element list */
2978529854
int count; /* Number of elements left to test */
2978629855
unsigned int h; /* The computed hash */
29856
+ static HashElem nullElement = { 0, 0, 0, 0 };
2978729857
2978829858
if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
2978929859
struct _ht *pEntry;
2979029860
h = strHash(pKey) % pH->htsize;
2979129861
pEntry = &pH->ht[h];
@@ -29794,19 +29864,19 @@
2979429864
}else{
2979529865
h = 0;
2979629866
elem = pH->first;
2979729867
count = pH->count;
2979829868
}
29799
- *pHash = h;
29869
+ if( pHash ) *pHash = h;
2980029870
while( count-- ){
2980129871
assert( elem!=0 );
2980229872
if( sqlite3StrICmp(elem->pKey,pKey)==0 ){
2980329873
return elem;
2980429874
}
2980529875
elem = elem->next;
2980629876
}
29807
- return 0;
29877
+ return &nullElement;
2980829878
}
2980929879
2981029880
/* Remove a single entry from the hash table given a pointer to that
2981129881
** element and a hash on the element's key.
2981229882
*/
@@ -29844,17 +29914,13 @@
2984429914
/* Attempt to locate an element of the hash table pH with a key
2984529915
** that matches pKey. Return the data for this element if it is
2984629916
** found, or NULL if there is no match.
2984729917
*/
2984829918
SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
29849
- HashElem *elem; /* The element that matches key */
29850
- unsigned int h; /* A hash on key */
29851
-
2985229919
assert( pH!=0 );
2985329920
assert( pKey!=0 );
29854
- elem = findElementWithHash(pH, pKey, &h);
29855
- return elem ? elem->data : 0;
29921
+ return findElementWithHash(pH, pKey, 0)->data;
2985629922
}
2985729923
2985829924
/* Insert an element into the hash table pH. The key is pKey
2985929925
** and the data is "data".
2986029926
**
@@ -29875,11 +29941,11 @@
2987529941
HashElem *new_elem; /* New element added to the pH */
2987629942
2987729943
assert( pH!=0 );
2987829944
assert( pKey!=0 );
2987929945
elem = findElementWithHash(pH,pKey,&h);
29880
- if( elem ){
29946
+ if( elem->data ){
2988129947
void *old_data = elem->data;
2988229948
if( data==0 ){
2988329949
removeElementGivenHash(pH,elem,h);
2988429950
}else{
2988529951
elem->data = data;
@@ -58883,14 +58949,16 @@
5888358949
** Allowed values for BtShared.btsFlags
5888458950
*/
5888558951
#define BTS_READ_ONLY 0x0001 /* Underlying file is readonly */
5888658952
#define BTS_PAGESIZE_FIXED 0x0002 /* Page size can no longer be changed */
5888758953
#define BTS_SECURE_DELETE 0x0004 /* PRAGMA secure_delete is enabled */
58888
-#define BTS_INITIALLY_EMPTY 0x0008 /* Database was empty at trans start */
58889
-#define BTS_NO_WAL 0x0010 /* Do not open write-ahead-log files */
58890
-#define BTS_EXCLUSIVE 0x0020 /* pWriter has an exclusive lock */
58891
-#define BTS_PENDING 0x0040 /* Waiting for read-locks to clear */
58954
+#define BTS_OVERWRITE 0x0008 /* Overwrite deleted content with zeros */
58955
+#define BTS_FAST_SECURE 0x000c /* Combination of the previous two */
58956
+#define BTS_INITIALLY_EMPTY 0x0010 /* Database was empty at trans start */
58957
+#define BTS_NO_WAL 0x0020 /* Do not open write-ahead-log files */
58958
+#define BTS_EXCLUSIVE 0x0040 /* pWriter has an exclusive lock */
58959
+#define BTS_PENDING 0x0080 /* Waiting for read-locks to clear */
5889258960
5889358961
/*
5889458962
** An instance of the following structure is used to hold information
5889558963
** about a cell. The parseCellPtr() function fills in this structure
5889658964
** based on information extract from the raw disk page.
@@ -61072,11 +61140,11 @@
6107261140
assert( iSize>=4 ); /* Minimum cell size is 4 */
6107361141
assert( iStart<=iLast );
6107461142
6107561143
/* Overwrite deleted information with zeros when the secure_delete
6107661144
** option is enabled */
61077
- if( pPage->pBt->btsFlags & BTS_SECURE_DELETE ){
61145
+ if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
6107861146
memset(&data[iStart], 0, iSize);
6107961147
}
6108061148
6108161149
/* The list of freeblocks must be in ascending order. Find the
6108261150
** spot on the list where iStart should be inserted.
@@ -61363,11 +61431,11 @@
6136361431
assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
6136461432
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
6136561433
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
6136661434
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6136761435
assert( sqlite3_mutex_held(pBt->mutex) );
61368
- if( pBt->btsFlags & BTS_SECURE_DELETE ){
61436
+ if( pBt->btsFlags & BTS_FAST_SECURE ){
6136961437
memset(&data[hdr], 0, pBt->usableSize - hdr);
6137061438
}
6137161439
data[hdr] = (char)flags;
6137261440
first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);
6137361441
memset(&data[hdr+1], 0, 4);
@@ -61786,12 +61854,14 @@
6178661854
p->pBt = pBt;
6178761855
6178861856
pBt->pCursor = 0;
6178961857
pBt->pPage1 = 0;
6179061858
if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;
61791
-#ifdef SQLITE_SECURE_DELETE
61859
+#if defined(SQLITE_SECURE_DELETE)
6179261860
pBt->btsFlags |= BTS_SECURE_DELETE;
61861
+#elif defined(SQLITE_FAST_SECURE_DELETE)
61862
+ pBt->btsFlags |= BTS_OVERWRITE;
6179361863
#endif
6179461864
/* EVIDENCE-OF: R-51873-39618 The page size for a database file is
6179561865
** determined by the 2-byte integer located at an offset of 16 bytes from
6179661866
** the beginning of the database file. */
6179761867
pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);
@@ -62235,23 +62305,38 @@
6223562305
sqlite3BtreeLeave(p);
6223662306
return n;
6223762307
}
6223862308
6223962309
/*
62240
-** Set the BTS_SECURE_DELETE flag if newFlag is 0 or 1. If newFlag is -1,
62241
-** then make no changes. Always return the value of the BTS_SECURE_DELETE
62242
-** setting after the change.
62310
+** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:
62311
+**
62312
+** newFlag==0 Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared
62313
+** newFlag==1 BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared
62314
+** newFlag==2 BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set
62315
+** newFlag==(-1) No changes
62316
+**
62317
+** This routine acts as a query if newFlag is less than zero
62318
+**
62319
+** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but
62320
+** freelist leaf pages are not written back to the database. Thus in-page
62321
+** deleted content is cleared, but freelist deleted content is not.
62322
+**
62323
+** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition
62324
+** that freelist leaf pages are written back into the database, increasing
62325
+** the amount of disk I/O.
6224362326
*/
6224462327
SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
6224562328
int b;
6224662329
if( p==0 ) return 0;
6224762330
sqlite3BtreeEnter(p);
62331
+ assert( BTS_OVERWRITE==BTS_SECURE_DELETE*2 );
62332
+ assert( BTS_FAST_SECURE==(BTS_OVERWRITE|BTS_SECURE_DELETE) );
6224862333
if( newFlag>=0 ){
62249
- p->pBt->btsFlags &= ~BTS_SECURE_DELETE;
62250
- if( newFlag ) p->pBt->btsFlags |= BTS_SECURE_DELETE;
62251
- }
62252
- b = (p->pBt->btsFlags & BTS_SECURE_DELETE)!=0;
62334
+ p->pBt->btsFlags &= ~BTS_FAST_SECURE;
62335
+ p->pBt->btsFlags |= BTS_SECURE_DELETE*newFlag;
62336
+ }
62337
+ b = (p->pBt->btsFlags & BTS_FAST_SECURE)/BTS_SECURE_DELETE;
6225362338
sqlite3BtreeLeave(p);
6225462339
return b;
6225562340
}
6225662341
6225762342
/*
@@ -66642,11 +66727,11 @@
6664266727
** But not if we are in secure-delete mode. In secure-delete mode,
6664366728
** the dropCell() routine will overwrite the entire cell with zeroes.
6664466729
** In this case, temporarily copy the cell into the aOvflSpace[]
6664566730
** buffer. It will be copied out again as soon as the aSpace[] buffer
6664666731
** is allocated. */
66647
- if( pBt->btsFlags & BTS_SECURE_DELETE ){
66732
+ if( pBt->btsFlags & BTS_FAST_SECURE ){
6664866733
int iOff;
6664966734
6665066735
iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
6665166736
if( (iOff+szNew[i])>(int)pBt->usableSize ){
6665266737
rc = SQLITE_CORRUPT_BKPT;
@@ -72056,25 +72141,31 @@
7205672141
** constants. The registers begin with iDest and increase consecutively.
7205772142
** One register is initialized for each characgter in zTypes[]. For each
7205872143
** "s" character in zTypes[], the register is a string if the argument is
7205972144
** not NULL, or OP_Null if the value is a null pointer. For each "i" character
7206072145
** in zTypes[], the register is initialized to an integer.
72146
+**
72147
+** If the input string does not end with "X" then an OP_ResultRow instruction
72148
+** is generated for the values inserted.
7206172149
*/
7206272150
SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
7206372151
va_list ap;
7206472152
int i;
7206572153
char c;
7206672154
va_start(ap, zTypes);
7206772155
for(i=0; (c = zTypes[i])!=0; i++){
7206872156
if( c=='s' ){
7206972157
const char *z = va_arg(ap, const char*);
72070
- sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest++, 0, z, 0);
72158
+ sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest+i, 0, z, 0);
72159
+ }else if( c=='i' ){
72160
+ sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest+i);
7207172161
}else{
72072
- assert( c=='i' );
72073
- sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++);
72162
+ goto skip_op_resultrow;
7207472163
}
7207572164
}
72165
+ sqlite3VdbeAddOp2(p, OP_ResultRow, iDest, i);
72166
+skip_op_resultrow:
7207672167
va_end(ap);
7207772168
}
7207872169
7207972170
/*
7208072171
** Add an opcode that includes the p4 value as a pointer.
@@ -89667,19 +89758,21 @@
8966789758
static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
8966889759
int rc;
8966989760
testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
8967089761
testcase( ExprHasProperty(pExpr, EP_Reduced) );
8967189762
rc = pWalker->xExprCallback(pWalker, pExpr);
89672
- if( rc || ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
89673
- return rc & WRC_Abort;
89674
- }
89675
- if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
89676
- if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
89677
- if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89678
- if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
89679
- }else if( pExpr->x.pList ){
89680
- if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
89763
+ if( rc ) return rc & WRC_Abort;
89764
+ if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
89765
+ if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
89766
+ assert( pExpr->x.pList==0 || pExpr->pRight==0 );
89767
+ if( pExpr->pRight ){
89768
+ if( walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
89769
+ }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89770
+ if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
89771
+ }else if( pExpr->x.pList ){
89772
+ if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
89773
+ }
8968189774
}
8968289775
return WRC_Continue;
8968389776
}
8968489777
SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
8968589778
return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;
@@ -89730,11 +89823,11 @@
8973089823
struct SrcList_item *pItem;
8973189824
8973289825
pSrc = p->pSrc;
8973389826
if( ALWAYS(pSrc) ){
8973489827
for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
89735
- if( sqlite3WalkSelect(pWalker, pItem->pSelect) ){
89828
+ if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){
8973689829
return WRC_Abort;
8973789830
}
8973889831
if( pItem->fg.isTabFunc
8973989832
&& sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)
8974089833
){
@@ -89762,11 +89855,12 @@
8976289855
** If the Walker does not have an xSelectCallback() then this routine
8976389856
** is a no-op returning WRC_Continue.
8976489857
*/
8976589858
SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
8976689859
int rc;
89767
- if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
89860
+ if( p==0 ) return WRC_Continue;
89861
+ if( pWalker->xSelectCallback==0 ) return WRC_Continue;
8976889862
do{
8976989863
rc = pWalker->xSelectCallback(pWalker, p);
8977089864
if( rc ) return rc & WRC_Abort;
8977189865
if( sqlite3WalkSelectExpr(pWalker, p)
8977289866
|| sqlite3WalkSelectFrom(pWalker, p)
@@ -90261,10 +90355,11 @@
9026190355
sqlite3ExprDelete(db, pExpr->pLeft);
9026290356
pExpr->pLeft = 0;
9026390357
sqlite3ExprDelete(db, pExpr->pRight);
9026490358
pExpr->pRight = 0;
9026590359
pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
90360
+ ExprSetProperty(pExpr, EP_Leaf);
9026690361
lookupname_end:
9026790362
if( cnt==1 ){
9026890363
assert( pNC!=0 );
9026990364
if( !ExprHasProperty(pExpr, EP_Alias) ){
9027090365
sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
@@ -92067,11 +92162,11 @@
9206792162
memset(pNew, 0, sizeof(Expr));
9206892163
pNew->op = (u8)op;
9206992164
pNew->iAgg = -1;
9207092165
if( pToken ){
9207192166
if( nExtra==0 ){
92072
- pNew->flags |= EP_IntValue;
92167
+ pNew->flags |= EP_IntValue|EP_Leaf;
9207392168
pNew->u.iValue = iValue;
9207492169
}else{
9207592170
pNew->u.zToken = (char*)&pNew[1];
9207692171
assert( pToken->z!=0 || pToken->n==0 );
9207792172
if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
@@ -92348,12 +92443,13 @@
9234892443
#endif
9234992444
if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
9235092445
/* The Expr.x union is never used at the same time as Expr.pRight */
9235192446
assert( p->x.pList==0 || p->pRight==0 );
9235292447
if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
92353
- sqlite3ExprDelete(db, p->pRight);
92354
- if( ExprHasProperty(p, EP_xIsSelect) ){
92448
+ if( p->pRight ){
92449
+ sqlite3ExprDeleteNN(db, p->pRight);
92450
+ }else if( ExprHasProperty(p, EP_xIsSelect) ){
9235592451
sqlite3SelectDelete(db, p->x.pSelect);
9235692452
}else{
9235792453
sqlite3ExprListDelete(db, p->x.pList);
9235892454
}
9235992455
}
@@ -103955,16 +104051,16 @@
103955104051
pItem = &pList->a[pList->nSrc-1];
103956104052
if( pDatabase && pDatabase->z==0 ){
103957104053
pDatabase = 0;
103958104054
}
103959104055
if( pDatabase ){
103960
- Token *pTemp = pDatabase;
103961
- pDatabase = pTable;
103962
- pTable = pTemp;
104056
+ pItem->zName = sqlite3NameFromToken(db, pDatabase);
104057
+ pItem->zDatabase = sqlite3NameFromToken(db, pTable);
104058
+ }else{
104059
+ pItem->zName = sqlite3NameFromToken(db, pTable);
104060
+ pItem->zDatabase = 0;
103963104061
}
103964
- pItem->zName = sqlite3NameFromToken(db, pTable);
103965
- pItem->zDatabase = sqlite3NameFromToken(db, pDatabase);
103966104062
return pList;
103967104063
}
103968104064
103969104065
/*
103970104066
** Assign VdbeCursor index numbers to all tables in a SrcList
@@ -104149,40 +104245,29 @@
104149104245
}
104150104246
sqlite3VdbeAddOp0(v, OP_AutoCommit);
104151104247
}
104152104248
104153104249
/*
104154
-** Generate VDBE code for a COMMIT statement.
104155
-*/
104156
-SQLITE_PRIVATE void sqlite3CommitTransaction(Parse *pParse){
104157
- Vdbe *v;
104158
-
104159
- assert( pParse!=0 );
104160
- assert( pParse->db!=0 );
104161
- if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ){
104162
- return;
104163
- }
104164
- v = sqlite3GetVdbe(pParse);
104165
- if( v ){
104166
- sqlite3VdbeAddOp1(v, OP_AutoCommit, 1);
104167
- }
104168
-}
104169
-
104170
-/*
104171
-** Generate VDBE code for a ROLLBACK statement.
104172
-*/
104173
-SQLITE_PRIVATE void sqlite3RollbackTransaction(Parse *pParse){
104174
- Vdbe *v;
104175
-
104176
- assert( pParse!=0 );
104177
- assert( pParse->db!=0 );
104178
- if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ){
104179
- return;
104180
- }
104181
- v = sqlite3GetVdbe(pParse);
104182
- if( v ){
104183
- sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1);
104250
+** Generate VDBE code for a COMMIT or ROLLBACK statement.
104251
+** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise
104252
+** code is generated for a COMMIT.
104253
+*/
104254
+SQLITE_PRIVATE void sqlite3EndTransaction(Parse *pParse, int eType){
104255
+ Vdbe *v;
104256
+ int isRollback;
104257
+
104258
+ assert( pParse!=0 );
104259
+ assert( pParse->db!=0 );
104260
+ assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );
104261
+ isRollback = eType==TK_ROLLBACK;
104262
+ if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION,
104263
+ isRollback ? "ROLLBACK" : "COMMIT", 0, 0) ){
104264
+ return;
104265
+ }
104266
+ v = sqlite3GetVdbe(pParse);
104267
+ if( v ){
104268
+ sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);
104184104269
}
104185104270
}
104186104271
104187104272
/*
104188104273
** This function is called by the parser when it parses a command to create,
@@ -104759,11 +104844,11 @@
104759104844
** request a definition of the collating sequence. If this doesn't work,
104760104845
** an equivalent collating sequence that uses a text encoding different
104761104846
** from the main database is substituted, if one is available.
104762104847
*/
104763104848
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
104764
- if( pColl ){
104849
+ if( pColl && pColl->xCmp==0 ){
104765104850
const char *zName = pColl->zName;
104766104851
sqlite3 *db = pParse->db;
104767104852
CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);
104768104853
if( !p ){
104769104854
return SQLITE_ERROR;
@@ -104795,22 +104880,21 @@
104795104880
){
104796104881
CollSeq *pColl;
104797104882
pColl = sqlite3HashFind(&db->aCollSeq, zName);
104798104883
104799104884
if( 0==pColl && create ){
104800
- int nName = sqlite3Strlen30(zName);
104801
- pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1);
104885
+ int nName = sqlite3Strlen30(zName) + 1;
104886
+ pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName);
104802104887
if( pColl ){
104803104888
CollSeq *pDel = 0;
104804104889
pColl[0].zName = (char*)&pColl[3];
104805104890
pColl[0].enc = SQLITE_UTF8;
104806104891
pColl[1].zName = (char*)&pColl[3];
104807104892
pColl[1].enc = SQLITE_UTF16LE;
104808104893
pColl[2].zName = (char*)&pColl[3];
104809104894
pColl[2].enc = SQLITE_UTF16BE;
104810104895
memcpy(pColl[0].zName, zName, nName);
104811
- pColl[0].zName[nName] = 0;
104812104896
pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);
104813104897
104814104898
/* If a malloc() failure occurred in sqlite3HashInsert(), it will
104815104899
** return the pColl pointer to be deleted (because it wasn't added
104816104900
** to the hash table).
@@ -104946,11 +105030,12 @@
104946105030
int i;
104947105031
for(i=0; i<nDef; i++){
104948105032
FuncDef *pOther;
104949105033
const char *zName = aDef[i].zName;
104950105034
int nName = sqlite3Strlen30(zName);
104951
- int h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;
105035
+ int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;
105036
+ assert( zName[0]>='a' && zName[0]<='z' );
104952105037
pOther = functionSearch(h, zName);
104953105038
if( pOther ){
104954105039
assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
104955105040
aDef[i].pNext = pOther->pNext;
104956105041
pOther->pNext = &aDef[i];
@@ -106109,20 +106194,20 @@
106109106194
static void typeofFunc(
106110106195
sqlite3_context *context,
106111106196
int NotUsed,
106112106197
sqlite3_value **argv
106113106198
){
106114
- const char *z = 0;
106199
+ static const char *azType[] = { "integer", "real", "text", "blob", "null" };
106200
+ int i = sqlite3_value_type(argv[0]) - 1;
106115106201
UNUSED_PARAMETER(NotUsed);
106116
- switch( sqlite3_value_type(argv[0]) ){
106117
- case SQLITE_INTEGER: z = "integer"; break;
106118
- case SQLITE_TEXT: z = "text"; break;
106119
- case SQLITE_FLOAT: z = "real"; break;
106120
- case SQLITE_BLOB: z = "blob"; break;
106121
- default: z = "null"; break;
106122
- }
106123
- sqlite3_result_text(context, z, -1, SQLITE_STATIC);
106202
+ assert( i>=0 && i<ArraySize(azType) );
106203
+ assert( SQLITE_INTEGER==1 );
106204
+ assert( SQLITE_FLOAT==2 );
106205
+ assert( SQLITE_TEXT==3 );
106206
+ assert( SQLITE_BLOB==4 );
106207
+ assert( SQLITE_NULL==5 );
106208
+ sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
106124106209
}
106125106210
106126106211
106127106212
/*
106128106213
** Implementation of the length() function
@@ -113151,39 +113236,42 @@
113151113236
#define PragTyp_DATABASE_LIST 10
113152113237
#define PragTyp_DEFAULT_CACHE_SIZE 11
113153113238
#define PragTyp_ENCODING 12
113154113239
#define PragTyp_FOREIGN_KEY_CHECK 13
113155113240
#define PragTyp_FOREIGN_KEY_LIST 14
113156
-#define PragTyp_INCREMENTAL_VACUUM 15
113157
-#define PragTyp_INDEX_INFO 16
113158
-#define PragTyp_INDEX_LIST 17
113159
-#define PragTyp_INTEGRITY_CHECK 18
113160
-#define PragTyp_JOURNAL_MODE 19
113161
-#define PragTyp_JOURNAL_SIZE_LIMIT 20
113162
-#define PragTyp_LOCK_PROXY_FILE 21
113163
-#define PragTyp_LOCKING_MODE 22
113164
-#define PragTyp_PAGE_COUNT 23
113165
-#define PragTyp_MMAP_SIZE 24
113166
-#define PragTyp_OPTIMIZE 25
113167
-#define PragTyp_PAGE_SIZE 26
113168
-#define PragTyp_SECURE_DELETE 27
113169
-#define PragTyp_SHRINK_MEMORY 28
113170
-#define PragTyp_SOFT_HEAP_LIMIT 29
113171
-#define PragTyp_SYNCHRONOUS 30
113172
-#define PragTyp_TABLE_INFO 31
113173
-#define PragTyp_TEMP_STORE 32
113174
-#define PragTyp_TEMP_STORE_DIRECTORY 33
113175
-#define PragTyp_THREADS 34
113176
-#define PragTyp_WAL_AUTOCHECKPOINT 35
113177
-#define PragTyp_WAL_CHECKPOINT 36
113178
-#define PragTyp_ACTIVATE_EXTENSIONS 37
113179
-#define PragTyp_HEXKEY 38
113180
-#define PragTyp_KEY 39
113181
-#define PragTyp_REKEY 40
113182
-#define PragTyp_LOCK_STATUS 41
113183
-#define PragTyp_PARSER_TRACE 42
113184
-#define PragTyp_STATS 43
113241
+#define PragTyp_FUNCTION_LIST 15
113242
+#define PragTyp_INCREMENTAL_VACUUM 16
113243
+#define PragTyp_INDEX_INFO 17
113244
+#define PragTyp_INDEX_LIST 18
113245
+#define PragTyp_INTEGRITY_CHECK 19
113246
+#define PragTyp_JOURNAL_MODE 20
113247
+#define PragTyp_JOURNAL_SIZE_LIMIT 21
113248
+#define PragTyp_LOCK_PROXY_FILE 22
113249
+#define PragTyp_LOCKING_MODE 23
113250
+#define PragTyp_PAGE_COUNT 24
113251
+#define PragTyp_MMAP_SIZE 25
113252
+#define PragTyp_MODULE_LIST 26
113253
+#define PragTyp_OPTIMIZE 27
113254
+#define PragTyp_PAGE_SIZE 28
113255
+#define PragTyp_PRAGMA_LIST 29
113256
+#define PragTyp_SECURE_DELETE 30
113257
+#define PragTyp_SHRINK_MEMORY 31
113258
+#define PragTyp_SOFT_HEAP_LIMIT 32
113259
+#define PragTyp_SYNCHRONOUS 33
113260
+#define PragTyp_TABLE_INFO 34
113261
+#define PragTyp_TEMP_STORE 35
113262
+#define PragTyp_TEMP_STORE_DIRECTORY 36
113263
+#define PragTyp_THREADS 37
113264
+#define PragTyp_WAL_AUTOCHECKPOINT 38
113265
+#define PragTyp_WAL_CHECKPOINT 39
113266
+#define PragTyp_ACTIVATE_EXTENSIONS 40
113267
+#define PragTyp_HEXKEY 41
113268
+#define PragTyp_KEY 42
113269
+#define PragTyp_REKEY 43
113270
+#define PragTyp_LOCK_STATUS 44
113271
+#define PragTyp_PARSER_TRACE 45
113272
+#define PragTyp_STATS 46
113185113273
113186113274
/* Property flags associated with various pragma. */
113187113275
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
113188113276
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
113189113277
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -113225,30 +113313,33 @@
113225113313
/* 24 */ "origin",
113226113314
/* 25 */ "partial",
113227113315
/* 26 */ "seq", /* Used by: database_list */
113228113316
/* 27 */ "name",
113229113317
/* 28 */ "file",
113230
- /* 29 */ "seq", /* Used by: collation_list */
113231
- /* 30 */ "name",
113232
- /* 31 */ "id", /* Used by: foreign_key_list */
113233
- /* 32 */ "seq",
113234
- /* 33 */ "table",
113235
- /* 34 */ "from",
113236
- /* 35 */ "to",
113237
- /* 36 */ "on_update",
113238
- /* 37 */ "on_delete",
113239
- /* 38 */ "match",
113240
- /* 39 */ "table", /* Used by: foreign_key_check */
113241
- /* 40 */ "rowid",
113242
- /* 41 */ "parent",
113243
- /* 42 */ "fkid",
113244
- /* 43 */ "busy", /* Used by: wal_checkpoint */
113245
- /* 44 */ "log",
113246
- /* 45 */ "checkpointed",
113247
- /* 46 */ "timeout", /* Used by: busy_timeout */
113248
- /* 47 */ "database", /* Used by: lock_status */
113249
- /* 48 */ "status",
113318
+ /* 29 */ "name", /* Used by: function_list */
113319
+ /* 30 */ "builtin",
113320
+ /* 31 */ "name", /* Used by: module_list pragma_list */
113321
+ /* 32 */ "seq", /* Used by: collation_list */
113322
+ /* 33 */ "name",
113323
+ /* 34 */ "id", /* Used by: foreign_key_list */
113324
+ /* 35 */ "seq",
113325
+ /* 36 */ "table",
113326
+ /* 37 */ "from",
113327
+ /* 38 */ "to",
113328
+ /* 39 */ "on_update",
113329
+ /* 40 */ "on_delete",
113330
+ /* 41 */ "match",
113331
+ /* 42 */ "table", /* Used by: foreign_key_check */
113332
+ /* 43 */ "rowid",
113333
+ /* 44 */ "parent",
113334
+ /* 45 */ "fkid",
113335
+ /* 46 */ "busy", /* Used by: wal_checkpoint */
113336
+ /* 47 */ "log",
113337
+ /* 48 */ "checkpointed",
113338
+ /* 49 */ "timeout", /* Used by: busy_timeout */
113339
+ /* 50 */ "database", /* Used by: lock_status */
113340
+ /* 51 */ "status",
113250113341
};
113251113342
113252113343
/* Definitions of all built-in pragmas */
113253113344
typedef struct PragmaName {
113254113345
const char *const zName; /* Name of pragma */
@@ -113290,11 +113381,11 @@
113290113381
#endif
113291113382
#endif
113292113383
{/* zName: */ "busy_timeout",
113293113384
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
113294113385
/* ePragFlg: */ PragFlg_Result0,
113295
- /* ColNames: */ 46, 1,
113386
+ /* ColNames: */ 49, 1,
113296113387
/* iArg: */ 0 },
113297113388
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113298113389
{/* zName: */ "cache_size",
113299113390
/* ePragTyp: */ PragTyp_CACHE_SIZE,
113300113391
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -113327,11 +113418,11 @@
113327113418
#endif
113328113419
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113329113420
{/* zName: */ "collation_list",
113330113421
/* ePragTyp: */ PragTyp_COLLATION_LIST,
113331113422
/* ePragFlg: */ PragFlg_Result0,
113332
- /* ColNames: */ 29, 2,
113423
+ /* ColNames: */ 32, 2,
113333113424
/* iArg: */ 0 },
113334113425
#endif
113335113426
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
113336113427
{/* zName: */ "compile_options",
113337113428
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -113399,18 +113490,18 @@
113399113490
#endif
113400113491
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113401113492
{/* zName: */ "foreign_key_check",
113402113493
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
113403113494
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
113404
- /* ColNames: */ 39, 4,
113495
+ /* ColNames: */ 42, 4,
113405113496
/* iArg: */ 0 },
113406113497
#endif
113407113498
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
113408113499
{/* zName: */ "foreign_key_list",
113409113500
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
113410113501
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
113411
- /* ColNames: */ 31, 8,
113502
+ /* ColNames: */ 34, 8,
113412113503
/* iArg: */ 0 },
113413113504
#endif
113414113505
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113415113506
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113416113507
{/* zName: */ "foreign_keys",
@@ -113436,10 +113527,19 @@
113436113527
{/* zName: */ "fullfsync",
113437113528
/* ePragTyp: */ PragTyp_FLAG,
113438113529
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113439113530
/* ColNames: */ 0, 0,
113440113531
/* iArg: */ SQLITE_FullFSync },
113532
+#endif
113533
+#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113534
+#if defined(SQLITE_INTROSPECTION_PRAGMAS)
113535
+ {/* zName: */ "function_list",
113536
+ /* ePragTyp: */ PragTyp_FUNCTION_LIST,
113537
+ /* ePragFlg: */ PragFlg_Result0,
113538
+ /* ColNames: */ 29, 2,
113539
+ /* iArg: */ 0 },
113540
+#endif
113441113541
#endif
113442113542
#if defined(SQLITE_HAS_CODEC)
113443113543
{/* zName: */ "hexkey",
113444113544
/* ePragTyp: */ PragTyp_HEXKEY,
113445113545
/* ePragFlg: */ 0,
@@ -113526,11 +113626,11 @@
113526113626
#endif
113527113627
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
113528113628
{/* zName: */ "lock_status",
113529113629
/* ePragTyp: */ PragTyp_LOCK_STATUS,
113530113630
/* ePragFlg: */ PragFlg_Result0,
113531
- /* ColNames: */ 47, 2,
113631
+ /* ColNames: */ 50, 2,
113532113632
/* iArg: */ 0 },
113533113633
#endif
113534113634
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113535113635
{/* zName: */ "locking_mode",
113536113636
/* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -113545,10 +113645,21 @@
113545113645
{/* zName: */ "mmap_size",
113546113646
/* ePragTyp: */ PragTyp_MMAP_SIZE,
113547113647
/* ePragFlg: */ 0,
113548113648
/* ColNames: */ 0, 0,
113549113649
/* iArg: */ 0 },
113650
+#endif
113651
+#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113652
+#if !defined(SQLITE_OMIT_VIRTUALTABLE)
113653
+#if defined(SQLITE_INTROSPECTION_PRAGMAS)
113654
+ {/* zName: */ "module_list",
113655
+ /* ePragTyp: */ PragTyp_MODULE_LIST,
113656
+ /* ePragFlg: */ PragFlg_Result0,
113657
+ /* ColNames: */ 31, 1,
113658
+ /* iArg: */ 0 },
113659
+#endif
113660
+#endif
113550113661
#endif
113551113662
{/* zName: */ "optimize",
113552113663
/* ePragTyp: */ PragTyp_OPTIMIZE,
113553113664
/* ePragFlg: */ PragFlg_Result1|PragFlg_NeedSchema,
113554113665
/* ColNames: */ 0, 0,
@@ -113569,10 +113680,17 @@
113569113680
{/* zName: */ "parser_trace",
113570113681
/* ePragTyp: */ PragTyp_PARSER_TRACE,
113571113682
/* ePragFlg: */ 0,
113572113683
/* ColNames: */ 0, 0,
113573113684
/* iArg: */ 0 },
113685
+#endif
113686
+#if defined(SQLITE_INTROSPECTION_PRAGMAS)
113687
+ {/* zName: */ "pragma_list",
113688
+ /* ePragTyp: */ PragTyp_PRAGMA_LIST,
113689
+ /* ePragFlg: */ PragFlg_Result0,
113690
+ /* ColNames: */ 31, 1,
113691
+ /* iArg: */ 0 },
113574113692
#endif
113575113693
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113576113694
{/* zName: */ "query_only",
113577113695
/* ePragTyp: */ PragTyp_FLAG,
113578113696
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -113733,11 +113851,11 @@
113733113851
/* ColNames: */ 0, 0,
113734113852
/* iArg: */ 0 },
113735113853
{/* zName: */ "wal_checkpoint",
113736113854
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
113737113855
/* ePragFlg: */ PragFlg_NeedSchema,
113738
- /* ColNames: */ 43, 3,
113856
+ /* ColNames: */ 46, 3,
113739113857
/* iArg: */ 0 },
113740113858
#endif
113741113859
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113742113860
{/* zName: */ "writable_schema",
113743113861
/* ePragTyp: */ PragTyp_FLAG,
@@ -113744,11 +113862,11 @@
113744113862
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113745113863
/* ColNames: */ 0, 0,
113746113864
/* iArg: */ SQLITE_WriteSchema },
113747113865
#endif
113748113866
};
113749
-/* Number of pragmas: 60 on by default, 74 total. */
113867
+/* Number of pragmas: 60 on by default, 77 total. */
113750113868
113751113869
/************** End of pragma.h **********************************************/
113752113870
/************** Continuing where we left off in pragma.c *********************/
113753113871
113754113872
/*
@@ -114234,22 +114352,26 @@
114234114352
break;
114235114353
}
114236114354
114237114355
/*
114238114356
** PRAGMA [schema.]secure_delete
114239
- ** PRAGMA [schema.]secure_delete=ON/OFF
114357
+ ** PRAGMA [schema.]secure_delete=ON/OFF/FAST
114240114358
**
114241114359
** The first form reports the current setting for the
114242114360
** secure_delete flag. The second form changes the secure_delete
114243
- ** flag setting and reports thenew value.
114361
+ ** flag setting and reports the new value.
114244114362
*/
114245114363
case PragTyp_SECURE_DELETE: {
114246114364
Btree *pBt = pDb->pBt;
114247114365
int b = -1;
114248114366
assert( pBt!=0 );
114249114367
if( zRight ){
114250
- b = sqlite3GetBoolean(zRight, 0);
114368
+ if( sqlite3_stricmp(zRight, "fast")==0 ){
114369
+ b = 2;
114370
+ }else{
114371
+ b = sqlite3GetBoolean(zRight, 0);
114372
+ }
114251114373
}
114252114374
if( pId2->n==0 && b>=0 ){
114253114375
int ii;
114254114376
for(ii=0; ii<db->nDb; ii++){
114255114377
sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
@@ -114827,11 +114949,10 @@
114827114949
pCol->zName,
114828114950
sqlite3ColumnType(pCol,""),
114829114951
pCol->notNull ? 1 : 0,
114830114952
pCol->pDflt ? pCol->pDflt->u.zToken : 0,
114831114953
k);
114832
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
114833114954
}
114834114955
}
114835114956
}
114836114957
break;
114837114958
@@ -114847,13 +114968,12 @@
114847114968
pTab->zName,
114848114969
0,
114849114970
pTab->szTabRow,
114850114971
pTab->nRowLogEst,
114851114972
pTab->tabFlags);
114852
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114853114973
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114854
- sqlite3VdbeMultiLoad(v, 2, "siii",
114974
+ sqlite3VdbeMultiLoad(v, 2, "siiiX",
114855114975
pIdx->zName,
114856114976
pIdx->szIdxRow,
114857114977
pIdx->aiRowLogEst[0],
114858114978
pIdx->hasStat1);
114859114979
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
@@ -114882,14 +115002,14 @@
114882115002
pTab = pIdx->pTable;
114883115003
sqlite3CodeVerifySchema(pParse, iDb);
114884115004
assert( pParse->nMem<=pPragma->nPragCName );
114885115005
for(i=0; i<mx; i++){
114886115006
i16 cnum = pIdx->aiColumn[i];
114887
- sqlite3VdbeMultiLoad(v, 1, "iis", i, cnum,
115007
+ sqlite3VdbeMultiLoad(v, 1, "iisX", i, cnum,
114888115008
cnum<0 ? 0 : pTab->aCol[cnum].zName);
114889115009
if( pPragma->iArg ){
114890
- sqlite3VdbeMultiLoad(v, 4, "isi",
115010
+ sqlite3VdbeMultiLoad(v, 4, "isiX",
114891115011
pIdx->aSortOrder[i],
114892115012
pIdx->azColl[i],
114893115013
i<pIdx->nKeyCol);
114894115014
}
114895115015
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
@@ -114912,11 +115032,10 @@
114912115032
i,
114913115033
pIdx->zName,
114914115034
IsUniqueIndex(pIdx),
114915115035
azOrigin[pIdx->idxType],
114916115036
pIdx->pPartIdxWhere!=0);
114917
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114918115037
}
114919115038
}
114920115039
}
114921115040
break;
114922115041
@@ -114928,11 +115047,10 @@
114928115047
assert( db->aDb[i].zDbSName!=0 );
114929115048
sqlite3VdbeMultiLoad(v, 1, "iss",
114930115049
i,
114931115050
db->aDb[i].zDbSName,
114932115051
sqlite3BtreeGetFilename(db->aDb[i].pBt));
114933
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
114934115052
}
114935115053
}
114936115054
break;
114937115055
114938115056
case PragTyp_COLLATION_LIST: {
@@ -114940,14 +115058,57 @@
114940115058
HashElem *p;
114941115059
pParse->nMem = 2;
114942115060
for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
114943115061
CollSeq *pColl = (CollSeq *)sqliteHashData(p);
114944115062
sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
115063
+ }
115064
+ }
115065
+ break;
115066
+
115067
+#ifdef SQLITE_INTROSPECTION_PRAGMAS
115068
+ case PragTyp_FUNCTION_LIST: {
115069
+ int i;
115070
+ HashElem *j;
115071
+ FuncDef *p;
115072
+ pParse->nMem = 2;
115073
+ for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
115074
+ for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
115075
+ sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
115076
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
115077
+ }
115078
+ }
115079
+ for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
115080
+ p = (FuncDef*)sqliteHashData(j);
115081
+ sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
114945115082
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
114946115083
}
114947115084
}
114948115085
break;
115086
+
115087
+#ifndef SQLITE_OMIT_VIRTUALTABLE
115088
+ case PragTyp_MODULE_LIST: {
115089
+ HashElem *j;
115090
+ pParse->nMem = 1;
115091
+ for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
115092
+ Module *pMod = (Module*)sqliteHashData(j);
115093
+ sqlite3VdbeMultiLoad(v, 1, "s", pMod->zName);
115094
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
115095
+ }
115096
+ }
115097
+ break;
115098
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
115099
+
115100
+ case PragTyp_PRAGMA_LIST: {
115101
+ int i;
115102
+ for(i=0; i<ArraySize(aPragmaName); i++){
115103
+ sqlite3VdbeMultiLoad(v, 1, "s", aPragmaName[i].zName);
115104
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
115105
+ }
115106
+ }
115107
+ break;
115108
+#endif /* SQLITE_INTROSPECTION_PRAGMAS */
115109
+
114949115110
#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
114950115111
114951115112
#ifndef SQLITE_OMIT_FOREIGN_KEY
114952115113
case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
114953115114
FKey *pFK;
@@ -114969,11 +115130,10 @@
114969115130
pTab->aCol[pFK->aCol[j].iFrom].zName,
114970115131
pFK->aCol[j].zCol,
114971115132
actionName(pFK->aAction[1]), /* ON UPDATE */
114972115133
actionName(pFK->aAction[0]), /* ON DELETE */
114973115134
"NONE");
114974
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);
114975115135
}
114976115136
++i;
114977115137
pFK = pFK->pNextFrom;
114978115138
}
114979115139
}
@@ -115079,11 +115239,11 @@
115079115239
if( HasRowid(pTab) ){
115080115240
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
115081115241
}else{
115082115242
sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);
115083115243
}
115084
- sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1);
115244
+ sqlite3VdbeMultiLoad(v, regResult+2, "siX", pFK->zTo, i-1);
115085115245
sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);
115086115246
sqlite3VdbeResolveLabel(v, addrOk);
115087115247
sqlite3DbFree(db, aiCols);
115088115248
}
115089115249
sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);
@@ -115781,11 +115941,10 @@
115781115941
}else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0,
115782115942
SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
115783115943
zState = azLockName[j];
115784115944
}
115785115945
sqlite3VdbeMultiLoad(v, 1, "ss", db->aDb[i].zDbSName, zState);
115786
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
115787115946
}
115788115947
break;
115789115948
}
115790115949
#endif
115791115950
@@ -118757,11 +118916,15 @@
118757118916
}else{
118758118917
/* Use the original text of the column expression as its name */
118759118918
zName = pEList->a[i].zSpan;
118760118919
}
118761118920
}
118762
- zName = sqlite3MPrintf(db, "%s", zName);
118921
+ if( zName ){
118922
+ zName = sqlite3DbStrDup(db, zName);
118923
+ }else{
118924
+ zName = sqlite3MPrintf(db,"column%d",i+1);
118925
+ }
118763118926
118764118927
/* Make sure the column name is unique. If the name is not unique,
118765118928
** append an integer to the name so that it becomes unique.
118766118929
*/
118767118930
cnt = 0;
@@ -122070,10 +122233,92 @@
122070122233
return pItem;
122071122234
}
122072122235
return 0;
122073122236
}
122074122237
122238
+#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
122239
+/*
122240
+** Attempt to transform a query of the form
122241
+**
122242
+** SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)
122243
+**
122244
+** Into this:
122245
+**
122246
+** SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)
122247
+**
122248
+** The transformation only works if all of the following are true:
122249
+**
122250
+** * The subquery is a UNION ALL of two or more terms
122251
+** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
122252
+** * The outer query is a simple count(*)
122253
+**
122254
+** Return TRUE if the optimization is undertaken.
122255
+*/
122256
+static int countOfViewOptimization(Parse *pParse, Select *p){
122257
+ Select *pSub, *pPrior;
122258
+ Expr *pExpr;
122259
+ Expr *pCount;
122260
+ sqlite3 *db;
122261
+ if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate query */
122262
+ if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
122263
+ pExpr = p->pEList->a[0].pExpr;
122264
+ if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */
122265
+ if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Must be count() */
122266
+ if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */
122267
+ if( p->pSrc->nSrc!=1 ) return 0; /* One table in the FROM clause */
122268
+ pSub = p->pSrc->a[0].pSelect;
122269
+ if( pSub==0 ) return 0; /* The FROM is a subquery */
122270
+ if( pSub->pPrior==0 ) return 0; /* Must be a compound subquery */
122271
+ do{
122272
+ if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
122273
+ if( pSub->pWhere ) return 0; /* No WHERE clause */
122274
+ if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
122275
+ pSub = pSub->pPrior; /* Repeat over compound terms */
122276
+ }while( pSub );
122277
+
122278
+ /* If we reach this point, that means it is OK to perform the transformation */
122279
+
122280
+ db = pParse->db;
122281
+ pCount = pExpr;
122282
+ pExpr = 0;
122283
+ pSub = p->pSrc->a[0].pSelect;
122284
+ p->pSrc->a[0].pSelect = 0;
122285
+ sqlite3SrcListDelete(db, p->pSrc);
122286
+ p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));
122287
+ while( pSub ){
122288
+ Expr *pTerm;
122289
+ pPrior = pSub->pPrior;
122290
+ pSub->pPrior = 0;
122291
+ pSub->pNext = 0;
122292
+ pSub->selFlags |= SF_Aggregate;
122293
+ pSub->selFlags &= ~SF_Compound;
122294
+ pSub->nSelectRow = 0;
122295
+ sqlite3ExprListDelete(db, pSub->pEList);
122296
+ pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;
122297
+ pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);
122298
+ pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
122299
+ sqlite3PExprAddSelect(pParse, pTerm, pSub);
122300
+ if( pExpr==0 ){
122301
+ pExpr = pTerm;
122302
+ }else{
122303
+ pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);
122304
+ }
122305
+ pSub = pPrior;
122306
+ }
122307
+ p->pEList->a[0].pExpr = pExpr;
122308
+ p->selFlags &= ~SF_Aggregate;
122309
+
122310
+#if SELECTTRACE_ENABLED
122311
+ if( sqlite3SelectTrace & 0x400 ){
122312
+ SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n"));
122313
+ sqlite3TreeViewSelect(0, p, 0);
122314
+ }
122315
+#endif
122316
+ return 1;
122317
+}
122318
+#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */
122319
+
122075122320
/*
122076122321
** Generate code for the SELECT statement given in the p argument.
122077122322
**
122078122323
** The results are returned according to the SelectDest structure.
122079122324
** See comments in sqliteInt.h for further information.
@@ -122381,10 +122626,20 @@
122381122626
if( sqlite3SelectTrace & 0x400 ){
122382122627
SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n"));
122383122628
sqlite3TreeViewSelect(0, p, 0);
122384122629
}
122385122630
#endif
122631
+
122632
+#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
122633
+ if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)
122634
+ && countOfViewOptimization(pParse, p)
122635
+ ){
122636
+ if( db->mallocFailed ) goto select_end;
122637
+ pEList = p->pEList;
122638
+ pTabList = p->pSrc;
122639
+ }
122640
+#endif
122386122641
122387122642
/* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
122388122643
** if the select-list is the same as the ORDER BY list, then this query
122389122644
** can be rewritten as a GROUP BY. In other words, this:
122390122645
**
@@ -127095,10 +127350,11 @@
127095127350
#endif
127096127351
#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
127097127352
#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
127098127353
#define TERM_LIKE 0x400 /* The original LIKE operator */
127099127354
#define TERM_IS 0x800 /* Term.pExpr is an IS operator */
127355
+#define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
127100127356
127101127357
/*
127102127358
** An instance of the WhereScan object is used as an iterator for locating
127103127359
** terms in the WHERE clause that are useful to the query planner.
127104127360
*/
@@ -127184,10 +127440,11 @@
127184127440
** does not really matter. What is important is that sparse cursor
127185127441
** numbers all get mapped into bit numbers that begin with 0 and contain
127186127442
** no gaps.
127187127443
*/
127188127444
struct WhereMaskSet {
127445
+ int bVarSelect; /* Used by sqlite3WhereExprUsage() */
127189127446
int n; /* Number of assigned cursor values */
127190127447
int ix[BMS]; /* Cursor assigned to each bit */
127191127448
};
127192127449
127193127450
/*
@@ -128481,11 +128738,11 @@
128481128738
int addrHalt; /* addrBrk for the outermost loop */
128482128739
int addrCont; /* Jump here to continue with next cycle */
128483128740
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
128484128741
int iReleaseReg = 0; /* Temp register to free before returning */
128485128742
Index *pIdx = 0; /* Index used by loop (if any) */
128486
- int loopAgain; /* True if constraint generator loop should repeat */
128743
+ int iLoop; /* Iteration of constraint generator loop */
128487128744
128488128745
pParse = pWInfo->pParse;
128489128746
v = pParse->pVdbe;
128490128747
pWC = &pWInfo->sWC;
128491128748
db = pParse->db;
@@ -129376,17 +129633,24 @@
129376129633
#endif
129377129634
129378129635
/* Insert code to test every subexpression that can be completely
129379129636
** computed using the current set of tables.
129380129637
**
129381
- ** This loop may run either once (pIdx==0) or twice (pIdx!=0). If
129382
- ** it is run twice, then the first iteration codes those sub-expressions
129383
- ** that can be computed using columns from pIdx only (without seeking
129384
- ** the main table cursor).
129638
+ ** This loop may run between one and three times, depending on the
129639
+ ** constraints to be generated. The value of stack variable iLoop
129640
+ ** determines the constraints coded by each iteration, as follows:
129641
+ **
129642
+ ** iLoop==1: Code only expressions that are entirely covered by pIdx.
129643
+ ** iLoop==2: Code remaining expressions that do not contain correlated
129644
+ ** sub-queries.
129645
+ ** iLoop==3: Code all remaining expressions.
129646
+ **
129647
+ ** An effort is made to skip unnecessary iterations of the loop.
129385129648
*/
129649
+ iLoop = (pIdx ? 1 : 2);
129386129650
do{
129387
- loopAgain = 0;
129651
+ int iNext = 0; /* Next value for iLoop */
129388129652
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
129389129653
Expr *pE;
129390129654
int skipLikeAddr = 0;
129391129655
testcase( pTerm->wtFlags & TERM_VIRTUAL );
129392129656
testcase( pTerm->wtFlags & TERM_CODED );
@@ -129400,14 +129664,20 @@
129400129664
pE = pTerm->pExpr;
129401129665
assert( pE!=0 );
129402129666
if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
129403129667
continue;
129404129668
}
129405
- if( pIdx && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
129406
- loopAgain = 1;
129669
+
129670
+ if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
129671
+ iNext = 2;
129672
+ continue;
129673
+ }
129674
+ if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){
129675
+ if( iNext==0 ) iNext = 3;
129407129676
continue;
129408129677
}
129678
+
129409129679
if( pTerm->wtFlags & TERM_LIKECOND ){
129410129680
/* If the TERM_LIKECOND flag is set, that means that the range search
129411129681
** is sufficient to guarantee that the LIKE operator is true, so we
129412129682
** can skip the call to the like(A,B) function. But this only works
129413129683
** for strings. So do not skip the call to the function on the pass
@@ -129419,16 +129689,22 @@
129419129689
assert( x>0 );
129420129690
skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));
129421129691
VdbeCoverage(v);
129422129692
#endif
129423129693
}
129694
+#ifdef WHERETRACE_ENABLED /* 0xffff */
129695
+ if( sqlite3WhereTrace ){
129696
+ VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
129697
+ pWC->nTerm-j, pTerm, iLoop));
129698
+ }
129699
+#endif
129424129700
sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
129425129701
if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
129426129702
pTerm->wtFlags |= TERM_CODED;
129427129703
}
129428
- pIdx = 0;
129429
- }while( loopAgain );
129704
+ iLoop = iNext;
129705
+ }while( iLoop>0 );
129430129706
129431129707
/* Insert code to test for implied constraints based on transitivity
129432129708
** of the "==" operator.
129433129709
**
129434129710
** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123"
@@ -130438,11 +130714,13 @@
130438130714
}else if( op==TK_ISNULL ){
130439130715
pTerm->prereqRight = 0;
130440130716
}else{
130441130717
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
130442130718
}
130719
+ pMaskSet->bVarSelect = 0;
130443130720
prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
130721
+ if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
130444130722
if( ExprHasProperty(pExpr, EP_FromJoin) ){
130445130723
Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
130446130724
prereqAll |= x;
130447130725
extraRight = x-1; /* ON clause terms may not be used with an index
130448130726
** on left table of a LEFT JOIN. Ticket #3015 */
@@ -130869,13 +131147,16 @@
130869131147
if( p->op==TK_COLUMN ){
130870131148
return sqlite3WhereGetMask(pMaskSet, p->iTable);
130871131149
}
130872131150
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
130873131151
assert( !ExprHasProperty(p, EP_TokenOnly) );
130874
- if( p->pRight ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
130875131152
if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
130876
- if( ExprHasProperty(p, EP_xIsSelect) ){
131153
+ if( p->pRight ){
131154
+ mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
131155
+ assert( p->x.pList==0 );
131156
+ }else if( ExprHasProperty(p, EP_xIsSelect) ){
131157
+ if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
130877131158
mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
130878131159
}else if( p->x.pList ){
130879131160
mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
130880131161
}
130881131162
return mask;
@@ -135501,13 +135782,17 @@
135501135782
for(ii=0; ii<pTabList->nSrc; ii++){
135502135783
createMask(pMaskSet, pTabList->a[ii].iCursor);
135503135784
sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
135504135785
}
135505135786
#ifdef SQLITE_DEBUG
135506
- for(ii=0; ii<pTabList->nSrc; ii++){
135507
- Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);
135508
- assert( m==MASKBIT(ii) );
135787
+ {
135788
+ Bitmask mx = 0;
135789
+ for(ii=0; ii<pTabList->nSrc; ii++){
135790
+ Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);
135791
+ assert( m>=mx );
135792
+ mx = m;
135793
+ }
135509135794
}
135510135795
#endif
135511135796
135512135797
/* Analyze all of the subexpressions. */
135513135798
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
@@ -136348,20 +136633,20 @@
136348136633
#define sqlite3ParserARG_SDECL Parse *pParse;
136349136634
#define sqlite3ParserARG_PDECL ,Parse *pParse
136350136635
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136351136636
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
136352136637
#define YYFALLBACK 1
136353
-#define YYNSTATE 456
136354
-#define YYNRULE 331
136355
-#define YY_MAX_SHIFT 455
136356
-#define YY_MIN_SHIFTREDUCE 667
136357
-#define YY_MAX_SHIFTREDUCE 997
136358
-#define YY_MIN_REDUCE 998
136359
-#define YY_MAX_REDUCE 1328
136360
-#define YY_ERROR_ACTION 1329
136361
-#define YY_ACCEPT_ACTION 1330
136362
-#define YY_NO_ACTION 1331
136638
+#define YYNSTATE 455
136639
+#define YYNRULE 330
136640
+#define YY_MAX_SHIFT 454
136641
+#define YY_MIN_SHIFTREDUCE 665
136642
+#define YY_MAX_SHIFTREDUCE 994
136643
+#define YY_MIN_REDUCE 995
136644
+#define YY_MAX_REDUCE 1324
136645
+#define YY_ERROR_ACTION 1325
136646
+#define YY_ACCEPT_ACTION 1326
136647
+#define YY_NO_ACTION 1327
136363136648
/************* End control #defines *******************************************/
136364136649
136365136650
/* Define the yytestcase() macro to be a no-op if is not already defined
136366136651
** otherwise.
136367136652
**
@@ -136429,169 +136714,169 @@
136429136714
** yy_reduce_ofst[] For each state, the offset into yy_action for
136430136715
** shifting non-terminals after a reduce.
136431136716
** yy_default[] Default action for each state.
136432136717
**
136433136718
*********** Begin parsing tables **********************************************/
136434
-#define YY_ACTTAB_COUNT (1566)
136719
+#define YY_ACTTAB_COUNT (1565)
136435136720
static const YYACTIONTYPE yy_action[] = {
136436
- /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
136721
+ /* 0 */ 324, 410, 342, 748, 748, 203, 941, 353, 971, 98,
136437136722
/* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136438
- /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439
- /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
136440
- /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136441
- /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136442
- /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136443
- /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444
- /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445
- /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446
- /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447
- /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448
- /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449
- /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136450
- /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136451
- /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452
- /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453
- /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454
- /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455
- /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456
- /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
136457
- /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136458
- /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459
- /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460
- /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461
- /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462
- /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
136463
- /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136464
- /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465
- /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466
- /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467
- /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468
- /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469
- /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470
- /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471
- /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472
- /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473
- /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474
- /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475
- /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476
- /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477
- /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
136478
- /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136479
- /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480
- /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481
- /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482
- /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483
- /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484
- /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136723
+ /* 20 */ 94, 94, 94, 93, 350, 1326, 155, 155, 2, 809,
136724
+ /* 30 */ 973, 973, 98, 98, 98, 98, 20, 96, 96, 96,
136725
+ /* 40 */ 96, 95, 95, 94, 94, 94, 93, 350, 92, 89,
136726
+ /* 50 */ 178, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136727
+ /* 60 */ 98, 98, 98, 98, 350, 96, 96, 96, 96, 95,
136728
+ /* 70 */ 95, 94, 94, 94, 93, 350, 324, 339, 971, 262,
136729
+ /* 80 */ 364, 251, 212, 169, 287, 404, 282, 403, 199, 787,
136730
+ /* 90 */ 242, 411, 21, 952, 378, 280, 93, 350, 788, 95,
136731
+ /* 100 */ 95, 94, 94, 94, 93, 350, 973, 973, 96, 96,
136732
+ /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 350, 809,
136733
+ /* 120 */ 328, 242, 411, 1238, 828, 1238, 132, 99, 100, 90,
136734
+ /* 130 */ 849, 852, 841, 841, 97, 97, 98, 98, 98, 98,
136735
+ /* 140 */ 449, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136736
+ /* 150 */ 93, 350, 324, 821, 348, 347, 120, 815, 120, 75,
136737
+ /* 160 */ 52, 52, 952, 953, 954, 1086, 979, 146, 360, 262,
136738
+ /* 170 */ 369, 261, 952, 977, 956, 978, 92, 89, 178, 370,
136739
+ /* 180 */ 230, 370, 973, 973, 1143, 360, 359, 101, 820, 820,
136740
+ /* 190 */ 822, 383, 24, 1289, 380, 427, 412, 368, 980, 379,
136741
+ /* 200 */ 980, 1034, 324, 99, 100, 90, 849, 852, 841, 841,
136742
+ /* 210 */ 97, 97, 98, 98, 98, 98, 372, 96, 96, 96,
136743
+ /* 220 */ 96, 95, 95, 94, 94, 94, 93, 350, 952, 132,
136744
+ /* 230 */ 892, 449, 973, 973, 892, 60, 94, 94, 94, 93,
136745
+ /* 240 */ 350, 952, 953, 954, 956, 103, 360, 952, 384, 333,
136746
+ /* 250 */ 698, 52, 52, 99, 100, 90, 849, 852, 841, 841,
136747
+ /* 260 */ 97, 97, 98, 98, 98, 98, 1024, 96, 96, 96,
136748
+ /* 270 */ 96, 95, 95, 94, 94, 94, 93, 350, 324, 454,
136749
+ /* 280 */ 997, 449, 227, 61, 157, 243, 343, 114, 1027, 1214,
136750
+ /* 290 */ 147, 828, 952, 372, 1073, 952, 319, 952, 953, 954,
136751
+ /* 300 */ 194, 10, 10, 401, 398, 397, 1214, 1216, 973, 973,
136752
+ /* 310 */ 758, 171, 170, 157, 396, 336, 952, 953, 954, 698,
136753
+ /* 320 */ 821, 310, 153, 952, 815, 320, 82, 23, 80, 99,
136754
+ /* 330 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136755
+ /* 340 */ 98, 98, 890, 96, 96, 96, 96, 95, 95, 94,
136756
+ /* 350 */ 94, 94, 93, 350, 324, 820, 820, 822, 277, 231,
136757
+ /* 360 */ 300, 952, 953, 954, 952, 953, 954, 1214, 194, 25,
136758
+ /* 370 */ 449, 401, 398, 397, 952, 354, 300, 449, 952, 74,
136759
+ /* 380 */ 449, 1, 396, 132, 973, 973, 952, 224, 224, 809,
136760
+ /* 390 */ 10, 10, 952, 953, 954, 1293, 132, 52, 52, 414,
136761
+ /* 400 */ 52, 52, 1065, 1065, 338, 99, 100, 90, 849, 852,
136762
+ /* 410 */ 841, 841, 97, 97, 98, 98, 98, 98, 1116, 96,
136763
+ /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 350,
136764
+ /* 430 */ 324, 1115, 427, 417, 702, 427, 426, 1263, 1263, 262,
136765
+ /* 440 */ 369, 261, 952, 952, 953, 954, 753, 952, 953, 954,
136766
+ /* 450 */ 449, 752, 449, 1060, 1039, 952, 953, 954, 442, 707,
136767
+ /* 460 */ 973, 973, 1060, 393, 92, 89, 178, 446, 446, 446,
136768
+ /* 470 */ 51, 51, 52, 52, 438, 774, 1026, 92, 89, 178,
136769
+ /* 480 */ 172, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136485136770
/* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136486
- /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487
- /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488
- /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489
- /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490
- /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491
- /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492
- /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136493
- /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136494
- /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495
- /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496
- /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497
- /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498
- /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499
- /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
136771
+ /* 500 */ 95, 94, 94, 94, 93, 350, 324, 427, 407, 911,
136772
+ /* 510 */ 695, 952, 953, 954, 92, 89, 178, 224, 224, 157,
136773
+ /* 520 */ 241, 221, 418, 299, 772, 912, 415, 374, 449, 414,
136774
+ /* 530 */ 58, 323, 1063, 1063, 1245, 378, 973, 973, 378, 773,
136775
+ /* 540 */ 448, 913, 362, 736, 296, 682, 9, 9, 52, 52,
136776
+ /* 550 */ 234, 329, 234, 256, 416, 737, 280, 99, 100, 90,
136777
+ /* 560 */ 849, 852, 841, 841, 97, 97, 98, 98, 98, 98,
136778
+ /* 570 */ 449, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136779
+ /* 580 */ 93, 350, 324, 422, 72, 449, 829, 120, 367, 449,
136780
+ /* 590 */ 10, 10, 5, 301, 203, 449, 177, 971, 253, 419,
136781
+ /* 600 */ 255, 772, 200, 175, 233, 10, 10, 838, 838, 36,
136782
+ /* 610 */ 36, 1292, 973, 973, 725, 37, 37, 348, 347, 424,
136783
+ /* 620 */ 203, 260, 772, 971, 232, 932, 1319, 872, 337, 1319,
136784
+ /* 630 */ 421, 850, 853, 99, 100, 90, 849, 852, 841, 841,
136500136785
/* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136501
- /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502
- /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503
- /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504
- /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505
- /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506
- /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507
- /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508
- /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509
- /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510
- /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511
- /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512
- /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136513
- /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136514
- /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515
- /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516
- /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517
- /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518
- /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519
- /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520
- /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
136521
- /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136522
- /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523
- /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524
- /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525
- /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
136786
+ /* 650 */ 96, 95, 95, 94, 94, 94, 93, 350, 324, 842,
136787
+ /* 660 */ 449, 980, 814, 980, 1203, 449, 911, 971, 716, 349,
136788
+ /* 670 */ 349, 349, 930, 177, 449, 932, 1320, 254, 198, 1320,
136789
+ /* 680 */ 12, 12, 912, 402, 449, 27, 27, 250, 973, 973,
136790
+ /* 690 */ 118, 717, 162, 971, 38, 38, 268, 176, 913, 772,
136791
+ /* 700 */ 432, 1268, 941, 353, 39, 39, 316, 993, 324, 99,
136792
+ /* 710 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136793
+ /* 720 */ 98, 98, 930, 96, 96, 96, 96, 95, 95, 94,
136794
+ /* 730 */ 94, 94, 93, 350, 449, 329, 449, 357, 973, 973,
136795
+ /* 740 */ 1043, 316, 931, 340, 895, 895, 386, 670, 671, 672,
136796
+ /* 750 */ 275, 1321, 317, 994, 40, 40, 41, 41, 268, 99,
136797
+ /* 760 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136798
+ /* 770 */ 98, 98, 449, 96, 96, 96, 96, 95, 95, 94,
136799
+ /* 780 */ 94, 94, 93, 350, 324, 449, 355, 449, 994, 449,
136800
+ /* 790 */ 1018, 330, 42, 42, 787, 270, 449, 273, 449, 228,
136801
+ /* 800 */ 449, 298, 449, 788, 449, 28, 28, 29, 29, 31,
136802
+ /* 810 */ 31, 449, 1143, 449, 973, 973, 43, 43, 44, 44,
136803
+ /* 820 */ 45, 45, 11, 11, 46, 46, 889, 78, 889, 268,
136804
+ /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 849, 852,
136805
+ /* 840 */ 841, 841, 97, 97, 98, 98, 98, 98, 449, 96,
136806
+ /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 350,
136807
+ /* 860 */ 324, 449, 117, 449, 1075, 158, 449, 692, 48, 48,
136808
+ /* 870 */ 229, 1244, 449, 1253, 449, 414, 449, 334, 449, 245,
136809
+ /* 880 */ 449, 33, 33, 49, 49, 449, 50, 50, 246, 1143,
136810
+ /* 890 */ 973, 973, 34, 34, 122, 122, 123, 123, 124, 124,
136526136811
/* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136527
- /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136528
- /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136529
- /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530
- /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531
- /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532
- /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136533
- /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136534
- /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535
- /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536
- /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537
- /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538
- /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
136539
- /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136540
- /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541
- /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542
- /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
136543
- /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136544
- /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545
- /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546
- /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547
- /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548
- /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
136549
- /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136550
- /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551
- /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552
- /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553
- /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554
- /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555
- /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
136812
+ /* 910 */ 324, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136813
+ /* 920 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136814
+ /* 930 */ 95, 94, 94, 94, 93, 350, 449, 692, 449, 1143,
136815
+ /* 940 */ 973, 973, 970, 1210, 106, 106, 268, 1212, 268, 1269,
136816
+ /* 950 */ 2, 888, 268, 888, 335, 1042, 53, 53, 107, 107,
136817
+ /* 960 */ 324, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136818
+ /* 970 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136819
+ /* 980 */ 95, 94, 94, 94, 93, 350, 449, 1072, 449, 1068,
136820
+ /* 990 */ 973, 973, 1041, 267, 108, 108, 445, 330, 331, 133,
136821
+ /* 1000 */ 223, 175, 301, 225, 385, 1258, 104, 104, 121, 121,
136822
+ /* 1010 */ 324, 99, 88, 90, 849, 852, 841, 841, 97, 97,
136823
+ /* 1020 */ 98, 98, 98, 98, 1143, 96, 96, 96, 96, 95,
136824
+ /* 1030 */ 95, 94, 94, 94, 93, 350, 449, 346, 449, 167,
136825
+ /* 1040 */ 973, 973, 927, 811, 371, 318, 202, 202, 373, 263,
136826
+ /* 1050 */ 394, 202, 74, 208, 722, 723, 119, 119, 112, 112,
136827
+ /* 1060 */ 324, 406, 100, 90, 849, 852, 841, 841, 97, 97,
136828
+ /* 1070 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136829
+ /* 1080 */ 95, 94, 94, 94, 93, 350, 449, 753, 449, 344,
136830
+ /* 1090 */ 973, 973, 752, 278, 111, 111, 74, 715, 714, 705,
136831
+ /* 1100 */ 286, 879, 750, 1282, 257, 77, 109, 109, 110, 110,
136832
+ /* 1110 */ 1233, 285, 1136, 90, 849, 852, 841, 841, 97, 97,
136833
+ /* 1120 */ 98, 98, 98, 98, 1236, 96, 96, 96, 96, 95,
136834
+ /* 1130 */ 95, 94, 94, 94, 93, 350, 86, 444, 449, 3,
136835
+ /* 1140 */ 1196, 449, 1071, 132, 351, 120, 1015, 86, 444, 781,
136836
+ /* 1150 */ 3, 1093, 202, 376, 447, 351, 1232, 120, 55, 55,
136837
+ /* 1160 */ 449, 57, 57, 824, 875, 447, 449, 208, 449, 705,
136838
+ /* 1170 */ 449, 879, 237, 433, 435, 120, 439, 428, 361, 120,
136839
+ /* 1180 */ 54, 54, 132, 449, 433, 828, 52, 52, 26, 26,
136840
+ /* 1190 */ 30, 30, 381, 132, 408, 443, 828, 690, 264, 389,
136556136841
/* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136557
- /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558
- /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559
- /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560
- /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561
- /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562
- /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563
- /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564
- /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565
- /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566
- /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567
- /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568
- /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569
- /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570
- /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571
- /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572
- /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573
- /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574
- /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575
- /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576
- /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577
- /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
136578
- /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136579
- /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580
- /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
136581
- /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136582
- /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583
- /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584
- /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585
- /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586
- /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587
- /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588
- /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589
- /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590
- /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591
- /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592
- /* 1560 */ 87, 312, 309, 945, 1288, 1287,
136842
+ /* 1210 */ 120, 276, 85, 351, 451, 450, 83, 84, 815, 1056,
136843
+ /* 1220 */ 1040, 427, 429, 85, 351, 451, 450, 120, 120, 815,
136844
+ /* 1230 */ 377, 218, 281, 824, 1109, 1142, 86, 444, 409, 3,
136845
+ /* 1240 */ 1089, 1100, 430, 431, 351, 302, 303, 1149, 1023, 820,
136846
+ /* 1250 */ 820, 822, 823, 19, 447, 1017, 1006, 1005, 1007, 1276,
136847
+ /* 1260 */ 820, 820, 822, 823, 19, 289, 159, 291, 293, 7,
136848
+ /* 1270 */ 315, 173, 259, 433, 1131, 363, 252, 1235, 375, 1039,
136849
+ /* 1280 */ 295, 434, 168, 988, 399, 828, 284, 1207, 1206, 205,
136850
+ /* 1290 */ 1279, 308, 1252, 86, 444, 985, 3, 1250, 332, 144,
136851
+ /* 1300 */ 130, 351, 72, 135, 59, 83, 84, 757, 137, 365,
136852
+ /* 1310 */ 1128, 447, 85, 351, 451, 450, 139, 226, 815, 140,
136853
+ /* 1320 */ 156, 62, 314, 314, 313, 215, 311, 366, 392, 679,
136854
+ /* 1330 */ 433, 185, 141, 1237, 142, 160, 148, 1138, 1201, 382,
136855
+ /* 1340 */ 189, 67, 828, 180, 388, 248, 1221, 1101, 219, 820,
136856
+ /* 1350 */ 820, 822, 823, 19, 247, 190, 266, 154, 390, 271,
136857
+ /* 1360 */ 191, 192, 83, 84, 1008, 405, 1059, 182, 321, 85,
136858
+ /* 1370 */ 351, 451, 450, 1058, 183, 815, 341, 132, 181, 707,
136859
+ /* 1380 */ 1057, 420, 76, 444, 1031, 3, 322, 1030, 283, 1050,
136860
+ /* 1390 */ 351, 1097, 1029, 1291, 1049, 71, 204, 6, 288, 290,
136861
+ /* 1400 */ 447, 1098, 1096, 1095, 79, 292, 820, 820, 822, 823,
136862
+ /* 1410 */ 19, 294, 297, 437, 345, 441, 102, 1187, 1079, 433,
136863
+ /* 1420 */ 238, 425, 73, 305, 239, 304, 325, 240, 423, 306,
136864
+ /* 1430 */ 307, 828, 213, 1014, 22, 947, 452, 214, 216, 217,
136865
+ /* 1440 */ 453, 1003, 115, 998, 125, 126, 235, 127, 666, 352,
136866
+ /* 1450 */ 326, 83, 84, 358, 166, 244, 179, 327, 85, 351,
136867
+ /* 1460 */ 451, 450, 134, 356, 815, 113, 887, 807, 885, 136,
136868
+ /* 1470 */ 128, 138, 739, 258, 184, 901, 143, 145, 63, 64,
136869
+ /* 1480 */ 65, 66, 129, 904, 187, 186, 900, 8, 13, 188,
136870
+ /* 1490 */ 265, 893, 149, 202, 982, 820, 820, 822, 823, 19,
136871
+ /* 1500 */ 150, 387, 161, 681, 285, 391, 151, 395, 400, 193,
136872
+ /* 1510 */ 68, 14, 236, 279, 15, 69, 718, 827, 131, 826,
136873
+ /* 1520 */ 855, 70, 747, 16, 413, 751, 4, 174, 220, 222,
136874
+ /* 1530 */ 152, 780, 859, 775, 201, 77, 74, 870, 17, 856,
136875
+ /* 1540 */ 854, 910, 18, 909, 207, 206, 936, 163, 436, 210,
136876
+ /* 1550 */ 937, 164, 209, 165, 440, 858, 825, 691, 87, 211,
136877
+ /* 1560 */ 309, 312, 1284, 942, 1283,
136593136878
};
136594136879
static const YYCODETYPE yy_lookahead[] = {
136595136880
/* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136596136881
/* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136597136882
/* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136734,26 +137019,26 @@
136734137019
/* 1390 */ 27, 216, 174, 174, 182, 107, 159, 22, 215, 215,
136735137020
/* 1400 */ 37, 216, 216, 216, 137, 215, 132, 133, 134, 135,
136736137021
/* 1410 */ 136, 215, 159, 177, 94, 177, 129, 224, 205, 56,
136737137022
/* 1420 */ 226, 126, 128, 203, 229, 204, 114, 229, 127, 202,
136738137023
/* 1430 */ 201, 68, 25, 162, 26, 13, 161, 153, 153, 6,
136739
- /* 1440 */ 151, 151, 178, 151, 151, 165, 165, 178, 165, 4,
136740
- /* 1450 */ 249, 88, 89, 141, 3, 142, 22, 249, 95, 96,
136741
- /* 1460 */ 97, 98, 246, 15, 101, 67, 16, 23, 120, 23,
136742
- /* 1470 */ 131, 111, 123, 20, 16, 125, 1, 123, 131, 78,
136743
- /* 1480 */ 78, 78, 78, 111, 96, 1, 122, 35, 5, 22,
136744
- /* 1490 */ 107, 140, 53, 53, 26, 132, 133, 134, 135, 136,
136745
- /* 1500 */ 43, 60, 107, 24, 112, 20, 19, 52, 22, 29,
136746
- /* 1510 */ 105, 22, 22, 52, 23, 22, 22, 52, 23, 23,
136747
- /* 1520 */ 39, 23, 116, 26, 22, 26, 23, 22, 96, 23,
136748
- /* 1530 */ 23, 122, 22, 24, 124, 35, 35, 26, 26, 35,
136749
- /* 1540 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
136750
- /* 1550 */ 122, 23, 26, 22, 24, 23, 22, 122, 23, 23,
136751
- /* 1560 */ 22, 15, 23, 1, 122, 122,
137024
+ /* 1440 */ 151, 151, 178, 151, 165, 165, 178, 165, 4, 3,
137025
+ /* 1450 */ 249, 88, 89, 141, 22, 142, 15, 249, 95, 96,
137026
+ /* 1460 */ 97, 98, 246, 67, 101, 16, 23, 120, 23, 131,
137027
+ /* 1470 */ 111, 123, 20, 16, 125, 1, 123, 131, 78, 78,
137028
+ /* 1480 */ 78, 78, 111, 96, 122, 35, 1, 5, 22, 107,
137029
+ /* 1490 */ 140, 53, 53, 26, 60, 132, 133, 134, 135, 136,
137030
+ /* 1500 */ 107, 43, 24, 20, 112, 19, 22, 52, 52, 105,
137031
+ /* 1510 */ 22, 22, 52, 23, 22, 22, 29, 23, 39, 23,
137032
+ /* 1520 */ 23, 26, 116, 22, 26, 23, 22, 122, 23, 23,
137033
+ /* 1530 */ 22, 96, 11, 124, 35, 26, 26, 23, 35, 23,
137034
+ /* 1540 */ 23, 23, 35, 23, 22, 26, 23, 22, 24, 122,
137035
+ /* 1550 */ 23, 22, 26, 22, 24, 23, 23, 23, 22, 122,
137036
+ /* 1560 */ 23, 15, 122, 1, 122,
136752137037
};
136753
-#define YY_SHIFT_USE_DFLT (1566)
136754
-#define YY_SHIFT_COUNT (455)
137038
+#define YY_SHIFT_USE_DFLT (1565)
137039
+#define YY_SHIFT_COUNT (454)
136755137040
#define YY_SHIFT_MIN (-114)
136756137041
#define YY_SHIFT_MAX (1562)
136757137042
static const short yy_shift_ofst[] = {
136758137043
/* 0 */ 5, 1117, 1312, 1128, 1274, 1274, 1274, 1274, 61, -19,
136759137044
/* 10 */ 57, 57, 183, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
@@ -136765,15 +137050,15 @@
136765137050
/* 70 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136766137051
/* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136767137052
/* 90 */ 1363, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136768137053
/* 100 */ 1274, 1274, 1274, 1274, -70, -47, -47, -47, -47, -47,
136769137054
/* 110 */ 24, 11, 146, 296, 524, 444, 529, 529, 296, 3,
136770
- /* 120 */ 2, -30, 1566, 1566, 1566, -17, -17, -17, 145, 145,
137055
+ /* 120 */ 2, -30, 1565, 1565, 1565, -17, -17, -17, 145, 145,
136771137056
/* 130 */ 497, 497, 265, 603, 653, 296, 296, 296, 296, 296,
136772137057
/* 140 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
136773137058
/* 150 */ 296, 296, 296, 296, 296, 701, 1078, 147, 147, 2,
136774
- /* 160 */ 164, 164, 164, 164, 164, 164, 1566, 1566, 1566, 223,
137059
+ /* 160 */ 164, 164, 164, 164, 164, 164, 1565, 1565, 1565, 223,
136775137060
/* 170 */ 56, 56, 268, 269, 220, 347, 351, 415, 359, 296,
136776137061
/* 180 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
136777137062
/* 190 */ 296, 296, 296, 296, 296, 632, 632, 632, 296, 296,
136778137063
/* 200 */ 498, 296, 296, 296, 570, 296, 296, 654, 296, 296,
136779137064
/* 210 */ 296, 296, 296, 296, 296, 296, 296, 296, 636, 200,
@@ -136784,30 +137069,30 @@
136784137069
/* 260 */ 1277, 1230, 1230, 1172, 1167, 1310, 1204, 1299, 1167, 1167,
136785137070
/* 270 */ 1310, 1335, 1167, 1310, 1167, 1310, 1335, 1258, 1258, 1258,
136786137071
/* 280 */ 1329, 1335, 1258, 1273, 1258, 1329, 1258, 1258, 1256, 1288,
136787137072
/* 290 */ 1256, 1288, 1256, 1288, 1256, 1288, 1167, 1375, 1167, 1267,
136788137073
/* 300 */ 1335, 1320, 1320, 1335, 1287, 1295, 1294, 1301, 1172, 1407,
136789
- /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1433, 1566, 1566, 1566,
136790
- /* 320 */ 1566, 1566, 1566, 1566, 1566, 558, 537, 684, 719, 734,
136791
- /* 330 */ 799, 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070,
136792
- /* 340 */ 1072, 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819,
136793
- /* 350 */ 1174, 1136, 981, 1445, 1451, 1434, 1313, 1448, 1398, 1450,
136794
- /* 360 */ 1444, 1446, 1348, 1339, 1360, 1349, 1453, 1350, 1458, 1475,
136795
- /* 370 */ 1354, 1347, 1401, 1402, 1403, 1404, 1372, 1388, 1452, 1364,
136796
- /* 380 */ 1484, 1483, 1467, 1383, 1351, 1439, 1468, 1440, 1441, 1457,
136797
- /* 390 */ 1395, 1479, 1485, 1487, 1392, 1405, 1486, 1455, 1489, 1490,
136798
- /* 400 */ 1491, 1493, 1461, 1480, 1494, 1465, 1481, 1495, 1496, 1498,
136799
- /* 410 */ 1497, 1406, 1502, 1503, 1505, 1499, 1409, 1506, 1507, 1432,
136800
- /* 420 */ 1500, 1510, 1410, 1511, 1501, 1512, 1504, 1517, 1511, 1518,
136801
- /* 430 */ 1519, 1520, 1521, 1522, 1524, 1533, 1525, 1527, 1509, 1526,
136802
- /* 440 */ 1528, 1531, 1530, 1526, 1532, 1534, 1535, 1536, 1538, 1428,
136803
- /* 450 */ 1435, 1442, 1443, 1539, 1546, 1562,
137074
+ /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1565, 1565, 1565, 1565,
137075
+ /* 320 */ 1565, 1565, 1565, 1565, 558, 537, 684, 719, 734, 799,
137076
+ /* 330 */ 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070, 1072,
137077
+ /* 340 */ 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819, 1174,
137078
+ /* 350 */ 1136, 981, 1444, 1446, 1432, 1313, 1441, 1396, 1449, 1443,
137079
+ /* 360 */ 1445, 1347, 1338, 1359, 1348, 1452, 1349, 1457, 1474, 1353,
137080
+ /* 370 */ 1346, 1400, 1401, 1402, 1403, 1371, 1387, 1450, 1362, 1485,
137081
+ /* 380 */ 1482, 1466, 1382, 1350, 1438, 1467, 1439, 1434, 1458, 1393,
137082
+ /* 390 */ 1478, 1483, 1486, 1392, 1404, 1484, 1455, 1488, 1489, 1490,
137083
+ /* 400 */ 1492, 1456, 1487, 1493, 1460, 1479, 1494, 1496, 1497, 1495,
137084
+ /* 410 */ 1406, 1501, 1502, 1504, 1498, 1405, 1505, 1506, 1435, 1499,
137085
+ /* 420 */ 1508, 1409, 1509, 1503, 1510, 1507, 1514, 1509, 1516, 1517,
137086
+ /* 430 */ 1518, 1519, 1520, 1522, 1521, 1523, 1525, 1524, 1526, 1527,
137087
+ /* 440 */ 1529, 1530, 1526, 1532, 1531, 1533, 1534, 1536, 1427, 1437,
137088
+ /* 450 */ 1440, 1442, 1537, 1546, 1562,
136804137089
};
136805137090
#define YY_REDUCE_USE_DFLT (-174)
136806
-#define YY_REDUCE_COUNT (324)
137091
+#define YY_REDUCE_COUNT (323)
136807137092
#define YY_REDUCE_MIN (-173)
136808
-#define YY_REDUCE_MAX (1293)
137093
+#define YY_REDUCE_MAX (1292)
136809137094
static const short yy_reduce_ofst[] = {
136810137095
/* 0 */ -119, 1014, 131, 1031, -12, 225, 228, 300, -40, -45,
136811137096
/* 10 */ 243, 256, 293, 129, 218, 418, 79, 376, 433, 298,
136812137097
/* 20 */ 16, 137, 367, 323, -38, 391, -173, -173, -173, -173,
136813137098
/* 30 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173,
@@ -136836,60 +137121,60 @@
136836137121
/* 260 */ 1115, 1147, 1148, 1137, 1180, 1182, 1110, 1121, 1188, 1189,
136837137122
/* 270 */ 1197, 1181, 1200, 1202, 1205, 1203, 1191, 1192, 1199, 1206,
136838137123
/* 280 */ 1207, 1209, 1210, 1211, 1214, 1212, 1218, 1219, 1175, 1183,
136839137124
/* 290 */ 1185, 1184, 1186, 1190, 1187, 1196, 1237, 1193, 1253, 1194,
136840137125
/* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136841
- /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136842
- /* 320 */ 1280, 1281, 1264, 1269, 1283,
137126
+ /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1201, 1208, 1216, 1279,
137127
+ /* 320 */ 1280, 1264, 1268, 1282,
136843137128
};
136844137129
static const YYACTIONTYPE yy_default[] = {
136845
- /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846
- /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847
- /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848
- /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849
- /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850
- /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851
- /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852
- /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853
- /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854
- /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855
- /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856
- /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857
- /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858
- /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859
- /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860
- /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861
- /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862
- /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863
- /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864
- /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865
- /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866
- /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867
- /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868
- /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869
- /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870
- /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871
- /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872
- /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873
- /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874
- /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875
- /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876
- /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877
- /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878
- /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879
- /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880
- /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881
- /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882
- /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883
- /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884
- /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885
- /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886
- /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887
- /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888
- /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889
- /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890
- /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
137130
+ /* 0 */ 1273, 1263, 1263, 1263, 1196, 1196, 1196, 1196, 1263, 1090,
137131
+ /* 10 */ 1119, 1119, 1247, 1325, 1325, 1325, 1325, 1325, 1325, 1195,
137132
+ /* 20 */ 1325, 1325, 1325, 1325, 1263, 1094, 1125, 1325, 1325, 1325,
137133
+ /* 30 */ 1325, 1197, 1198, 1325, 1325, 1325, 1246, 1248, 1135, 1134,
137134
+ /* 40 */ 1133, 1132, 1229, 1106, 1130, 1123, 1127, 1197, 1191, 1192,
137135
+ /* 50 */ 1190, 1194, 1198, 1325, 1126, 1161, 1175, 1160, 1325, 1325,
137136
+ /* 60 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137137
+ /* 70 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137138
+ /* 80 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137139
+ /* 90 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137140
+ /* 100 */ 1325, 1325, 1325, 1325, 1169, 1174, 1181, 1173, 1170, 1163,
137141
+ /* 110 */ 1162, 1164, 1165, 1325, 1013, 1061, 1325, 1325, 1325, 1166,
137142
+ /* 120 */ 1325, 1167, 1178, 1177, 1176, 1254, 1281, 1280, 1325, 1325,
137143
+ /* 130 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137144
+ /* 140 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137145
+ /* 150 */ 1325, 1325, 1325, 1325, 1325, 1273, 1263, 1019, 1019, 1325,
137146
+ /* 160 */ 1263, 1263, 1263, 1263, 1263, 1263, 1259, 1094, 1085, 1325,
137147
+ /* 170 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137148
+ /* 180 */ 1251, 1249, 1325, 1211, 1325, 1325, 1325, 1325, 1325, 1325,
137149
+ /* 190 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137150
+ /* 200 */ 1325, 1325, 1325, 1325, 1090, 1325, 1325, 1325, 1325, 1325,
137151
+ /* 210 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1275, 1325, 1224,
137152
+ /* 220 */ 1090, 1090, 1090, 1092, 1074, 1084, 999, 1129, 1108, 1108,
137153
+ /* 230 */ 1314, 1129, 1314, 1036, 1295, 1033, 1119, 1108, 1193, 1119,
137154
+ /* 240 */ 1119, 1091, 1084, 1325, 1317, 1099, 1099, 1316, 1316, 1099,
137155
+ /* 250 */ 1140, 1064, 1129, 1070, 1070, 1070, 1070, 1099, 1010, 1129,
137156
+ /* 260 */ 1140, 1064, 1064, 1129, 1099, 1010, 1228, 1311, 1099, 1099,
137157
+ /* 270 */ 1010, 1204, 1099, 1010, 1099, 1010, 1204, 1062, 1062, 1062,
137158
+ /* 280 */ 1051, 1204, 1062, 1036, 1062, 1051, 1062, 1062, 1112, 1107,
137159
+ /* 290 */ 1112, 1107, 1112, 1107, 1112, 1107, 1099, 1199, 1099, 1325,
137160
+ /* 300 */ 1204, 1208, 1208, 1204, 1124, 1113, 1122, 1120, 1129, 1016,
137161
+ /* 310 */ 1054, 1278, 1278, 1274, 1274, 1274, 1322, 1322, 1259, 1290,
137162
+ /* 320 */ 1290, 1038, 1038, 1290, 1325, 1325, 1325, 1325, 1325, 1325,
137163
+ /* 330 */ 1285, 1325, 1213, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137164
+ /* 340 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137165
+ /* 350 */ 1325, 1146, 1325, 995, 1256, 1325, 1325, 1255, 1325, 1325,
137166
+ /* 360 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137167
+ /* 370 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1313, 1325,
137168
+ /* 380 */ 1325, 1325, 1325, 1325, 1325, 1227, 1226, 1325, 1325, 1325,
137169
+ /* 390 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137170
+ /* 400 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137171
+ /* 410 */ 1076, 1325, 1325, 1325, 1299, 1325, 1325, 1325, 1325, 1325,
137172
+ /* 420 */ 1325, 1325, 1121, 1325, 1114, 1325, 1325, 1304, 1325, 1325,
137173
+ /* 430 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1265, 1325,
137174
+ /* 440 */ 1325, 1325, 1264, 1325, 1325, 1325, 1325, 1325, 1148, 1325,
137175
+ /* 450 */ 1147, 1151, 1325, 1004, 1325,
136891137176
};
136892137177
/********** End of lemon-generated parsing tables *****************************/
136893137178
136894137179
/* The next table maps tokens (terminal symbols) into fallback tokens.
136895137180
** If a construct like the following:
@@ -137138,333 +137423,332 @@
137138137423
/* 3 */ "cmd ::= BEGIN transtype trans_opt",
137139137424
/* 4 */ "transtype ::=",
137140137425
/* 5 */ "transtype ::= DEFERRED",
137141137426
/* 6 */ "transtype ::= IMMEDIATE",
137142137427
/* 7 */ "transtype ::= EXCLUSIVE",
137143
- /* 8 */ "cmd ::= COMMIT trans_opt",
137144
- /* 9 */ "cmd ::= END trans_opt",
137145
- /* 10 */ "cmd ::= ROLLBACK trans_opt",
137146
- /* 11 */ "cmd ::= SAVEPOINT nm",
137147
- /* 12 */ "cmd ::= RELEASE savepoint_opt nm",
137148
- /* 13 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
137149
- /* 14 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
137150
- /* 15 */ "createkw ::= CREATE",
137151
- /* 16 */ "ifnotexists ::=",
137152
- /* 17 */ "ifnotexists ::= IF NOT EXISTS",
137153
- /* 18 */ "temp ::= TEMP",
137154
- /* 19 */ "temp ::=",
137155
- /* 20 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
137156
- /* 21 */ "create_table_args ::= AS select",
137157
- /* 22 */ "table_options ::=",
137158
- /* 23 */ "table_options ::= WITHOUT nm",
137159
- /* 24 */ "columnname ::= nm typetoken",
137160
- /* 25 */ "typetoken ::=",
137161
- /* 26 */ "typetoken ::= typename LP signed RP",
137162
- /* 27 */ "typetoken ::= typename LP signed COMMA signed RP",
137163
- /* 28 */ "typename ::= typename ID|STRING",
137164
- /* 29 */ "ccons ::= CONSTRAINT nm",
137165
- /* 30 */ "ccons ::= DEFAULT term",
137166
- /* 31 */ "ccons ::= DEFAULT LP expr RP",
137167
- /* 32 */ "ccons ::= DEFAULT PLUS term",
137168
- /* 33 */ "ccons ::= DEFAULT MINUS term",
137169
- /* 34 */ "ccons ::= DEFAULT ID|INDEXED",
137170
- /* 35 */ "ccons ::= NOT NULL onconf",
137171
- /* 36 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
137172
- /* 37 */ "ccons ::= UNIQUE onconf",
137173
- /* 38 */ "ccons ::= CHECK LP expr RP",
137174
- /* 39 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
137175
- /* 40 */ "ccons ::= defer_subclause",
137176
- /* 41 */ "ccons ::= COLLATE ID|STRING",
137177
- /* 42 */ "autoinc ::=",
137178
- /* 43 */ "autoinc ::= AUTOINCR",
137179
- /* 44 */ "refargs ::=",
137180
- /* 45 */ "refargs ::= refargs refarg",
137181
- /* 46 */ "refarg ::= MATCH nm",
137182
- /* 47 */ "refarg ::= ON INSERT refact",
137183
- /* 48 */ "refarg ::= ON DELETE refact",
137184
- /* 49 */ "refarg ::= ON UPDATE refact",
137185
- /* 50 */ "refact ::= SET NULL",
137186
- /* 51 */ "refact ::= SET DEFAULT",
137187
- /* 52 */ "refact ::= CASCADE",
137188
- /* 53 */ "refact ::= RESTRICT",
137189
- /* 54 */ "refact ::= NO ACTION",
137190
- /* 55 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
137191
- /* 56 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
137192
- /* 57 */ "init_deferred_pred_opt ::=",
137193
- /* 58 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
137194
- /* 59 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
137195
- /* 60 */ "conslist_opt ::=",
137196
- /* 61 */ "tconscomma ::= COMMA",
137197
- /* 62 */ "tcons ::= CONSTRAINT nm",
137198
- /* 63 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
137199
- /* 64 */ "tcons ::= UNIQUE LP sortlist RP onconf",
137200
- /* 65 */ "tcons ::= CHECK LP expr RP onconf",
137201
- /* 66 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
137202
- /* 67 */ "defer_subclause_opt ::=",
137203
- /* 68 */ "onconf ::=",
137204
- /* 69 */ "onconf ::= ON CONFLICT resolvetype",
137205
- /* 70 */ "orconf ::=",
137206
- /* 71 */ "orconf ::= OR resolvetype",
137207
- /* 72 */ "resolvetype ::= IGNORE",
137208
- /* 73 */ "resolvetype ::= REPLACE",
137209
- /* 74 */ "cmd ::= DROP TABLE ifexists fullname",
137210
- /* 75 */ "ifexists ::= IF EXISTS",
137211
- /* 76 */ "ifexists ::=",
137212
- /* 77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
137213
- /* 78 */ "cmd ::= DROP VIEW ifexists fullname",
137214
- /* 79 */ "cmd ::= select",
137215
- /* 80 */ "select ::= with selectnowith",
137216
- /* 81 */ "selectnowith ::= selectnowith multiselect_op oneselect",
137217
- /* 82 */ "multiselect_op ::= UNION",
137218
- /* 83 */ "multiselect_op ::= UNION ALL",
137219
- /* 84 */ "multiselect_op ::= EXCEPT|INTERSECT",
137220
- /* 85 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
137221
- /* 86 */ "values ::= VALUES LP nexprlist RP",
137222
- /* 87 */ "values ::= values COMMA LP exprlist RP",
137223
- /* 88 */ "distinct ::= DISTINCT",
137224
- /* 89 */ "distinct ::= ALL",
137225
- /* 90 */ "distinct ::=",
137226
- /* 91 */ "sclp ::=",
137227
- /* 92 */ "selcollist ::= sclp expr as",
137228
- /* 93 */ "selcollist ::= sclp STAR",
137229
- /* 94 */ "selcollist ::= sclp nm DOT STAR",
137230
- /* 95 */ "as ::= AS nm",
137231
- /* 96 */ "as ::=",
137232
- /* 97 */ "from ::=",
137233
- /* 98 */ "from ::= FROM seltablist",
137234
- /* 99 */ "stl_prefix ::= seltablist joinop",
137235
- /* 100 */ "stl_prefix ::=",
137236
- /* 101 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
137237
- /* 102 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
137238
- /* 103 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
137239
- /* 104 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
137240
- /* 105 */ "dbnm ::=",
137241
- /* 106 */ "dbnm ::= DOT nm",
137242
- /* 107 */ "fullname ::= nm dbnm",
137243
- /* 108 */ "joinop ::= COMMA|JOIN",
137244
- /* 109 */ "joinop ::= JOIN_KW JOIN",
137245
- /* 110 */ "joinop ::= JOIN_KW nm JOIN",
137246
- /* 111 */ "joinop ::= JOIN_KW nm nm JOIN",
137247
- /* 112 */ "on_opt ::= ON expr",
137248
- /* 113 */ "on_opt ::=",
137249
- /* 114 */ "indexed_opt ::=",
137250
- /* 115 */ "indexed_opt ::= INDEXED BY nm",
137251
- /* 116 */ "indexed_opt ::= NOT INDEXED",
137252
- /* 117 */ "using_opt ::= USING LP idlist RP",
137253
- /* 118 */ "using_opt ::=",
137254
- /* 119 */ "orderby_opt ::=",
137255
- /* 120 */ "orderby_opt ::= ORDER BY sortlist",
137256
- /* 121 */ "sortlist ::= sortlist COMMA expr sortorder",
137257
- /* 122 */ "sortlist ::= expr sortorder",
137258
- /* 123 */ "sortorder ::= ASC",
137259
- /* 124 */ "sortorder ::= DESC",
137260
- /* 125 */ "sortorder ::=",
137261
- /* 126 */ "groupby_opt ::=",
137262
- /* 127 */ "groupby_opt ::= GROUP BY nexprlist",
137263
- /* 128 */ "having_opt ::=",
137264
- /* 129 */ "having_opt ::= HAVING expr",
137265
- /* 130 */ "limit_opt ::=",
137266
- /* 131 */ "limit_opt ::= LIMIT expr",
137267
- /* 132 */ "limit_opt ::= LIMIT expr OFFSET expr",
137268
- /* 133 */ "limit_opt ::= LIMIT expr COMMA expr",
137269
- /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
137270
- /* 135 */ "where_opt ::=",
137271
- /* 136 */ "where_opt ::= WHERE expr",
137272
- /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
137273
- /* 138 */ "setlist ::= setlist COMMA nm EQ expr",
137274
- /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
137275
- /* 140 */ "setlist ::= nm EQ expr",
137276
- /* 141 */ "setlist ::= LP idlist RP EQ expr",
137277
- /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
137278
- /* 143 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
137279
- /* 144 */ "insert_cmd ::= INSERT orconf",
137280
- /* 145 */ "insert_cmd ::= REPLACE",
137281
- /* 146 */ "idlist_opt ::=",
137282
- /* 147 */ "idlist_opt ::= LP idlist RP",
137283
- /* 148 */ "idlist ::= idlist COMMA nm",
137284
- /* 149 */ "idlist ::= nm",
137285
- /* 150 */ "expr ::= LP expr RP",
137286
- /* 151 */ "term ::= NULL",
137287
- /* 152 */ "expr ::= ID|INDEXED",
137288
- /* 153 */ "expr ::= JOIN_KW",
137289
- /* 154 */ "expr ::= nm DOT nm",
137290
- /* 155 */ "expr ::= nm DOT nm DOT nm",
137291
- /* 156 */ "term ::= FLOAT|BLOB",
137292
- /* 157 */ "term ::= STRING",
137293
- /* 158 */ "term ::= INTEGER",
137294
- /* 159 */ "expr ::= VARIABLE",
137295
- /* 160 */ "expr ::= expr COLLATE ID|STRING",
137296
- /* 161 */ "expr ::= CAST LP expr AS typetoken RP",
137297
- /* 162 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
137298
- /* 163 */ "expr ::= ID|INDEXED LP STAR RP",
137299
- /* 164 */ "term ::= CTIME_KW",
137300
- /* 165 */ "expr ::= LP nexprlist COMMA expr RP",
137301
- /* 166 */ "expr ::= expr AND expr",
137302
- /* 167 */ "expr ::= expr OR expr",
137303
- /* 168 */ "expr ::= expr LT|GT|GE|LE expr",
137304
- /* 169 */ "expr ::= expr EQ|NE expr",
137305
- /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
137306
- /* 171 */ "expr ::= expr PLUS|MINUS expr",
137307
- /* 172 */ "expr ::= expr STAR|SLASH|REM expr",
137308
- /* 173 */ "expr ::= expr CONCAT expr",
137309
- /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
137310
- /* 175 */ "expr ::= expr likeop expr",
137311
- /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
137312
- /* 177 */ "expr ::= expr ISNULL|NOTNULL",
137313
- /* 178 */ "expr ::= expr NOT NULL",
137314
- /* 179 */ "expr ::= expr IS expr",
137315
- /* 180 */ "expr ::= expr IS NOT expr",
137316
- /* 181 */ "expr ::= NOT expr",
137317
- /* 182 */ "expr ::= BITNOT expr",
137318
- /* 183 */ "expr ::= MINUS expr",
137319
- /* 184 */ "expr ::= PLUS expr",
137320
- /* 185 */ "between_op ::= BETWEEN",
137321
- /* 186 */ "between_op ::= NOT BETWEEN",
137322
- /* 187 */ "expr ::= expr between_op expr AND expr",
137323
- /* 188 */ "in_op ::= IN",
137324
- /* 189 */ "in_op ::= NOT IN",
137325
- /* 190 */ "expr ::= expr in_op LP exprlist RP",
137326
- /* 191 */ "expr ::= LP select RP",
137327
- /* 192 */ "expr ::= expr in_op LP select RP",
137328
- /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
137329
- /* 194 */ "expr ::= EXISTS LP select RP",
137330
- /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
137331
- /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
137332
- /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
137333
- /* 198 */ "case_else ::= ELSE expr",
137334
- /* 199 */ "case_else ::=",
137335
- /* 200 */ "case_operand ::= expr",
137336
- /* 201 */ "case_operand ::=",
137337
- /* 202 */ "exprlist ::=",
137338
- /* 203 */ "nexprlist ::= nexprlist COMMA expr",
137339
- /* 204 */ "nexprlist ::= expr",
137340
- /* 205 */ "paren_exprlist ::=",
137341
- /* 206 */ "paren_exprlist ::= LP exprlist RP",
137342
- /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
137343
- /* 208 */ "uniqueflag ::= UNIQUE",
137344
- /* 209 */ "uniqueflag ::=",
137345
- /* 210 */ "eidlist_opt ::=",
137346
- /* 211 */ "eidlist_opt ::= LP eidlist RP",
137347
- /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
137348
- /* 213 */ "eidlist ::= nm collate sortorder",
137349
- /* 214 */ "collate ::=",
137350
- /* 215 */ "collate ::= COLLATE ID|STRING",
137351
- /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
137352
- /* 217 */ "cmd ::= VACUUM",
137353
- /* 218 */ "cmd ::= VACUUM nm",
137354
- /* 219 */ "cmd ::= PRAGMA nm dbnm",
137355
- /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
137356
- /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
137357
- /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
137358
- /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137359
- /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137360
- /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137361
- /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137362
- /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137363
- /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364
- /* 229 */ "trigger_time ::= INSTEAD OF",
137365
- /* 230 */ "trigger_time ::=",
137366
- /* 231 */ "trigger_event ::= DELETE|INSERT",
137367
- /* 232 */ "trigger_event ::= UPDATE",
137368
- /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369
- /* 234 */ "when_clause ::=",
137370
- /* 235 */ "when_clause ::= WHEN expr",
137371
- /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372
- /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373
- /* 238 */ "trnm ::= nm DOT nm",
137374
- /* 239 */ "tridxby ::= INDEXED BY nm",
137375
- /* 240 */ "tridxby ::= NOT INDEXED",
137376
- /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377
- /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378
- /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379
- /* 244 */ "trigger_cmd ::= select",
137380
- /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381
- /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382
- /* 247 */ "raisetype ::= ROLLBACK",
137383
- /* 248 */ "raisetype ::= ABORT",
137384
- /* 249 */ "raisetype ::= FAIL",
137385
- /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386
- /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387
- /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388
- /* 253 */ "key_opt ::=",
137389
- /* 254 */ "key_opt ::= KEY expr",
137390
- /* 255 */ "cmd ::= REINDEX",
137391
- /* 256 */ "cmd ::= REINDEX nm dbnm",
137392
- /* 257 */ "cmd ::= ANALYZE",
137393
- /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394
- /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395
- /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396
- /* 261 */ "add_column_fullname ::= fullname",
137397
- /* 262 */ "cmd ::= create_vtab",
137398
- /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399
- /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400
- /* 265 */ "vtabarg ::=",
137401
- /* 266 */ "vtabargtoken ::= ANY",
137402
- /* 267 */ "vtabargtoken ::= lp anylist RP",
137403
- /* 268 */ "lp ::= LP",
137404
- /* 269 */ "with ::=",
137405
- /* 270 */ "with ::= WITH wqlist",
137406
- /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407
- /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408
- /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409
- /* 274 */ "input ::= cmdlist",
137410
- /* 275 */ "cmdlist ::= cmdlist ecmd",
137411
- /* 276 */ "cmdlist ::= ecmd",
137412
- /* 277 */ "ecmd ::= SEMI",
137413
- /* 278 */ "ecmd ::= explain cmdx SEMI",
137414
- /* 279 */ "explain ::=",
137415
- /* 280 */ "trans_opt ::=",
137416
- /* 281 */ "trans_opt ::= TRANSACTION",
137417
- /* 282 */ "trans_opt ::= TRANSACTION nm",
137418
- /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419
- /* 284 */ "savepoint_opt ::=",
137420
- /* 285 */ "cmd ::= create_table create_table_args",
137421
- /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422
- /* 287 */ "columnlist ::= columnname carglist",
137423
- /* 288 */ "nm ::= ID|INDEXED",
137424
- /* 289 */ "nm ::= STRING",
137425
- /* 290 */ "nm ::= JOIN_KW",
137426
- /* 291 */ "typetoken ::= typename",
137427
- /* 292 */ "typename ::= ID|STRING",
137428
- /* 293 */ "signed ::= plus_num",
137429
- /* 294 */ "signed ::= minus_num",
137430
- /* 295 */ "carglist ::= carglist ccons",
137431
- /* 296 */ "carglist ::=",
137432
- /* 297 */ "ccons ::= NULL onconf",
137433
- /* 298 */ "conslist_opt ::= COMMA conslist",
137434
- /* 299 */ "conslist ::= conslist tconscomma tcons",
137435
- /* 300 */ "conslist ::= tcons",
137436
- /* 301 */ "tconscomma ::=",
137437
- /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438
- /* 303 */ "resolvetype ::= raisetype",
137439
- /* 304 */ "selectnowith ::= oneselect",
137440
- /* 305 */ "oneselect ::= values",
137441
- /* 306 */ "sclp ::= selcollist COMMA",
137442
- /* 307 */ "as ::= ID|STRING",
137443
- /* 308 */ "expr ::= term",
137444
- /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445
- /* 310 */ "exprlist ::= nexprlist",
137446
- /* 311 */ "nmnum ::= plus_num",
137447
- /* 312 */ "nmnum ::= nm",
137448
- /* 313 */ "nmnum ::= ON",
137449
- /* 314 */ "nmnum ::= DELETE",
137450
- /* 315 */ "nmnum ::= DEFAULT",
137451
- /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452
- /* 317 */ "foreach_clause ::=",
137453
- /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454
- /* 319 */ "trnm ::= nm",
137455
- /* 320 */ "tridxby ::=",
137456
- /* 321 */ "database_kw_opt ::= DATABASE",
137457
- /* 322 */ "database_kw_opt ::=",
137458
- /* 323 */ "kwcolumn_opt ::=",
137459
- /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460
- /* 325 */ "vtabarglist ::= vtabarg",
137461
- /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462
- /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463
- /* 328 */ "anylist ::=",
137464
- /* 329 */ "anylist ::= anylist LP anylist RP",
137465
- /* 330 */ "anylist ::= anylist ANY",
137428
+ /* 8 */ "cmd ::= COMMIT|END trans_opt",
137429
+ /* 9 */ "cmd ::= ROLLBACK trans_opt",
137430
+ /* 10 */ "cmd ::= SAVEPOINT nm",
137431
+ /* 11 */ "cmd ::= RELEASE savepoint_opt nm",
137432
+ /* 12 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
137433
+ /* 13 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
137434
+ /* 14 */ "createkw ::= CREATE",
137435
+ /* 15 */ "ifnotexists ::=",
137436
+ /* 16 */ "ifnotexists ::= IF NOT EXISTS",
137437
+ /* 17 */ "temp ::= TEMP",
137438
+ /* 18 */ "temp ::=",
137439
+ /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
137440
+ /* 20 */ "create_table_args ::= AS select",
137441
+ /* 21 */ "table_options ::=",
137442
+ /* 22 */ "table_options ::= WITHOUT nm",
137443
+ /* 23 */ "columnname ::= nm typetoken",
137444
+ /* 24 */ "typetoken ::=",
137445
+ /* 25 */ "typetoken ::= typename LP signed RP",
137446
+ /* 26 */ "typetoken ::= typename LP signed COMMA signed RP",
137447
+ /* 27 */ "typename ::= typename ID|STRING",
137448
+ /* 28 */ "ccons ::= CONSTRAINT nm",
137449
+ /* 29 */ "ccons ::= DEFAULT term",
137450
+ /* 30 */ "ccons ::= DEFAULT LP expr RP",
137451
+ /* 31 */ "ccons ::= DEFAULT PLUS term",
137452
+ /* 32 */ "ccons ::= DEFAULT MINUS term",
137453
+ /* 33 */ "ccons ::= DEFAULT ID|INDEXED",
137454
+ /* 34 */ "ccons ::= NOT NULL onconf",
137455
+ /* 35 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
137456
+ /* 36 */ "ccons ::= UNIQUE onconf",
137457
+ /* 37 */ "ccons ::= CHECK LP expr RP",
137458
+ /* 38 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
137459
+ /* 39 */ "ccons ::= defer_subclause",
137460
+ /* 40 */ "ccons ::= COLLATE ID|STRING",
137461
+ /* 41 */ "autoinc ::=",
137462
+ /* 42 */ "autoinc ::= AUTOINCR",
137463
+ /* 43 */ "refargs ::=",
137464
+ /* 44 */ "refargs ::= refargs refarg",
137465
+ /* 45 */ "refarg ::= MATCH nm",
137466
+ /* 46 */ "refarg ::= ON INSERT refact",
137467
+ /* 47 */ "refarg ::= ON DELETE refact",
137468
+ /* 48 */ "refarg ::= ON UPDATE refact",
137469
+ /* 49 */ "refact ::= SET NULL",
137470
+ /* 50 */ "refact ::= SET DEFAULT",
137471
+ /* 51 */ "refact ::= CASCADE",
137472
+ /* 52 */ "refact ::= RESTRICT",
137473
+ /* 53 */ "refact ::= NO ACTION",
137474
+ /* 54 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
137475
+ /* 55 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
137476
+ /* 56 */ "init_deferred_pred_opt ::=",
137477
+ /* 57 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
137478
+ /* 58 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
137479
+ /* 59 */ "conslist_opt ::=",
137480
+ /* 60 */ "tconscomma ::= COMMA",
137481
+ /* 61 */ "tcons ::= CONSTRAINT nm",
137482
+ /* 62 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
137483
+ /* 63 */ "tcons ::= UNIQUE LP sortlist RP onconf",
137484
+ /* 64 */ "tcons ::= CHECK LP expr RP onconf",
137485
+ /* 65 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
137486
+ /* 66 */ "defer_subclause_opt ::=",
137487
+ /* 67 */ "onconf ::=",
137488
+ /* 68 */ "onconf ::= ON CONFLICT resolvetype",
137489
+ /* 69 */ "orconf ::=",
137490
+ /* 70 */ "orconf ::= OR resolvetype",
137491
+ /* 71 */ "resolvetype ::= IGNORE",
137492
+ /* 72 */ "resolvetype ::= REPLACE",
137493
+ /* 73 */ "cmd ::= DROP TABLE ifexists fullname",
137494
+ /* 74 */ "ifexists ::= IF EXISTS",
137495
+ /* 75 */ "ifexists ::=",
137496
+ /* 76 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
137497
+ /* 77 */ "cmd ::= DROP VIEW ifexists fullname",
137498
+ /* 78 */ "cmd ::= select",
137499
+ /* 79 */ "select ::= with selectnowith",
137500
+ /* 80 */ "selectnowith ::= selectnowith multiselect_op oneselect",
137501
+ /* 81 */ "multiselect_op ::= UNION",
137502
+ /* 82 */ "multiselect_op ::= UNION ALL",
137503
+ /* 83 */ "multiselect_op ::= EXCEPT|INTERSECT",
137504
+ /* 84 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
137505
+ /* 85 */ "values ::= VALUES LP nexprlist RP",
137506
+ /* 86 */ "values ::= values COMMA LP exprlist RP",
137507
+ /* 87 */ "distinct ::= DISTINCT",
137508
+ /* 88 */ "distinct ::= ALL",
137509
+ /* 89 */ "distinct ::=",
137510
+ /* 90 */ "sclp ::=",
137511
+ /* 91 */ "selcollist ::= sclp expr as",
137512
+ /* 92 */ "selcollist ::= sclp STAR",
137513
+ /* 93 */ "selcollist ::= sclp nm DOT STAR",
137514
+ /* 94 */ "as ::= AS nm",
137515
+ /* 95 */ "as ::=",
137516
+ /* 96 */ "from ::=",
137517
+ /* 97 */ "from ::= FROM seltablist",
137518
+ /* 98 */ "stl_prefix ::= seltablist joinop",
137519
+ /* 99 */ "stl_prefix ::=",
137520
+ /* 100 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
137521
+ /* 101 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
137522
+ /* 102 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
137523
+ /* 103 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
137524
+ /* 104 */ "dbnm ::=",
137525
+ /* 105 */ "dbnm ::= DOT nm",
137526
+ /* 106 */ "fullname ::= nm dbnm",
137527
+ /* 107 */ "joinop ::= COMMA|JOIN",
137528
+ /* 108 */ "joinop ::= JOIN_KW JOIN",
137529
+ /* 109 */ "joinop ::= JOIN_KW nm JOIN",
137530
+ /* 110 */ "joinop ::= JOIN_KW nm nm JOIN",
137531
+ /* 111 */ "on_opt ::= ON expr",
137532
+ /* 112 */ "on_opt ::=",
137533
+ /* 113 */ "indexed_opt ::=",
137534
+ /* 114 */ "indexed_opt ::= INDEXED BY nm",
137535
+ /* 115 */ "indexed_opt ::= NOT INDEXED",
137536
+ /* 116 */ "using_opt ::= USING LP idlist RP",
137537
+ /* 117 */ "using_opt ::=",
137538
+ /* 118 */ "orderby_opt ::=",
137539
+ /* 119 */ "orderby_opt ::= ORDER BY sortlist",
137540
+ /* 120 */ "sortlist ::= sortlist COMMA expr sortorder",
137541
+ /* 121 */ "sortlist ::= expr sortorder",
137542
+ /* 122 */ "sortorder ::= ASC",
137543
+ /* 123 */ "sortorder ::= DESC",
137544
+ /* 124 */ "sortorder ::=",
137545
+ /* 125 */ "groupby_opt ::=",
137546
+ /* 126 */ "groupby_opt ::= GROUP BY nexprlist",
137547
+ /* 127 */ "having_opt ::=",
137548
+ /* 128 */ "having_opt ::= HAVING expr",
137549
+ /* 129 */ "limit_opt ::=",
137550
+ /* 130 */ "limit_opt ::= LIMIT expr",
137551
+ /* 131 */ "limit_opt ::= LIMIT expr OFFSET expr",
137552
+ /* 132 */ "limit_opt ::= LIMIT expr COMMA expr",
137553
+ /* 133 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
137554
+ /* 134 */ "where_opt ::=",
137555
+ /* 135 */ "where_opt ::= WHERE expr",
137556
+ /* 136 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
137557
+ /* 137 */ "setlist ::= setlist COMMA nm EQ expr",
137558
+ /* 138 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
137559
+ /* 139 */ "setlist ::= nm EQ expr",
137560
+ /* 140 */ "setlist ::= LP idlist RP EQ expr",
137561
+ /* 141 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
137562
+ /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
137563
+ /* 143 */ "insert_cmd ::= INSERT orconf",
137564
+ /* 144 */ "insert_cmd ::= REPLACE",
137565
+ /* 145 */ "idlist_opt ::=",
137566
+ /* 146 */ "idlist_opt ::= LP idlist RP",
137567
+ /* 147 */ "idlist ::= idlist COMMA nm",
137568
+ /* 148 */ "idlist ::= nm",
137569
+ /* 149 */ "expr ::= LP expr RP",
137570
+ /* 150 */ "term ::= NULL",
137571
+ /* 151 */ "expr ::= ID|INDEXED",
137572
+ /* 152 */ "expr ::= JOIN_KW",
137573
+ /* 153 */ "expr ::= nm DOT nm",
137574
+ /* 154 */ "expr ::= nm DOT nm DOT nm",
137575
+ /* 155 */ "term ::= FLOAT|BLOB",
137576
+ /* 156 */ "term ::= STRING",
137577
+ /* 157 */ "term ::= INTEGER",
137578
+ /* 158 */ "expr ::= VARIABLE",
137579
+ /* 159 */ "expr ::= expr COLLATE ID|STRING",
137580
+ /* 160 */ "expr ::= CAST LP expr AS typetoken RP",
137581
+ /* 161 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
137582
+ /* 162 */ "expr ::= ID|INDEXED LP STAR RP",
137583
+ /* 163 */ "term ::= CTIME_KW",
137584
+ /* 164 */ "expr ::= LP nexprlist COMMA expr RP",
137585
+ /* 165 */ "expr ::= expr AND expr",
137586
+ /* 166 */ "expr ::= expr OR expr",
137587
+ /* 167 */ "expr ::= expr LT|GT|GE|LE expr",
137588
+ /* 168 */ "expr ::= expr EQ|NE expr",
137589
+ /* 169 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
137590
+ /* 170 */ "expr ::= expr PLUS|MINUS expr",
137591
+ /* 171 */ "expr ::= expr STAR|SLASH|REM expr",
137592
+ /* 172 */ "expr ::= expr CONCAT expr",
137593
+ /* 173 */ "likeop ::= NOT LIKE_KW|MATCH",
137594
+ /* 174 */ "expr ::= expr likeop expr",
137595
+ /* 175 */ "expr ::= expr likeop expr ESCAPE expr",
137596
+ /* 176 */ "expr ::= expr ISNULL|NOTNULL",
137597
+ /* 177 */ "expr ::= expr NOT NULL",
137598
+ /* 178 */ "expr ::= expr IS expr",
137599
+ /* 179 */ "expr ::= expr IS NOT expr",
137600
+ /* 180 */ "expr ::= NOT expr",
137601
+ /* 181 */ "expr ::= BITNOT expr",
137602
+ /* 182 */ "expr ::= MINUS expr",
137603
+ /* 183 */ "expr ::= PLUS expr",
137604
+ /* 184 */ "between_op ::= BETWEEN",
137605
+ /* 185 */ "between_op ::= NOT BETWEEN",
137606
+ /* 186 */ "expr ::= expr between_op expr AND expr",
137607
+ /* 187 */ "in_op ::= IN",
137608
+ /* 188 */ "in_op ::= NOT IN",
137609
+ /* 189 */ "expr ::= expr in_op LP exprlist RP",
137610
+ /* 190 */ "expr ::= LP select RP",
137611
+ /* 191 */ "expr ::= expr in_op LP select RP",
137612
+ /* 192 */ "expr ::= expr in_op nm dbnm paren_exprlist",
137613
+ /* 193 */ "expr ::= EXISTS LP select RP",
137614
+ /* 194 */ "expr ::= CASE case_operand case_exprlist case_else END",
137615
+ /* 195 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
137616
+ /* 196 */ "case_exprlist ::= WHEN expr THEN expr",
137617
+ /* 197 */ "case_else ::= ELSE expr",
137618
+ /* 198 */ "case_else ::=",
137619
+ /* 199 */ "case_operand ::= expr",
137620
+ /* 200 */ "case_operand ::=",
137621
+ /* 201 */ "exprlist ::=",
137622
+ /* 202 */ "nexprlist ::= nexprlist COMMA expr",
137623
+ /* 203 */ "nexprlist ::= expr",
137624
+ /* 204 */ "paren_exprlist ::=",
137625
+ /* 205 */ "paren_exprlist ::= LP exprlist RP",
137626
+ /* 206 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
137627
+ /* 207 */ "uniqueflag ::= UNIQUE",
137628
+ /* 208 */ "uniqueflag ::=",
137629
+ /* 209 */ "eidlist_opt ::=",
137630
+ /* 210 */ "eidlist_opt ::= LP eidlist RP",
137631
+ /* 211 */ "eidlist ::= eidlist COMMA nm collate sortorder",
137632
+ /* 212 */ "eidlist ::= nm collate sortorder",
137633
+ /* 213 */ "collate ::=",
137634
+ /* 214 */ "collate ::= COLLATE ID|STRING",
137635
+ /* 215 */ "cmd ::= DROP INDEX ifexists fullname",
137636
+ /* 216 */ "cmd ::= VACUUM",
137637
+ /* 217 */ "cmd ::= VACUUM nm",
137638
+ /* 218 */ "cmd ::= PRAGMA nm dbnm",
137639
+ /* 219 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
137640
+ /* 220 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
137641
+ /* 221 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
137642
+ /* 222 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137643
+ /* 223 */ "plus_num ::= PLUS INTEGER|FLOAT",
137644
+ /* 224 */ "minus_num ::= MINUS INTEGER|FLOAT",
137645
+ /* 225 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137646
+ /* 226 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137647
+ /* 227 */ "trigger_time ::= BEFORE|AFTER",
137648
+ /* 228 */ "trigger_time ::= INSTEAD OF",
137649
+ /* 229 */ "trigger_time ::=",
137650
+ /* 230 */ "trigger_event ::= DELETE|INSERT",
137651
+ /* 231 */ "trigger_event ::= UPDATE",
137652
+ /* 232 */ "trigger_event ::= UPDATE OF idlist",
137653
+ /* 233 */ "when_clause ::=",
137654
+ /* 234 */ "when_clause ::= WHEN expr",
137655
+ /* 235 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137656
+ /* 236 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137657
+ /* 237 */ "trnm ::= nm DOT nm",
137658
+ /* 238 */ "tridxby ::= INDEXED BY nm",
137659
+ /* 239 */ "tridxby ::= NOT INDEXED",
137660
+ /* 240 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137661
+ /* 241 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137662
+ /* 242 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137663
+ /* 243 */ "trigger_cmd ::= select",
137664
+ /* 244 */ "expr ::= RAISE LP IGNORE RP",
137665
+ /* 245 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137666
+ /* 246 */ "raisetype ::= ROLLBACK",
137667
+ /* 247 */ "raisetype ::= ABORT",
137668
+ /* 248 */ "raisetype ::= FAIL",
137669
+ /* 249 */ "cmd ::= DROP TRIGGER ifexists fullname",
137670
+ /* 250 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137671
+ /* 251 */ "cmd ::= DETACH database_kw_opt expr",
137672
+ /* 252 */ "key_opt ::=",
137673
+ /* 253 */ "key_opt ::= KEY expr",
137674
+ /* 254 */ "cmd ::= REINDEX",
137675
+ /* 255 */ "cmd ::= REINDEX nm dbnm",
137676
+ /* 256 */ "cmd ::= ANALYZE",
137677
+ /* 257 */ "cmd ::= ANALYZE nm dbnm",
137678
+ /* 258 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137679
+ /* 259 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137680
+ /* 260 */ "add_column_fullname ::= fullname",
137681
+ /* 261 */ "cmd ::= create_vtab",
137682
+ /* 262 */ "cmd ::= create_vtab LP vtabarglist RP",
137683
+ /* 263 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137684
+ /* 264 */ "vtabarg ::=",
137685
+ /* 265 */ "vtabargtoken ::= ANY",
137686
+ /* 266 */ "vtabargtoken ::= lp anylist RP",
137687
+ /* 267 */ "lp ::= LP",
137688
+ /* 268 */ "with ::=",
137689
+ /* 269 */ "with ::= WITH wqlist",
137690
+ /* 270 */ "with ::= WITH RECURSIVE wqlist",
137691
+ /* 271 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137692
+ /* 272 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137693
+ /* 273 */ "input ::= cmdlist",
137694
+ /* 274 */ "cmdlist ::= cmdlist ecmd",
137695
+ /* 275 */ "cmdlist ::= ecmd",
137696
+ /* 276 */ "ecmd ::= SEMI",
137697
+ /* 277 */ "ecmd ::= explain cmdx SEMI",
137698
+ /* 278 */ "explain ::=",
137699
+ /* 279 */ "trans_opt ::=",
137700
+ /* 280 */ "trans_opt ::= TRANSACTION",
137701
+ /* 281 */ "trans_opt ::= TRANSACTION nm",
137702
+ /* 282 */ "savepoint_opt ::= SAVEPOINT",
137703
+ /* 283 */ "savepoint_opt ::=",
137704
+ /* 284 */ "cmd ::= create_table create_table_args",
137705
+ /* 285 */ "columnlist ::= columnlist COMMA columnname carglist",
137706
+ /* 286 */ "columnlist ::= columnname carglist",
137707
+ /* 287 */ "nm ::= ID|INDEXED",
137708
+ /* 288 */ "nm ::= STRING",
137709
+ /* 289 */ "nm ::= JOIN_KW",
137710
+ /* 290 */ "typetoken ::= typename",
137711
+ /* 291 */ "typename ::= ID|STRING",
137712
+ /* 292 */ "signed ::= plus_num",
137713
+ /* 293 */ "signed ::= minus_num",
137714
+ /* 294 */ "carglist ::= carglist ccons",
137715
+ /* 295 */ "carglist ::=",
137716
+ /* 296 */ "ccons ::= NULL onconf",
137717
+ /* 297 */ "conslist_opt ::= COMMA conslist",
137718
+ /* 298 */ "conslist ::= conslist tconscomma tcons",
137719
+ /* 299 */ "conslist ::= tcons",
137720
+ /* 300 */ "tconscomma ::=",
137721
+ /* 301 */ "defer_subclause_opt ::= defer_subclause",
137722
+ /* 302 */ "resolvetype ::= raisetype",
137723
+ /* 303 */ "selectnowith ::= oneselect",
137724
+ /* 304 */ "oneselect ::= values",
137725
+ /* 305 */ "sclp ::= selcollist COMMA",
137726
+ /* 306 */ "as ::= ID|STRING",
137727
+ /* 307 */ "expr ::= term",
137728
+ /* 308 */ "likeop ::= LIKE_KW|MATCH",
137729
+ /* 309 */ "exprlist ::= nexprlist",
137730
+ /* 310 */ "nmnum ::= plus_num",
137731
+ /* 311 */ "nmnum ::= nm",
137732
+ /* 312 */ "nmnum ::= ON",
137733
+ /* 313 */ "nmnum ::= DELETE",
137734
+ /* 314 */ "nmnum ::= DEFAULT",
137735
+ /* 315 */ "plus_num ::= INTEGER|FLOAT",
137736
+ /* 316 */ "foreach_clause ::=",
137737
+ /* 317 */ "foreach_clause ::= FOR EACH ROW",
137738
+ /* 318 */ "trnm ::= nm",
137739
+ /* 319 */ "tridxby ::=",
137740
+ /* 320 */ "database_kw_opt ::= DATABASE",
137741
+ /* 321 */ "database_kw_opt ::=",
137742
+ /* 322 */ "kwcolumn_opt ::=",
137743
+ /* 323 */ "kwcolumn_opt ::= COLUMNKW",
137744
+ /* 324 */ "vtabarglist ::= vtabarg",
137745
+ /* 325 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137746
+ /* 326 */ "vtabarg ::= vtabarg vtabargtoken",
137747
+ /* 327 */ "anylist ::=",
137748
+ /* 328 */ "anylist ::= anylist LP anylist RP",
137749
+ /* 329 */ "anylist ::= anylist ANY",
137466137750
};
137467137751
#endif /* NDEBUG */
137468137752
137469137753
137470137754
#if YYSTACKDEPTH<=0
@@ -137529,11 +137813,13 @@
137529137813
pParser->yyerrcnt = -1;
137530137814
#endif
137531137815
pParser->yytos = pParser->yystack;
137532137816
pParser->yystack[0].stateno = 0;
137533137817
pParser->yystack[0].major = 0;
137818
+#if YYSTACKDEPTH>0
137534137819
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137820
+#endif
137535137821
}
137536137822
137537137823
#ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137538137824
/*
137539137825
** This function allocates a new parser.
@@ -137911,11 +138197,10 @@
137911138197
{ 149, -3 },
137912138198
{ 150, 0 },
137913138199
{ 150, -1 },
137914138200
{ 150, -1 },
137915138201
{ 150, -1 },
137916
- { 149, -2 },
137917138202
{ 149, -2 },
137918138203
{ 149, -2 },
137919138204
{ 149, -2 },
137920138205
{ 149, -3 },
137921138206
{ 149, -5 },
@@ -138317,256 +138602,253 @@
138317138602
case 5: /* transtype ::= DEFERRED */
138318138603
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
138319138604
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
138320138605
{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
138321138606
break;
138322
- case 8: /* cmd ::= COMMIT trans_opt */
138323
- case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
138324
-{sqlite3CommitTransaction(pParse);}
138325
- break;
138326
- case 10: /* cmd ::= ROLLBACK trans_opt */
138327
-{sqlite3RollbackTransaction(pParse);}
138328
- break;
138329
- case 11: /* cmd ::= SAVEPOINT nm */
138607
+ case 8: /* cmd ::= COMMIT|END trans_opt */
138608
+ case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
138609
+{sqlite3EndTransaction(pParse,yymsp[-1].major);}
138610
+ break;
138611
+ case 10: /* cmd ::= SAVEPOINT nm */
138330138612
{
138331138613
sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);
138332138614
}
138333138615
break;
138334
- case 12: /* cmd ::= RELEASE savepoint_opt nm */
138616
+ case 11: /* cmd ::= RELEASE savepoint_opt nm */
138335138617
{
138336138618
sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);
138337138619
}
138338138620
break;
138339
- case 13: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
138621
+ case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
138340138622
{
138341138623
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
138342138624
}
138343138625
break;
138344
- case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
138626
+ case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
138345138627
{
138346138628
sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
138347138629
}
138348138630
break;
138349
- case 15: /* createkw ::= CREATE */
138631
+ case 14: /* createkw ::= CREATE */
138350138632
{disableLookaside(pParse);}
138351138633
break;
138352
- case 16: /* ifnotexists ::= */
138353
- case 19: /* temp ::= */ yytestcase(yyruleno==19);
138354
- case 22: /* table_options ::= */ yytestcase(yyruleno==22);
138355
- case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
138356
- case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
138357
- case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
138358
- case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
138359
- case 90: /* distinct ::= */ yytestcase(yyruleno==90);
138360
- case 214: /* collate ::= */ yytestcase(yyruleno==214);
138634
+ case 15: /* ifnotexists ::= */
138635
+ case 18: /* temp ::= */ yytestcase(yyruleno==18);
138636
+ case 21: /* table_options ::= */ yytestcase(yyruleno==21);
138637
+ case 41: /* autoinc ::= */ yytestcase(yyruleno==41);
138638
+ case 56: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==56);
138639
+ case 66: /* defer_subclause_opt ::= */ yytestcase(yyruleno==66);
138640
+ case 75: /* ifexists ::= */ yytestcase(yyruleno==75);
138641
+ case 89: /* distinct ::= */ yytestcase(yyruleno==89);
138642
+ case 213: /* collate ::= */ yytestcase(yyruleno==213);
138361138643
{yymsp[1].minor.yy194 = 0;}
138362138644
break;
138363
- case 17: /* ifnotexists ::= IF NOT EXISTS */
138645
+ case 16: /* ifnotexists ::= IF NOT EXISTS */
138364138646
{yymsp[-2].minor.yy194 = 1;}
138365138647
break;
138366
- case 18: /* temp ::= TEMP */
138367
- case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
138648
+ case 17: /* temp ::= TEMP */
138649
+ case 42: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==42);
138368138650
{yymsp[0].minor.yy194 = 1;}
138369138651
break;
138370
- case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
138652
+ case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
138371138653
{
138372138654
sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
138373138655
}
138374138656
break;
138375
- case 21: /* create_table_args ::= AS select */
138657
+ case 20: /* create_table_args ::= AS select */
138376138658
{
138377138659
sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
138378138660
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138379138661
}
138380138662
break;
138381
- case 23: /* table_options ::= WITHOUT nm */
138663
+ case 22: /* table_options ::= WITHOUT nm */
138382138664
{
138383138665
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
138384138666
yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
138385138667
}else{
138386138668
yymsp[-1].minor.yy194 = 0;
138387138669
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
138388138670
}
138389138671
}
138390138672
break;
138391
- case 24: /* columnname ::= nm typetoken */
138673
+ case 23: /* columnname ::= nm typetoken */
138392138674
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
138393138675
break;
138394
- case 25: /* typetoken ::= */
138395
- case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
138396
- case 96: /* as ::= */ yytestcase(yyruleno==96);
138676
+ case 24: /* typetoken ::= */
138677
+ case 59: /* conslist_opt ::= */ yytestcase(yyruleno==59);
138678
+ case 95: /* as ::= */ yytestcase(yyruleno==95);
138397138679
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
138398138680
break;
138399
- case 26: /* typetoken ::= typename LP signed RP */
138681
+ case 25: /* typetoken ::= typename LP signed RP */
138400138682
{
138401138683
yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
138402138684
}
138403138685
break;
138404
- case 27: /* typetoken ::= typename LP signed COMMA signed RP */
138686
+ case 26: /* typetoken ::= typename LP signed COMMA signed RP */
138405138687
{
138406138688
yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
138407138689
}
138408138690
break;
138409
- case 28: /* typename ::= typename ID|STRING */
138691
+ case 27: /* typename ::= typename ID|STRING */
138410138692
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
138411138693
break;
138412
- case 29: /* ccons ::= CONSTRAINT nm */
138413
- case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
138694
+ case 28: /* ccons ::= CONSTRAINT nm */
138695
+ case 61: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==61);
138414138696
{pParse->constraintName = yymsp[0].minor.yy0;}
138415138697
break;
138416
- case 30: /* ccons ::= DEFAULT term */
138417
- case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
138698
+ case 29: /* ccons ::= DEFAULT term */
138699
+ case 31: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==31);
138418138700
{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
138419138701
break;
138420
- case 31: /* ccons ::= DEFAULT LP expr RP */
138702
+ case 30: /* ccons ::= DEFAULT LP expr RP */
138421138703
{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
138422138704
break;
138423
- case 33: /* ccons ::= DEFAULT MINUS term */
138705
+ case 32: /* ccons ::= DEFAULT MINUS term */
138424138706
{
138425138707
ExprSpan v;
138426138708
v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0);
138427138709
v.zStart = yymsp[-1].minor.yy0.z;
138428138710
v.zEnd = yymsp[0].minor.yy190.zEnd;
138429138711
sqlite3AddDefaultValue(pParse,&v);
138430138712
}
138431138713
break;
138432
- case 34: /* ccons ::= DEFAULT ID|INDEXED */
138714
+ case 33: /* ccons ::= DEFAULT ID|INDEXED */
138433138715
{
138434138716
ExprSpan v;
138435138717
spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
138436138718
sqlite3AddDefaultValue(pParse,&v);
138437138719
}
138438138720
break;
138439
- case 35: /* ccons ::= NOT NULL onconf */
138721
+ case 34: /* ccons ::= NOT NULL onconf */
138440138722
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
138441138723
break;
138442
- case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
138724
+ case 35: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
138443138725
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
138444138726
break;
138445
- case 37: /* ccons ::= UNIQUE onconf */
138727
+ case 36: /* ccons ::= UNIQUE onconf */
138446138728
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
138447138729
SQLITE_IDXTYPE_UNIQUE);}
138448138730
break;
138449
- case 38: /* ccons ::= CHECK LP expr RP */
138731
+ case 37: /* ccons ::= CHECK LP expr RP */
138450138732
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
138451138733
break;
138452
- case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
138734
+ case 38: /* ccons ::= REFERENCES nm eidlist_opt refargs */
138453138735
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
138454138736
break;
138455
- case 40: /* ccons ::= defer_subclause */
138737
+ case 39: /* ccons ::= defer_subclause */
138456138738
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
138457138739
break;
138458
- case 41: /* ccons ::= COLLATE ID|STRING */
138740
+ case 40: /* ccons ::= COLLATE ID|STRING */
138459138741
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
138460138742
break;
138461
- case 44: /* refargs ::= */
138743
+ case 43: /* refargs ::= */
138462138744
{ yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
138463138745
break;
138464
- case 45: /* refargs ::= refargs refarg */
138746
+ case 44: /* refargs ::= refargs refarg */
138465138747
{ yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
138466138748
break;
138467
- case 46: /* refarg ::= MATCH nm */
138749
+ case 45: /* refarg ::= MATCH nm */
138468138750
{ yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
138469138751
break;
138470
- case 47: /* refarg ::= ON INSERT refact */
138752
+ case 46: /* refarg ::= ON INSERT refact */
138471138753
{ yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
138472138754
break;
138473
- case 48: /* refarg ::= ON DELETE refact */
138755
+ case 47: /* refarg ::= ON DELETE refact */
138474138756
{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
138475138757
break;
138476
- case 49: /* refarg ::= ON UPDATE refact */
138758
+ case 48: /* refarg ::= ON UPDATE refact */
138477138759
{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
138478138760
break;
138479
- case 50: /* refact ::= SET NULL */
138761
+ case 49: /* refact ::= SET NULL */
138480138762
{ yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
138481138763
break;
138482
- case 51: /* refact ::= SET DEFAULT */
138764
+ case 50: /* refact ::= SET DEFAULT */
138483138765
{ yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
138484138766
break;
138485
- case 52: /* refact ::= CASCADE */
138767
+ case 51: /* refact ::= CASCADE */
138486138768
{ yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
138487138769
break;
138488
- case 53: /* refact ::= RESTRICT */
138770
+ case 52: /* refact ::= RESTRICT */
138489138771
{ yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
138490138772
break;
138491
- case 54: /* refact ::= NO ACTION */
138773
+ case 53: /* refact ::= NO ACTION */
138492138774
{ yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
138493138775
break;
138494
- case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
138776
+ case 54: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
138495138777
{yymsp[-2].minor.yy194 = 0;}
138496138778
break;
138497
- case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
138498
- case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
138499
- case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
138779
+ case 55: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
138780
+ case 70: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==70);
138781
+ case 143: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==143);
138500138782
{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
138501138783
break;
138502
- case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
138503
- case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
138504
- case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
138505
- case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
138506
- case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
138784
+ case 57: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
138785
+ case 74: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==74);
138786
+ case 185: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==185);
138787
+ case 188: /* in_op ::= NOT IN */ yytestcase(yyruleno==188);
138788
+ case 214: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==214);
138507138789
{yymsp[-1].minor.yy194 = 1;}
138508138790
break;
138509
- case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
138791
+ case 58: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
138510138792
{yymsp[-1].minor.yy194 = 0;}
138511138793
break;
138512
- case 61: /* tconscomma ::= COMMA */
138794
+ case 60: /* tconscomma ::= COMMA */
138513138795
{pParse->constraintName.n = 0;}
138514138796
break;
138515
- case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
138797
+ case 62: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
138516138798
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
138517138799
break;
138518
- case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
138800
+ case 63: /* tcons ::= UNIQUE LP sortlist RP onconf */
138519138801
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
138520138802
SQLITE_IDXTYPE_UNIQUE);}
138521138803
break;
138522
- case 65: /* tcons ::= CHECK LP expr RP onconf */
138804
+ case 64: /* tcons ::= CHECK LP expr RP onconf */
138523138805
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
138524138806
break;
138525
- case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
138807
+ case 65: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
138526138808
{
138527138809
sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
138528138810
sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
138529138811
}
138530138812
break;
138531
- case 68: /* onconf ::= */
138532
- case 70: /* orconf ::= */ yytestcase(yyruleno==70);
138813
+ case 67: /* onconf ::= */
138814
+ case 69: /* orconf ::= */ yytestcase(yyruleno==69);
138533138815
{yymsp[1].minor.yy194 = OE_Default;}
138534138816
break;
138535
- case 69: /* onconf ::= ON CONFLICT resolvetype */
138817
+ case 68: /* onconf ::= ON CONFLICT resolvetype */
138536138818
{yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
138537138819
break;
138538
- case 72: /* resolvetype ::= IGNORE */
138820
+ case 71: /* resolvetype ::= IGNORE */
138539138821
{yymsp[0].minor.yy194 = OE_Ignore;}
138540138822
break;
138541
- case 73: /* resolvetype ::= REPLACE */
138542
- case 145: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==145);
138823
+ case 72: /* resolvetype ::= REPLACE */
138824
+ case 144: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==144);
138543138825
{yymsp[0].minor.yy194 = OE_Replace;}
138544138826
break;
138545
- case 74: /* cmd ::= DROP TABLE ifexists fullname */
138827
+ case 73: /* cmd ::= DROP TABLE ifexists fullname */
138546138828
{
138547138829
sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
138548138830
}
138549138831
break;
138550
- case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
138832
+ case 76: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
138551138833
{
138552138834
sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
138553138835
}
138554138836
break;
138555
- case 78: /* cmd ::= DROP VIEW ifexists fullname */
138837
+ case 77: /* cmd ::= DROP VIEW ifexists fullname */
138556138838
{
138557138839
sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
138558138840
}
138559138841
break;
138560
- case 79: /* cmd ::= select */
138842
+ case 78: /* cmd ::= select */
138561138843
{
138562138844
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
138563138845
sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
138564138846
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138565138847
}
138566138848
break;
138567
- case 80: /* select ::= with selectnowith */
138849
+ case 79: /* select ::= with selectnowith */
138568138850
{
138569138851
Select *p = yymsp[0].minor.yy243;
138570138852
if( p ){
138571138853
p->pWith = yymsp[-1].minor.yy285;
138572138854
parserDoubleLinkSelect(pParse, p);
@@ -138574,11 +138856,11 @@
138574138856
sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
138575138857
}
138576138858
yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
138577138859
}
138578138860
break;
138579
- case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
138861
+ case 80: /* selectnowith ::= selectnowith multiselect_op oneselect */
138580138862
{
138581138863
Select *pRhs = yymsp[0].minor.yy243;
138582138864
Select *pLhs = yymsp[-2].minor.yy243;
138583138865
if( pRhs && pRhs->pPrior ){
138584138866
SrcList *pFrom;
@@ -138598,18 +138880,18 @@
138598138880
sqlite3SelectDelete(pParse->db, pLhs);
138599138881
}
138600138882
yymsp[-2].minor.yy243 = pRhs;
138601138883
}
138602138884
break;
138603
- case 82: /* multiselect_op ::= UNION */
138604
- case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
138885
+ case 81: /* multiselect_op ::= UNION */
138886
+ case 83: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==83);
138605138887
{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
138606138888
break;
138607
- case 83: /* multiselect_op ::= UNION ALL */
138889
+ case 82: /* multiselect_op ::= UNION ALL */
138608138890
{yymsp[-1].minor.yy194 = TK_ALL;}
138609138891
break;
138610
- case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
138892
+ case 84: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
138611138893
{
138612138894
#if SELECTTRACE_ENABLED
138613138895
Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
138614138896
#endif
138615138897
yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
@@ -138637,16 +138919,16 @@
138637138919
}
138638138920
}
138639138921
#endif /* SELECTRACE_ENABLED */
138640138922
}
138641138923
break;
138642
- case 86: /* values ::= VALUES LP nexprlist RP */
138924
+ case 85: /* values ::= VALUES LP nexprlist RP */
138643138925
{
138644138926
yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
138645138927
}
138646138928
break;
138647
- case 87: /* values ::= values COMMA LP exprlist RP */
138929
+ case 86: /* values ::= values COMMA LP exprlist RP */
138648138930
{
138649138931
Select *pRight, *pLeft = yymsp[-4].minor.yy243;
138650138932
pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
138651138933
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
138652138934
if( pRight ){
@@ -138656,86 +138938,86 @@
138656138938
}else{
138657138939
yymsp[-4].minor.yy243 = pLeft;
138658138940
}
138659138941
}
138660138942
break;
138661
- case 88: /* distinct ::= DISTINCT */
138943
+ case 87: /* distinct ::= DISTINCT */
138662138944
{yymsp[0].minor.yy194 = SF_Distinct;}
138663138945
break;
138664
- case 89: /* distinct ::= ALL */
138946
+ case 88: /* distinct ::= ALL */
138665138947
{yymsp[0].minor.yy194 = SF_All;}
138666138948
break;
138667
- case 91: /* sclp ::= */
138668
- case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
138669
- case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
138670
- case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
138671
- case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
138672
- case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
138949
+ case 90: /* sclp ::= */
138950
+ case 118: /* orderby_opt ::= */ yytestcase(yyruleno==118);
138951
+ case 125: /* groupby_opt ::= */ yytestcase(yyruleno==125);
138952
+ case 201: /* exprlist ::= */ yytestcase(yyruleno==201);
138953
+ case 204: /* paren_exprlist ::= */ yytestcase(yyruleno==204);
138954
+ case 209: /* eidlist_opt ::= */ yytestcase(yyruleno==209);
138673138955
{yymsp[1].minor.yy148 = 0;}
138674138956
break;
138675
- case 92: /* selcollist ::= sclp expr as */
138957
+ case 91: /* selcollist ::= sclp expr as */
138676138958
{
138677138959
yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
138678138960
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
138679138961
sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
138680138962
}
138681138963
break;
138682
- case 93: /* selcollist ::= sclp STAR */
138964
+ case 92: /* selcollist ::= sclp STAR */
138683138965
{
138684138966
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
138685138967
yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
138686138968
}
138687138969
break;
138688
- case 94: /* selcollist ::= sclp nm DOT STAR */
138970
+ case 93: /* selcollist ::= sclp nm DOT STAR */
138689138971
{
138690138972
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
138691138973
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138692138974
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
138693138975
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
138694138976
}
138695138977
break;
138696
- case 95: /* as ::= AS nm */
138697
- case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
138698
- case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
138699
- case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
138978
+ case 94: /* as ::= AS nm */
138979
+ case 105: /* dbnm ::= DOT nm */ yytestcase(yyruleno==105);
138980
+ case 223: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==223);
138981
+ case 224: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
138700138982
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
138701138983
break;
138702
- case 97: /* from ::= */
138984
+ case 96: /* from ::= */
138703138985
{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
138704138986
break;
138705
- case 98: /* from ::= FROM seltablist */
138987
+ case 97: /* from ::= FROM seltablist */
138706138988
{
138707138989
yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
138708138990
sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
138709138991
}
138710138992
break;
138711
- case 99: /* stl_prefix ::= seltablist joinop */
138993
+ case 98: /* stl_prefix ::= seltablist joinop */
138712138994
{
138713138995
if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
138714138996
}
138715138997
break;
138716
- case 100: /* stl_prefix ::= */
138998
+ case 99: /* stl_prefix ::= */
138717138999
{yymsp[1].minor.yy185 = 0;}
138718139000
break;
138719
- case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
139001
+ case 100: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
138720139002
{
138721139003
yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138722139004
sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
138723139005
}
138724139006
break;
138725
- case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
139007
+ case 101: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
138726139008
{
138727139009
yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138728139010
sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
138729139011
}
138730139012
break;
138731
- case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
139013
+ case 102: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
138732139014
{
138733139015
yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138734139016
}
138735139017
break;
138736
- case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
139018
+ case 103: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
138737139019
{
138738139020
if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
138739139021
yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
138740139022
}else if( yymsp[-4].minor.yy185->nSrc==1 ){
138741139023
yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
@@ -138755,191 +139037,191 @@
138755139037
pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
138756139038
yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138757139039
}
138758139040
}
138759139041
break;
138760
- case 105: /* dbnm ::= */
138761
- case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
139042
+ case 104: /* dbnm ::= */
139043
+ case 113: /* indexed_opt ::= */ yytestcase(yyruleno==113);
138762139044
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
138763139045
break;
138764
- case 107: /* fullname ::= nm dbnm */
139046
+ case 106: /* fullname ::= nm dbnm */
138765139047
{yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
138766139048
break;
138767
- case 108: /* joinop ::= COMMA|JOIN */
139049
+ case 107: /* joinop ::= COMMA|JOIN */
138768139050
{ yymsp[0].minor.yy194 = JT_INNER; }
138769139051
break;
138770
- case 109: /* joinop ::= JOIN_KW JOIN */
139052
+ case 108: /* joinop ::= JOIN_KW JOIN */
138771139053
{yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
138772139054
break;
138773
- case 110: /* joinop ::= JOIN_KW nm JOIN */
139055
+ case 109: /* joinop ::= JOIN_KW nm JOIN */
138774139056
{yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
138775139057
break;
138776
- case 111: /* joinop ::= JOIN_KW nm nm JOIN */
139058
+ case 110: /* joinop ::= JOIN_KW nm nm JOIN */
138777139059
{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
138778139060
break;
138779
- case 112: /* on_opt ::= ON expr */
138780
- case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
138781
- case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
138782
- case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
139061
+ case 111: /* on_opt ::= ON expr */
139062
+ case 128: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==128);
139063
+ case 135: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==135);
139064
+ case 197: /* case_else ::= ELSE expr */ yytestcase(yyruleno==197);
138783139065
{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
138784139066
break;
138785
- case 113: /* on_opt ::= */
138786
- case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
138787
- case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
138788
- case 199: /* case_else ::= */ yytestcase(yyruleno==199);
138789
- case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
139067
+ case 112: /* on_opt ::= */
139068
+ case 127: /* having_opt ::= */ yytestcase(yyruleno==127);
139069
+ case 134: /* where_opt ::= */ yytestcase(yyruleno==134);
139070
+ case 198: /* case_else ::= */ yytestcase(yyruleno==198);
139071
+ case 200: /* case_operand ::= */ yytestcase(yyruleno==200);
138790139072
{yymsp[1].minor.yy72 = 0;}
138791139073
break;
138792
- case 115: /* indexed_opt ::= INDEXED BY nm */
139074
+ case 114: /* indexed_opt ::= INDEXED BY nm */
138793139075
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
138794139076
break;
138795
- case 116: /* indexed_opt ::= NOT INDEXED */
139077
+ case 115: /* indexed_opt ::= NOT INDEXED */
138796139078
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
138797139079
break;
138798
- case 117: /* using_opt ::= USING LP idlist RP */
139080
+ case 116: /* using_opt ::= USING LP idlist RP */
138799139081
{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
138800139082
break;
138801
- case 118: /* using_opt ::= */
138802
- case 146: /* idlist_opt ::= */ yytestcase(yyruleno==146);
139083
+ case 117: /* using_opt ::= */
139084
+ case 145: /* idlist_opt ::= */ yytestcase(yyruleno==145);
138803139085
{yymsp[1].minor.yy254 = 0;}
138804139086
break;
138805
- case 120: /* orderby_opt ::= ORDER BY sortlist */
138806
- case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
139087
+ case 119: /* orderby_opt ::= ORDER BY sortlist */
139088
+ case 126: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==126);
138807139089
{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
138808139090
break;
138809
- case 121: /* sortlist ::= sortlist COMMA expr sortorder */
139091
+ case 120: /* sortlist ::= sortlist COMMA expr sortorder */
138810139092
{
138811139093
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
138812139094
sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
138813139095
}
138814139096
break;
138815
- case 122: /* sortlist ::= expr sortorder */
139097
+ case 121: /* sortlist ::= expr sortorder */
138816139098
{
138817139099
yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
138818139100
sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
138819139101
}
138820139102
break;
138821
- case 123: /* sortorder ::= ASC */
139103
+ case 122: /* sortorder ::= ASC */
138822139104
{yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
138823139105
break;
138824
- case 124: /* sortorder ::= DESC */
139106
+ case 123: /* sortorder ::= DESC */
138825139107
{yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
138826139108
break;
138827
- case 125: /* sortorder ::= */
139109
+ case 124: /* sortorder ::= */
138828139110
{yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
138829139111
break;
138830
- case 130: /* limit_opt ::= */
139112
+ case 129: /* limit_opt ::= */
138831139113
{yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
138832139114
break;
138833
- case 131: /* limit_opt ::= LIMIT expr */
139115
+ case 130: /* limit_opt ::= LIMIT expr */
138834139116
{yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
138835139117
break;
138836
- case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
139118
+ case 131: /* limit_opt ::= LIMIT expr OFFSET expr */
138837139119
{yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
138838139120
break;
138839
- case 133: /* limit_opt ::= LIMIT expr COMMA expr */
139121
+ case 132: /* limit_opt ::= LIMIT expr COMMA expr */
138840139122
{yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
138841139123
break;
138842
- case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
139124
+ case 133: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
138843139125
{
138844139126
sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
138845139127
sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
138846139128
sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
138847139129
}
138848139130
break;
138849
- case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
139131
+ case 136: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
138850139132
{
138851139133
sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
138852139134
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
138853139135
sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
138854139136
sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
138855139137
}
138856139138
break;
138857
- case 138: /* setlist ::= setlist COMMA nm EQ expr */
139139
+ case 137: /* setlist ::= setlist COMMA nm EQ expr */
138858139140
{
138859139141
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
138860139142
sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
138861139143
}
138862139144
break;
138863
- case 139: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
139145
+ case 138: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
138864139146
{
138865139147
yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
138866139148
}
138867139149
break;
138868
- case 140: /* setlist ::= nm EQ expr */
139150
+ case 139: /* setlist ::= nm EQ expr */
138869139151
{
138870139152
yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
138871139153
sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
138872139154
}
138873139155
yymsp[-2].minor.yy148 = yylhsminor.yy148;
138874139156
break;
138875
- case 141: /* setlist ::= LP idlist RP EQ expr */
139157
+ case 140: /* setlist ::= LP idlist RP EQ expr */
138876139158
{
138877139159
yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
138878139160
}
138879139161
break;
138880
- case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
139162
+ case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
138881139163
{
138882139164
sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
138883139165
sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
138884139166
}
138885139167
break;
138886
- case 143: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
139168
+ case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
138887139169
{
138888139170
sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
138889139171
sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
138890139172
}
138891139173
break;
138892
- case 147: /* idlist_opt ::= LP idlist RP */
139174
+ case 146: /* idlist_opt ::= LP idlist RP */
138893139175
{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
138894139176
break;
138895
- case 148: /* idlist ::= idlist COMMA nm */
139177
+ case 147: /* idlist ::= idlist COMMA nm */
138896139178
{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
138897139179
break;
138898
- case 149: /* idlist ::= nm */
139180
+ case 148: /* idlist ::= nm */
138899139181
{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
138900139182
break;
138901
- case 150: /* expr ::= LP expr RP */
139183
+ case 149: /* expr ::= LP expr RP */
138902139184
{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
138903139185
break;
138904
- case 151: /* term ::= NULL */
138905
- case 156: /* term ::= FLOAT|BLOB */ yytestcase(yyruleno==156);
138906
- case 157: /* term ::= STRING */ yytestcase(yyruleno==157);
139186
+ case 150: /* term ::= NULL */
139187
+ case 155: /* term ::= FLOAT|BLOB */ yytestcase(yyruleno==155);
139188
+ case 156: /* term ::= STRING */ yytestcase(yyruleno==156);
138907139189
{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
138908139190
break;
138909
- case 152: /* expr ::= ID|INDEXED */
138910
- case 153: /* expr ::= JOIN_KW */ yytestcase(yyruleno==153);
139191
+ case 151: /* expr ::= ID|INDEXED */
139192
+ case 152: /* expr ::= JOIN_KW */ yytestcase(yyruleno==152);
138911139193
{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
138912139194
break;
138913
- case 154: /* expr ::= nm DOT nm */
139195
+ case 153: /* expr ::= nm DOT nm */
138914139196
{
138915139197
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138916139198
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
138917139199
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138918139200
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
138919139201
}
138920139202
break;
138921
- case 155: /* expr ::= nm DOT nm DOT nm */
139203
+ case 154: /* expr ::= nm DOT nm DOT nm */
138922139204
{
138923139205
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
138924139206
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138925139207
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
138926139208
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
138927139209
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138928139210
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
138929139211
}
138930139212
break;
138931
- case 158: /* term ::= INTEGER */
139213
+ case 157: /* term ::= INTEGER */
138932139214
{
138933139215
yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
138934139216
yylhsminor.yy190.zStart = yymsp[0].minor.yy0.z;
138935139217
yylhsminor.yy190.zEnd = yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n;
138936139218
if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf|EP_Resolved;
138937139219
}
138938139220
yymsp[0].minor.yy190 = yylhsminor.yy190;
138939139221
break;
138940
- case 159: /* expr ::= VARIABLE */
139222
+ case 158: /* expr ::= VARIABLE */
138941139223
{
138942139224
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
138943139225
u32 n = yymsp[0].minor.yy0.n;
138944139226
spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
138945139227
sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n);
@@ -138958,24 +139240,24 @@
138958139240
if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
138959139241
}
138960139242
}
138961139243
}
138962139244
break;
138963
- case 160: /* expr ::= expr COLLATE ID|STRING */
139245
+ case 159: /* expr ::= expr COLLATE ID|STRING */
138964139246
{
138965139247
yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
138966139248
yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
138967139249
}
138968139250
break;
138969
- case 161: /* expr ::= CAST LP expr AS typetoken RP */
139251
+ case 160: /* expr ::= CAST LP expr AS typetoken RP */
138970139252
{
138971139253
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138972139254
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
138973139255
sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, 0);
138974139256
}
138975139257
break;
138976
- case 162: /* expr ::= ID|INDEXED LP distinct exprlist RP */
139258
+ case 161: /* expr ::= ID|INDEXED LP distinct exprlist RP */
138977139259
{
138978139260
if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
138979139261
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
138980139262
}
138981139263
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -138984,25 +139266,25 @@
138984139266
yylhsminor.yy190.pExpr->flags |= EP_Distinct;
138985139267
}
138986139268
}
138987139269
yymsp[-4].minor.yy190 = yylhsminor.yy190;
138988139270
break;
138989
- case 163: /* expr ::= ID|INDEXED LP STAR RP */
139271
+ case 162: /* expr ::= ID|INDEXED LP STAR RP */
138990139272
{
138991139273
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
138992139274
spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
138993139275
}
138994139276
yymsp[-3].minor.yy190 = yylhsminor.yy190;
138995139277
break;
138996
- case 164: /* term ::= CTIME_KW */
139278
+ case 163: /* term ::= CTIME_KW */
138997139279
{
138998139280
yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
138999139281
spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
139000139282
}
139001139283
yymsp[0].minor.yy190 = yylhsminor.yy190;
139002139284
break;
139003
- case 165: /* expr ::= LP nexprlist COMMA expr RP */
139285
+ case 164: /* expr ::= LP nexprlist COMMA expr RP */
139004139286
{
139005139287
ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
139006139288
yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
139007139289
if( yylhsminor.yy190.pExpr ){
139008139290
yylhsminor.yy190.pExpr->x.pList = pList;
@@ -139011,24 +139293,24 @@
139011139293
sqlite3ExprListDelete(pParse->db, pList);
139012139294
}
139013139295
}
139014139296
yymsp[-4].minor.yy190 = yylhsminor.yy190;
139015139297
break;
139016
- case 166: /* expr ::= expr AND expr */
139017
- case 167: /* expr ::= expr OR expr */ yytestcase(yyruleno==167);
139018
- case 168: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==168);
139019
- case 169: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==169);
139020
- case 170: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==170);
139021
- case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
139022
- case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
139023
- case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
139298
+ case 165: /* expr ::= expr AND expr */
139299
+ case 166: /* expr ::= expr OR expr */ yytestcase(yyruleno==166);
139300
+ case 167: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==167);
139301
+ case 168: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==168);
139302
+ case 169: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==169);
139303
+ case 170: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==170);
139304
+ case 171: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==171);
139305
+ case 172: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==172);
139024139306
{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
139025139307
break;
139026
- case 174: /* likeop ::= NOT LIKE_KW|MATCH */
139308
+ case 173: /* likeop ::= NOT LIKE_KW|MATCH */
139027139309
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
139028139310
break;
139029
- case 175: /* expr ::= expr likeop expr */
139311
+ case 174: /* expr ::= expr likeop expr */
139030139312
{
139031139313
ExprList *pList;
139032139314
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
139033139315
yymsp[-1].minor.yy0.n &= 0x7fffffff;
139034139316
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -139037,11 +139319,11 @@
139037139319
exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
139038139320
yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139039139321
if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
139040139322
}
139041139323
break;
139042
- case 176: /* expr ::= expr likeop expr ESCAPE expr */
139324
+ case 175: /* expr ::= expr likeop expr ESCAPE expr */
139043139325
{
139044139326
ExprList *pList;
139045139327
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
139046139328
yymsp[-3].minor.yy0.n &= 0x7fffffff;
139047139329
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -139051,43 +139333,43 @@
139051139333
exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
139052139334
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139053139335
if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
139054139336
}
139055139337
break;
139056
- case 177: /* expr ::= expr ISNULL|NOTNULL */
139338
+ case 176: /* expr ::= expr ISNULL|NOTNULL */
139057139339
{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
139058139340
break;
139059
- case 178: /* expr ::= expr NOT NULL */
139341
+ case 177: /* expr ::= expr NOT NULL */
139060139342
{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
139061139343
break;
139062
- case 179: /* expr ::= expr IS expr */
139344
+ case 178: /* expr ::= expr IS expr */
139063139345
{
139064139346
spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
139065139347
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
139066139348
}
139067139349
break;
139068
- case 180: /* expr ::= expr IS NOT expr */
139350
+ case 179: /* expr ::= expr IS NOT expr */
139069139351
{
139070139352
spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
139071139353
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
139072139354
}
139073139355
break;
139074
- case 181: /* expr ::= NOT expr */
139075
- case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
139356
+ case 180: /* expr ::= NOT expr */
139357
+ case 181: /* expr ::= BITNOT expr */ yytestcase(yyruleno==181);
139076139358
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139077139359
break;
139078
- case 183: /* expr ::= MINUS expr */
139360
+ case 182: /* expr ::= MINUS expr */
139079139361
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139080139362
break;
139081
- case 184: /* expr ::= PLUS expr */
139363
+ case 183: /* expr ::= PLUS expr */
139082139364
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139083139365
break;
139084
- case 185: /* between_op ::= BETWEEN */
139085
- case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
139366
+ case 184: /* between_op ::= BETWEEN */
139367
+ case 187: /* in_op ::= IN */ yytestcase(yyruleno==187);
139086139368
{yymsp[0].minor.yy194 = 0;}
139087139369
break;
139088
- case 187: /* expr ::= expr between_op expr AND expr */
139370
+ case 186: /* expr ::= expr between_op expr AND expr */
139089139371
{
139090139372
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139091139373
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
139092139374
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
139093139375
if( yymsp[-4].minor.yy190.pExpr ){
@@ -139097,11 +139379,11 @@
139097139379
}
139098139380
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139099139381
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139100139382
}
139101139383
break;
139102
- case 190: /* expr ::= expr in_op LP exprlist RP */
139384
+ case 189: /* expr ::= expr in_op LP exprlist RP */
139103139385
{
139104139386
if( yymsp[-1].minor.yy148==0 ){
139105139387
/* Expressions of the form
139106139388
**
139107139389
** expr1 IN ()
@@ -139150,26 +139432,26 @@
139150139432
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139151139433
}
139152139434
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139153139435
}
139154139436
break;
139155
- case 191: /* expr ::= LP select RP */
139437
+ case 190: /* expr ::= LP select RP */
139156139438
{
139157139439
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139158139440
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
139159139441
sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139160139442
}
139161139443
break;
139162
- case 192: /* expr ::= expr in_op LP select RP */
139444
+ case 191: /* expr ::= expr in_op LP select RP */
139163139445
{
139164139446
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
139165139447
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139166139448
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139167139449
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139168139450
}
139169139451
break;
139170
- case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
139452
+ case 192: /* expr ::= expr in_op nm dbnm paren_exprlist */
139171139453
{
139172139454
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
139173139455
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
139174139456
if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
139175139457
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -139176,19 +139458,19 @@
139176139458
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
139177139459
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139178139460
yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
139179139461
}
139180139462
break;
139181
- case 194: /* expr ::= EXISTS LP select RP */
139463
+ case 193: /* expr ::= EXISTS LP select RP */
139182139464
{
139183139465
Expr *p;
139184139466
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139185139467
p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
139186139468
sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
139187139469
}
139188139470
break;
139189
- case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
139471
+ case 194: /* expr ::= CASE case_operand case_exprlist case_else END */
139190139472
{
139191139473
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
139192139474
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
139193139475
if( yymsp[-4].minor.yy190.pExpr ){
139194139476
yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -139197,332 +139479,332 @@
139197139479
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
139198139480
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
139199139481
}
139200139482
}
139201139483
break;
139202
- case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
139484
+ case 195: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
139203139485
{
139204139486
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
139205139487
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
139206139488
}
139207139489
break;
139208
- case 197: /* case_exprlist ::= WHEN expr THEN expr */
139490
+ case 196: /* case_exprlist ::= WHEN expr THEN expr */
139209139491
{
139210139492
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139211139493
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
139212139494
}
139213139495
break;
139214
- case 200: /* case_operand ::= expr */
139496
+ case 199: /* case_operand ::= expr */
139215139497
{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
139216139498
break;
139217
- case 203: /* nexprlist ::= nexprlist COMMA expr */
139499
+ case 202: /* nexprlist ::= nexprlist COMMA expr */
139218139500
{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
139219139501
break;
139220
- case 204: /* nexprlist ::= expr */
139502
+ case 203: /* nexprlist ::= expr */
139221139503
{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
139222139504
break;
139223
- case 206: /* paren_exprlist ::= LP exprlist RP */
139224
- case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
139505
+ case 205: /* paren_exprlist ::= LP exprlist RP */
139506
+ case 210: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==210);
139225139507
{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
139226139508
break;
139227
- case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
139509
+ case 206: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
139228139510
{
139229139511
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
139230139512
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139231139513
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139232139514
}
139233139515
break;
139234
- case 208: /* uniqueflag ::= UNIQUE */
139235
- case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
139516
+ case 207: /* uniqueflag ::= UNIQUE */
139517
+ case 247: /* raisetype ::= ABORT */ yytestcase(yyruleno==247);
139236139518
{yymsp[0].minor.yy194 = OE_Abort;}
139237139519
break;
139238
- case 209: /* uniqueflag ::= */
139520
+ case 208: /* uniqueflag ::= */
139239139521
{yymsp[1].minor.yy194 = OE_None;}
139240139522
break;
139241
- case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
139523
+ case 211: /* eidlist ::= eidlist COMMA nm collate sortorder */
139242139524
{
139243139525
yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
139244139526
}
139245139527
break;
139246
- case 213: /* eidlist ::= nm collate sortorder */
139528
+ case 212: /* eidlist ::= nm collate sortorder */
139247139529
{
139248139530
yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
139249139531
}
139250139532
break;
139251
- case 216: /* cmd ::= DROP INDEX ifexists fullname */
139533
+ case 215: /* cmd ::= DROP INDEX ifexists fullname */
139252139534
{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
139253139535
break;
139254
- case 217: /* cmd ::= VACUUM */
139536
+ case 216: /* cmd ::= VACUUM */
139255139537
{sqlite3Vacuum(pParse,0);}
139256139538
break;
139257
- case 218: /* cmd ::= VACUUM nm */
139539
+ case 217: /* cmd ::= VACUUM nm */
139258139540
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
139259139541
break;
139260
- case 219: /* cmd ::= PRAGMA nm dbnm */
139542
+ case 218: /* cmd ::= PRAGMA nm dbnm */
139261139543
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
139262139544
break;
139263
- case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
139545
+ case 219: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
139264139546
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
139265139547
break;
139266
- case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
139548
+ case 220: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
139267139549
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
139268139550
break;
139269
- case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
139551
+ case 221: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
139270139552
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
139271139553
break;
139272
- case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
139554
+ case 222: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
139273139555
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
139274139556
break;
139275
- case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
139557
+ case 225: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
139276139558
{
139277139559
Token all;
139278139560
all.z = yymsp[-3].minor.yy0.z;
139279139561
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
139280139562
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
139281139563
}
139282139564
break;
139283
- case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
139565
+ case 226: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
139284139566
{
139285139567
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139286139568
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139287139569
}
139288139570
break;
139289
- case 228: /* trigger_time ::= BEFORE|AFTER */
139571
+ case 227: /* trigger_time ::= BEFORE|AFTER */
139290139572
{ yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139291139573
break;
139292
- case 229: /* trigger_time ::= INSTEAD OF */
139574
+ case 228: /* trigger_time ::= INSTEAD OF */
139293139575
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
139294139576
break;
139295
- case 230: /* trigger_time ::= */
139577
+ case 229: /* trigger_time ::= */
139296139578
{ yymsp[1].minor.yy194 = TK_BEFORE; }
139297139579
break;
139298
- case 231: /* trigger_event ::= DELETE|INSERT */
139299
- case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
139580
+ case 230: /* trigger_event ::= DELETE|INSERT */
139581
+ case 231: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==231);
139300139582
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139301139583
break;
139302
- case 233: /* trigger_event ::= UPDATE OF idlist */
139584
+ case 232: /* trigger_event ::= UPDATE OF idlist */
139303139585
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139304139586
break;
139305
- case 234: /* when_clause ::= */
139306
- case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
139587
+ case 233: /* when_clause ::= */
139588
+ case 252: /* key_opt ::= */ yytestcase(yyruleno==252);
139307139589
{ yymsp[1].minor.yy72 = 0; }
139308139590
break;
139309
- case 235: /* when_clause ::= WHEN expr */
139310
- case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
139591
+ case 234: /* when_clause ::= WHEN expr */
139592
+ case 253: /* key_opt ::= KEY expr */ yytestcase(yyruleno==253);
139311139593
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139312139594
break;
139313
- case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139595
+ case 235: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139314139596
{
139315139597
assert( yymsp[-2].minor.yy145!=0 );
139316139598
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139317139599
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139318139600
}
139319139601
break;
139320
- case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
139602
+ case 236: /* trigger_cmd_list ::= trigger_cmd SEMI */
139321139603
{
139322139604
assert( yymsp[-1].minor.yy145!=0 );
139323139605
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139324139606
}
139325139607
break;
139326
- case 238: /* trnm ::= nm DOT nm */
139608
+ case 237: /* trnm ::= nm DOT nm */
139327139609
{
139328139610
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139329139611
sqlite3ErrorMsg(pParse,
139330139612
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139331139613
"statements within triggers");
139332139614
}
139333139615
break;
139334
- case 239: /* tridxby ::= INDEXED BY nm */
139616
+ case 238: /* tridxby ::= INDEXED BY nm */
139335139617
{
139336139618
sqlite3ErrorMsg(pParse,
139337139619
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139338139620
"within triggers");
139339139621
}
139340139622
break;
139341
- case 240: /* tridxby ::= NOT INDEXED */
139623
+ case 239: /* tridxby ::= NOT INDEXED */
139342139624
{
139343139625
sqlite3ErrorMsg(pParse,
139344139626
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139345139627
"within triggers");
139346139628
}
139347139629
break;
139348
- case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139630
+ case 240: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139349139631
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139350139632
break;
139351
- case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139633
+ case 241: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139352139634
{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139353139635
break;
139354
- case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139636
+ case 242: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139355139637
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139356139638
break;
139357
- case 244: /* trigger_cmd ::= select */
139639
+ case 243: /* trigger_cmd ::= select */
139358139640
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139359139641
break;
139360
- case 245: /* expr ::= RAISE LP IGNORE RP */
139642
+ case 244: /* expr ::= RAISE LP IGNORE RP */
139361139643
{
139362139644
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139363139645
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139364139646
if( yymsp[-3].minor.yy190.pExpr ){
139365139647
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139366139648
}
139367139649
}
139368139650
break;
139369
- case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
139651
+ case 245: /* expr ::= RAISE LP raisetype COMMA nm RP */
139370139652
{
139371139653
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139372139654
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139373139655
if( yymsp[-5].minor.yy190.pExpr ) {
139374139656
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139375139657
}
139376139658
}
139377139659
break;
139378
- case 247: /* raisetype ::= ROLLBACK */
139660
+ case 246: /* raisetype ::= ROLLBACK */
139379139661
{yymsp[0].minor.yy194 = OE_Rollback;}
139380139662
break;
139381
- case 249: /* raisetype ::= FAIL */
139663
+ case 248: /* raisetype ::= FAIL */
139382139664
{yymsp[0].minor.yy194 = OE_Fail;}
139383139665
break;
139384
- case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
139666
+ case 249: /* cmd ::= DROP TRIGGER ifexists fullname */
139385139667
{
139386139668
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139387139669
}
139388139670
break;
139389
- case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139671
+ case 250: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139390139672
{
139391139673
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139392139674
}
139393139675
break;
139394
- case 252: /* cmd ::= DETACH database_kw_opt expr */
139676
+ case 251: /* cmd ::= DETACH database_kw_opt expr */
139395139677
{
139396139678
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139397139679
}
139398139680
break;
139399
- case 255: /* cmd ::= REINDEX */
139681
+ case 254: /* cmd ::= REINDEX */
139400139682
{sqlite3Reindex(pParse, 0, 0);}
139401139683
break;
139402
- case 256: /* cmd ::= REINDEX nm dbnm */
139684
+ case 255: /* cmd ::= REINDEX nm dbnm */
139403139685
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139404139686
break;
139405
- case 257: /* cmd ::= ANALYZE */
139687
+ case 256: /* cmd ::= ANALYZE */
139406139688
{sqlite3Analyze(pParse, 0, 0);}
139407139689
break;
139408
- case 258: /* cmd ::= ANALYZE nm dbnm */
139690
+ case 257: /* cmd ::= ANALYZE nm dbnm */
139409139691
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139410139692
break;
139411
- case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139693
+ case 258: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139412139694
{
139413139695
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139414139696
}
139415139697
break;
139416
- case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139698
+ case 259: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139417139699
{
139418139700
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139419139701
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139420139702
}
139421139703
break;
139422
- case 261: /* add_column_fullname ::= fullname */
139704
+ case 260: /* add_column_fullname ::= fullname */
139423139705
{
139424139706
disableLookaside(pParse);
139425139707
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139426139708
}
139427139709
break;
139428
- case 262: /* cmd ::= create_vtab */
139710
+ case 261: /* cmd ::= create_vtab */
139429139711
{sqlite3VtabFinishParse(pParse,0);}
139430139712
break;
139431
- case 263: /* cmd ::= create_vtab LP vtabarglist RP */
139713
+ case 262: /* cmd ::= create_vtab LP vtabarglist RP */
139432139714
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139433139715
break;
139434
- case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139716
+ case 263: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139435139717
{
139436139718
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139437139719
}
139438139720
break;
139439
- case 265: /* vtabarg ::= */
139721
+ case 264: /* vtabarg ::= */
139440139722
{sqlite3VtabArgInit(pParse);}
139441139723
break;
139442
- case 266: /* vtabargtoken ::= ANY */
139443
- case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444
- case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
139724
+ case 265: /* vtabargtoken ::= ANY */
139725
+ case 266: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==266);
139726
+ case 267: /* lp ::= LP */ yytestcase(yyruleno==267);
139445139727
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139446139728
break;
139447
- case 269: /* with ::= */
139729
+ case 268: /* with ::= */
139448139730
{yymsp[1].minor.yy285 = 0;}
139449139731
break;
139450
- case 270: /* with ::= WITH wqlist */
139732
+ case 269: /* with ::= WITH wqlist */
139451139733
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139452139734
break;
139453
- case 271: /* with ::= WITH RECURSIVE wqlist */
139735
+ case 270: /* with ::= WITH RECURSIVE wqlist */
139454139736
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139455139737
break;
139456
- case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
139738
+ case 271: /* wqlist ::= nm eidlist_opt AS LP select RP */
139457139739
{
139458139740
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139459139741
}
139460139742
break;
139461
- case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139743
+ case 272: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139462139744
{
139463139745
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139464139746
}
139465139747
break;
139466139748
default:
139467
- /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468
- /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469
- /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470
- /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471
- /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472
- /* (279) explain ::= */ yytestcase(yyruleno==279);
139473
- /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474
- /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475
- /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476
- /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477
- /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478
- /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479
- /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480
- /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481
- /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482
- /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483
- /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484
- /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485
- /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486
- /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487
- /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488
- /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489
- /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490
- /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491
- /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492
- /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493
- /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494
- /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495
- /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496
- /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497
- /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498
- /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499
- /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500
- /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501
- /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502
- /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503
- /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504
- /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505
- /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506
- /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507
- /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508
- /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509
- /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510
- /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511
- /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512
- /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513
- /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514
- /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515
- /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516
- /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517
- /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518
- /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519
- /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520
- /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521
- /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522
- /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523
- /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
139749
+ /* (273) input ::= cmdlist */ yytestcase(yyruleno==273);
139750
+ /* (274) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==274);
139751
+ /* (275) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=275);
139752
+ /* (276) ecmd ::= SEMI */ yytestcase(yyruleno==276);
139753
+ /* (277) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==277);
139754
+ /* (278) explain ::= */ yytestcase(yyruleno==278);
139755
+ /* (279) trans_opt ::= */ yytestcase(yyruleno==279);
139756
+ /* (280) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==280);
139757
+ /* (281) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==281);
139758
+ /* (282) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==282);
139759
+ /* (283) savepoint_opt ::= */ yytestcase(yyruleno==283);
139760
+ /* (284) cmd ::= create_table create_table_args */ yytestcase(yyruleno==284);
139761
+ /* (285) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==285);
139762
+ /* (286) columnlist ::= columnname carglist */ yytestcase(yyruleno==286);
139763
+ /* (287) nm ::= ID|INDEXED */ yytestcase(yyruleno==287);
139764
+ /* (288) nm ::= STRING */ yytestcase(yyruleno==288);
139765
+ /* (289) nm ::= JOIN_KW */ yytestcase(yyruleno==289);
139766
+ /* (290) typetoken ::= typename */ yytestcase(yyruleno==290);
139767
+ /* (291) typename ::= ID|STRING */ yytestcase(yyruleno==291);
139768
+ /* (292) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
139769
+ /* (293) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139770
+ /* (294) carglist ::= carglist ccons */ yytestcase(yyruleno==294);
139771
+ /* (295) carglist ::= */ yytestcase(yyruleno==295);
139772
+ /* (296) ccons ::= NULL onconf */ yytestcase(yyruleno==296);
139773
+ /* (297) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==297);
139774
+ /* (298) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==298);
139775
+ /* (299) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=299);
139776
+ /* (300) tconscomma ::= */ yytestcase(yyruleno==300);
139777
+ /* (301) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=301);
139778
+ /* (302) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=302);
139779
+ /* (303) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=303);
139780
+ /* (304) oneselect ::= values */ yytestcase(yyruleno==304);
139781
+ /* (305) sclp ::= selcollist COMMA */ yytestcase(yyruleno==305);
139782
+ /* (306) as ::= ID|STRING */ yytestcase(yyruleno==306);
139783
+ /* (307) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=307);
139784
+ /* (308) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==308);
139785
+ /* (309) exprlist ::= nexprlist */ yytestcase(yyruleno==309);
139786
+ /* (310) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=310);
139787
+ /* (311) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=311);
139788
+ /* (312) nmnum ::= ON */ yytestcase(yyruleno==312);
139789
+ /* (313) nmnum ::= DELETE */ yytestcase(yyruleno==313);
139790
+ /* (314) nmnum ::= DEFAULT */ yytestcase(yyruleno==314);
139791
+ /* (315) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==315);
139792
+ /* (316) foreach_clause ::= */ yytestcase(yyruleno==316);
139793
+ /* (317) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==317);
139794
+ /* (318) trnm ::= nm */ yytestcase(yyruleno==318);
139795
+ /* (319) tridxby ::= */ yytestcase(yyruleno==319);
139796
+ /* (320) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==320);
139797
+ /* (321) database_kw_opt ::= */ yytestcase(yyruleno==321);
139798
+ /* (322) kwcolumn_opt ::= */ yytestcase(yyruleno==322);
139799
+ /* (323) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==323);
139800
+ /* (324) vtabarglist ::= vtabarg */ yytestcase(yyruleno==324);
139801
+ /* (325) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==325);
139802
+ /* (326) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==326);
139803
+ /* (327) anylist ::= */ yytestcase(yyruleno==327);
139804
+ /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
139805
+ /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);
139524139806
break;
139525139807
/********** End reduce actions ************************************************/
139526139808
};
139527139809
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139528139810
yygoto = yyRuleInfo[yyruleno].lhs;
@@ -139948,138 +140230,149 @@
139948140230
** But by using this automatically generated code, the size of the code
139949140231
** is substantially reduced. This is important for embedded applications
139950140232
** on platforms with limited memory.
139951140233
*/
139952140234
/* Hash score: 182 */
139953
-static int keywordCode(const char *z, int n, int *pType){
139954
- /* zText[] encodes 834 bytes of keywords in 554 bytes */
139955
- /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
139956
- /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
139957
- /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
139958
- /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
139959
- /* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
139960
- /* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
139961
- /* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
139962
- /* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
139963
- /* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
139964
- /* VACUUMVIEWINITIALLY */
139965
- static const char zText[553] = {
139966
- 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
139967
- 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
139968
- 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
139969
- 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
139970
- 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
139971
- 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
139972
- 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
139973
- 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
139974
- 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
139975
- 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
139976
- 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
139977
- 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
139978
- 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
139979
- 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
139980
- 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
139981
- 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
139982
- 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
139983
- 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
139984
- 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
139985
- 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
139986
- 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
139987
- 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
139988
- 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
139989
- 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
139990
- 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
139991
- 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
139992
- 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
139993
- 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
139994
- 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
139995
- 'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
139996
- 'V','I','E','W','I','N','I','T','I','A','L','L','Y',
139997
- };
139998
- static const unsigned char aHash[127] = {
139999
- 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
140000
- 42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
140001
- 121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
140002
- 0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
140003
- 0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
140004
- 96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
140005
- 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
140006
- 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
140007
- 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
140008
- 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
140009
- };
140010
- static const unsigned char aNext[124] = {
140011
- 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
140012
- 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
140013
- 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140014
- 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
140015
- 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
140016
- 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
140017
- 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
140018
- 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
140019
- 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
140020
- 73, 83, 0, 35, 68, 0, 0,
140021
- };
140022
- static const unsigned char aLen[124] = {
140023
- 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
140024
- 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
140025
- 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
140026
- 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
140027
- 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
140028
- 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
140029
- 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
140030
- 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
140031
- 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
140032
- 3, 5, 5, 6, 4, 9, 3,
140033
- };
140034
- static const unsigned short int aOffset[124] = {
140035
- 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
140036
- 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
140037
- 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
140038
- 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
140039
- 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
140040
- 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
140041
- 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
140042
- 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
140043
- 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
140044
- 521, 524, 529, 534, 540, 544, 549,
140045
- };
140046
- static const unsigned char aCode[124] = {
140047
- TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
140048
- TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
140049
- TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
140050
- TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
140051
- TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
140052
- TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
140053
- TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
140054
- TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
140055
- TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
140056
- TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
140057
- TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
140058
- TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
140059
- TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
140060
- TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
140061
- TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
140062
- TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
140063
- TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
140064
- TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
140065
- TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
140066
- TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
140067
- TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
140068
- TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
140069
- TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
140070
- TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
140071
- TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
140072
- };
140235
+/* zKWText[] encodes 834 bytes of keyword text in 554 bytes */
140236
+/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
140237
+/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
140238
+/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
140239
+/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
140240
+/* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
140241
+/* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
140242
+/* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
140243
+/* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
140244
+/* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
140245
+/* VACUUMVIEWINITIALLY */
140246
+static const char zKWText[553] = {
140247
+ 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
140248
+ 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
140249
+ 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
140250
+ 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
140251
+ 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
140252
+ 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
140253
+ 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
140254
+ 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
140255
+ 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
140256
+ 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
140257
+ 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
140258
+ 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
140259
+ 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
140260
+ 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
140261
+ 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
140262
+ 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
140263
+ 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
140264
+ 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
140265
+ 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
140266
+ 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
140267
+ 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
140268
+ 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
140269
+ 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
140270
+ 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
140271
+ 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
140272
+ 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
140273
+ 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
140274
+ 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
140275
+ 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
140276
+ 'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
140277
+ 'V','I','E','W','I','N','I','T','I','A','L','L','Y',
140278
+};
140279
+/* aKWHash[i] is the hash value for the i-th keyword */
140280
+static const unsigned char aKWHash[127] = {
140281
+ 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
140282
+ 42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
140283
+ 121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
140284
+ 0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
140285
+ 0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
140286
+ 96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
140287
+ 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
140288
+ 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
140289
+ 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
140290
+ 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
140291
+};
140292
+/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
140293
+** then the i-th keyword has no more hash collisions. Otherwise,
140294
+** the next keyword with the same hash is aKWHash[i]-1. */
140295
+static const unsigned char aKWNext[124] = {
140296
+ 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
140297
+ 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
140298
+ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140299
+ 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
140300
+ 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
140301
+ 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
140302
+ 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
140303
+ 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
140304
+ 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
140305
+ 73, 83, 0, 35, 68, 0, 0,
140306
+};
140307
+/* aKWLen[i] is the length (in bytes) of the i-th keyword */
140308
+static const unsigned char aKWLen[124] = {
140309
+ 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
140310
+ 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
140311
+ 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
140312
+ 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
140313
+ 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
140314
+ 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
140315
+ 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
140316
+ 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
140317
+ 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
140318
+ 3, 5, 5, 6, 4, 9, 3,
140319
+};
140320
+/* aKWOffset[i] is the index into zKWText[] of the start of
140321
+** the text for the i-th keyword. */
140322
+static const unsigned short int aKWOffset[124] = {
140323
+ 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
140324
+ 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
140325
+ 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
140326
+ 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
140327
+ 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
140328
+ 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
140329
+ 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
140330
+ 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
140331
+ 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
140332
+ 521, 524, 529, 534, 540, 544, 549,
140333
+};
140334
+/* aKWCode[i] is the parser symbol code for the i-th keyword */
140335
+static const unsigned char aKWCode[124] = {
140336
+ TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
140337
+ TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
140338
+ TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
140339
+ TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
140340
+ TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
140341
+ TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
140342
+ TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
140343
+ TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
140344
+ TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
140345
+ TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
140346
+ TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
140347
+ TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
140348
+ TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
140349
+ TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
140350
+ TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
140351
+ TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
140352
+ TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
140353
+ TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
140354
+ TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
140355
+ TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
140356
+ TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
140357
+ TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
140358
+ TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
140359
+ TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
140360
+ TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
140361
+};
140362
+/* Check to see if z[0..n-1] is a keyword. If it is, write the
140363
+** parser symbol code for that keyword into *pType. Always
140364
+** return the integer n (the length of the token). */
140365
+static int keywordCode(const char *z, int n, int *pType){
140073140366
int i, j;
140074140367
const char *zKW;
140075140368
if( n>=2 ){
140076140369
i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127;
140077
- for(i=((int)aHash[i])-1; i>=0; i=((int)aNext[i])-1){
140078
- if( aLen[i]!=n ) continue;
140370
+ for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){
140371
+ if( aKWLen[i]!=n ) continue;
140079140372
j = 0;
140080
- zKW = &zText[aOffset[i]];
140373
+ zKW = &zKWText[aKWOffset[i]];
140081140374
#ifdef SQLITE_ASCII
140082140375
while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }
140083140376
#endif
140084140377
#ifdef SQLITE_EBCDIC
140085140378
while( j<n && toupper(z[j])==zKW[j] ){ j++; }
@@ -140207,11 +140500,11 @@
140207140500
testcase( i==119 ); /* USING */
140208140501
testcase( i==120 ); /* VACUUM */
140209140502
testcase( i==121 ); /* VIEW */
140210140503
testcase( i==122 ); /* INITIALLY */
140211140504
testcase( i==123 ); /* ALL */
140212
- *pType = aCode[i];
140505
+ *pType = aKWCode[i];
140213140506
break;
140214140507
}
140215140508
}
140216140509
return n;
140217140510
}
@@ -142486,14 +142779,14 @@
142486142779
** argument.
142487142780
*/
142488142781
SQLITE_PRIVATE const char *sqlite3ErrStr(int rc){
142489142782
static const char* const aMsg[] = {
142490142783
/* SQLITE_OK */ "not an error",
142491
- /* SQLITE_ERROR */ "SQL logic error or missing database",
142784
+ /* SQLITE_ERROR */ "SQL logic error",
142492142785
/* SQLITE_INTERNAL */ 0,
142493142786
/* SQLITE_PERM */ "access permission denied",
142494
- /* SQLITE_ABORT */ "callback requested query abort",
142787
+ /* SQLITE_ABORT */ "query aborted",
142495142788
/* SQLITE_BUSY */ "database is locked",
142496142789
/* SQLITE_LOCKED */ "database table is locked",
142497142790
/* SQLITE_NOMEM */ "out of memory",
142498142791
/* SQLITE_READONLY */ "attempt to write a readonly database",
142499142792
/* SQLITE_INTERRUPT */ "interrupted",
@@ -142501,21 +142794,25 @@
142501142794
/* SQLITE_CORRUPT */ "database disk image is malformed",
142502142795
/* SQLITE_NOTFOUND */ "unknown operation",
142503142796
/* SQLITE_FULL */ "database or disk is full",
142504142797
/* SQLITE_CANTOPEN */ "unable to open database file",
142505142798
/* SQLITE_PROTOCOL */ "locking protocol",
142506
- /* SQLITE_EMPTY */ "table contains no data",
142799
+ /* SQLITE_EMPTY */ 0,
142507142800
/* SQLITE_SCHEMA */ "database schema has changed",
142508142801
/* SQLITE_TOOBIG */ "string or blob too big",
142509142802
/* SQLITE_CONSTRAINT */ "constraint failed",
142510142803
/* SQLITE_MISMATCH */ "datatype mismatch",
142511
- /* SQLITE_MISUSE */ "library routine called out of sequence",
142804
+ /* SQLITE_MISUSE */ "bad parameter or other API misuse",
142805
+#ifdef SQLITE_DISABLE_LFS
142512142806
/* SQLITE_NOLFS */ "large file support is disabled",
142807
+#else
142808
+ /* SQLITE_NOLFS */ 0,
142809
+#endif
142513142810
/* SQLITE_AUTH */ "authorization denied",
142514
- /* SQLITE_FORMAT */ "auxiliary database format error",
142515
- /* SQLITE_RANGE */ "bind or column index out of range",
142516
- /* SQLITE_NOTADB */ "file is encrypted or is not a database",
142811
+ /* SQLITE_FORMAT */ 0,
142812
+ /* SQLITE_RANGE */ "column index out of range",
142813
+ /* SQLITE_NOTADB */ "file is not a database",
142517142814
};
142518142815
const char *zErr = "unknown error";
142519142816
switch( rc ){
142520142817
case SQLITE_ABORT_ROLLBACK: {
142521142818
zErr = "abort due to ROLLBACK";
@@ -143351,16 +143648,13 @@
143351143648
SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
143352143649
static const u16 outOfMem[] = {
143353143650
'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
143354143651
};
143355143652
static const u16 misuse[] = {
143356
- 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
143357
- 'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
143358
- 'c', 'a', 'l', 'l', 'e', 'd', ' ',
143359
- 'o', 'u', 't', ' ',
143360
- 'o', 'f', ' ',
143361
- 's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
143653
+ 'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ',
143654
+ 'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ',
143655
+ 'm', 'i', 's', 'u', 's', 'e', 0
143362143656
};
143363143657
143364143658
const void *z;
143365143659
if( !db ){
143366143660
return (void *)outOfMem;
@@ -143891,30 +144185,10 @@
143891144185
#ifndef SQLITE_OMIT_AUTOINIT
143892144186
rc = sqlite3_initialize();
143893144187
if( rc ) return rc;
143894144188
#endif
143895144189
143896
- /* Only allow sensible combinations of bits in the flags argument.
143897
- ** Throw an error if any non-sense combination is used. If we
143898
- ** do not block illegal combinations here, it could trigger
143899
- ** assert() statements in deeper layers. Sensible combinations
143900
- ** are:
143901
- **
143902
- ** 1: SQLITE_OPEN_READONLY
143903
- ** 2: SQLITE_OPEN_READWRITE
143904
- ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
143905
- */
143906
- assert( SQLITE_OPEN_READONLY == 0x01 );
143907
- assert( SQLITE_OPEN_READWRITE == 0x02 );
143908
- assert( SQLITE_OPEN_CREATE == 0x04 );
143909
- testcase( (1<<(flags&7))==0x02 ); /* READONLY */
143910
- testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
143911
- testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
143912
- if( ((1<<(flags&7)) & 0x46)==0 ){
143913
- return SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
143914
- }
143915
-
143916144190
if( sqlite3GlobalConfig.bCoreMutex==0 ){
143917144191
isThreadsafe = 0;
143918144192
}else if( flags & SQLITE_OPEN_NOMUTEX ){
143919144193
isThreadsafe = 0;
143920144194
}else if( flags & SQLITE_OPEN_FULLMUTEX ){
@@ -144032,13 +144306,34 @@
144032144306
** strings is BINARY.
144033144307
*/
144034144308
db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);
144035144309
assert( db->pDfltColl!=0 );
144036144310
144037
- /* Parse the filename/URI argument. */
144311
+ /* Parse the filename/URI argument
144312
+ **
144313
+ ** Only allow sensible combinations of bits in the flags argument.
144314
+ ** Throw an error if any non-sense combination is used. If we
144315
+ ** do not block illegal combinations here, it could trigger
144316
+ ** assert() statements in deeper layers. Sensible combinations
144317
+ ** are:
144318
+ **
144319
+ ** 1: SQLITE_OPEN_READONLY
144320
+ ** 2: SQLITE_OPEN_READWRITE
144321
+ ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
144322
+ */
144038144323
db->openFlags = flags;
144039
- rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
144324
+ assert( SQLITE_OPEN_READONLY == 0x01 );
144325
+ assert( SQLITE_OPEN_READWRITE == 0x02 );
144326
+ assert( SQLITE_OPEN_CREATE == 0x04 );
144327
+ testcase( (1<<(flags&7))==0x02 ); /* READONLY */
144328
+ testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
144329
+ testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
144330
+ if( ((1<<(flags&7)) & 0x46)==0 ){
144331
+ rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
144332
+ }else{
144333
+ rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
144334
+ }
144040144335
if( rc!=SQLITE_OK ){
144041144336
if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
144042144337
sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
144043144338
sqlite3_free(zErrMsg);
144044144339
goto opendb_out;
@@ -148199,23 +148494,32 @@
148199148494
}
148200148495
pCsr->bSeekStmt = 0;
148201148496
}
148202148497
sqlite3_finalize(pCsr->pStmt);
148203148498
}
148499
+
148500
+/*
148501
+** Free all resources currently held by the cursor passed as the only
148502
+** argument.
148503
+*/
148504
+static void fts3ClearCursor(Fts3Cursor *pCsr){
148505
+ fts3CursorFinalizeStmt(pCsr);
148506
+ sqlite3Fts3FreeDeferredTokens(pCsr);
148507
+ sqlite3_free(pCsr->aDoclist);
148508
+ sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
148509
+ sqlite3Fts3ExprFree(pCsr->pExpr);
148510
+ memset(&(&pCsr->base)[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
148511
+}
148204148512
148205148513
/*
148206148514
** Close the cursor. For additional information see the documentation
148207148515
** on the xClose method of the virtual table interface.
148208148516
*/
148209148517
static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){
148210148518
Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
148211148519
assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148212
- fts3CursorFinalizeStmt(pCsr);
148213
- sqlite3Fts3ExprFree(pCsr->pExpr);
148214
- sqlite3Fts3FreeDeferredTokens(pCsr);
148215
- sqlite3_free(pCsr->aDoclist);
148216
- sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
148520
+ fts3ClearCursor(pCsr);
148217148521
assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148218148522
sqlite3_free(pCsr);
148219148523
return SQLITE_OK;
148220148524
}
148221148525
@@ -149712,15 +150016,11 @@
149712150016
if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];
149713150017
if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];
149714150018
assert( iIdx==nVal );
149715150019
149716150020
/* In case the cursor has been used before, clear it now. */
149717
- fts3CursorFinalizeStmt(pCsr);
149718
- sqlite3_free(pCsr->aDoclist);
149719
- sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
149720
- sqlite3Fts3ExprFree(pCsr->pExpr);
149721
- memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
150021
+ fts3ClearCursor(pCsr);
149722150022
149723150023
/* Set the lower and upper bounds on docids to return */
149724150024
pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);
149725150025
pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);
149726150026
@@ -149795,11 +150095,16 @@
149795150095
/*
149796150096
** This is the xEof method of the virtual table. SQLite calls this
149797150097
** routine to find out if it has reached the end of a result set.
149798150098
*/
149799150099
static int fts3EofMethod(sqlite3_vtab_cursor *pCursor){
149800
- return ((Fts3Cursor *)pCursor)->isEof;
150100
+ Fts3Cursor *pCsr = (Fts3Cursor*)pCursor;
150101
+ if( pCsr->isEof ){
150102
+ fts3ClearCursor(pCsr);
150103
+ pCsr->isEof = 1;
150104
+ }
150105
+ return pCsr->isEof;
149801150106
}
149802150107
149803150108
/*
149804150109
** This is the xRowid method. The SQLite core calls this routine to
149805150110
** retrieve the rowid for the current row of the result set. fts3
@@ -168168,10 +168473,14 @@
168168168473
pRtree->zDb, pRtree->zName
168169168474
);
168170168475
rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);
168171168476
if( rc!=SQLITE_OK ){
168172168477
*pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
168478
+ }else if( pRtree->iNodeSize<(512-64) ){
168479
+ rc = SQLITE_CORRUPT;
168480
+ *pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"",
168481
+ pRtree->zName);
168173168482
}
168174168483
}
168175168484
168176168485
sqlite3_free(zSql);
168177168486
return rc;
@@ -184399,11 +184708,13 @@
184399184708
pParser->fts5yyerrcnt = -1;
184400184709
#endif
184401184710
pParser->fts5yytos = pParser->fts5yystack;
184402184711
pParser->fts5yystack[0].stateno = 0;
184403184712
pParser->fts5yystack[0].major = 0;
184713
+#if fts5YYSTACKDEPTH>0
184404184714
pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184715
+#endif
184405184716
}
184406184717
184407184718
#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184408184719
/*
184409184720
** This function allocates a new parser.
@@ -199766,11 +200077,11 @@
199766200077
int nArg, /* Number of args */
199767200078
sqlite3_value **apUnused /* Function arguments */
199768200079
){
199769200080
assert( nArg==0 );
199770200081
UNUSED_PARAM2(nArg, apUnused);
199771
- sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
200082
+ sqlite3_result_text(pCtx, "fts5: 2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40", -1, SQLITE_TRANSIENT);
199772200083
}
199773200084
199774200085
static int fts5Init(sqlite3 *db){
199775200086
static const sqlite3_module fts5Mod = {
199776200087
/* iVersion */ 2,
@@ -203694,20 +204005,20 @@
203694204005
sqlite3_int64 iRowid; /* The rowid */
203695204006
};
203696204007
203697204008
/*
203698204009
** The stmtConnect() method is invoked to create a new
203699
-** stmt_vtab that describes the generate_stmt virtual table.
204010
+** stmt_vtab that describes the stmt virtual table.
203700204011
**
203701204012
** Think of this routine as the constructor for stmt_vtab objects.
203702204013
**
203703204014
** All this routine needs to do is:
203704204015
**
203705204016
** (1) Allocate the stmt_vtab object and initialize all fields.
203706204017
**
203707204018
** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708
-** result set of queries against generate_stmt will look like.
204019
+** result set of queries against stmt will look like.
203709204020
*/
203710204021
static int stmtConnect(
203711204022
sqlite3 *db,
203712204023
void *pAux,
203713204024
int argc, const char *const*argv,
@@ -203871,11 +204182,11 @@
203871204182
return stmtNext(pVtabCursor);
203872204183
}
203873204184
203874204185
/*
203875204186
** SQLite will invoke this method one or more times while planning a query
203876
-** that uses the generate_stmt virtual table. This routine needs to create
204187
+** that uses the stmt virtual table. This routine needs to create
203877204188
** a query plan for each invocation and compute an estimated cost for that
203878204189
** plan.
203879204190
*/
203880204191
static int stmtBestIndex(
203881204192
sqlite3_vtab *tab,
@@ -203886,11 +204197,11 @@
203886204197
return SQLITE_OK;
203887204198
}
203888204199
203889204200
/*
203890204201
** This following structure defines all the methods for the
203891
-** generate_stmt virtual table.
204202
+** stmt virtual table.
203892204203
*/
203893204204
static sqlite3_module stmtModule = {
203894204205
0, /* iVersion */
203895204206
0, /* xCreate */
203896204207
stmtConnect, /* xConnect */
203897204208
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1444,11 +1444,11 @@
1444 **
1445 ** See also: [extended result code definitions]
1446 */
1447 #define SQLITE_OK 0 /* Successful result */
1448 /* beginning-of-error-codes */
1449 #define SQLITE_ERROR 1 /* SQL error or missing database */
1450 #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
1451 #define SQLITE_PERM 3 /* Access permission denied */
1452 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
1453 #define SQLITE_BUSY 5 /* The database file is locked */
1454 #define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -1459,19 +1459,19 @@
1459 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
1460 #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
1461 #define SQLITE_FULL 13 /* Insertion failed because database is full */
1462 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
1463 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
1464 #define SQLITE_EMPTY 16 /* Database is empty */
1465 #define SQLITE_SCHEMA 17 /* The database schema changed */
1466 #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
1467 #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
1468 #define SQLITE_MISMATCH 20 /* Data type mismatch */
1469 #define SQLITE_MISUSE 21 /* Library used incorrectly */
1470 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
1471 #define SQLITE_AUTH 23 /* Authorization denied */
1472 #define SQLITE_FORMAT 24 /* Auxiliary database format error */
1473 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
1474 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
1475 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
1476 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
1477 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -5294,10 +5294,32 @@
5294
5295 /*
5296 ** CAPI3REF: Result Values From A Query
5297 ** KEYWORDS: {column access functions}
5298 ** METHOD: sqlite3_stmt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5299 **
5300 ** ^These routines return information about a single column of the current
5301 ** result row of a query. ^In every case the first argument is a pointer
5302 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5303 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -5316,19 +5338,32 @@
5316 ** something other than [SQLITE_ROW], the results are undefined.
5317 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
5318 ** are called from a different thread while any of these routines
5319 ** are pending, then the results are undefined.
5320 **
 
 
 
 
 
 
5321 ** ^The sqlite3_column_type() routine returns the
5322 ** [SQLITE_INTEGER | datatype code] for the initial data type
5323 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
5324 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
5325 ** returned by sqlite3_column_type() is only meaningful if no type
5326 ** conversions have occurred as described below. After a type conversion,
5327 ** the value returned by sqlite3_column_type() is undefined. Future
 
 
 
5328 ** versions of SQLite may change the behavior of sqlite3_column_type()
5329 ** following a type conversion.
 
 
 
 
5330 **
5331 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
5332 ** routine returns the number of bytes in that BLOB or string.
5333 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
5334 ** the string to UTF-8 and then returns the number of bytes.
@@ -5362,13 +5397,17 @@
5362 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
5363 ** If the [unprotected sqlite3_value] object returned by
5364 ** [sqlite3_column_value()] is used in any other way, including calls
5365 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
5366 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
 
 
 
 
5367 **
5368 ** These routines attempt to convert the value where appropriate. ^For
5369 ** example, if the internal representation is FLOAT and a text result
5370 ** is requested, [sqlite3_snprintf()] is used internally to perform the
5371 ** conversion automatically. ^(The following table details the conversions
5372 ** that are applied:
5373 **
5374 ** <blockquote>
@@ -5436,11 +5475,11 @@
5436 ** with calls to sqlite3_column_bytes().
5437 **
5438 ** ^The pointers returned are valid until a type conversion occurs as
5439 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
5440 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
5441 ** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
5442 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
5443 ** [sqlite3_free()].
5444 **
5445 ** ^(If a memory allocation error occurs during the evaluation of any
5446 ** of these routines, a default value is returned. The default value
@@ -5447,19 +5486,19 @@
5447 ** is either the integer 0, the floating point number 0.0, or a NULL
5448 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
5449 ** [SQLITE_NOMEM].)^
5450 */
5451 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
5452 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
5453 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
5454 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
5455 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
5456 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
5457 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
5458 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
5459 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
5460 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 
 
 
5461
5462 /*
5463 ** CAPI3REF: Destroy A Prepared Statement Object
5464 ** DESTRUCTOR: sqlite3_stmt
5465 **
@@ -5689,25 +5728,43 @@
5689
5690 /*
5691 ** CAPI3REF: Obtaining SQL Values
5692 ** METHOD: sqlite3_value
5693 **
5694 ** The C-language implementation of SQL functions and aggregates uses
5695 ** this set of interface routines to access the parameter values on
5696 ** the function or aggregate.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5697 **
5698 ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
5699 ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
5700 ** define callbacks that implement the SQL functions and aggregates.
5701 ** The 3rd parameter to these callbacks is an array of pointers to
5702 ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
5703 ** each parameter to the SQL function. These routines are used to
5704 ** extract values from the [sqlite3_value] objects.
5705 **
5706 ** These routines work only with [protected sqlite3_value] objects.
5707 ** Any attempt to use these routines on an [unprotected sqlite3_value]
5708 ** object results in undefined behavior.
5709 **
5710 ** ^These routines work just like the corresponding [column access functions]
5711 ** except that these routines take a single [protected sqlite3_value] object
5712 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
5713 **
@@ -5714,10 +5771,21 @@
5714 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
5715 ** in the native byte-order of the host machine. ^The
5716 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
5717 ** extract UTF-16 strings as big-endian and little-endian respectively.
5718 **
 
 
 
 
 
 
 
 
 
 
 
5719 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
5720 ** numeric affinity to the value. This means that an attempt is
5721 ** made to convert the value to an integer or floating point. If
5722 ** such a conversion is possible without loss of information (in other
5723 ** words, if the value is a string that looks like a number)
@@ -5732,19 +5800,19 @@
5732 **
5733 ** These routines must be called from the same thread as
5734 ** the SQL function that supplied the [sqlite3_value*] parameters.
5735 */
5736 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5737 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5738 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
5739 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5740 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5741 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5742 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5743 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5744 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5745 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
 
 
5746 SQLITE_API int sqlite3_value_type(sqlite3_value*);
5747 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5748
5749 /*
5750 ** CAPI3REF: Finding The Subtype Of SQL Values
@@ -15143,10 +15211,11 @@
15143 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
15144 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
15145 #define SQLITE_Transitive 0x0200 /* Transitive constraints */
15146 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
15147 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
 
15148 #define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */
15149 #define SQLITE_AllOpts 0xffff /* All optimizations */
15150
15151 /*
15152 ** Macros for testing whether or not optimizations are enabled or disabled.
@@ -17437,12 +17506,11 @@
17437 #endif
17438 SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);
17439 SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);
17440 SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
17441 SQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);
17442 SQLITE_PRIVATE void sqlite3CommitTransaction(Parse*);
17443 SQLITE_PRIVATE void sqlite3RollbackTransaction(Parse*);
17444 SQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);
17445 SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);
17446 SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
17447 SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
17448 SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
@@ -26962,21 +27030,21 @@
26962 }
26963 break;
26964 }
26965 #ifndef SQLITE_OMIT_SUBQUERY
26966 case TK_EXISTS: {
26967 sqlite3TreeViewLine(pView, "EXISTS-expr");
26968 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26969 break;
26970 }
26971 case TK_SELECT: {
26972 sqlite3TreeViewLine(pView, "SELECT-expr");
26973 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26974 break;
26975 }
26976 case TK_IN: {
26977 sqlite3TreeViewLine(pView, "IN");
26978 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
26979 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
26980 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
26981 }else{
26982 sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
@@ -29771,21 +29839,23 @@
29771 }
29772 return 1;
29773 }
29774
29775 /* This function (for internal use only) locates an element in an
29776 ** hash table that matches the given key. The hash for this key is
29777 ** also computed and returned in the *pH parameter.
 
29778 */
29779 static HashElem *findElementWithHash(
29780 const Hash *pH, /* The pH to be searched */
29781 const char *pKey, /* The key we are searching for */
29782 unsigned int *pHash /* Write the hash value here */
29783 ){
29784 HashElem *elem; /* Used to loop thru the element list */
29785 int count; /* Number of elements left to test */
29786 unsigned int h; /* The computed hash */
 
29787
29788 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
29789 struct _ht *pEntry;
29790 h = strHash(pKey) % pH->htsize;
29791 pEntry = &pH->ht[h];
@@ -29794,19 +29864,19 @@
29794 }else{
29795 h = 0;
29796 elem = pH->first;
29797 count = pH->count;
29798 }
29799 *pHash = h;
29800 while( count-- ){
29801 assert( elem!=0 );
29802 if( sqlite3StrICmp(elem->pKey,pKey)==0 ){
29803 return elem;
29804 }
29805 elem = elem->next;
29806 }
29807 return 0;
29808 }
29809
29810 /* Remove a single entry from the hash table given a pointer to that
29811 ** element and a hash on the element's key.
29812 */
@@ -29844,17 +29914,13 @@
29844 /* Attempt to locate an element of the hash table pH with a key
29845 ** that matches pKey. Return the data for this element if it is
29846 ** found, or NULL if there is no match.
29847 */
29848 SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
29849 HashElem *elem; /* The element that matches key */
29850 unsigned int h; /* A hash on key */
29851
29852 assert( pH!=0 );
29853 assert( pKey!=0 );
29854 elem = findElementWithHash(pH, pKey, &h);
29855 return elem ? elem->data : 0;
29856 }
29857
29858 /* Insert an element into the hash table pH. The key is pKey
29859 ** and the data is "data".
29860 **
@@ -29875,11 +29941,11 @@
29875 HashElem *new_elem; /* New element added to the pH */
29876
29877 assert( pH!=0 );
29878 assert( pKey!=0 );
29879 elem = findElementWithHash(pH,pKey,&h);
29880 if( elem ){
29881 void *old_data = elem->data;
29882 if( data==0 ){
29883 removeElementGivenHash(pH,elem,h);
29884 }else{
29885 elem->data = data;
@@ -58883,14 +58949,16 @@
58883 ** Allowed values for BtShared.btsFlags
58884 */
58885 #define BTS_READ_ONLY 0x0001 /* Underlying file is readonly */
58886 #define BTS_PAGESIZE_FIXED 0x0002 /* Page size can no longer be changed */
58887 #define BTS_SECURE_DELETE 0x0004 /* PRAGMA secure_delete is enabled */
58888 #define BTS_INITIALLY_EMPTY 0x0008 /* Database was empty at trans start */
58889 #define BTS_NO_WAL 0x0010 /* Do not open write-ahead-log files */
58890 #define BTS_EXCLUSIVE 0x0020 /* pWriter has an exclusive lock */
58891 #define BTS_PENDING 0x0040 /* Waiting for read-locks to clear */
 
 
58892
58893 /*
58894 ** An instance of the following structure is used to hold information
58895 ** about a cell. The parseCellPtr() function fills in this structure
58896 ** based on information extract from the raw disk page.
@@ -61072,11 +61140,11 @@
61072 assert( iSize>=4 ); /* Minimum cell size is 4 */
61073 assert( iStart<=iLast );
61074
61075 /* Overwrite deleted information with zeros when the secure_delete
61076 ** option is enabled */
61077 if( pPage->pBt->btsFlags & BTS_SECURE_DELETE ){
61078 memset(&data[iStart], 0, iSize);
61079 }
61080
61081 /* The list of freeblocks must be in ascending order. Find the
61082 ** spot on the list where iStart should be inserted.
@@ -61363,11 +61431,11 @@
61363 assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
61364 assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
61365 assert( sqlite3PagerGetData(pPage->pDbPage) == data );
61366 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
61367 assert( sqlite3_mutex_held(pBt->mutex) );
61368 if( pBt->btsFlags & BTS_SECURE_DELETE ){
61369 memset(&data[hdr], 0, pBt->usableSize - hdr);
61370 }
61371 data[hdr] = (char)flags;
61372 first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);
61373 memset(&data[hdr+1], 0, 4);
@@ -61786,12 +61854,14 @@
61786 p->pBt = pBt;
61787
61788 pBt->pCursor = 0;
61789 pBt->pPage1 = 0;
61790 if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;
61791 #ifdef SQLITE_SECURE_DELETE
61792 pBt->btsFlags |= BTS_SECURE_DELETE;
 
 
61793 #endif
61794 /* EVIDENCE-OF: R-51873-39618 The page size for a database file is
61795 ** determined by the 2-byte integer located at an offset of 16 bytes from
61796 ** the beginning of the database file. */
61797 pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);
@@ -62235,23 +62305,38 @@
62235 sqlite3BtreeLeave(p);
62236 return n;
62237 }
62238
62239 /*
62240 ** Set the BTS_SECURE_DELETE flag if newFlag is 0 or 1. If newFlag is -1,
62241 ** then make no changes. Always return the value of the BTS_SECURE_DELETE
62242 ** setting after the change.
 
 
 
 
 
 
 
 
 
 
 
 
 
62243 */
62244 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
62245 int b;
62246 if( p==0 ) return 0;
62247 sqlite3BtreeEnter(p);
 
 
62248 if( newFlag>=0 ){
62249 p->pBt->btsFlags &= ~BTS_SECURE_DELETE;
62250 if( newFlag ) p->pBt->btsFlags |= BTS_SECURE_DELETE;
62251 }
62252 b = (p->pBt->btsFlags & BTS_SECURE_DELETE)!=0;
62253 sqlite3BtreeLeave(p);
62254 return b;
62255 }
62256
62257 /*
@@ -66642,11 +66727,11 @@
66642 ** But not if we are in secure-delete mode. In secure-delete mode,
66643 ** the dropCell() routine will overwrite the entire cell with zeroes.
66644 ** In this case, temporarily copy the cell into the aOvflSpace[]
66645 ** buffer. It will be copied out again as soon as the aSpace[] buffer
66646 ** is allocated. */
66647 if( pBt->btsFlags & BTS_SECURE_DELETE ){
66648 int iOff;
66649
66650 iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
66651 if( (iOff+szNew[i])>(int)pBt->usableSize ){
66652 rc = SQLITE_CORRUPT_BKPT;
@@ -72056,25 +72141,31 @@
72056 ** constants. The registers begin with iDest and increase consecutively.
72057 ** One register is initialized for each characgter in zTypes[]. For each
72058 ** "s" character in zTypes[], the register is a string if the argument is
72059 ** not NULL, or OP_Null if the value is a null pointer. For each "i" character
72060 ** in zTypes[], the register is initialized to an integer.
 
 
 
72061 */
72062 SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
72063 va_list ap;
72064 int i;
72065 char c;
72066 va_start(ap, zTypes);
72067 for(i=0; (c = zTypes[i])!=0; i++){
72068 if( c=='s' ){
72069 const char *z = va_arg(ap, const char*);
72070 sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest++, 0, z, 0);
 
 
72071 }else{
72072 assert( c=='i' );
72073 sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++);
72074 }
72075 }
 
 
72076 va_end(ap);
72077 }
72078
72079 /*
72080 ** Add an opcode that includes the p4 value as a pointer.
@@ -89667,19 +89758,21 @@
89667 static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
89668 int rc;
89669 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
89670 testcase( ExprHasProperty(pExpr, EP_Reduced) );
89671 rc = pWalker->xExprCallback(pWalker, pExpr);
89672 if( rc || ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
89673 return rc & WRC_Abort;
89674 }
89675 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
89676 if( pExpr->pRight && walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
89677 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89678 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
89679 }else if( pExpr->x.pList ){
89680 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
 
 
89681 }
89682 return WRC_Continue;
89683 }
89684 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
89685 return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;
@@ -89730,11 +89823,11 @@
89730 struct SrcList_item *pItem;
89731
89732 pSrc = p->pSrc;
89733 if( ALWAYS(pSrc) ){
89734 for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
89735 if( sqlite3WalkSelect(pWalker, pItem->pSelect) ){
89736 return WRC_Abort;
89737 }
89738 if( pItem->fg.isTabFunc
89739 && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)
89740 ){
@@ -89762,11 +89855,12 @@
89762 ** If the Walker does not have an xSelectCallback() then this routine
89763 ** is a no-op returning WRC_Continue.
89764 */
89765 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
89766 int rc;
89767 if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
 
89768 do{
89769 rc = pWalker->xSelectCallback(pWalker, p);
89770 if( rc ) return rc & WRC_Abort;
89771 if( sqlite3WalkSelectExpr(pWalker, p)
89772 || sqlite3WalkSelectFrom(pWalker, p)
@@ -90261,10 +90355,11 @@
90261 sqlite3ExprDelete(db, pExpr->pLeft);
90262 pExpr->pLeft = 0;
90263 sqlite3ExprDelete(db, pExpr->pRight);
90264 pExpr->pRight = 0;
90265 pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
 
90266 lookupname_end:
90267 if( cnt==1 ){
90268 assert( pNC!=0 );
90269 if( !ExprHasProperty(pExpr, EP_Alias) ){
90270 sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
@@ -92067,11 +92162,11 @@
92067 memset(pNew, 0, sizeof(Expr));
92068 pNew->op = (u8)op;
92069 pNew->iAgg = -1;
92070 if( pToken ){
92071 if( nExtra==0 ){
92072 pNew->flags |= EP_IntValue;
92073 pNew->u.iValue = iValue;
92074 }else{
92075 pNew->u.zToken = (char*)&pNew[1];
92076 assert( pToken->z!=0 || pToken->n==0 );
92077 if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
@@ -92348,12 +92443,13 @@
92348 #endif
92349 if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
92350 /* The Expr.x union is never used at the same time as Expr.pRight */
92351 assert( p->x.pList==0 || p->pRight==0 );
92352 if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
92353 sqlite3ExprDelete(db, p->pRight);
92354 if( ExprHasProperty(p, EP_xIsSelect) ){
 
92355 sqlite3SelectDelete(db, p->x.pSelect);
92356 }else{
92357 sqlite3ExprListDelete(db, p->x.pList);
92358 }
92359 }
@@ -103955,16 +104051,16 @@
103955 pItem = &pList->a[pList->nSrc-1];
103956 if( pDatabase && pDatabase->z==0 ){
103957 pDatabase = 0;
103958 }
103959 if( pDatabase ){
103960 Token *pTemp = pDatabase;
103961 pDatabase = pTable;
103962 pTable = pTemp;
 
 
103963 }
103964 pItem->zName = sqlite3NameFromToken(db, pTable);
103965 pItem->zDatabase = sqlite3NameFromToken(db, pDatabase);
103966 return pList;
103967 }
103968
103969 /*
103970 ** Assign VdbeCursor index numbers to all tables in a SrcList
@@ -104149,40 +104245,29 @@
104149 }
104150 sqlite3VdbeAddOp0(v, OP_AutoCommit);
104151 }
104152
104153 /*
104154 ** Generate VDBE code for a COMMIT statement.
104155 */
104156 SQLITE_PRIVATE void sqlite3CommitTransaction(Parse *pParse){
104157 Vdbe *v;
104158
104159 assert( pParse!=0 );
104160 assert( pParse->db!=0 );
104161 if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ){
104162 return;
104163 }
104164 v = sqlite3GetVdbe(pParse);
104165 if( v ){
104166 sqlite3VdbeAddOp1(v, OP_AutoCommit, 1);
104167 }
104168 }
104169
104170 /*
104171 ** Generate VDBE code for a ROLLBACK statement.
104172 */
104173 SQLITE_PRIVATE void sqlite3RollbackTransaction(Parse *pParse){
104174 Vdbe *v;
104175
104176 assert( pParse!=0 );
104177 assert( pParse->db!=0 );
104178 if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ){
104179 return;
104180 }
104181 v = sqlite3GetVdbe(pParse);
104182 if( v ){
104183 sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1);
104184 }
104185 }
104186
104187 /*
104188 ** This function is called by the parser when it parses a command to create,
@@ -104759,11 +104844,11 @@
104759 ** request a definition of the collating sequence. If this doesn't work,
104760 ** an equivalent collating sequence that uses a text encoding different
104761 ** from the main database is substituted, if one is available.
104762 */
104763 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
104764 if( pColl ){
104765 const char *zName = pColl->zName;
104766 sqlite3 *db = pParse->db;
104767 CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);
104768 if( !p ){
104769 return SQLITE_ERROR;
@@ -104795,22 +104880,21 @@
104795 ){
104796 CollSeq *pColl;
104797 pColl = sqlite3HashFind(&db->aCollSeq, zName);
104798
104799 if( 0==pColl && create ){
104800 int nName = sqlite3Strlen30(zName);
104801 pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1);
104802 if( pColl ){
104803 CollSeq *pDel = 0;
104804 pColl[0].zName = (char*)&pColl[3];
104805 pColl[0].enc = SQLITE_UTF8;
104806 pColl[1].zName = (char*)&pColl[3];
104807 pColl[1].enc = SQLITE_UTF16LE;
104808 pColl[2].zName = (char*)&pColl[3];
104809 pColl[2].enc = SQLITE_UTF16BE;
104810 memcpy(pColl[0].zName, zName, nName);
104811 pColl[0].zName[nName] = 0;
104812 pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);
104813
104814 /* If a malloc() failure occurred in sqlite3HashInsert(), it will
104815 ** return the pColl pointer to be deleted (because it wasn't added
104816 ** to the hash table).
@@ -104946,11 +105030,12 @@
104946 int i;
104947 for(i=0; i<nDef; i++){
104948 FuncDef *pOther;
104949 const char *zName = aDef[i].zName;
104950 int nName = sqlite3Strlen30(zName);
104951 int h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;
 
104952 pOther = functionSearch(h, zName);
104953 if( pOther ){
104954 assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
104955 aDef[i].pNext = pOther->pNext;
104956 pOther->pNext = &aDef[i];
@@ -106109,20 +106194,20 @@
106109 static void typeofFunc(
106110 sqlite3_context *context,
106111 int NotUsed,
106112 sqlite3_value **argv
106113 ){
106114 const char *z = 0;
 
106115 UNUSED_PARAMETER(NotUsed);
106116 switch( sqlite3_value_type(argv[0]) ){
106117 case SQLITE_INTEGER: z = "integer"; break;
106118 case SQLITE_TEXT: z = "text"; break;
106119 case SQLITE_FLOAT: z = "real"; break;
106120 case SQLITE_BLOB: z = "blob"; break;
106121 default: z = "null"; break;
106122 }
106123 sqlite3_result_text(context, z, -1, SQLITE_STATIC);
106124 }
106125
106126
106127 /*
106128 ** Implementation of the length() function
@@ -113151,39 +113236,42 @@
113151 #define PragTyp_DATABASE_LIST 10
113152 #define PragTyp_DEFAULT_CACHE_SIZE 11
113153 #define PragTyp_ENCODING 12
113154 #define PragTyp_FOREIGN_KEY_CHECK 13
113155 #define PragTyp_FOREIGN_KEY_LIST 14
113156 #define PragTyp_INCREMENTAL_VACUUM 15
113157 #define PragTyp_INDEX_INFO 16
113158 #define PragTyp_INDEX_LIST 17
113159 #define PragTyp_INTEGRITY_CHECK 18
113160 #define PragTyp_JOURNAL_MODE 19
113161 #define PragTyp_JOURNAL_SIZE_LIMIT 20
113162 #define PragTyp_LOCK_PROXY_FILE 21
113163 #define PragTyp_LOCKING_MODE 22
113164 #define PragTyp_PAGE_COUNT 23
113165 #define PragTyp_MMAP_SIZE 24
113166 #define PragTyp_OPTIMIZE 25
113167 #define PragTyp_PAGE_SIZE 26
113168 #define PragTyp_SECURE_DELETE 27
113169 #define PragTyp_SHRINK_MEMORY 28
113170 #define PragTyp_SOFT_HEAP_LIMIT 29
113171 #define PragTyp_SYNCHRONOUS 30
113172 #define PragTyp_TABLE_INFO 31
113173 #define PragTyp_TEMP_STORE 32
113174 #define PragTyp_TEMP_STORE_DIRECTORY 33
113175 #define PragTyp_THREADS 34
113176 #define PragTyp_WAL_AUTOCHECKPOINT 35
113177 #define PragTyp_WAL_CHECKPOINT 36
113178 #define PragTyp_ACTIVATE_EXTENSIONS 37
113179 #define PragTyp_HEXKEY 38
113180 #define PragTyp_KEY 39
113181 #define PragTyp_REKEY 40
113182 #define PragTyp_LOCK_STATUS 41
113183 #define PragTyp_PARSER_TRACE 42
113184 #define PragTyp_STATS 43
 
 
 
113185
113186 /* Property flags associated with various pragma. */
113187 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
113188 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
113189 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -113225,30 +113313,33 @@
113225 /* 24 */ "origin",
113226 /* 25 */ "partial",
113227 /* 26 */ "seq", /* Used by: database_list */
113228 /* 27 */ "name",
113229 /* 28 */ "file",
113230 /* 29 */ "seq", /* Used by: collation_list */
113231 /* 30 */ "name",
113232 /* 31 */ "id", /* Used by: foreign_key_list */
113233 /* 32 */ "seq",
113234 /* 33 */ "table",
113235 /* 34 */ "from",
113236 /* 35 */ "to",
113237 /* 36 */ "on_update",
113238 /* 37 */ "on_delete",
113239 /* 38 */ "match",
113240 /* 39 */ "table", /* Used by: foreign_key_check */
113241 /* 40 */ "rowid",
113242 /* 41 */ "parent",
113243 /* 42 */ "fkid",
113244 /* 43 */ "busy", /* Used by: wal_checkpoint */
113245 /* 44 */ "log",
113246 /* 45 */ "checkpointed",
113247 /* 46 */ "timeout", /* Used by: busy_timeout */
113248 /* 47 */ "database", /* Used by: lock_status */
113249 /* 48 */ "status",
 
 
 
113250 };
113251
113252 /* Definitions of all built-in pragmas */
113253 typedef struct PragmaName {
113254 const char *const zName; /* Name of pragma */
@@ -113290,11 +113381,11 @@
113290 #endif
113291 #endif
113292 {/* zName: */ "busy_timeout",
113293 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
113294 /* ePragFlg: */ PragFlg_Result0,
113295 /* ColNames: */ 46, 1,
113296 /* iArg: */ 0 },
113297 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113298 {/* zName: */ "cache_size",
113299 /* ePragTyp: */ PragTyp_CACHE_SIZE,
113300 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -113327,11 +113418,11 @@
113327 #endif
113328 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113329 {/* zName: */ "collation_list",
113330 /* ePragTyp: */ PragTyp_COLLATION_LIST,
113331 /* ePragFlg: */ PragFlg_Result0,
113332 /* ColNames: */ 29, 2,
113333 /* iArg: */ 0 },
113334 #endif
113335 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
113336 {/* zName: */ "compile_options",
113337 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -113399,18 +113490,18 @@
113399 #endif
113400 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113401 {/* zName: */ "foreign_key_check",
113402 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
113403 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
113404 /* ColNames: */ 39, 4,
113405 /* iArg: */ 0 },
113406 #endif
113407 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
113408 {/* zName: */ "foreign_key_list",
113409 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
113410 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
113411 /* ColNames: */ 31, 8,
113412 /* iArg: */ 0 },
113413 #endif
113414 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113415 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113416 {/* zName: */ "foreign_keys",
@@ -113436,10 +113527,19 @@
113436 {/* zName: */ "fullfsync",
113437 /* ePragTyp: */ PragTyp_FLAG,
113438 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113439 /* ColNames: */ 0, 0,
113440 /* iArg: */ SQLITE_FullFSync },
 
 
 
 
 
 
 
 
 
113441 #endif
113442 #if defined(SQLITE_HAS_CODEC)
113443 {/* zName: */ "hexkey",
113444 /* ePragTyp: */ PragTyp_HEXKEY,
113445 /* ePragFlg: */ 0,
@@ -113526,11 +113626,11 @@
113526 #endif
113527 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
113528 {/* zName: */ "lock_status",
113529 /* ePragTyp: */ PragTyp_LOCK_STATUS,
113530 /* ePragFlg: */ PragFlg_Result0,
113531 /* ColNames: */ 47, 2,
113532 /* iArg: */ 0 },
113533 #endif
113534 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113535 {/* zName: */ "locking_mode",
113536 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -113545,10 +113645,21 @@
113545 {/* zName: */ "mmap_size",
113546 /* ePragTyp: */ PragTyp_MMAP_SIZE,
113547 /* ePragFlg: */ 0,
113548 /* ColNames: */ 0, 0,
113549 /* iArg: */ 0 },
 
 
 
 
 
 
 
 
 
 
 
113550 #endif
113551 {/* zName: */ "optimize",
113552 /* ePragTyp: */ PragTyp_OPTIMIZE,
113553 /* ePragFlg: */ PragFlg_Result1|PragFlg_NeedSchema,
113554 /* ColNames: */ 0, 0,
@@ -113569,10 +113680,17 @@
113569 {/* zName: */ "parser_trace",
113570 /* ePragTyp: */ PragTyp_PARSER_TRACE,
113571 /* ePragFlg: */ 0,
113572 /* ColNames: */ 0, 0,
113573 /* iArg: */ 0 },
 
 
 
 
 
 
 
113574 #endif
113575 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113576 {/* zName: */ "query_only",
113577 /* ePragTyp: */ PragTyp_FLAG,
113578 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -113733,11 +113851,11 @@
113733 /* ColNames: */ 0, 0,
113734 /* iArg: */ 0 },
113735 {/* zName: */ "wal_checkpoint",
113736 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
113737 /* ePragFlg: */ PragFlg_NeedSchema,
113738 /* ColNames: */ 43, 3,
113739 /* iArg: */ 0 },
113740 #endif
113741 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113742 {/* zName: */ "writable_schema",
113743 /* ePragTyp: */ PragTyp_FLAG,
@@ -113744,11 +113862,11 @@
113744 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113745 /* ColNames: */ 0, 0,
113746 /* iArg: */ SQLITE_WriteSchema },
113747 #endif
113748 };
113749 /* Number of pragmas: 60 on by default, 74 total. */
113750
113751 /************** End of pragma.h **********************************************/
113752 /************** Continuing where we left off in pragma.c *********************/
113753
113754 /*
@@ -114234,22 +114352,26 @@
114234 break;
114235 }
114236
114237 /*
114238 ** PRAGMA [schema.]secure_delete
114239 ** PRAGMA [schema.]secure_delete=ON/OFF
114240 **
114241 ** The first form reports the current setting for the
114242 ** secure_delete flag. The second form changes the secure_delete
114243 ** flag setting and reports thenew value.
114244 */
114245 case PragTyp_SECURE_DELETE: {
114246 Btree *pBt = pDb->pBt;
114247 int b = -1;
114248 assert( pBt!=0 );
114249 if( zRight ){
114250 b = sqlite3GetBoolean(zRight, 0);
 
 
 
 
114251 }
114252 if( pId2->n==0 && b>=0 ){
114253 int ii;
114254 for(ii=0; ii<db->nDb; ii++){
114255 sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
@@ -114827,11 +114949,10 @@
114827 pCol->zName,
114828 sqlite3ColumnType(pCol,""),
114829 pCol->notNull ? 1 : 0,
114830 pCol->pDflt ? pCol->pDflt->u.zToken : 0,
114831 k);
114832 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
114833 }
114834 }
114835 }
114836 break;
114837
@@ -114847,13 +114968,12 @@
114847 pTab->zName,
114848 0,
114849 pTab->szTabRow,
114850 pTab->nRowLogEst,
114851 pTab->tabFlags);
114852 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114853 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114854 sqlite3VdbeMultiLoad(v, 2, "siii",
114855 pIdx->zName,
114856 pIdx->szIdxRow,
114857 pIdx->aiRowLogEst[0],
114858 pIdx->hasStat1);
114859 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
@@ -114882,14 +115002,14 @@
114882 pTab = pIdx->pTable;
114883 sqlite3CodeVerifySchema(pParse, iDb);
114884 assert( pParse->nMem<=pPragma->nPragCName );
114885 for(i=0; i<mx; i++){
114886 i16 cnum = pIdx->aiColumn[i];
114887 sqlite3VdbeMultiLoad(v, 1, "iis", i, cnum,
114888 cnum<0 ? 0 : pTab->aCol[cnum].zName);
114889 if( pPragma->iArg ){
114890 sqlite3VdbeMultiLoad(v, 4, "isi",
114891 pIdx->aSortOrder[i],
114892 pIdx->azColl[i],
114893 i<pIdx->nKeyCol);
114894 }
114895 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
@@ -114912,11 +115032,10 @@
114912 i,
114913 pIdx->zName,
114914 IsUniqueIndex(pIdx),
114915 azOrigin[pIdx->idxType],
114916 pIdx->pPartIdxWhere!=0);
114917 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114918 }
114919 }
114920 }
114921 break;
114922
@@ -114928,11 +115047,10 @@
114928 assert( db->aDb[i].zDbSName!=0 );
114929 sqlite3VdbeMultiLoad(v, 1, "iss",
114930 i,
114931 db->aDb[i].zDbSName,
114932 sqlite3BtreeGetFilename(db->aDb[i].pBt));
114933 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
114934 }
114935 }
114936 break;
114937
114938 case PragTyp_COLLATION_LIST: {
@@ -114940,14 +115058,57 @@
114940 HashElem *p;
114941 pParse->nMem = 2;
114942 for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
114943 CollSeq *pColl = (CollSeq *)sqliteHashData(p);
114944 sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114945 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
114946 }
114947 }
114948 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114949 #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
114950
114951 #ifndef SQLITE_OMIT_FOREIGN_KEY
114952 case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
114953 FKey *pFK;
@@ -114969,11 +115130,10 @@
114969 pTab->aCol[pFK->aCol[j].iFrom].zName,
114970 pFK->aCol[j].zCol,
114971 actionName(pFK->aAction[1]), /* ON UPDATE */
114972 actionName(pFK->aAction[0]), /* ON DELETE */
114973 "NONE");
114974 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);
114975 }
114976 ++i;
114977 pFK = pFK->pNextFrom;
114978 }
114979 }
@@ -115079,11 +115239,11 @@
115079 if( HasRowid(pTab) ){
115080 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
115081 }else{
115082 sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);
115083 }
115084 sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1);
115085 sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);
115086 sqlite3VdbeResolveLabel(v, addrOk);
115087 sqlite3DbFree(db, aiCols);
115088 }
115089 sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);
@@ -115781,11 +115941,10 @@
115781 }else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0,
115782 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
115783 zState = azLockName[j];
115784 }
115785 sqlite3VdbeMultiLoad(v, 1, "ss", db->aDb[i].zDbSName, zState);
115786 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
115787 }
115788 break;
115789 }
115790 #endif
115791
@@ -118757,11 +118916,15 @@
118757 }else{
118758 /* Use the original text of the column expression as its name */
118759 zName = pEList->a[i].zSpan;
118760 }
118761 }
118762 zName = sqlite3MPrintf(db, "%s", zName);
 
 
 
 
118763
118764 /* Make sure the column name is unique. If the name is not unique,
118765 ** append an integer to the name so that it becomes unique.
118766 */
118767 cnt = 0;
@@ -122070,10 +122233,92 @@
122070 return pItem;
122071 }
122072 return 0;
122073 }
122074
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122075 /*
122076 ** Generate code for the SELECT statement given in the p argument.
122077 **
122078 ** The results are returned according to the SelectDest structure.
122079 ** See comments in sqliteInt.h for further information.
@@ -122381,10 +122626,20 @@
122381 if( sqlite3SelectTrace & 0x400 ){
122382 SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n"));
122383 sqlite3TreeViewSelect(0, p, 0);
122384 }
122385 #endif
 
 
 
 
 
 
 
 
 
 
122386
122387 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
122388 ** if the select-list is the same as the ORDER BY list, then this query
122389 ** can be rewritten as a GROUP BY. In other words, this:
122390 **
@@ -127095,10 +127350,11 @@
127095 #endif
127096 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
127097 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
127098 #define TERM_LIKE 0x400 /* The original LIKE operator */
127099 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
 
127100
127101 /*
127102 ** An instance of the WhereScan object is used as an iterator for locating
127103 ** terms in the WHERE clause that are useful to the query planner.
127104 */
@@ -127184,10 +127440,11 @@
127184 ** does not really matter. What is important is that sparse cursor
127185 ** numbers all get mapped into bit numbers that begin with 0 and contain
127186 ** no gaps.
127187 */
127188 struct WhereMaskSet {
 
127189 int n; /* Number of assigned cursor values */
127190 int ix[BMS]; /* Cursor assigned to each bit */
127191 };
127192
127193 /*
@@ -128481,11 +128738,11 @@
128481 int addrHalt; /* addrBrk for the outermost loop */
128482 int addrCont; /* Jump here to continue with next cycle */
128483 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
128484 int iReleaseReg = 0; /* Temp register to free before returning */
128485 Index *pIdx = 0; /* Index used by loop (if any) */
128486 int loopAgain; /* True if constraint generator loop should repeat */
128487
128488 pParse = pWInfo->pParse;
128489 v = pParse->pVdbe;
128490 pWC = &pWInfo->sWC;
128491 db = pParse->db;
@@ -129376,17 +129633,24 @@
129376 #endif
129377
129378 /* Insert code to test every subexpression that can be completely
129379 ** computed using the current set of tables.
129380 **
129381 ** This loop may run either once (pIdx==0) or twice (pIdx!=0). If
129382 ** it is run twice, then the first iteration codes those sub-expressions
129383 ** that can be computed using columns from pIdx only (without seeking
129384 ** the main table cursor).
 
 
 
 
 
 
129385 */
 
129386 do{
129387 loopAgain = 0;
129388 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
129389 Expr *pE;
129390 int skipLikeAddr = 0;
129391 testcase( pTerm->wtFlags & TERM_VIRTUAL );
129392 testcase( pTerm->wtFlags & TERM_CODED );
@@ -129400,14 +129664,20 @@
129400 pE = pTerm->pExpr;
129401 assert( pE!=0 );
129402 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
129403 continue;
129404 }
129405 if( pIdx && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
129406 loopAgain = 1;
 
 
 
 
 
129407 continue;
129408 }
 
129409 if( pTerm->wtFlags & TERM_LIKECOND ){
129410 /* If the TERM_LIKECOND flag is set, that means that the range search
129411 ** is sufficient to guarantee that the LIKE operator is true, so we
129412 ** can skip the call to the like(A,B) function. But this only works
129413 ** for strings. So do not skip the call to the function on the pass
@@ -129419,16 +129689,22 @@
129419 assert( x>0 );
129420 skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));
129421 VdbeCoverage(v);
129422 #endif
129423 }
 
 
 
 
 
 
129424 sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
129425 if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
129426 pTerm->wtFlags |= TERM_CODED;
129427 }
129428 pIdx = 0;
129429 }while( loopAgain );
129430
129431 /* Insert code to test for implied constraints based on transitivity
129432 ** of the "==" operator.
129433 **
129434 ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123"
@@ -130438,11 +130714,13 @@
130438 }else if( op==TK_ISNULL ){
130439 pTerm->prereqRight = 0;
130440 }else{
130441 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
130442 }
 
130443 prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
 
130444 if( ExprHasProperty(pExpr, EP_FromJoin) ){
130445 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
130446 prereqAll |= x;
130447 extraRight = x-1; /* ON clause terms may not be used with an index
130448 ** on left table of a LEFT JOIN. Ticket #3015 */
@@ -130869,13 +131147,16 @@
130869 if( p->op==TK_COLUMN ){
130870 return sqlite3WhereGetMask(pMaskSet, p->iTable);
130871 }
130872 mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
130873 assert( !ExprHasProperty(p, EP_TokenOnly) );
130874 if( p->pRight ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
130875 if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
130876 if( ExprHasProperty(p, EP_xIsSelect) ){
 
 
 
 
130877 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
130878 }else if( p->x.pList ){
130879 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
130880 }
130881 return mask;
@@ -135501,13 +135782,17 @@
135501 for(ii=0; ii<pTabList->nSrc; ii++){
135502 createMask(pMaskSet, pTabList->a[ii].iCursor);
135503 sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
135504 }
135505 #ifdef SQLITE_DEBUG
135506 for(ii=0; ii<pTabList->nSrc; ii++){
135507 Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);
135508 assert( m==MASKBIT(ii) );
 
 
 
 
135509 }
135510 #endif
135511
135512 /* Analyze all of the subexpressions. */
135513 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
@@ -136348,20 +136633,20 @@
136348 #define sqlite3ParserARG_SDECL Parse *pParse;
136349 #define sqlite3ParserARG_PDECL ,Parse *pParse
136350 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136351 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
136352 #define YYFALLBACK 1
136353 #define YYNSTATE 456
136354 #define YYNRULE 331
136355 #define YY_MAX_SHIFT 455
136356 #define YY_MIN_SHIFTREDUCE 667
136357 #define YY_MAX_SHIFTREDUCE 997
136358 #define YY_MIN_REDUCE 998
136359 #define YY_MAX_REDUCE 1328
136360 #define YY_ERROR_ACTION 1329
136361 #define YY_ACCEPT_ACTION 1330
136362 #define YY_NO_ACTION 1331
136363 /************* End control #defines *******************************************/
136364
136365 /* Define the yytestcase() macro to be a no-op if is not already defined
136366 ** otherwise.
136367 **
@@ -136429,169 +136714,169 @@
136429 ** yy_reduce_ofst[] For each state, the offset into yy_action for
136430 ** shifting non-terminals after a reduce.
136431 ** yy_default[] Default action for each state.
136432 **
136433 *********** Begin parsing tables **********************************************/
136434 #define YY_ACTTAB_COUNT (1566)
136435 static const YYACTIONTYPE yy_action[] = {
136436 /* 0 */ 325, 411, 343, 751, 751, 203, 944, 354, 974, 98,
136437 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136438 /* 20 */ 94, 94, 94, 93, 351, 1330, 155, 155, 2, 812,
136439 /* 30 */ 976, 976, 98, 98, 98, 98, 20, 96, 96, 96,
136440 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89,
136441 /* 50 */ 178, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136442 /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95,
136443 /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 974, 262,
136444 /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 790,
136445 /* 90 */ 242, 412, 21, 955, 379, 280, 93, 351, 791, 95,
136446 /* 100 */ 95, 94, 94, 94, 93, 351, 976, 976, 96, 96,
136447 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 812,
136448 /* 120 */ 329, 242, 412, 1242, 831, 1242, 132, 99, 100, 90,
136449 /* 130 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136450 /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136451 /* 150 */ 93, 351, 325, 824, 349, 348, 120, 818, 120, 75,
136452 /* 160 */ 52, 52, 955, 956, 957, 1090, 982, 146, 361, 262,
136453 /* 170 */ 370, 261, 955, 980, 959, 981, 92, 89, 178, 371,
136454 /* 180 */ 230, 371, 976, 976, 1147, 361, 360, 101, 823, 823,
136455 /* 190 */ 825, 384, 24, 1293, 381, 428, 413, 369, 983, 380,
136456 /* 200 */ 983, 1038, 325, 99, 100, 90, 852, 855, 844, 844,
136457 /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96,
136458 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 955, 132,
136459 /* 230 */ 895, 450, 976, 976, 895, 60, 94, 94, 94, 93,
136460 /* 240 */ 351, 955, 956, 957, 959, 103, 361, 955, 385, 334,
136461 /* 250 */ 701, 52, 52, 99, 100, 90, 852, 855, 844, 844,
136462 /* 260 */ 97, 97, 98, 98, 98, 98, 1028, 96, 96, 96,
136463 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455,
136464 /* 280 */ 1000, 450, 227, 61, 157, 243, 344, 114, 1031, 1218,
136465 /* 290 */ 147, 831, 955, 373, 1077, 955, 320, 955, 956, 957,
136466 /* 300 */ 194, 10, 10, 402, 399, 398, 1218, 1220, 976, 976,
136467 /* 310 */ 761, 171, 170, 157, 397, 337, 955, 956, 957, 701,
136468 /* 320 */ 824, 310, 153, 955, 818, 321, 82, 23, 80, 99,
136469 /* 330 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136470 /* 340 */ 98, 98, 893, 96, 96, 96, 96, 95, 95, 94,
136471 /* 350 */ 94, 94, 93, 351, 325, 823, 823, 825, 277, 231,
136472 /* 360 */ 300, 955, 956, 957, 955, 956, 957, 1218, 194, 25,
136473 /* 370 */ 450, 402, 399, 398, 955, 355, 300, 450, 955, 74,
136474 /* 380 */ 450, 1, 397, 132, 976, 976, 955, 224, 224, 812,
136475 /* 390 */ 10, 10, 955, 956, 957, 1297, 132, 52, 52, 415,
136476 /* 400 */ 52, 52, 1069, 1069, 339, 99, 100, 90, 852, 855,
136477 /* 410 */ 844, 844, 97, 97, 98, 98, 98, 98, 1120, 96,
136478 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136479 /* 430 */ 325, 1119, 428, 418, 705, 428, 427, 1267, 1267, 262,
136480 /* 440 */ 370, 261, 955, 955, 956, 957, 756, 955, 956, 957,
136481 /* 450 */ 450, 755, 450, 1064, 1043, 955, 956, 957, 443, 710,
136482 /* 460 */ 976, 976, 1064, 394, 92, 89, 178, 447, 447, 447,
136483 /* 470 */ 51, 51, 52, 52, 439, 777, 1030, 92, 89, 178,
136484 /* 480 */ 172, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136485 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136486 /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 914,
136487 /* 510 */ 698, 955, 956, 957, 92, 89, 178, 224, 224, 157,
136488 /* 520 */ 241, 221, 419, 299, 775, 915, 416, 375, 450, 415,
136489 /* 530 */ 58, 324, 1067, 1067, 1249, 379, 976, 976, 379, 776,
136490 /* 540 */ 449, 916, 363, 739, 296, 685, 9, 9, 52, 52,
136491 /* 550 */ 234, 330, 234, 256, 417, 740, 280, 99, 100, 90,
136492 /* 560 */ 852, 855, 844, 844, 97, 97, 98, 98, 98, 98,
136493 /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136494 /* 580 */ 93, 351, 325, 423, 72, 450, 832, 120, 368, 450,
136495 /* 590 */ 10, 10, 5, 301, 203, 450, 177, 974, 253, 420,
136496 /* 600 */ 255, 775, 200, 175, 233, 10, 10, 841, 841, 36,
136497 /* 610 */ 36, 1296, 976, 976, 728, 37, 37, 349, 348, 425,
136498 /* 620 */ 203, 260, 775, 974, 232, 935, 1323, 875, 338, 1323,
136499 /* 630 */ 422, 853, 856, 99, 100, 90, 852, 855, 844, 844,
136500 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136501 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 845,
136502 /* 660 */ 450, 983, 817, 983, 1207, 450, 914, 974, 719, 350,
136503 /* 670 */ 350, 350, 933, 177, 450, 935, 1324, 254, 198, 1324,
136504 /* 680 */ 12, 12, 915, 403, 450, 27, 27, 250, 976, 976,
136505 /* 690 */ 118, 720, 162, 974, 38, 38, 268, 176, 916, 775,
136506 /* 700 */ 433, 1272, 944, 354, 39, 39, 317, 996, 325, 99,
136507 /* 710 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136508 /* 720 */ 98, 98, 933, 96, 96, 96, 96, 95, 95, 94,
136509 /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 976, 976,
136510 /* 740 */ 1047, 317, 934, 341, 898, 898, 387, 672, 673, 674,
136511 /* 750 */ 275, 1325, 318, 997, 40, 40, 41, 41, 268, 99,
136512 /* 760 */ 100, 90, 852, 855, 844, 844, 97, 97, 98, 98,
136513 /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94,
136514 /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 997, 450,
136515 /* 790 */ 1022, 331, 42, 42, 790, 270, 450, 273, 450, 228,
136516 /* 800 */ 450, 298, 450, 791, 450, 28, 28, 29, 29, 31,
136517 /* 810 */ 31, 450, 1147, 450, 976, 976, 43, 43, 44, 44,
136518 /* 820 */ 45, 45, 11, 11, 46, 46, 892, 78, 892, 268,
136519 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 852, 855,
136520 /* 840 */ 844, 844, 97, 97, 98, 98, 98, 98, 450, 96,
136521 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
136522 /* 860 */ 325, 450, 117, 450, 1079, 158, 450, 695, 48, 48,
136523 /* 870 */ 229, 1248, 450, 1257, 450, 415, 450, 335, 450, 245,
136524 /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 1147,
136525 /* 890 */ 976, 976, 34, 34, 122, 122, 123, 123, 124, 124,
136526 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136527 /* 910 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136528 /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136529 /* 930 */ 95, 94, 94, 94, 93, 351, 450, 695, 450, 1147,
136530 /* 940 */ 976, 976, 973, 1214, 106, 106, 268, 1216, 268, 1273,
136531 /* 950 */ 2, 891, 268, 891, 336, 1046, 53, 53, 107, 107,
136532 /* 960 */ 325, 99, 100, 90, 852, 855, 844, 844, 97, 97,
136533 /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136534 /* 980 */ 95, 94, 94, 94, 93, 351, 450, 1076, 450, 1072,
136535 /* 990 */ 976, 976, 1045, 267, 108, 108, 446, 331, 332, 133,
136536 /* 1000 */ 223, 175, 301, 225, 386, 1262, 104, 104, 121, 121,
136537 /* 1010 */ 325, 99, 88, 90, 852, 855, 844, 844, 97, 97,
136538 /* 1020 */ 98, 98, 98, 98, 1147, 96, 96, 96, 96, 95,
136539 /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167,
136540 /* 1040 */ 976, 976, 930, 814, 372, 319, 202, 202, 374, 263,
136541 /* 1050 */ 395, 202, 74, 208, 725, 726, 119, 119, 112, 112,
136542 /* 1060 */ 325, 407, 100, 90, 852, 855, 844, 844, 97, 97,
136543 /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95,
136544 /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 756, 450, 345,
136545 /* 1090 */ 976, 976, 755, 278, 111, 111, 74, 718, 717, 708,
136546 /* 1100 */ 286, 882, 753, 1286, 257, 77, 109, 109, 110, 110,
136547 /* 1110 */ 1237, 285, 1140, 90, 852, 855, 844, 844, 97, 97,
136548 /* 1120 */ 98, 98, 98, 98, 1240, 96, 96, 96, 96, 95,
136549 /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3,
136550 /* 1140 */ 1200, 450, 1075, 132, 352, 120, 1019, 86, 445, 784,
136551 /* 1150 */ 3, 1097, 202, 377, 448, 352, 1236, 120, 55, 55,
136552 /* 1160 */ 450, 57, 57, 827, 878, 448, 450, 208, 450, 708,
136553 /* 1170 */ 450, 882, 237, 434, 436, 120, 440, 429, 362, 120,
136554 /* 1180 */ 54, 54, 132, 450, 434, 831, 52, 52, 26, 26,
136555 /* 1190 */ 30, 30, 382, 132, 409, 444, 831, 693, 264, 390,
136556 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136557 /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 818, 1060,
136558 /* 1220 */ 1044, 428, 430, 85, 352, 452, 451, 120, 120, 818,
136559 /* 1230 */ 378, 218, 281, 827, 1113, 1146, 86, 445, 410, 3,
136560 /* 1240 */ 1093, 1104, 431, 432, 352, 302, 303, 1153, 1027, 823,
136561 /* 1250 */ 823, 825, 826, 19, 448, 1021, 1010, 1009, 1011, 1280,
136562 /* 1260 */ 823, 823, 825, 826, 19, 289, 159, 291, 293, 7,
136563 /* 1270 */ 316, 173, 259, 434, 1135, 364, 252, 1239, 376, 1043,
136564 /* 1280 */ 295, 435, 168, 991, 400, 831, 284, 1211, 1210, 205,
136565 /* 1290 */ 1283, 308, 1256, 86, 445, 988, 3, 1254, 333, 144,
136566 /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 760, 137, 366,
136567 /* 1310 */ 1132, 448, 85, 352, 452, 451, 139, 226, 818, 140,
136568 /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 682,
136569 /* 1330 */ 434, 185, 141, 1241, 142, 160, 148, 1142, 1205, 383,
136570 /* 1340 */ 189, 67, 831, 180, 389, 248, 1225, 1105, 219, 823,
136571 /* 1350 */ 823, 825, 826, 19, 247, 190, 266, 154, 391, 271,
136572 /* 1360 */ 191, 192, 83, 84, 1012, 406, 1063, 182, 322, 85,
136573 /* 1370 */ 352, 452, 451, 1062, 183, 818, 342, 132, 181, 710,
136574 /* 1380 */ 1061, 421, 76, 445, 1035, 3, 323, 1034, 283, 1054,
136575 /* 1390 */ 352, 1101, 1033, 1295, 1053, 71, 204, 6, 288, 290,
136576 /* 1400 */ 448, 1102, 1100, 1099, 79, 292, 823, 823, 825, 826,
136577 /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 1191, 1083, 434,
136578 /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306,
136579 /* 1430 */ 307, 831, 213, 1018, 22, 950, 453, 214, 216, 217,
136580 /* 1440 */ 454, 1007, 115, 1006, 1001, 125, 126, 235, 127, 668,
136581 /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352,
136582 /* 1460 */ 452, 451, 134, 179, 818, 357, 113, 890, 810, 888,
136583 /* 1470 */ 136, 128, 138, 742, 258, 184, 904, 143, 145, 63,
136584 /* 1480 */ 64, 65, 66, 129, 907, 903, 187, 186, 8, 13,
136585 /* 1490 */ 188, 265, 896, 149, 202, 823, 823, 825, 826, 19,
136586 /* 1500 */ 388, 985, 150, 161, 285, 684, 392, 396, 151, 721,
136587 /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 830, 829,
136588 /* 1520 */ 131, 858, 750, 70, 16, 414, 754, 4, 783, 220,
136589 /* 1530 */ 222, 174, 152, 437, 778, 201, 17, 77, 74, 18,
136590 /* 1540 */ 873, 859, 857, 913, 862, 912, 207, 206, 939, 163,
136591 /* 1550 */ 210, 940, 209, 164, 441, 861, 165, 211, 828, 694,
136592 /* 1560 */ 87, 312, 309, 945, 1288, 1287,
136593 };
136594 static const YYCODETYPE yy_lookahead[] = {
136595 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136596 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136597 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136734,26 +137019,26 @@
136734 /* 1390 */ 27, 216, 174, 174, 182, 107, 159, 22, 215, 215,
136735 /* 1400 */ 37, 216, 216, 216, 137, 215, 132, 133, 134, 135,
136736 /* 1410 */ 136, 215, 159, 177, 94, 177, 129, 224, 205, 56,
136737 /* 1420 */ 226, 126, 128, 203, 229, 204, 114, 229, 127, 202,
136738 /* 1430 */ 201, 68, 25, 162, 26, 13, 161, 153, 153, 6,
136739 /* 1440 */ 151, 151, 178, 151, 151, 165, 165, 178, 165, 4,
136740 /* 1450 */ 249, 88, 89, 141, 3, 142, 22, 249, 95, 96,
136741 /* 1460 */ 97, 98, 246, 15, 101, 67, 16, 23, 120, 23,
136742 /* 1470 */ 131, 111, 123, 20, 16, 125, 1, 123, 131, 78,
136743 /* 1480 */ 78, 78, 78, 111, 96, 1, 122, 35, 5, 22,
136744 /* 1490 */ 107, 140, 53, 53, 26, 132, 133, 134, 135, 136,
136745 /* 1500 */ 43, 60, 107, 24, 112, 20, 19, 52, 22, 29,
136746 /* 1510 */ 105, 22, 22, 52, 23, 22, 22, 52, 23, 23,
136747 /* 1520 */ 39, 23, 116, 26, 22, 26, 23, 22, 96, 23,
136748 /* 1530 */ 23, 122, 22, 24, 124, 35, 35, 26, 26, 35,
136749 /* 1540 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22,
136750 /* 1550 */ 122, 23, 26, 22, 24, 23, 22, 122, 23, 23,
136751 /* 1560 */ 22, 15, 23, 1, 122, 122,
136752 };
136753 #define YY_SHIFT_USE_DFLT (1566)
136754 #define YY_SHIFT_COUNT (455)
136755 #define YY_SHIFT_MIN (-114)
136756 #define YY_SHIFT_MAX (1562)
136757 static const short yy_shift_ofst[] = {
136758 /* 0 */ 5, 1117, 1312, 1128, 1274, 1274, 1274, 1274, 61, -19,
136759 /* 10 */ 57, 57, 183, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
@@ -136765,15 +137050,15 @@
136765 /* 70 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136766 /* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136767 /* 90 */ 1363, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
136768 /* 100 */ 1274, 1274, 1274, 1274, -70, -47, -47, -47, -47, -47,
136769 /* 110 */ 24, 11, 146, 296, 524, 444, 529, 529, 296, 3,
136770 /* 120 */ 2, -30, 1566, 1566, 1566, -17, -17, -17, 145, 145,
136771 /* 130 */ 497, 497, 265, 603, 653, 296, 296, 296, 296, 296,
136772 /* 140 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
136773 /* 150 */ 296, 296, 296, 296, 296, 701, 1078, 147, 147, 2,
136774 /* 160 */ 164, 164, 164, 164, 164, 164, 1566, 1566, 1566, 223,
136775 /* 170 */ 56, 56, 268, 269, 220, 347, 351, 415, 359, 296,
136776 /* 180 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
136777 /* 190 */ 296, 296, 296, 296, 296, 632, 632, 632, 296, 296,
136778 /* 200 */ 498, 296, 296, 296, 570, 296, 296, 654, 296, 296,
136779 /* 210 */ 296, 296, 296, 296, 296, 296, 296, 296, 636, 200,
@@ -136784,30 +137069,30 @@
136784 /* 260 */ 1277, 1230, 1230, 1172, 1167, 1310, 1204, 1299, 1167, 1167,
136785 /* 270 */ 1310, 1335, 1167, 1310, 1167, 1310, 1335, 1258, 1258, 1258,
136786 /* 280 */ 1329, 1335, 1258, 1273, 1258, 1329, 1258, 1258, 1256, 1288,
136787 /* 290 */ 1256, 1288, 1256, 1288, 1256, 1288, 1167, 1375, 1167, 1267,
136788 /* 300 */ 1335, 1320, 1320, 1335, 1287, 1295, 1294, 1301, 1172, 1407,
136789 /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1433, 1566, 1566, 1566,
136790 /* 320 */ 1566, 1566, 1566, 1566, 1566, 558, 537, 684, 719, 734,
136791 /* 330 */ 799, 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070,
136792 /* 340 */ 1072, 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819,
136793 /* 350 */ 1174, 1136, 981, 1445, 1451, 1434, 1313, 1448, 1398, 1450,
136794 /* 360 */ 1444, 1446, 1348, 1339, 1360, 1349, 1453, 1350, 1458, 1475,
136795 /* 370 */ 1354, 1347, 1401, 1402, 1403, 1404, 1372, 1388, 1452, 1364,
136796 /* 380 */ 1484, 1483, 1467, 1383, 1351, 1439, 1468, 1440, 1441, 1457,
136797 /* 390 */ 1395, 1479, 1485, 1487, 1392, 1405, 1486, 1455, 1489, 1490,
136798 /* 400 */ 1491, 1493, 1461, 1480, 1494, 1465, 1481, 1495, 1496, 1498,
136799 /* 410 */ 1497, 1406, 1502, 1503, 1505, 1499, 1409, 1506, 1507, 1432,
136800 /* 420 */ 1500, 1510, 1410, 1511, 1501, 1512, 1504, 1517, 1511, 1518,
136801 /* 430 */ 1519, 1520, 1521, 1522, 1524, 1533, 1525, 1527, 1509, 1526,
136802 /* 440 */ 1528, 1531, 1530, 1526, 1532, 1534, 1535, 1536, 1538, 1428,
136803 /* 450 */ 1435, 1442, 1443, 1539, 1546, 1562,
136804 };
136805 #define YY_REDUCE_USE_DFLT (-174)
136806 #define YY_REDUCE_COUNT (324)
136807 #define YY_REDUCE_MIN (-173)
136808 #define YY_REDUCE_MAX (1293)
136809 static const short yy_reduce_ofst[] = {
136810 /* 0 */ -119, 1014, 131, 1031, -12, 225, 228, 300, -40, -45,
136811 /* 10 */ 243, 256, 293, 129, 218, 418, 79, 376, 433, 298,
136812 /* 20 */ 16, 137, 367, 323, -38, 391, -173, -173, -173, -173,
136813 /* 30 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173,
@@ -136836,60 +137121,60 @@
136836 /* 260 */ 1115, 1147, 1148, 1137, 1180, 1182, 1110, 1121, 1188, 1189,
136837 /* 270 */ 1197, 1181, 1200, 1202, 1205, 1203, 1191, 1192, 1199, 1206,
136838 /* 280 */ 1207, 1209, 1210, 1211, 1214, 1212, 1218, 1219, 1175, 1183,
136839 /* 290 */ 1185, 1184, 1186, 1190, 1187, 1196, 1237, 1193, 1253, 1194,
136840 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
136841 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216,
136842 /* 320 */ 1280, 1281, 1264, 1269, 1283,
136843 };
136844 static const YYACTIONTYPE yy_default[] = {
136845 /* 0 */ 1277, 1267, 1267, 1267, 1200, 1200, 1200, 1200, 1267, 1094,
136846 /* 10 */ 1123, 1123, 1251, 1329, 1329, 1329, 1329, 1329, 1329, 1199,
136847 /* 20 */ 1329, 1329, 1329, 1329, 1267, 1098, 1129, 1329, 1329, 1329,
136848 /* 30 */ 1329, 1201, 1202, 1329, 1329, 1329, 1250, 1252, 1139, 1138,
136849 /* 40 */ 1137, 1136, 1233, 1110, 1134, 1127, 1131, 1201, 1195, 1196,
136850 /* 50 */ 1194, 1198, 1202, 1329, 1130, 1165, 1179, 1164, 1329, 1329,
136851 /* 60 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136852 /* 70 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136853 /* 80 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136854 /* 90 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136855 /* 100 */ 1329, 1329, 1329, 1329, 1173, 1178, 1185, 1177, 1174, 1167,
136856 /* 110 */ 1166, 1168, 1169, 1329, 1017, 1065, 1329, 1329, 1329, 1170,
136857 /* 120 */ 1329, 1171, 1182, 1181, 1180, 1258, 1285, 1284, 1329, 1329,
136858 /* 130 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136859 /* 140 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136860 /* 150 */ 1329, 1329, 1329, 1329, 1329, 1277, 1267, 1023, 1023, 1329,
136861 /* 160 */ 1267, 1267, 1267, 1267, 1267, 1267, 1263, 1098, 1089, 1329,
136862 /* 170 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136863 /* 180 */ 1255, 1253, 1329, 1215, 1329, 1329, 1329, 1329, 1329, 1329,
136864 /* 190 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136865 /* 200 */ 1329, 1329, 1329, 1329, 1094, 1329, 1329, 1329, 1329, 1329,
136866 /* 210 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1279, 1329, 1228,
136867 /* 220 */ 1094, 1094, 1094, 1096, 1078, 1088, 1002, 1133, 1112, 1112,
136868 /* 230 */ 1318, 1133, 1318, 1040, 1299, 1037, 1123, 1112, 1197, 1123,
136869 /* 240 */ 1123, 1095, 1088, 1329, 1321, 1103, 1103, 1320, 1320, 1103,
136870 /* 250 */ 1144, 1068, 1133, 1074, 1074, 1074, 1074, 1103, 1014, 1133,
136871 /* 260 */ 1144, 1068, 1068, 1133, 1103, 1014, 1232, 1315, 1103, 1103,
136872 /* 270 */ 1014, 1208, 1103, 1014, 1103, 1014, 1208, 1066, 1066, 1066,
136873 /* 280 */ 1055, 1208, 1066, 1040, 1066, 1055, 1066, 1066, 1116, 1111,
136874 /* 290 */ 1116, 1111, 1116, 1111, 1116, 1111, 1103, 1203, 1103, 1329,
136875 /* 300 */ 1208, 1212, 1212, 1208, 1128, 1117, 1126, 1124, 1133, 1020,
136876 /* 310 */ 1058, 1282, 1282, 1278, 1278, 1278, 1278, 1326, 1326, 1263,
136877 /* 320 */ 1294, 1294, 1042, 1042, 1294, 1329, 1329, 1329, 1329, 1329,
136878 /* 330 */ 1329, 1289, 1329, 1217, 1329, 1329, 1329, 1329, 1329, 1329,
136879 /* 340 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136880 /* 350 */ 1329, 1329, 1150, 1329, 998, 1260, 1329, 1329, 1259, 1329,
136881 /* 360 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136882 /* 370 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1317,
136883 /* 380 */ 1329, 1329, 1329, 1329, 1329, 1329, 1231, 1230, 1329, 1329,
136884 /* 390 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136885 /* 400 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329,
136886 /* 410 */ 1329, 1080, 1329, 1329, 1329, 1303, 1329, 1329, 1329, 1329,
136887 /* 420 */ 1329, 1329, 1329, 1125, 1329, 1118, 1329, 1329, 1308, 1329,
136888 /* 430 */ 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1269,
136889 /* 440 */ 1329, 1329, 1329, 1268, 1329, 1329, 1329, 1329, 1329, 1152,
136890 /* 450 */ 1329, 1151, 1155, 1329, 1008, 1329,
136891 };
136892 /********** End of lemon-generated parsing tables *****************************/
136893
136894 /* The next table maps tokens (terminal symbols) into fallback tokens.
136895 ** If a construct like the following:
@@ -137138,333 +137423,332 @@
137138 /* 3 */ "cmd ::= BEGIN transtype trans_opt",
137139 /* 4 */ "transtype ::=",
137140 /* 5 */ "transtype ::= DEFERRED",
137141 /* 6 */ "transtype ::= IMMEDIATE",
137142 /* 7 */ "transtype ::= EXCLUSIVE",
137143 /* 8 */ "cmd ::= COMMIT trans_opt",
137144 /* 9 */ "cmd ::= END trans_opt",
137145 /* 10 */ "cmd ::= ROLLBACK trans_opt",
137146 /* 11 */ "cmd ::= SAVEPOINT nm",
137147 /* 12 */ "cmd ::= RELEASE savepoint_opt nm",
137148 /* 13 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
137149 /* 14 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
137150 /* 15 */ "createkw ::= CREATE",
137151 /* 16 */ "ifnotexists ::=",
137152 /* 17 */ "ifnotexists ::= IF NOT EXISTS",
137153 /* 18 */ "temp ::= TEMP",
137154 /* 19 */ "temp ::=",
137155 /* 20 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
137156 /* 21 */ "create_table_args ::= AS select",
137157 /* 22 */ "table_options ::=",
137158 /* 23 */ "table_options ::= WITHOUT nm",
137159 /* 24 */ "columnname ::= nm typetoken",
137160 /* 25 */ "typetoken ::=",
137161 /* 26 */ "typetoken ::= typename LP signed RP",
137162 /* 27 */ "typetoken ::= typename LP signed COMMA signed RP",
137163 /* 28 */ "typename ::= typename ID|STRING",
137164 /* 29 */ "ccons ::= CONSTRAINT nm",
137165 /* 30 */ "ccons ::= DEFAULT term",
137166 /* 31 */ "ccons ::= DEFAULT LP expr RP",
137167 /* 32 */ "ccons ::= DEFAULT PLUS term",
137168 /* 33 */ "ccons ::= DEFAULT MINUS term",
137169 /* 34 */ "ccons ::= DEFAULT ID|INDEXED",
137170 /* 35 */ "ccons ::= NOT NULL onconf",
137171 /* 36 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
137172 /* 37 */ "ccons ::= UNIQUE onconf",
137173 /* 38 */ "ccons ::= CHECK LP expr RP",
137174 /* 39 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
137175 /* 40 */ "ccons ::= defer_subclause",
137176 /* 41 */ "ccons ::= COLLATE ID|STRING",
137177 /* 42 */ "autoinc ::=",
137178 /* 43 */ "autoinc ::= AUTOINCR",
137179 /* 44 */ "refargs ::=",
137180 /* 45 */ "refargs ::= refargs refarg",
137181 /* 46 */ "refarg ::= MATCH nm",
137182 /* 47 */ "refarg ::= ON INSERT refact",
137183 /* 48 */ "refarg ::= ON DELETE refact",
137184 /* 49 */ "refarg ::= ON UPDATE refact",
137185 /* 50 */ "refact ::= SET NULL",
137186 /* 51 */ "refact ::= SET DEFAULT",
137187 /* 52 */ "refact ::= CASCADE",
137188 /* 53 */ "refact ::= RESTRICT",
137189 /* 54 */ "refact ::= NO ACTION",
137190 /* 55 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
137191 /* 56 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
137192 /* 57 */ "init_deferred_pred_opt ::=",
137193 /* 58 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
137194 /* 59 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
137195 /* 60 */ "conslist_opt ::=",
137196 /* 61 */ "tconscomma ::= COMMA",
137197 /* 62 */ "tcons ::= CONSTRAINT nm",
137198 /* 63 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
137199 /* 64 */ "tcons ::= UNIQUE LP sortlist RP onconf",
137200 /* 65 */ "tcons ::= CHECK LP expr RP onconf",
137201 /* 66 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
137202 /* 67 */ "defer_subclause_opt ::=",
137203 /* 68 */ "onconf ::=",
137204 /* 69 */ "onconf ::= ON CONFLICT resolvetype",
137205 /* 70 */ "orconf ::=",
137206 /* 71 */ "orconf ::= OR resolvetype",
137207 /* 72 */ "resolvetype ::= IGNORE",
137208 /* 73 */ "resolvetype ::= REPLACE",
137209 /* 74 */ "cmd ::= DROP TABLE ifexists fullname",
137210 /* 75 */ "ifexists ::= IF EXISTS",
137211 /* 76 */ "ifexists ::=",
137212 /* 77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
137213 /* 78 */ "cmd ::= DROP VIEW ifexists fullname",
137214 /* 79 */ "cmd ::= select",
137215 /* 80 */ "select ::= with selectnowith",
137216 /* 81 */ "selectnowith ::= selectnowith multiselect_op oneselect",
137217 /* 82 */ "multiselect_op ::= UNION",
137218 /* 83 */ "multiselect_op ::= UNION ALL",
137219 /* 84 */ "multiselect_op ::= EXCEPT|INTERSECT",
137220 /* 85 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
137221 /* 86 */ "values ::= VALUES LP nexprlist RP",
137222 /* 87 */ "values ::= values COMMA LP exprlist RP",
137223 /* 88 */ "distinct ::= DISTINCT",
137224 /* 89 */ "distinct ::= ALL",
137225 /* 90 */ "distinct ::=",
137226 /* 91 */ "sclp ::=",
137227 /* 92 */ "selcollist ::= sclp expr as",
137228 /* 93 */ "selcollist ::= sclp STAR",
137229 /* 94 */ "selcollist ::= sclp nm DOT STAR",
137230 /* 95 */ "as ::= AS nm",
137231 /* 96 */ "as ::=",
137232 /* 97 */ "from ::=",
137233 /* 98 */ "from ::= FROM seltablist",
137234 /* 99 */ "stl_prefix ::= seltablist joinop",
137235 /* 100 */ "stl_prefix ::=",
137236 /* 101 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
137237 /* 102 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
137238 /* 103 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
137239 /* 104 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
137240 /* 105 */ "dbnm ::=",
137241 /* 106 */ "dbnm ::= DOT nm",
137242 /* 107 */ "fullname ::= nm dbnm",
137243 /* 108 */ "joinop ::= COMMA|JOIN",
137244 /* 109 */ "joinop ::= JOIN_KW JOIN",
137245 /* 110 */ "joinop ::= JOIN_KW nm JOIN",
137246 /* 111 */ "joinop ::= JOIN_KW nm nm JOIN",
137247 /* 112 */ "on_opt ::= ON expr",
137248 /* 113 */ "on_opt ::=",
137249 /* 114 */ "indexed_opt ::=",
137250 /* 115 */ "indexed_opt ::= INDEXED BY nm",
137251 /* 116 */ "indexed_opt ::= NOT INDEXED",
137252 /* 117 */ "using_opt ::= USING LP idlist RP",
137253 /* 118 */ "using_opt ::=",
137254 /* 119 */ "orderby_opt ::=",
137255 /* 120 */ "orderby_opt ::= ORDER BY sortlist",
137256 /* 121 */ "sortlist ::= sortlist COMMA expr sortorder",
137257 /* 122 */ "sortlist ::= expr sortorder",
137258 /* 123 */ "sortorder ::= ASC",
137259 /* 124 */ "sortorder ::= DESC",
137260 /* 125 */ "sortorder ::=",
137261 /* 126 */ "groupby_opt ::=",
137262 /* 127 */ "groupby_opt ::= GROUP BY nexprlist",
137263 /* 128 */ "having_opt ::=",
137264 /* 129 */ "having_opt ::= HAVING expr",
137265 /* 130 */ "limit_opt ::=",
137266 /* 131 */ "limit_opt ::= LIMIT expr",
137267 /* 132 */ "limit_opt ::= LIMIT expr OFFSET expr",
137268 /* 133 */ "limit_opt ::= LIMIT expr COMMA expr",
137269 /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
137270 /* 135 */ "where_opt ::=",
137271 /* 136 */ "where_opt ::= WHERE expr",
137272 /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
137273 /* 138 */ "setlist ::= setlist COMMA nm EQ expr",
137274 /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
137275 /* 140 */ "setlist ::= nm EQ expr",
137276 /* 141 */ "setlist ::= LP idlist RP EQ expr",
137277 /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
137278 /* 143 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
137279 /* 144 */ "insert_cmd ::= INSERT orconf",
137280 /* 145 */ "insert_cmd ::= REPLACE",
137281 /* 146 */ "idlist_opt ::=",
137282 /* 147 */ "idlist_opt ::= LP idlist RP",
137283 /* 148 */ "idlist ::= idlist COMMA nm",
137284 /* 149 */ "idlist ::= nm",
137285 /* 150 */ "expr ::= LP expr RP",
137286 /* 151 */ "term ::= NULL",
137287 /* 152 */ "expr ::= ID|INDEXED",
137288 /* 153 */ "expr ::= JOIN_KW",
137289 /* 154 */ "expr ::= nm DOT nm",
137290 /* 155 */ "expr ::= nm DOT nm DOT nm",
137291 /* 156 */ "term ::= FLOAT|BLOB",
137292 /* 157 */ "term ::= STRING",
137293 /* 158 */ "term ::= INTEGER",
137294 /* 159 */ "expr ::= VARIABLE",
137295 /* 160 */ "expr ::= expr COLLATE ID|STRING",
137296 /* 161 */ "expr ::= CAST LP expr AS typetoken RP",
137297 /* 162 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
137298 /* 163 */ "expr ::= ID|INDEXED LP STAR RP",
137299 /* 164 */ "term ::= CTIME_KW",
137300 /* 165 */ "expr ::= LP nexprlist COMMA expr RP",
137301 /* 166 */ "expr ::= expr AND expr",
137302 /* 167 */ "expr ::= expr OR expr",
137303 /* 168 */ "expr ::= expr LT|GT|GE|LE expr",
137304 /* 169 */ "expr ::= expr EQ|NE expr",
137305 /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
137306 /* 171 */ "expr ::= expr PLUS|MINUS expr",
137307 /* 172 */ "expr ::= expr STAR|SLASH|REM expr",
137308 /* 173 */ "expr ::= expr CONCAT expr",
137309 /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
137310 /* 175 */ "expr ::= expr likeop expr",
137311 /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
137312 /* 177 */ "expr ::= expr ISNULL|NOTNULL",
137313 /* 178 */ "expr ::= expr NOT NULL",
137314 /* 179 */ "expr ::= expr IS expr",
137315 /* 180 */ "expr ::= expr IS NOT expr",
137316 /* 181 */ "expr ::= NOT expr",
137317 /* 182 */ "expr ::= BITNOT expr",
137318 /* 183 */ "expr ::= MINUS expr",
137319 /* 184 */ "expr ::= PLUS expr",
137320 /* 185 */ "between_op ::= BETWEEN",
137321 /* 186 */ "between_op ::= NOT BETWEEN",
137322 /* 187 */ "expr ::= expr between_op expr AND expr",
137323 /* 188 */ "in_op ::= IN",
137324 /* 189 */ "in_op ::= NOT IN",
137325 /* 190 */ "expr ::= expr in_op LP exprlist RP",
137326 /* 191 */ "expr ::= LP select RP",
137327 /* 192 */ "expr ::= expr in_op LP select RP",
137328 /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
137329 /* 194 */ "expr ::= EXISTS LP select RP",
137330 /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
137331 /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
137332 /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
137333 /* 198 */ "case_else ::= ELSE expr",
137334 /* 199 */ "case_else ::=",
137335 /* 200 */ "case_operand ::= expr",
137336 /* 201 */ "case_operand ::=",
137337 /* 202 */ "exprlist ::=",
137338 /* 203 */ "nexprlist ::= nexprlist COMMA expr",
137339 /* 204 */ "nexprlist ::= expr",
137340 /* 205 */ "paren_exprlist ::=",
137341 /* 206 */ "paren_exprlist ::= LP exprlist RP",
137342 /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
137343 /* 208 */ "uniqueflag ::= UNIQUE",
137344 /* 209 */ "uniqueflag ::=",
137345 /* 210 */ "eidlist_opt ::=",
137346 /* 211 */ "eidlist_opt ::= LP eidlist RP",
137347 /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
137348 /* 213 */ "eidlist ::= nm collate sortorder",
137349 /* 214 */ "collate ::=",
137350 /* 215 */ "collate ::= COLLATE ID|STRING",
137351 /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
137352 /* 217 */ "cmd ::= VACUUM",
137353 /* 218 */ "cmd ::= VACUUM nm",
137354 /* 219 */ "cmd ::= PRAGMA nm dbnm",
137355 /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
137356 /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
137357 /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
137358 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137359 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
137360 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
137361 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137362 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137363 /* 228 */ "trigger_time ::= BEFORE|AFTER",
137364 /* 229 */ "trigger_time ::= INSTEAD OF",
137365 /* 230 */ "trigger_time ::=",
137366 /* 231 */ "trigger_event ::= DELETE|INSERT",
137367 /* 232 */ "trigger_event ::= UPDATE",
137368 /* 233 */ "trigger_event ::= UPDATE OF idlist",
137369 /* 234 */ "when_clause ::=",
137370 /* 235 */ "when_clause ::= WHEN expr",
137371 /* 236 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137372 /* 237 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137373 /* 238 */ "trnm ::= nm DOT nm",
137374 /* 239 */ "tridxby ::= INDEXED BY nm",
137375 /* 240 */ "tridxby ::= NOT INDEXED",
137376 /* 241 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137377 /* 242 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137378 /* 243 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137379 /* 244 */ "trigger_cmd ::= select",
137380 /* 245 */ "expr ::= RAISE LP IGNORE RP",
137381 /* 246 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137382 /* 247 */ "raisetype ::= ROLLBACK",
137383 /* 248 */ "raisetype ::= ABORT",
137384 /* 249 */ "raisetype ::= FAIL",
137385 /* 250 */ "cmd ::= DROP TRIGGER ifexists fullname",
137386 /* 251 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137387 /* 252 */ "cmd ::= DETACH database_kw_opt expr",
137388 /* 253 */ "key_opt ::=",
137389 /* 254 */ "key_opt ::= KEY expr",
137390 /* 255 */ "cmd ::= REINDEX",
137391 /* 256 */ "cmd ::= REINDEX nm dbnm",
137392 /* 257 */ "cmd ::= ANALYZE",
137393 /* 258 */ "cmd ::= ANALYZE nm dbnm",
137394 /* 259 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137395 /* 260 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137396 /* 261 */ "add_column_fullname ::= fullname",
137397 /* 262 */ "cmd ::= create_vtab",
137398 /* 263 */ "cmd ::= create_vtab LP vtabarglist RP",
137399 /* 264 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137400 /* 265 */ "vtabarg ::=",
137401 /* 266 */ "vtabargtoken ::= ANY",
137402 /* 267 */ "vtabargtoken ::= lp anylist RP",
137403 /* 268 */ "lp ::= LP",
137404 /* 269 */ "with ::=",
137405 /* 270 */ "with ::= WITH wqlist",
137406 /* 271 */ "with ::= WITH RECURSIVE wqlist",
137407 /* 272 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137408 /* 273 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137409 /* 274 */ "input ::= cmdlist",
137410 /* 275 */ "cmdlist ::= cmdlist ecmd",
137411 /* 276 */ "cmdlist ::= ecmd",
137412 /* 277 */ "ecmd ::= SEMI",
137413 /* 278 */ "ecmd ::= explain cmdx SEMI",
137414 /* 279 */ "explain ::=",
137415 /* 280 */ "trans_opt ::=",
137416 /* 281 */ "trans_opt ::= TRANSACTION",
137417 /* 282 */ "trans_opt ::= TRANSACTION nm",
137418 /* 283 */ "savepoint_opt ::= SAVEPOINT",
137419 /* 284 */ "savepoint_opt ::=",
137420 /* 285 */ "cmd ::= create_table create_table_args",
137421 /* 286 */ "columnlist ::= columnlist COMMA columnname carglist",
137422 /* 287 */ "columnlist ::= columnname carglist",
137423 /* 288 */ "nm ::= ID|INDEXED",
137424 /* 289 */ "nm ::= STRING",
137425 /* 290 */ "nm ::= JOIN_KW",
137426 /* 291 */ "typetoken ::= typename",
137427 /* 292 */ "typename ::= ID|STRING",
137428 /* 293 */ "signed ::= plus_num",
137429 /* 294 */ "signed ::= minus_num",
137430 /* 295 */ "carglist ::= carglist ccons",
137431 /* 296 */ "carglist ::=",
137432 /* 297 */ "ccons ::= NULL onconf",
137433 /* 298 */ "conslist_opt ::= COMMA conslist",
137434 /* 299 */ "conslist ::= conslist tconscomma tcons",
137435 /* 300 */ "conslist ::= tcons",
137436 /* 301 */ "tconscomma ::=",
137437 /* 302 */ "defer_subclause_opt ::= defer_subclause",
137438 /* 303 */ "resolvetype ::= raisetype",
137439 /* 304 */ "selectnowith ::= oneselect",
137440 /* 305 */ "oneselect ::= values",
137441 /* 306 */ "sclp ::= selcollist COMMA",
137442 /* 307 */ "as ::= ID|STRING",
137443 /* 308 */ "expr ::= term",
137444 /* 309 */ "likeop ::= LIKE_KW|MATCH",
137445 /* 310 */ "exprlist ::= nexprlist",
137446 /* 311 */ "nmnum ::= plus_num",
137447 /* 312 */ "nmnum ::= nm",
137448 /* 313 */ "nmnum ::= ON",
137449 /* 314 */ "nmnum ::= DELETE",
137450 /* 315 */ "nmnum ::= DEFAULT",
137451 /* 316 */ "plus_num ::= INTEGER|FLOAT",
137452 /* 317 */ "foreach_clause ::=",
137453 /* 318 */ "foreach_clause ::= FOR EACH ROW",
137454 /* 319 */ "trnm ::= nm",
137455 /* 320 */ "tridxby ::=",
137456 /* 321 */ "database_kw_opt ::= DATABASE",
137457 /* 322 */ "database_kw_opt ::=",
137458 /* 323 */ "kwcolumn_opt ::=",
137459 /* 324 */ "kwcolumn_opt ::= COLUMNKW",
137460 /* 325 */ "vtabarglist ::= vtabarg",
137461 /* 326 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137462 /* 327 */ "vtabarg ::= vtabarg vtabargtoken",
137463 /* 328 */ "anylist ::=",
137464 /* 329 */ "anylist ::= anylist LP anylist RP",
137465 /* 330 */ "anylist ::= anylist ANY",
137466 };
137467 #endif /* NDEBUG */
137468
137469
137470 #if YYSTACKDEPTH<=0
@@ -137529,11 +137813,13 @@
137529 pParser->yyerrcnt = -1;
137530 #endif
137531 pParser->yytos = pParser->yystack;
137532 pParser->yystack[0].stateno = 0;
137533 pParser->yystack[0].major = 0;
 
137534 pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
 
137535 }
137536
137537 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137538 /*
137539 ** This function allocates a new parser.
@@ -137911,11 +138197,10 @@
137911 { 149, -3 },
137912 { 150, 0 },
137913 { 150, -1 },
137914 { 150, -1 },
137915 { 150, -1 },
137916 { 149, -2 },
137917 { 149, -2 },
137918 { 149, -2 },
137919 { 149, -2 },
137920 { 149, -3 },
137921 { 149, -5 },
@@ -138317,256 +138602,253 @@
138317 case 5: /* transtype ::= DEFERRED */
138318 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
138319 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
138320 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
138321 break;
138322 case 8: /* cmd ::= COMMIT trans_opt */
138323 case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9);
138324 {sqlite3CommitTransaction(pParse);}
138325 break;
138326 case 10: /* cmd ::= ROLLBACK trans_opt */
138327 {sqlite3RollbackTransaction(pParse);}
138328 break;
138329 case 11: /* cmd ::= SAVEPOINT nm */
138330 {
138331 sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);
138332 }
138333 break;
138334 case 12: /* cmd ::= RELEASE savepoint_opt nm */
138335 {
138336 sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);
138337 }
138338 break;
138339 case 13: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
138340 {
138341 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
138342 }
138343 break;
138344 case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
138345 {
138346 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
138347 }
138348 break;
138349 case 15: /* createkw ::= CREATE */
138350 {disableLookaside(pParse);}
138351 break;
138352 case 16: /* ifnotexists ::= */
138353 case 19: /* temp ::= */ yytestcase(yyruleno==19);
138354 case 22: /* table_options ::= */ yytestcase(yyruleno==22);
138355 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
138356 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
138357 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
138358 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
138359 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
138360 case 214: /* collate ::= */ yytestcase(yyruleno==214);
138361 {yymsp[1].minor.yy194 = 0;}
138362 break;
138363 case 17: /* ifnotexists ::= IF NOT EXISTS */
138364 {yymsp[-2].minor.yy194 = 1;}
138365 break;
138366 case 18: /* temp ::= TEMP */
138367 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
138368 {yymsp[0].minor.yy194 = 1;}
138369 break;
138370 case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
138371 {
138372 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
138373 }
138374 break;
138375 case 21: /* create_table_args ::= AS select */
138376 {
138377 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
138378 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138379 }
138380 break;
138381 case 23: /* table_options ::= WITHOUT nm */
138382 {
138383 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
138384 yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
138385 }else{
138386 yymsp[-1].minor.yy194 = 0;
138387 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
138388 }
138389 }
138390 break;
138391 case 24: /* columnname ::= nm typetoken */
138392 {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
138393 break;
138394 case 25: /* typetoken ::= */
138395 case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
138396 case 96: /* as ::= */ yytestcase(yyruleno==96);
138397 {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
138398 break;
138399 case 26: /* typetoken ::= typename LP signed RP */
138400 {
138401 yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
138402 }
138403 break;
138404 case 27: /* typetoken ::= typename LP signed COMMA signed RP */
138405 {
138406 yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
138407 }
138408 break;
138409 case 28: /* typename ::= typename ID|STRING */
138410 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
138411 break;
138412 case 29: /* ccons ::= CONSTRAINT nm */
138413 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
138414 {pParse->constraintName = yymsp[0].minor.yy0;}
138415 break;
138416 case 30: /* ccons ::= DEFAULT term */
138417 case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32);
138418 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
138419 break;
138420 case 31: /* ccons ::= DEFAULT LP expr RP */
138421 {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
138422 break;
138423 case 33: /* ccons ::= DEFAULT MINUS term */
138424 {
138425 ExprSpan v;
138426 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0);
138427 v.zStart = yymsp[-1].minor.yy0.z;
138428 v.zEnd = yymsp[0].minor.yy190.zEnd;
138429 sqlite3AddDefaultValue(pParse,&v);
138430 }
138431 break;
138432 case 34: /* ccons ::= DEFAULT ID|INDEXED */
138433 {
138434 ExprSpan v;
138435 spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
138436 sqlite3AddDefaultValue(pParse,&v);
138437 }
138438 break;
138439 case 35: /* ccons ::= NOT NULL onconf */
138440 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
138441 break;
138442 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
138443 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
138444 break;
138445 case 37: /* ccons ::= UNIQUE onconf */
138446 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
138447 SQLITE_IDXTYPE_UNIQUE);}
138448 break;
138449 case 38: /* ccons ::= CHECK LP expr RP */
138450 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
138451 break;
138452 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
138453 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
138454 break;
138455 case 40: /* ccons ::= defer_subclause */
138456 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
138457 break;
138458 case 41: /* ccons ::= COLLATE ID|STRING */
138459 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
138460 break;
138461 case 44: /* refargs ::= */
138462 { yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
138463 break;
138464 case 45: /* refargs ::= refargs refarg */
138465 { yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
138466 break;
138467 case 46: /* refarg ::= MATCH nm */
138468 { yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
138469 break;
138470 case 47: /* refarg ::= ON INSERT refact */
138471 { yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
138472 break;
138473 case 48: /* refarg ::= ON DELETE refact */
138474 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
138475 break;
138476 case 49: /* refarg ::= ON UPDATE refact */
138477 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
138478 break;
138479 case 50: /* refact ::= SET NULL */
138480 { yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
138481 break;
138482 case 51: /* refact ::= SET DEFAULT */
138483 { yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
138484 break;
138485 case 52: /* refact ::= CASCADE */
138486 { yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
138487 break;
138488 case 53: /* refact ::= RESTRICT */
138489 { yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
138490 break;
138491 case 54: /* refact ::= NO ACTION */
138492 { yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
138493 break;
138494 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
138495 {yymsp[-2].minor.yy194 = 0;}
138496 break;
138497 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
138498 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
138499 case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
138500 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
138501 break;
138502 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
138503 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
138504 case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
138505 case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
138506 case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
138507 {yymsp[-1].minor.yy194 = 1;}
138508 break;
138509 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
138510 {yymsp[-1].minor.yy194 = 0;}
138511 break;
138512 case 61: /* tconscomma ::= COMMA */
138513 {pParse->constraintName.n = 0;}
138514 break;
138515 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
138516 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
138517 break;
138518 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
138519 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
138520 SQLITE_IDXTYPE_UNIQUE);}
138521 break;
138522 case 65: /* tcons ::= CHECK LP expr RP onconf */
138523 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
138524 break;
138525 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
138526 {
138527 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
138528 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
138529 }
138530 break;
138531 case 68: /* onconf ::= */
138532 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
138533 {yymsp[1].minor.yy194 = OE_Default;}
138534 break;
138535 case 69: /* onconf ::= ON CONFLICT resolvetype */
138536 {yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
138537 break;
138538 case 72: /* resolvetype ::= IGNORE */
138539 {yymsp[0].minor.yy194 = OE_Ignore;}
138540 break;
138541 case 73: /* resolvetype ::= REPLACE */
138542 case 145: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==145);
138543 {yymsp[0].minor.yy194 = OE_Replace;}
138544 break;
138545 case 74: /* cmd ::= DROP TABLE ifexists fullname */
138546 {
138547 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
138548 }
138549 break;
138550 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
138551 {
138552 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
138553 }
138554 break;
138555 case 78: /* cmd ::= DROP VIEW ifexists fullname */
138556 {
138557 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
138558 }
138559 break;
138560 case 79: /* cmd ::= select */
138561 {
138562 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
138563 sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
138564 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138565 }
138566 break;
138567 case 80: /* select ::= with selectnowith */
138568 {
138569 Select *p = yymsp[0].minor.yy243;
138570 if( p ){
138571 p->pWith = yymsp[-1].minor.yy285;
138572 parserDoubleLinkSelect(pParse, p);
@@ -138574,11 +138856,11 @@
138574 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
138575 }
138576 yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
138577 }
138578 break;
138579 case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
138580 {
138581 Select *pRhs = yymsp[0].minor.yy243;
138582 Select *pLhs = yymsp[-2].minor.yy243;
138583 if( pRhs && pRhs->pPrior ){
138584 SrcList *pFrom;
@@ -138598,18 +138880,18 @@
138598 sqlite3SelectDelete(pParse->db, pLhs);
138599 }
138600 yymsp[-2].minor.yy243 = pRhs;
138601 }
138602 break;
138603 case 82: /* multiselect_op ::= UNION */
138604 case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
138605 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
138606 break;
138607 case 83: /* multiselect_op ::= UNION ALL */
138608 {yymsp[-1].minor.yy194 = TK_ALL;}
138609 break;
138610 case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
138611 {
138612 #if SELECTTRACE_ENABLED
138613 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
138614 #endif
138615 yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
@@ -138637,16 +138919,16 @@
138637 }
138638 }
138639 #endif /* SELECTRACE_ENABLED */
138640 }
138641 break;
138642 case 86: /* values ::= VALUES LP nexprlist RP */
138643 {
138644 yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
138645 }
138646 break;
138647 case 87: /* values ::= values COMMA LP exprlist RP */
138648 {
138649 Select *pRight, *pLeft = yymsp[-4].minor.yy243;
138650 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
138651 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
138652 if( pRight ){
@@ -138656,86 +138938,86 @@
138656 }else{
138657 yymsp[-4].minor.yy243 = pLeft;
138658 }
138659 }
138660 break;
138661 case 88: /* distinct ::= DISTINCT */
138662 {yymsp[0].minor.yy194 = SF_Distinct;}
138663 break;
138664 case 89: /* distinct ::= ALL */
138665 {yymsp[0].minor.yy194 = SF_All;}
138666 break;
138667 case 91: /* sclp ::= */
138668 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
138669 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
138670 case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
138671 case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
138672 case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
138673 {yymsp[1].minor.yy148 = 0;}
138674 break;
138675 case 92: /* selcollist ::= sclp expr as */
138676 {
138677 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
138678 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
138679 sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
138680 }
138681 break;
138682 case 93: /* selcollist ::= sclp STAR */
138683 {
138684 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
138685 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
138686 }
138687 break;
138688 case 94: /* selcollist ::= sclp nm DOT STAR */
138689 {
138690 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
138691 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138692 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
138693 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
138694 }
138695 break;
138696 case 95: /* as ::= AS nm */
138697 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
138698 case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
138699 case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
138700 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
138701 break;
138702 case 97: /* from ::= */
138703 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
138704 break;
138705 case 98: /* from ::= FROM seltablist */
138706 {
138707 yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
138708 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
138709 }
138710 break;
138711 case 99: /* stl_prefix ::= seltablist joinop */
138712 {
138713 if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
138714 }
138715 break;
138716 case 100: /* stl_prefix ::= */
138717 {yymsp[1].minor.yy185 = 0;}
138718 break;
138719 case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
138720 {
138721 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138722 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
138723 }
138724 break;
138725 case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
138726 {
138727 yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138728 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
138729 }
138730 break;
138731 case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
138732 {
138733 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138734 }
138735 break;
138736 case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
138737 {
138738 if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
138739 yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
138740 }else if( yymsp[-4].minor.yy185->nSrc==1 ){
138741 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
@@ -138755,191 +139037,191 @@
138755 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
138756 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
138757 }
138758 }
138759 break;
138760 case 105: /* dbnm ::= */
138761 case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
138762 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
138763 break;
138764 case 107: /* fullname ::= nm dbnm */
138765 {yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
138766 break;
138767 case 108: /* joinop ::= COMMA|JOIN */
138768 { yymsp[0].minor.yy194 = JT_INNER; }
138769 break;
138770 case 109: /* joinop ::= JOIN_KW JOIN */
138771 {yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
138772 break;
138773 case 110: /* joinop ::= JOIN_KW nm JOIN */
138774 {yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
138775 break;
138776 case 111: /* joinop ::= JOIN_KW nm nm JOIN */
138777 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
138778 break;
138779 case 112: /* on_opt ::= ON expr */
138780 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
138781 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
138782 case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
138783 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
138784 break;
138785 case 113: /* on_opt ::= */
138786 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
138787 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
138788 case 199: /* case_else ::= */ yytestcase(yyruleno==199);
138789 case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
138790 {yymsp[1].minor.yy72 = 0;}
138791 break;
138792 case 115: /* indexed_opt ::= INDEXED BY nm */
138793 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
138794 break;
138795 case 116: /* indexed_opt ::= NOT INDEXED */
138796 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
138797 break;
138798 case 117: /* using_opt ::= USING LP idlist RP */
138799 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
138800 break;
138801 case 118: /* using_opt ::= */
138802 case 146: /* idlist_opt ::= */ yytestcase(yyruleno==146);
138803 {yymsp[1].minor.yy254 = 0;}
138804 break;
138805 case 120: /* orderby_opt ::= ORDER BY sortlist */
138806 case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
138807 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
138808 break;
138809 case 121: /* sortlist ::= sortlist COMMA expr sortorder */
138810 {
138811 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
138812 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
138813 }
138814 break;
138815 case 122: /* sortlist ::= expr sortorder */
138816 {
138817 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
138818 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
138819 }
138820 break;
138821 case 123: /* sortorder ::= ASC */
138822 {yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
138823 break;
138824 case 124: /* sortorder ::= DESC */
138825 {yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
138826 break;
138827 case 125: /* sortorder ::= */
138828 {yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
138829 break;
138830 case 130: /* limit_opt ::= */
138831 {yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
138832 break;
138833 case 131: /* limit_opt ::= LIMIT expr */
138834 {yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
138835 break;
138836 case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
138837 {yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
138838 break;
138839 case 133: /* limit_opt ::= LIMIT expr COMMA expr */
138840 {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
138841 break;
138842 case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
138843 {
138844 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
138845 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
138846 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
138847 }
138848 break;
138849 case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
138850 {
138851 sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
138852 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
138853 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
138854 sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
138855 }
138856 break;
138857 case 138: /* setlist ::= setlist COMMA nm EQ expr */
138858 {
138859 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
138860 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
138861 }
138862 break;
138863 case 139: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
138864 {
138865 yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
138866 }
138867 break;
138868 case 140: /* setlist ::= nm EQ expr */
138869 {
138870 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
138871 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
138872 }
138873 yymsp[-2].minor.yy148 = yylhsminor.yy148;
138874 break;
138875 case 141: /* setlist ::= LP idlist RP EQ expr */
138876 {
138877 yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
138878 }
138879 break;
138880 case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
138881 {
138882 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
138883 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
138884 }
138885 break;
138886 case 143: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
138887 {
138888 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
138889 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
138890 }
138891 break;
138892 case 147: /* idlist_opt ::= LP idlist RP */
138893 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
138894 break;
138895 case 148: /* idlist ::= idlist COMMA nm */
138896 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
138897 break;
138898 case 149: /* idlist ::= nm */
138899 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
138900 break;
138901 case 150: /* expr ::= LP expr RP */
138902 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
138903 break;
138904 case 151: /* term ::= NULL */
138905 case 156: /* term ::= FLOAT|BLOB */ yytestcase(yyruleno==156);
138906 case 157: /* term ::= STRING */ yytestcase(yyruleno==157);
138907 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
138908 break;
138909 case 152: /* expr ::= ID|INDEXED */
138910 case 153: /* expr ::= JOIN_KW */ yytestcase(yyruleno==153);
138911 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
138912 break;
138913 case 154: /* expr ::= nm DOT nm */
138914 {
138915 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138916 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
138917 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138918 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
138919 }
138920 break;
138921 case 155: /* expr ::= nm DOT nm DOT nm */
138922 {
138923 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
138924 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138925 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
138926 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
138927 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138928 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
138929 }
138930 break;
138931 case 158: /* term ::= INTEGER */
138932 {
138933 yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
138934 yylhsminor.yy190.zStart = yymsp[0].minor.yy0.z;
138935 yylhsminor.yy190.zEnd = yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n;
138936 if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf|EP_Resolved;
138937 }
138938 yymsp[0].minor.yy190 = yylhsminor.yy190;
138939 break;
138940 case 159: /* expr ::= VARIABLE */
138941 {
138942 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
138943 u32 n = yymsp[0].minor.yy0.n;
138944 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
138945 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n);
@@ -138958,24 +139240,24 @@
138958 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
138959 }
138960 }
138961 }
138962 break;
138963 case 160: /* expr ::= expr COLLATE ID|STRING */
138964 {
138965 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
138966 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
138967 }
138968 break;
138969 case 161: /* expr ::= CAST LP expr AS typetoken RP */
138970 {
138971 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138972 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
138973 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, 0);
138974 }
138975 break;
138976 case 162: /* expr ::= ID|INDEXED LP distinct exprlist RP */
138977 {
138978 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
138979 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
138980 }
138981 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -138984,25 +139266,25 @@
138984 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
138985 }
138986 }
138987 yymsp[-4].minor.yy190 = yylhsminor.yy190;
138988 break;
138989 case 163: /* expr ::= ID|INDEXED LP STAR RP */
138990 {
138991 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
138992 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
138993 }
138994 yymsp[-3].minor.yy190 = yylhsminor.yy190;
138995 break;
138996 case 164: /* term ::= CTIME_KW */
138997 {
138998 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
138999 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
139000 }
139001 yymsp[0].minor.yy190 = yylhsminor.yy190;
139002 break;
139003 case 165: /* expr ::= LP nexprlist COMMA expr RP */
139004 {
139005 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
139006 yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
139007 if( yylhsminor.yy190.pExpr ){
139008 yylhsminor.yy190.pExpr->x.pList = pList;
@@ -139011,24 +139293,24 @@
139011 sqlite3ExprListDelete(pParse->db, pList);
139012 }
139013 }
139014 yymsp[-4].minor.yy190 = yylhsminor.yy190;
139015 break;
139016 case 166: /* expr ::= expr AND expr */
139017 case 167: /* expr ::= expr OR expr */ yytestcase(yyruleno==167);
139018 case 168: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==168);
139019 case 169: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==169);
139020 case 170: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==170);
139021 case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
139022 case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
139023 case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
139024 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
139025 break;
139026 case 174: /* likeop ::= NOT LIKE_KW|MATCH */
139027 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
139028 break;
139029 case 175: /* expr ::= expr likeop expr */
139030 {
139031 ExprList *pList;
139032 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
139033 yymsp[-1].minor.yy0.n &= 0x7fffffff;
139034 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -139037,11 +139319,11 @@
139037 exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
139038 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139039 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
139040 }
139041 break;
139042 case 176: /* expr ::= expr likeop expr ESCAPE expr */
139043 {
139044 ExprList *pList;
139045 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
139046 yymsp[-3].minor.yy0.n &= 0x7fffffff;
139047 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -139051,43 +139333,43 @@
139051 exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
139052 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139053 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
139054 }
139055 break;
139056 case 177: /* expr ::= expr ISNULL|NOTNULL */
139057 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
139058 break;
139059 case 178: /* expr ::= expr NOT NULL */
139060 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
139061 break;
139062 case 179: /* expr ::= expr IS expr */
139063 {
139064 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
139065 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
139066 }
139067 break;
139068 case 180: /* expr ::= expr IS NOT expr */
139069 {
139070 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
139071 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
139072 }
139073 break;
139074 case 181: /* expr ::= NOT expr */
139075 case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
139076 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139077 break;
139078 case 183: /* expr ::= MINUS expr */
139079 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139080 break;
139081 case 184: /* expr ::= PLUS expr */
139082 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139083 break;
139084 case 185: /* between_op ::= BETWEEN */
139085 case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
139086 {yymsp[0].minor.yy194 = 0;}
139087 break;
139088 case 187: /* expr ::= expr between_op expr AND expr */
139089 {
139090 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139091 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
139092 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
139093 if( yymsp[-4].minor.yy190.pExpr ){
@@ -139097,11 +139379,11 @@
139097 }
139098 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139099 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139100 }
139101 break;
139102 case 190: /* expr ::= expr in_op LP exprlist RP */
139103 {
139104 if( yymsp[-1].minor.yy148==0 ){
139105 /* Expressions of the form
139106 **
139107 ** expr1 IN ()
@@ -139150,26 +139432,26 @@
139150 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139151 }
139152 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139153 }
139154 break;
139155 case 191: /* expr ::= LP select RP */
139156 {
139157 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139158 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
139159 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139160 }
139161 break;
139162 case 192: /* expr ::= expr in_op LP select RP */
139163 {
139164 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
139165 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139166 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139167 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139168 }
139169 break;
139170 case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
139171 {
139172 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
139173 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
139174 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
139175 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -139176,19 +139458,19 @@
139176 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
139177 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139178 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
139179 }
139180 break;
139181 case 194: /* expr ::= EXISTS LP select RP */
139182 {
139183 Expr *p;
139184 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139185 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
139186 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
139187 }
139188 break;
139189 case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
139190 {
139191 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
139192 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
139193 if( yymsp[-4].minor.yy190.pExpr ){
139194 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -139197,332 +139479,332 @@
139197 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
139198 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
139199 }
139200 }
139201 break;
139202 case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
139203 {
139204 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
139205 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
139206 }
139207 break;
139208 case 197: /* case_exprlist ::= WHEN expr THEN expr */
139209 {
139210 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139211 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
139212 }
139213 break;
139214 case 200: /* case_operand ::= expr */
139215 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
139216 break;
139217 case 203: /* nexprlist ::= nexprlist COMMA expr */
139218 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
139219 break;
139220 case 204: /* nexprlist ::= expr */
139221 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
139222 break;
139223 case 206: /* paren_exprlist ::= LP exprlist RP */
139224 case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
139225 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
139226 break;
139227 case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
139228 {
139229 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
139230 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139231 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139232 }
139233 break;
139234 case 208: /* uniqueflag ::= UNIQUE */
139235 case 248: /* raisetype ::= ABORT */ yytestcase(yyruleno==248);
139236 {yymsp[0].minor.yy194 = OE_Abort;}
139237 break;
139238 case 209: /* uniqueflag ::= */
139239 {yymsp[1].minor.yy194 = OE_None;}
139240 break;
139241 case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
139242 {
139243 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
139244 }
139245 break;
139246 case 213: /* eidlist ::= nm collate sortorder */
139247 {
139248 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
139249 }
139250 break;
139251 case 216: /* cmd ::= DROP INDEX ifexists fullname */
139252 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
139253 break;
139254 case 217: /* cmd ::= VACUUM */
139255 {sqlite3Vacuum(pParse,0);}
139256 break;
139257 case 218: /* cmd ::= VACUUM nm */
139258 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
139259 break;
139260 case 219: /* cmd ::= PRAGMA nm dbnm */
139261 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
139262 break;
139263 case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
139264 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
139265 break;
139266 case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
139267 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
139268 break;
139269 case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
139270 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
139271 break;
139272 case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
139273 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
139274 break;
139275 case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
139276 {
139277 Token all;
139278 all.z = yymsp[-3].minor.yy0.z;
139279 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
139280 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
139281 }
139282 break;
139283 case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
139284 {
139285 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139286 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139287 }
139288 break;
139289 case 228: /* trigger_time ::= BEFORE|AFTER */
139290 { yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139291 break;
139292 case 229: /* trigger_time ::= INSTEAD OF */
139293 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
139294 break;
139295 case 230: /* trigger_time ::= */
139296 { yymsp[1].minor.yy194 = TK_BEFORE; }
139297 break;
139298 case 231: /* trigger_event ::= DELETE|INSERT */
139299 case 232: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==232);
139300 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139301 break;
139302 case 233: /* trigger_event ::= UPDATE OF idlist */
139303 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139304 break;
139305 case 234: /* when_clause ::= */
139306 case 253: /* key_opt ::= */ yytestcase(yyruleno==253);
139307 { yymsp[1].minor.yy72 = 0; }
139308 break;
139309 case 235: /* when_clause ::= WHEN expr */
139310 case 254: /* key_opt ::= KEY expr */ yytestcase(yyruleno==254);
139311 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139312 break;
139313 case 236: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139314 {
139315 assert( yymsp[-2].minor.yy145!=0 );
139316 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139317 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139318 }
139319 break;
139320 case 237: /* trigger_cmd_list ::= trigger_cmd SEMI */
139321 {
139322 assert( yymsp[-1].minor.yy145!=0 );
139323 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139324 }
139325 break;
139326 case 238: /* trnm ::= nm DOT nm */
139327 {
139328 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139329 sqlite3ErrorMsg(pParse,
139330 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139331 "statements within triggers");
139332 }
139333 break;
139334 case 239: /* tridxby ::= INDEXED BY nm */
139335 {
139336 sqlite3ErrorMsg(pParse,
139337 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139338 "within triggers");
139339 }
139340 break;
139341 case 240: /* tridxby ::= NOT INDEXED */
139342 {
139343 sqlite3ErrorMsg(pParse,
139344 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139345 "within triggers");
139346 }
139347 break;
139348 case 241: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139349 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139350 break;
139351 case 242: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139352 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139353 break;
139354 case 243: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139355 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139356 break;
139357 case 244: /* trigger_cmd ::= select */
139358 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139359 break;
139360 case 245: /* expr ::= RAISE LP IGNORE RP */
139361 {
139362 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139363 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139364 if( yymsp[-3].minor.yy190.pExpr ){
139365 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139366 }
139367 }
139368 break;
139369 case 246: /* expr ::= RAISE LP raisetype COMMA nm RP */
139370 {
139371 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139372 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139373 if( yymsp[-5].minor.yy190.pExpr ) {
139374 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139375 }
139376 }
139377 break;
139378 case 247: /* raisetype ::= ROLLBACK */
139379 {yymsp[0].minor.yy194 = OE_Rollback;}
139380 break;
139381 case 249: /* raisetype ::= FAIL */
139382 {yymsp[0].minor.yy194 = OE_Fail;}
139383 break;
139384 case 250: /* cmd ::= DROP TRIGGER ifexists fullname */
139385 {
139386 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139387 }
139388 break;
139389 case 251: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139390 {
139391 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139392 }
139393 break;
139394 case 252: /* cmd ::= DETACH database_kw_opt expr */
139395 {
139396 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139397 }
139398 break;
139399 case 255: /* cmd ::= REINDEX */
139400 {sqlite3Reindex(pParse, 0, 0);}
139401 break;
139402 case 256: /* cmd ::= REINDEX nm dbnm */
139403 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139404 break;
139405 case 257: /* cmd ::= ANALYZE */
139406 {sqlite3Analyze(pParse, 0, 0);}
139407 break;
139408 case 258: /* cmd ::= ANALYZE nm dbnm */
139409 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139410 break;
139411 case 259: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139412 {
139413 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139414 }
139415 break;
139416 case 260: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139417 {
139418 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139419 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139420 }
139421 break;
139422 case 261: /* add_column_fullname ::= fullname */
139423 {
139424 disableLookaside(pParse);
139425 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139426 }
139427 break;
139428 case 262: /* cmd ::= create_vtab */
139429 {sqlite3VtabFinishParse(pParse,0);}
139430 break;
139431 case 263: /* cmd ::= create_vtab LP vtabarglist RP */
139432 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139433 break;
139434 case 264: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139435 {
139436 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139437 }
139438 break;
139439 case 265: /* vtabarg ::= */
139440 {sqlite3VtabArgInit(pParse);}
139441 break;
139442 case 266: /* vtabargtoken ::= ANY */
139443 case 267: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==267);
139444 case 268: /* lp ::= LP */ yytestcase(yyruleno==268);
139445 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139446 break;
139447 case 269: /* with ::= */
139448 {yymsp[1].minor.yy285 = 0;}
139449 break;
139450 case 270: /* with ::= WITH wqlist */
139451 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139452 break;
139453 case 271: /* with ::= WITH RECURSIVE wqlist */
139454 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139455 break;
139456 case 272: /* wqlist ::= nm eidlist_opt AS LP select RP */
139457 {
139458 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139459 }
139460 break;
139461 case 273: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139462 {
139463 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139464 }
139465 break;
139466 default:
139467 /* (274) input ::= cmdlist */ yytestcase(yyruleno==274);
139468 /* (275) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==275);
139469 /* (276) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=276);
139470 /* (277) ecmd ::= SEMI */ yytestcase(yyruleno==277);
139471 /* (278) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==278);
139472 /* (279) explain ::= */ yytestcase(yyruleno==279);
139473 /* (280) trans_opt ::= */ yytestcase(yyruleno==280);
139474 /* (281) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==281);
139475 /* (282) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==282);
139476 /* (283) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==283);
139477 /* (284) savepoint_opt ::= */ yytestcase(yyruleno==284);
139478 /* (285) cmd ::= create_table create_table_args */ yytestcase(yyruleno==285);
139479 /* (286) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==286);
139480 /* (287) columnlist ::= columnname carglist */ yytestcase(yyruleno==287);
139481 /* (288) nm ::= ID|INDEXED */ yytestcase(yyruleno==288);
139482 /* (289) nm ::= STRING */ yytestcase(yyruleno==289);
139483 /* (290) nm ::= JOIN_KW */ yytestcase(yyruleno==290);
139484 /* (291) typetoken ::= typename */ yytestcase(yyruleno==291);
139485 /* (292) typename ::= ID|STRING */ yytestcase(yyruleno==292);
139486 /* (293) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139487 /* (294) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
139488 /* (295) carglist ::= carglist ccons */ yytestcase(yyruleno==295);
139489 /* (296) carglist ::= */ yytestcase(yyruleno==296);
139490 /* (297) ccons ::= NULL onconf */ yytestcase(yyruleno==297);
139491 /* (298) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==298);
139492 /* (299) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==299);
139493 /* (300) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=300);
139494 /* (301) tconscomma ::= */ yytestcase(yyruleno==301);
139495 /* (302) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=302);
139496 /* (303) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=303);
139497 /* (304) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=304);
139498 /* (305) oneselect ::= values */ yytestcase(yyruleno==305);
139499 /* (306) sclp ::= selcollist COMMA */ yytestcase(yyruleno==306);
139500 /* (307) as ::= ID|STRING */ yytestcase(yyruleno==307);
139501 /* (308) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=308);
139502 /* (309) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==309);
139503 /* (310) exprlist ::= nexprlist */ yytestcase(yyruleno==310);
139504 /* (311) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=311);
139505 /* (312) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=312);
139506 /* (313) nmnum ::= ON */ yytestcase(yyruleno==313);
139507 /* (314) nmnum ::= DELETE */ yytestcase(yyruleno==314);
139508 /* (315) nmnum ::= DEFAULT */ yytestcase(yyruleno==315);
139509 /* (316) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==316);
139510 /* (317) foreach_clause ::= */ yytestcase(yyruleno==317);
139511 /* (318) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==318);
139512 /* (319) trnm ::= nm */ yytestcase(yyruleno==319);
139513 /* (320) tridxby ::= */ yytestcase(yyruleno==320);
139514 /* (321) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==321);
139515 /* (322) database_kw_opt ::= */ yytestcase(yyruleno==322);
139516 /* (323) kwcolumn_opt ::= */ yytestcase(yyruleno==323);
139517 /* (324) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==324);
139518 /* (325) vtabarglist ::= vtabarg */ yytestcase(yyruleno==325);
139519 /* (326) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==326);
139520 /* (327) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==327);
139521 /* (328) anylist ::= */ yytestcase(yyruleno==328);
139522 /* (329) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==329);
139523 /* (330) anylist ::= anylist ANY */ yytestcase(yyruleno==330);
139524 break;
139525 /********** End reduce actions ************************************************/
139526 };
139527 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139528 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -139948,138 +140230,149 @@
139948 ** But by using this automatically generated code, the size of the code
139949 ** is substantially reduced. This is important for embedded applications
139950 ** on platforms with limited memory.
139951 */
139952 /* Hash score: 182 */
139953 static int keywordCode(const char *z, int n, int *pType){
139954 /* zText[] encodes 834 bytes of keywords in 554 bytes */
139955 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
139956 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
139957 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
139958 /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
139959 /* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
139960 /* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
139961 /* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
139962 /* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
139963 /* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
139964 /* VACUUMVIEWINITIALLY */
139965 static const char zText[553] = {
139966 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
139967 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
139968 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
139969 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
139970 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
139971 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
139972 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
139973 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
139974 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
139975 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
139976 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
139977 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
139978 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
139979 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
139980 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
139981 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
139982 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
139983 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
139984 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
139985 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
139986 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
139987 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
139988 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
139989 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
139990 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
139991 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
139992 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
139993 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
139994 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
139995 'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
139996 'V','I','E','W','I','N','I','T','I','A','L','L','Y',
139997 };
139998 static const unsigned char aHash[127] = {
139999 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
140000 42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
140001 121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
140002 0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
140003 0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
140004 96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
140005 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
140006 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
140007 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
140008 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
140009 };
140010 static const unsigned char aNext[124] = {
140011 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
140012 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
140013 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140014 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
140015 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
140016 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
140017 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
140018 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
140019 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
140020 73, 83, 0, 35, 68, 0, 0,
140021 };
140022 static const unsigned char aLen[124] = {
140023 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
140024 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
140025 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
140026 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
140027 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
140028 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
140029 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
140030 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
140031 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
140032 3, 5, 5, 6, 4, 9, 3,
140033 };
140034 static const unsigned short int aOffset[124] = {
140035 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
140036 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
140037 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
140038 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
140039 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
140040 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
140041 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
140042 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
140043 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
140044 521, 524, 529, 534, 540, 544, 549,
140045 };
140046 static const unsigned char aCode[124] = {
140047 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
140048 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
140049 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
140050 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
140051 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
140052 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
140053 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
140054 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
140055 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
140056 TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
140057 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
140058 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
140059 TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
140060 TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
140061 TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
140062 TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
140063 TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
140064 TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
140065 TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
140066 TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
140067 TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
140068 TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
140069 TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
140070 TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
140071 TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
140072 };
 
 
 
 
 
 
 
 
 
 
 
140073 int i, j;
140074 const char *zKW;
140075 if( n>=2 ){
140076 i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127;
140077 for(i=((int)aHash[i])-1; i>=0; i=((int)aNext[i])-1){
140078 if( aLen[i]!=n ) continue;
140079 j = 0;
140080 zKW = &zText[aOffset[i]];
140081 #ifdef SQLITE_ASCII
140082 while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }
140083 #endif
140084 #ifdef SQLITE_EBCDIC
140085 while( j<n && toupper(z[j])==zKW[j] ){ j++; }
@@ -140207,11 +140500,11 @@
140207 testcase( i==119 ); /* USING */
140208 testcase( i==120 ); /* VACUUM */
140209 testcase( i==121 ); /* VIEW */
140210 testcase( i==122 ); /* INITIALLY */
140211 testcase( i==123 ); /* ALL */
140212 *pType = aCode[i];
140213 break;
140214 }
140215 }
140216 return n;
140217 }
@@ -142486,14 +142779,14 @@
142486 ** argument.
142487 */
142488 SQLITE_PRIVATE const char *sqlite3ErrStr(int rc){
142489 static const char* const aMsg[] = {
142490 /* SQLITE_OK */ "not an error",
142491 /* SQLITE_ERROR */ "SQL logic error or missing database",
142492 /* SQLITE_INTERNAL */ 0,
142493 /* SQLITE_PERM */ "access permission denied",
142494 /* SQLITE_ABORT */ "callback requested query abort",
142495 /* SQLITE_BUSY */ "database is locked",
142496 /* SQLITE_LOCKED */ "database table is locked",
142497 /* SQLITE_NOMEM */ "out of memory",
142498 /* SQLITE_READONLY */ "attempt to write a readonly database",
142499 /* SQLITE_INTERRUPT */ "interrupted",
@@ -142501,21 +142794,25 @@
142501 /* SQLITE_CORRUPT */ "database disk image is malformed",
142502 /* SQLITE_NOTFOUND */ "unknown operation",
142503 /* SQLITE_FULL */ "database or disk is full",
142504 /* SQLITE_CANTOPEN */ "unable to open database file",
142505 /* SQLITE_PROTOCOL */ "locking protocol",
142506 /* SQLITE_EMPTY */ "table contains no data",
142507 /* SQLITE_SCHEMA */ "database schema has changed",
142508 /* SQLITE_TOOBIG */ "string or blob too big",
142509 /* SQLITE_CONSTRAINT */ "constraint failed",
142510 /* SQLITE_MISMATCH */ "datatype mismatch",
142511 /* SQLITE_MISUSE */ "library routine called out of sequence",
 
142512 /* SQLITE_NOLFS */ "large file support is disabled",
 
 
 
142513 /* SQLITE_AUTH */ "authorization denied",
142514 /* SQLITE_FORMAT */ "auxiliary database format error",
142515 /* SQLITE_RANGE */ "bind or column index out of range",
142516 /* SQLITE_NOTADB */ "file is encrypted or is not a database",
142517 };
142518 const char *zErr = "unknown error";
142519 switch( rc ){
142520 case SQLITE_ABORT_ROLLBACK: {
142521 zErr = "abort due to ROLLBACK";
@@ -143351,16 +143648,13 @@
143351 SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
143352 static const u16 outOfMem[] = {
143353 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
143354 };
143355 static const u16 misuse[] = {
143356 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
143357 'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
143358 'c', 'a', 'l', 'l', 'e', 'd', ' ',
143359 'o', 'u', 't', ' ',
143360 'o', 'f', ' ',
143361 's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
143362 };
143363
143364 const void *z;
143365 if( !db ){
143366 return (void *)outOfMem;
@@ -143891,30 +144185,10 @@
143891 #ifndef SQLITE_OMIT_AUTOINIT
143892 rc = sqlite3_initialize();
143893 if( rc ) return rc;
143894 #endif
143895
143896 /* Only allow sensible combinations of bits in the flags argument.
143897 ** Throw an error if any non-sense combination is used. If we
143898 ** do not block illegal combinations here, it could trigger
143899 ** assert() statements in deeper layers. Sensible combinations
143900 ** are:
143901 **
143902 ** 1: SQLITE_OPEN_READONLY
143903 ** 2: SQLITE_OPEN_READWRITE
143904 ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
143905 */
143906 assert( SQLITE_OPEN_READONLY == 0x01 );
143907 assert( SQLITE_OPEN_READWRITE == 0x02 );
143908 assert( SQLITE_OPEN_CREATE == 0x04 );
143909 testcase( (1<<(flags&7))==0x02 ); /* READONLY */
143910 testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
143911 testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
143912 if( ((1<<(flags&7)) & 0x46)==0 ){
143913 return SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
143914 }
143915
143916 if( sqlite3GlobalConfig.bCoreMutex==0 ){
143917 isThreadsafe = 0;
143918 }else if( flags & SQLITE_OPEN_NOMUTEX ){
143919 isThreadsafe = 0;
143920 }else if( flags & SQLITE_OPEN_FULLMUTEX ){
@@ -144032,13 +144306,34 @@
144032 ** strings is BINARY.
144033 */
144034 db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);
144035 assert( db->pDfltColl!=0 );
144036
144037 /* Parse the filename/URI argument. */
 
 
 
 
 
 
 
 
 
 
 
144038 db->openFlags = flags;
144039 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
 
 
 
 
 
 
 
 
 
 
144040 if( rc!=SQLITE_OK ){
144041 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
144042 sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
144043 sqlite3_free(zErrMsg);
144044 goto opendb_out;
@@ -148199,23 +148494,32 @@
148199 }
148200 pCsr->bSeekStmt = 0;
148201 }
148202 sqlite3_finalize(pCsr->pStmt);
148203 }
 
 
 
 
 
 
 
 
 
 
 
 
 
148204
148205 /*
148206 ** Close the cursor. For additional information see the documentation
148207 ** on the xClose method of the virtual table interface.
148208 */
148209 static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){
148210 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
148211 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148212 fts3CursorFinalizeStmt(pCsr);
148213 sqlite3Fts3ExprFree(pCsr->pExpr);
148214 sqlite3Fts3FreeDeferredTokens(pCsr);
148215 sqlite3_free(pCsr->aDoclist);
148216 sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
148217 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148218 sqlite3_free(pCsr);
148219 return SQLITE_OK;
148220 }
148221
@@ -149712,15 +150016,11 @@
149712 if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];
149713 if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];
149714 assert( iIdx==nVal );
149715
149716 /* In case the cursor has been used before, clear it now. */
149717 fts3CursorFinalizeStmt(pCsr);
149718 sqlite3_free(pCsr->aDoclist);
149719 sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
149720 sqlite3Fts3ExprFree(pCsr->pExpr);
149721 memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
149722
149723 /* Set the lower and upper bounds on docids to return */
149724 pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);
149725 pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);
149726
@@ -149795,11 +150095,16 @@
149795 /*
149796 ** This is the xEof method of the virtual table. SQLite calls this
149797 ** routine to find out if it has reached the end of a result set.
149798 */
149799 static int fts3EofMethod(sqlite3_vtab_cursor *pCursor){
149800 return ((Fts3Cursor *)pCursor)->isEof;
 
 
 
 
 
149801 }
149802
149803 /*
149804 ** This is the xRowid method. The SQLite core calls this routine to
149805 ** retrieve the rowid for the current row of the result set. fts3
@@ -168168,10 +168473,14 @@
168168 pRtree->zDb, pRtree->zName
168169 );
168170 rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);
168171 if( rc!=SQLITE_OK ){
168172 *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
 
 
 
 
168173 }
168174 }
168175
168176 sqlite3_free(zSql);
168177 return rc;
@@ -184399,11 +184708,13 @@
184399 pParser->fts5yyerrcnt = -1;
184400 #endif
184401 pParser->fts5yytos = pParser->fts5yystack;
184402 pParser->fts5yystack[0].stateno = 0;
184403 pParser->fts5yystack[0].major = 0;
 
184404 pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
 
184405 }
184406
184407 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184408 /*
184409 ** This function allocates a new parser.
@@ -199766,11 +200077,11 @@
199766 int nArg, /* Number of args */
199767 sqlite3_value **apUnused /* Function arguments */
199768 ){
199769 assert( nArg==0 );
199770 UNUSED_PARAM2(nArg, apUnused);
199771 sqlite3_result_text(pCtx, "fts5: 2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954", -1, SQLITE_TRANSIENT);
199772 }
199773
199774 static int fts5Init(sqlite3 *db){
199775 static const sqlite3_module fts5Mod = {
199776 /* iVersion */ 2,
@@ -203694,20 +204005,20 @@
203694 sqlite3_int64 iRowid; /* The rowid */
203695 };
203696
203697 /*
203698 ** The stmtConnect() method is invoked to create a new
203699 ** stmt_vtab that describes the generate_stmt virtual table.
203700 **
203701 ** Think of this routine as the constructor for stmt_vtab objects.
203702 **
203703 ** All this routine needs to do is:
203704 **
203705 ** (1) Allocate the stmt_vtab object and initialize all fields.
203706 **
203707 ** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
203708 ** result set of queries against generate_stmt will look like.
203709 */
203710 static int stmtConnect(
203711 sqlite3 *db,
203712 void *pAux,
203713 int argc, const char *const*argv,
@@ -203871,11 +204182,11 @@
203871 return stmtNext(pVtabCursor);
203872 }
203873
203874 /*
203875 ** SQLite will invoke this method one or more times while planning a query
203876 ** that uses the generate_stmt virtual table. This routine needs to create
203877 ** a query plan for each invocation and compute an estimated cost for that
203878 ** plan.
203879 */
203880 static int stmtBestIndex(
203881 sqlite3_vtab *tab,
@@ -203886,11 +204197,11 @@
203886 return SQLITE_OK;
203887 }
203888
203889 /*
203890 ** This following structure defines all the methods for the
203891 ** generate_stmt virtual table.
203892 */
203893 static sqlite3_module stmtModule = {
203894 0, /* iVersion */
203895 0, /* xCreate */
203896 stmtConnect, /* xConnect */
203897
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1150,11 +1150,11 @@
1150 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1151 ** [sqlite_version()] and [sqlite_source_id()].
1152 */
1153 #define SQLITE_VERSION "3.20.0"
1154 #define SQLITE_VERSION_NUMBER 3020000
1155 #define SQLITE_SOURCE_ID "2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40"
1156
1157 /*
1158 ** CAPI3REF: Run-Time Library Version Numbers
1159 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1160 **
@@ -1444,11 +1444,11 @@
1444 **
1445 ** See also: [extended result code definitions]
1446 */
1447 #define SQLITE_OK 0 /* Successful result */
1448 /* beginning-of-error-codes */
1449 #define SQLITE_ERROR 1 /* Generic error */
1450 #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
1451 #define SQLITE_PERM 3 /* Access permission denied */
1452 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
1453 #define SQLITE_BUSY 5 /* The database file is locked */
1454 #define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -1459,19 +1459,19 @@
1459 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
1460 #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
1461 #define SQLITE_FULL 13 /* Insertion failed because database is full */
1462 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
1463 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
1464 #define SQLITE_EMPTY 16 /* Not used */
1465 #define SQLITE_SCHEMA 17 /* The database schema changed */
1466 #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
1467 #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
1468 #define SQLITE_MISMATCH 20 /* Data type mismatch */
1469 #define SQLITE_MISUSE 21 /* Library used incorrectly */
1470 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
1471 #define SQLITE_AUTH 23 /* Authorization denied */
1472 #define SQLITE_FORMAT 24 /* Not used */
1473 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
1474 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
1475 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
1476 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
1477 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -5294,10 +5294,32 @@
5294
5295 /*
5296 ** CAPI3REF: Result Values From A Query
5297 ** KEYWORDS: {column access functions}
5298 ** METHOD: sqlite3_stmt
5299 **
5300 ** <b>Summary:</b>
5301 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5302 ** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
5303 ** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
5304 ** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
5305 ** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
5306 ** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
5307 ** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
5308 ** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
5309 ** [sqlite3_value|unprotected sqlite3_value] object.
5310 ** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
5311 ** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
5312 ** or a UTF-8 TEXT result in bytes
5313 ** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
5314 ** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
5315 ** TEXT in bytes
5316 ** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
5317 ** datatype of the result
5318 ** </table></blockquote>
5319 **
5320 ** <b>Details:</b>
5321 **
5322 ** ^These routines return information about a single column of the current
5323 ** result row of a query. ^In every case the first argument is a pointer
5324 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
5325 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -5316,19 +5338,32 @@
5338 ** something other than [SQLITE_ROW], the results are undefined.
5339 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
5340 ** are called from a different thread while any of these routines
5341 ** are pending, then the results are undefined.
5342 **
5343 ** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
5344 ** each return the value of a result column in a specific data format. If
5345 ** the result column is not initially in the requested format (for example,
5346 ** if the query returns an integer but the sqlite3_column_text() interface
5347 ** is used to extract the value) then an automatic type conversion is performed.
5348 **
5349 ** ^The sqlite3_column_type() routine returns the
5350 ** [SQLITE_INTEGER | datatype code] for the initial data type
5351 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
5352 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].
5353 ** The return value of sqlite3_column_type() can be used to decide which
5354 ** of the first six interface should be used to extract the column value.
5355 ** The value returned by sqlite3_column_type() is only meaningful if no
5356 ** automatic type conversions have occurred for the value in question.
5357 ** After a type conversion, the result of calling sqlite3_column_type()
5358 ** is undefined, though harmless. Future
5359 ** versions of SQLite may change the behavior of sqlite3_column_type()
5360 ** following a type conversion.
5361 **
5362 ** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
5363 ** or sqlite3_column_bytes16() interfaces can be used to determine the size
5364 ** of that BLOB or string.
5365 **
5366 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
5367 ** routine returns the number of bytes in that BLOB or string.
5368 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
5369 ** the string to UTF-8 and then returns the number of bytes.
@@ -5362,13 +5397,17 @@
5397 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
5398 ** If the [unprotected sqlite3_value] object returned by
5399 ** [sqlite3_column_value()] is used in any other way, including calls
5400 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
5401 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
5402 ** Hence, the sqlite3_column_value() interface
5403 ** is normally only useful within the implementation of
5404 ** [application-defined SQL functions] or [virtual tables], not within
5405 ** top-level application code.
5406 **
5407 ** The these routines may attempt to convert the datatype of the result.
5408 ** ^For example, if the internal representation is FLOAT and a text result
5409 ** is requested, [sqlite3_snprintf()] is used internally to perform the
5410 ** conversion automatically. ^(The following table details the conversions
5411 ** that are applied:
5412 **
5413 ** <blockquote>
@@ -5436,11 +5475,11 @@
5475 ** with calls to sqlite3_column_bytes().
5476 **
5477 ** ^The pointers returned are valid until a type conversion occurs as
5478 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
5479 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
5480 ** and BLOBs is freed automatically. Do not pass the pointers returned
5481 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
5482 ** [sqlite3_free()].
5483 **
5484 ** ^(If a memory allocation error occurs during the evaluation of any
5485 ** of these routines, a default value is returned. The default value
@@ -5447,19 +5486,19 @@
5486 ** is either the integer 0, the floating point number 0.0, or a NULL
5487 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
5488 ** [SQLITE_NOMEM].)^
5489 */
5490 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
 
 
5491 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
5492 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
5493 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
5494 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
5495 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
 
5496 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
5497 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
5498 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
5499 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
5500
5501 /*
5502 ** CAPI3REF: Destroy A Prepared Statement Object
5503 ** DESTRUCTOR: sqlite3_stmt
5504 **
@@ -5689,25 +5728,43 @@
5728
5729 /*
5730 ** CAPI3REF: Obtaining SQL Values
5731 ** METHOD: sqlite3_value
5732 **
5733 ** <b>Summary:</b>
5734 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
5735 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
5736 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
5737 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
5738 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
5739 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
5740 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
5741 ** the native byteorder
5742 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
5743 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
5744 ** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
5745 ** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB
5746 ** or a UTF-8 TEXT in bytes
5747 ** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>
5748 ** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
5749 ** TEXT in bytes
5750 ** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default
5751 ** datatype of the value
5752 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
5753 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
5754 ** </table></blockquote>
5755 **
5756 ** <b>Details:</b>
5757 **
5758 ** This routine extract type, size, and content information from
5759 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
5760 ** are used to pass parameter information into implementation of
5761 ** [application-defined SQL functions] and [virtual tables].
 
5762 **
5763 ** These routines work only with [protected sqlite3_value] objects.
5764 ** Any attempt to use these routines on an [unprotected sqlite3_value]
5765 ** is not threadsafe.
5766 **
5767 ** ^These routines work just like the corresponding [column access functions]
5768 ** except that these routines take a single [protected sqlite3_value] object
5769 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
5770 **
@@ -5714,10 +5771,21 @@
5771 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
5772 ** in the native byte-order of the host machine. ^The
5773 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
5774 ** extract UTF-16 strings as big-endian and little-endian respectively.
5775 **
5776 ** ^(The sqlite3_value_type(V) interface returns the
5777 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
5778 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
5779 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
5780 ** Other interfaces might change the datatype for an sqlite3_value object.
5781 ** For example, if the datatype is initially SQLITE_INTEGER and
5782 ** sqlite3_value_text(V) is called to extract a text value for that
5783 ** integer, then subsequent calls to sqlite3_value_type(V) might return
5784 ** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
5785 ** occurs is undefined and may change from one release of SQLite to the next.
5786 **
5787 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
5788 ** numeric affinity to the value. This means that an attempt is
5789 ** made to convert the value to an integer or floating point. If
5790 ** such a conversion is possible without loss of information (in other
5791 ** words, if the value is a string that looks like a number)
@@ -5732,19 +5800,19 @@
5800 **
5801 ** These routines must be called from the same thread as
5802 ** the SQL function that supplied the [sqlite3_value*] parameters.
5803 */
5804 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
 
 
5805 SQLITE_API double sqlite3_value_double(sqlite3_value*);
5806 SQLITE_API int sqlite3_value_int(sqlite3_value*);
5807 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
5808 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
5809 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
5810 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
5811 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
5812 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5813 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
5814 SQLITE_API int sqlite3_value_type(sqlite3_value*);
5815 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5816
5817 /*
5818 ** CAPI3REF: Finding The Subtype Of SQL Values
@@ -15143,10 +15211,11 @@
15211 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
15212 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
15213 #define SQLITE_Transitive 0x0200 /* Transitive constraints */
15214 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
15215 #define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
15216 #define SQLITE_CountOfView 0x1000 /* The count-of-view optimization */
15217 #define SQLITE_CursorHints 0x2000 /* Add OP_CursorHint opcodes */
15218 #define SQLITE_AllOpts 0xffff /* All optimizations */
15219
15220 /*
15221 ** Macros for testing whether or not optimizations are enabled or disabled.
@@ -17437,12 +17506,11 @@
17506 #endif
17507 SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);
17508 SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);
17509 SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
17510 SQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);
17511 SQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int);
 
17512 SQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);
17513 SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);
17514 SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
17515 SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
17516 SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
@@ -26962,21 +27030,21 @@
27030 }
27031 break;
27032 }
27033 #ifndef SQLITE_OMIT_SUBQUERY
27034 case TK_EXISTS: {
27035 sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags);
27036 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
27037 break;
27038 }
27039 case TK_SELECT: {
27040 sqlite3TreeViewLine(pView, "SELECT-expr flags=0x%x", pExpr->flags);
27041 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
27042 break;
27043 }
27044 case TK_IN: {
27045 sqlite3TreeViewLine(pView, "IN flags=0x%x", pExpr->flags);
27046 sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);
27047 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
27048 sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);
27049 }else{
27050 sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);
@@ -29771,21 +29839,23 @@
29839 }
29840 return 1;
29841 }
29842
29843 /* This function (for internal use only) locates an element in an
29844 ** hash table that matches the given key. If no element is found,
29845 ** a pointer to a static null element with HashElem.data==0 is returned.
29846 ** If pH is not NULL, then the hash for this key is written to *pH.
29847 */
29848 static HashElem *findElementWithHash(
29849 const Hash *pH, /* The pH to be searched */
29850 const char *pKey, /* The key we are searching for */
29851 unsigned int *pHash /* Write the hash value here */
29852 ){
29853 HashElem *elem; /* Used to loop thru the element list */
29854 int count; /* Number of elements left to test */
29855 unsigned int h; /* The computed hash */
29856 static HashElem nullElement = { 0, 0, 0, 0 };
29857
29858 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
29859 struct _ht *pEntry;
29860 h = strHash(pKey) % pH->htsize;
29861 pEntry = &pH->ht[h];
@@ -29794,19 +29864,19 @@
29864 }else{
29865 h = 0;
29866 elem = pH->first;
29867 count = pH->count;
29868 }
29869 if( pHash ) *pHash = h;
29870 while( count-- ){
29871 assert( elem!=0 );
29872 if( sqlite3StrICmp(elem->pKey,pKey)==0 ){
29873 return elem;
29874 }
29875 elem = elem->next;
29876 }
29877 return &nullElement;
29878 }
29879
29880 /* Remove a single entry from the hash table given a pointer to that
29881 ** element and a hash on the element's key.
29882 */
@@ -29844,17 +29914,13 @@
29914 /* Attempt to locate an element of the hash table pH with a key
29915 ** that matches pKey. Return the data for this element if it is
29916 ** found, or NULL if there is no match.
29917 */
29918 SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
 
 
 
29919 assert( pH!=0 );
29920 assert( pKey!=0 );
29921 return findElementWithHash(pH, pKey, 0)->data;
 
29922 }
29923
29924 /* Insert an element into the hash table pH. The key is pKey
29925 ** and the data is "data".
29926 **
@@ -29875,11 +29941,11 @@
29941 HashElem *new_elem; /* New element added to the pH */
29942
29943 assert( pH!=0 );
29944 assert( pKey!=0 );
29945 elem = findElementWithHash(pH,pKey,&h);
29946 if( elem->data ){
29947 void *old_data = elem->data;
29948 if( data==0 ){
29949 removeElementGivenHash(pH,elem,h);
29950 }else{
29951 elem->data = data;
@@ -58883,14 +58949,16 @@
58949 ** Allowed values for BtShared.btsFlags
58950 */
58951 #define BTS_READ_ONLY 0x0001 /* Underlying file is readonly */
58952 #define BTS_PAGESIZE_FIXED 0x0002 /* Page size can no longer be changed */
58953 #define BTS_SECURE_DELETE 0x0004 /* PRAGMA secure_delete is enabled */
58954 #define BTS_OVERWRITE 0x0008 /* Overwrite deleted content with zeros */
58955 #define BTS_FAST_SECURE 0x000c /* Combination of the previous two */
58956 #define BTS_INITIALLY_EMPTY 0x0010 /* Database was empty at trans start */
58957 #define BTS_NO_WAL 0x0020 /* Do not open write-ahead-log files */
58958 #define BTS_EXCLUSIVE 0x0040 /* pWriter has an exclusive lock */
58959 #define BTS_PENDING 0x0080 /* Waiting for read-locks to clear */
58960
58961 /*
58962 ** An instance of the following structure is used to hold information
58963 ** about a cell. The parseCellPtr() function fills in this structure
58964 ** based on information extract from the raw disk page.
@@ -61072,11 +61140,11 @@
61140 assert( iSize>=4 ); /* Minimum cell size is 4 */
61141 assert( iStart<=iLast );
61142
61143 /* Overwrite deleted information with zeros when the secure_delete
61144 ** option is enabled */
61145 if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
61146 memset(&data[iStart], 0, iSize);
61147 }
61148
61149 /* The list of freeblocks must be in ascending order. Find the
61150 ** spot on the list where iStart should be inserted.
@@ -61363,11 +61431,11 @@
61431 assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
61432 assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
61433 assert( sqlite3PagerGetData(pPage->pDbPage) == data );
61434 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
61435 assert( sqlite3_mutex_held(pBt->mutex) );
61436 if( pBt->btsFlags & BTS_FAST_SECURE ){
61437 memset(&data[hdr], 0, pBt->usableSize - hdr);
61438 }
61439 data[hdr] = (char)flags;
61440 first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);
61441 memset(&data[hdr+1], 0, 4);
@@ -61786,12 +61854,14 @@
61854 p->pBt = pBt;
61855
61856 pBt->pCursor = 0;
61857 pBt->pPage1 = 0;
61858 if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;
61859 #if defined(SQLITE_SECURE_DELETE)
61860 pBt->btsFlags |= BTS_SECURE_DELETE;
61861 #elif defined(SQLITE_FAST_SECURE_DELETE)
61862 pBt->btsFlags |= BTS_OVERWRITE;
61863 #endif
61864 /* EVIDENCE-OF: R-51873-39618 The page size for a database file is
61865 ** determined by the 2-byte integer located at an offset of 16 bytes from
61866 ** the beginning of the database file. */
61867 pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);
@@ -62235,23 +62305,38 @@
62305 sqlite3BtreeLeave(p);
62306 return n;
62307 }
62308
62309 /*
62310 ** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:
62311 **
62312 ** newFlag==0 Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared
62313 ** newFlag==1 BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared
62314 ** newFlag==2 BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set
62315 ** newFlag==(-1) No changes
62316 **
62317 ** This routine acts as a query if newFlag is less than zero
62318 **
62319 ** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but
62320 ** freelist leaf pages are not written back to the database. Thus in-page
62321 ** deleted content is cleared, but freelist deleted content is not.
62322 **
62323 ** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition
62324 ** that freelist leaf pages are written back into the database, increasing
62325 ** the amount of disk I/O.
62326 */
62327 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
62328 int b;
62329 if( p==0 ) return 0;
62330 sqlite3BtreeEnter(p);
62331 assert( BTS_OVERWRITE==BTS_SECURE_DELETE*2 );
62332 assert( BTS_FAST_SECURE==(BTS_OVERWRITE|BTS_SECURE_DELETE) );
62333 if( newFlag>=0 ){
62334 p->pBt->btsFlags &= ~BTS_FAST_SECURE;
62335 p->pBt->btsFlags |= BTS_SECURE_DELETE*newFlag;
62336 }
62337 b = (p->pBt->btsFlags & BTS_FAST_SECURE)/BTS_SECURE_DELETE;
62338 sqlite3BtreeLeave(p);
62339 return b;
62340 }
62341
62342 /*
@@ -66642,11 +66727,11 @@
66727 ** But not if we are in secure-delete mode. In secure-delete mode,
66728 ** the dropCell() routine will overwrite the entire cell with zeroes.
66729 ** In this case, temporarily copy the cell into the aOvflSpace[]
66730 ** buffer. It will be copied out again as soon as the aSpace[] buffer
66731 ** is allocated. */
66732 if( pBt->btsFlags & BTS_FAST_SECURE ){
66733 int iOff;
66734
66735 iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
66736 if( (iOff+szNew[i])>(int)pBt->usableSize ){
66737 rc = SQLITE_CORRUPT_BKPT;
@@ -72056,25 +72141,31 @@
72141 ** constants. The registers begin with iDest and increase consecutively.
72142 ** One register is initialized for each characgter in zTypes[]. For each
72143 ** "s" character in zTypes[], the register is a string if the argument is
72144 ** not NULL, or OP_Null if the value is a null pointer. For each "i" character
72145 ** in zTypes[], the register is initialized to an integer.
72146 **
72147 ** If the input string does not end with "X" then an OP_ResultRow instruction
72148 ** is generated for the values inserted.
72149 */
72150 SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
72151 va_list ap;
72152 int i;
72153 char c;
72154 va_start(ap, zTypes);
72155 for(i=0; (c = zTypes[i])!=0; i++){
72156 if( c=='s' ){
72157 const char *z = va_arg(ap, const char*);
72158 sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest+i, 0, z, 0);
72159 }else if( c=='i' ){
72160 sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest+i);
72161 }else{
72162 goto skip_op_resultrow;
 
72163 }
72164 }
72165 sqlite3VdbeAddOp2(p, OP_ResultRow, iDest, i);
72166 skip_op_resultrow:
72167 va_end(ap);
72168 }
72169
72170 /*
72171 ** Add an opcode that includes the p4 value as a pointer.
@@ -89667,19 +89758,21 @@
89758 static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
89759 int rc;
89760 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
89761 testcase( ExprHasProperty(pExpr, EP_Reduced) );
89762 rc = pWalker->xExprCallback(pWalker, pExpr);
89763 if( rc ) return rc & WRC_Abort;
89764 if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){
89765 if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
89766 assert( pExpr->x.pList==0 || pExpr->pRight==0 );
89767 if( pExpr->pRight ){
89768 if( walkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
89769 }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
89770 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
89771 }else if( pExpr->x.pList ){
89772 if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
89773 }
89774 }
89775 return WRC_Continue;
89776 }
89777 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
89778 return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;
@@ -89730,11 +89823,11 @@
89823 struct SrcList_item *pItem;
89824
89825 pSrc = p->pSrc;
89826 if( ALWAYS(pSrc) ){
89827 for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){
89828 if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){
89829 return WRC_Abort;
89830 }
89831 if( pItem->fg.isTabFunc
89832 && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)
89833 ){
@@ -89762,11 +89855,12 @@
89855 ** If the Walker does not have an xSelectCallback() then this routine
89856 ** is a no-op returning WRC_Continue.
89857 */
89858 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
89859 int rc;
89860 if( p==0 ) return WRC_Continue;
89861 if( pWalker->xSelectCallback==0 ) return WRC_Continue;
89862 do{
89863 rc = pWalker->xSelectCallback(pWalker, p);
89864 if( rc ) return rc & WRC_Abort;
89865 if( sqlite3WalkSelectExpr(pWalker, p)
89866 || sqlite3WalkSelectFrom(pWalker, p)
@@ -90261,10 +90355,11 @@
90355 sqlite3ExprDelete(db, pExpr->pLeft);
90356 pExpr->pLeft = 0;
90357 sqlite3ExprDelete(db, pExpr->pRight);
90358 pExpr->pRight = 0;
90359 pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
90360 ExprSetProperty(pExpr, EP_Leaf);
90361 lookupname_end:
90362 if( cnt==1 ){
90363 assert( pNC!=0 );
90364 if( !ExprHasProperty(pExpr, EP_Alias) ){
90365 sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
@@ -92067,11 +92162,11 @@
92162 memset(pNew, 0, sizeof(Expr));
92163 pNew->op = (u8)op;
92164 pNew->iAgg = -1;
92165 if( pToken ){
92166 if( nExtra==0 ){
92167 pNew->flags |= EP_IntValue|EP_Leaf;
92168 pNew->u.iValue = iValue;
92169 }else{
92170 pNew->u.zToken = (char*)&pNew[1];
92171 assert( pToken->z!=0 || pToken->n==0 );
92172 if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
@@ -92348,12 +92443,13 @@
92443 #endif
92444 if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){
92445 /* The Expr.x union is never used at the same time as Expr.pRight */
92446 assert( p->x.pList==0 || p->pRight==0 );
92447 if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);
92448 if( p->pRight ){
92449 sqlite3ExprDeleteNN(db, p->pRight);
92450 }else if( ExprHasProperty(p, EP_xIsSelect) ){
92451 sqlite3SelectDelete(db, p->x.pSelect);
92452 }else{
92453 sqlite3ExprListDelete(db, p->x.pList);
92454 }
92455 }
@@ -103955,16 +104051,16 @@
104051 pItem = &pList->a[pList->nSrc-1];
104052 if( pDatabase && pDatabase->z==0 ){
104053 pDatabase = 0;
104054 }
104055 if( pDatabase ){
104056 pItem->zName = sqlite3NameFromToken(db, pDatabase);
104057 pItem->zDatabase = sqlite3NameFromToken(db, pTable);
104058 }else{
104059 pItem->zName = sqlite3NameFromToken(db, pTable);
104060 pItem->zDatabase = 0;
104061 }
 
 
104062 return pList;
104063 }
104064
104065 /*
104066 ** Assign VdbeCursor index numbers to all tables in a SrcList
@@ -104149,40 +104245,29 @@
104245 }
104246 sqlite3VdbeAddOp0(v, OP_AutoCommit);
104247 }
104248
104249 /*
104250 ** Generate VDBE code for a COMMIT or ROLLBACK statement.
104251 ** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise
104252 ** code is generated for a COMMIT.
104253 */
104254 SQLITE_PRIVATE void sqlite3EndTransaction(Parse *pParse, int eType){
104255 Vdbe *v;
104256 int isRollback;
104257
104258 assert( pParse!=0 );
104259 assert( pParse->db!=0 );
104260 assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );
104261 isRollback = eType==TK_ROLLBACK;
104262 if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION,
104263 isRollback ? "ROLLBACK" : "COMMIT", 0, 0) ){
104264 return;
104265 }
104266 v = sqlite3GetVdbe(pParse);
104267 if( v ){
104268 sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);
 
 
 
 
 
 
 
 
 
 
 
104269 }
104270 }
104271
104272 /*
104273 ** This function is called by the parser when it parses a command to create,
@@ -104759,11 +104844,11 @@
104844 ** request a definition of the collating sequence. If this doesn't work,
104845 ** an equivalent collating sequence that uses a text encoding different
104846 ** from the main database is substituted, if one is available.
104847 */
104848 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
104849 if( pColl && pColl->xCmp==0 ){
104850 const char *zName = pColl->zName;
104851 sqlite3 *db = pParse->db;
104852 CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);
104853 if( !p ){
104854 return SQLITE_ERROR;
@@ -104795,22 +104880,21 @@
104880 ){
104881 CollSeq *pColl;
104882 pColl = sqlite3HashFind(&db->aCollSeq, zName);
104883
104884 if( 0==pColl && create ){
104885 int nName = sqlite3Strlen30(zName) + 1;
104886 pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName);
104887 if( pColl ){
104888 CollSeq *pDel = 0;
104889 pColl[0].zName = (char*)&pColl[3];
104890 pColl[0].enc = SQLITE_UTF8;
104891 pColl[1].zName = (char*)&pColl[3];
104892 pColl[1].enc = SQLITE_UTF16LE;
104893 pColl[2].zName = (char*)&pColl[3];
104894 pColl[2].enc = SQLITE_UTF16BE;
104895 memcpy(pColl[0].zName, zName, nName);
 
104896 pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);
104897
104898 /* If a malloc() failure occurred in sqlite3HashInsert(), it will
104899 ** return the pColl pointer to be deleted (because it wasn't added
104900 ** to the hash table).
@@ -104946,11 +105030,12 @@
105030 int i;
105031 for(i=0; i<nDef; i++){
105032 FuncDef *pOther;
105033 const char *zName = aDef[i].zName;
105034 int nName = sqlite3Strlen30(zName);
105035 int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;
105036 assert( zName[0]>='a' && zName[0]<='z' );
105037 pOther = functionSearch(h, zName);
105038 if( pOther ){
105039 assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
105040 aDef[i].pNext = pOther->pNext;
105041 pOther->pNext = &aDef[i];
@@ -106109,20 +106194,20 @@
106194 static void typeofFunc(
106195 sqlite3_context *context,
106196 int NotUsed,
106197 sqlite3_value **argv
106198 ){
106199 static const char *azType[] = { "integer", "real", "text", "blob", "null" };
106200 int i = sqlite3_value_type(argv[0]) - 1;
106201 UNUSED_PARAMETER(NotUsed);
106202 assert( i>=0 && i<ArraySize(azType) );
106203 assert( SQLITE_INTEGER==1 );
106204 assert( SQLITE_FLOAT==2 );
106205 assert( SQLITE_TEXT==3 );
106206 assert( SQLITE_BLOB==4 );
106207 assert( SQLITE_NULL==5 );
106208 sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
 
106209 }
106210
106211
106212 /*
106213 ** Implementation of the length() function
@@ -113151,39 +113236,42 @@
113236 #define PragTyp_DATABASE_LIST 10
113237 #define PragTyp_DEFAULT_CACHE_SIZE 11
113238 #define PragTyp_ENCODING 12
113239 #define PragTyp_FOREIGN_KEY_CHECK 13
113240 #define PragTyp_FOREIGN_KEY_LIST 14
113241 #define PragTyp_FUNCTION_LIST 15
113242 #define PragTyp_INCREMENTAL_VACUUM 16
113243 #define PragTyp_INDEX_INFO 17
113244 #define PragTyp_INDEX_LIST 18
113245 #define PragTyp_INTEGRITY_CHECK 19
113246 #define PragTyp_JOURNAL_MODE 20
113247 #define PragTyp_JOURNAL_SIZE_LIMIT 21
113248 #define PragTyp_LOCK_PROXY_FILE 22
113249 #define PragTyp_LOCKING_MODE 23
113250 #define PragTyp_PAGE_COUNT 24
113251 #define PragTyp_MMAP_SIZE 25
113252 #define PragTyp_MODULE_LIST 26
113253 #define PragTyp_OPTIMIZE 27
113254 #define PragTyp_PAGE_SIZE 28
113255 #define PragTyp_PRAGMA_LIST 29
113256 #define PragTyp_SECURE_DELETE 30
113257 #define PragTyp_SHRINK_MEMORY 31
113258 #define PragTyp_SOFT_HEAP_LIMIT 32
113259 #define PragTyp_SYNCHRONOUS 33
113260 #define PragTyp_TABLE_INFO 34
113261 #define PragTyp_TEMP_STORE 35
113262 #define PragTyp_TEMP_STORE_DIRECTORY 36
113263 #define PragTyp_THREADS 37
113264 #define PragTyp_WAL_AUTOCHECKPOINT 38
113265 #define PragTyp_WAL_CHECKPOINT 39
113266 #define PragTyp_ACTIVATE_EXTENSIONS 40
113267 #define PragTyp_HEXKEY 41
113268 #define PragTyp_KEY 42
113269 #define PragTyp_REKEY 43
113270 #define PragTyp_LOCK_STATUS 44
113271 #define PragTyp_PARSER_TRACE 45
113272 #define PragTyp_STATS 46
113273
113274 /* Property flags associated with various pragma. */
113275 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
113276 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
113277 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -113225,30 +113313,33 @@
113313 /* 24 */ "origin",
113314 /* 25 */ "partial",
113315 /* 26 */ "seq", /* Used by: database_list */
113316 /* 27 */ "name",
113317 /* 28 */ "file",
113318 /* 29 */ "name", /* Used by: function_list */
113319 /* 30 */ "builtin",
113320 /* 31 */ "name", /* Used by: module_list pragma_list */
113321 /* 32 */ "seq", /* Used by: collation_list */
113322 /* 33 */ "name",
113323 /* 34 */ "id", /* Used by: foreign_key_list */
113324 /* 35 */ "seq",
113325 /* 36 */ "table",
113326 /* 37 */ "from",
113327 /* 38 */ "to",
113328 /* 39 */ "on_update",
113329 /* 40 */ "on_delete",
113330 /* 41 */ "match",
113331 /* 42 */ "table", /* Used by: foreign_key_check */
113332 /* 43 */ "rowid",
113333 /* 44 */ "parent",
113334 /* 45 */ "fkid",
113335 /* 46 */ "busy", /* Used by: wal_checkpoint */
113336 /* 47 */ "log",
113337 /* 48 */ "checkpointed",
113338 /* 49 */ "timeout", /* Used by: busy_timeout */
113339 /* 50 */ "database", /* Used by: lock_status */
113340 /* 51 */ "status",
113341 };
113342
113343 /* Definitions of all built-in pragmas */
113344 typedef struct PragmaName {
113345 const char *const zName; /* Name of pragma */
@@ -113290,11 +113381,11 @@
113381 #endif
113382 #endif
113383 {/* zName: */ "busy_timeout",
113384 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
113385 /* ePragFlg: */ PragFlg_Result0,
113386 /* ColNames: */ 49, 1,
113387 /* iArg: */ 0 },
113388 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113389 {/* zName: */ "cache_size",
113390 /* ePragTyp: */ PragTyp_CACHE_SIZE,
113391 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -113327,11 +113418,11 @@
113418 #endif
113419 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113420 {/* zName: */ "collation_list",
113421 /* ePragTyp: */ PragTyp_COLLATION_LIST,
113422 /* ePragFlg: */ PragFlg_Result0,
113423 /* ColNames: */ 32, 2,
113424 /* iArg: */ 0 },
113425 #endif
113426 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
113427 {/* zName: */ "compile_options",
113428 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -113399,18 +113490,18 @@
113490 #endif
113491 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113492 {/* zName: */ "foreign_key_check",
113493 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
113494 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
113495 /* ColNames: */ 42, 4,
113496 /* iArg: */ 0 },
113497 #endif
113498 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
113499 {/* zName: */ "foreign_key_list",
113500 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
113501 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
113502 /* ColNames: */ 34, 8,
113503 /* iArg: */ 0 },
113504 #endif
113505 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113506 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
113507 {/* zName: */ "foreign_keys",
@@ -113436,10 +113527,19 @@
113527 {/* zName: */ "fullfsync",
113528 /* ePragTyp: */ PragTyp_FLAG,
113529 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113530 /* ColNames: */ 0, 0,
113531 /* iArg: */ SQLITE_FullFSync },
113532 #endif
113533 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113534 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
113535 {/* zName: */ "function_list",
113536 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
113537 /* ePragFlg: */ PragFlg_Result0,
113538 /* ColNames: */ 29, 2,
113539 /* iArg: */ 0 },
113540 #endif
113541 #endif
113542 #if defined(SQLITE_HAS_CODEC)
113543 {/* zName: */ "hexkey",
113544 /* ePragTyp: */ PragTyp_HEXKEY,
113545 /* ePragFlg: */ 0,
@@ -113526,11 +113626,11 @@
113626 #endif
113627 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
113628 {/* zName: */ "lock_status",
113629 /* ePragTyp: */ PragTyp_LOCK_STATUS,
113630 /* ePragFlg: */ PragFlg_Result0,
113631 /* ColNames: */ 50, 2,
113632 /* iArg: */ 0 },
113633 #endif
113634 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
113635 {/* zName: */ "locking_mode",
113636 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -113545,10 +113645,21 @@
113645 {/* zName: */ "mmap_size",
113646 /* ePragTyp: */ PragTyp_MMAP_SIZE,
113647 /* ePragFlg: */ 0,
113648 /* ColNames: */ 0, 0,
113649 /* iArg: */ 0 },
113650 #endif
113651 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
113652 #if !defined(SQLITE_OMIT_VIRTUALTABLE)
113653 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
113654 {/* zName: */ "module_list",
113655 /* ePragTyp: */ PragTyp_MODULE_LIST,
113656 /* ePragFlg: */ PragFlg_Result0,
113657 /* ColNames: */ 31, 1,
113658 /* iArg: */ 0 },
113659 #endif
113660 #endif
113661 #endif
113662 {/* zName: */ "optimize",
113663 /* ePragTyp: */ PragTyp_OPTIMIZE,
113664 /* ePragFlg: */ PragFlg_Result1|PragFlg_NeedSchema,
113665 /* ColNames: */ 0, 0,
@@ -113569,10 +113680,17 @@
113680 {/* zName: */ "parser_trace",
113681 /* ePragTyp: */ PragTyp_PARSER_TRACE,
113682 /* ePragFlg: */ 0,
113683 /* ColNames: */ 0, 0,
113684 /* iArg: */ 0 },
113685 #endif
113686 #if defined(SQLITE_INTROSPECTION_PRAGMAS)
113687 {/* zName: */ "pragma_list",
113688 /* ePragTyp: */ PragTyp_PRAGMA_LIST,
113689 /* ePragFlg: */ PragFlg_Result0,
113690 /* ColNames: */ 31, 1,
113691 /* iArg: */ 0 },
113692 #endif
113693 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113694 {/* zName: */ "query_only",
113695 /* ePragTyp: */ PragTyp_FLAG,
113696 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
@@ -113733,11 +113851,11 @@
113851 /* ColNames: */ 0, 0,
113852 /* iArg: */ 0 },
113853 {/* zName: */ "wal_checkpoint",
113854 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
113855 /* ePragFlg: */ PragFlg_NeedSchema,
113856 /* ColNames: */ 46, 3,
113857 /* iArg: */ 0 },
113858 #endif
113859 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
113860 {/* zName: */ "writable_schema",
113861 /* ePragTyp: */ PragTyp_FLAG,
@@ -113744,11 +113862,11 @@
113862 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
113863 /* ColNames: */ 0, 0,
113864 /* iArg: */ SQLITE_WriteSchema },
113865 #endif
113866 };
113867 /* Number of pragmas: 60 on by default, 77 total. */
113868
113869 /************** End of pragma.h **********************************************/
113870 /************** Continuing where we left off in pragma.c *********************/
113871
113872 /*
@@ -114234,22 +114352,26 @@
114352 break;
114353 }
114354
114355 /*
114356 ** PRAGMA [schema.]secure_delete
114357 ** PRAGMA [schema.]secure_delete=ON/OFF/FAST
114358 **
114359 ** The first form reports the current setting for the
114360 ** secure_delete flag. The second form changes the secure_delete
114361 ** flag setting and reports the new value.
114362 */
114363 case PragTyp_SECURE_DELETE: {
114364 Btree *pBt = pDb->pBt;
114365 int b = -1;
114366 assert( pBt!=0 );
114367 if( zRight ){
114368 if( sqlite3_stricmp(zRight, "fast")==0 ){
114369 b = 2;
114370 }else{
114371 b = sqlite3GetBoolean(zRight, 0);
114372 }
114373 }
114374 if( pId2->n==0 && b>=0 ){
114375 int ii;
114376 for(ii=0; ii<db->nDb; ii++){
114377 sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
@@ -114827,11 +114949,10 @@
114949 pCol->zName,
114950 sqlite3ColumnType(pCol,""),
114951 pCol->notNull ? 1 : 0,
114952 pCol->pDflt ? pCol->pDflt->u.zToken : 0,
114953 k);
 
114954 }
114955 }
114956 }
114957 break;
114958
@@ -114847,13 +114968,12 @@
114968 pTab->zName,
114969 0,
114970 pTab->szTabRow,
114971 pTab->nRowLogEst,
114972 pTab->tabFlags);
 
114973 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114974 sqlite3VdbeMultiLoad(v, 2, "siiiX",
114975 pIdx->zName,
114976 pIdx->szIdxRow,
114977 pIdx->aiRowLogEst[0],
114978 pIdx->hasStat1);
114979 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
@@ -114882,14 +115002,14 @@
115002 pTab = pIdx->pTable;
115003 sqlite3CodeVerifySchema(pParse, iDb);
115004 assert( pParse->nMem<=pPragma->nPragCName );
115005 for(i=0; i<mx; i++){
115006 i16 cnum = pIdx->aiColumn[i];
115007 sqlite3VdbeMultiLoad(v, 1, "iisX", i, cnum,
115008 cnum<0 ? 0 : pTab->aCol[cnum].zName);
115009 if( pPragma->iArg ){
115010 sqlite3VdbeMultiLoad(v, 4, "isiX",
115011 pIdx->aSortOrder[i],
115012 pIdx->azColl[i],
115013 i<pIdx->nKeyCol);
115014 }
115015 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
@@ -114912,11 +115032,10 @@
115032 i,
115033 pIdx->zName,
115034 IsUniqueIndex(pIdx),
115035 azOrigin[pIdx->idxType],
115036 pIdx->pPartIdxWhere!=0);
 
115037 }
115038 }
115039 }
115040 break;
115041
@@ -114928,11 +115047,10 @@
115047 assert( db->aDb[i].zDbSName!=0 );
115048 sqlite3VdbeMultiLoad(v, 1, "iss",
115049 i,
115050 db->aDb[i].zDbSName,
115051 sqlite3BtreeGetFilename(db->aDb[i].pBt));
 
115052 }
115053 }
115054 break;
115055
115056 case PragTyp_COLLATION_LIST: {
@@ -114940,14 +115058,57 @@
115058 HashElem *p;
115059 pParse->nMem = 2;
115060 for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
115061 CollSeq *pColl = (CollSeq *)sqliteHashData(p);
115062 sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
115063 }
115064 }
115065 break;
115066
115067 #ifdef SQLITE_INTROSPECTION_PRAGMAS
115068 case PragTyp_FUNCTION_LIST: {
115069 int i;
115070 HashElem *j;
115071 FuncDef *p;
115072 pParse->nMem = 2;
115073 for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
115074 for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
115075 sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
115076 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
115077 }
115078 }
115079 for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
115080 p = (FuncDef*)sqliteHashData(j);
115081 sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
115082 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
115083 }
115084 }
115085 break;
115086
115087 #ifndef SQLITE_OMIT_VIRTUALTABLE
115088 case PragTyp_MODULE_LIST: {
115089 HashElem *j;
115090 pParse->nMem = 1;
115091 for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
115092 Module *pMod = (Module*)sqliteHashData(j);
115093 sqlite3VdbeMultiLoad(v, 1, "s", pMod->zName);
115094 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
115095 }
115096 }
115097 break;
115098 #endif /* SQLITE_OMIT_VIRTUALTABLE */
115099
115100 case PragTyp_PRAGMA_LIST: {
115101 int i;
115102 for(i=0; i<ArraySize(aPragmaName); i++){
115103 sqlite3VdbeMultiLoad(v, 1, "s", aPragmaName[i].zName);
115104 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
115105 }
115106 }
115107 break;
115108 #endif /* SQLITE_INTROSPECTION_PRAGMAS */
115109
115110 #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
115111
115112 #ifndef SQLITE_OMIT_FOREIGN_KEY
115113 case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
115114 FKey *pFK;
@@ -114969,11 +115130,10 @@
115130 pTab->aCol[pFK->aCol[j].iFrom].zName,
115131 pFK->aCol[j].zCol,
115132 actionName(pFK->aAction[1]), /* ON UPDATE */
115133 actionName(pFK->aAction[0]), /* ON DELETE */
115134 "NONE");
 
115135 }
115136 ++i;
115137 pFK = pFK->pNextFrom;
115138 }
115139 }
@@ -115079,11 +115239,11 @@
115239 if( HasRowid(pTab) ){
115240 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
115241 }else{
115242 sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);
115243 }
115244 sqlite3VdbeMultiLoad(v, regResult+2, "siX", pFK->zTo, i-1);
115245 sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);
115246 sqlite3VdbeResolveLabel(v, addrOk);
115247 sqlite3DbFree(db, aiCols);
115248 }
115249 sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);
@@ -115781,11 +115941,10 @@
115941 }else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0,
115942 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
115943 zState = azLockName[j];
115944 }
115945 sqlite3VdbeMultiLoad(v, 1, "ss", db->aDb[i].zDbSName, zState);
 
115946 }
115947 break;
115948 }
115949 #endif
115950
@@ -118757,11 +118916,15 @@
118916 }else{
118917 /* Use the original text of the column expression as its name */
118918 zName = pEList->a[i].zSpan;
118919 }
118920 }
118921 if( zName ){
118922 zName = sqlite3DbStrDup(db, zName);
118923 }else{
118924 zName = sqlite3MPrintf(db,"column%d",i+1);
118925 }
118926
118927 /* Make sure the column name is unique. If the name is not unique,
118928 ** append an integer to the name so that it becomes unique.
118929 */
118930 cnt = 0;
@@ -122070,10 +122233,92 @@
122233 return pItem;
122234 }
122235 return 0;
122236 }
122237
122238 #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
122239 /*
122240 ** Attempt to transform a query of the form
122241 **
122242 ** SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)
122243 **
122244 ** Into this:
122245 **
122246 ** SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)
122247 **
122248 ** The transformation only works if all of the following are true:
122249 **
122250 ** * The subquery is a UNION ALL of two or more terms
122251 ** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
122252 ** * The outer query is a simple count(*)
122253 **
122254 ** Return TRUE if the optimization is undertaken.
122255 */
122256 static int countOfViewOptimization(Parse *pParse, Select *p){
122257 Select *pSub, *pPrior;
122258 Expr *pExpr;
122259 Expr *pCount;
122260 sqlite3 *db;
122261 if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate query */
122262 if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
122263 pExpr = p->pEList->a[0].pExpr;
122264 if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */
122265 if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Must be count() */
122266 if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */
122267 if( p->pSrc->nSrc!=1 ) return 0; /* One table in the FROM clause */
122268 pSub = p->pSrc->a[0].pSelect;
122269 if( pSub==0 ) return 0; /* The FROM is a subquery */
122270 if( pSub->pPrior==0 ) return 0; /* Must be a compound subquery */
122271 do{
122272 if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
122273 if( pSub->pWhere ) return 0; /* No WHERE clause */
122274 if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
122275 pSub = pSub->pPrior; /* Repeat over compound terms */
122276 }while( pSub );
122277
122278 /* If we reach this point, that means it is OK to perform the transformation */
122279
122280 db = pParse->db;
122281 pCount = pExpr;
122282 pExpr = 0;
122283 pSub = p->pSrc->a[0].pSelect;
122284 p->pSrc->a[0].pSelect = 0;
122285 sqlite3SrcListDelete(db, p->pSrc);
122286 p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));
122287 while( pSub ){
122288 Expr *pTerm;
122289 pPrior = pSub->pPrior;
122290 pSub->pPrior = 0;
122291 pSub->pNext = 0;
122292 pSub->selFlags |= SF_Aggregate;
122293 pSub->selFlags &= ~SF_Compound;
122294 pSub->nSelectRow = 0;
122295 sqlite3ExprListDelete(db, pSub->pEList);
122296 pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;
122297 pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);
122298 pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
122299 sqlite3PExprAddSelect(pParse, pTerm, pSub);
122300 if( pExpr==0 ){
122301 pExpr = pTerm;
122302 }else{
122303 pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);
122304 }
122305 pSub = pPrior;
122306 }
122307 p->pEList->a[0].pExpr = pExpr;
122308 p->selFlags &= ~SF_Aggregate;
122309
122310 #if SELECTTRACE_ENABLED
122311 if( sqlite3SelectTrace & 0x400 ){
122312 SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n"));
122313 sqlite3TreeViewSelect(0, p, 0);
122314 }
122315 #endif
122316 return 1;
122317 }
122318 #endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */
122319
122320 /*
122321 ** Generate code for the SELECT statement given in the p argument.
122322 **
122323 ** The results are returned according to the SelectDest structure.
122324 ** See comments in sqliteInt.h for further information.
@@ -122381,10 +122626,20 @@
122626 if( sqlite3SelectTrace & 0x400 ){
122627 SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n"));
122628 sqlite3TreeViewSelect(0, p, 0);
122629 }
122630 #endif
122631
122632 #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION
122633 if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)
122634 && countOfViewOptimization(pParse, p)
122635 ){
122636 if( db->mallocFailed ) goto select_end;
122637 pEList = p->pEList;
122638 pTabList = p->pSrc;
122639 }
122640 #endif
122641
122642 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
122643 ** if the select-list is the same as the ORDER BY list, then this query
122644 ** can be rewritten as a GROUP BY. In other words, this:
122645 **
@@ -127095,10 +127350,11 @@
127350 #endif
127351 #define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
127352 #define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
127353 #define TERM_LIKE 0x400 /* The original LIKE operator */
127354 #define TERM_IS 0x800 /* Term.pExpr is an IS operator */
127355 #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */
127356
127357 /*
127358 ** An instance of the WhereScan object is used as an iterator for locating
127359 ** terms in the WHERE clause that are useful to the query planner.
127360 */
@@ -127184,10 +127440,11 @@
127440 ** does not really matter. What is important is that sparse cursor
127441 ** numbers all get mapped into bit numbers that begin with 0 and contain
127442 ** no gaps.
127443 */
127444 struct WhereMaskSet {
127445 int bVarSelect; /* Used by sqlite3WhereExprUsage() */
127446 int n; /* Number of assigned cursor values */
127447 int ix[BMS]; /* Cursor assigned to each bit */
127448 };
127449
127450 /*
@@ -128481,11 +128738,11 @@
128738 int addrHalt; /* addrBrk for the outermost loop */
128739 int addrCont; /* Jump here to continue with next cycle */
128740 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
128741 int iReleaseReg = 0; /* Temp register to free before returning */
128742 Index *pIdx = 0; /* Index used by loop (if any) */
128743 int iLoop; /* Iteration of constraint generator loop */
128744
128745 pParse = pWInfo->pParse;
128746 v = pParse->pVdbe;
128747 pWC = &pWInfo->sWC;
128748 db = pParse->db;
@@ -129376,17 +129633,24 @@
129633 #endif
129634
129635 /* Insert code to test every subexpression that can be completely
129636 ** computed using the current set of tables.
129637 **
129638 ** This loop may run between one and three times, depending on the
129639 ** constraints to be generated. The value of stack variable iLoop
129640 ** determines the constraints coded by each iteration, as follows:
129641 **
129642 ** iLoop==1: Code only expressions that are entirely covered by pIdx.
129643 ** iLoop==2: Code remaining expressions that do not contain correlated
129644 ** sub-queries.
129645 ** iLoop==3: Code all remaining expressions.
129646 **
129647 ** An effort is made to skip unnecessary iterations of the loop.
129648 */
129649 iLoop = (pIdx ? 1 : 2);
129650 do{
129651 int iNext = 0; /* Next value for iLoop */
129652 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
129653 Expr *pE;
129654 int skipLikeAddr = 0;
129655 testcase( pTerm->wtFlags & TERM_VIRTUAL );
129656 testcase( pTerm->wtFlags & TERM_CODED );
@@ -129400,14 +129664,20 @@
129664 pE = pTerm->pExpr;
129665 assert( pE!=0 );
129666 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
129667 continue;
129668 }
129669
129670 if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
129671 iNext = 2;
129672 continue;
129673 }
129674 if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){
129675 if( iNext==0 ) iNext = 3;
129676 continue;
129677 }
129678
129679 if( pTerm->wtFlags & TERM_LIKECOND ){
129680 /* If the TERM_LIKECOND flag is set, that means that the range search
129681 ** is sufficient to guarantee that the LIKE operator is true, so we
129682 ** can skip the call to the like(A,B) function. But this only works
129683 ** for strings. So do not skip the call to the function on the pass
@@ -129419,16 +129689,22 @@
129689 assert( x>0 );
129690 skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));
129691 VdbeCoverage(v);
129692 #endif
129693 }
129694 #ifdef WHERETRACE_ENABLED /* 0xffff */
129695 if( sqlite3WhereTrace ){
129696 VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
129697 pWC->nTerm-j, pTerm, iLoop));
129698 }
129699 #endif
129700 sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
129701 if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
129702 pTerm->wtFlags |= TERM_CODED;
129703 }
129704 iLoop = iNext;
129705 }while( iLoop>0 );
129706
129707 /* Insert code to test for implied constraints based on transitivity
129708 ** of the "==" operator.
129709 **
129710 ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123"
@@ -130438,11 +130714,13 @@
130714 }else if( op==TK_ISNULL ){
130715 pTerm->prereqRight = 0;
130716 }else{
130717 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
130718 }
130719 pMaskSet->bVarSelect = 0;
130720 prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);
130721 if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
130722 if( ExprHasProperty(pExpr, EP_FromJoin) ){
130723 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
130724 prereqAll |= x;
130725 extraRight = x-1; /* ON clause terms may not be used with an index
130726 ** on left table of a LEFT JOIN. Ticket #3015 */
@@ -130869,13 +131147,16 @@
131147 if( p->op==TK_COLUMN ){
131148 return sqlite3WhereGetMask(pMaskSet, p->iTable);
131149 }
131150 mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
131151 assert( !ExprHasProperty(p, EP_TokenOnly) );
 
131152 if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
131153 if( p->pRight ){
131154 mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
131155 assert( p->x.pList==0 );
131156 }else if( ExprHasProperty(p, EP_xIsSelect) ){
131157 if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
131158 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);
131159 }else if( p->x.pList ){
131160 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);
131161 }
131162 return mask;
@@ -135501,13 +135782,17 @@
135782 for(ii=0; ii<pTabList->nSrc; ii++){
135783 createMask(pMaskSet, pTabList->a[ii].iCursor);
135784 sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);
135785 }
135786 #ifdef SQLITE_DEBUG
135787 {
135788 Bitmask mx = 0;
135789 for(ii=0; ii<pTabList->nSrc; ii++){
135790 Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);
135791 assert( m>=mx );
135792 mx = m;
135793 }
135794 }
135795 #endif
135796
135797 /* Analyze all of the subexpressions. */
135798 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
@@ -136348,20 +136633,20 @@
136633 #define sqlite3ParserARG_SDECL Parse *pParse;
136634 #define sqlite3ParserARG_PDECL ,Parse *pParse
136635 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
136636 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
136637 #define YYFALLBACK 1
136638 #define YYNSTATE 455
136639 #define YYNRULE 330
136640 #define YY_MAX_SHIFT 454
136641 #define YY_MIN_SHIFTREDUCE 665
136642 #define YY_MAX_SHIFTREDUCE 994
136643 #define YY_MIN_REDUCE 995
136644 #define YY_MAX_REDUCE 1324
136645 #define YY_ERROR_ACTION 1325
136646 #define YY_ACCEPT_ACTION 1326
136647 #define YY_NO_ACTION 1327
136648 /************* End control #defines *******************************************/
136649
136650 /* Define the yytestcase() macro to be a no-op if is not already defined
136651 ** otherwise.
136652 **
@@ -136429,169 +136714,169 @@
136714 ** yy_reduce_ofst[] For each state, the offset into yy_action for
136715 ** shifting non-terminals after a reduce.
136716 ** yy_default[] Default action for each state.
136717 **
136718 *********** Begin parsing tables **********************************************/
136719 #define YY_ACTTAB_COUNT (1565)
136720 static const YYACTIONTYPE yy_action[] = {
136721 /* 0 */ 324, 410, 342, 748, 748, 203, 941, 353, 971, 98,
136722 /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95,
136723 /* 20 */ 94, 94, 94, 93, 350, 1326, 155, 155, 2, 809,
136724 /* 30 */ 973, 973, 98, 98, 98, 98, 20, 96, 96, 96,
136725 /* 40 */ 96, 95, 95, 94, 94, 94, 93, 350, 92, 89,
136726 /* 50 */ 178, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136727 /* 60 */ 98, 98, 98, 98, 350, 96, 96, 96, 96, 95,
136728 /* 70 */ 95, 94, 94, 94, 93, 350, 324, 339, 971, 262,
136729 /* 80 */ 364, 251, 212, 169, 287, 404, 282, 403, 199, 787,
136730 /* 90 */ 242, 411, 21, 952, 378, 280, 93, 350, 788, 95,
136731 /* 100 */ 95, 94, 94, 94, 93, 350, 973, 973, 96, 96,
136732 /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 350, 809,
136733 /* 120 */ 328, 242, 411, 1238, 828, 1238, 132, 99, 100, 90,
136734 /* 130 */ 849, 852, 841, 841, 97, 97, 98, 98, 98, 98,
136735 /* 140 */ 449, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136736 /* 150 */ 93, 350, 324, 821, 348, 347, 120, 815, 120, 75,
136737 /* 160 */ 52, 52, 952, 953, 954, 1086, 979, 146, 360, 262,
136738 /* 170 */ 369, 261, 952, 977, 956, 978, 92, 89, 178, 370,
136739 /* 180 */ 230, 370, 973, 973, 1143, 360, 359, 101, 820, 820,
136740 /* 190 */ 822, 383, 24, 1289, 380, 427, 412, 368, 980, 379,
136741 /* 200 */ 980, 1034, 324, 99, 100, 90, 849, 852, 841, 841,
136742 /* 210 */ 97, 97, 98, 98, 98, 98, 372, 96, 96, 96,
136743 /* 220 */ 96, 95, 95, 94, 94, 94, 93, 350, 952, 132,
136744 /* 230 */ 892, 449, 973, 973, 892, 60, 94, 94, 94, 93,
136745 /* 240 */ 350, 952, 953, 954, 956, 103, 360, 952, 384, 333,
136746 /* 250 */ 698, 52, 52, 99, 100, 90, 849, 852, 841, 841,
136747 /* 260 */ 97, 97, 98, 98, 98, 98, 1024, 96, 96, 96,
136748 /* 270 */ 96, 95, 95, 94, 94, 94, 93, 350, 324, 454,
136749 /* 280 */ 997, 449, 227, 61, 157, 243, 343, 114, 1027, 1214,
136750 /* 290 */ 147, 828, 952, 372, 1073, 952, 319, 952, 953, 954,
136751 /* 300 */ 194, 10, 10, 401, 398, 397, 1214, 1216, 973, 973,
136752 /* 310 */ 758, 171, 170, 157, 396, 336, 952, 953, 954, 698,
136753 /* 320 */ 821, 310, 153, 952, 815, 320, 82, 23, 80, 99,
136754 /* 330 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136755 /* 340 */ 98, 98, 890, 96, 96, 96, 96, 95, 95, 94,
136756 /* 350 */ 94, 94, 93, 350, 324, 820, 820, 822, 277, 231,
136757 /* 360 */ 300, 952, 953, 954, 952, 953, 954, 1214, 194, 25,
136758 /* 370 */ 449, 401, 398, 397, 952, 354, 300, 449, 952, 74,
136759 /* 380 */ 449, 1, 396, 132, 973, 973, 952, 224, 224, 809,
136760 /* 390 */ 10, 10, 952, 953, 954, 1293, 132, 52, 52, 414,
136761 /* 400 */ 52, 52, 1065, 1065, 338, 99, 100, 90, 849, 852,
136762 /* 410 */ 841, 841, 97, 97, 98, 98, 98, 98, 1116, 96,
136763 /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 350,
136764 /* 430 */ 324, 1115, 427, 417, 702, 427, 426, 1263, 1263, 262,
136765 /* 440 */ 369, 261, 952, 952, 953, 954, 753, 952, 953, 954,
136766 /* 450 */ 449, 752, 449, 1060, 1039, 952, 953, 954, 442, 707,
136767 /* 460 */ 973, 973, 1060, 393, 92, 89, 178, 446, 446, 446,
136768 /* 470 */ 51, 51, 52, 52, 438, 774, 1026, 92, 89, 178,
136769 /* 480 */ 172, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136770 /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95,
136771 /* 500 */ 95, 94, 94, 94, 93, 350, 324, 427, 407, 911,
136772 /* 510 */ 695, 952, 953, 954, 92, 89, 178, 224, 224, 157,
136773 /* 520 */ 241, 221, 418, 299, 772, 912, 415, 374, 449, 414,
136774 /* 530 */ 58, 323, 1063, 1063, 1245, 378, 973, 973, 378, 773,
136775 /* 540 */ 448, 913, 362, 736, 296, 682, 9, 9, 52, 52,
136776 /* 550 */ 234, 329, 234, 256, 416, 737, 280, 99, 100, 90,
136777 /* 560 */ 849, 852, 841, 841, 97, 97, 98, 98, 98, 98,
136778 /* 570 */ 449, 96, 96, 96, 96, 95, 95, 94, 94, 94,
136779 /* 580 */ 93, 350, 324, 422, 72, 449, 829, 120, 367, 449,
136780 /* 590 */ 10, 10, 5, 301, 203, 449, 177, 971, 253, 419,
136781 /* 600 */ 255, 772, 200, 175, 233, 10, 10, 838, 838, 36,
136782 /* 610 */ 36, 1292, 973, 973, 725, 37, 37, 348, 347, 424,
136783 /* 620 */ 203, 260, 772, 971, 232, 932, 1319, 872, 337, 1319,
136784 /* 630 */ 421, 850, 853, 99, 100, 90, 849, 852, 841, 841,
136785 /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96,
136786 /* 650 */ 96, 95, 95, 94, 94, 94, 93, 350, 324, 842,
136787 /* 660 */ 449, 980, 814, 980, 1203, 449, 911, 971, 716, 349,
136788 /* 670 */ 349, 349, 930, 177, 449, 932, 1320, 254, 198, 1320,
136789 /* 680 */ 12, 12, 912, 402, 449, 27, 27, 250, 973, 973,
136790 /* 690 */ 118, 717, 162, 971, 38, 38, 268, 176, 913, 772,
136791 /* 700 */ 432, 1268, 941, 353, 39, 39, 316, 993, 324, 99,
136792 /* 710 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136793 /* 720 */ 98, 98, 930, 96, 96, 96, 96, 95, 95, 94,
136794 /* 730 */ 94, 94, 93, 350, 449, 329, 449, 357, 973, 973,
136795 /* 740 */ 1043, 316, 931, 340, 895, 895, 386, 670, 671, 672,
136796 /* 750 */ 275, 1321, 317, 994, 40, 40, 41, 41, 268, 99,
136797 /* 760 */ 100, 90, 849, 852, 841, 841, 97, 97, 98, 98,
136798 /* 770 */ 98, 98, 449, 96, 96, 96, 96, 95, 95, 94,
136799 /* 780 */ 94, 94, 93, 350, 324, 449, 355, 449, 994, 449,
136800 /* 790 */ 1018, 330, 42, 42, 787, 270, 449, 273, 449, 228,
136801 /* 800 */ 449, 298, 449, 788, 449, 28, 28, 29, 29, 31,
136802 /* 810 */ 31, 449, 1143, 449, 973, 973, 43, 43, 44, 44,
136803 /* 820 */ 45, 45, 11, 11, 46, 46, 889, 78, 889, 268,
136804 /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 849, 852,
136805 /* 840 */ 841, 841, 97, 97, 98, 98, 98, 98, 449, 96,
136806 /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 350,
136807 /* 860 */ 324, 449, 117, 449, 1075, 158, 449, 692, 48, 48,
136808 /* 870 */ 229, 1244, 449, 1253, 449, 414, 449, 334, 449, 245,
136809 /* 880 */ 449, 33, 33, 49, 49, 449, 50, 50, 246, 1143,
136810 /* 890 */ 973, 973, 34, 34, 122, 122, 123, 123, 124, 124,
136811 /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195,
136812 /* 910 */ 324, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136813 /* 920 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136814 /* 930 */ 95, 94, 94, 94, 93, 350, 449, 692, 449, 1143,
136815 /* 940 */ 973, 973, 970, 1210, 106, 106, 268, 1212, 268, 1269,
136816 /* 950 */ 2, 888, 268, 888, 335, 1042, 53, 53, 107, 107,
136817 /* 960 */ 324, 99, 100, 90, 849, 852, 841, 841, 97, 97,
136818 /* 970 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136819 /* 980 */ 95, 94, 94, 94, 93, 350, 449, 1072, 449, 1068,
136820 /* 990 */ 973, 973, 1041, 267, 108, 108, 445, 330, 331, 133,
136821 /* 1000 */ 223, 175, 301, 225, 385, 1258, 104, 104, 121, 121,
136822 /* 1010 */ 324, 99, 88, 90, 849, 852, 841, 841, 97, 97,
136823 /* 1020 */ 98, 98, 98, 98, 1143, 96, 96, 96, 96, 95,
136824 /* 1030 */ 95, 94, 94, 94, 93, 350, 449, 346, 449, 167,
136825 /* 1040 */ 973, 973, 927, 811, 371, 318, 202, 202, 373, 263,
136826 /* 1050 */ 394, 202, 74, 208, 722, 723, 119, 119, 112, 112,
136827 /* 1060 */ 324, 406, 100, 90, 849, 852, 841, 841, 97, 97,
136828 /* 1070 */ 98, 98, 98, 98, 449, 96, 96, 96, 96, 95,
136829 /* 1080 */ 95, 94, 94, 94, 93, 350, 449, 753, 449, 344,
136830 /* 1090 */ 973, 973, 752, 278, 111, 111, 74, 715, 714, 705,
136831 /* 1100 */ 286, 879, 750, 1282, 257, 77, 109, 109, 110, 110,
136832 /* 1110 */ 1233, 285, 1136, 90, 849, 852, 841, 841, 97, 97,
136833 /* 1120 */ 98, 98, 98, 98, 1236, 96, 96, 96, 96, 95,
136834 /* 1130 */ 95, 94, 94, 94, 93, 350, 86, 444, 449, 3,
136835 /* 1140 */ 1196, 449, 1071, 132, 351, 120, 1015, 86, 444, 781,
136836 /* 1150 */ 3, 1093, 202, 376, 447, 351, 1232, 120, 55, 55,
136837 /* 1160 */ 449, 57, 57, 824, 875, 447, 449, 208, 449, 705,
136838 /* 1170 */ 449, 879, 237, 433, 435, 120, 439, 428, 361, 120,
136839 /* 1180 */ 54, 54, 132, 449, 433, 828, 52, 52, 26, 26,
136840 /* 1190 */ 30, 30, 381, 132, 408, 443, 828, 690, 264, 389,
136841 /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120,
136842 /* 1210 */ 120, 276, 85, 351, 451, 450, 83, 84, 815, 1056,
136843 /* 1220 */ 1040, 427, 429, 85, 351, 451, 450, 120, 120, 815,
136844 /* 1230 */ 377, 218, 281, 824, 1109, 1142, 86, 444, 409, 3,
136845 /* 1240 */ 1089, 1100, 430, 431, 351, 302, 303, 1149, 1023, 820,
136846 /* 1250 */ 820, 822, 823, 19, 447, 1017, 1006, 1005, 1007, 1276,
136847 /* 1260 */ 820, 820, 822, 823, 19, 289, 159, 291, 293, 7,
136848 /* 1270 */ 315, 173, 259, 433, 1131, 363, 252, 1235, 375, 1039,
136849 /* 1280 */ 295, 434, 168, 988, 399, 828, 284, 1207, 1206, 205,
136850 /* 1290 */ 1279, 308, 1252, 86, 444, 985, 3, 1250, 332, 144,
136851 /* 1300 */ 130, 351, 72, 135, 59, 83, 84, 757, 137, 365,
136852 /* 1310 */ 1128, 447, 85, 351, 451, 450, 139, 226, 815, 140,
136853 /* 1320 */ 156, 62, 314, 314, 313, 215, 311, 366, 392, 679,
136854 /* 1330 */ 433, 185, 141, 1237, 142, 160, 148, 1138, 1201, 382,
136855 /* 1340 */ 189, 67, 828, 180, 388, 248, 1221, 1101, 219, 820,
136856 /* 1350 */ 820, 822, 823, 19, 247, 190, 266, 154, 390, 271,
136857 /* 1360 */ 191, 192, 83, 84, 1008, 405, 1059, 182, 321, 85,
136858 /* 1370 */ 351, 451, 450, 1058, 183, 815, 341, 132, 181, 707,
136859 /* 1380 */ 1057, 420, 76, 444, 1031, 3, 322, 1030, 283, 1050,
136860 /* 1390 */ 351, 1097, 1029, 1291, 1049, 71, 204, 6, 288, 290,
136861 /* 1400 */ 447, 1098, 1096, 1095, 79, 292, 820, 820, 822, 823,
136862 /* 1410 */ 19, 294, 297, 437, 345, 441, 102, 1187, 1079, 433,
136863 /* 1420 */ 238, 425, 73, 305, 239, 304, 325, 240, 423, 306,
136864 /* 1430 */ 307, 828, 213, 1014, 22, 947, 452, 214, 216, 217,
136865 /* 1440 */ 453, 1003, 115, 998, 125, 126, 235, 127, 666, 352,
136866 /* 1450 */ 326, 83, 84, 358, 166, 244, 179, 327, 85, 351,
136867 /* 1460 */ 451, 450, 134, 356, 815, 113, 887, 807, 885, 136,
136868 /* 1470 */ 128, 138, 739, 258, 184, 901, 143, 145, 63, 64,
136869 /* 1480 */ 65, 66, 129, 904, 187, 186, 900, 8, 13, 188,
136870 /* 1490 */ 265, 893, 149, 202, 982, 820, 820, 822, 823, 19,
136871 /* 1500 */ 150, 387, 161, 681, 285, 391, 151, 395, 400, 193,
136872 /* 1510 */ 68, 14, 236, 279, 15, 69, 718, 827, 131, 826,
136873 /* 1520 */ 855, 70, 747, 16, 413, 751, 4, 174, 220, 222,
136874 /* 1530 */ 152, 780, 859, 775, 201, 77, 74, 870, 17, 856,
136875 /* 1540 */ 854, 910, 18, 909, 207, 206, 936, 163, 436, 210,
136876 /* 1550 */ 937, 164, 209, 165, 440, 858, 825, 691, 87, 211,
136877 /* 1560 */ 309, 312, 1284, 942, 1283,
136878 };
136879 static const YYCODETYPE yy_lookahead[] = {
136880 /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79,
136881 /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
136882 /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58,
@@ -136734,26 +137019,26 @@
137019 /* 1390 */ 27, 216, 174, 174, 182, 107, 159, 22, 215, 215,
137020 /* 1400 */ 37, 216, 216, 216, 137, 215, 132, 133, 134, 135,
137021 /* 1410 */ 136, 215, 159, 177, 94, 177, 129, 224, 205, 56,
137022 /* 1420 */ 226, 126, 128, 203, 229, 204, 114, 229, 127, 202,
137023 /* 1430 */ 201, 68, 25, 162, 26, 13, 161, 153, 153, 6,
137024 /* 1440 */ 151, 151, 178, 151, 165, 165, 178, 165, 4, 3,
137025 /* 1450 */ 249, 88, 89, 141, 22, 142, 15, 249, 95, 96,
137026 /* 1460 */ 97, 98, 246, 67, 101, 16, 23, 120, 23, 131,
137027 /* 1470 */ 111, 123, 20, 16, 125, 1, 123, 131, 78, 78,
137028 /* 1480 */ 78, 78, 111, 96, 122, 35, 1, 5, 22, 107,
137029 /* 1490 */ 140, 53, 53, 26, 60, 132, 133, 134, 135, 136,
137030 /* 1500 */ 107, 43, 24, 20, 112, 19, 22, 52, 52, 105,
137031 /* 1510 */ 22, 22, 52, 23, 22, 22, 29, 23, 39, 23,
137032 /* 1520 */ 23, 26, 116, 22, 26, 23, 22, 122, 23, 23,
137033 /* 1530 */ 22, 96, 11, 124, 35, 26, 26, 23, 35, 23,
137034 /* 1540 */ 23, 23, 35, 23, 22, 26, 23, 22, 24, 122,
137035 /* 1550 */ 23, 22, 26, 22, 24, 23, 23, 23, 22, 122,
137036 /* 1560 */ 23, 15, 122, 1, 122,
137037 };
137038 #define YY_SHIFT_USE_DFLT (1565)
137039 #define YY_SHIFT_COUNT (454)
137040 #define YY_SHIFT_MIN (-114)
137041 #define YY_SHIFT_MAX (1562)
137042 static const short yy_shift_ofst[] = {
137043 /* 0 */ 5, 1117, 1312, 1128, 1274, 1274, 1274, 1274, 61, -19,
137044 /* 10 */ 57, 57, 183, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
@@ -136765,15 +137050,15 @@
137050 /* 70 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
137051 /* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
137052 /* 90 */ 1363, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
137053 /* 100 */ 1274, 1274, 1274, 1274, -70, -47, -47, -47, -47, -47,
137054 /* 110 */ 24, 11, 146, 296, 524, 444, 529, 529, 296, 3,
137055 /* 120 */ 2, -30, 1565, 1565, 1565, -17, -17, -17, 145, 145,
137056 /* 130 */ 497, 497, 265, 603, 653, 296, 296, 296, 296, 296,
137057 /* 140 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
137058 /* 150 */ 296, 296, 296, 296, 296, 701, 1078, 147, 147, 2,
137059 /* 160 */ 164, 164, 164, 164, 164, 164, 1565, 1565, 1565, 223,
137060 /* 170 */ 56, 56, 268, 269, 220, 347, 351, 415, 359, 296,
137061 /* 180 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296,
137062 /* 190 */ 296, 296, 296, 296, 296, 632, 632, 632, 296, 296,
137063 /* 200 */ 498, 296, 296, 296, 570, 296, 296, 654, 296, 296,
137064 /* 210 */ 296, 296, 296, 296, 296, 296, 296, 296, 636, 200,
@@ -136784,30 +137069,30 @@
137069 /* 260 */ 1277, 1230, 1230, 1172, 1167, 1310, 1204, 1299, 1167, 1167,
137070 /* 270 */ 1310, 1335, 1167, 1310, 1167, 1310, 1335, 1258, 1258, 1258,
137071 /* 280 */ 1329, 1335, 1258, 1273, 1258, 1329, 1258, 1258, 1256, 1288,
137072 /* 290 */ 1256, 1288, 1256, 1288, 1256, 1288, 1167, 1375, 1167, 1267,
137073 /* 300 */ 1335, 1320, 1320, 1335, 1287, 1295, 1294, 1301, 1172, 1407,
137074 /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1565, 1565, 1565, 1565,
137075 /* 320 */ 1565, 1565, 1565, 1565, 558, 537, 684, 719, 734, 799,
137076 /* 330 */ 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070, 1072,
137077 /* 340 */ 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819, 1174,
137078 /* 350 */ 1136, 981, 1444, 1446, 1432, 1313, 1441, 1396, 1449, 1443,
137079 /* 360 */ 1445, 1347, 1338, 1359, 1348, 1452, 1349, 1457, 1474, 1353,
137080 /* 370 */ 1346, 1400, 1401, 1402, 1403, 1371, 1387, 1450, 1362, 1485,
137081 /* 380 */ 1482, 1466, 1382, 1350, 1438, 1467, 1439, 1434, 1458, 1393,
137082 /* 390 */ 1478, 1483, 1486, 1392, 1404, 1484, 1455, 1488, 1489, 1490,
137083 /* 400 */ 1492, 1456, 1487, 1493, 1460, 1479, 1494, 1496, 1497, 1495,
137084 /* 410 */ 1406, 1501, 1502, 1504, 1498, 1405, 1505, 1506, 1435, 1499,
137085 /* 420 */ 1508, 1409, 1509, 1503, 1510, 1507, 1514, 1509, 1516, 1517,
137086 /* 430 */ 1518, 1519, 1520, 1522, 1521, 1523, 1525, 1524, 1526, 1527,
137087 /* 440 */ 1529, 1530, 1526, 1532, 1531, 1533, 1534, 1536, 1427, 1437,
137088 /* 450 */ 1440, 1442, 1537, 1546, 1562,
137089 };
137090 #define YY_REDUCE_USE_DFLT (-174)
137091 #define YY_REDUCE_COUNT (323)
137092 #define YY_REDUCE_MIN (-173)
137093 #define YY_REDUCE_MAX (1292)
137094 static const short yy_reduce_ofst[] = {
137095 /* 0 */ -119, 1014, 131, 1031, -12, 225, 228, 300, -40, -45,
137096 /* 10 */ 243, 256, 293, 129, 218, 418, 79, 376, 433, 298,
137097 /* 20 */ 16, 137, 367, 323, -38, 391, -173, -173, -173, -173,
137098 /* 30 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173,
@@ -136836,60 +137121,60 @@
137121 /* 260 */ 1115, 1147, 1148, 1137, 1180, 1182, 1110, 1121, 1188, 1189,
137122 /* 270 */ 1197, 1181, 1200, 1202, 1205, 1203, 1191, 1192, 1199, 1206,
137123 /* 280 */ 1207, 1209, 1210, 1211, 1214, 1212, 1218, 1219, 1175, 1183,
137124 /* 290 */ 1185, 1184, 1186, 1190, 1187, 1196, 1237, 1193, 1253, 1194,
137125 /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271,
137126 /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1201, 1208, 1216, 1279,
137127 /* 320 */ 1280, 1264, 1268, 1282,
137128 };
137129 static const YYACTIONTYPE yy_default[] = {
137130 /* 0 */ 1273, 1263, 1263, 1263, 1196, 1196, 1196, 1196, 1263, 1090,
137131 /* 10 */ 1119, 1119, 1247, 1325, 1325, 1325, 1325, 1325, 1325, 1195,
137132 /* 20 */ 1325, 1325, 1325, 1325, 1263, 1094, 1125, 1325, 1325, 1325,
137133 /* 30 */ 1325, 1197, 1198, 1325, 1325, 1325, 1246, 1248, 1135, 1134,
137134 /* 40 */ 1133, 1132, 1229, 1106, 1130, 1123, 1127, 1197, 1191, 1192,
137135 /* 50 */ 1190, 1194, 1198, 1325, 1126, 1161, 1175, 1160, 1325, 1325,
137136 /* 60 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137137 /* 70 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137138 /* 80 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137139 /* 90 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137140 /* 100 */ 1325, 1325, 1325, 1325, 1169, 1174, 1181, 1173, 1170, 1163,
137141 /* 110 */ 1162, 1164, 1165, 1325, 1013, 1061, 1325, 1325, 1325, 1166,
137142 /* 120 */ 1325, 1167, 1178, 1177, 1176, 1254, 1281, 1280, 1325, 1325,
137143 /* 130 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137144 /* 140 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137145 /* 150 */ 1325, 1325, 1325, 1325, 1325, 1273, 1263, 1019, 1019, 1325,
137146 /* 160 */ 1263, 1263, 1263, 1263, 1263, 1263, 1259, 1094, 1085, 1325,
137147 /* 170 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137148 /* 180 */ 1251, 1249, 1325, 1211, 1325, 1325, 1325, 1325, 1325, 1325,
137149 /* 190 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137150 /* 200 */ 1325, 1325, 1325, 1325, 1090, 1325, 1325, 1325, 1325, 1325,
137151 /* 210 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1275, 1325, 1224,
137152 /* 220 */ 1090, 1090, 1090, 1092, 1074, 1084, 999, 1129, 1108, 1108,
137153 /* 230 */ 1314, 1129, 1314, 1036, 1295, 1033, 1119, 1108, 1193, 1119,
137154 /* 240 */ 1119, 1091, 1084, 1325, 1317, 1099, 1099, 1316, 1316, 1099,
137155 /* 250 */ 1140, 1064, 1129, 1070, 1070, 1070, 1070, 1099, 1010, 1129,
137156 /* 260 */ 1140, 1064, 1064, 1129, 1099, 1010, 1228, 1311, 1099, 1099,
137157 /* 270 */ 1010, 1204, 1099, 1010, 1099, 1010, 1204, 1062, 1062, 1062,
137158 /* 280 */ 1051, 1204, 1062, 1036, 1062, 1051, 1062, 1062, 1112, 1107,
137159 /* 290 */ 1112, 1107, 1112, 1107, 1112, 1107, 1099, 1199, 1099, 1325,
137160 /* 300 */ 1204, 1208, 1208, 1204, 1124, 1113, 1122, 1120, 1129, 1016,
137161 /* 310 */ 1054, 1278, 1278, 1274, 1274, 1274, 1322, 1322, 1259, 1290,
137162 /* 320 */ 1290, 1038, 1038, 1290, 1325, 1325, 1325, 1325, 1325, 1325,
137163 /* 330 */ 1285, 1325, 1213, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137164 /* 340 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137165 /* 350 */ 1325, 1146, 1325, 995, 1256, 1325, 1325, 1255, 1325, 1325,
137166 /* 360 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137167 /* 370 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1313, 1325,
137168 /* 380 */ 1325, 1325, 1325, 1325, 1325, 1227, 1226, 1325, 1325, 1325,
137169 /* 390 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137170 /* 400 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,
137171 /* 410 */ 1076, 1325, 1325, 1325, 1299, 1325, 1325, 1325, 1325, 1325,
137172 /* 420 */ 1325, 1325, 1121, 1325, 1114, 1325, 1325, 1304, 1325, 1325,
137173 /* 430 */ 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1265, 1325,
137174 /* 440 */ 1325, 1325, 1264, 1325, 1325, 1325, 1325, 1325, 1148, 1325,
137175 /* 450 */ 1147, 1151, 1325, 1004, 1325,
137176 };
137177 /********** End of lemon-generated parsing tables *****************************/
137178
137179 /* The next table maps tokens (terminal symbols) into fallback tokens.
137180 ** If a construct like the following:
@@ -137138,333 +137423,332 @@
137423 /* 3 */ "cmd ::= BEGIN transtype trans_opt",
137424 /* 4 */ "transtype ::=",
137425 /* 5 */ "transtype ::= DEFERRED",
137426 /* 6 */ "transtype ::= IMMEDIATE",
137427 /* 7 */ "transtype ::= EXCLUSIVE",
137428 /* 8 */ "cmd ::= COMMIT|END trans_opt",
137429 /* 9 */ "cmd ::= ROLLBACK trans_opt",
137430 /* 10 */ "cmd ::= SAVEPOINT nm",
137431 /* 11 */ "cmd ::= RELEASE savepoint_opt nm",
137432 /* 12 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
137433 /* 13 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
137434 /* 14 */ "createkw ::= CREATE",
137435 /* 15 */ "ifnotexists ::=",
137436 /* 16 */ "ifnotexists ::= IF NOT EXISTS",
137437 /* 17 */ "temp ::= TEMP",
137438 /* 18 */ "temp ::=",
137439 /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
137440 /* 20 */ "create_table_args ::= AS select",
137441 /* 21 */ "table_options ::=",
137442 /* 22 */ "table_options ::= WITHOUT nm",
137443 /* 23 */ "columnname ::= nm typetoken",
137444 /* 24 */ "typetoken ::=",
137445 /* 25 */ "typetoken ::= typename LP signed RP",
137446 /* 26 */ "typetoken ::= typename LP signed COMMA signed RP",
137447 /* 27 */ "typename ::= typename ID|STRING",
137448 /* 28 */ "ccons ::= CONSTRAINT nm",
137449 /* 29 */ "ccons ::= DEFAULT term",
137450 /* 30 */ "ccons ::= DEFAULT LP expr RP",
137451 /* 31 */ "ccons ::= DEFAULT PLUS term",
137452 /* 32 */ "ccons ::= DEFAULT MINUS term",
137453 /* 33 */ "ccons ::= DEFAULT ID|INDEXED",
137454 /* 34 */ "ccons ::= NOT NULL onconf",
137455 /* 35 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
137456 /* 36 */ "ccons ::= UNIQUE onconf",
137457 /* 37 */ "ccons ::= CHECK LP expr RP",
137458 /* 38 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
137459 /* 39 */ "ccons ::= defer_subclause",
137460 /* 40 */ "ccons ::= COLLATE ID|STRING",
137461 /* 41 */ "autoinc ::=",
137462 /* 42 */ "autoinc ::= AUTOINCR",
137463 /* 43 */ "refargs ::=",
137464 /* 44 */ "refargs ::= refargs refarg",
137465 /* 45 */ "refarg ::= MATCH nm",
137466 /* 46 */ "refarg ::= ON INSERT refact",
137467 /* 47 */ "refarg ::= ON DELETE refact",
137468 /* 48 */ "refarg ::= ON UPDATE refact",
137469 /* 49 */ "refact ::= SET NULL",
137470 /* 50 */ "refact ::= SET DEFAULT",
137471 /* 51 */ "refact ::= CASCADE",
137472 /* 52 */ "refact ::= RESTRICT",
137473 /* 53 */ "refact ::= NO ACTION",
137474 /* 54 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
137475 /* 55 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
137476 /* 56 */ "init_deferred_pred_opt ::=",
137477 /* 57 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
137478 /* 58 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
137479 /* 59 */ "conslist_opt ::=",
137480 /* 60 */ "tconscomma ::= COMMA",
137481 /* 61 */ "tcons ::= CONSTRAINT nm",
137482 /* 62 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
137483 /* 63 */ "tcons ::= UNIQUE LP sortlist RP onconf",
137484 /* 64 */ "tcons ::= CHECK LP expr RP onconf",
137485 /* 65 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
137486 /* 66 */ "defer_subclause_opt ::=",
137487 /* 67 */ "onconf ::=",
137488 /* 68 */ "onconf ::= ON CONFLICT resolvetype",
137489 /* 69 */ "orconf ::=",
137490 /* 70 */ "orconf ::= OR resolvetype",
137491 /* 71 */ "resolvetype ::= IGNORE",
137492 /* 72 */ "resolvetype ::= REPLACE",
137493 /* 73 */ "cmd ::= DROP TABLE ifexists fullname",
137494 /* 74 */ "ifexists ::= IF EXISTS",
137495 /* 75 */ "ifexists ::=",
137496 /* 76 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
137497 /* 77 */ "cmd ::= DROP VIEW ifexists fullname",
137498 /* 78 */ "cmd ::= select",
137499 /* 79 */ "select ::= with selectnowith",
137500 /* 80 */ "selectnowith ::= selectnowith multiselect_op oneselect",
137501 /* 81 */ "multiselect_op ::= UNION",
137502 /* 82 */ "multiselect_op ::= UNION ALL",
137503 /* 83 */ "multiselect_op ::= EXCEPT|INTERSECT",
137504 /* 84 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
137505 /* 85 */ "values ::= VALUES LP nexprlist RP",
137506 /* 86 */ "values ::= values COMMA LP exprlist RP",
137507 /* 87 */ "distinct ::= DISTINCT",
137508 /* 88 */ "distinct ::= ALL",
137509 /* 89 */ "distinct ::=",
137510 /* 90 */ "sclp ::=",
137511 /* 91 */ "selcollist ::= sclp expr as",
137512 /* 92 */ "selcollist ::= sclp STAR",
137513 /* 93 */ "selcollist ::= sclp nm DOT STAR",
137514 /* 94 */ "as ::= AS nm",
137515 /* 95 */ "as ::=",
137516 /* 96 */ "from ::=",
137517 /* 97 */ "from ::= FROM seltablist",
137518 /* 98 */ "stl_prefix ::= seltablist joinop",
137519 /* 99 */ "stl_prefix ::=",
137520 /* 100 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
137521 /* 101 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
137522 /* 102 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
137523 /* 103 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
137524 /* 104 */ "dbnm ::=",
137525 /* 105 */ "dbnm ::= DOT nm",
137526 /* 106 */ "fullname ::= nm dbnm",
137527 /* 107 */ "joinop ::= COMMA|JOIN",
137528 /* 108 */ "joinop ::= JOIN_KW JOIN",
137529 /* 109 */ "joinop ::= JOIN_KW nm JOIN",
137530 /* 110 */ "joinop ::= JOIN_KW nm nm JOIN",
137531 /* 111 */ "on_opt ::= ON expr",
137532 /* 112 */ "on_opt ::=",
137533 /* 113 */ "indexed_opt ::=",
137534 /* 114 */ "indexed_opt ::= INDEXED BY nm",
137535 /* 115 */ "indexed_opt ::= NOT INDEXED",
137536 /* 116 */ "using_opt ::= USING LP idlist RP",
137537 /* 117 */ "using_opt ::=",
137538 /* 118 */ "orderby_opt ::=",
137539 /* 119 */ "orderby_opt ::= ORDER BY sortlist",
137540 /* 120 */ "sortlist ::= sortlist COMMA expr sortorder",
137541 /* 121 */ "sortlist ::= expr sortorder",
137542 /* 122 */ "sortorder ::= ASC",
137543 /* 123 */ "sortorder ::= DESC",
137544 /* 124 */ "sortorder ::=",
137545 /* 125 */ "groupby_opt ::=",
137546 /* 126 */ "groupby_opt ::= GROUP BY nexprlist",
137547 /* 127 */ "having_opt ::=",
137548 /* 128 */ "having_opt ::= HAVING expr",
137549 /* 129 */ "limit_opt ::=",
137550 /* 130 */ "limit_opt ::= LIMIT expr",
137551 /* 131 */ "limit_opt ::= LIMIT expr OFFSET expr",
137552 /* 132 */ "limit_opt ::= LIMIT expr COMMA expr",
137553 /* 133 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
137554 /* 134 */ "where_opt ::=",
137555 /* 135 */ "where_opt ::= WHERE expr",
137556 /* 136 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
137557 /* 137 */ "setlist ::= setlist COMMA nm EQ expr",
137558 /* 138 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
137559 /* 139 */ "setlist ::= nm EQ expr",
137560 /* 140 */ "setlist ::= LP idlist RP EQ expr",
137561 /* 141 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
137562 /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
137563 /* 143 */ "insert_cmd ::= INSERT orconf",
137564 /* 144 */ "insert_cmd ::= REPLACE",
137565 /* 145 */ "idlist_opt ::=",
137566 /* 146 */ "idlist_opt ::= LP idlist RP",
137567 /* 147 */ "idlist ::= idlist COMMA nm",
137568 /* 148 */ "idlist ::= nm",
137569 /* 149 */ "expr ::= LP expr RP",
137570 /* 150 */ "term ::= NULL",
137571 /* 151 */ "expr ::= ID|INDEXED",
137572 /* 152 */ "expr ::= JOIN_KW",
137573 /* 153 */ "expr ::= nm DOT nm",
137574 /* 154 */ "expr ::= nm DOT nm DOT nm",
137575 /* 155 */ "term ::= FLOAT|BLOB",
137576 /* 156 */ "term ::= STRING",
137577 /* 157 */ "term ::= INTEGER",
137578 /* 158 */ "expr ::= VARIABLE",
137579 /* 159 */ "expr ::= expr COLLATE ID|STRING",
137580 /* 160 */ "expr ::= CAST LP expr AS typetoken RP",
137581 /* 161 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
137582 /* 162 */ "expr ::= ID|INDEXED LP STAR RP",
137583 /* 163 */ "term ::= CTIME_KW",
137584 /* 164 */ "expr ::= LP nexprlist COMMA expr RP",
137585 /* 165 */ "expr ::= expr AND expr",
137586 /* 166 */ "expr ::= expr OR expr",
137587 /* 167 */ "expr ::= expr LT|GT|GE|LE expr",
137588 /* 168 */ "expr ::= expr EQ|NE expr",
137589 /* 169 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
137590 /* 170 */ "expr ::= expr PLUS|MINUS expr",
137591 /* 171 */ "expr ::= expr STAR|SLASH|REM expr",
137592 /* 172 */ "expr ::= expr CONCAT expr",
137593 /* 173 */ "likeop ::= NOT LIKE_KW|MATCH",
137594 /* 174 */ "expr ::= expr likeop expr",
137595 /* 175 */ "expr ::= expr likeop expr ESCAPE expr",
137596 /* 176 */ "expr ::= expr ISNULL|NOTNULL",
137597 /* 177 */ "expr ::= expr NOT NULL",
137598 /* 178 */ "expr ::= expr IS expr",
137599 /* 179 */ "expr ::= expr IS NOT expr",
137600 /* 180 */ "expr ::= NOT expr",
137601 /* 181 */ "expr ::= BITNOT expr",
137602 /* 182 */ "expr ::= MINUS expr",
137603 /* 183 */ "expr ::= PLUS expr",
137604 /* 184 */ "between_op ::= BETWEEN",
137605 /* 185 */ "between_op ::= NOT BETWEEN",
137606 /* 186 */ "expr ::= expr between_op expr AND expr",
137607 /* 187 */ "in_op ::= IN",
137608 /* 188 */ "in_op ::= NOT IN",
137609 /* 189 */ "expr ::= expr in_op LP exprlist RP",
137610 /* 190 */ "expr ::= LP select RP",
137611 /* 191 */ "expr ::= expr in_op LP select RP",
137612 /* 192 */ "expr ::= expr in_op nm dbnm paren_exprlist",
137613 /* 193 */ "expr ::= EXISTS LP select RP",
137614 /* 194 */ "expr ::= CASE case_operand case_exprlist case_else END",
137615 /* 195 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
137616 /* 196 */ "case_exprlist ::= WHEN expr THEN expr",
137617 /* 197 */ "case_else ::= ELSE expr",
137618 /* 198 */ "case_else ::=",
137619 /* 199 */ "case_operand ::= expr",
137620 /* 200 */ "case_operand ::=",
137621 /* 201 */ "exprlist ::=",
137622 /* 202 */ "nexprlist ::= nexprlist COMMA expr",
137623 /* 203 */ "nexprlist ::= expr",
137624 /* 204 */ "paren_exprlist ::=",
137625 /* 205 */ "paren_exprlist ::= LP exprlist RP",
137626 /* 206 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
137627 /* 207 */ "uniqueflag ::= UNIQUE",
137628 /* 208 */ "uniqueflag ::=",
137629 /* 209 */ "eidlist_opt ::=",
137630 /* 210 */ "eidlist_opt ::= LP eidlist RP",
137631 /* 211 */ "eidlist ::= eidlist COMMA nm collate sortorder",
137632 /* 212 */ "eidlist ::= nm collate sortorder",
137633 /* 213 */ "collate ::=",
137634 /* 214 */ "collate ::= COLLATE ID|STRING",
137635 /* 215 */ "cmd ::= DROP INDEX ifexists fullname",
137636 /* 216 */ "cmd ::= VACUUM",
137637 /* 217 */ "cmd ::= VACUUM nm",
137638 /* 218 */ "cmd ::= PRAGMA nm dbnm",
137639 /* 219 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
137640 /* 220 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
137641 /* 221 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
137642 /* 222 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
137643 /* 223 */ "plus_num ::= PLUS INTEGER|FLOAT",
137644 /* 224 */ "minus_num ::= MINUS INTEGER|FLOAT",
137645 /* 225 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
137646 /* 226 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
137647 /* 227 */ "trigger_time ::= BEFORE|AFTER",
137648 /* 228 */ "trigger_time ::= INSTEAD OF",
137649 /* 229 */ "trigger_time ::=",
137650 /* 230 */ "trigger_event ::= DELETE|INSERT",
137651 /* 231 */ "trigger_event ::= UPDATE",
137652 /* 232 */ "trigger_event ::= UPDATE OF idlist",
137653 /* 233 */ "when_clause ::=",
137654 /* 234 */ "when_clause ::= WHEN expr",
137655 /* 235 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
137656 /* 236 */ "trigger_cmd_list ::= trigger_cmd SEMI",
137657 /* 237 */ "trnm ::= nm DOT nm",
137658 /* 238 */ "tridxby ::= INDEXED BY nm",
137659 /* 239 */ "tridxby ::= NOT INDEXED",
137660 /* 240 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
137661 /* 241 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
137662 /* 242 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
137663 /* 243 */ "trigger_cmd ::= select",
137664 /* 244 */ "expr ::= RAISE LP IGNORE RP",
137665 /* 245 */ "expr ::= RAISE LP raisetype COMMA nm RP",
137666 /* 246 */ "raisetype ::= ROLLBACK",
137667 /* 247 */ "raisetype ::= ABORT",
137668 /* 248 */ "raisetype ::= FAIL",
137669 /* 249 */ "cmd ::= DROP TRIGGER ifexists fullname",
137670 /* 250 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
137671 /* 251 */ "cmd ::= DETACH database_kw_opt expr",
137672 /* 252 */ "key_opt ::=",
137673 /* 253 */ "key_opt ::= KEY expr",
137674 /* 254 */ "cmd ::= REINDEX",
137675 /* 255 */ "cmd ::= REINDEX nm dbnm",
137676 /* 256 */ "cmd ::= ANALYZE",
137677 /* 257 */ "cmd ::= ANALYZE nm dbnm",
137678 /* 258 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
137679 /* 259 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
137680 /* 260 */ "add_column_fullname ::= fullname",
137681 /* 261 */ "cmd ::= create_vtab",
137682 /* 262 */ "cmd ::= create_vtab LP vtabarglist RP",
137683 /* 263 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
137684 /* 264 */ "vtabarg ::=",
137685 /* 265 */ "vtabargtoken ::= ANY",
137686 /* 266 */ "vtabargtoken ::= lp anylist RP",
137687 /* 267 */ "lp ::= LP",
137688 /* 268 */ "with ::=",
137689 /* 269 */ "with ::= WITH wqlist",
137690 /* 270 */ "with ::= WITH RECURSIVE wqlist",
137691 /* 271 */ "wqlist ::= nm eidlist_opt AS LP select RP",
137692 /* 272 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
137693 /* 273 */ "input ::= cmdlist",
137694 /* 274 */ "cmdlist ::= cmdlist ecmd",
137695 /* 275 */ "cmdlist ::= ecmd",
137696 /* 276 */ "ecmd ::= SEMI",
137697 /* 277 */ "ecmd ::= explain cmdx SEMI",
137698 /* 278 */ "explain ::=",
137699 /* 279 */ "trans_opt ::=",
137700 /* 280 */ "trans_opt ::= TRANSACTION",
137701 /* 281 */ "trans_opt ::= TRANSACTION nm",
137702 /* 282 */ "savepoint_opt ::= SAVEPOINT",
137703 /* 283 */ "savepoint_opt ::=",
137704 /* 284 */ "cmd ::= create_table create_table_args",
137705 /* 285 */ "columnlist ::= columnlist COMMA columnname carglist",
137706 /* 286 */ "columnlist ::= columnname carglist",
137707 /* 287 */ "nm ::= ID|INDEXED",
137708 /* 288 */ "nm ::= STRING",
137709 /* 289 */ "nm ::= JOIN_KW",
137710 /* 290 */ "typetoken ::= typename",
137711 /* 291 */ "typename ::= ID|STRING",
137712 /* 292 */ "signed ::= plus_num",
137713 /* 293 */ "signed ::= minus_num",
137714 /* 294 */ "carglist ::= carglist ccons",
137715 /* 295 */ "carglist ::=",
137716 /* 296 */ "ccons ::= NULL onconf",
137717 /* 297 */ "conslist_opt ::= COMMA conslist",
137718 /* 298 */ "conslist ::= conslist tconscomma tcons",
137719 /* 299 */ "conslist ::= tcons",
137720 /* 300 */ "tconscomma ::=",
137721 /* 301 */ "defer_subclause_opt ::= defer_subclause",
137722 /* 302 */ "resolvetype ::= raisetype",
137723 /* 303 */ "selectnowith ::= oneselect",
137724 /* 304 */ "oneselect ::= values",
137725 /* 305 */ "sclp ::= selcollist COMMA",
137726 /* 306 */ "as ::= ID|STRING",
137727 /* 307 */ "expr ::= term",
137728 /* 308 */ "likeop ::= LIKE_KW|MATCH",
137729 /* 309 */ "exprlist ::= nexprlist",
137730 /* 310 */ "nmnum ::= plus_num",
137731 /* 311 */ "nmnum ::= nm",
137732 /* 312 */ "nmnum ::= ON",
137733 /* 313 */ "nmnum ::= DELETE",
137734 /* 314 */ "nmnum ::= DEFAULT",
137735 /* 315 */ "plus_num ::= INTEGER|FLOAT",
137736 /* 316 */ "foreach_clause ::=",
137737 /* 317 */ "foreach_clause ::= FOR EACH ROW",
137738 /* 318 */ "trnm ::= nm",
137739 /* 319 */ "tridxby ::=",
137740 /* 320 */ "database_kw_opt ::= DATABASE",
137741 /* 321 */ "database_kw_opt ::=",
137742 /* 322 */ "kwcolumn_opt ::=",
137743 /* 323 */ "kwcolumn_opt ::= COLUMNKW",
137744 /* 324 */ "vtabarglist ::= vtabarg",
137745 /* 325 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
137746 /* 326 */ "vtabarg ::= vtabarg vtabargtoken",
137747 /* 327 */ "anylist ::=",
137748 /* 328 */ "anylist ::= anylist LP anylist RP",
137749 /* 329 */ "anylist ::= anylist ANY",
 
137750 };
137751 #endif /* NDEBUG */
137752
137753
137754 #if YYSTACKDEPTH<=0
@@ -137529,11 +137813,13 @@
137813 pParser->yyerrcnt = -1;
137814 #endif
137815 pParser->yytos = pParser->yystack;
137816 pParser->yystack[0].stateno = 0;
137817 pParser->yystack[0].major = 0;
137818 #if YYSTACKDEPTH>0
137819 pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
137820 #endif
137821 }
137822
137823 #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
137824 /*
137825 ** This function allocates a new parser.
@@ -137911,11 +138197,10 @@
138197 { 149, -3 },
138198 { 150, 0 },
138199 { 150, -1 },
138200 { 150, -1 },
138201 { 150, -1 },
 
138202 { 149, -2 },
138203 { 149, -2 },
138204 { 149, -2 },
138205 { 149, -3 },
138206 { 149, -5 },
@@ -138317,256 +138602,253 @@
138602 case 5: /* transtype ::= DEFERRED */
138603 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
138604 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
138605 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}
138606 break;
138607 case 8: /* cmd ::= COMMIT|END trans_opt */
138608 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
138609 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
138610 break;
138611 case 10: /* cmd ::= SAVEPOINT nm */
 
 
 
138612 {
138613 sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);
138614 }
138615 break;
138616 case 11: /* cmd ::= RELEASE savepoint_opt nm */
138617 {
138618 sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);
138619 }
138620 break;
138621 case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
138622 {
138623 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
138624 }
138625 break;
138626 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
138627 {
138628 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);
138629 }
138630 break;
138631 case 14: /* createkw ::= CREATE */
138632 {disableLookaside(pParse);}
138633 break;
138634 case 15: /* ifnotexists ::= */
138635 case 18: /* temp ::= */ yytestcase(yyruleno==18);
138636 case 21: /* table_options ::= */ yytestcase(yyruleno==21);
138637 case 41: /* autoinc ::= */ yytestcase(yyruleno==41);
138638 case 56: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==56);
138639 case 66: /* defer_subclause_opt ::= */ yytestcase(yyruleno==66);
138640 case 75: /* ifexists ::= */ yytestcase(yyruleno==75);
138641 case 89: /* distinct ::= */ yytestcase(yyruleno==89);
138642 case 213: /* collate ::= */ yytestcase(yyruleno==213);
138643 {yymsp[1].minor.yy194 = 0;}
138644 break;
138645 case 16: /* ifnotexists ::= IF NOT EXISTS */
138646 {yymsp[-2].minor.yy194 = 1;}
138647 break;
138648 case 17: /* temp ::= TEMP */
138649 case 42: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==42);
138650 {yymsp[0].minor.yy194 = 1;}
138651 break;
138652 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
138653 {
138654 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);
138655 }
138656 break;
138657 case 20: /* create_table_args ::= AS select */
138658 {
138659 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);
138660 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138661 }
138662 break;
138663 case 22: /* table_options ::= WITHOUT nm */
138664 {
138665 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
138666 yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;
138667 }else{
138668 yymsp[-1].minor.yy194 = 0;
138669 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
138670 }
138671 }
138672 break;
138673 case 23: /* columnname ::= nm typetoken */
138674 {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
138675 break;
138676 case 24: /* typetoken ::= */
138677 case 59: /* conslist_opt ::= */ yytestcase(yyruleno==59);
138678 case 95: /* as ::= */ yytestcase(yyruleno==95);
138679 {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
138680 break;
138681 case 25: /* typetoken ::= typename LP signed RP */
138682 {
138683 yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
138684 }
138685 break;
138686 case 26: /* typetoken ::= typename LP signed COMMA signed RP */
138687 {
138688 yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
138689 }
138690 break;
138691 case 27: /* typename ::= typename ID|STRING */
138692 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
138693 break;
138694 case 28: /* ccons ::= CONSTRAINT nm */
138695 case 61: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==61);
138696 {pParse->constraintName = yymsp[0].minor.yy0;}
138697 break;
138698 case 29: /* ccons ::= DEFAULT term */
138699 case 31: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==31);
138700 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}
138701 break;
138702 case 30: /* ccons ::= DEFAULT LP expr RP */
138703 {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}
138704 break;
138705 case 32: /* ccons ::= DEFAULT MINUS term */
138706 {
138707 ExprSpan v;
138708 v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0);
138709 v.zStart = yymsp[-1].minor.yy0.z;
138710 v.zEnd = yymsp[0].minor.yy190.zEnd;
138711 sqlite3AddDefaultValue(pParse,&v);
138712 }
138713 break;
138714 case 33: /* ccons ::= DEFAULT ID|INDEXED */
138715 {
138716 ExprSpan v;
138717 spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);
138718 sqlite3AddDefaultValue(pParse,&v);
138719 }
138720 break;
138721 case 34: /* ccons ::= NOT NULL onconf */
138722 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}
138723 break;
138724 case 35: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
138725 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}
138726 break;
138727 case 36: /* ccons ::= UNIQUE onconf */
138728 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,
138729 SQLITE_IDXTYPE_UNIQUE);}
138730 break;
138731 case 37: /* ccons ::= CHECK LP expr RP */
138732 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}
138733 break;
138734 case 38: /* ccons ::= REFERENCES nm eidlist_opt refargs */
138735 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}
138736 break;
138737 case 39: /* ccons ::= defer_subclause */
138738 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}
138739 break;
138740 case 40: /* ccons ::= COLLATE ID|STRING */
138741 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
138742 break;
138743 case 43: /* refargs ::= */
138744 { yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}
138745 break;
138746 case 44: /* refargs ::= refargs refarg */
138747 { yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }
138748 break;
138749 case 45: /* refarg ::= MATCH nm */
138750 { yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; }
138751 break;
138752 case 46: /* refarg ::= ON INSERT refact */
138753 { yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; }
138754 break;
138755 case 47: /* refarg ::= ON DELETE refact */
138756 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; }
138757 break;
138758 case 48: /* refarg ::= ON UPDATE refact */
138759 { yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; }
138760 break;
138761 case 49: /* refact ::= SET NULL */
138762 { yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */}
138763 break;
138764 case 50: /* refact ::= SET DEFAULT */
138765 { yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */}
138766 break;
138767 case 51: /* refact ::= CASCADE */
138768 { yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */}
138769 break;
138770 case 52: /* refact ::= RESTRICT */
138771 { yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}
138772 break;
138773 case 53: /* refact ::= NO ACTION */
138774 { yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */}
138775 break;
138776 case 54: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
138777 {yymsp[-2].minor.yy194 = 0;}
138778 break;
138779 case 55: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
138780 case 70: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==70);
138781 case 143: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==143);
138782 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
138783 break;
138784 case 57: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
138785 case 74: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==74);
138786 case 185: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==185);
138787 case 188: /* in_op ::= NOT IN */ yytestcase(yyruleno==188);
138788 case 214: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==214);
138789 {yymsp[-1].minor.yy194 = 1;}
138790 break;
138791 case 58: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
138792 {yymsp[-1].minor.yy194 = 0;}
138793 break;
138794 case 60: /* tconscomma ::= COMMA */
138795 {pParse->constraintName.n = 0;}
138796 break;
138797 case 62: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
138798 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}
138799 break;
138800 case 63: /* tcons ::= UNIQUE LP sortlist RP onconf */
138801 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,
138802 SQLITE_IDXTYPE_UNIQUE);}
138803 break;
138804 case 64: /* tcons ::= CHECK LP expr RP onconf */
138805 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}
138806 break;
138807 case 65: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
138808 {
138809 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);
138810 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);
138811 }
138812 break;
138813 case 67: /* onconf ::= */
138814 case 69: /* orconf ::= */ yytestcase(yyruleno==69);
138815 {yymsp[1].minor.yy194 = OE_Default;}
138816 break;
138817 case 68: /* onconf ::= ON CONFLICT resolvetype */
138818 {yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}
138819 break;
138820 case 71: /* resolvetype ::= IGNORE */
138821 {yymsp[0].minor.yy194 = OE_Ignore;}
138822 break;
138823 case 72: /* resolvetype ::= REPLACE */
138824 case 144: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==144);
138825 {yymsp[0].minor.yy194 = OE_Replace;}
138826 break;
138827 case 73: /* cmd ::= DROP TABLE ifexists fullname */
138828 {
138829 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);
138830 }
138831 break;
138832 case 76: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
138833 {
138834 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);
138835 }
138836 break;
138837 case 77: /* cmd ::= DROP VIEW ifexists fullname */
138838 {
138839 sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);
138840 }
138841 break;
138842 case 78: /* cmd ::= select */
138843 {
138844 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
138845 sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);
138846 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);
138847 }
138848 break;
138849 case 79: /* select ::= with selectnowith */
138850 {
138851 Select *p = yymsp[0].minor.yy243;
138852 if( p ){
138853 p->pWith = yymsp[-1].minor.yy285;
138854 parserDoubleLinkSelect(pParse, p);
@@ -138574,11 +138856,11 @@
138856 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);
138857 }
138858 yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/
138859 }
138860 break;
138861 case 80: /* selectnowith ::= selectnowith multiselect_op oneselect */
138862 {
138863 Select *pRhs = yymsp[0].minor.yy243;
138864 Select *pLhs = yymsp[-2].minor.yy243;
138865 if( pRhs && pRhs->pPrior ){
138866 SrcList *pFrom;
@@ -138598,18 +138880,18 @@
138880 sqlite3SelectDelete(pParse->db, pLhs);
138881 }
138882 yymsp[-2].minor.yy243 = pRhs;
138883 }
138884 break;
138885 case 81: /* multiselect_op ::= UNION */
138886 case 83: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==83);
138887 {yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}
138888 break;
138889 case 82: /* multiselect_op ::= UNION ALL */
138890 {yymsp[-1].minor.yy194 = TK_ALL;}
138891 break;
138892 case 84: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
138893 {
138894 #if SELECTTRACE_ENABLED
138895 Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
138896 #endif
138897 yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);
@@ -138637,16 +138919,16 @@
138919 }
138920 }
138921 #endif /* SELECTRACE_ENABLED */
138922 }
138923 break;
138924 case 85: /* values ::= VALUES LP nexprlist RP */
138925 {
138926 yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);
138927 }
138928 break;
138929 case 86: /* values ::= values COMMA LP exprlist RP */
138930 {
138931 Select *pRight, *pLeft = yymsp[-4].minor.yy243;
138932 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
138933 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
138934 if( pRight ){
@@ -138656,86 +138938,86 @@
138938 }else{
138939 yymsp[-4].minor.yy243 = pLeft;
138940 }
138941 }
138942 break;
138943 case 87: /* distinct ::= DISTINCT */
138944 {yymsp[0].minor.yy194 = SF_Distinct;}
138945 break;
138946 case 88: /* distinct ::= ALL */
138947 {yymsp[0].minor.yy194 = SF_All;}
138948 break;
138949 case 90: /* sclp ::= */
138950 case 118: /* orderby_opt ::= */ yytestcase(yyruleno==118);
138951 case 125: /* groupby_opt ::= */ yytestcase(yyruleno==125);
138952 case 201: /* exprlist ::= */ yytestcase(yyruleno==201);
138953 case 204: /* paren_exprlist ::= */ yytestcase(yyruleno==204);
138954 case 209: /* eidlist_opt ::= */ yytestcase(yyruleno==209);
138955 {yymsp[1].minor.yy148 = 0;}
138956 break;
138957 case 91: /* selcollist ::= sclp expr as */
138958 {
138959 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
138960 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
138961 sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
138962 }
138963 break;
138964 case 92: /* selcollist ::= sclp STAR */
138965 {
138966 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
138967 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);
138968 }
138969 break;
138970 case 93: /* selcollist ::= sclp nm DOT STAR */
138971 {
138972 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
138973 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
138974 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
138975 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
138976 }
138977 break;
138978 case 94: /* as ::= AS nm */
138979 case 105: /* dbnm ::= DOT nm */ yytestcase(yyruleno==105);
138980 case 223: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==223);
138981 case 224: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
138982 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
138983 break;
138984 case 96: /* from ::= */
138985 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
138986 break;
138987 case 97: /* from ::= FROM seltablist */
138988 {
138989 yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;
138990 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);
138991 }
138992 break;
138993 case 98: /* stl_prefix ::= seltablist joinop */
138994 {
138995 if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;
138996 }
138997 break;
138998 case 99: /* stl_prefix ::= */
138999 {yymsp[1].minor.yy185 = 0;}
139000 break;
139001 case 100: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
139002 {
139003 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
139004 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);
139005 }
139006 break;
139007 case 101: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
139008 {
139009 yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
139010 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);
139011 }
139012 break;
139013 case 102: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
139014 {
139015 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
139016 }
139017 break;
139018 case 103: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
139019 {
139020 if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){
139021 yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;
139022 }else if( yymsp[-4].minor.yy185->nSrc==1 ){
139023 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
@@ -138755,191 +139037,191 @@
139037 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);
139038 yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);
139039 }
139040 }
139041 break;
139042 case 104: /* dbnm ::= */
139043 case 113: /* indexed_opt ::= */ yytestcase(yyruleno==113);
139044 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
139045 break;
139046 case 106: /* fullname ::= nm dbnm */
139047 {yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
139048 break;
139049 case 107: /* joinop ::= COMMA|JOIN */
139050 { yymsp[0].minor.yy194 = JT_INNER; }
139051 break;
139052 case 108: /* joinop ::= JOIN_KW JOIN */
139053 {yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
139054 break;
139055 case 109: /* joinop ::= JOIN_KW nm JOIN */
139056 {yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
139057 break;
139058 case 110: /* joinop ::= JOIN_KW nm nm JOIN */
139059 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
139060 break;
139061 case 111: /* on_opt ::= ON expr */
139062 case 128: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==128);
139063 case 135: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==135);
139064 case 197: /* case_else ::= ELSE expr */ yytestcase(yyruleno==197);
139065 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
139066 break;
139067 case 112: /* on_opt ::= */
139068 case 127: /* having_opt ::= */ yytestcase(yyruleno==127);
139069 case 134: /* where_opt ::= */ yytestcase(yyruleno==134);
139070 case 198: /* case_else ::= */ yytestcase(yyruleno==198);
139071 case 200: /* case_operand ::= */ yytestcase(yyruleno==200);
139072 {yymsp[1].minor.yy72 = 0;}
139073 break;
139074 case 114: /* indexed_opt ::= INDEXED BY nm */
139075 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
139076 break;
139077 case 115: /* indexed_opt ::= NOT INDEXED */
139078 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
139079 break;
139080 case 116: /* using_opt ::= USING LP idlist RP */
139081 {yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
139082 break;
139083 case 117: /* using_opt ::= */
139084 case 145: /* idlist_opt ::= */ yytestcase(yyruleno==145);
139085 {yymsp[1].minor.yy254 = 0;}
139086 break;
139087 case 119: /* orderby_opt ::= ORDER BY sortlist */
139088 case 126: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==126);
139089 {yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}
139090 break;
139091 case 120: /* sortlist ::= sortlist COMMA expr sortorder */
139092 {
139093 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);
139094 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);
139095 }
139096 break;
139097 case 121: /* sortlist ::= expr sortorder */
139098 {
139099 yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/
139100 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);
139101 }
139102 break;
139103 case 122: /* sortorder ::= ASC */
139104 {yymsp[0].minor.yy194 = SQLITE_SO_ASC;}
139105 break;
139106 case 123: /* sortorder ::= DESC */
139107 {yymsp[0].minor.yy194 = SQLITE_SO_DESC;}
139108 break;
139109 case 124: /* sortorder ::= */
139110 {yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}
139111 break;
139112 case 129: /* limit_opt ::= */
139113 {yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}
139114 break;
139115 case 130: /* limit_opt ::= LIMIT expr */
139116 {yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}
139117 break;
139118 case 131: /* limit_opt ::= LIMIT expr OFFSET expr */
139119 {yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}
139120 break;
139121 case 132: /* limit_opt ::= LIMIT expr COMMA expr */
139122 {yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}
139123 break;
139124 case 133: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
139125 {
139126 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
139127 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);
139128 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);
139129 }
139130 break;
139131 case 136: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
139132 {
139133 sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);
139134 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);
139135 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list");
139136 sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);
139137 }
139138 break;
139139 case 137: /* setlist ::= setlist COMMA nm EQ expr */
139140 {
139141 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
139142 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);
139143 }
139144 break;
139145 case 138: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
139146 {
139147 yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
139148 }
139149 break;
139150 case 139: /* setlist ::= nm EQ expr */
139151 {
139152 yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);
139153 sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);
139154 }
139155 yymsp[-2].minor.yy148 = yylhsminor.yy148;
139156 break;
139157 case 140: /* setlist ::= LP idlist RP EQ expr */
139158 {
139159 yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);
139160 }
139161 break;
139162 case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
139163 {
139164 sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);
139165 sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);
139166 }
139167 break;
139168 case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
139169 {
139170 sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);
139171 sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);
139172 }
139173 break;
139174 case 146: /* idlist_opt ::= LP idlist RP */
139175 {yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
139176 break;
139177 case 147: /* idlist ::= idlist COMMA nm */
139178 {yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
139179 break;
139180 case 148: /* idlist ::= nm */
139181 {yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
139182 break;
139183 case 149: /* expr ::= LP expr RP */
139184 {spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}
139185 break;
139186 case 150: /* term ::= NULL */
139187 case 155: /* term ::= FLOAT|BLOB */ yytestcase(yyruleno==155);
139188 case 156: /* term ::= STRING */ yytestcase(yyruleno==156);
139189 {spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/}
139190 break;
139191 case 151: /* expr ::= ID|INDEXED */
139192 case 152: /* expr ::= JOIN_KW */ yytestcase(yyruleno==152);
139193 {spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
139194 break;
139195 case 153: /* expr ::= nm DOT nm */
139196 {
139197 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
139198 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
139199 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139200 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
139201 }
139202 break;
139203 case 154: /* expr ::= nm DOT nm DOT nm */
139204 {
139205 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
139206 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
139207 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
139208 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
139209 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139210 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
139211 }
139212 break;
139213 case 157: /* term ::= INTEGER */
139214 {
139215 yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
139216 yylhsminor.yy190.zStart = yymsp[0].minor.yy0.z;
139217 yylhsminor.yy190.zEnd = yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n;
139218 if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf|EP_Resolved;
139219 }
139220 yymsp[0].minor.yy190 = yylhsminor.yy190;
139221 break;
139222 case 158: /* expr ::= VARIABLE */
139223 {
139224 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
139225 u32 n = yymsp[0].minor.yy0.n;
139226 spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);
139227 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n);
@@ -138958,24 +139240,24 @@
139240 if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);
139241 }
139242 }
139243 }
139244 break;
139245 case 159: /* expr ::= expr COLLATE ID|STRING */
139246 {
139247 yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);
139248 yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139249 }
139250 break;
139251 case 160: /* expr ::= CAST LP expr AS typetoken RP */
139252 {
139253 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139254 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
139255 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, 0);
139256 }
139257 break;
139258 case 161: /* expr ::= ID|INDEXED LP distinct exprlist RP */
139259 {
139260 if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
139261 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
139262 }
139263 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);
@@ -138984,25 +139266,25 @@
139266 yylhsminor.yy190.pExpr->flags |= EP_Distinct;
139267 }
139268 }
139269 yymsp[-4].minor.yy190 = yylhsminor.yy190;
139270 break;
139271 case 162: /* expr ::= ID|INDEXED LP STAR RP */
139272 {
139273 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
139274 spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
139275 }
139276 yymsp[-3].minor.yy190 = yylhsminor.yy190;
139277 break;
139278 case 163: /* term ::= CTIME_KW */
139279 {
139280 yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
139281 spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
139282 }
139283 yymsp[0].minor.yy190 = yylhsminor.yy190;
139284 break;
139285 case 164: /* expr ::= LP nexprlist COMMA expr RP */
139286 {
139287 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);
139288 yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
139289 if( yylhsminor.yy190.pExpr ){
139290 yylhsminor.yy190.pExpr->x.pList = pList;
@@ -139011,24 +139293,24 @@
139293 sqlite3ExprListDelete(pParse->db, pList);
139294 }
139295 }
139296 yymsp[-4].minor.yy190 = yylhsminor.yy190;
139297 break;
139298 case 165: /* expr ::= expr AND expr */
139299 case 166: /* expr ::= expr OR expr */ yytestcase(yyruleno==166);
139300 case 167: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==167);
139301 case 168: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==168);
139302 case 169: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==169);
139303 case 170: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==170);
139304 case 171: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==171);
139305 case 172: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==172);
139306 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
139307 break;
139308 case 173: /* likeop ::= NOT LIKE_KW|MATCH */
139309 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
139310 break;
139311 case 174: /* expr ::= expr likeop expr */
139312 {
139313 ExprList *pList;
139314 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
139315 yymsp[-1].minor.yy0.n &= 0x7fffffff;
139316 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -139037,11 +139319,11 @@
139319 exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
139320 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139321 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
139322 }
139323 break;
139324 case 175: /* expr ::= expr likeop expr ESCAPE expr */
139325 {
139326 ExprList *pList;
139327 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
139328 yymsp[-3].minor.yy0.n &= 0x7fffffff;
139329 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -139051,43 +139333,43 @@
139333 exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
139334 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139335 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
139336 }
139337 break;
139338 case 176: /* expr ::= expr ISNULL|NOTNULL */
139339 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
139340 break;
139341 case 177: /* expr ::= expr NOT NULL */
139342 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
139343 break;
139344 case 178: /* expr ::= expr IS expr */
139345 {
139346 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
139347 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
139348 }
139349 break;
139350 case 179: /* expr ::= expr IS NOT expr */
139351 {
139352 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
139353 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
139354 }
139355 break;
139356 case 180: /* expr ::= NOT expr */
139357 case 181: /* expr ::= BITNOT expr */ yytestcase(yyruleno==181);
139358 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139359 break;
139360 case 182: /* expr ::= MINUS expr */
139361 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139362 break;
139363 case 183: /* expr ::= PLUS expr */
139364 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
139365 break;
139366 case 184: /* between_op ::= BETWEEN */
139367 case 187: /* in_op ::= IN */ yytestcase(yyruleno==187);
139368 {yymsp[0].minor.yy194 = 0;}
139369 break;
139370 case 186: /* expr ::= expr between_op expr AND expr */
139371 {
139372 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139373 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
139374 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
139375 if( yymsp[-4].minor.yy190.pExpr ){
@@ -139097,11 +139379,11 @@
139379 }
139380 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139381 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
139382 }
139383 break;
139384 case 189: /* expr ::= expr in_op LP exprlist RP */
139385 {
139386 if( yymsp[-1].minor.yy148==0 ){
139387 /* Expressions of the form
139388 **
139389 ** expr1 IN ()
@@ -139150,26 +139432,26 @@
139432 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139433 }
139434 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139435 }
139436 break;
139437 case 190: /* expr ::= LP select RP */
139438 {
139439 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139440 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
139441 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139442 }
139443 break;
139444 case 191: /* expr ::= expr in_op LP select RP */
139445 {
139446 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
139447 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
139448 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139449 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
139450 }
139451 break;
139452 case 192: /* expr ::= expr in_op nm dbnm paren_exprlist */
139453 {
139454 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
139455 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
139456 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
139457 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -139176,19 +139458,19 @@
139458 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
139459 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
139460 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
139461 }
139462 break;
139463 case 193: /* expr ::= EXISTS LP select RP */
139464 {
139465 Expr *p;
139466 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
139467 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
139468 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
139469 }
139470 break;
139471 case 194: /* expr ::= CASE case_operand case_exprlist case_else END */
139472 {
139473 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
139474 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
139475 if( yymsp[-4].minor.yy190.pExpr ){
139476 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -139197,332 +139479,332 @@
139479 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
139480 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
139481 }
139482 }
139483 break;
139484 case 195: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
139485 {
139486 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
139487 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
139488 }
139489 break;
139490 case 196: /* case_exprlist ::= WHEN expr THEN expr */
139491 {
139492 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
139493 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
139494 }
139495 break;
139496 case 199: /* case_operand ::= expr */
139497 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
139498 break;
139499 case 202: /* nexprlist ::= nexprlist COMMA expr */
139500 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
139501 break;
139502 case 203: /* nexprlist ::= expr */
139503 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
139504 break;
139505 case 205: /* paren_exprlist ::= LP exprlist RP */
139506 case 210: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==210);
139507 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
139508 break;
139509 case 206: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
139510 {
139511 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
139512 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
139513 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
139514 }
139515 break;
139516 case 207: /* uniqueflag ::= UNIQUE */
139517 case 247: /* raisetype ::= ABORT */ yytestcase(yyruleno==247);
139518 {yymsp[0].minor.yy194 = OE_Abort;}
139519 break;
139520 case 208: /* uniqueflag ::= */
139521 {yymsp[1].minor.yy194 = OE_None;}
139522 break;
139523 case 211: /* eidlist ::= eidlist COMMA nm collate sortorder */
139524 {
139525 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
139526 }
139527 break;
139528 case 212: /* eidlist ::= nm collate sortorder */
139529 {
139530 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
139531 }
139532 break;
139533 case 215: /* cmd ::= DROP INDEX ifexists fullname */
139534 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
139535 break;
139536 case 216: /* cmd ::= VACUUM */
139537 {sqlite3Vacuum(pParse,0);}
139538 break;
139539 case 217: /* cmd ::= VACUUM nm */
139540 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
139541 break;
139542 case 218: /* cmd ::= PRAGMA nm dbnm */
139543 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
139544 break;
139545 case 219: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
139546 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
139547 break;
139548 case 220: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
139549 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
139550 break;
139551 case 221: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
139552 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
139553 break;
139554 case 222: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
139555 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
139556 break;
139557 case 225: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
139558 {
139559 Token all;
139560 all.z = yymsp[-3].minor.yy0.z;
139561 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
139562 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
139563 }
139564 break;
139565 case 226: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
139566 {
139567 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
139568 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
139569 }
139570 break;
139571 case 227: /* trigger_time ::= BEFORE|AFTER */
139572 { yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }
139573 break;
139574 case 228: /* trigger_time ::= INSTEAD OF */
139575 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
139576 break;
139577 case 229: /* trigger_time ::= */
139578 { yymsp[1].minor.yy194 = TK_BEFORE; }
139579 break;
139580 case 230: /* trigger_event ::= DELETE|INSERT */
139581 case 231: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==231);
139582 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
139583 break;
139584 case 232: /* trigger_event ::= UPDATE OF idlist */
139585 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
139586 break;
139587 case 233: /* when_clause ::= */
139588 case 252: /* key_opt ::= */ yytestcase(yyruleno==252);
139589 { yymsp[1].minor.yy72 = 0; }
139590 break;
139591 case 234: /* when_clause ::= WHEN expr */
139592 case 253: /* key_opt ::= KEY expr */ yytestcase(yyruleno==253);
139593 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
139594 break;
139595 case 235: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
139596 {
139597 assert( yymsp[-2].minor.yy145!=0 );
139598 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
139599 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
139600 }
139601 break;
139602 case 236: /* trigger_cmd_list ::= trigger_cmd SEMI */
139603 {
139604 assert( yymsp[-1].minor.yy145!=0 );
139605 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
139606 }
139607 break;
139608 case 237: /* trnm ::= nm DOT nm */
139609 {
139610 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
139611 sqlite3ErrorMsg(pParse,
139612 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
139613 "statements within triggers");
139614 }
139615 break;
139616 case 238: /* tridxby ::= INDEXED BY nm */
139617 {
139618 sqlite3ErrorMsg(pParse,
139619 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
139620 "within triggers");
139621 }
139622 break;
139623 case 239: /* tridxby ::= NOT INDEXED */
139624 {
139625 sqlite3ErrorMsg(pParse,
139626 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
139627 "within triggers");
139628 }
139629 break;
139630 case 240: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
139631 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
139632 break;
139633 case 241: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
139634 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
139635 break;
139636 case 242: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
139637 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
139638 break;
139639 case 243: /* trigger_cmd ::= select */
139640 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
139641 break;
139642 case 244: /* expr ::= RAISE LP IGNORE RP */
139643 {
139644 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139645 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
139646 if( yymsp[-3].minor.yy190.pExpr ){
139647 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
139648 }
139649 }
139650 break;
139651 case 245: /* expr ::= RAISE LP raisetype COMMA nm RP */
139652 {
139653 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
139654 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
139655 if( yymsp[-5].minor.yy190.pExpr ) {
139656 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
139657 }
139658 }
139659 break;
139660 case 246: /* raisetype ::= ROLLBACK */
139661 {yymsp[0].minor.yy194 = OE_Rollback;}
139662 break;
139663 case 248: /* raisetype ::= FAIL */
139664 {yymsp[0].minor.yy194 = OE_Fail;}
139665 break;
139666 case 249: /* cmd ::= DROP TRIGGER ifexists fullname */
139667 {
139668 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
139669 }
139670 break;
139671 case 250: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
139672 {
139673 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
139674 }
139675 break;
139676 case 251: /* cmd ::= DETACH database_kw_opt expr */
139677 {
139678 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
139679 }
139680 break;
139681 case 254: /* cmd ::= REINDEX */
139682 {sqlite3Reindex(pParse, 0, 0);}
139683 break;
139684 case 255: /* cmd ::= REINDEX nm dbnm */
139685 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139686 break;
139687 case 256: /* cmd ::= ANALYZE */
139688 {sqlite3Analyze(pParse, 0, 0);}
139689 break;
139690 case 257: /* cmd ::= ANALYZE nm dbnm */
139691 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
139692 break;
139693 case 258: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
139694 {
139695 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
139696 }
139697 break;
139698 case 259: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
139699 {
139700 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
139701 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
139702 }
139703 break;
139704 case 260: /* add_column_fullname ::= fullname */
139705 {
139706 disableLookaside(pParse);
139707 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
139708 }
139709 break;
139710 case 261: /* cmd ::= create_vtab */
139711 {sqlite3VtabFinishParse(pParse,0);}
139712 break;
139713 case 262: /* cmd ::= create_vtab LP vtabarglist RP */
139714 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
139715 break;
139716 case 263: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
139717 {
139718 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
139719 }
139720 break;
139721 case 264: /* vtabarg ::= */
139722 {sqlite3VtabArgInit(pParse);}
139723 break;
139724 case 265: /* vtabargtoken ::= ANY */
139725 case 266: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==266);
139726 case 267: /* lp ::= LP */ yytestcase(yyruleno==267);
139727 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
139728 break;
139729 case 268: /* with ::= */
139730 {yymsp[1].minor.yy285 = 0;}
139731 break;
139732 case 269: /* with ::= WITH wqlist */
139733 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
139734 break;
139735 case 270: /* with ::= WITH RECURSIVE wqlist */
139736 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
139737 break;
139738 case 271: /* wqlist ::= nm eidlist_opt AS LP select RP */
139739 {
139740 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
139741 }
139742 break;
139743 case 272: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
139744 {
139745 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
139746 }
139747 break;
139748 default:
139749 /* (273) input ::= cmdlist */ yytestcase(yyruleno==273);
139750 /* (274) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==274);
139751 /* (275) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=275);
139752 /* (276) ecmd ::= SEMI */ yytestcase(yyruleno==276);
139753 /* (277) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==277);
139754 /* (278) explain ::= */ yytestcase(yyruleno==278);
139755 /* (279) trans_opt ::= */ yytestcase(yyruleno==279);
139756 /* (280) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==280);
139757 /* (281) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==281);
139758 /* (282) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==282);
139759 /* (283) savepoint_opt ::= */ yytestcase(yyruleno==283);
139760 /* (284) cmd ::= create_table create_table_args */ yytestcase(yyruleno==284);
139761 /* (285) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==285);
139762 /* (286) columnlist ::= columnname carglist */ yytestcase(yyruleno==286);
139763 /* (287) nm ::= ID|INDEXED */ yytestcase(yyruleno==287);
139764 /* (288) nm ::= STRING */ yytestcase(yyruleno==288);
139765 /* (289) nm ::= JOIN_KW */ yytestcase(yyruleno==289);
139766 /* (290) typetoken ::= typename */ yytestcase(yyruleno==290);
139767 /* (291) typename ::= ID|STRING */ yytestcase(yyruleno==291);
139768 /* (292) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
139769 /* (293) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
139770 /* (294) carglist ::= carglist ccons */ yytestcase(yyruleno==294);
139771 /* (295) carglist ::= */ yytestcase(yyruleno==295);
139772 /* (296) ccons ::= NULL onconf */ yytestcase(yyruleno==296);
139773 /* (297) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==297);
139774 /* (298) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==298);
139775 /* (299) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=299);
139776 /* (300) tconscomma ::= */ yytestcase(yyruleno==300);
139777 /* (301) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=301);
139778 /* (302) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=302);
139779 /* (303) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=303);
139780 /* (304) oneselect ::= values */ yytestcase(yyruleno==304);
139781 /* (305) sclp ::= selcollist COMMA */ yytestcase(yyruleno==305);
139782 /* (306) as ::= ID|STRING */ yytestcase(yyruleno==306);
139783 /* (307) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=307);
139784 /* (308) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==308);
139785 /* (309) exprlist ::= nexprlist */ yytestcase(yyruleno==309);
139786 /* (310) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=310);
139787 /* (311) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=311);
139788 /* (312) nmnum ::= ON */ yytestcase(yyruleno==312);
139789 /* (313) nmnum ::= DELETE */ yytestcase(yyruleno==313);
139790 /* (314) nmnum ::= DEFAULT */ yytestcase(yyruleno==314);
139791 /* (315) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==315);
139792 /* (316) foreach_clause ::= */ yytestcase(yyruleno==316);
139793 /* (317) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==317);
139794 /* (318) trnm ::= nm */ yytestcase(yyruleno==318);
139795 /* (319) tridxby ::= */ yytestcase(yyruleno==319);
139796 /* (320) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==320);
139797 /* (321) database_kw_opt ::= */ yytestcase(yyruleno==321);
139798 /* (322) kwcolumn_opt ::= */ yytestcase(yyruleno==322);
139799 /* (323) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==323);
139800 /* (324) vtabarglist ::= vtabarg */ yytestcase(yyruleno==324);
139801 /* (325) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==325);
139802 /* (326) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==326);
139803 /* (327) anylist ::= */ yytestcase(yyruleno==327);
139804 /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
139805 /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);
139806 break;
139807 /********** End reduce actions ************************************************/
139808 };
139809 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
139810 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -139948,138 +140230,149 @@
140230 ** But by using this automatically generated code, the size of the code
140231 ** is substantially reduced. This is important for embedded applications
140232 ** on platforms with limited memory.
140233 */
140234 /* Hash score: 182 */
140235 /* zKWText[] encodes 834 bytes of keyword text in 554 bytes */
140236 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
140237 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
140238 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
140239 /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
140240 /* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
140241 /* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
140242 /* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
140243 /* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
140244 /* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
140245 /* VACUUMVIEWINITIALLY */
140246 static const char zKWText[553] = {
140247 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
140248 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
140249 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
140250 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
140251 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
140252 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
140253 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
140254 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
140255 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
140256 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
140257 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
140258 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
140259 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
140260 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
140261 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
140262 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
140263 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
140264 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
140265 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
140266 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
140267 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
140268 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
140269 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
140270 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
140271 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
140272 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
140273 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
140274 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
140275 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
140276 'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
140277 'V','I','E','W','I','N','I','T','I','A','L','L','Y',
140278 };
140279 /* aKWHash[i] is the hash value for the i-th keyword */
140280 static const unsigned char aKWHash[127] = {
140281 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
140282 42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
140283 121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
140284 0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
140285 0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
140286 96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
140287 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
140288 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
140289 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
140290 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
140291 };
140292 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
140293 ** then the i-th keyword has no more hash collisions. Otherwise,
140294 ** the next keyword with the same hash is aKWHash[i]-1. */
140295 static const unsigned char aKWNext[124] = {
140296 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
140297 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
140298 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140299 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
140300 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
140301 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
140302 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
140303 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
140304 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
140305 73, 83, 0, 35, 68, 0, 0,
140306 };
140307 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
140308 static const unsigned char aKWLen[124] = {
140309 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
140310 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
140311 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
140312 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
140313 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
140314 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
140315 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
140316 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
140317 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
140318 3, 5, 5, 6, 4, 9, 3,
140319 };
140320 /* aKWOffset[i] is the index into zKWText[] of the start of
140321 ** the text for the i-th keyword. */
140322 static const unsigned short int aKWOffset[124] = {
140323 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
140324 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
140325 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
140326 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
140327 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
140328 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
140329 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
140330 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
140331 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
140332 521, 524, 529, 534, 540, 544, 549,
140333 };
140334 /* aKWCode[i] is the parser symbol code for the i-th keyword */
140335 static const unsigned char aKWCode[124] = {
140336 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
140337 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
140338 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
140339 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
140340 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
140341 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
140342 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
140343 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
140344 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
140345 TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
140346 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
140347 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
140348 TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
140349 TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
140350 TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
140351 TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
140352 TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
140353 TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
140354 TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
140355 TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
140356 TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
140357 TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
140358 TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
140359 TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
140360 TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
140361 };
140362 /* Check to see if z[0..n-1] is a keyword. If it is, write the
140363 ** parser symbol code for that keyword into *pType. Always
140364 ** return the integer n (the length of the token). */
140365 static int keywordCode(const char *z, int n, int *pType){
140366 int i, j;
140367 const char *zKW;
140368 if( n>=2 ){
140369 i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127;
140370 for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){
140371 if( aKWLen[i]!=n ) continue;
140372 j = 0;
140373 zKW = &zKWText[aKWOffset[i]];
140374 #ifdef SQLITE_ASCII
140375 while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }
140376 #endif
140377 #ifdef SQLITE_EBCDIC
140378 while( j<n && toupper(z[j])==zKW[j] ){ j++; }
@@ -140207,11 +140500,11 @@
140500 testcase( i==119 ); /* USING */
140501 testcase( i==120 ); /* VACUUM */
140502 testcase( i==121 ); /* VIEW */
140503 testcase( i==122 ); /* INITIALLY */
140504 testcase( i==123 ); /* ALL */
140505 *pType = aKWCode[i];
140506 break;
140507 }
140508 }
140509 return n;
140510 }
@@ -142486,14 +142779,14 @@
142779 ** argument.
142780 */
142781 SQLITE_PRIVATE const char *sqlite3ErrStr(int rc){
142782 static const char* const aMsg[] = {
142783 /* SQLITE_OK */ "not an error",
142784 /* SQLITE_ERROR */ "SQL logic error",
142785 /* SQLITE_INTERNAL */ 0,
142786 /* SQLITE_PERM */ "access permission denied",
142787 /* SQLITE_ABORT */ "query aborted",
142788 /* SQLITE_BUSY */ "database is locked",
142789 /* SQLITE_LOCKED */ "database table is locked",
142790 /* SQLITE_NOMEM */ "out of memory",
142791 /* SQLITE_READONLY */ "attempt to write a readonly database",
142792 /* SQLITE_INTERRUPT */ "interrupted",
@@ -142501,21 +142794,25 @@
142794 /* SQLITE_CORRUPT */ "database disk image is malformed",
142795 /* SQLITE_NOTFOUND */ "unknown operation",
142796 /* SQLITE_FULL */ "database or disk is full",
142797 /* SQLITE_CANTOPEN */ "unable to open database file",
142798 /* SQLITE_PROTOCOL */ "locking protocol",
142799 /* SQLITE_EMPTY */ 0,
142800 /* SQLITE_SCHEMA */ "database schema has changed",
142801 /* SQLITE_TOOBIG */ "string or blob too big",
142802 /* SQLITE_CONSTRAINT */ "constraint failed",
142803 /* SQLITE_MISMATCH */ "datatype mismatch",
142804 /* SQLITE_MISUSE */ "bad parameter or other API misuse",
142805 #ifdef SQLITE_DISABLE_LFS
142806 /* SQLITE_NOLFS */ "large file support is disabled",
142807 #else
142808 /* SQLITE_NOLFS */ 0,
142809 #endif
142810 /* SQLITE_AUTH */ "authorization denied",
142811 /* SQLITE_FORMAT */ 0,
142812 /* SQLITE_RANGE */ "column index out of range",
142813 /* SQLITE_NOTADB */ "file is not a database",
142814 };
142815 const char *zErr = "unknown error";
142816 switch( rc ){
142817 case SQLITE_ABORT_ROLLBACK: {
142818 zErr = "abort due to ROLLBACK";
@@ -143351,16 +143648,13 @@
143648 SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
143649 static const u16 outOfMem[] = {
143650 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
143651 };
143652 static const u16 misuse[] = {
143653 'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ',
143654 'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ',
143655 'm', 'i', 's', 'u', 's', 'e', 0
 
 
 
143656 };
143657
143658 const void *z;
143659 if( !db ){
143660 return (void *)outOfMem;
@@ -143891,30 +144185,10 @@
144185 #ifndef SQLITE_OMIT_AUTOINIT
144186 rc = sqlite3_initialize();
144187 if( rc ) return rc;
144188 #endif
144189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144190 if( sqlite3GlobalConfig.bCoreMutex==0 ){
144191 isThreadsafe = 0;
144192 }else if( flags & SQLITE_OPEN_NOMUTEX ){
144193 isThreadsafe = 0;
144194 }else if( flags & SQLITE_OPEN_FULLMUTEX ){
@@ -144032,13 +144306,34 @@
144306 ** strings is BINARY.
144307 */
144308 db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);
144309 assert( db->pDfltColl!=0 );
144310
144311 /* Parse the filename/URI argument
144312 **
144313 ** Only allow sensible combinations of bits in the flags argument.
144314 ** Throw an error if any non-sense combination is used. If we
144315 ** do not block illegal combinations here, it could trigger
144316 ** assert() statements in deeper layers. Sensible combinations
144317 ** are:
144318 **
144319 ** 1: SQLITE_OPEN_READONLY
144320 ** 2: SQLITE_OPEN_READWRITE
144321 ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
144322 */
144323 db->openFlags = flags;
144324 assert( SQLITE_OPEN_READONLY == 0x01 );
144325 assert( SQLITE_OPEN_READWRITE == 0x02 );
144326 assert( SQLITE_OPEN_CREATE == 0x04 );
144327 testcase( (1<<(flags&7))==0x02 ); /* READONLY */
144328 testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
144329 testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
144330 if( ((1<<(flags&7)) & 0x46)==0 ){
144331 rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
144332 }else{
144333 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
144334 }
144335 if( rc!=SQLITE_OK ){
144336 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
144337 sqlite3ErrorWithMsg(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
144338 sqlite3_free(zErrMsg);
144339 goto opendb_out;
@@ -148199,23 +148494,32 @@
148494 }
148495 pCsr->bSeekStmt = 0;
148496 }
148497 sqlite3_finalize(pCsr->pStmt);
148498 }
148499
148500 /*
148501 ** Free all resources currently held by the cursor passed as the only
148502 ** argument.
148503 */
148504 static void fts3ClearCursor(Fts3Cursor *pCsr){
148505 fts3CursorFinalizeStmt(pCsr);
148506 sqlite3Fts3FreeDeferredTokens(pCsr);
148507 sqlite3_free(pCsr->aDoclist);
148508 sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);
148509 sqlite3Fts3ExprFree(pCsr->pExpr);
148510 memset(&(&pCsr->base)[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
148511 }
148512
148513 /*
148514 ** Close the cursor. For additional information see the documentation
148515 ** on the xClose method of the virtual table interface.
148516 */
148517 static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){
148518 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
148519 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148520 fts3ClearCursor(pCsr);
 
 
 
 
148521 assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );
148522 sqlite3_free(pCsr);
148523 return SQLITE_OK;
148524 }
148525
@@ -149712,15 +150016,11 @@
150016 if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];
150017 if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];
150018 assert( iIdx==nVal );
150019
150020 /* In case the cursor has been used before, clear it now. */
150021 fts3ClearCursor(pCsr);
 
 
 
 
150022
150023 /* Set the lower and upper bounds on docids to return */
150024 pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);
150025 pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);
150026
@@ -149795,11 +150095,16 @@
150095 /*
150096 ** This is the xEof method of the virtual table. SQLite calls this
150097 ** routine to find out if it has reached the end of a result set.
150098 */
150099 static int fts3EofMethod(sqlite3_vtab_cursor *pCursor){
150100 Fts3Cursor *pCsr = (Fts3Cursor*)pCursor;
150101 if( pCsr->isEof ){
150102 fts3ClearCursor(pCsr);
150103 pCsr->isEof = 1;
150104 }
150105 return pCsr->isEof;
150106 }
150107
150108 /*
150109 ** This is the xRowid method. The SQLite core calls this routine to
150110 ** retrieve the rowid for the current row of the result set. fts3
@@ -168168,10 +168473,14 @@
168473 pRtree->zDb, pRtree->zName
168474 );
168475 rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);
168476 if( rc!=SQLITE_OK ){
168477 *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
168478 }else if( pRtree->iNodeSize<(512-64) ){
168479 rc = SQLITE_CORRUPT;
168480 *pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"",
168481 pRtree->zName);
168482 }
168483 }
168484
168485 sqlite3_free(zSql);
168486 return rc;
@@ -184399,11 +184708,13 @@
184708 pParser->fts5yyerrcnt = -1;
184709 #endif
184710 pParser->fts5yytos = pParser->fts5yystack;
184711 pParser->fts5yystack[0].stateno = 0;
184712 pParser->fts5yystack[0].major = 0;
184713 #if fts5YYSTACKDEPTH>0
184714 pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];
184715 #endif
184716 }
184717
184718 #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK
184719 /*
184720 ** This function allocates a new parser.
@@ -199766,11 +200077,11 @@
200077 int nArg, /* Number of args */
200078 sqlite3_value **apUnused /* Function arguments */
200079 ){
200080 assert( nArg==0 );
200081 UNUSED_PARAM2(nArg, apUnused);
200082 sqlite3_result_text(pCtx, "fts5: 2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40", -1, SQLITE_TRANSIENT);
200083 }
200084
200085 static int fts5Init(sqlite3 *db){
200086 static const sqlite3_module fts5Mod = {
200087 /* iVersion */ 2,
@@ -203694,20 +204005,20 @@
204005 sqlite3_int64 iRowid; /* The rowid */
204006 };
204007
204008 /*
204009 ** The stmtConnect() method is invoked to create a new
204010 ** stmt_vtab that describes the stmt virtual table.
204011 **
204012 ** Think of this routine as the constructor for stmt_vtab objects.
204013 **
204014 ** All this routine needs to do is:
204015 **
204016 ** (1) Allocate the stmt_vtab object and initialize all fields.
204017 **
204018 ** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
204019 ** result set of queries against stmt will look like.
204020 */
204021 static int stmtConnect(
204022 sqlite3 *db,
204023 void *pAux,
204024 int argc, const char *const*argv,
@@ -203871,11 +204182,11 @@
204182 return stmtNext(pVtabCursor);
204183 }
204184
204185 /*
204186 ** SQLite will invoke this method one or more times while planning a query
204187 ** that uses the stmt virtual table. This routine needs to create
204188 ** a query plan for each invocation and compute an estimated cost for that
204189 ** plan.
204190 */
204191 static int stmtBestIndex(
204192 sqlite3_vtab *tab,
@@ -203886,11 +204197,11 @@
204197 return SQLITE_OK;
204198 }
204199
204200 /*
204201 ** This following structure defines all the methods for the
204202 ** stmt virtual table.
204203 */
204204 static sqlite3_module stmtModule = {
204205 0, /* iVersion */
204206 0, /* xCreate */
204207 stmtConnect, /* xConnect */
204208
+95 -27
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.20.0"
125125
#define SQLITE_VERSION_NUMBER 3020000
126
-#define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
126
+#define SQLITE_SOURCE_ID "2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -415,11 +415,11 @@
415415
**
416416
** See also: [extended result code definitions]
417417
*/
418418
#define SQLITE_OK 0 /* Successful result */
419419
/* beginning-of-error-codes */
420
-#define SQLITE_ERROR 1 /* SQL error or missing database */
420
+#define SQLITE_ERROR 1 /* Generic error */
421421
#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
422422
#define SQLITE_PERM 3 /* Access permission denied */
423423
#define SQLITE_ABORT 4 /* Callback routine requested an abort */
424424
#define SQLITE_BUSY 5 /* The database file is locked */
425425
#define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -430,19 +430,19 @@
430430
#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
431431
#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
432432
#define SQLITE_FULL 13 /* Insertion failed because database is full */
433433
#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
434434
#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
435
-#define SQLITE_EMPTY 16 /* Database is empty */
435
+#define SQLITE_EMPTY 16 /* Not used */
436436
#define SQLITE_SCHEMA 17 /* The database schema changed */
437437
#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
438438
#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
439439
#define SQLITE_MISMATCH 20 /* Data type mismatch */
440440
#define SQLITE_MISUSE 21 /* Library used incorrectly */
441441
#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
442442
#define SQLITE_AUTH 23 /* Authorization denied */
443
-#define SQLITE_FORMAT 24 /* Auxiliary database format error */
443
+#define SQLITE_FORMAT 24 /* Not used */
444444
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
445445
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
446446
#define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
447447
#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
448448
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -4265,10 +4265,32 @@
42654265
42664266
/*
42674267
** CAPI3REF: Result Values From A Query
42684268
** KEYWORDS: {column access functions}
42694269
** METHOD: sqlite3_stmt
4270
+**
4271
+** <b>Summary:</b>
4272
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4273
+** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
4274
+** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
4275
+** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
4276
+** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
4277
+** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
4278
+** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
4279
+** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
4280
+** [sqlite3_value|unprotected sqlite3_value] object.
4281
+** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
4282
+** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
4283
+** or a UTF-8 TEXT result in bytes
4284
+** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
4285
+** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
4286
+** TEXT in bytes
4287
+** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
4288
+** datatype of the result
4289
+** </table></blockquote>
4290
+**
4291
+** <b>Details:</b>
42704292
**
42714293
** ^These routines return information about a single column of the current
42724294
** result row of a query. ^In every case the first argument is a pointer
42734295
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
42744296
** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -4287,19 +4309,32 @@
42874309
** something other than [SQLITE_ROW], the results are undefined.
42884310
** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
42894311
** are called from a different thread while any of these routines
42904312
** are pending, then the results are undefined.
42914313
**
4314
+** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
4315
+** each return the value of a result column in a specific data format. If
4316
+** the result column is not initially in the requested format (for example,
4317
+** if the query returns an integer but the sqlite3_column_text() interface
4318
+** is used to extract the value) then an automatic type conversion is performed.
4319
+**
42924320
** ^The sqlite3_column_type() routine returns the
42934321
** [SQLITE_INTEGER | datatype code] for the initial data type
42944322
** of the result column. ^The returned value is one of [SQLITE_INTEGER],
4295
-** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
4296
-** returned by sqlite3_column_type() is only meaningful if no type
4297
-** conversions have occurred as described below. After a type conversion,
4298
-** the value returned by sqlite3_column_type() is undefined. Future
4323
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].
4324
+** The return value of sqlite3_column_type() can be used to decide which
4325
+** of the first six interface should be used to extract the column value.
4326
+** The value returned by sqlite3_column_type() is only meaningful if no
4327
+** automatic type conversions have occurred for the value in question.
4328
+** After a type conversion, the result of calling sqlite3_column_type()
4329
+** is undefined, though harmless. Future
42994330
** versions of SQLite may change the behavior of sqlite3_column_type()
43004331
** following a type conversion.
4332
+**
4333
+** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
4334
+** or sqlite3_column_bytes16() interfaces can be used to determine the size
4335
+** of that BLOB or string.
43014336
**
43024337
** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
43034338
** routine returns the number of bytes in that BLOB or string.
43044339
** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
43054340
** the string to UTF-8 and then returns the number of bytes.
@@ -4333,13 +4368,17 @@
43334368
** [sqlite3_bind_value()] and [sqlite3_result_value()].
43344369
** If the [unprotected sqlite3_value] object returned by
43354370
** [sqlite3_column_value()] is used in any other way, including calls
43364371
** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
43374372
** or [sqlite3_value_bytes()], the behavior is not threadsafe.
4373
+** Hence, the sqlite3_column_value() interface
4374
+** is normally only useful within the implementation of
4375
+** [application-defined SQL functions] or [virtual tables], not within
4376
+** top-level application code.
43384377
**
4339
-** These routines attempt to convert the value where appropriate. ^For
4340
-** example, if the internal representation is FLOAT and a text result
4378
+** The these routines may attempt to convert the datatype of the result.
4379
+** ^For example, if the internal representation is FLOAT and a text result
43414380
** is requested, [sqlite3_snprintf()] is used internally to perform the
43424381
** conversion automatically. ^(The following table details the conversions
43434382
** that are applied:
43444383
**
43454384
** <blockquote>
@@ -4407,11 +4446,11 @@
44074446
** with calls to sqlite3_column_bytes().
44084447
**
44094448
** ^The pointers returned are valid until a type conversion occurs as
44104449
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
44114450
** [sqlite3_finalize()] is called. ^The memory space used to hold strings
4412
-** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
4451
+** and BLOBs is freed automatically. Do not pass the pointers returned
44134452
** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
44144453
** [sqlite3_free()].
44154454
**
44164455
** ^(If a memory allocation error occurs during the evaluation of any
44174456
** of these routines, a default value is returned. The default value
@@ -4418,19 +4457,19 @@
44184457
** is either the integer 0, the floating point number 0.0, or a NULL
44194458
** pointer. Subsequent calls to [sqlite3_errcode()] will return
44204459
** [SQLITE_NOMEM].)^
44214460
*/
44224461
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4423
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4424
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
44254462
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
44264463
SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
44274464
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
44284465
SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
44294466
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4430
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
44314467
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4468
+SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4469
+SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4470
+SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
44324471
44334472
/*
44344473
** CAPI3REF: Destroy A Prepared Statement Object
44354474
** DESTRUCTOR: sqlite3_stmt
44364475
**
@@ -4660,25 +4699,43 @@
46604699
46614700
/*
46624701
** CAPI3REF: Obtaining SQL Values
46634702
** METHOD: sqlite3_value
46644703
**
4665
-** The C-language implementation of SQL functions and aggregates uses
4666
-** this set of interface routines to access the parameter values on
4667
-** the function or aggregate.
4704
+** <b>Summary:</b>
4705
+** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4706
+** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
4707
+** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
4708
+** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
4709
+** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
4710
+** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
4711
+** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
4712
+** the native byteorder
4713
+** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
4714
+** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
4715
+** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
4716
+** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB
4717
+** or a UTF-8 TEXT in bytes
4718
+** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>
4719
+** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
4720
+** TEXT in bytes
4721
+** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default
4722
+** datatype of the value
4723
+** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
4724
+** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4725
+** </table></blockquote>
46684726
**
4669
-** The xFunc (for scalar functions) or xStep (for aggregates) parameters
4670
-** to [sqlite3_create_function()] and [sqlite3_create_function16()]
4671
-** define callbacks that implement the SQL functions and aggregates.
4672
-** The 3rd parameter to these callbacks is an array of pointers to
4673
-** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
4674
-** each parameter to the SQL function. These routines are used to
4675
-** extract values from the [sqlite3_value] objects.
4727
+** <b>Details:</b>
4728
+**
4729
+** This routine extract type, size, and content information from
4730
+** [protected sqlite3_value] objects. Protected sqlite3_value objects
4731
+** are used to pass parameter information into implementation of
4732
+** [application-defined SQL functions] and [virtual tables].
46764733
**
46774734
** These routines work only with [protected sqlite3_value] objects.
46784735
** Any attempt to use these routines on an [unprotected sqlite3_value]
4679
-** object results in undefined behavior.
4736
+** is not threadsafe.
46804737
**
46814738
** ^These routines work just like the corresponding [column access functions]
46824739
** except that these routines take a single [protected sqlite3_value] object
46834740
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
46844741
**
@@ -4685,10 +4742,21 @@
46854742
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
46864743
** in the native byte-order of the host machine. ^The
46874744
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
46884745
** extract UTF-16 strings as big-endian and little-endian respectively.
46894746
**
4747
+** ^(The sqlite3_value_type(V) interface returns the
4748
+** [SQLITE_INTEGER | datatype code] for the initial datatype of the
4749
+** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
4750
+** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
4751
+** Other interfaces might change the datatype for an sqlite3_value object.
4752
+** For example, if the datatype is initially SQLITE_INTEGER and
4753
+** sqlite3_value_text(V) is called to extract a text value for that
4754
+** integer, then subsequent calls to sqlite3_value_type(V) might return
4755
+** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
4756
+** occurs is undefined and may change from one release of SQLite to the next.
4757
+**
46904758
** ^(The sqlite3_value_numeric_type() interface attempts to apply
46914759
** numeric affinity to the value. This means that an attempt is
46924760
** made to convert the value to an integer or floating point. If
46934761
** such a conversion is possible without loss of information (in other
46944762
** words, if the value is a string that looks like a number)
@@ -4703,19 +4771,19 @@
47034771
**
47044772
** These routines must be called from the same thread as
47054773
** the SQL function that supplied the [sqlite3_value*] parameters.
47064774
*/
47074775
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4708
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4709
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
47104776
SQLITE_API double sqlite3_value_double(sqlite3_value*);
47114777
SQLITE_API int sqlite3_value_int(sqlite3_value*);
47124778
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
47134779
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
47144780
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
47154781
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
47164782
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4783
+SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4784
+SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
47174785
SQLITE_API int sqlite3_value_type(sqlite3_value*);
47184786
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
47194787
47204788
/*
47214789
** CAPI3REF: Finding The Subtype Of SQL Values
47224790
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-06-29 17:27:04 284707a7b3514a55cce24292e45632b7033d6edcff5b27deac5118b27c7b2954"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -415,11 +415,11 @@
415 **
416 ** See also: [extended result code definitions]
417 */
418 #define SQLITE_OK 0 /* Successful result */
419 /* beginning-of-error-codes */
420 #define SQLITE_ERROR 1 /* SQL error or missing database */
421 #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
422 #define SQLITE_PERM 3 /* Access permission denied */
423 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
424 #define SQLITE_BUSY 5 /* The database file is locked */
425 #define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -430,19 +430,19 @@
430 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
431 #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
432 #define SQLITE_FULL 13 /* Insertion failed because database is full */
433 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
434 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
435 #define SQLITE_EMPTY 16 /* Database is empty */
436 #define SQLITE_SCHEMA 17 /* The database schema changed */
437 #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
438 #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
439 #define SQLITE_MISMATCH 20 /* Data type mismatch */
440 #define SQLITE_MISUSE 21 /* Library used incorrectly */
441 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
442 #define SQLITE_AUTH 23 /* Authorization denied */
443 #define SQLITE_FORMAT 24 /* Auxiliary database format error */
444 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
445 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
446 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
447 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
448 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -4265,10 +4265,32 @@
4265
4266 /*
4267 ** CAPI3REF: Result Values From A Query
4268 ** KEYWORDS: {column access functions}
4269 ** METHOD: sqlite3_stmt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4270 **
4271 ** ^These routines return information about a single column of the current
4272 ** result row of a query. ^In every case the first argument is a pointer
4273 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4274 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -4287,19 +4309,32 @@
4287 ** something other than [SQLITE_ROW], the results are undefined.
4288 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
4289 ** are called from a different thread while any of these routines
4290 ** are pending, then the results are undefined.
4291 **
 
 
 
 
 
 
4292 ** ^The sqlite3_column_type() routine returns the
4293 ** [SQLITE_INTEGER | datatype code] for the initial data type
4294 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
4295 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
4296 ** returned by sqlite3_column_type() is only meaningful if no type
4297 ** conversions have occurred as described below. After a type conversion,
4298 ** the value returned by sqlite3_column_type() is undefined. Future
 
 
 
4299 ** versions of SQLite may change the behavior of sqlite3_column_type()
4300 ** following a type conversion.
 
 
 
 
4301 **
4302 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
4303 ** routine returns the number of bytes in that BLOB or string.
4304 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
4305 ** the string to UTF-8 and then returns the number of bytes.
@@ -4333,13 +4368,17 @@
4333 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
4334 ** If the [unprotected sqlite3_value] object returned by
4335 ** [sqlite3_column_value()] is used in any other way, including calls
4336 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
4337 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
 
 
 
 
4338 **
4339 ** These routines attempt to convert the value where appropriate. ^For
4340 ** example, if the internal representation is FLOAT and a text result
4341 ** is requested, [sqlite3_snprintf()] is used internally to perform the
4342 ** conversion automatically. ^(The following table details the conversions
4343 ** that are applied:
4344 **
4345 ** <blockquote>
@@ -4407,11 +4446,11 @@
4407 ** with calls to sqlite3_column_bytes().
4408 **
4409 ** ^The pointers returned are valid until a type conversion occurs as
4410 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
4411 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
4412 ** and BLOBs is freed automatically. Do <em>not</em> pass the pointers returned
4413 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
4414 ** [sqlite3_free()].
4415 **
4416 ** ^(If a memory allocation error occurs during the evaluation of any
4417 ** of these routines, a default value is returned. The default value
@@ -4418,19 +4457,19 @@
4418 ** is either the integer 0, the floating point number 0.0, or a NULL
4419 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4420 ** [SQLITE_NOMEM].)^
4421 */
4422 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4423 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4424 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4425 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4426 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4427 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4428 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4429 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4430 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4431 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 
 
 
4432
4433 /*
4434 ** CAPI3REF: Destroy A Prepared Statement Object
4435 ** DESTRUCTOR: sqlite3_stmt
4436 **
@@ -4660,25 +4699,43 @@
4660
4661 /*
4662 ** CAPI3REF: Obtaining SQL Values
4663 ** METHOD: sqlite3_value
4664 **
4665 ** The C-language implementation of SQL functions and aggregates uses
4666 ** this set of interface routines to access the parameter values on
4667 ** the function or aggregate.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4668 **
4669 ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
4670 ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
4671 ** define callbacks that implement the SQL functions and aggregates.
4672 ** The 3rd parameter to these callbacks is an array of pointers to
4673 ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for
4674 ** each parameter to the SQL function. These routines are used to
4675 ** extract values from the [sqlite3_value] objects.
4676 **
4677 ** These routines work only with [protected sqlite3_value] objects.
4678 ** Any attempt to use these routines on an [unprotected sqlite3_value]
4679 ** object results in undefined behavior.
4680 **
4681 ** ^These routines work just like the corresponding [column access functions]
4682 ** except that these routines take a single [protected sqlite3_value] object
4683 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
4684 **
@@ -4685,10 +4742,21 @@
4685 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
4686 ** in the native byte-order of the host machine. ^The
4687 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
4688 ** extract UTF-16 strings as big-endian and little-endian respectively.
4689 **
 
 
 
 
 
 
 
 
 
 
 
4690 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
4691 ** numeric affinity to the value. This means that an attempt is
4692 ** made to convert the value to an integer or floating point. If
4693 ** such a conversion is possible without loss of information (in other
4694 ** words, if the value is a string that looks like a number)
@@ -4703,19 +4771,19 @@
4703 **
4704 ** These routines must be called from the same thread as
4705 ** the SQL function that supplied the [sqlite3_value*] parameters.
4706 */
4707 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4708 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4709 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4710 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4711 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4712 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4713 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4714 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4715 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4716 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
 
 
4717 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4718 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4719
4720 /*
4721 ** CAPI3REF: Finding The Subtype Of SQL Values
4722
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.20.0"
125 #define SQLITE_VERSION_NUMBER 3020000
126 #define SQLITE_SOURCE_ID "2017-07-11 13:59:07 95cd1d9f8baa6be305c9a8bfa26fef2a403f2d5b3b5c9c55382ec04f0bc98d40"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -415,11 +415,11 @@
415 **
416 ** See also: [extended result code definitions]
417 */
418 #define SQLITE_OK 0 /* Successful result */
419 /* beginning-of-error-codes */
420 #define SQLITE_ERROR 1 /* Generic error */
421 #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
422 #define SQLITE_PERM 3 /* Access permission denied */
423 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
424 #define SQLITE_BUSY 5 /* The database file is locked */
425 #define SQLITE_LOCKED 6 /* A table in the database is locked */
@@ -430,19 +430,19 @@
430 #define SQLITE_CORRUPT 11 /* The database disk image is malformed */
431 #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
432 #define SQLITE_FULL 13 /* Insertion failed because database is full */
433 #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
434 #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
435 #define SQLITE_EMPTY 16 /* Not used */
436 #define SQLITE_SCHEMA 17 /* The database schema changed */
437 #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
438 #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
439 #define SQLITE_MISMATCH 20 /* Data type mismatch */
440 #define SQLITE_MISUSE 21 /* Library used incorrectly */
441 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
442 #define SQLITE_AUTH 23 /* Authorization denied */
443 #define SQLITE_FORMAT 24 /* Not used */
444 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
445 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
446 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
447 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
448 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
@@ -4265,10 +4265,32 @@
4265
4266 /*
4267 ** CAPI3REF: Result Values From A Query
4268 ** KEYWORDS: {column access functions}
4269 ** METHOD: sqlite3_stmt
4270 **
4271 ** <b>Summary:</b>
4272 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4273 ** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result
4274 ** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result
4275 ** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result
4276 ** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result
4277 ** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result
4278 ** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result
4279 ** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an
4280 ** [sqlite3_value|unprotected sqlite3_value] object.
4281 ** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
4282 ** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB
4283 ** or a UTF-8 TEXT result in bytes
4284 ** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>
4285 ** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
4286 ** TEXT in bytes
4287 ** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default
4288 ** datatype of the result
4289 ** </table></blockquote>
4290 **
4291 ** <b>Details:</b>
4292 **
4293 ** ^These routines return information about a single column of the current
4294 ** result row of a query. ^In every case the first argument is a pointer
4295 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
4296 ** that was returned from [sqlite3_prepare_v3()] or one of its variants)
@@ -4287,19 +4309,32 @@
4309 ** something other than [SQLITE_ROW], the results are undefined.
4310 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
4311 ** are called from a different thread while any of these routines
4312 ** are pending, then the results are undefined.
4313 **
4314 ** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)
4315 ** each return the value of a result column in a specific data format. If
4316 ** the result column is not initially in the requested format (for example,
4317 ** if the query returns an integer but the sqlite3_column_text() interface
4318 ** is used to extract the value) then an automatic type conversion is performed.
4319 **
4320 ** ^The sqlite3_column_type() routine returns the
4321 ** [SQLITE_INTEGER | datatype code] for the initial data type
4322 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
4323 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].
4324 ** The return value of sqlite3_column_type() can be used to decide which
4325 ** of the first six interface should be used to extract the column value.
4326 ** The value returned by sqlite3_column_type() is only meaningful if no
4327 ** automatic type conversions have occurred for the value in question.
4328 ** After a type conversion, the result of calling sqlite3_column_type()
4329 ** is undefined, though harmless. Future
4330 ** versions of SQLite may change the behavior of sqlite3_column_type()
4331 ** following a type conversion.
4332 **
4333 ** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()
4334 ** or sqlite3_column_bytes16() interfaces can be used to determine the size
4335 ** of that BLOB or string.
4336 **
4337 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
4338 ** routine returns the number of bytes in that BLOB or string.
4339 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
4340 ** the string to UTF-8 and then returns the number of bytes.
@@ -4333,13 +4368,17 @@
4368 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
4369 ** If the [unprotected sqlite3_value] object returned by
4370 ** [sqlite3_column_value()] is used in any other way, including calls
4371 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
4372 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
4373 ** Hence, the sqlite3_column_value() interface
4374 ** is normally only useful within the implementation of
4375 ** [application-defined SQL functions] or [virtual tables], not within
4376 ** top-level application code.
4377 **
4378 ** The these routines may attempt to convert the datatype of the result.
4379 ** ^For example, if the internal representation is FLOAT and a text result
4380 ** is requested, [sqlite3_snprintf()] is used internally to perform the
4381 ** conversion automatically. ^(The following table details the conversions
4382 ** that are applied:
4383 **
4384 ** <blockquote>
@@ -4407,11 +4446,11 @@
4446 ** with calls to sqlite3_column_bytes().
4447 **
4448 ** ^The pointers returned are valid until a type conversion occurs as
4449 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
4450 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
4451 ** and BLOBs is freed automatically. Do not pass the pointers returned
4452 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
4453 ** [sqlite3_free()].
4454 **
4455 ** ^(If a memory allocation error occurs during the evaluation of any
4456 ** of these routines, a default value is returned. The default value
@@ -4418,19 +4457,19 @@
4457 ** is either the integer 0, the floating point number 0.0, or a NULL
4458 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4459 ** [SQLITE_NOMEM].)^
4460 */
4461 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
 
 
4462 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4463 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4464 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4465 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4466 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
 
4467 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4468 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4469 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4470 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4471
4472 /*
4473 ** CAPI3REF: Destroy A Prepared Statement Object
4474 ** DESTRUCTOR: sqlite3_stmt
4475 **
@@ -4660,25 +4699,43 @@
4699
4700 /*
4701 ** CAPI3REF: Obtaining SQL Values
4702 ** METHOD: sqlite3_value
4703 **
4704 ** <b>Summary:</b>
4705 ** <blockquote><table border=0 cellpadding=0 cellspacing=0>
4706 ** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value
4707 ** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value
4708 ** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value
4709 ** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value
4710 ** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value
4711 ** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in
4712 ** the native byteorder
4713 ** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value
4714 ** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value
4715 ** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;
4716 ** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB
4717 ** or a UTF-8 TEXT in bytes
4718 ** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>
4719 ** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16
4720 ** TEXT in bytes
4721 ** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default
4722 ** datatype of the value
4723 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
4724 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4725 ** </table></blockquote>
4726 **
4727 ** <b>Details:</b>
4728 **
4729 ** This routine extract type, size, and content information from
4730 ** [protected sqlite3_value] objects. Protected sqlite3_value objects
4731 ** are used to pass parameter information into implementation of
4732 ** [application-defined SQL functions] and [virtual tables].
 
4733 **
4734 ** These routines work only with [protected sqlite3_value] objects.
4735 ** Any attempt to use these routines on an [unprotected sqlite3_value]
4736 ** is not threadsafe.
4737 **
4738 ** ^These routines work just like the corresponding [column access functions]
4739 ** except that these routines take a single [protected sqlite3_value] object
4740 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
4741 **
@@ -4685,10 +4742,21 @@
4742 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
4743 ** in the native byte-order of the host machine. ^The
4744 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
4745 ** extract UTF-16 strings as big-endian and little-endian respectively.
4746 **
4747 ** ^(The sqlite3_value_type(V) interface returns the
4748 ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
4749 ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
4750 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
4751 ** Other interfaces might change the datatype for an sqlite3_value object.
4752 ** For example, if the datatype is initially SQLITE_INTEGER and
4753 ** sqlite3_value_text(V) is called to extract a text value for that
4754 ** integer, then subsequent calls to sqlite3_value_type(V) might return
4755 ** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
4756 ** occurs is undefined and may change from one release of SQLite to the next.
4757 **
4758 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
4759 ** numeric affinity to the value. This means that an attempt is
4760 ** made to convert the value to an integer or floating point. If
4761 ** such a conversion is possible without loss of information (in other
4762 ** words, if the value is a string that looks like a number)
@@ -4703,19 +4771,19 @@
4771 **
4772 ** These routines must be called from the same thread as
4773 ** the SQL function that supplied the [sqlite3_value*] parameters.
4774 */
4775 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
 
 
4776 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4777 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4778 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4779 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4780 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4781 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4782 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4783 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4784 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4785 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4786 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4787
4788 /*
4789 ** CAPI3REF: Finding The Subtype Of SQL Values
4790

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button