Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch branch-1.28 Through [7ecb9d25f9] Excluding Merge-Ins
This is equivalent to a diff from cde4759d5e to 7ecb9d25f9
|
2014-02-14
| ||
| 13:37 | Cherrypick [252aff3e62] and related clean-ups: Use built-in Tcl for "diff --tk" implementation if possible. Fallback is to spawn an external "tclsh" as before. This makes "fossil diff --tk" work with ActiveState Tcl on Win32 out-of-the-box. ... (check-in: f325b2343e user: jan.nijtmans tags: branch-1.28) | |
| 12:44 | Cherrypick [7b30a7c7ef8977a7]: unbreak win/Makefile.mingw for modified SRCDIR ... (check-in: 7ecb9d25f9 user: jan.nijtmans tags: branch-1.28) | |
| 11:01 | Cherrypick [d8a588ba765ae5be]: Check for "clearsign" option in "fossil branch" command. Reported by J. van den Hoff. ... (check-in: 21904cec14 user: jan.nijtmans tags: branch-1.28) | |
|
2014-01-17
| ||
| 12:47 | unbreak win/Makefile.mingw for modified SRCDIR ... (check-in: 7b30a7c7ef user: jan.nijtmans tags: trunk) | |
|
2014-01-13
| ||
| 23:32 | Make sure that TH1 variables get removed from the call frame upon being unset. ... (check-in: 1ebe4b02e4 user: mistachkin tags: trunk) | |
| 23:06 | Trim trailing whitespace in TH1 and align some comments. ... (check-in: 5a9f9ba61d user: mistachkin tags: th1Work) | |
| 22:50 | Merge updates from trunk. Style fixes. ... (check-in: 81c185f685 user: mistachkin tags: delay-ticket-hook) | |
| 13:27 | Add discussion of SQLITE_ENABLE_EXPLAIN_COMMENTS to the makefile documentation. ... (check-in: cde4759d5e user: drh tags: trunk) | |
|
2014-01-12
| ||
| 10:24 | Fix tree-view JS error/warnings. ... (check-in: 26c26b6fc3 user: joel tags: trunk) | |
Changes to auto.def.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 |
# search for the system SQLite once with -ldl, and once without. If
# the library can only be found with $extralibs set to -ldl, then
# the code below will append -ldl to LIBS.
#
foreach extralibs {{} {-ldl}} {
# Locate the system SQLite by searching for sqlite3_open(). Then check
| | | | | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# search for the system SQLite once with -ldl, and once without. If
# the library can only be found with $extralibs set to -ldl, then
# the code below will append -ldl to LIBS.
#
foreach extralibs {{} {-ldl}} {
# Locate the system SQLite by searching for sqlite3_open(). Then check
# if sqlite3_strglob() can be found as well. If we can find open() but
# not strglob(), then the system SQLite is too old to link against
# fossil.
#
if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
if {![cc-check-function-in-lib sqlite3_strglob sqlite3 $extralibs]} {
user-error "system sqlite3 too old (require >= 3.7.17)"
}
# Success. Update symbols and return.
#
define USE_SYSTEM_SQLITE 1
define-append LIBS $extralibs
return
|
| ︙ | ︙ |
Changes to src/branch.c.
| ︙ | ︙ | |||
49 50 51 52 53 54 55 |
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
verify_all_options();
if( g.argc<5 ){
usage("new BRANCH-NAME BASIS ?OPTIONS?");
}
db_find_and_open_repository(0, 0);
| | > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
zDateOvrd = find_option("date-override",0,1);
zUserOvrd = find_option("user-override",0,1);
verify_all_options();
if( g.argc<5 ){
usage("new BRANCH-NAME BASIS ?OPTIONS?");
}
db_find_and_open_repository(0, 0);
noSign = db_get_boolean("omitsign", 0)|noSign;
if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
/* fossil branch new name */
zBranch = g.argv[3];
if( zBranch==0 || zBranch[0]==0 ){
fossil_fatal("branch name cannot be empty");
}
if( db_exists(
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
376 377 378 379 380 381 382 |
#endif
free(g.zErrMsg);
if(g.db){
db_close(0);
}
/*
** FIXME: The next two lines cannot always be enabled; however, they
| | < > | | | | > | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
#endif
free(g.zErrMsg);
if(g.db){
db_close(0);
}
/*
** FIXME: The next two lines cannot always be enabled; however, they
** are very useful for tracking down TH1 memory leaks.
*/
if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
if( g.interp ){
Th_DeleteInterp(g.interp); g.interp = 0;
}
assert( Th_GetOutstandingMalloc()==0 );
}
}
/*
** Convert all arguments from mbcs (or unicode) to UTF-8. Then
** search g.argv for arguments "--args FILENAME". If found, then
** (1) remove the two arguments from g.argv
** (2) Read the file FILENAME
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 |
#endif
int main(int argc, char **argv)
#endif
{
const char *zCmdName = "unknown";
int idx;
int rc;
| | | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
#endif
int main(int argc, char **argv)
#endif
{
const char *zCmdName = "unknown";
int idx;
int rc;
if( sqlite3_libversion_number()<3007017 ){
fossil_fatal("Unsuitable SQLite version %s, must be at least 3.7.17",
sqlite3_libversion());
}
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
memset(&g, 0, sizeof(g));
g.now = time(0);
g.httpHeader = empty_blob;
|
| ︙ | ︙ |
Changes to src/main.mk.
| ︙ | ︙ | |||
390 391 392 393 394 395 396 |
-DSQLITE_OMIT_LOAD_EXTENSION=1
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
# to 1. If it is set to 1, then there is no need to build or link
# the sqlite3.o object. Instead, the system sqlite will be linked
# using -lsqlite3.
SQLITE3_OBJ.1 =
| | | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
-DSQLITE_OMIT_LOAD_EXTENSION=1
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
# to 1. If it is set to 1, then there is no need to build or link
# the sqlite3.o object. Instead, the system sqlite will be linked
# using -lsqlite3.
SQLITE3_OBJ.1 =
SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
SQLITE3_OBJ. = $(SQLITE3_OBJ.0)
# The FOSSIL_ENABLE_TCL variable may be undefined, set to 0, or set to 1.
# If it is set to 1, then we need to build the Tcl integration code and
# link to the Tcl library.
TCL_OBJ.0 =
TCL_OBJ.1 = $(OBJDIR)/th_tcl.o
TCL_OBJ. = $(TCL_OBJ.0)
EXTRAOBJ = $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) $(OBJDIR)/shell.o $(OBJDIR)/th.o $(OBJDIR)/th_lang.o $(TCL_OBJ.$(FOSSIL_ENABLE_TCL)) $(OBJDIR)/cson_amalgamation.o
$(APPNAME): $(OBJDIR)/headers $(OBJ) $(EXTRAOBJ)
$(TCC) -o $(APPNAME) $(OBJ) $(EXTRAOBJ) $(LIB)
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
|
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
259 260 261 262 263 264 265 | SHELL_OPTIONS = <<<SHELL_OPTIONS>>> # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set # to 1. If it is set to 1, then there is no need to build or link # the sqlite3.o object. Instead, the system sqlite will be linked # using -lsqlite3. SQLITE3_OBJ.1 = | | > | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | SHELL_OPTIONS = <<<SHELL_OPTIONS>>> # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set # to 1. If it is set to 1, then there is no need to build or link # the sqlite3.o object. Instead, the system sqlite will be linked # using -lsqlite3. SQLITE3_OBJ.1 = SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o SQLITE3_OBJ. = $(SQLITE3_OBJ.0) # The FOSSIL_ENABLE_TCL variable may be undefined, set to 0, or set to 1. # If it is set to 1, then we need to build the Tcl integration code and # link to the Tcl library. TCL_OBJ.0 = TCL_OBJ.1 = $(OBJDIR)/th_tcl.o TCL_OBJ. = $(TCL_OBJ.0) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(OBJDIR)/shell.o \ $(OBJDIR)/th.o \ $(OBJDIR)/th_lang.o \ $(TCL_OBJ.$(FOSSIL_ENABLE_TCL)) \ $(OBJDIR)/cson_amalgamation.o $(APPNAME): $(OBJDIR)/headers $(OBJ) $(EXTRAOBJ) $(TCC) -o $(APPNAME) $(OBJ) $(EXTRAOBJ) $(LIB) |
| ︙ | ︙ | |||
801 802 803 804 805 806 807 | lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MSIZE set j " \\\n " writeln "SQLITE_OPTIONS = [join $MINGW_SQLITE_OPTIONS $j]\n" set j " \\\n " writeln "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]\n" | | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MSIZE set j " \\\n " writeln "SQLITE_OPTIONS = [join $MINGW_SQLITE_OPTIONS $j]\n" set j " \\\n " writeln "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]\n" writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c \$(SRCDIR)/../win/Makefile.mingw" writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n" writeln "\$(OBJDIR)/cson_amalgamation.o:\t\$(SRCDIR)/cson_amalgamation.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/cson_amalgamation.c -o \$(OBJDIR)/cson_amalgamation.o\n" writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/jsos_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h\n" writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h \$(SRCDIR)/../win/Makefile.mingw" writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n" writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n" writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n" |
| ︙ | ︙ | |||
1030 1031 1032 1033 1034 1035 1036 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR) !ifdef FOSSIL_ENABLE_SSL INCL = $(INCL) -I$(SSLINCDIR) !endif | | | > > | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR) !ifdef FOSSIL_ENABLE_SSL INCL = $(INCL) -I$(SSLINCDIR) !endif CFLAGS = -nologo LDFLAGS = /NODEFAULTLIB:msvcrt /MANIFEST:NO !ifdef DEBUG CFLAGS = $(CFLAGS) -Zi -MTd -Od LDFLAGS = $(LDFLAGS) /DEBUG !else CFLAGS = $(CFLAGS) -MT -O2 !endif BCC = $(CC) $(CFLAGS) TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL) RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL) LIBS = $(ZLIB) ws2_32.lib advapi32.lib LIBDIR = -LIBPATH:$(ZLIBDIR) |
| ︙ | ︙ | |||
1125 1126 1127 1128 1129 1130 1131 | mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** mkversion$E: $B\src\mkversion.c $(BCC) $** | | | | 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** mkversion$E: $B\src\mkversion.c $(BCC) $** $(OX)\shell$O : $(SRCDIR)\shell.c $B\win\Makefile.msc $(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c $(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c $B\win\Makefile.msc $(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SRCDIR)\sqlite3.c $(OX)\th$O : $(SRCDIR)\th.c $(TCC) /Fo$@ -c $** $(OX)\th_lang$O : $(SRCDIR)\th_lang.c $(TCC) /Fo$@ -c $** |
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 | #define AGE_ADJUST_INCREMENT (25.0/86400000.0) /* 25 milliseconds */ #endif /* LOCAL_INTERFACE */ /* ** Finish up a sequence of manifest_crosslink calls. */ | | > > > > > > > > > > > > | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 |
#define AGE_ADJUST_INCREMENT (25.0/86400000.0) /* 25 milliseconds */
#endif /* LOCAL_INTERFACE */
/*
** Finish up a sequence of manifest_crosslink calls.
*/
int manifest_crosslink_end(int flags){
Stmt q, u;
int i;
int rc = TH_OK;
int permitHooks = (flags & MC_PERMIT_HOOKS);
const char *zScript = 0;
assert( manifest_crosslink_busy==1 );
if( permitHooks ){
rc = xfer_run_common_script();
if( rc==TH_OK ){
zScript = xfer_ticket_code();
}
}
db_prepare(&q, "SELECT uuid FROM pending_tkt");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
if( permitHooks && rc==TH_OK ){
rc = xfer_run_script(zScript, zUuid);
}
}
db_finalize(&q);
db_multi_exec("DROP TABLE pending_tkt");
/* If multiple check-ins happen close together in time, adjust their
** times by a few milliseconds to make sure they appear in chronological
** order.
|
| ︙ | ︙ | |||
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 |
"UPDATE event SET mtime=(SELECT m1 FROM time_fudge WHERE mid=objid)"
" WHERE objid IN (SELECT mid FROM time_fudge);"
"DROP TABLE time_fudge;"
);
db_end_transaction(0);
manifest_crosslink_busy = 0;
}
/*
** Make an entry in the event table for a ticket change artifact.
*/
void manifest_ticket_event(
int rid, /* Artifact ID of the change ticket artifact */
| > | 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 |
"UPDATE event SET mtime=(SELECT m1 FROM time_fudge WHERE mid=objid)"
" WHERE objid IN (SELECT mid FROM time_fudge);"
"DROP TABLE time_fudge;"
);
db_end_transaction(0);
manifest_crosslink_busy = 0;
return ( rc!=TH_ERROR );
}
/*
** Make an entry in the event table for a ticket change artifact.
*/
void manifest_ticket_event(
int rid, /* Artifact ID of the change ticket artifact */
|
| ︙ | ︙ | |||
1655 1656 1657 1658 1659 1660 1661 |
**
** Historical note: This routine original processed manifests only.
** Processing for other control artifacts was added later. The name
** of the routine, "manifest_crosslink", and the name of this source
** file, is a legacy of its original use.
*/
int manifest_crosslink(int rid, Blob *pContent, int flags){
| | > | 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 |
**
** Historical note: This routine original processed manifests only.
** Processing for other control artifacts was added later. The name
** of the routine, "manifest_crosslink", and the name of this source
** file, is a legacy of its original use.
*/
int manifest_crosslink(int rid, Blob *pContent, int flags){
int i, rc = TH_OK;
Manifest *p;
Stmt q;
int parentid = 0;
int permitHooks = (flags & MC_PERMIT_HOOKS);
const char *zScript = 0;
const char *zUuid = 0;
if( (p = manifest_cache_find(rid))!=0 ){
blob_reset(pContent);
}else if( (p = manifest_parse(pContent, rid, 0))==0 ){
assert( blob_is_reset(pContent) || pContent==0 );
|
| ︙ | ︙ | |||
1683 1684 1685 1686 1687 1688 1689 |
manifest_destroy(p);
assert( blob_is_reset(pContent) );
fossil_error(1, "cannot fetch baseline manifest");
return 0;
}
db_begin_transaction();
if( p->type==CFTYPE_MANIFEST ){
| > | > | 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 |
manifest_destroy(p);
assert( blob_is_reset(pContent) );
fossil_error(1, "cannot fetch baseline manifest");
return 0;
}
db_begin_transaction();
if( p->type==CFTYPE_MANIFEST ){
if( permitHooks ){
zScript = xfer_commit_code();
}
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
char *zCom;
for(i=0; i<p->nParent; i++){
int pid = uuid_to_rid(p->azParent[i], 1);
db_multi_exec("INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)"
"VALUES(%d, %d, %d, %.17g)", pid, rid, i==0, p->rDate);
|
| ︙ | ︙ | |||
1881 1882 1883 1884 1885 1886 1887 |
TAG_BGCOLOR, rid
);
}
}
if( p->type==CFTYPE_TICKET ){
char *zTag;
| < < | 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 |
TAG_BGCOLOR, rid
);
}
}
if( p->type==CFTYPE_TICKET ){
char *zTag;
assert( manifest_crosslink_busy==1 );
zTag = mprintf("tkt-%s", p->zTicketUuid);
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
free(zTag);
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
p->zTicketUuid);
}
|
| ︙ | ︙ | |||
1966 1967 1968 1969 1970 1971 1972 |
blob_appendf(&comment,
" Edit [%S]:",
zTagUuid);
branchMove = 0;
if( db_exists("SELECT 1 FROM event, blob"
" WHERE event.type='ci' AND event.objid=blob.rid"
" AND blob.uuid='%s'", zTagUuid) ){
| > | > | 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 |
blob_appendf(&comment,
" Edit [%S]:",
zTagUuid);
branchMove = 0;
if( db_exists("SELECT 1 FROM event, blob"
" WHERE event.type='ci' AND event.objid=blob.rid"
" AND blob.uuid='%s'", zTagUuid) ){
if( permitHooks ){
zScript = xfer_commit_code();
}
zUuid = zTagUuid;
}
}
zName = p->aTag[i].zName;
zValue = p->aTag[i].zValue;
if( strcmp(zName, "*branch")==0 ){
blob_appendf(&comment,
|
| ︙ | ︙ | |||
2040 2041 2042 2043 2044 2045 2046 |
"REPLACE INTO event(type,mtime,objid,user,comment)"
"VALUES('g',%.17g,%d,%Q,%Q)",
p->rDate, rid, p->zUser, blob_str(&comment)+1
);
blob_reset(&comment);
}
db_end_transaction(0);
| | | | | | | 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 |
"REPLACE INTO event(type,mtime,objid,user,comment)"
"VALUES('g',%.17g,%d,%Q,%Q)",
p->rDate, rid, p->zUser, blob_str(&comment)+1
);
blob_reset(&comment);
}
db_end_transaction(0);
if( permitHooks ){
rc = xfer_run_common_script();
if( rc==TH_OK ){
rc = xfer_run_script(zScript, zUuid);
}
}
if( p->type==CFTYPE_MANIFEST ){
manifest_cache_insert(p);
}else{
manifest_destroy(p);
}
assert( blob_is_reset(pContent) );
return ( rc!=TH_ERROR );
}
/*
** COMMAND: test-crosslink
**
** Usage: %fossil test-crosslink RECORDID
**
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
410 411 412 413 414 415 416 |
}
}else{
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
rebuild_step_done(rid);
}
}
db_finalize(&s);
| | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
}
}else{
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
rebuild_step_done(rid);
}
}
db_finalize(&s);
manifest_crosslink_end(MC_NONE);
rebuild_tag_trunk();
if( ttyOutput && !g.fQuiet && totalSize>0 ){
processCnt += incrSize;
percent_complete((processCnt*1000)/totalSize);
}
if( doClustering ) create_cluster();
if( ttyOutput && !g.fQuiet && totalSize>0 ){
|
| ︙ | ︙ |
Changes to src/shell.c.
| ︙ | ︙ | |||
593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
/*
** Output the given string with characters that are special to
** HTML escaped.
*/
static void output_html_string(FILE *out, const char *z){
int i;
while( *z ){
for(i=0; z[i]
&& z[i]!='<'
&& z[i]!='&'
&& z[i]!='>'
&& z[i]!='\"'
&& z[i]!='\'';
| > | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
/*
** Output the given string with characters that are special to
** HTML escaped.
*/
static void output_html_string(FILE *out, const char *z){
int i;
if( z==0 ) z = "";
while( *z ){
for(i=0; z[i]
&& z[i]!='<'
&& z[i]!='&'
&& z[i]!='>'
&& z[i]!='\"'
&& z[i]!='\'';
|
| ︙ | ︙ | |||
1138 1139 1140 1141 1142 1143 1144 |
if( pArg && pArg->out && db && pArg->pStmt ){
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);
fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
fprintf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
| > | | > | 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
if( pArg && pArg->out && db && pArg->pStmt ){
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);
fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
fprintf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
if( sqlite3_libversion_number()>=3008000 ){
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
}
}
return 0;
}
/*
** Parameter azArray points to a zero-terminated array of strings. zStr
|
| ︙ | ︙ | |||
1172 1173 1174 1175 1176 1177 1178 | ** ** * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent ** all opcodes that occur between the p2 jump destination and the opcode ** itself by 2 spaces. ** ** * For each "Goto", if the jump destination is earlier in the program ** and ends on one of: | | | | 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
**
** * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
** all opcodes that occur between the p2 jump destination and the opcode
** itself by 2 spaces.
**
** * For each "Goto", if the jump destination is earlier in the program
** and ends on one of:
** Yield SeekGt SeekLt RowSetRead Rewind
** then indent all opcodes between the earlier instruction
** and "Goto" by 2 spaces.
*/
static void explain_data_prepare(struct callback_data *p, sqlite3_stmt *pSql){
const char *zSql; /* The text of the SQL statement */
const char *z; /* Used to check if this is an EXPLAIN */
int *abYield = 0; /* True if op is an OP_Yield */
int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
int iOp; /* Index of operation in p->aiIndent[] */
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext", 0 };
const char *azYield[] = { "Yield", "SeekLt", "SeekGt", "RowSetRead", "Rewind", 0 };
const char *azGoto[] = { "Goto", 0 };
/* Try to figure out if this is really an EXPLAIN statement. If this
** cannot be verified, return early. */
zSql = sqlite3_sql(pSql);
if( zSql==0 ) return;
for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
|
| ︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 |
p->aiIndent[iOp] = 0;
p->nIndent = iOp+1;
if( str_in_array(zOp, azNext) ){
for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
}
if( str_in_array(zOp, azGoto) && p2op<p->nIndent && abYield[p2op] ){
| | | 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 |
p->aiIndent[iOp] = 0;
p->nIndent = iOp+1;
if( str_in_array(zOp, azNext) ){
for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
}
if( str_in_array(zOp, azGoto) && p2op<p->nIndent && abYield[p2op] ){
for(i=p2op+1; i<iOp; i++) p->aiIndent[i] += 2;
}
}
p->iIndent = 0;
sqlite3_free(abYield);
sqlite3_reset(pSql);
}
|
| ︙ | ︙ | |||
3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 |
char *zErrMsg = 0;
struct callback_data data;
const char *zInitFile = 0;
char *zFirstCmd = 0;
int i;
int rc = 0;
if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
sqlite3_sourceid(), SQLITE_SOURCE_ID);
exit(1);
}
Argv0 = argv[0];
main_init(&data);
stdin_is_interactive = isatty(0);
/* Make sure we have a valid signal handler early, before anything
** else is done.
*/
| > > | 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 |
char *zErrMsg = 0;
struct callback_data data;
const char *zInitFile = 0;
char *zFirstCmd = 0;
int i;
int rc = 0;
#if 0
if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
sqlite3_sourceid(), SQLITE_SOURCE_ID);
exit(1);
}
#endif
Argv0 = argv[0];
main_init(&data);
stdin_is_interactive = isatty(0);
/* Make sure we have a valid signal handler early, before anything
** else is done.
*/
|
| ︙ | ︙ |
Changes to src/sqlcmd.c.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | ** ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" #include "sqlcmd.h" #include <zlib.h> /* ** Implementation of the "content(X)" SQL function. Return the complete ** content of artifact identified by X as a blob. */ |
| ︙ | ︙ | |||
153 154 155 156 157 158 159 |
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
*pzRepoName = g.zRepositoryName;
}
| < < | 152 153 154 155 156 157 158 |
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
*pzRepoName = g.zRepositoryName;
}
|
Changes to src/sqlite3.c.
1 2 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite | | | 1 2 3 4 5 6 7 8 9 10 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.8.3.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% or more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other |
| ︙ | ︙ | |||
131 132 133 134 135 136 137 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.8.3.1" #define SQLITE_VERSION_NUMBER 3008003 #define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 | #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** | > | 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 | #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ #define SQLITE_RECURSIVE 33 /* NULL NULL */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** |
| ︙ | ︙ | |||
8038 8039 8040 8041 8042 8043 8044 | #endif /* _SQLITE_HASH_H_ */ /************** End of hash.h ************************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include parse.h in the middle of sqliteInt.h *****************/ /************** Begin file parse.h *******************************************/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < | > > > > > > > > > > > | | | < | | | | | | | | | | | | | | | | | | | | | | | | > | 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 | #endif /* _SQLITE_HASH_H_ */ /************** End of hash.h ************************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /************** Include parse.h in the middle of sqliteInt.h *****************/ /************** Begin file parse.h *******************************************/ #define TK_SEMI 1 #define TK_EXPLAIN 2 #define TK_QUERY 3 #define TK_PLAN 4 #define TK_BEGIN 5 #define TK_TRANSACTION 6 #define TK_DEFERRED 7 #define TK_IMMEDIATE 8 #define TK_EXCLUSIVE 9 #define TK_COMMIT 10 #define TK_END 11 #define TK_ROLLBACK 12 #define TK_SAVEPOINT 13 #define TK_RELEASE 14 #define TK_TO 15 #define TK_TABLE 16 #define TK_CREATE 17 #define TK_IF 18 #define TK_NOT 19 #define TK_EXISTS 20 #define TK_TEMP 21 #define TK_LP 22 #define TK_RP 23 #define TK_AS 24 #define TK_WITHOUT 25 #define TK_COMMA 26 #define TK_ID 27 #define TK_INDEXED 28 #define TK_ABORT 29 #define TK_ACTION 30 #define TK_AFTER 31 #define TK_ANALYZE 32 #define TK_ASC 33 #define TK_ATTACH 34 #define TK_BEFORE 35 #define TK_BY 36 #define TK_CASCADE 37 #define TK_CAST 38 #define TK_COLUMNKW 39 #define TK_CONFLICT 40 #define TK_DATABASE 41 #define TK_DESC 42 #define TK_DETACH 43 #define TK_EACH 44 #define TK_FAIL 45 #define TK_FOR 46 #define TK_IGNORE 47 #define TK_INITIALLY 48 #define TK_INSTEAD 49 #define TK_LIKE_KW 50 #define TK_MATCH 51 #define TK_NO 52 #define TK_KEY 53 #define TK_OF 54 #define TK_OFFSET 55 #define TK_PRAGMA 56 #define TK_RAISE 57 #define TK_RECURSIVE 58 #define TK_REPLACE 59 #define TK_RESTRICT 60 #define TK_ROW 61 #define TK_TRIGGER 62 #define TK_VACUUM 63 #define TK_VIEW 64 #define TK_VIRTUAL 65 #define TK_WITH 66 #define TK_REINDEX 67 #define TK_RENAME 68 #define TK_CTIME_KW 69 #define TK_ANY 70 #define TK_OR 71 #define TK_AND 72 #define TK_IS 73 #define TK_BETWEEN 74 #define TK_IN 75 #define TK_ISNULL 76 #define TK_NOTNULL 77 #define TK_NE 78 #define TK_EQ 79 #define TK_GT 80 #define TK_LE 81 #define TK_LT 82 #define TK_GE 83 #define TK_ESCAPE 84 #define TK_BITAND 85 #define TK_BITOR 86 #define TK_LSHIFT 87 #define TK_RSHIFT 88 #define TK_PLUS 89 #define TK_MINUS 90 #define TK_STAR 91 #define TK_SLASH 92 #define TK_REM 93 #define TK_CONCAT 94 #define TK_COLLATE 95 #define TK_BITNOT 96 #define TK_STRING 97 #define TK_JOIN_KW 98 #define TK_CONSTRAINT 99 #define TK_DEFAULT 100 #define TK_NULL 101 #define TK_PRIMARY 102 #define TK_UNIQUE 103 #define TK_CHECK 104 #define TK_REFERENCES 105 #define TK_AUTOINCR 106 #define TK_ON 107 #define TK_INSERT 108 #define TK_DELETE 109 #define TK_UPDATE 110 #define TK_SET 111 #define TK_DEFERRABLE 112 #define TK_FOREIGN 113 #define TK_DROP 114 #define TK_UNION 115 #define TK_ALL 116 #define TK_EXCEPT 117 #define TK_INTERSECT 118 #define TK_SELECT 119 #define TK_VALUES 120 #define TK_DISTINCT 121 #define TK_DOT 122 #define TK_FROM 123 #define TK_JOIN 124 #define TK_USING 125 #define TK_ORDER 126 #define TK_GROUP 127 #define TK_HAVING 128 #define TK_LIMIT 129 #define TK_WHERE 130 #define TK_INTO 131 #define TK_INTEGER 132 #define TK_FLOAT 133 #define TK_BLOB 134 #define TK_VARIABLE 135 #define TK_CASE 136 #define TK_WHEN 137 #define TK_THEN 138 #define TK_ELSE 139 #define TK_INDEX 140 #define TK_ALTER 141 #define TK_ADD 142 #define TK_TO_TEXT 143 #define TK_TO_BLOB 144 #define TK_TO_NUMERIC 145 #define TK_TO_INT 146 #define TK_TO_REAL 147 #define TK_ISNOT 148 #define TK_END_OF_FILE 149 #define TK_ILLEGAL 150 #define TK_SPACE 151 #define TK_UNCLOSED_STRING 152 #define TK_FUNCTION 153 #define TK_COLUMN 154 #define TK_AGG_FUNCTION 155 #define TK_AGG_COLUMN 156 #define TK_UMINUS 157 #define TK_UPLUS 158 #define TK_REGISTER 159 /************** End of parse.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> |
| ︙ | ︙ | |||
8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 | typedef struct TriggerPrg TriggerPrg; typedef struct TriggerStep TriggerStep; typedef struct UnpackedRecord UnpackedRecord; typedef struct VTable VTable; typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WhereInfo WhereInfo; /* ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque ** pointer types (i.e. FuncDef) defined above. */ /************** Include btree.h in the middle of sqliteInt.h *****************/ | > | 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 | typedef struct TriggerPrg TriggerPrg; typedef struct TriggerStep TriggerStep; typedef struct UnpackedRecord UnpackedRecord; typedef struct VTable VTable; typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WhereInfo WhereInfo; typedef struct With With; /* ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque ** pointer types (i.e. FuncDef) defined above. */ /************** Include btree.h in the middle of sqliteInt.h *****************/ |
| ︙ | ︙ | |||
9137 9138 9139 9140 9141 9142 9143 | #define OP_NoConflict 62 /* synopsis: key=r[P3@P4] */ #define OP_NotFound 63 /* synopsis: key=r[P3@P4] */ #define OP_Found 64 /* synopsis: key=r[P3@P4] */ #define OP_NotExists 65 /* synopsis: intkey=r[P3] */ #define OP_Sequence 66 /* synopsis: r[P2]=rowid */ #define OP_NewRowid 67 /* synopsis: r[P2]=rowid */ #define OP_Insert 68 /* synopsis: intkey=r[P3] data=r[P2] */ | < < | | > > > > | | | | | | | | | | | | | | | | | | | | | | < < | 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 | #define OP_NoConflict 62 /* synopsis: key=r[P3@P4] */ #define OP_NotFound 63 /* synopsis: key=r[P3@P4] */ #define OP_Found 64 /* synopsis: key=r[P3@P4] */ #define OP_NotExists 65 /* synopsis: intkey=r[P3] */ #define OP_Sequence 66 /* synopsis: r[P2]=rowid */ #define OP_NewRowid 67 /* synopsis: r[P2]=rowid */ #define OP_Insert 68 /* synopsis: intkey=r[P3] data=r[P2] */ #define OP_InsertInt 69 /* synopsis: intkey=P3 data=r[P2] */ #define OP_Delete 70 #define OP_Or 71 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ #define OP_And 72 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ #define OP_ResetCount 73 #define OP_SorterCompare 74 /* synopsis: if key(P1)!=rtrim(r[P3],P4) goto P2 */ #define OP_SorterData 75 /* synopsis: r[P2]=data */ #define OP_IsNull 76 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ #define OP_NotNull 77 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ #define OP_Ne 78 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */ #define OP_Eq 79 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */ #define OP_Gt 80 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */ #define OP_Le 81 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */ #define OP_Lt 82 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */ #define OP_Ge 83 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */ #define OP_RowKey 84 /* synopsis: r[P2]=key */ #define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ #define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ #define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ #define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ #define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ #define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ #define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ #define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ #define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ #define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ #define OP_RowData 95 /* synopsis: r[P2]=data */ #define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ #define OP_Rowid 98 /* synopsis: r[P2]=rowid */ #define OP_NullRow 99 #define OP_Last 100 #define OP_SorterSort 101 #define OP_Sort 102 #define OP_Rewind 103 #define OP_SorterInsert 104 |
| ︙ | ︙ | |||
9199 9200 9201 9202 9203 9204 9205 | #define OP_Param 124 #define OP_FkCounter 125 /* synopsis: fkctr[P1]+=P2 */ #define OP_FkIfZero 126 /* synopsis: if fkctr[P1]==0 goto P2 */ #define OP_MemMax 127 /* synopsis: r[P1]=max(r[P1],r[P2]) */ #define OP_IfPos 128 /* synopsis: if r[P1]>0 goto P2 */ #define OP_IfNeg 129 /* synopsis: if r[P1]<0 goto P2 */ #define OP_IfZero 130 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ | < | | > > | | | | | < | 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 | #define OP_Param 124 #define OP_FkCounter 125 /* synopsis: fkctr[P1]+=P2 */ #define OP_FkIfZero 126 /* synopsis: if fkctr[P1]==0 goto P2 */ #define OP_MemMax 127 /* synopsis: r[P1]=max(r[P1],r[P2]) */ #define OP_IfPos 128 /* synopsis: if r[P1]>0 goto P2 */ #define OP_IfNeg 129 /* synopsis: if r[P1]<0 goto P2 */ #define OP_IfZero 130 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ #define OP_AggFinal 131 /* synopsis: accum=r[P1] N=P2 */ #define OP_IncrVacuum 132 #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ #define OP_Expire 134 #define OP_TableLock 135 /* synopsis: iDb=P1 root=P2 write=P3 */ #define OP_VBegin 136 #define OP_VCreate 137 #define OP_VDestroy 138 #define OP_VOpen 139 #define OP_VColumn 140 /* synopsis: r[P3]=vcolumn(P2) */ #define OP_VNext 141 #define OP_VRename 142 #define OP_ToText 143 /* same as TK_TO_TEXT */ #define OP_ToBlob 144 /* same as TK_TO_BLOB */ #define OP_ToNumeric 145 /* same as TK_TO_NUMERIC */ #define OP_ToInt 146 /* same as TK_TO_INT */ #define OP_ToReal 147 /* same as TK_TO_REAL */ #define OP_Pagecount 148 #define OP_MaxPgcnt 149 #define OP_Trace 150 #define OP_Noop 151 #define OP_Explain 152 |
| ︙ | ︙ | |||
9243 9244 9245 9246 9247 9248 9249 | /* 8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\ /* 16 */ 0x01, 0x01, 0x04, 0x24, 0x04, 0x10, 0x00, 0x02,\ /* 24 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x20,\ /* 32 */ 0x00, 0x00, 0x04, 0x05, 0x04, 0x00, 0x00, 0x01,\ /* 40 */ 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x02,\ /* 48 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 56 */ 0x00, 0x11, 0x11, 0x11, 0x11, 0x08, 0x11, 0x11,\ | | | | | | | | | | 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 | /* 8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\ /* 16 */ 0x01, 0x01, 0x04, 0x24, 0x04, 0x10, 0x00, 0x02,\ /* 24 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x20,\ /* 32 */ 0x00, 0x00, 0x04, 0x05, 0x04, 0x00, 0x00, 0x01,\ /* 40 */ 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x02,\ /* 48 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 56 */ 0x00, 0x11, 0x11, 0x11, 0x11, 0x08, 0x11, 0x11,\ /* 64 */ 0x11, 0x11, 0x02, 0x02, 0x00, 0x00, 0x00, 0x4c,\ /* 72 */ 0x4c, 0x00, 0x00, 0x00, 0x05, 0x05, 0x15, 0x15,\ /* 80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\ /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\ /* 96 */ 0x24, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01,\ /* 104 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\ /* 112 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 120 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\ /* 128 */ 0x05, 0x05, 0x05, 0x00, 0x01, 0x02, 0x00, 0x00,\ /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,\ /* 144 */ 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x00, 0x00,\ /* 152 */ 0x00,} /************** End of opcodes.h *********************************************/ /************** Continuing where we left off in vdbe.h ***********************/ /* ** Prototypes for the VDBE interface. See comments on the implementation |
| ︙ | ︙ | |||
9278 9279 9280 9281 9282 9283 9284 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr); | | | 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr); SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); |
| ︙ | ︙ | |||
10744 10745 10746 10747 10748 10749 10750 | #endif Trigger *pTrigger; /* List of triggers stored in pSchema */ Schema *pSchema; /* Schema that contains this table */ Table *pNextZombie; /* Next on the Parse.pZombieTab list */ }; /* | | | 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 | #endif Trigger *pTrigger; /* List of triggers stored in pSchema */ Schema *pSchema; /* Schema that contains this table */ Table *pNextZombie; /* Next on the Parse.pZombieTab list */ }; /* ** Allowed values for Table.tabFlags. */ #define TF_Readonly 0x01 /* Read-only system table */ #define TF_Ephemeral 0x02 /* An ephemeral table */ #define TF_HasPrimaryKey 0x04 /* Table has a primary key */ #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ #define TF_Virtual 0x10 /* Is a virtual table */ #define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */ |
| ︙ | ︙ | |||
11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 | */ #define BMS ((int)(sizeof(Bitmask)*8)) /* ** A bit in a Bitmask */ #define MASKBIT(n) (((Bitmask)1)<<(n)) /* ** The following structure describes the FROM clause of a SELECT statement. ** Each table or subquery in the FROM clause is a separate element of ** the SrcList.a[] array. ** ** With the addition of multiple database support, the following structure | > | 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 | */ #define BMS ((int)(sizeof(Bitmask)*8)) /* ** A bit in a Bitmask */ #define MASKBIT(n) (((Bitmask)1)<<(n)) #define MASKBIT32(n) (((unsigned int)1)<<(n)) /* ** The following structure describes the FROM clause of a SELECT statement. ** Each table or subquery in the FROM clause is a separate element of ** the SrcList.a[] array. ** ** With the addition of multiple database support, the following structure |
| ︙ | ︙ | |||
11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 |
Select *pSelect; /* A SELECT statement used in place of a table name */
int addrFillSub; /* Address of subroutine to manifest a subquery */
int regReturn; /* Register holding return address of addrFillSub */
u8 jointype; /* Type of join between this able and the previous */
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
unsigned isCorrelated :1; /* True if sub-query is correlated */
unsigned viaCoroutine :1; /* Implemented as a co-routine */
#ifndef SQLITE_OMIT_EXPLAIN
u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
#endif
int iCursor; /* The VDBE cursor number used to access this table */
Expr *pOn; /* The ON clause of a join */
IdList *pUsing; /* The USING clause of a join */
Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
| > | 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 |
Select *pSelect; /* A SELECT statement used in place of a table name */
int addrFillSub; /* Address of subroutine to manifest a subquery */
int regReturn; /* Register holding return address of addrFillSub */
u8 jointype; /* Type of join between this able and the previous */
unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */
unsigned isCorrelated :1; /* True if sub-query is correlated */
unsigned viaCoroutine :1; /* Implemented as a co-routine */
unsigned isRecursive :1; /* True for recursive reference in WITH */
#ifndef SQLITE_OMIT_EXPLAIN
u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */
#endif
int iCursor; /* The VDBE cursor number used to access this table */
Expr *pOn; /* The ON clause of a join */
IdList *pUsing; /* The USING clause of a join */
Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */
|
| ︙ | ︙ | |||
11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 | Expr *pHaving; /* The HAVING clause */ ExprList *pOrderBy; /* The ORDER BY clause */ Select *pPrior; /* Prior select in a compound select statement */ Select *pNext; /* Next select to the left in a compound */ Select *pRightmost; /* Right-most select in a compound select statement */ Expr *pLimit; /* LIMIT expression. NULL means not used. */ Expr *pOffset; /* OFFSET expression. NULL means not used. */ }; /* ** Allowed values for Select.selFlags. The "SF" prefix stands for ** "Select Flag". */ #define SF_Distinct 0x0001 /* Output should be DISTINCT */ #define SF_Resolved 0x0002 /* Identifiers have been resolved */ #define SF_Aggregate 0x0004 /* Contains aggregate functions */ #define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */ #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ #define SF_UseSorter 0x0040 /* Sort using a sorter */ #define SF_Values 0x0080 /* Synthesized from VALUES clause */ #define SF_Materialize 0x0100 /* Force materialization of views */ #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */ /* | > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < | | > > > > | | | | | > | 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 |
Expr *pHaving; /* The HAVING clause */
ExprList *pOrderBy; /* The ORDER BY clause */
Select *pPrior; /* Prior select in a compound select statement */
Select *pNext; /* Next select to the left in a compound */
Select *pRightmost; /* Right-most select in a compound select statement */
Expr *pLimit; /* LIMIT expression. NULL means not used. */
Expr *pOffset; /* OFFSET expression. NULL means not used. */
With *pWith; /* WITH clause attached to this select. Or NULL. */
};
/*
** Allowed values for Select.selFlags. The "SF" prefix stands for
** "Select Flag".
*/
#define SF_Distinct 0x0001 /* Output should be DISTINCT */
#define SF_Resolved 0x0002 /* Identifiers have been resolved */
#define SF_Aggregate 0x0004 /* Contains aggregate functions */
#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
#define SF_UseSorter 0x0040 /* Sort using a sorter */
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
#define SF_Materialize 0x0100 /* Force materialization of views */
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
#define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
/*
** The results of a SELECT can be distributed in several ways, as defined
** by one of the following macros. The "SRT" prefix means "SELECT Result
** Type".
**
** SRT_Union Store results as a key in a temporary index
** identified by pDest->iSDParm.
**
** SRT_Except Remove results from the temporary index pDest->iSDParm.
**
** SRT_Exists Store a 1 in memory cell pDest->iSDParm if the result
** set is not empty.
**
** SRT_Discard Throw the results away. This is used by SELECT
** statements within triggers whose only purpose is
** the side-effects of functions.
**
** All of the above are free to ignore their ORDER BY clause. Those that
** follow must honor the ORDER BY clause.
**
** SRT_Output Generate a row of output (using the OP_ResultRow
** opcode) for each row in the result set.
**
** SRT_Mem Only valid if the result is a single column.
** Store the first column of the first result row
** in register pDest->iSDParm then abandon the rest
** of the query. This destination implies "LIMIT 1".
**
** SRT_Set The result must be a single column. Store each
** row of result as the key in table pDest->iSDParm.
** Apply the affinity pDest->affSdst before storing
** results. Used to implement "IN (SELECT ...)".
**
** SRT_EphemTab Create an temporary table pDest->iSDParm and store
** the result there. The cursor is left open after
** returning. This is like SRT_Table except that
** this destination uses OP_OpenEphemeral to create
** the table first.
**
** SRT_Coroutine Generate a co-routine that returns a new row of
** results each time it is invoked. The entry point
** of the co-routine is stored in register pDest->iSDParm
** and the result row is stored in pDest->nDest registers
** starting with pDest->iSdst.
**
** SRT_Table Store results in temporary table pDest->iSDParm.
** This is like SRT_EphemTab except that the table
** is assumed to already be open.
**
** SRT_DistTable Store results in a temporary table pDest->iSDParm.
** But also use temporary table pDest->iSDParm+1 as
** a record of all prior results and ignore any duplicate
** rows. Name means: "Distinct Table".
**
** SRT_Queue Store results in priority queue pDest->iSDParm (really
** an index). Append a sequence number so that all entries
** are distinct.
**
** SRT_DistQueue Store results in priority queue pDest->iSDParm only if
** the same record has never been stored before. The
** index at pDest->iSDParm+1 hold all prior stores.
*/
#define SRT_Union 1 /* Store result as keys in an index */
#define SRT_Except 2 /* Remove result from a UNION index */
#define SRT_Exists 3 /* Store 1 if the result is not empty */
#define SRT_Discard 4 /* Do not save the results anywhere */
/* The ORDER BY clause is ignored for all of the above */
#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard)
#define SRT_Output 5 /* Output each row of result */
#define SRT_Mem 6 /* Store result in a memory cell */
#define SRT_Set 7 /* Store results as keys in an index */
#define SRT_EphemTab 8 /* Create transient tab and store like SRT_Table */
#define SRT_Coroutine 9 /* Generate a single row of result */
#define SRT_Table 10 /* Store result as data with an automatic rowid */
#define SRT_DistTable 11 /* Like SRT_Table, but unique results only */
#define SRT_Queue 12 /* Store result in an queue */
#define SRT_DistQueue 13 /* Like SRT_Queue, but unique results only */
/*
** An instance of this object describes where to put of the results of
** a SELECT statement.
*/
struct SelectDest {
u8 eDest; /* How to dispose of the results. On of SRT_* above. */
char affSdst; /* Affinity used when eDest==SRT_Set */
int iSDParm; /* A parameter used by the eDest disposal method */
int iSdst; /* Base register where results are written */
int nSdst; /* Number of registers allocated */
ExprList *pOrderBy; /* Key columns for SRT_Queue and SRT_DistQueue */
};
/*
** During code generation of statements that do inserts into AUTOINCREMENT
** tables, the following information is attached to the Table.u.autoInc.p
** pointer of each autoincrement table to record some side information that
** the code generator needs. We have to keep per-table autoincrement
|
| ︙ | ︙ | |||
11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 |
int nTab; /* Number of previously allocated VDBE cursors */
int nMem; /* Number of memory cells used so far */
int nSet; /* Number of sets used so far */
int nOnce; /* Number of OP_Once instructions so far */
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
int nLabel; /* Number of labels used */
int *aLabel; /* Space to hold the labels */
int ckBase; /* Base register of data during check constraints */
int iPartIdxTab; /* Table corresponding to a partial index */
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
struct yColCache {
int iTable; /* Table cursor number */
int iColumn; /* Table column number */
| > | 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 |
int nTab; /* Number of previously allocated VDBE cursors */
int nMem; /* Number of memory cells used so far */
int nSet; /* Number of sets used so far */
int nOnce; /* Number of OP_Once instructions so far */
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
int nLabel; /* Number of labels used */
int *aLabel; /* Space to hold the labels */
int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */
int ckBase; /* Base register of data during check constraints */
int iPartIdxTab; /* Table corresponding to a partial index */
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
struct yColCache {
int iTable; /* Table cursor number */
int iColumn; /* Table column number */
|
| ︙ | ︙ | |||
11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 | Token sLastToken; /* The last token parsed */ #ifndef SQLITE_OMIT_VIRTUALTABLE Token sArg; /* Complete text of a module argument */ Table **apVtabLock; /* Pointer to virtual tables needing locking */ #endif Table *pZombieTab; /* List of Table objects to delete after code gen */ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ }; /* ** Return true if currently inside an sqlite3_declare_vtab() call. */ #ifdef SQLITE_OMIT_VIRTUALTABLE #define IN_DECLARE_VTAB 0 | > > | 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 | Token sLastToken; /* The last token parsed */ #ifndef SQLITE_OMIT_VIRTUALTABLE Token sArg; /* Complete text of a module argument */ Table **apVtabLock; /* Pointer to virtual tables needing locking */ #endif Table *pZombieTab; /* List of Table objects to delete after code gen */ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ With *pWith; /* Current WITH clause, or NULL */ u8 bFreeWith; /* True if pWith should be freed with parser */ }; /* ** Return true if currently inside an sqlite3_declare_vtab() call. */ #ifdef SQLITE_OMIT_VIRTUALTABLE #define IN_DECLARE_VTAB 0 |
| ︙ | ︙ | |||
11798 11799 11800 11801 11802 11803 11804 |
struct TriggerStep {
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
u8 orconf; /* OE_Rollback etc. */
Trigger *pTrig; /* The trigger that this step is a part of */
Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
Token target; /* Target table for DELETE, UPDATE, INSERT */
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
| | | 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 |
struct TriggerStep {
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
u8 orconf; /* OE_Rollback etc. */
Trigger *pTrig; /* The trigger that this step is a part of */
Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
Token target; /* Target table for DELETE, UPDATE, INSERT */
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
ExprList *pExprList; /* SET clause for UPDATE. */
IdList *pIdList; /* Column names for INSERT */
TriggerStep *pNext; /* Next in the link-list */
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
};
/*
** The following structure contains information used by the sqliteFix...
|
| ︙ | ︙ | |||
11920 11921 11922 11923 11924 11925 11926 11927 11928 |
/*
** Context pointer passed down through the tree-walk.
*/
struct Walker {
int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
Parse *pParse; /* Parser context. */
int walkerDepth; /* Number of subqueries */
| > < | 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 |
/*
** Context pointer passed down through the tree-walk.
*/
struct Walker {
int (*xExprCallback)(Walker*, Expr*); /* Callback for expressions */
int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
Parse *pParse; /* Parser context. */
int walkerDepth; /* Number of subqueries */
union { /* Extra data for callback */
NameContext *pNC; /* Naming context */
int i; /* Integer value */
SrcList *pSrcList; /* FROM clause */
struct SrcCount *pSrcCount; /* Counting column references */
} u;
};
|
| ︙ | ︙ | |||
11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 |
/*
** Return code from the parse-tree walking primitives and their
** callbacks.
*/
#define WRC_Continue 0 /* Continue down into children */
#define WRC_Prune 1 /* Omit children but continue walking siblings */
#define WRC_Abort 2 /* Abandon the tree walk */
/*
** Assuming zIn points to the first byte of a UTF-8 character,
** advance zIn to point to the first byte of the next UTF-8 character.
*/
#define SQLITE_SKIP_UTF8(zIn) { \
if( (*(zIn++))>=0xc0 ){ \
| > > > > > > > > > > > > > > > | 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 |
/*
** Return code from the parse-tree walking primitives and their
** callbacks.
*/
#define WRC_Continue 0 /* Continue down into children */
#define WRC_Prune 1 /* Omit children but continue walking siblings */
#define WRC_Abort 2 /* Abandon the tree walk */
/*
** An instance of this structure represents a set of one or more CTEs
** (common table expressions) created by a single WITH clause.
*/
struct With {
int nCte; /* Number of CTEs in the WITH clause */
With *pOuter; /* Containing WITH clause, or NULL */
struct Cte { /* For each CTE in the WITH clause.... */
char *zName; /* Name of this CTE */
ExprList *pCols; /* List of explicit column names, or NULL */
Select *pSelect; /* The definition of this CTE */
const char *zErr; /* Error message for circular references */
} a[1];
};
/*
** Assuming zIn points to the first byte of a UTF-8 character,
** advance zIn to point to the first byte of the next UTF-8 character.
*/
#define SQLITE_SKIP_UTF8(zIn) { \
if( (*(zIn++))>=0xc0 ){ \
|
| ︙ | ︙ | |||
12213 12214 12215 12216 12217 12218 12219 | SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); #else # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif SQLITE_PRIVATE int sqlite3CodeCoroutine(Parse*, Select*, SelectDest*); | | | 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 |
SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse);
SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse);
#else
# define sqlite3AutoincrementBegin(X)
# define sqlite3AutoincrementEnd(X)
#endif
SQLITE_PRIVATE int sqlite3CodeCoroutine(Parse*, Select*, SelectDest*);
SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
Token*, Select*, Expr*, IdList*);
|
| ︙ | ︙ | |||
12307 12308 12309 12310 12311 12312 12313 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); SQLITE_PRIVATE int sqlite3IsRowid(const char*); SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8); SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*); | | | 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 |
SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8);
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*);
SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
u8,u8,int,int*);
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, u8*, int*, int*);
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
SQLITE_PRIVATE void sqlite3MultiWrite(Parse*);
SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
|
| ︙ | ︙ | |||
12351 12352 12353 12354 12355 12356 12357 |
SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
int, int, int);
SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
| | | 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 |
SQLITE_PRIVATE void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,
int, int, int);
SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
Select*,u8);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
#else
|
| ︙ | ︙ | |||
12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 | SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*); SQLITE_PRIVATE const char *sqlite3JournalModename(int); #ifndef SQLITE_OMIT_WAL SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); #endif /* Declarations for functions in fkey.c. All of these are replaced by ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign ** key functionality is available. If OMIT_TRIGGER is defined but ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In ** this case foreign keys are parsed, but no other functionality is ** provided (enforcement of FK constraints requires the triggers sub-system). | > > > > > > > > | 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 | SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*); SQLITE_PRIVATE const char *sqlite3JournalModename(int); #ifndef SQLITE_OMIT_WAL SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); #endif #ifndef SQLITE_OMIT_CTE SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*); SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); #else #define sqlite3WithPush(x,y,z) #define sqlite3WithDelete(x,y) #endif /* Declarations for functions in fkey.c. All of these are replaced by ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign ** key functionality is available. If OMIT_TRIGGER is defined but ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In ** this case foreign keys are parsed, but no other functionality is ** provided (enforcement of FK constraints requires the triggers sub-system). |
| ︙ | ︙ | |||
22508 22509 22510 22511 22512 22513 22514 |
}
/*
** Read or write a four-byte big-endian integer value.
*/
SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
| > | | 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 |
}
/*
** Read or write a four-byte big-endian integer value.
*/
SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
testcase( p[0]&0x80 );
return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
}
SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
p[0] = (u8)(v>>24);
p[1] = (u8)(v>>16);
p[2] = (u8)(v>>8);
p[3] = (u8)v;
}
|
| ︙ | ︙ | |||
22849 22850 22851 22852 22853 22854 22855 |
pH->count = 0;
}
/*
** The hashing function.
*/
static unsigned int strHash(const char *z, int nKey){
| | | 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 |
pH->count = 0;
}
/*
** The hashing function.
*/
static unsigned int strHash(const char *z, int nKey){
unsigned int h = 0;
assert( nKey>=0 );
while( nKey > 0 ){
h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
nKey--;
}
return h;
}
|
| ︙ | ︙ | |||
23156 23157 23158 23159 23160 23161 23162 |
/* 62 */ "NoConflict" OpHelp("key=r[P3@P4]"),
/* 63 */ "NotFound" OpHelp("key=r[P3@P4]"),
/* 64 */ "Found" OpHelp("key=r[P3@P4]"),
/* 65 */ "NotExists" OpHelp("intkey=r[P3]"),
/* 66 */ "Sequence" OpHelp("r[P2]=rowid"),
/* 67 */ "NewRowid" OpHelp("r[P2]=rowid"),
/* 68 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
| > > | | < < > > | | | | | | | | | | | | | | | | | | | | | | < < | 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 |
/* 62 */ "NoConflict" OpHelp("key=r[P3@P4]"),
/* 63 */ "NotFound" OpHelp("key=r[P3@P4]"),
/* 64 */ "Found" OpHelp("key=r[P3@P4]"),
/* 65 */ "NotExists" OpHelp("intkey=r[P3]"),
/* 66 */ "Sequence" OpHelp("r[P2]=rowid"),
/* 67 */ "NewRowid" OpHelp("r[P2]=rowid"),
/* 68 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
/* 69 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
/* 70 */ "Delete" OpHelp(""),
/* 71 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
/* 72 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
/* 73 */ "ResetCount" OpHelp(""),
/* 74 */ "SorterCompare" OpHelp("if key(P1)!=rtrim(r[P3],P4) goto P2"),
/* 75 */ "SorterData" OpHelp("r[P2]=data"),
/* 76 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
/* 77 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
/* 78 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"),
/* 79 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"),
/* 80 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"),
/* 81 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"),
/* 82 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"),
/* 83 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"),
/* 84 */ "RowKey" OpHelp("r[P2]=key"),
/* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
/* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
/* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
/* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
/* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
/* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
/* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
/* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
/* 95 */ "RowData" OpHelp("r[P2]=data"),
/* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
/* 98 */ "Rowid" OpHelp("r[P2]=rowid"),
/* 99 */ "NullRow" OpHelp(""),
/* 100 */ "Last" OpHelp(""),
/* 101 */ "SorterSort" OpHelp(""),
/* 102 */ "Sort" OpHelp(""),
/* 103 */ "Rewind" OpHelp(""),
/* 104 */ "SorterInsert" OpHelp(""),
|
| ︙ | ︙ | |||
23218 23219 23220 23221 23222 23223 23224 |
/* 124 */ "Param" OpHelp(""),
/* 125 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
/* 126 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
/* 127 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 128 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
/* 129 */ "IfNeg" OpHelp("if r[P1]<0 goto P2"),
/* 130 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"),
| < | | > > | | | | | < | 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 |
/* 124 */ "Param" OpHelp(""),
/* 125 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
/* 126 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
/* 127 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 128 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
/* 129 */ "IfNeg" OpHelp("if r[P1]<0 goto P2"),
/* 130 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"),
/* 131 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
/* 132 */ "IncrVacuum" OpHelp(""),
/* 133 */ "Real" OpHelp("r[P2]=P4"),
/* 134 */ "Expire" OpHelp(""),
/* 135 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
/* 136 */ "VBegin" OpHelp(""),
/* 137 */ "VCreate" OpHelp(""),
/* 138 */ "VDestroy" OpHelp(""),
/* 139 */ "VOpen" OpHelp(""),
/* 140 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
/* 141 */ "VNext" OpHelp(""),
/* 142 */ "VRename" OpHelp(""),
/* 143 */ "ToText" OpHelp(""),
/* 144 */ "ToBlob" OpHelp(""),
/* 145 */ "ToNumeric" OpHelp(""),
/* 146 */ "ToInt" OpHelp(""),
/* 147 */ "ToReal" OpHelp(""),
/* 148 */ "Pagecount" OpHelp(""),
/* 149 */ "MaxPgcnt" OpHelp(""),
/* 150 */ "Trace" OpHelp(""),
/* 151 */ "Noop" OpHelp(""),
/* 152 */ "Explain" OpHelp(""),
};
return azName[i];
|
| ︙ | ︙ | |||
27553 27554 27555 27556 27557 27558 27559 |
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
}
/* Update the global lock state and do debug tracing */
#ifdef SQLITE_DEBUG
{ u16 mask;
OSTRACE(("SHM-LOCK "));
| | | 27650 27651 27652 27653 27654 27655 27656 27657 27658 27659 27660 27661 27662 27663 27664 |
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
}
/* Update the global lock state and do debug tracing */
#ifdef SQLITE_DEBUG
{ u16 mask;
OSTRACE(("SHM-LOCK "));
mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);
if( rc==SQLITE_OK ){
if( lockType==F_UNLCK ){
OSTRACE(("unlock %d ok", ofst));
pShmNode->exclMask &= ~mask;
pShmNode->sharedMask &= ~mask;
}else if( lockType==F_RDLCK ){
OSTRACE(("read-lock %d ok", ofst));
|
| ︙ | ︙ | |||
28304 28305 28306 28307 28308 28309 28310 28311 28312 28313 |
** argument that was passed to the unixFetch() invocation.
**
** Or, if the third argument is NULL, then this function is being called
** to inform the VFS layer that, according to POSIX, any existing mapping
** may now be invalid and should be unmapped.
*/
static int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){
unixFile *pFd = (unixFile *)fd; /* The underlying database file */
UNUSED_PARAMETER(iOff);
| > < > > > > | 28401 28402 28403 28404 28405 28406 28407 28408 28409 28410 28411 28412 28413 28414 28415 28416 28417 28418 28419 28420 28421 28422 28423 28424 28425 28426 28427 28428 28429 28430 28431 28432 28433 28434 28435 28436 28437 |
** argument that was passed to the unixFetch() invocation.
**
** Or, if the third argument is NULL, then this function is being called
** to inform the VFS layer that, according to POSIX, any existing mapping
** may now be invalid and should be unmapped.
*/
static int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){
#if SQLITE_MAX_MMAP_SIZE>0
unixFile *pFd = (unixFile *)fd; /* The underlying database file */
UNUSED_PARAMETER(iOff);
/* If p==0 (unmap the entire file) then there must be no outstanding
** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
** then there must be at least one outstanding. */
assert( (p==0)==(pFd->nFetchOut==0) );
/* If p!=0, it must match the iOff value. */
assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );
if( p ){
pFd->nFetchOut--;
}else{
unixUnmapfile(pFd);
}
assert( pFd->nFetchOut>=0 );
#else
UNUSED_PARAMETER(fd);
UNUSED_PARAMETER(p);
UNUSED_PARAMETER(iOff);
#endif
return SQLITE_OK;
}
/*
** Here ends the implementation of all sqlite3_file methods.
**
|
| ︙ | ︙ | |||
34364 34365 34366 34367 34368 34369 34370 |
*/
static void winShmEnterMutex(void){
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
static void winShmLeaveMutex(void){
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
| | | 34465 34466 34467 34468 34469 34470 34471 34472 34473 34474 34475 34476 34477 34478 34479 |
*/
static void winShmEnterMutex(void){
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
static void winShmLeaveMutex(void){
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
#ifndef NDEBUG
static int winShmMutexHeld(void) {
return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
#endif
/*
** Object used to represent a single file opened and mmapped to provide
|
| ︙ | ︙ | |||
38325 38326 38327 38328 38329 38330 38331 38332 38333 38334 38335 38336 38337 38338 |
int createFlag
){
unsigned int nPinned;
PCache1 *pCache = (PCache1 *)p;
PGroup *pGroup;
PgHdr1 *pPage = 0;
assert( pCache->bPurgeable || createFlag!=1 );
assert( pCache->bPurgeable || pCache->nMin==0 );
assert( pCache->bPurgeable==0 || pCache->nMin==10 );
assert( pCache->nMin==0 || pCache->bPurgeable );
pcache1EnterMutex(pGroup = pCache->pGroup);
/* Step 1: Search the hash table for an existing entry. */
| > | 38426 38427 38428 38429 38430 38431 38432 38433 38434 38435 38436 38437 38438 38439 38440 |
int createFlag
){
unsigned int nPinned;
PCache1 *pCache = (PCache1 *)p;
PGroup *pGroup;
PgHdr1 *pPage = 0;
assert( offsetof(PgHdr1,page)==0 );
assert( pCache->bPurgeable || createFlag!=1 );
assert( pCache->bPurgeable || pCache->nMin==0 );
assert( pCache->bPurgeable==0 || pCache->nMin==10 );
assert( pCache->nMin==0 || pCache->bPurgeable );
pcache1EnterMutex(pGroup = pCache->pGroup);
/* Step 1: Search the hash table for an existing entry. */
|
| ︙ | ︙ | |||
38430 38431 38432 38433 38434 38435 38436 |
}
fetch_out:
if( pPage && iKey>pCache->iMaxKey ){
pCache->iMaxKey = iKey;
}
pcache1LeaveMutex(pGroup);
| | | 38532 38533 38534 38535 38536 38537 38538 38539 38540 38541 38542 38543 38544 38545 38546 |
}
fetch_out:
if( pPage && iKey>pCache->iMaxKey ){
pCache->iMaxKey = iKey;
}
pcache1LeaveMutex(pGroup);
return (sqlite3_pcache_page*)pPage;
}
/*
** Implementation of the sqlite3_pcache.xUnpin method.
**
** Mark a page as unpinned (eligible for asynchronous recycling).
|
| ︙ | ︙ | |||
40970 40971 40972 40973 40974 40975 40976 |
/*
** Find a page in the hash table given its page number. Return
** a pointer to the page or NULL if the requested page is not
** already in memory.
*/
static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){
| | | 41072 41073 41074 41075 41076 41077 41078 41079 41080 41081 41082 41083 41084 41085 41086 |
/*
** Find a page in the hash table given its page number. Return
** a pointer to the page or NULL if the requested page is not
** already in memory.
*/
static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){
PgHdr *p = 0; /* Return value */
/* It is not possible for a call to PcacheFetch() with createFlag==0 to
** fail, since no attempt to allocate dynamic memory will be made.
*/
(void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p);
return p;
}
|
| ︙ | ︙ | |||
54321 54322 54323 54324 54325 54326 54327 |
*/
#ifndef NDEBUG
static void assertCellInfo(BtCursor *pCur){
CellInfo info;
int iPage = pCur->iPage;
memset(&info, 0, sizeof(info));
btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info);
| | | 54423 54424 54425 54426 54427 54428 54429 54430 54431 54432 54433 54434 54435 54436 54437 |
*/
#ifndef NDEBUG
static void assertCellInfo(BtCursor *pCur){
CellInfo info;
int iPage = pCur->iPage;
memset(&info, 0, sizeof(info));
btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info);
assert( CORRUPT_DB || memcmp(&info, &pCur->info, sizeof(info))==0 );
}
#else
#define assertCellInfo(x)
#endif
#ifdef _MSC_VER
/* Use a real function in MSVC to work around bugs in that compiler. */
static void getCellInfo(BtCursor *pCur){
|
| ︙ | ︙ | |||
54957 54958 54959 54960 54961 54962 54963 |
rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
pCur->wrFlag==0 ? PAGER_GET_READONLY : 0);
if( rc!=SQLITE_OK ){
pCur->eState = CURSOR_INVALID;
return rc;
}
pCur->iPage = 0;
| | > > > | | | | > > > > > > | | | | < < < < < < < < < < < | 55059 55060 55061 55062 55063 55064 55065 55066 55067 55068 55069 55070 55071 55072 55073 55074 55075 55076 55077 55078 55079 55080 55081 55082 55083 55084 55085 55086 55087 55088 55089 55090 |
rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
pCur->wrFlag==0 ? PAGER_GET_READONLY : 0);
if( rc!=SQLITE_OK ){
pCur->eState = CURSOR_INVALID;
return rc;
}
pCur->iPage = 0;
}
pRoot = pCur->apPage[0];
assert( pRoot->pgno==pCur->pgnoRoot );
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
** NULL, the caller expects a table b-tree. If this is not the case,
** return an SQLITE_CORRUPT error.
**
** Earlier versions of SQLite assumed that this test could not fail
** if the root page was already loaded when this function was called (i.e.
** if pCur->iPage>=0). But this is not so if the database is corrupted
** in such a way that page pRoot is linked into a second b-tree table
** (or the freelist). */
assert( pRoot->intKey==1 || pRoot->intKey==0 );
if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
return SQLITE_CORRUPT_BKPT;
}
pCur->aiIdx[0] = 0;
pCur->info.nSize = 0;
pCur->atLast = 0;
pCur->validNKey = 0;
if( pRoot->nCell>0 ){
|
| ︙ | ︙ | |||
55818 55819 55820 55821 55822 55823 55824 55825 55826 55827 55828 55829 55830 55831 |
end_allocate_page:
releasePage(pTrunk);
releasePage(pPrevTrunk);
if( rc==SQLITE_OK ){
if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){
releasePage(*ppPage);
return SQLITE_CORRUPT_BKPT;
}
(*ppPage)->isInit = 0;
}else{
*ppPage = 0;
}
assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
| > | 55918 55919 55920 55921 55922 55923 55924 55925 55926 55927 55928 55929 55930 55931 55932 |
end_allocate_page:
releasePage(pTrunk);
releasePage(pPrevTrunk);
if( rc==SQLITE_OK ){
if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){
releasePage(*ppPage);
*ppPage = 0;
return SQLITE_CORRUPT_BKPT;
}
(*ppPage)->isInit = 0;
}else{
*ppPage = 0;
}
assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
|
| ︙ | ︙ | |||
57917 57918 57919 57920 57921 57922 57923 57924 57925 57926 57927 57928 57929 57930 57931 57932 57933 57934 57935 57936 57937 57938 57939 57940 57941 |
int freePageFlag, /* Deallocate page if true */
int *pnChange /* Add number of Cells freed to this counter */
){
MemPage *pPage;
int rc;
unsigned char *pCell;
int i;
assert( sqlite3_mutex_held(pBt->mutex) );
if( pgno>btreePagecount(pBt) ){
return SQLITE_CORRUPT_BKPT;
}
rc = getAndInitPage(pBt, pgno, &pPage, 0);
if( rc ) return rc;
for(i=0; i<pPage->nCell; i++){
pCell = findCell(pPage, i);
if( !pPage->leaf ){
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
if( rc ) goto cleardatabasepage_out;
}
rc = clearCell(pPage, pCell);
if( rc ) goto cleardatabasepage_out;
}
if( !pPage->leaf ){
| > > | | | 58018 58019 58020 58021 58022 58023 58024 58025 58026 58027 58028 58029 58030 58031 58032 58033 58034 58035 58036 58037 58038 58039 58040 58041 58042 58043 58044 58045 58046 58047 58048 58049 58050 58051 58052 58053 58054 58055 58056 58057 58058 58059 58060 58061 |
int freePageFlag, /* Deallocate page if true */
int *pnChange /* Add number of Cells freed to this counter */
){
MemPage *pPage;
int rc;
unsigned char *pCell;
int i;
int hdr;
assert( sqlite3_mutex_held(pBt->mutex) );
if( pgno>btreePagecount(pBt) ){
return SQLITE_CORRUPT_BKPT;
}
rc = getAndInitPage(pBt, pgno, &pPage, 0);
if( rc ) return rc;
hdr = pPage->hdrOffset;
for(i=0; i<pPage->nCell; i++){
pCell = findCell(pPage, i);
if( !pPage->leaf ){
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
if( rc ) goto cleardatabasepage_out;
}
rc = clearCell(pPage, pCell);
if( rc ) goto cleardatabasepage_out;
}
if( !pPage->leaf ){
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
if( rc ) goto cleardatabasepage_out;
}else if( pnChange ){
assert( pPage->intKey );
*pnChange += pPage->nCell;
}
if( freePageFlag ){
freePage(pPage, &rc);
}else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);
}
cleardatabasepage_out:
releasePage(pPage);
return rc;
}
|
| ︙ | ︙ | |||
60396 60397 60398 60399 60400 60401 60402 | pMem->pScopyFrom = 0; } #endif /* SQLITE_DEBUG */ /* ** Size of struct Mem not including the Mem.zMalloc member. */ | | | 60499 60500 60501 60502 60503 60504 60505 60506 60507 60508 60509 60510 60511 60512 60513 | pMem->pScopyFrom = 0; } #endif /* SQLITE_DEBUG */ /* ** Size of struct Mem not including the Mem.zMalloc member. */ #define MEMCELLSIZE offsetof(Mem,zMalloc) /* ** Make an shallow copy of pFrom into pTo. Prior contents of ** pTo are freed. The pFrom->z field is not duplicated. If ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z ** and flags gets srcType (either MEM_Ephem or MEM_Static). */ |
| ︙ | ︙ | |||
61461 61462 61463 61464 61465 61466 61467 61468 61469 61470 61471 61472 61473 61474 |
Parse *p = v->pParse;
int j = -1-x;
assert( v->magic==VDBE_MAGIC_INIT );
assert( j<p->nLabel );
if( j>=0 && p->aLabel ){
p->aLabel[j] = v->nOp;
}
}
/*
** Mark the VDBE as one that can only be run one time.
*/
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
p->runOnlyOnce = 1;
| > | 61564 61565 61566 61567 61568 61569 61570 61571 61572 61573 61574 61575 61576 61577 61578 |
Parse *p = v->pParse;
int j = -1-x;
assert( v->magic==VDBE_MAGIC_INIT );
assert( j<p->nLabel );
if( j>=0 && p->aLabel ){
p->aLabel[j] = v->nOp;
}
p->iFixedOp = v->nOp - 1;
}
/*
** Mark the VDBE as one that can only be run one time.
*/
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
p->runOnlyOnce = 1;
|
| ︙ | ︙ | |||
61809 61810 61811 61812 61813 61814 61815 |
}
/*
** Change the P2 operand of instruction addr so that it points to
** the address of the next instruction to be coded.
*/
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
| | > | 61913 61914 61915 61916 61917 61918 61919 61920 61921 61922 61923 61924 61925 61926 61927 61928 |
}
/*
** Change the P2 operand of instruction addr so that it points to
** the address of the next instruction to be coded.
*/
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
sqlite3VdbeChangeP2(p, addr, p->nOp);
p->pParse->iFixedOp = p->nOp - 1;
}
/*
** If the input FuncDef structure is ephemeral, then free it. If
** the FuncDef is not ephermal, then do nothing.
*/
|
| ︙ | ︙ | |||
61914 61915 61916 61917 61918 61919 61920 |
if( addr==p->nOp-1 ) p->nOp--;
}
}
/*
** Remove the last opcode inserted
*/
| | > | > > > > | 62019 62020 62021 62022 62023 62024 62025 62026 62027 62028 62029 62030 62031 62032 62033 62034 62035 62036 62037 62038 62039 |
if( addr==p->nOp-1 ) p->nOp--;
}
}
/*
** Remove the last opcode inserted
*/
SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){
if( (p->nOp-1)>(p->pParse->iFixedOp) && p->aOp[p->nOp-1].opcode==op ){
sqlite3VdbeChangeToNoop(p, p->nOp-1);
return 1;
}else{
return 0;
}
}
/*
** Change the value of the P4 operand for a specific instruction.
** This routine is useful when a large program is loaded from a
** static array using sqlite3VdbeAddOpList but we want to make a
** few minor changes to the program.
|
| ︙ | ︙ | |||
63793 63794 63795 63796 63797 63798 63799 |
** function parameter corrsponds to bit 0 etc.).
*/
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
AuxData **pp = &pVdbe->pAuxData;
while( *pp ){
AuxData *pAux = *pp;
if( (iOp<0)
| | > | 63903 63904 63905 63906 63907 63908 63909 63910 63911 63912 63913 63914 63915 63916 63917 63918 63919 |
** function parameter corrsponds to bit 0 etc.).
*/
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
AuxData **pp = &pVdbe->pAuxData;
while( *pp ){
AuxData *pAux = *pp;
if( (iOp<0)
|| (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
){
testcase( pAux->iArg==31 );
if( pAux->xDelete ){
pAux->xDelete(pAux->pAux);
}
*pp = pAux->pNext;
sqlite3DbFree(pVdbe->db, pAux);
}else{
pp= &pAux->pNext;
|
| ︙ | ︙ | |||
64109 64110 64111 64112 64113 64114 64115 64116 64117 64118 64119 64120 64121 64122 64123 64124 64125 64126 64127 64128 |
** and store the result in pMem. Return the number of bytes read.
*/
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
){
switch( serial_type ){
case 10: /* Reserved for future use */
case 11: /* Reserved for future use */
case 0: { /* NULL */
pMem->flags = MEM_Null;
break;
}
case 1: { /* 1-byte signed integer */
pMem->u.i = (signed char)buf[0];
pMem->flags = MEM_Int;
return 1;
}
case 2: { /* 2-byte signed integer */
| > > > > | > | | > | | < < < | | | 64220 64221 64222 64223 64224 64225 64226 64227 64228 64229 64230 64231 64232 64233 64234 64235 64236 64237 64238 64239 64240 64241 64242 64243 64244 64245 64246 64247 64248 64249 64250 64251 64252 64253 64254 64255 64256 64257 64258 64259 64260 64261 64262 64263 64264 64265 64266 64267 64268 64269 64270 64271 64272 64273 64274 64275 64276 64277 64278 64279 64280 64281 64282 64283 64284 64285 64286 64287 64288 64289 64290 |
** and store the result in pMem. Return the number of bytes read.
*/
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
){
u64 x;
u32 y;
int i;
switch( serial_type ){
case 10: /* Reserved for future use */
case 11: /* Reserved for future use */
case 0: { /* NULL */
pMem->flags = MEM_Null;
break;
}
case 1: { /* 1-byte signed integer */
pMem->u.i = (signed char)buf[0];
pMem->flags = MEM_Int;
return 1;
}
case 2: { /* 2-byte signed integer */
i = 256*(signed char)buf[0] | buf[1];
pMem->u.i = (i64)i;
pMem->flags = MEM_Int;
return 2;
}
case 3: { /* 3-byte signed integer */
i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2];
pMem->u.i = (i64)i;
pMem->flags = MEM_Int;
return 3;
}
case 4: { /* 4-byte signed integer */
y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
pMem->u.i = (i64)*(int*)&y;
pMem->flags = MEM_Int;
return 4;
}
case 5: { /* 6-byte signed integer */
x = 256*(signed char)buf[0] + buf[1];
y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];
x = (x<<32) | y;
pMem->u.i = *(i64*)&x;
pMem->flags = MEM_Int;
return 6;
}
case 6: /* 8-byte signed integer */
case 7: { /* IEEE floating point */
#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
/* Verify that integers and floating point values use the same
** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
** defined that 64-bit floating point values really are mixed
** endian.
*/
static const u64 t1 = ((u64)0x3ff00000)<<32;
static const double r1 = 1.0;
u64 t2 = t1;
swapMixedEndianFloat(t2);
assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
#endif
x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];
x = (x<<32) | y;
if( serial_type==6 ){
pMem->u.i = *(i64*)&x;
pMem->flags = MEM_Int;
}else{
assert( sizeof(x)==8 && sizeof(pMem->r)==8 );
swapMixedEndianFloat(x);
|
| ︙ | ︙ | |||
70683 70684 70685 70686 70687 70688 70689 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); pC->nullRow = 1; pC->rowidIsValid = 0; pC->cacheStatus = CACHE_STALE; | < | 70797 70798 70799 70800 70801 70802 70803 70804 70805 70806 70807 70808 70809 70810 |
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
pC->nullRow = 1;
pC->rowidIsValid = 0;
pC->cacheStatus = CACHE_STALE;
if( pC->pCursor ){
sqlite3BtreeClearCursor(pC->pCursor);
}
break;
}
/* Opcode: Last P1 P2 * * *
|
| ︙ | ︙ | |||
72492 72493 72494 72495 72496 72497 72498 |
sqlite3DbFree(db, z);
}
#ifdef SQLITE_USE_FCNTL_TRACE
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
if( zTrace ){
int i;
for(i=0; i<db->nDb; i++){
| | | 72605 72606 72607 72608 72609 72610 72611 72612 72613 72614 72615 72616 72617 72618 72619 |
sqlite3DbFree(db, z);
}
#ifdef SQLITE_USE_FCNTL_TRACE
zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
if( zTrace ){
int i;
for(i=0; i<db->nDb; i++){
if( MASKBIT(i) & p->btreeMask)==0 ) continue;
sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace);
}
}
#endif /* SQLITE_USE_FCNTL_TRACE */
#ifdef SQLITE_DEBUG
if( (db->flags & SQLITE_SqlTrace)!=0
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
|
| ︙ | ︙ | |||
74779 74780 74781 74782 74783 74784 74785 | } return WRC_Continue; } /* ** Call sqlite3WalkExpr() for every expression in Select statement p. ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and | | > > > > | < > | > | | | < < < < | 74892 74893 74894 74895 74896 74897 74898 74899 74900 74901 74902 74903 74904 74905 74906 74907 74908 74909 74910 74911 74912 74913 74914 74915 74916 74917 74918 74919 74920 74921 74922 74923 74924 74925 74926 74927 74928 74929 74930 74931 74932 74933 74934 74935 74936 74937 74938 |
}
return WRC_Continue;
}
/*
** Call sqlite3WalkExpr() for every expression in Select statement p.
** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
** on the compound select chain, p->pPrior.
**
** If it is not NULL, the xSelectCallback() callback is invoked before
** the walk of the expressions and FROM clause. The xSelectCallback2()
** method, if it is not NULL, is invoked following the walk of the
** expressions and FROM clause.
**
** Return WRC_Continue under normal conditions. Return WRC_Abort if
** there is an abort request.
**
** If the Walker does not have an xSelectCallback() then this routine
** is a no-op returning WRC_Continue.
*/
SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
int rc;
if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){
return WRC_Continue;
}
rc = WRC_Continue;
pWalker->walkerDepth++;
while( p ){
if( pWalker->xSelectCallback ){
rc = pWalker->xSelectCallback(pWalker, p);
if( rc ) break;
}
if( sqlite3WalkSelectExpr(pWalker, p)
|| sqlite3WalkSelectFrom(pWalker, p)
){
pWalker->walkerDepth--;
return WRC_Abort;
}
if( pWalker->xSelectCallback2 ){
pWalker->xSelectCallback2(pWalker, p);
}
p = p->pPrior;
}
pWalker->walkerDepth--;
return rc & WRC_Abort;
}
|
| ︙ | ︙ | |||
77168 77169 77170 77171 77172 77173 77174 77175 77176 77177 77178 77179 77180 77181 |
}
}
}
return pNew;
}
/*
** The following group of routines make deep copies of expressions,
** expression lists, ID lists, and select statements. The copies can
** be deleted (by being passed to their respective ...Delete() routines)
** without effecting the originals.
**
** The expression list, ID, and source lists return by sqlite3ExprListDup(),
| > > > > > > > > > > > > > > > > > > > > > > > > > > > | 77282 77283 77284 77285 77286 77287 77288 77289 77290 77291 77292 77293 77294 77295 77296 77297 77298 77299 77300 77301 77302 77303 77304 77305 77306 77307 77308 77309 77310 77311 77312 77313 77314 77315 77316 77317 77318 77319 77320 77321 77322 |
}
}
}
return pNew;
}
/*
** Create and return a deep copy of the object passed as the second
** argument. If an OOM condition is encountered, NULL is returned
** and the db->mallocFailed flag set.
*/
#ifndef SQLITE_OMIT_CTE
static With *withDup(sqlite3 *db, With *p){
With *pRet = 0;
if( p ){
int nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);
pRet = sqlite3DbMallocZero(db, nByte);
if( pRet ){
int i;
pRet->nCte = p->nCte;
for(i=0; i<p->nCte; i++){
pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0);
pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0);
pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName);
}
}
}
return pRet;
}
#else
# define withDup(x,y) 0
#endif
/*
** The following group of routines make deep copies of expressions,
** expression lists, ID lists, and select statements. The copies can
** be deleted (by being passed to their respective ...Delete() routines)
** without effecting the originals.
**
** The expression list, ID, and source lists return by sqlite3ExprListDup(),
|
| ︙ | ︙ | |||
77248 77249 77250 77251 77252 77253 77254 77255 77256 77257 77258 77259 77260 77261 |
pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);
pNewItem->jointype = pOldItem->jointype;
pNewItem->iCursor = pOldItem->iCursor;
pNewItem->addrFillSub = pOldItem->addrFillSub;
pNewItem->regReturn = pOldItem->regReturn;
pNewItem->isCorrelated = pOldItem->isCorrelated;
pNewItem->viaCoroutine = pOldItem->viaCoroutine;
pNewItem->zIndex = sqlite3DbStrDup(db, pOldItem->zIndex);
pNewItem->notIndexed = pOldItem->notIndexed;
pNewItem->pIndex = pOldItem->pIndex;
pTab = pNewItem->pTab = pOldItem->pTab;
if( pTab ){
pTab->nRef++;
}
| > | 77389 77390 77391 77392 77393 77394 77395 77396 77397 77398 77399 77400 77401 77402 77403 |
pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);
pNewItem->jointype = pOldItem->jointype;
pNewItem->iCursor = pOldItem->iCursor;
pNewItem->addrFillSub = pOldItem->addrFillSub;
pNewItem->regReturn = pOldItem->regReturn;
pNewItem->isCorrelated = pOldItem->isCorrelated;
pNewItem->viaCoroutine = pOldItem->viaCoroutine;
pNewItem->isRecursive = pOldItem->isRecursive;
pNewItem->zIndex = sqlite3DbStrDup(db, pOldItem->zIndex);
pNewItem->notIndexed = pOldItem->notIndexed;
pNewItem->pIndex = pOldItem->pIndex;
pTab = pNewItem->pTab = pOldItem->pTab;
if( pTab ){
pTab->nRef++;
}
|
| ︙ | ︙ | |||
77309 77310 77311 77312 77313 77314 77315 77316 77317 77318 77319 77320 77321 77322 |
pNew->iLimit = 0;
pNew->iOffset = 0;
pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
pNew->pRightmost = 0;
pNew->addrOpenEphm[0] = -1;
pNew->addrOpenEphm[1] = -1;
pNew->addrOpenEphm[2] = -1;
return pNew;
}
#else
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
assert( p==0 );
return 0;
}
| > > | 77451 77452 77453 77454 77455 77456 77457 77458 77459 77460 77461 77462 77463 77464 77465 77466 |
pNew->iLimit = 0;
pNew->iOffset = 0;
pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;
pNew->pRightmost = 0;
pNew->addrOpenEphm[0] = -1;
pNew->addrOpenEphm[1] = -1;
pNew->addrOpenEphm[2] = -1;
pNew->nSelectRow = p->nSelectRow;
pNew->pWith = withDup(db, p->pWith);
return pNew;
}
#else
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
assert( p==0 );
return 0;
}
|
| ︙ | ︙ | |||
78929 78930 78931 78932 78933 78934 78935 |
}
case TK_FUNCTION: {
ExprList *pFarg; /* List of function arguments */
int nFarg; /* Number of function arguments */
FuncDef *pDef; /* The function definition object */
int nId; /* Length of the function name in bytes */
const char *zId; /* The function name */
| | | 79073 79074 79075 79076 79077 79078 79079 79080 79081 79082 79083 79084 79085 79086 79087 |
}
case TK_FUNCTION: {
ExprList *pFarg; /* List of function arguments */
int nFarg; /* Number of function arguments */
FuncDef *pDef; /* The function definition object */
int nId; /* Length of the function name in bytes */
const char *zId; /* The function name */
u32 constMask = 0; /* Mask of function arguments that are constant */
int i; /* Loop counter */
u8 enc = ENC(db); /* The text encoding used by this database */
CollSeq *pColl = 0; /* A collating sequence */
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
pFarg = 0;
|
| ︙ | ︙ | |||
78980 78981 78982 78983 78984 78985 78986 |
assert( nFarg>=1 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
break;
}
for(i=0; i<nFarg; i++){
if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
| > | | 79124 79125 79126 79127 79128 79129 79130 79131 79132 79133 79134 79135 79136 79137 79138 79139 |
assert( nFarg>=1 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
break;
}
for(i=0; i<nFarg; i++){
if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
testcase( i==31 );
constMask |= MASKBIT32(i);
}
if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
}
}
if( pFarg ){
if( constMask ){
|
| ︙ | ︙ | |||
79661 79662 79663 79664 79665 79666 79667 |
sqlite3ExplainExpr(pOut, pList->a[0].pExpr);
}else{
sqlite3ExplainPush(pOut);
for(i=0; i<pList->nExpr; i++){
sqlite3ExplainPrintf(pOut, "item[%d] = ", i);
sqlite3ExplainPush(pOut);
sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
| | | 79806 79807 79808 79809 79810 79811 79812 79813 79814 79815 79816 79817 79818 79819 79820 |
sqlite3ExplainExpr(pOut, pList->a[0].pExpr);
}else{
sqlite3ExplainPush(pOut);
for(i=0; i<pList->nExpr; i++){
sqlite3ExplainPrintf(pOut, "item[%d] = ", i);
sqlite3ExplainPush(pOut);
sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
sqlite3ExplainPop(pOut);
if( pList->a[i].zName ){
sqlite3ExplainPrintf(pOut, " AS %s", pList->a[i].zName);
}
if( pList->a[i].bSpanIsTab ){
sqlite3ExplainPrintf(pOut, " (%s)", pList->a[i].zSpan);
}
if( i<pList->nExpr-1 ){
|
| ︙ | ︙ | |||
84089 84090 84091 84092 84093 84094 84095 84096 84097 84098 84099 84100 84101 84102 |
/* Begin by generating some termination code at the end of the
** vdbe program
*/
v = sqlite3GetVdbe(pParse);
assert( !pParse->isMultiWrite
|| sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
if( v ){
sqlite3VdbeAddOp0(v, OP_Halt);
/* The cookie mask contains one bit for each database file open.
** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
** set for each database that is used. Generate code to start a
** transaction on each used database and to verify the schema cookie
** on each used database.
| > | 84234 84235 84236 84237 84238 84239 84240 84241 84242 84243 84244 84245 84246 84247 84248 |
/* Begin by generating some termination code at the end of the
** vdbe program
*/
v = sqlite3GetVdbe(pParse);
assert( !pParse->isMultiWrite
|| sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
if( v ){
while( sqlite3VdbeDeletePriorOpcode(v, OP_Close) ){}
sqlite3VdbeAddOp0(v, OP_Halt);
/* The cookie mask contains one bit for each database file open.
** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are
** set for each database that is used. Generate code to start a
** transaction on each used database and to verify the schema cookie
** on each used database.
|
| ︙ | ︙ | |||
85400 85401 85402 85403 85404 85405 85406 |
unsigned char *zIdent = (unsigned char*)zSignedIdent;
int i, j, needQuote;
i = *pIdx;
for(j=0; zIdent[j]; j++){
if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
}
| | | | < > | 85546 85547 85548 85549 85550 85551 85552 85553 85554 85555 85556 85557 85558 85559 85560 85561 85562 85563 |
unsigned char *zIdent = (unsigned char*)zSignedIdent;
int i, j, needQuote;
i = *pIdx;
for(j=0; zIdent[j]; j++){
if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
}
needQuote = sqlite3Isdigit(zIdent[0])
|| sqlite3KeywordCode(zIdent, j)!=TK_ID
|| zIdent[j]!=0
|| j==0;
if( needQuote ) z[i++] = '"';
for(j=0; zIdent[j]; j++){
z[i++] = zIdent[j];
if( zIdent[j]=='"' ) z[i++] = '"';
}
if( needQuote ) z[i++] = '"';
|
| ︙ | ︙ | |||
86626 86627 86628 86629 86630 86631 86632 | /* Open the table. Loop through all rows of the table, inserting index ** records into the sorter. */ sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); regRecord = sqlite3GetTempReg(pParse); | | | 86772 86773 86774 86775 86776 86777 86778 86779 86780 86781 86782 86783 86784 86785 86786 |
/* Open the table. Loop through all rows of the table, inserting index
** records into the sorter. */
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
regRecord = sqlite3GetTempReg(pParse);
sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);
sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
sqlite3VdbeResolveLabel(v, iPartIdxLabel);
sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
sqlite3VdbeJumpHere(v, addr1);
if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb,
(char *)pKey, P4_KEYINFO);
|
| ︙ | ︙ | |||
88147 88148 88149 88150 88151 88152 88153 88154 88155 88156 88157 88158 88159 88160 |
pIdx->pKeyInfo = pKey;
}
}
}
return sqlite3KeyInfoRef(pIdx->pKeyInfo);
}
/************** End of build.c ***********************************************/
/************** Begin file callback.c ****************************************/
/*
** 2005 May 23
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 88293 88294 88295 88296 88297 88298 88299 88300 88301 88302 88303 88304 88305 88306 88307 88308 88309 88310 88311 88312 88313 88314 88315 88316 88317 88318 88319 88320 88321 88322 88323 88324 88325 88326 88327 88328 88329 88330 88331 88332 88333 88334 88335 88336 88337 88338 88339 88340 88341 88342 88343 88344 88345 88346 88347 88348 88349 88350 88351 88352 88353 88354 88355 88356 88357 88358 88359 88360 88361 88362 88363 88364 88365 88366 88367 88368 88369 88370 88371 88372 88373 88374 88375 88376 |
pIdx->pKeyInfo = pKey;
}
}
}
return sqlite3KeyInfoRef(pIdx->pKeyInfo);
}
#ifndef SQLITE_OMIT_CTE
/*
** This routine is invoked once per CTE by the parser while parsing a
** WITH clause.
*/
SQLITE_PRIVATE With *sqlite3WithAdd(
Parse *pParse, /* Parsing context */
With *pWith, /* Existing WITH clause, or NULL */
Token *pName, /* Name of the common-table */
ExprList *pArglist, /* Optional column name list for the table */
Select *pQuery /* Query used to initialize the table */
){
sqlite3 *db = pParse->db;
With *pNew;
char *zName;
/* Check that the CTE name is unique within this WITH clause. If
** not, store an error in the Parse structure. */
zName = sqlite3NameFromToken(pParse->db, pName);
if( zName && pWith ){
int i;
for(i=0; i<pWith->nCte; i++){
if( sqlite3StrICmp(zName, pWith->a[i].zName)==0 ){
sqlite3ErrorMsg(pParse, "duplicate WITH table name: %s", zName);
}
}
}
if( pWith ){
int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte);
pNew = sqlite3DbRealloc(db, pWith, nByte);
}else{
pNew = sqlite3DbMallocZero(db, sizeof(*pWith));
}
assert( zName!=0 || pNew==0 );
assert( db->mallocFailed==0 || pNew==0 );
if( pNew==0 ){
sqlite3ExprListDelete(db, pArglist);
sqlite3SelectDelete(db, pQuery);
sqlite3DbFree(db, zName);
pNew = pWith;
}else{
pNew->a[pNew->nCte].pSelect = pQuery;
pNew->a[pNew->nCte].pCols = pArglist;
pNew->a[pNew->nCte].zName = zName;
pNew->a[pNew->nCte].zErr = 0;
pNew->nCte++;
}
return pNew;
}
/*
** Free the contents of the With object passed as the second argument.
*/
SQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){
if( pWith ){
int i;
for(i=0; i<pWith->nCte; i++){
struct Cte *pCte = &pWith->a[i];
sqlite3ExprListDelete(db, pCte->pCols);
sqlite3SelectDelete(db, pCte->pSelect);
sqlite3DbFree(db, pCte->zName);
}
sqlite3DbFree(db, pWith);
}
}
#endif /* !defined(SQLITE_OMIT_CTE) */
/************** End of build.c ***********************************************/
/************** Begin file callback.c ****************************************/
/*
** 2005 May 23
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
|
| ︙ | ︙ | |||
89265 89266 89267 89268 89269 89270 89271 |
iOld = pParse->nMem+1;
pParse->nMem += (1 + pTab->nCol);
/* Populate the OLD.* pseudo-table register array. These values will be
** used by any BEFORE and AFTER triggers that exist. */
sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
for(iCol=0; iCol<pTab->nCol; iCol++){
| > > | | 89481 89482 89483 89484 89485 89486 89487 89488 89489 89490 89491 89492 89493 89494 89495 89496 89497 |
iOld = pParse->nMem+1;
pParse->nMem += (1 + pTab->nCol);
/* Populate the OLD.* pseudo-table register array. These values will be
** used by any BEFORE and AFTER triggers that exist. */
sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);
for(iCol=0; iCol<pTab->nCol; iCol++){
testcase( mask!=0xffffffff && iCol==31 );
testcase( mask!=0xffffffff && iCol==32 );
if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);
}
}
/* Invoke BEFORE DELETE trigger programs. */
addrStart = sqlite3VdbeCurrentAddr(v);
sqlite3CodeRowTrigger(pParse, pTrigger,
|
| ︙ | ︙ | |||
89345 89346 89347 89348 89349 89350 89351 |
Parse *pParse, /* Parsing and code generating context */
Table *pTab, /* Table containing the row to be deleted */
int iDataCur, /* Cursor of table holding data. */
int iIdxCur, /* First index cursor */
int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
){
int i; /* Index loop counter */
| | > | > > | 89563 89564 89565 89566 89567 89568 89569 89570 89571 89572 89573 89574 89575 89576 89577 89578 89579 89580 89581 89582 89583 89584 89585 89586 89587 89588 89589 89590 89591 89592 89593 89594 89595 89596 |
Parse *pParse, /* Parsing and code generating context */
Table *pTab, /* Table containing the row to be deleted */
int iDataCur, /* Cursor of table holding data. */
int iIdxCur, /* First index cursor */
int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */
){
int i; /* Index loop counter */
int r1 = -1; /* Register holding an index key */
int iPartIdxLabel; /* Jump destination for skipping partial index entries */
Index *pIdx; /* Current index */
Index *pPrior = 0; /* Prior index */
Vdbe *v; /* The prepared statement under construction */
Index *pPk; /* PRIMARY KEY index, or NULL for rowid tables */
v = pParse->pVdbe;
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
assert( iIdxCur+i!=iDataCur || pPk==pIdx );
if( aRegIdx!=0 && aRegIdx[i]==0 ) continue;
if( pIdx==pPk ) continue;
VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
&iPartIdxLabel, pPrior, r1);
sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,
pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
sqlite3VdbeResolveLabel(v, iPartIdxLabel);
pPrior = pIdx;
}
}
/*
** Generate code that will assemble an index key and stores it in register
** regOut. The key with be for index pIdx which is an index on pTab.
** iCur is the index of a cursor open on the pTab table and pointing to
|
| ︙ | ︙ | |||
89383 89384 89385 89386 89387 89388 89389 89390 89391 89392 89393 89394 89395 89396 | ** ** If *piPartIdxLabel is not NULL, fill it in with a label and jump ** to that label if pIdx is a partial index that should be skipped. ** A partial index should be skipped if its WHERE clause evaluates ** to false or null. If pIdx is not a partial index, *piPartIdxLabel ** will be set to zero which is an empty label that is ignored by ** sqlite3VdbeResolveLabel(). */ SQLITE_PRIVATE int sqlite3GenerateIndexKey( Parse *pParse, /* Parsing context */ Index *pIdx, /* The index for which to generate a key */ int iDataCur, /* Cursor number from which to take column data */ int regOut, /* Put the new key into this register if not 0 */ int prefixOnly, /* Compute only a unique prefix of the key */ | > > > > > > > > > > > | > > > > < | < | 89604 89605 89606 89607 89608 89609 89610 89611 89612 89613 89614 89615 89616 89617 89618 89619 89620 89621 89622 89623 89624 89625 89626 89627 89628 89629 89630 89631 89632 89633 89634 89635 89636 89637 89638 89639 89640 89641 89642 89643 89644 89645 89646 89647 89648 89649 89650 89651 89652 89653 89654 89655 89656 89657 89658 89659 89660 89661 89662 89663 89664 89665 89666 89667 89668 89669 |
**
** If *piPartIdxLabel is not NULL, fill it in with a label and jump
** to that label if pIdx is a partial index that should be skipped.
** A partial index should be skipped if its WHERE clause evaluates
** to false or null. If pIdx is not a partial index, *piPartIdxLabel
** will be set to zero which is an empty label that is ignored by
** sqlite3VdbeResolveLabel().
**
** The pPrior and regPrior parameters are used to implement a cache to
** avoid unnecessary register loads. If pPrior is not NULL, then it is
** a pointer to a different index for which an index key has just been
** computed into register regPrior. If the current pIdx index is generating
** its key into the same sequence of registers and if pPrior and pIdx share
** a column in common, then the register corresponding to that column already
** holds the correct value and the loading of that register is skipped.
** This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK
** on a table with multiple indices, and especially with the ROWID or
** PRIMARY KEY columns of the index.
*/
SQLITE_PRIVATE int sqlite3GenerateIndexKey(
Parse *pParse, /* Parsing context */
Index *pIdx, /* The index for which to generate a key */
int iDataCur, /* Cursor number from which to take column data */
int regOut, /* Put the new key into this register if not 0 */
int prefixOnly, /* Compute only a unique prefix of the key */
int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */
Index *pPrior, /* Previously generated index key */
int regPrior /* Register holding previous generated key */
){
Vdbe *v = pParse->pVdbe;
int j;
Table *pTab = pIdx->pTable;
int regBase;
int nCol;
if( piPartIdxLabel ){
if( pIdx->pPartIdxWhere ){
*piPartIdxLabel = sqlite3VdbeMakeLabel(v);
pParse->iPartIdxTab = iDataCur;
sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
SQLITE_JUMPIFNULL);
}else{
*piPartIdxLabel = 0;
}
}
nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
regBase = sqlite3GetTempRange(pParse, nCol);
if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;
for(j=0; j<nCol; j++){
if( pPrior && pPrior->aiColumn[j]==pIdx->aiColumn[j] ) continue;
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pIdx->aiColumn[j],
regBase+j);
/* If the column affinity is REAL but the number is an integer, then it
** might be stored in the table as an integer (using a compact
** representation) then converted to REAL by an OP_RealAffinity opcode.
** But we are getting ready to store this value back into an index, where
** it should be converted by to INTEGER again. So omit the OP_RealAffinity
** opcode if it is present */
sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
}
if( regOut ){
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
}
sqlite3ReleaseTempRange(pParse, regBase, nCol);
return regBase;
}
|
| ︙ | ︙ | |||
89569 89570 89571 89572 89573 89574 89575 |
static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
assert( argc==1 );
UNUSED_PARAMETER(argc);
switch( sqlite3_value_type(argv[0]) ){
case SQLITE_INTEGER: {
i64 iVal = sqlite3_value_int64(argv[0]);
if( iVal<0 ){
| | | 89803 89804 89805 89806 89807 89808 89809 89810 89811 89812 89813 89814 89815 89816 89817 |
static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
assert( argc==1 );
UNUSED_PARAMETER(argc);
switch( sqlite3_value_type(argv[0]) ){
case SQLITE_INTEGER: {
i64 iVal = sqlite3_value_int64(argv[0]);
if( iVal<0 ){
if( iVal==SMALLEST_INT64 ){
/* IMP: R-31676-45509 If X is the integer -9223372036854775808
** then abs(X) throws an integer overflow error since there is no
** equivalent positive 64-bit two complement value. */
sqlite3_result_error(context, "integer overflow", -1);
return;
}
iVal = -iVal;
|
| ︙ | ︙ | |||
93084 93085 93086 93087 93088 93089 93090 | ** transfer values form intermediate table into <table> ** end loop ** D: cleanup */ SQLITE_PRIVATE void sqlite3Insert( Parse *pParse, /* Parser context */ SrcList *pTabList, /* Name of table into which we are inserting */ | < | 93318 93319 93320 93321 93322 93323 93324 93325 93326 93327 93328 93329 93330 93331 |
** transfer values form intermediate table into <table>
** end loop
** D: cleanup
*/
SQLITE_PRIVATE void sqlite3Insert(
Parse *pParse, /* Parser context */
SrcList *pTabList, /* Name of table into which we are inserting */
Select *pSelect, /* A SELECT statement to use as the data source */
IdList *pColumn, /* Column names corresponding to IDLIST. */
int onError /* How to handle constraint errors */
){
sqlite3 *db; /* The main database structure */
Table *pTab; /* The table to insert into. aka TABLE */
char *zTab; /* Name of the table into which we are inserting */
|
| ︙ | ︙ | |||
93112 93113 93114 93115 93116 93117 93118 93119 93120 93121 93122 93123 93124 93125 | int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ int addrSelect = 0; /* Address of coroutine that implements the SELECT */ SelectDest dest; /* Destination for SELECT on rhs of INSERT */ int iDb; /* Index of database holding TABLE */ Db *pDb; /* The database containing table being inserted into */ int appendFlag = 0; /* True if the insert is likely to be an append */ int withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ /* Register allocations */ int regFromSelect = 0;/* Base register for data coming from SELECT */ int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ int regRowCount = 0; /* Memory cell used for the row counter */ int regIns; /* Block of regs holding rowid+data being inserted */ int regRowid; /* registers holding insert rowid */ | > | 93345 93346 93347 93348 93349 93350 93351 93352 93353 93354 93355 93356 93357 93358 93359 | int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ int addrSelect = 0; /* Address of coroutine that implements the SELECT */ SelectDest dest; /* Destination for SELECT on rhs of INSERT */ int iDb; /* Index of database holding TABLE */ Db *pDb; /* The database containing table being inserted into */ int appendFlag = 0; /* True if the insert is likely to be an append */ int withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ ExprList *pList = 0; /* List of VALUES() to be inserted */ /* Register allocations */ int regFromSelect = 0;/* Base register for data coming from SELECT */ int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ int regRowCount = 0; /* Memory cell used for the row counter */ int regIns; /* Block of regs holding rowid+data being inserted */ int regRowid; /* registers holding insert rowid */ |
| ︙ | ︙ | |||
93134 93135 93136 93137 93138 93139 93140 93141 93142 93143 93144 93145 93146 93147 |
#endif
db = pParse->db;
memset(&dest, 0, sizeof(dest));
if( pParse->nErr || db->mallocFailed ){
goto insert_cleanup;
}
/* Locate the table into which we will be inserting new information.
*/
assert( pTabList->nSrc==1 );
zTab = pTabList->a[0].zName;
if( NEVER(zTab==0) ) goto insert_cleanup;
pTab = sqlite3SrcListLookup(pParse, pTabList);
| > > > > > > > > > > > | 93368 93369 93370 93371 93372 93373 93374 93375 93376 93377 93378 93379 93380 93381 93382 93383 93384 93385 93386 93387 93388 93389 93390 93391 93392 |
#endif
db = pParse->db;
memset(&dest, 0, sizeof(dest));
if( pParse->nErr || db->mallocFailed ){
goto insert_cleanup;
}
/* If the Select object is really just a simple VALUES() list with a
** single row values (the common case) then keep that one row of values
** and go ahead and discard the Select object
*/
if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){
pList = pSelect->pEList;
pSelect->pEList = 0;
sqlite3SelectDelete(db, pSelect);
pSelect = 0;
}
/* Locate the table into which we will be inserting new information.
*/
assert( pTabList->nSrc==1 );
zTab = pTabList->a[0].zName;
if( NEVER(zTab==0) ) goto insert_cleanup;
pTab = sqlite3SrcListLookup(pParse, pTabList);
|
| ︙ | ︙ | |||
94390 94391 94392 94393 94394 94395 94396 94397 94398 94399 94400 94401 94402 94403 |
Vdbe *v; /* The VDBE we are building */
int regAutoinc; /* Memory register used by AUTOINC */
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
if( pSelect==0 ){
return 0; /* Must be of the form INSERT INTO ... SELECT ... */
}
if( sqlite3TriggerList(pParse, pDest) ){
return 0; /* tab1 must not have triggers */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( pDest->tabFlags & TF_Virtual ){
return 0; /* tab1 must not be a virtual table */
| > > > > > > | 94635 94636 94637 94638 94639 94640 94641 94642 94643 94644 94645 94646 94647 94648 94649 94650 94651 94652 94653 94654 |
Vdbe *v; /* The VDBE we are building */
int regAutoinc; /* Memory register used by AUTOINC */
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
if( pSelect==0 ){
return 0; /* Must be of the form INSERT INTO ... SELECT ... */
}
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
if( sqlite3TriggerList(pParse, pDest) ){
return 0; /* tab1 must not have triggers */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( pDest->tabFlags & TF_Virtual ){
return 0; /* tab1 must not be a virtual table */
|
| ︙ | ︙ | |||
97889 97890 97891 97892 97893 97894 97895 97896 97897 97898 97899 97900 97901 97902 97903 97904 97905 97906 97907 97908 97909 97910 97911 97912 97913 97914 97915 |
sqlite3VdbeJumpHere(v, addr);
/* Make sure all the indices are constructed correctly.
*/
for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){
Table *pTab = sqliteHashData(x);
Index *pIdx, *pPk;
int loopTop;
int iDataCur, iIdxCur;
if( pTab->pIndex==0 ) continue;
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
sqlite3VdbeJumpHere(v, addr);
sqlite3ExprCacheClear(pParse);
sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead,
1, 0, &iDataCur, &iIdxCur);
sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */
}
pParse->nMem = MAX(pParse->nMem, 8+j);
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0);
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4;
| > > < | > > | 98140 98141 98142 98143 98144 98145 98146 98147 98148 98149 98150 98151 98152 98153 98154 98155 98156 98157 98158 98159 98160 98161 98162 98163 98164 98165 98166 98167 98168 98169 98170 98171 98172 98173 98174 98175 98176 98177 98178 98179 |
sqlite3VdbeJumpHere(v, addr);
/* Make sure all the indices are constructed correctly.
*/
for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){
Table *pTab = sqliteHashData(x);
Index *pIdx, *pPk;
Index *pPrior = 0;
int loopTop;
int iDataCur, iIdxCur;
int r1 = -1;
if( pTab->pIndex==0 ) continue;
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
sqlite3VdbeJumpHere(v, addr);
sqlite3ExprCacheClear(pParse);
sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead,
1, 0, &iDataCur, &iIdxCur);
sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */
}
pParse->nMem = MAX(pParse->nMem, 8+j);
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0);
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4;
if( pPk==pIdx ) continue;
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
pPrior, r1);
pPrior = pIdx;
sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, 0, r1,
pIdx->nColumn);
sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, "row ", P4_STATIC);
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, " missing from index ",
|
| ︙ | ︙ | |||
99227 99228 99229 99230 99231 99232 99233 99234 99235 99236 99237 99238 99239 99240 |
sqlite3ExprDelete(db, p->pWhere);
sqlite3ExprListDelete(db, p->pGroupBy);
sqlite3ExprDelete(db, p->pHaving);
sqlite3ExprListDelete(db, p->pOrderBy);
sqlite3SelectDelete(db, p->pPrior);
sqlite3ExprDelete(db, p->pLimit);
sqlite3ExprDelete(db, p->pOffset);
}
/*
** Initialize a SelectDest structure.
*/
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
pDest->eDest = (u8)eDest;
| > | 99481 99482 99483 99484 99485 99486 99487 99488 99489 99490 99491 99492 99493 99494 99495 |
sqlite3ExprDelete(db, p->pWhere);
sqlite3ExprListDelete(db, p->pGroupBy);
sqlite3ExprDelete(db, p->pHaving);
sqlite3ExprListDelete(db, p->pOrderBy);
sqlite3SelectDelete(db, p->pPrior);
sqlite3ExprDelete(db, p->pLimit);
sqlite3ExprDelete(db, p->pOffset);
sqlite3WithDelete(db, p->pWith);
}
/*
** Initialize a SelectDest structure.
*/
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
pDest->eDest = (u8)eDest;
|
| ︙ | ︙ | |||
99659 99660 99661 99662 99663 99664 99665 | } /* ** Add code to implement the OFFSET */ static void codeOffset( Vdbe *v, /* Generate code into this VM */ | | | | | | 99914 99915 99916 99917 99918 99919 99920 99921 99922 99923 99924 99925 99926 99927 99928 99929 99930 99931 99932 99933 99934 |
}
/*
** Add code to implement the OFFSET
*/
static void codeOffset(
Vdbe *v, /* Generate code into this VM */
int iOffset, /* Register holding the offset counter */
int iContinue /* Jump here to skip the current record */
){
if( iOffset>0 && iContinue!=0 ){
int addr;
sqlite3VdbeAddOp2(v, OP_AddImm, iOffset, -1);
addr = sqlite3VdbeAddOp1(v, OP_IfNeg, iOffset);
sqlite3VdbeAddOp2(v, OP_Goto, 0, iContinue);
VdbeComment((v, "skip OFFSET records"));
sqlite3VdbeJumpHere(v, addr);
}
}
/*
|
| ︙ | ︙ | |||
99740 99741 99742 99743 99744 99745 99746 | int addrTnct; /* Address of OP_OpenEphemeral opcode for tabTnct */ }; /* ** This routine generates the code for the inside of the inner loop ** of a SELECT. ** | | | | | < < | < < < | < | | > < < < | | | | | | | | | | > | > > > > > > > > > > > > > | | 99995 99996 99997 99998 99999 100000 100001 100002 100003 100004 100005 100006 100007 100008 100009 100010 100011 100012 100013 100014 100015 100016 100017 100018 100019 100020 100021 100022 100023 100024 100025 100026 100027 100028 100029 100030 100031 100032 100033 100034 100035 100036 100037 100038 100039 100040 100041 100042 100043 100044 100045 100046 100047 100048 100049 100050 100051 100052 100053 100054 100055 100056 100057 100058 100059 100060 100061 100062 100063 100064 100065 100066 100067 100068 100069 100070 100071 100072 100073 100074 100075 100076 100077 100078 100079 100080 100081 100082 100083 100084 100085 100086 100087 100088 100089 100090 100091 100092 100093 100094 100095 100096 100097 100098 100099 100100 100101 100102 100103 100104 100105 100106 100107 100108 100109 100110 100111 100112 100113 100114 100115 100116 100117 100118 100119 100120 100121 100122 100123 100124 100125 100126 100127 100128 100129 100130 100131 100132 100133 100134 100135 100136 100137 100138 100139 100140 100141 100142 100143 100144 100145 100146 100147 100148 100149 100150 100151 100152 100153 100154 100155 100156 100157 100158 100159 100160 100161 100162 100163 100164 100165 100166 100167 100168 100169 100170 100171 100172 100173 100174 100175 100176 100177 100178 100179 100180 100181 100182 100183 100184 100185 100186 100187 100188 |
int addrTnct; /* Address of OP_OpenEphemeral opcode for tabTnct */
};
/*
** This routine generates the code for the inside of the inner loop
** of a SELECT.
**
** If srcTab is negative, then the pEList expressions
** are evaluated in order to get the data for this row. If srcTab is
** zero or more, then data is pulled from srcTab and pEList is used only
** to get number columns and the datatype for each column.
*/
static void selectInnerLoop(
Parse *pParse, /* The parser context */
Select *p, /* The complete select statement being coded */
ExprList *pEList, /* List of values being extracted */
int srcTab, /* Pull data from this table */
ExprList *pOrderBy, /* If not NULL, sort results using this key */
DistinctCtx *pDistinct, /* If not NULL, info on how to process DISTINCT */
SelectDest *pDest, /* How to dispose of the results */
int iContinue, /* Jump here to continue with next row */
int iBreak /* Jump here to break out of the inner loop */
){
Vdbe *v = pParse->pVdbe;
int i;
int hasDistinct; /* True if the DISTINCT keyword is present */
int regResult; /* Start of memory holding result set */
int eDest = pDest->eDest; /* How to dispose of results */
int iParm = pDest->iSDParm; /* First argument to disposal method */
int nResultCol; /* Number of result columns */
assert( v );
assert( pEList!=0 );
hasDistinct = pDistinct ? pDistinct->eTnctType : WHERE_DISTINCT_NOOP;
if( pOrderBy==0 && !hasDistinct ){
codeOffset(v, p->iOffset, iContinue);
}
/* Pull the requested columns.
*/
nResultCol = pEList->nExpr;
if( pDest->iSdst==0 ){
pDest->iSdst = pParse->nMem+1;
pDest->nSdst = nResultCol;
pParse->nMem += nResultCol;
}else{
assert( pDest->nSdst==nResultCol );
}
regResult = pDest->iSdst;
if( srcTab>=0 ){
for(i=0; i<nResultCol; i++){
sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);
VdbeComment((v, "%s", pEList->a[i].zName));
}
}else if( eDest!=SRT_Exists ){
/* If the destination is an EXISTS(...) expression, the actual
** values returned by the SELECT are not required.
*/
sqlite3ExprCodeExprList(pParse, pEList, regResult,
(eDest==SRT_Output)?SQLITE_ECEL_DUP:0);
}
/* If the DISTINCT keyword was present on the SELECT statement
** and this row has been seen before, then do not make this row
** part of the result.
*/
if( hasDistinct ){
switch( pDistinct->eTnctType ){
case WHERE_DISTINCT_ORDERED: {
VdbeOp *pOp; /* No longer required OpenEphemeral instr. */
int iJump; /* Jump destination */
int regPrev; /* Previous row content */
/* Allocate space for the previous row */
regPrev = pParse->nMem+1;
pParse->nMem += nResultCol;
/* Change the OP_OpenEphemeral coded earlier to an OP_Null
** sets the MEM_Cleared bit on the first register of the
** previous value. This will cause the OP_Ne below to always
** fail on the first iteration of the loop even if the first
** row is all NULLs.
*/
sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);
pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);
pOp->opcode = OP_Null;
pOp->p1 = 1;
pOp->p2 = regPrev;
iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;
for(i=0; i<nResultCol; i++){
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[i].pExpr);
if( i<nResultCol-1 ){
sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i);
}else{
sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i);
}
sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ);
sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
}
assert( sqlite3VdbeCurrentAddr(v)==iJump );
sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1);
break;
}
case WHERE_DISTINCT_UNIQUE: {
sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);
break;
}
default: {
assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED );
codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol, regResult);
break;
}
}
if( pOrderBy==0 ){
codeOffset(v, p->iOffset, iContinue);
}
}
switch( eDest ){
/* In this mode, write each query result to the key of the temporary
** table iParm.
*/
#ifndef SQLITE_OMIT_COMPOUND_SELECT
case SRT_Union: {
int r1;
r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
sqlite3ReleaseTempReg(pParse, r1);
break;
}
/* Construct a record from the query result, but instead of
** saving that record, use it as a key to delete elements from
** the temporary table iParm.
*/
case SRT_Except: {
sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nResultCol);
break;
}
#endif /* SQLITE_OMIT_COMPOUND_SELECT */
/* Store the result as data using a unique key.
*/
case SRT_DistTable:
case SRT_Table:
case SRT_EphemTab: {
int r1 = sqlite3GetTempReg(pParse);
testcase( eDest==SRT_Table );
testcase( eDest==SRT_EphemTab );
sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);
#ifndef SQLITE_OMIT_CTE
if( eDest==SRT_DistTable ){
/* If the destination is DistTable, then cursor (iParm+1) is open
** on an ephemeral index. If the current row is already present
** in the index, do not write it to the output. If not, add the
** current row to the index and proceed with writing it to the
** output table as well. */
int addr = sqlite3VdbeCurrentAddr(v) + 4;
sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, addr, r1, 0);
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r1);
assert( pOrderBy==0 );
}
#endif
if( pOrderBy ){
pushOntoSorter(pParse, pOrderBy, p, r1);
}else{
int r2 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);
sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
sqlite3ReleaseTempReg(pParse, r2);
}
sqlite3ReleaseTempReg(pParse, r1);
break;
}
#ifndef SQLITE_OMIT_SUBQUERY
/* If we are creating a set for an "expr IN (SELECT ...)" construct,
** then there should be a single item on the stack. Write this
** item into the set table with bogus data.
*/
case SRT_Set: {
assert( nResultCol==1 );
pDest->affSdst =
sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst);
if( pOrderBy ){
/* At first glance you would think we could optimize out the
** ORDER BY in this case since the order of entries in the set
** does not matter. But there might be a LIMIT clause, in which
** case the order does matter */
|
| ︙ | ︙ | |||
99945 99946 99947 99948 99949 99950 99951 |
}
/* If this is a scalar select that is part of an expression, then
** store the results in the appropriate memory cell and break out
** of the scan loop.
*/
case SRT_Mem: {
| | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 100206 100207 100208 100209 100210 100211 100212 100213 100214 100215 100216 100217 100218 100219 100220 100221 100222 100223 100224 100225 100226 100227 100228 100229 100230 100231 100232 100233 100234 100235 100236 100237 100238 100239 100240 100241 100242 100243 100244 100245 100246 100247 100248 100249 100250 100251 100252 100253 100254 100255 100256 100257 100258 100259 100260 100261 100262 100263 100264 100265 100266 100267 100268 100269 100270 100271 100272 100273 100274 100275 100276 100277 100278 100279 100280 100281 100282 100283 100284 100285 100286 100287 100288 100289 100290 100291 100292 100293 100294 100295 100296 100297 |
}
/* If this is a scalar select that is part of an expression, then
** store the results in the appropriate memory cell and break out
** of the scan loop.
*/
case SRT_Mem: {
assert( nResultCol==1 );
if( pOrderBy ){
pushOntoSorter(pParse, pOrderBy, p, regResult);
}else{
sqlite3ExprCodeMove(pParse, regResult, iParm, 1);
/* The LIMIT clause will jump out of the loop for us */
}
break;
}
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
/* Send the data to the callback function or to a subroutine. In the
** case of a subroutine, the subroutine itself is responsible for
** popping the data from the stack.
*/
case SRT_Coroutine:
case SRT_Output: {
testcase( eDest==SRT_Coroutine );
testcase( eDest==SRT_Output );
if( pOrderBy ){
int r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);
pushOntoSorter(pParse, pOrderBy, p, r1);
sqlite3ReleaseTempReg(pParse, r1);
}else if( eDest==SRT_Coroutine ){
sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
}else{
sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);
sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);
}
break;
}
#ifndef SQLITE_OMIT_CTE
/* Write the results into a priority queue that is order according to
** pDest->pOrderBy (in pSO). pDest->iSDParm (in iParm) is the cursor for an
** index with pSO->nExpr+2 columns. Build a key using pSO for the first
** pSO->nExpr columns, then make sure all keys are unique by adding a
** final OP_Sequence column. The last column is the record as a blob.
*/
case SRT_DistQueue:
case SRT_Queue: {
int nKey;
int r1, r2, r3;
int addrTest = 0;
ExprList *pSO;
pSO = pDest->pOrderBy;
assert( pSO );
nKey = pSO->nExpr;
r1 = sqlite3GetTempReg(pParse);
r2 = sqlite3GetTempRange(pParse, nKey+2);
r3 = r2+nKey+1;
sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r3);
if( eDest==SRT_DistQueue ){
/* If the destination is DistQueue, then cursor (iParm+1) is open
** on a second ephemeral index that holds all values every previously
** added to the queue. Only add this new value if it has never before
** been added */
addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0);
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
}
for(i=0; i<nKey; i++){
sqlite3VdbeAddOp2(v, OP_SCopy,
regResult + pSO->a[i].u.x.iOrderByCol - 1,
r2+i);
}
sqlite3VdbeAddOp2(v, OP_Sequence, iParm, r2+nKey);
sqlite3VdbeAddOp3(v, OP_MakeRecord, r2, nKey+2, r1);
sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
if( addrTest ) sqlite3VdbeJumpHere(v, addrTest);
sqlite3ReleaseTempReg(pParse, r1);
sqlite3ReleaseTempRange(pParse, r2, nKey+2);
break;
}
#endif /* SQLITE_OMIT_CTE */
#if !defined(SQLITE_OMIT_TRIGGER)
/* Discard the results. This is used for SELECT statements inside
** the body of a TRIGGER. The purpose of such selects is to call
** user-defined functions that have side effects. We do not care
** about the actual results of the select.
*/
|
| ︙ | ︙ | |||
100066 100067 100068 100069 100070 100071 100072 | ** then the KeyInfo structure is appropriate for initializing a virtual ** index to implement a DISTINCT test. ** ** Space to hold the KeyInfo structure is obtain from malloc. The calling ** function is responsible for seeing that this structure is eventually ** freed. */ | | | | 100373 100374 100375 100376 100377 100378 100379 100380 100381 100382 100383 100384 100385 100386 100387 100388 100389 100390 100391 100392 100393 100394 100395 |
** then the KeyInfo structure is appropriate for initializing a virtual
** index to implement a DISTINCT test.
**
** Space to hold the KeyInfo structure is obtain from malloc. The calling
** function is responsible for seeing that this structure is eventually
** freed.
*/
static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList, int nExtra){
int nExpr;
KeyInfo *pInfo;
struct ExprList_item *pItem;
sqlite3 *db = pParse->db;
int i;
nExpr = pList->nExpr;
pInfo = sqlite3KeyInfoAlloc(db, nExpr+nExtra, 1);
if( pInfo ){
assert( sqlite3KeyInfoIsWriteable(pInfo) );
for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
CollSeq *pColl;
pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
if( !pColl ) pColl = db->pDfltColl;
pInfo->aColl[i] = pColl;
|
| ︙ | ︙ | |||
100215 100216 100217 100218 100219 100220 100221 |
regRowid = sqlite3GetTempReg(pParse);
}
if( p->selFlags & SF_UseSorter ){
int regSortOut = ++pParse->nMem;
int ptab2 = pParse->nTab++;
sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
| | | | 100522 100523 100524 100525 100526 100527 100528 100529 100530 100531 100532 100533 100534 100535 100536 100537 100538 100539 100540 100541 100542 |
regRowid = sqlite3GetTempReg(pParse);
}
if( p->selFlags & SF_UseSorter ){
int regSortOut = ++pParse->nMem;
int ptab2 = pParse->nTab++;
sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
codeOffset(v, p->iOffset, addrContinue);
sqlite3VdbeAddOp2(v, OP_SorterData, iTab, regSortOut);
sqlite3VdbeAddOp3(v, OP_Column, ptab2, pOrderBy->nExpr+1, regRow);
sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE);
}else{
addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak);
codeOffset(v, p->iOffset, addrContinue);
sqlite3VdbeAddOp3(v, OP_Column, iTab, pOrderBy->nExpr+1, regRow);
}
switch( eDest ){
case SRT_Table:
case SRT_EphemTab: {
testcase( eDest==SRT_Table );
testcase( eDest==SRT_EphemTab );
|
| ︙ | ︙ | |||
100400 100401 100402 100403 100404 100405 100406 |
NameContext sNC;
Expr *p = pS->pEList->a[iCol].pExpr;
sNC.pSrcList = pS->pSrc;
sNC.pNext = pNC;
sNC.pParse = pNC->pParse;
zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol, &estWidth);
}
| | | 100707 100708 100709 100710 100711 100712 100713 100714 100715 100716 100717 100718 100719 100720 100721 |
NameContext sNC;
Expr *p = pS->pEList->a[iCol].pExpr;
sNC.pSrcList = pS->pSrc;
sNC.pNext = pNC;
sNC.pParse = pNC->pParse;
zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol, &estWidth);
}
}else if( pTab->pSchema ){
/* A real table */
assert( !pS );
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
#ifdef SQLITE_ENABLE_COLUMN_METADATA
if( iCol<0 ){
zType = "INTEGER";
|
| ︙ | ︙ | |||
100561 100562 100563 100564 100565 100566 100567 |
char *zName = 0;
zName = sqlite3MPrintf(db, "%s.%s", pTab->zName, zCol);
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
}else{
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);
}
}else{
| > > | < | 100868 100869 100870 100871 100872 100873 100874 100875 100876 100877 100878 100879 100880 100881 100882 100883 100884 |
char *zName = 0;
zName = sqlite3MPrintf(db, "%s.%s", pTab->zName, zCol);
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
}else{
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);
}
}else{
const char *z = pEList->a[i].zSpan;
z = z==0 ? sqlite3MPrintf(db, "column%d", i+1) : sqlite3DbStrDup(db, z);
sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);
}
}
generateColumnTypes(pParse, pTabList, pEList);
}
/*
** Given a an expression list (which is really the list of expressions
|
| ︙ | ︙ | |||
100784 100785 100786 100787 100788 100789 100790 | ** keywords. Or NULL if those keywords are omitted. iLimit and iOffset ** are the integer memory register numbers for counters used to compute ** the limit and offset. If there is no limit and/or offset, then ** iLimit and iOffset are negative. ** ** This routine changes the values of iLimit and iOffset only if ** a limit or offset is defined by pLimit and pOffset. iLimit and | | | > > > > > | 101092 101093 101094 101095 101096 101097 101098 101099 101100 101101 101102 101103 101104 101105 101106 101107 101108 101109 101110 101111 101112 |
** keywords. Or NULL if those keywords are omitted. iLimit and iOffset
** are the integer memory register numbers for counters used to compute
** the limit and offset. If there is no limit and/or offset, then
** iLimit and iOffset are negative.
**
** This routine changes the values of iLimit and iOffset only if
** a limit or offset is defined by pLimit and pOffset. iLimit and
** iOffset should have been preset to appropriate default values (zero)
** prior to calling this routine.
**
** The iOffset register (if it exists) is initialized to the value
** of the OFFSET. The iLimit register is initialized to LIMIT. Register
** iOffset+1 is initialized to LIMIT+OFFSET.
**
** Only if pLimit!=0 or pOffset!=0 do the limit registers get
** redefined. The UNION ALL operator uses this property to force
** the reuse of the same limit and offset registers across multiple
** SELECT statements.
*/
static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
Vdbe *v = 0;
|
| ︙ | ︙ | |||
100809 100810 100811 100812 100813 100814 100815 |
** no rows.
*/
sqlite3ExprCacheClear(pParse);
assert( p->pOffset==0 || p->pLimit!=0 );
if( p->pLimit ){
p->iLimit = iLimit = ++pParse->nMem;
v = sqlite3GetVdbe(pParse);
| | | 101122 101123 101124 101125 101126 101127 101128 101129 101130 101131 101132 101133 101134 101135 101136 |
** no rows.
*/
sqlite3ExprCacheClear(pParse);
assert( p->pOffset==0 || p->pLimit!=0 );
if( p->pLimit ){
p->iLimit = iLimit = ++pParse->nMem;
v = sqlite3GetVdbe(pParse);
assert( v!=0 );
if( sqlite3ExprIsInteger(p->pLimit, &n) ){
sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);
VdbeComment((v, "LIMIT counter"));
if( n==0 ){
sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);
}else if( n>=0 && p->nSelectRow>(u64)n ){
p->nSelectRow = n;
|
| ︙ | ︙ | |||
100864 100865 100866 100867 100868 100869 100870 |
}
assert( iCol>=0 );
if( pRet==0 && iCol<p->pEList->nExpr ){
pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
}
return pRet;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < | 101177 101178 101179 101180 101181 101182 101183 101184 101185 101186 101187 101188 101189 101190 101191 101192 101193 101194 101195 101196 101197 101198 101199 101200 101201 101202 101203 101204 101205 101206 101207 101208 101209 101210 101211 101212 101213 101214 101215 101216 101217 101218 101219 101220 101221 101222 101223 101224 101225 101226 101227 101228 101229 101230 101231 101232 101233 101234 101235 101236 101237 101238 101239 101240 101241 101242 101243 101244 101245 101246 101247 101248 101249 101250 101251 101252 101253 101254 101255 101256 101257 101258 101259 101260 101261 101262 101263 101264 101265 101266 101267 101268 101269 101270 101271 101272 101273 101274 101275 101276 101277 101278 101279 101280 101281 101282 101283 101284 101285 101286 101287 101288 101289 101290 101291 101292 101293 101294 101295 101296 101297 101298 101299 101300 101301 101302 101303 101304 101305 101306 101307 101308 101309 101310 101311 101312 101313 101314 101315 101316 101317 101318 101319 101320 101321 101322 101323 101324 101325 101326 101327 101328 101329 101330 101331 101332 101333 101334 101335 101336 101337 101338 101339 101340 101341 101342 101343 101344 101345 101346 101347 101348 101349 101350 101351 101352 101353 101354 101355 101356 101357 101358 101359 101360 101361 101362 101363 101364 101365 101366 101367 101368 101369 101370 101371 101372 101373 101374 101375 101376 101377 101378 101379 101380 101381 101382 101383 101384 101385 101386 101387 101388 101389 101390 101391 101392 101393 101394 101395 |
}
assert( iCol>=0 );
if( pRet==0 && iCol<p->pEList->nExpr ){
pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);
}
return pRet;
}
/*
** The select statement passed as the second parameter is a compound SELECT
** with an ORDER BY clause. This function allocates and returns a KeyInfo
** structure suitable for implementing the ORDER BY.
**
** Space to hold the KeyInfo structure is obtained from malloc. The calling
** function is responsible for ensuring that this structure is eventually
** freed.
*/
static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){
ExprList *pOrderBy = p->pOrderBy;
int nOrderBy = p->pOrderBy->nExpr;
sqlite3 *db = pParse->db;
KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);
if( pRet ){
int i;
for(i=0; i<nOrderBy; i++){
struct ExprList_item *pItem = &pOrderBy->a[i];
Expr *pTerm = pItem->pExpr;
CollSeq *pColl;
if( pTerm->flags & EP_Collate ){
pColl = sqlite3ExprCollSeq(pParse, pTerm);
}else{
pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);
if( pColl==0 ) pColl = db->pDfltColl;
pOrderBy->a[i].pExpr =
sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);
}
assert( sqlite3KeyInfoIsWriteable(pRet) );
pRet->aColl[i] = pColl;
pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;
}
}
return pRet;
}
#ifndef SQLITE_OMIT_CTE
/*
** This routine generates VDBE code to compute the content of a WITH RECURSIVE
** query of the form:
**
** <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)
** \___________/ \_______________/
** p->pPrior p
**
**
** There is exactly one reference to the recursive-table in the FROM clause
** of recursive-query, marked with the SrcList->a[].isRecursive flag.
**
** The setup-query runs once to generate an initial set of rows that go
** into a Queue table. Rows are extracted from the Queue table one by
** one. Each row extracted from Queue is output to pDest. Then the single
** extracted row (now in the iCurrent table) becomes the content of the
** recursive-table for a recursive-query run. The output of the recursive-query
** is added back into the Queue table. Then another row is extracted from Queue
** and the iteration continues until the Queue table is empty.
**
** If the compound query operator is UNION then no duplicate rows are ever
** inserted into the Queue table. The iDistinct table keeps a copy of all rows
** that have ever been inserted into Queue and causes duplicates to be
** discarded. If the operator is UNION ALL, then duplicates are allowed.
**
** If the query has an ORDER BY, then entries in the Queue table are kept in
** ORDER BY order and the first entry is extracted for each cycle. Without
** an ORDER BY, the Queue table is just a FIFO.
**
** If a LIMIT clause is provided, then the iteration stops after LIMIT rows
** have been output to pDest. A LIMIT of zero means to output no rows and a
** negative LIMIT means to output all rows. If there is also an OFFSET clause
** with a positive value, then the first OFFSET outputs are discarded rather
** than being sent to pDest. The LIMIT count does not begin until after OFFSET
** rows have been skipped.
*/
static void generateWithRecursiveQuery(
Parse *pParse, /* Parsing context */
Select *p, /* The recursive SELECT to be coded */
SelectDest *pDest /* What to do with query results */
){
SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */
int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */
Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
Select *pSetup = p->pPrior; /* The setup query */
int addrTop; /* Top of the loop */
int addrCont, addrBreak; /* CONTINUE and BREAK addresses */
int iCurrent = 0; /* The Current table */
int regCurrent; /* Register holding Current table */
int iQueue; /* The Queue table */
int iDistinct = 0; /* To ensure unique results if UNION */
int eDest = SRT_Table; /* How to write to Queue */
SelectDest destQueue; /* SelectDest targetting the Queue table */
int i; /* Loop counter */
int rc; /* Result code */
ExprList *pOrderBy; /* The ORDER BY clause */
Expr *pLimit, *pOffset; /* Saved LIMIT and OFFSET */
int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */
/* Obtain authorization to do a recursive query */
if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
/* Process the LIMIT and OFFSET clauses, if they exist */
addrBreak = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, addrBreak);
pLimit = p->pLimit;
pOffset = p->pOffset;
regLimit = p->iLimit;
regOffset = p->iOffset;
p->pLimit = p->pOffset = 0;
p->iLimit = p->iOffset = 0;
pOrderBy = p->pOrderBy;
/* Locate the cursor number of the Current table */
for(i=0; ALWAYS(i<pSrc->nSrc); i++){
if( pSrc->a[i].isRecursive ){
iCurrent = pSrc->a[i].iCursor;
break;
}
}
/* Allocate cursors numbers for Queue and Distinct. The cursor number for
** the Distinct table must be exactly one greater than Queue in order
** for the SRT_DistTable and SRT_DistQueue destinations to work. */
iQueue = pParse->nTab++;
if( p->op==TK_UNION ){
eDest = pOrderBy ? SRT_DistQueue : SRT_DistTable;
iDistinct = pParse->nTab++;
}else{
eDest = pOrderBy ? SRT_Queue : SRT_Table;
}
sqlite3SelectDestInit(&destQueue, eDest, iQueue);
/* Allocate cursors for Current, Queue, and Distinct. */
regCurrent = ++pParse->nMem;
sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);
if( pOrderBy ){
KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,
(char*)pKeyInfo, P4_KEYINFO);
destQueue.pOrderBy = pOrderBy;
}else{
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);
}
VdbeComment((v, "Queue table"));
if( iDistinct ){
p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);
p->selFlags |= SF_UsesEphemeral;
}
/* Detach the ORDER BY clause from the compound SELECT */
p->pOrderBy = 0;
/* Store the results of the setup-query in Queue. */
rc = sqlite3Select(pParse, pSetup, &destQueue);
if( rc ) goto end_of_recursive_query;
/* Find the next row in the Queue and output that row */
addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak);
/* Transfer the next row in Queue over to Current */
sqlite3VdbeAddOp1(v, OP_NullRow, iCurrent); /* To reset column cache */
if( pOrderBy ){
sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent);
}else{
sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent);
}
sqlite3VdbeAddOp1(v, OP_Delete, iQueue);
/* Output the single row in Current */
addrCont = sqlite3VdbeMakeLabel(v);
codeOffset(v, regOffset, addrCont);
selectInnerLoop(pParse, p, p->pEList, iCurrent,
0, 0, pDest, addrCont, addrBreak);
if( regLimit ) sqlite3VdbeAddOp3(v, OP_IfZero, regLimit, addrBreak, -1);
sqlite3VdbeResolveLabel(v, addrCont);
/* Execute the recursive SELECT taking the single row in Current as
** the value for the recursive-table. Store the results in the Queue.
*/
p->pPrior = 0;
sqlite3Select(pParse, p, &destQueue);
assert( p->pPrior==0 );
p->pPrior = pSetup;
/* Keep running the loop until the Queue is empty */
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
sqlite3VdbeResolveLabel(v, addrBreak);
end_of_recursive_query:
p->pOrderBy = pOrderBy;
p->pLimit = pLimit;
p->pOffset = pOffset;
return;
}
#endif /* SQLITE_OMIT_CTE */
/* Forward references */
static int multiSelectOrderBy(
Parse *pParse, /* Parsing context */
Select *p, /* The right-most of SELECTs to be coded */
SelectDest *pDest /* What to do with query results */
);
/*
** This routine is called to process a compound query form from
** two or more separate queries using UNION, UNION ALL, EXCEPT, or
** INTERSECT
**
** "p" points to the right-most of the two queries. the query on the
** left is p->pPrior. The left query could also be a compound query
|
| ︙ | ︙ | |||
100918 100919 100920 100921 100922 100923 100924 | int rc = SQLITE_OK; /* Success code from a subroutine */ Select *pPrior; /* Another SELECT immediately to our left */ Vdbe *v; /* Generate code to this VDBE */ SelectDest dest; /* Alternative data destination */ Select *pDelete = 0; /* Chain of simple selects to delete */ sqlite3 *db; /* Database connection */ #ifndef SQLITE_OMIT_EXPLAIN | | | > | 101425 101426 101427 101428 101429 101430 101431 101432 101433 101434 101435 101436 101437 101438 101439 101440 101441 101442 101443 101444 101445 101446 101447 |
int rc = SQLITE_OK; /* Success code from a subroutine */
Select *pPrior; /* Another SELECT immediately to our left */
Vdbe *v; /* Generate code to this VDBE */
SelectDest dest; /* Alternative data destination */
Select *pDelete = 0; /* Chain of simple selects to delete */
sqlite3 *db; /* Database connection */
#ifndef SQLITE_OMIT_EXPLAIN
int iSub1 = 0; /* EQP id of left-hand query */
int iSub2 = 0; /* EQP id of right-hand query */
#endif
/* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
*/
assert( p && p->pPrior ); /* Calling function guarantees this much */
assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );
db = pParse->db;
pPrior = p->pPrior;
assert( pPrior->pRightmost!=pPrior );
assert( pPrior->pRightmost==p->pRightmost );
dest = *pDest;
if( pPrior->pOrderBy ){
sqlite3ErrorMsg(pParse,"ORDER BY clause should come after %s not before",
|
| ︙ | ︙ | |||
100970 100971 100972 100973 100974 100975 100976 100977 100978 100979 100980 100981 |
}else{
sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
" do not have the same number of result columns", selectOpName(p->op));
}
rc = 1;
goto multi_select_end;
}
/* Compound SELECTs that have an ORDER BY clause are handled separately.
*/
if( p->pOrderBy ){
return multiSelectOrderBy(pParse, p, pDest);
| > > > > > > | | 101478 101479 101480 101481 101482 101483 101484 101485 101486 101487 101488 101489 101490 101491 101492 101493 101494 101495 101496 101497 101498 101499 101500 101501 101502 101503 |
}else{
sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
" do not have the same number of result columns", selectOpName(p->op));
}
rc = 1;
goto multi_select_end;
}
#ifndef SQLITE_OMIT_CTE
if( p->selFlags & SF_Recursive ){
generateWithRecursiveQuery(pParse, p, &dest);
}else
#endif
/* Compound SELECTs that have an ORDER BY clause are handled separately.
*/
if( p->pOrderBy ){
return multiSelectOrderBy(pParse, p, pDest);
}else
/* Generate code for the left and right SELECT statements.
*/
switch( p->op ){
case TK_ALL: {
int addr = 0;
int nLimit;
|
| ︙ | ︙ | |||
101110 101111 101112 101113 101114 101115 101116 |
generateColumnNames(pParse, 0, pFirst->pEList);
}
iBreak = sqlite3VdbeMakeLabel(v);
iCont = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak);
iStart = sqlite3VdbeCurrentAddr(v);
| | | 101624 101625 101626 101627 101628 101629 101630 101631 101632 101633 101634 101635 101636 101637 101638 |
generateColumnNames(pParse, 0, pFirst->pEList);
}
iBreak = sqlite3VdbeMakeLabel(v);
iCont = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak);
iStart = sqlite3VdbeCurrentAddr(v);
selectInnerLoop(pParse, p, p->pEList, unionTab,
0, 0, &dest, iCont, iBreak);
sqlite3VdbeResolveLabel(v, iCont);
sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart);
sqlite3VdbeResolveLabel(v, iBreak);
sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
}
break;
|
| ︙ | ︙ | |||
101188 101189 101190 101191 101192 101193 101194 |
iCont = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak);
r1 = sqlite3GetTempReg(pParse);
iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);
sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
sqlite3ReleaseTempReg(pParse, r1);
| | | 101702 101703 101704 101705 101706 101707 101708 101709 101710 101711 101712 101713 101714 101715 101716 |
iCont = sqlite3VdbeMakeLabel(v);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak);
r1 = sqlite3GetTempReg(pParse);
iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);
sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
sqlite3ReleaseTempReg(pParse, r1);
selectInnerLoop(pParse, p, p->pEList, tab1,
0, 0, &dest, iCont, iBreak);
sqlite3VdbeResolveLabel(v, iCont);
sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart);
sqlite3VdbeResolveLabel(v, iBreak);
sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
break;
|
| ︙ | ︙ | |||
101310 101311 101312 101313 101314 101315 101316 |
sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);
sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
}
if( pParse->db->mallocFailed ) return 0;
/* Suppress the first OFFSET entries if there is an OFFSET clause
*/
| | | 101824 101825 101826 101827 101828 101829 101830 101831 101832 101833 101834 101835 101836 101837 101838 |
sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);
sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
}
if( pParse->db->mallocFailed ) return 0;
/* Suppress the first OFFSET entries if there is an OFFSET clause
*/
codeOffset(v, p->iOffset, iContinue);
switch( pDest->eDest ){
/* Store the result as data using a unique key.
*/
case SRT_Table:
case SRT_EphemTab: {
int r1 = sqlite3GetTempReg(pParse);
|
| ︙ | ︙ | |||
101599 101600 101601 101602 101603 101604 101605 |
if( aPermute ){
struct ExprList_item *pItem;
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
assert( pItem->u.x.iOrderByCol>0
&& pItem->u.x.iOrderByCol<=p->pEList->nExpr );
aPermute[i] = pItem->u.x.iOrderByCol - 1;
}
| < | < < < < < < < < < < < < < < < < | 102113 102114 102115 102116 102117 102118 102119 102120 102121 102122 102123 102124 102125 102126 102127 |
if( aPermute ){
struct ExprList_item *pItem;
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
assert( pItem->u.x.iOrderByCol>0
&& pItem->u.x.iOrderByCol<=p->pEList->nExpr );
aPermute[i] = pItem->u.x.iOrderByCol - 1;
}
pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
}else{
pKeyMerge = 0;
}
/* Reattach the ORDER BY clause to the query.
*/
p->pOrderBy = pOrderBy;
|
| ︙ | ︙ | |||
102038 102039 102040 102041 102042 102043 102044 102045 102046 102047 102048 102049 102050 102051 | ** an ORDER BY clause. Ticket #3773. We could relax this constraint ** somewhat by saying that the terms of the ORDER BY clause must ** appear as unmodified result columns in the outer query. But we ** have other optimizations in mind to deal with that case. ** ** (21) The subquery does not use LIMIT or the outer query is not ** DISTINCT. (See ticket [752e1646fc]). ** ** In this routine, the "p" parameter is a pointer to the outer query. ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. ** ** If flattening is not attempted, this routine is a no-op and returns 0. ** If flattening is attempted this routine returns 1. | > > > > > > > > | 102535 102536 102537 102538 102539 102540 102541 102542 102543 102544 102545 102546 102547 102548 102549 102550 102551 102552 102553 102554 102555 102556 | ** an ORDER BY clause. Ticket #3773. We could relax this constraint ** somewhat by saying that the terms of the ORDER BY clause must ** appear as unmodified result columns in the outer query. But we ** have other optimizations in mind to deal with that case. ** ** (21) The subquery does not use LIMIT or the outer query is not ** DISTINCT. (See ticket [752e1646fc]). ** ** (22) The subquery is not a recursive CTE. ** ** (23) The parent is not a recursive CTE, or the sub-query is not a ** compound query. This restriction is because transforming the ** parent to a compound query confuses the code that handles ** recursive queries in multiSelect(). ** ** ** In this routine, the "p" parameter is a pointer to the outer query. ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. ** ** If flattening is not attempted, this routine is a no-op and returns 0. ** If flattening is attempted this routine returns 1. |
| ︙ | ︙ | |||
102110 102111 102112 102113 102114 102115 102116 102117 102118 102119 102120 102121 102122 102123 |
return 0; /* Restriction (11) */
}
if( isAgg && pSub->pOrderBy ) return 0; /* Restriction (16) */
if( pSub->pLimit && p->pWhere ) return 0; /* Restriction (19) */
if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){
return 0; /* Restriction (21) */
}
/* OBSOLETE COMMENT 1:
** Restriction 3: If the subquery is a join, make sure the subquery is
** not used as the right operand of an outer join. Examples of why this
** is not allowed:
**
** t1 LEFT OUTER JOIN (t2 JOIN t3)
| > > | 102615 102616 102617 102618 102619 102620 102621 102622 102623 102624 102625 102626 102627 102628 102629 102630 |
return 0; /* Restriction (11) */
}
if( isAgg && pSub->pOrderBy ) return 0; /* Restriction (16) */
if( pSub->pLimit && p->pWhere ) return 0; /* Restriction (19) */
if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){
return 0; /* Restriction (21) */
}
if( pSub->selFlags & SF_Recursive ) return 0; /* Restriction (22) */
if( (p->selFlags & SF_Recursive) && pSub->pPrior ) return 0; /* (23) */
/* OBSOLETE COMMENT 1:
** Restriction 3: If the subquery is a join, make sure the subquery is
** not used as the right operand of an outer join. Examples of why this
** is not allowed:
**
** t1 LEFT OUTER JOIN (t2 JOIN t3)
|
| ︙ | ︙ | |||
102591 102592 102593 102594 102595 102596 102597 102598 102599 102600 102601 102602 102603 102604 | pNew->pOrderBy = 0; p->pPrior = 0; pNew->pLimit = 0; pNew->pOffset = 0; return WRC_Continue; } /* ** This routine is a Walker callback for "expanding" a SELECT statement. ** "Expanding" means to do the following: ** ** (1) Make sure VDBE cursor numbers have been assigned to every ** element of the FROM clause. ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 103098 103099 103100 103101 103102 103103 103104 103105 103106 103107 103108 103109 103110 103111 103112 103113 103114 103115 103116 103117 103118 103119 103120 103121 103122 103123 103124 103125 103126 103127 103128 103129 103130 103131 103132 103133 103134 103135 103136 103137 103138 103139 103140 103141 103142 103143 103144 103145 103146 103147 103148 103149 103150 103151 103152 103153 103154 103155 103156 103157 103158 103159 103160 103161 103162 103163 103164 103165 103166 103167 103168 103169 103170 103171 103172 103173 103174 103175 103176 103177 103178 103179 103180 103181 103182 103183 103184 103185 103186 103187 103188 103189 103190 103191 103192 103193 103194 103195 103196 103197 103198 103199 103200 103201 103202 103203 103204 103205 103206 103207 103208 103209 103210 103211 103212 103213 103214 103215 103216 103217 103218 103219 103220 103221 103222 103223 103224 103225 103226 103227 103228 103229 103230 103231 103232 103233 103234 103235 103236 103237 103238 103239 103240 103241 103242 103243 103244 103245 103246 103247 103248 103249 103250 103251 103252 103253 103254 103255 103256 103257 103258 103259 103260 103261 103262 103263 103264 103265 103266 103267 103268 103269 103270 103271 103272 103273 103274 103275 103276 103277 103278 103279 103280 103281 103282 103283 103284 103285 103286 103287 103288 103289 103290 103291 103292 103293 103294 103295 103296 103297 103298 103299 103300 103301 103302 |
pNew->pOrderBy = 0;
p->pPrior = 0;
pNew->pLimit = 0;
pNew->pOffset = 0;
return WRC_Continue;
}
#ifndef SQLITE_OMIT_CTE
/*
** Argument pWith (which may be NULL) points to a linked list of nested
** WITH contexts, from inner to outermost. If the table identified by
** FROM clause element pItem is really a common-table-expression (CTE)
** then return a pointer to the CTE definition for that table. Otherwise
** return NULL.
**
** If a non-NULL value is returned, set *ppContext to point to the With
** object that the returned CTE belongs to.
*/
static struct Cte *searchWith(
With *pWith, /* Current outermost WITH clause */
struct SrcList_item *pItem, /* FROM clause element to resolve */
With **ppContext /* OUT: WITH clause return value belongs to */
){
const char *zName;
if( pItem->zDatabase==0 && (zName = pItem->zName)!=0 ){
With *p;
for(p=pWith; p; p=p->pOuter){
int i;
for(i=0; i<p->nCte; i++){
if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){
*ppContext = p;
return &p->a[i];
}
}
}
}
return 0;
}
/* The code generator maintains a stack of active WITH clauses
** with the inner-most WITH clause being at the top of the stack.
**
** This routine pushes the WITH clause passed as the second argument
** onto the top of the stack. If argument bFree is true, then this
** WITH clause will never be popped from the stack. In this case it
** should be freed along with the Parse object. In other cases, when
** bFree==0, the With object will be freed along with the SELECT
** statement with which it is associated.
*/
SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){
assert( bFree==0 || pParse->pWith==0 );
if( pWith ){
pWith->pOuter = pParse->pWith;
pParse->pWith = pWith;
pParse->bFreeWith = bFree;
}
}
/*
** This function checks if argument pFrom refers to a CTE declared by
** a WITH clause on the stack currently maintained by the parser. And,
** if currently processing a CTE expression, if it is a recursive
** reference to the current CTE.
**
** If pFrom falls into either of the two categories above, pFrom->pTab
** and other fields are populated accordingly. The caller should check
** (pFrom->pTab!=0) to determine whether or not a successful match
** was found.
**
** Whether or not a match is found, SQLITE_OK is returned if no error
** occurs. If an error does occur, an error message is stored in the
** parser and some error code other than SQLITE_OK returned.
*/
static int withExpand(
Walker *pWalker,
struct SrcList_item *pFrom
){
Parse *pParse = pWalker->pParse;
sqlite3 *db = pParse->db;
struct Cte *pCte; /* Matched CTE (or NULL if no match) */
With *pWith; /* WITH clause that pCte belongs to */
assert( pFrom->pTab==0 );
pCte = searchWith(pParse->pWith, pFrom, &pWith);
if( pCte ){
Table *pTab;
ExprList *pEList;
Select *pSel;
Select *pLeft; /* Left-most SELECT statement */
int bMayRecursive; /* True if compound joined by UNION [ALL] */
With *pSavedWith; /* Initial value of pParse->pWith */
/* If pCte->zErr is non-NULL at this point, then this is an illegal
** recursive reference to CTE pCte. Leave an error in pParse and return
** early. If pCte->zErr is NULL, then this is not a recursive reference.
** In this case, proceed. */
if( pCte->zErr ){
sqlite3ErrorMsg(pParse, pCte->zErr, pCte->zName);
return SQLITE_ERROR;
}
assert( pFrom->pTab==0 );
pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
if( pTab==0 ) return WRC_Abort;
pTab->nRef = 1;
pTab->zName = sqlite3DbStrDup(db, pCte->zName);
pTab->iPKey = -1;
pTab->nRowEst = 1048576;
pTab->tabFlags |= TF_Ephemeral;
pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);
if( db->mallocFailed ) return SQLITE_NOMEM;
assert( pFrom->pSelect );
/* Check if this is a recursive CTE. */
pSel = pFrom->pSelect;
bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );
if( bMayRecursive ){
int i;
SrcList *pSrc = pFrom->pSelect->pSrc;
for(i=0; i<pSrc->nSrc; i++){
struct SrcList_item *pItem = &pSrc->a[i];
if( pItem->zDatabase==0
&& pItem->zName!=0
&& 0==sqlite3StrICmp(pItem->zName, pCte->zName)
){
pItem->pTab = pTab;
pItem->isRecursive = 1;
pTab->nRef++;
pSel->selFlags |= SF_Recursive;
}
}
}
/* Only one recursive reference is permitted. */
if( pTab->nRef>2 ){
sqlite3ErrorMsg(
pParse, "multiple references to recursive table: %s", pCte->zName
);
return SQLITE_ERROR;
}
assert( pTab->nRef==1 || ((pSel->selFlags&SF_Recursive) && pTab->nRef==2 ));
pCte->zErr = "circular reference: %s";
pSavedWith = pParse->pWith;
pParse->pWith = pWith;
sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel);
for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
pEList = pLeft->pEList;
if( pCte->pCols ){
if( pEList->nExpr!=pCte->pCols->nExpr ){
sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
pCte->zName, pEList->nExpr, pCte->pCols->nExpr
);
pParse->pWith = pSavedWith;
return SQLITE_ERROR;
}
pEList = pCte->pCols;
}
selectColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol);
if( bMayRecursive ){
if( pSel->selFlags & SF_Recursive ){
pCte->zErr = "multiple recursive references: %s";
}else{
pCte->zErr = "recursive reference in a subquery: %s";
}
sqlite3WalkSelect(pWalker, pSel);
}
pCte->zErr = 0;
pParse->pWith = pSavedWith;
}
return SQLITE_OK;
}
#endif
#ifndef SQLITE_OMIT_CTE
/*
** If the SELECT passed as the second argument has an associated WITH
** clause, pop it from the stack stored as part of the Parse object.
**
** This function is used as the xSelectCallback2() callback by
** sqlite3SelectExpand() when walking a SELECT tree to resolve table
** names and other FROM clause elements.
*/
static void selectPopWith(Walker *pWalker, Select *p){
Parse *pParse = pWalker->pParse;
if( p->pWith ){
assert( pParse->pWith==p->pWith );
pParse->pWith = p->pWith->pOuter;
}
}
#else
#define selectPopWith 0
#endif
/*
** This routine is a Walker callback for "expanding" a SELECT statement.
** "Expanding" means to do the following:
**
** (1) Make sure VDBE cursor numbers have been assigned to every
** element of the FROM clause.
**
|
| ︙ | ︙ | |||
102634 102635 102636 102637 102638 102639 102640 102641 102642 102643 102644 102645 102646 102647 102648 102649 102650 102651 102652 102653 102654 102655 102656 102657 102658 102659 102660 102661 102662 102663 102664 102665 |
return WRC_Abort;
}
if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){
return WRC_Prune;
}
pTabList = p->pSrc;
pEList = p->pEList;
/* Make sure cursor numbers have been assigned to all entries in
** the FROM clause of the SELECT statement.
*/
sqlite3SrcListAssignCursors(pParse, pTabList);
/* Look up every table named in the FROM clause of the select. If
** an entry of the FROM clause is a subquery instead of a table or view,
** then create a transient table structure to describe the subquery.
*/
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
Table *pTab;
if( pFrom->pTab!=0 ){
/* This statement has already been prepared. There is no need
** to go further. */
assert( i==0 );
return WRC_Prune;
}
if( pFrom->zName==0 ){
#ifndef SQLITE_OMIT_SUBQUERY
Select *pSel = pFrom->pSelect;
/* A sub-query in the FROM clause of a SELECT */
assert( pSel!=0 );
assert( pFrom->pTab==0 );
sqlite3WalkSelect(pWalker, pSel);
| > > > > > > > > > > | 103332 103333 103334 103335 103336 103337 103338 103339 103340 103341 103342 103343 103344 103345 103346 103347 103348 103349 103350 103351 103352 103353 103354 103355 103356 103357 103358 103359 103360 103361 103362 103363 103364 103365 103366 103367 103368 103369 103370 103371 103372 103373 |
return WRC_Abort;
}
if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){
return WRC_Prune;
}
pTabList = p->pSrc;
pEList = p->pEList;
sqlite3WithPush(pParse, p->pWith, 0);
/* Make sure cursor numbers have been assigned to all entries in
** the FROM clause of the SELECT statement.
*/
sqlite3SrcListAssignCursors(pParse, pTabList);
/* Look up every table named in the FROM clause of the select. If
** an entry of the FROM clause is a subquery instead of a table or view,
** then create a transient table structure to describe the subquery.
*/
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
Table *pTab;
assert( pFrom->isRecursive==0 || pFrom->pTab );
if( pFrom->isRecursive ) continue;
if( pFrom->pTab!=0 ){
/* This statement has already been prepared. There is no need
** to go further. */
assert( i==0 );
#ifndef SQLITE_OMIT_CTE
selectPopWith(pWalker, p);
#endif
return WRC_Prune;
}
#ifndef SQLITE_OMIT_CTE
if( withExpand(pWalker, pFrom) ) return WRC_Abort;
if( pFrom->pTab ) {} else
#endif
if( pFrom->zName==0 ){
#ifndef SQLITE_OMIT_SUBQUERY
Select *pSel = pFrom->pSelect;
/* A sub-query in the FROM clause of a SELECT */
assert( pSel!=0 );
assert( pFrom->pTab==0 );
sqlite3WalkSelect(pWalker, pSel);
|
| ︙ | ︙ | |||
102914 102915 102916 102917 102918 102919 102920 102921 102922 102923 102924 102925 102926 102927 102928 102929 102930 102931 102932 102933 102934 102935 102936 102937 102938 |
w.xExprCallback = exprWalkNoop;
w.pParse = pParse;
if( pParse->hasCompound ){
w.xSelectCallback = convertCompoundSelectToSubquery;
sqlite3WalkSelect(&w, pSelect);
}
w.xSelectCallback = selectExpander;
sqlite3WalkSelect(&w, pSelect);
}
#ifndef SQLITE_OMIT_SUBQUERY
/*
** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()
** interface.
**
** For each FROM-clause subquery, add Column.zType and Column.zColl
** information to the Table structure that represents the result set
** of that subquery.
**
** The Table structure that represents the result set was constructed
** by selectExpander() but the type and collation information was omitted
** at that point because identifiers had not yet been resolved. This
** routine is called after identifier resolution.
*/
| > | | | | > < | < | 103622 103623 103624 103625 103626 103627 103628 103629 103630 103631 103632 103633 103634 103635 103636 103637 103638 103639 103640 103641 103642 103643 103644 103645 103646 103647 103648 103649 103650 103651 103652 103653 103654 103655 103656 103657 103658 103659 103660 103661 103662 103663 103664 103665 103666 103667 103668 103669 103670 103671 103672 103673 103674 103675 103676 103677 103678 103679 103680 103681 103682 103683 103684 103685 103686 103687 103688 103689 103690 103691 103692 103693 103694 103695 |
w.xExprCallback = exprWalkNoop;
w.pParse = pParse;
if( pParse->hasCompound ){
w.xSelectCallback = convertCompoundSelectToSubquery;
sqlite3WalkSelect(&w, pSelect);
}
w.xSelectCallback = selectExpander;
w.xSelectCallback2 = selectPopWith;
sqlite3WalkSelect(&w, pSelect);
}
#ifndef SQLITE_OMIT_SUBQUERY
/*
** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()
** interface.
**
** For each FROM-clause subquery, add Column.zType and Column.zColl
** information to the Table structure that represents the result set
** of that subquery.
**
** The Table structure that represents the result set was constructed
** by selectExpander() but the type and collation information was omitted
** at that point because identifiers had not yet been resolved. This
** routine is called after identifier resolution.
*/
static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
Parse *pParse;
int i;
SrcList *pTabList;
struct SrcList_item *pFrom;
assert( p->selFlags & SF_Resolved );
if( (p->selFlags & SF_HasTypeInfo)==0 ){
p->selFlags |= SF_HasTypeInfo;
pParse = pWalker->pParse;
pTabList = p->pSrc;
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
Table *pTab = pFrom->pTab;
if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){
/* A sub-query in the FROM clause of a SELECT */
Select *pSel = pFrom->pSelect;
if( pSel ){
while( pSel->pPrior ) pSel = pSel->pPrior;
selectAddColumnTypeAndCollation(pParse, pTab, pSel);
}
}
}
}
}
#endif
/*
** This routine adds datatype and collating sequence information to
** the Table structures of all FROM-clause subqueries in a
** SELECT statement.
**
** Use this routine after name resolution.
*/
static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
#ifndef SQLITE_OMIT_SUBQUERY
Walker w;
memset(&w, 0, sizeof(w));
w.xSelectCallback2 = selectAddSubqueryTypeInfo;
w.xExprCallback = exprWalkNoop;
w.pParse = pParse;
sqlite3WalkSelect(&w, pSelect);
#endif
}
/*
** This routine sets up a SELECT statement for processing. The
|
| ︙ | ︙ | |||
103045 103046 103047 103048 103049 103050 103051 |
Expr *pE = pFunc->pExpr;
assert( !ExprHasProperty(pE, EP_xIsSelect) );
if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){
sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
"argument");
pFunc->iDistinct = -1;
}else{
| | | 103753 103754 103755 103756 103757 103758 103759 103760 103761 103762 103763 103764 103765 103766 103767 |
Expr *pE = pFunc->pExpr;
assert( !ExprHasProperty(pE, EP_xIsSelect) );
if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){
sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
"argument");
pFunc->iDistinct = -1;
}else{
KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0);
sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,
(char*)pKeyInfo, P4_KEYINFO);
}
}
}
}
|
| ︙ | ︙ | |||
103178 103179 103180 103181 103182 103183 103184 | #else # define explainSimpleCount(a,b,c) #endif /* ** Generate code for the SELECT statement given in the p argument. ** | < | < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < | 103886 103887 103888 103889 103890 103891 103892 103893 103894 103895 103896 103897 103898 103899 103900 103901 | #else # define explainSimpleCount(a,b,c) #endif /* ** Generate code for the SELECT statement given in the p argument. ** ** The results are returned according to the SelectDest structure. ** See comments in sqliteInt.h for further information. ** ** This routine returns the number of errors. If any errors are ** encountered, then an appropriate error message is left in ** pParse->zErrMsg. ** ** This routine does NOT free the Select structure passed in. The ** calling function needs to do that. |
| ︙ | ︙ | |||
103496 103497 103498 103499 103500 103501 103502 |
** extracted in pre-sorted order. If that is the case, then the
** OP_OpenEphemeral instruction will be changed to an OP_Noop once
** we figure out that the sorting index is not needed. The addrSortIndex
** variable is used to facilitate that change.
*/
if( pOrderBy ){
KeyInfo *pKeyInfo;
| | | 104162 104163 104164 104165 104166 104167 104168 104169 104170 104171 104172 104173 104174 104175 104176 |
** extracted in pre-sorted order. If that is the case, then the
** OP_OpenEphemeral instruction will be changed to an OP_Noop once
** we figure out that the sorting index is not needed. The addrSortIndex
** variable is used to facilitate that change.
*/
if( pOrderBy ){
KeyInfo *pKeyInfo;
pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 0);
pOrderBy->iECursor = pParse->nTab++;
p->addrOpenEphm[2] = addrSortIndex =
sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
pOrderBy->iECursor, pOrderBy->nExpr+2, 0,
(char*)pKeyInfo, P4_KEYINFO);
}else{
addrSortIndex = -1;
|
| ︙ | ︙ | |||
103528 103529 103530 103531 103532 103533 103534 |
/* Open a virtual index to use for the distinct set.
*/
if( p->selFlags & SF_Distinct ){
sDistinct.tabTnct = pParse->nTab++;
sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
sDistinct.tabTnct, 0, 0,
| | | 104194 104195 104196 104197 104198 104199 104200 104201 104202 104203 104204 104205 104206 104207 104208 |
/* Open a virtual index to use for the distinct set.
*/
if( p->selFlags & SF_Distinct ){
sDistinct.tabTnct = pParse->nTab++;
sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
sDistinct.tabTnct, 0, 0,
(char*)keyInfoFromExprList(pParse, p->pEList, 0),
P4_KEYINFO);
sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;
}else{
sDistinct.eTnctType = WHERE_DISTINCT_NOOP;
}
|
| ︙ | ︙ | |||
103562 103563 103564 103565 103566 103567 103568 |
*/
if( addrSortIndex>=0 && pOrderBy==0 ){
sqlite3VdbeChangeToNoop(v, addrSortIndex);
p->addrOpenEphm[2] = -1;
}
/* Use the standard inner loop. */
| | | 104228 104229 104230 104231 104232 104233 104234 104235 104236 104237 104238 104239 104240 104241 104242 |
*/
if( addrSortIndex>=0 && pOrderBy==0 ){
sqlite3VdbeChangeToNoop(v, addrSortIndex);
p->addrOpenEphm[2] = -1;
}
/* Use the standard inner loop. */
selectInnerLoop(pParse, p, pEList, -1, pOrderBy, &sDistinct, pDest,
sqlite3WhereContinueLabel(pWInfo),
sqlite3WhereBreakLabel(pWInfo));
/* End the database scan loop.
*/
sqlite3WhereEnd(pWInfo);
}else{
|
| ︙ | ︙ | |||
103652 103653 103654 103655 103656 103657 103658 |
/* If there is a GROUP BY clause we might need a sorting index to
** implement it. Allocate that sorting index now. If it turns out
** that we do not need it after all, the OP_SorterOpen instruction
** will be converted into a Noop.
*/
sAggInfo.sortingIdx = pParse->nTab++;
| | | 104318 104319 104320 104321 104322 104323 104324 104325 104326 104327 104328 104329 104330 104331 104332 |
/* If there is a GROUP BY clause we might need a sorting index to
** implement it. Allocate that sorting index now. If it turns out
** that we do not need it after all, the OP_SorterOpen instruction
** will be converted into a Noop.
*/
sAggInfo.sortingIdx = pParse->nTab++;
pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0);
addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
0, (char*)pKeyInfo, P4_KEYINFO);
/* Initialize memory locations used by GROUP BY aggregate processing
*/
iUseFlag = ++pParse->nMem;
|
| ︙ | ︙ | |||
103834 103835 103836 103837 103838 103839 103840 |
sqlite3VdbeResolveLabel(v, addrOutputRow);
addrOutputRow = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
VdbeComment((v, "Groupby result generator entry point"));
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
finalizeAggFunctions(pParse, &sAggInfo);
sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
| | | 104500 104501 104502 104503 104504 104505 104506 104507 104508 104509 104510 104511 104512 104513 104514 |
sqlite3VdbeResolveLabel(v, addrOutputRow);
addrOutputRow = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);
VdbeComment((v, "Groupby result generator entry point"));
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
finalizeAggFunctions(pParse, &sAggInfo);
sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
selectInnerLoop(pParse, p, p->pEList, -1, pOrderBy,
&sDistinct, pDest,
addrOutputRow+1, addrSetAbort);
sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
VdbeComment((v, "end groupby result generator"));
/* Generate a subroutine that will reset the group-by accumulator
*/
|
| ︙ | ︙ | |||
103977 103978 103979 103980 103981 103982 103983 |
}
sqlite3WhereEnd(pWInfo);
finalizeAggFunctions(pParse, &sAggInfo);
}
pOrderBy = 0;
sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);
| | | 104643 104644 104645 104646 104647 104648 104649 104650 104651 104652 104653 104654 104655 104656 104657 |
}
sqlite3WhereEnd(pWInfo);
finalizeAggFunctions(pParse, &sAggInfo);
}
pOrderBy = 0;
sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);
selectInnerLoop(pParse, p, p->pEList, -1, 0, 0,
pDest, addrEnd, addrEnd);
sqlite3ExprListDelete(db, pDel);
}
sqlite3VdbeResolveLabel(v, addrEnd);
} /* endif aggregate query */
|
| ︙ | ︙ | |||
104721 104722 104723 104724 104725 104726 104727 | ** The parser calls this routine when it sees an INSERT inside the ** body of a trigger. */ SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep( sqlite3 *db, /* The database connection */ Token *pTableName, /* Name of the table into which we insert */ IdList *pColumn, /* List of columns in pTableName to insert into */ | < < | < < | 105387 105388 105389 105390 105391 105392 105393 105394 105395 105396 105397 105398 105399 105400 105401 105402 105403 105404 105405 105406 105407 105408 105409 105410 105411 105412 105413 105414 105415 |
** The parser calls this routine when it sees an INSERT inside the
** body of a trigger.
*/
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
sqlite3 *db, /* The database connection */
Token *pTableName, /* Name of the table into which we insert */
IdList *pColumn, /* List of columns in pTableName to insert into */
Select *pSelect, /* A SELECT statement that supplies values */
u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
){
TriggerStep *pTriggerStep;
assert(pSelect != 0 || db->mallocFailed);
pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);
if( pTriggerStep ){
pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
pTriggerStep->pIdList = pColumn;
pTriggerStep->orconf = orconf;
}else{
sqlite3IdListDelete(db, pColumn);
}
sqlite3SelectDelete(db, pSelect);
return pTriggerStep;
}
/*
** Construct a trigger step that implements an UPDATE statement and return
|
| ︙ | ︙ | |||
105077 105078 105079 105080 105081 105082 105083 |
pParse->eOrconf
);
break;
}
case TK_INSERT: {
sqlite3Insert(pParse,
targetSrcList(pParse, pStep),
| < | 105739 105740 105741 105742 105743 105744 105745 105746 105747 105748 105749 105750 105751 105752 |
pParse->eOrconf
);
break;
}
case TK_INSERT: {
sqlite3Insert(pParse,
targetSrcList(pParse, pStep),
sqlite3SelectDup(db, pStep->pSelect, 0),
sqlite3IdListDup(db, pStep->pIdList),
pParse->eOrconf
);
break;
}
case TK_DELETE: {
|
| ︙ | ︙ | |||
105929 105930 105931 105932 105933 105934 105935 |
if( chngPk || hasFK || pTrigger ){
u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
oldmask |= sqlite3TriggerColmask(pParse,
pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
);
for(i=0; i<pTab->nCol; i++){
if( oldmask==0xffffffff
| | > | 106590 106591 106592 106593 106594 106595 106596 106597 106598 106599 106600 106601 106602 106603 106604 106605 106606 106607 |
if( chngPk || hasFK || pTrigger ){
u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);
oldmask |= sqlite3TriggerColmask(pParse,
pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError
);
for(i=0; i<pTab->nCol; i++){
if( oldmask==0xffffffff
|| (i<32 && (oldmask & MASKBIT32(i))!=0)
|| (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0
){
testcase( oldmask!=0xffffffff && i==31 );
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
}
}
if( chngRowid==0 && pPk==0 ){
sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
|
| ︙ | ︙ | |||
105966 105967 105968 105969 105970 105971 105972 |
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
}else{
j = aXRef[i];
if( j>=0 ){
sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
| | | 106628 106629 106630 106631 106632 106633 106634 106635 106636 106637 106638 106639 106640 106641 106642 |
for(i=0; i<pTab->nCol; i++){
if( i==pTab->iPKey ){
sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);
}else{
j = aXRef[i];
if( j>=0 ){
sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);
}else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){
/* This branch loads the value of a column that will not be changed
** into a register. This is done if there are no BEFORE triggers, or
** if there are one or more BEFORE triggers that use this value via
** a new.* reference in a trigger program.
*/
testcase( i==31 );
testcase( i==32 );
|
| ︙ | ︙ | |||
108828 108829 108830 108831 108832 108833 108834 |
){
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
** be the name of an indexed column with TEXT affinity. */
return 0;
}
assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
| | | 109490 109491 109492 109493 109494 109495 109496 109497 109498 109499 109500 109501 109502 109503 109504 |
){
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
** be the name of an indexed column with TEXT affinity. */
return 0;
}
assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
op = pRight->op;
if( op==TK_VARIABLE ){
Vdbe *pReprepare = pParse->pReprepare;
int iCol = pRight->iColumn;
pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE);
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
z = (char *)sqlite3_value_text(pVal);
|
| ︙ | ︙ | |||
109871 109872 109873 109874 109875 109876 109877 | sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1); sqlite3VdbeSetP4KeyInfo(pParse, pIdx); VdbeComment((v, "for %s", pTable->zName)); /* Fill the automatic index with content */ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); regRecord = sqlite3GetTempReg(pParse); | | | 110533 110534 110535 110536 110537 110538 110539 110540 110541 110542 110543 110544 110545 110546 110547 | sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1); sqlite3VdbeSetP4KeyInfo(pParse, pIdx); VdbeComment((v, "for %s", pTable->zName)); /* Fill the automatic index with content */ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); regRecord = sqlite3GetTempReg(pParse); sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0); sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); sqlite3VdbeJumpHere(v, addrTop); sqlite3ReleaseTempReg(pParse, regRecord); |
| ︙ | ︙ | |||
109912 109913 109914 109915 109916 109917 109918 |
/* Count the number of possible WHERE clause constraints referring
** to this virtual table */
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
if( pTerm->leftCursor != pSrc->iCursor ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
testcase( pTerm->eOperator & WO_IN );
testcase( pTerm->eOperator & WO_ISNULL );
| | > | 110574 110575 110576 110577 110578 110579 110580 110581 110582 110583 110584 110585 110586 110587 110588 110589 |
/* Count the number of possible WHERE clause constraints referring
** to this virtual table */
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
if( pTerm->leftCursor != pSrc->iCursor ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
testcase( pTerm->eOperator & WO_IN );
testcase( pTerm->eOperator & WO_ISNULL );
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
nTerm++;
}
/* If the ORDER BY clause contains only columns in the current
** virtual table then allocate space for the aOrderBy part of
** the sqlite3_index_info structure.
|
| ︙ | ︙ | |||
109964 109965 109966 109967 109968 109969 109970 |
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
u8 op;
if( pTerm->leftCursor != pSrc->iCursor ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
testcase( pTerm->eOperator & WO_IN );
testcase( pTerm->eOperator & WO_ISNULL );
| | > | 110627 110628 110629 110630 110631 110632 110633 110634 110635 110636 110637 110638 110639 110640 110641 110642 |
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
u8 op;
if( pTerm->leftCursor != pSrc->iCursor ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
testcase( pTerm->eOperator & WO_IN );
testcase( pTerm->eOperator & WO_ISNULL );
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
pIdxCons[j].iColumn = pTerm->u.leftColumn;
pIdxCons[j].iTermOffset = i;
op = (u8)pTerm->eOperator & WO_ALL;
if( op==WO_IN ) op = WO_EQ;
pIdxCons[j].op = op;
/* The direct assignment in the previous line is possible only because
|
| ︙ | ︙ | |||
111473 111474 111475 111476 111477 111478 111479 |
*/
if( pWC->nTerm>1 ){
int iTerm;
for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
Expr *pExpr = pWC->a[iTerm].pExpr;
if( &pWC->a[iTerm] == pTerm ) continue;
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
| > > | | 112137 112138 112139 112140 112141 112142 112143 112144 112145 112146 112147 112148 112149 112150 112151 112152 112153 |
*/
if( pWC->nTerm>1 ){
int iTerm;
for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
Expr *pExpr = pWC->a[iTerm].pExpr;
if( &pWC->a[iTerm] == pTerm ) continue;
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue;
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
}
if( pAndExpr ){
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
}
|
| ︙ | ︙ | |||
111569 111570 111571 111572 111573 111574 111575 |
{
/* Case 6: There is no usable index. We must do a complete
** scan of the entire table.
*/
static const u8 aStep[] = { OP_Next, OP_Prev };
static const u8 aStart[] = { OP_Rewind, OP_Last };
assert( bRev==0 || bRev==1 );
| > > > > > | | | | > | 112235 112236 112237 112238 112239 112240 112241 112242 112243 112244 112245 112246 112247 112248 112249 112250 112251 112252 112253 112254 112255 112256 112257 112258 |
{
/* Case 6: There is no usable index. We must do a complete
** scan of the entire table.
*/
static const u8 aStep[] = { OP_Next, OP_Prev };
static const u8 aStart[] = { OP_Rewind, OP_Last };
assert( bRev==0 || bRev==1 );
if( pTabItem->isRecursive ){
/* Tables marked isRecursive have only a single row that is stored in
** a pseudo-cursor. No need to Rewind or Next such cursors. */
pLevel->op = OP_Noop;
}else{
pLevel->op = aStep[bRev];
pLevel->p1 = iCur;
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
}
}
/* Insert code to test every subexpression that can be completely
** computed using the current set of tables.
*/
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
Expr *pE;
|
| ︙ | ︙ | |||
112357 112358 112359 112360 112361 112362 112363 112364 112365 112366 112367 112368 112369 112370 |
if( !pBuilder->pOrSet
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
&& pSrc->pIndex==0
&& !pSrc->viaCoroutine
&& !pSrc->notIndexed
&& HasRowid(pTab)
&& !pSrc->isCorrelated
){
/* Generate auto-index WhereLoops */
WhereTerm *pTerm;
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
if( pTerm->prereqRight & pNew->maskSelf ) continue;
if( termCanDriveIndex(pTerm, pSrc, 0) ){
| > | 113029 113030 113031 113032 113033 113034 113035 113036 113037 113038 113039 113040 113041 113042 113043 |
if( !pBuilder->pOrSet
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
&& pSrc->pIndex==0
&& !pSrc->viaCoroutine
&& !pSrc->notIndexed
&& HasRowid(pTab)
&& !pSrc->isCorrelated
&& !pSrc->isRecursive
){
/* Generate auto-index WhereLoops */
WhereTerm *pTerm;
WhereTerm *pWCEnd = pWC->a + pWC->nTerm;
for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){
if( pTerm->prereqRight & pNew->maskSelf ) continue;
if( termCanDriveIndex(pTerm, pSrc, 0) ){
|
| ︙ | ︙ | |||
114127 114128 114129 114130 114131 114132 114133 |
struct TrigEvent { int a; IdList * b; };
/*
** An instance of this structure holds the ATTACH key and the key type.
*/
struct AttachKey { int type; Token key; };
| < < < < < < < < | 114800 114801 114802 114803 114804 114805 114806 114807 114808 114809 114810 114811 114812 114813 |
struct TrigEvent { int a; IdList * b; };
/*
** An instance of this structure holds the ATTACH key and the key type.
*/
struct AttachKey { int type; Token key; };
/* This is a utility routine used to set the ExprSpan.zStart and
** ExprSpan.zEnd values of pOut so that the span covers the complete
** range of text beginning with pStart and going to the end of pEnd.
*/
static void spanSet(ExprSpan *pOut, Token *pStart, Token *pEnd){
pOut->zStart = pStart->z;
|
| ︙ | ︙ | |||
114258 114259 114260 114261 114262 114263 114264 | ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define YYCODETYPE unsigned char | | | | < < | < | < | < | | > | > | > | > | > | | | 114923 114924 114925 114926 114927 114928 114929 114930 114931 114932 114933 114934 114935 114936 114937 114938 114939 114940 114941 114942 114943 114944 114945 114946 114947 114948 114949 114950 114951 114952 114953 114954 114955 114956 114957 114958 114959 114960 114961 114962 114963 114964 114965 114966 114967 114968 |
** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser
** YYNSTATE the combined number of states.
** YYNRULE the number of rules in the grammar
** YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing.
*/
#define YYCODETYPE unsigned char
#define YYNOCODE 254
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 70
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
Select* yy3;
ExprList* yy14;
With* yy59;
SrcList* yy65;
struct LikeOp yy96;
Expr* yy132;
u8 yy186;
int yy328;
ExprSpan yy346;
struct TrigEvent yy378;
u16 yy381;
IdList* yy408;
struct {int value; int mask;} yy429;
TriggerStep* yy473;
struct LimitVal yy476;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL Parse *pParse;
#define sqlite3ParserARG_PDECL ,Parse *pParse
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
#define YYNSTATE 642
#define YYNRULE 327
#define YYFALLBACK 1
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
/* The yyzerominor constant is used to initialize instances of
** YYMINORTYPE objects to zero. */
|
| ︙ | ︙ | |||
114359 114360 114361 114362 114363 114364 114365 | ** yy_action. Used to detect hash collisions. ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < > > > > > | | | | | | | | | | | | | < < < < < < < > > > > > > > | | | | | | | | | | | < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | < | | | | | | | | | | | | | | | | | | < | > | | | | | | < | | > | | | | < | | | > | | | | < | | > | | | | | | < | > | | < < < | | > > > | | | | | | | | | | < < < | | > > > | | | | | | | | | | | | | < < < < < > > > > > | | | | | | | | | | | | | | | | < < < < | > > > > | | | | | | < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 115024 115025 115026 115027 115028 115029 115030 115031 115032 115033 115034 115035 115036 115037 115038 115039 115040 115041 115042 115043 115044 115045 115046 115047 115048 115049 115050 115051 115052 115053 115054 115055 115056 115057 115058 115059 115060 115061 115062 115063 115064 115065 115066 115067 115068 115069 115070 115071 115072 115073 115074 115075 115076 115077 115078 115079 115080 115081 115082 115083 115084 115085 115086 115087 115088 115089 115090 115091 115092 115093 115094 115095 115096 115097 115098 115099 115100 115101 115102 115103 115104 115105 115106 115107 115108 115109 115110 115111 115112 115113 115114 115115 115116 115117 115118 115119 115120 115121 115122 115123 115124 115125 115126 115127 115128 115129 115130 115131 115132 115133 115134 115135 115136 115137 115138 115139 115140 115141 115142 115143 115144 115145 115146 115147 115148 115149 115150 115151 115152 115153 115154 115155 115156 115157 115158 115159 115160 115161 115162 115163 115164 115165 115166 115167 115168 115169 115170 115171 115172 115173 115174 115175 115176 115177 115178 115179 115180 115181 115182 115183 115184 115185 115186 115187 115188 115189 115190 115191 115192 115193 115194 115195 115196 115197 115198 115199 115200 115201 115202 115203 115204 115205 115206 115207 115208 115209 115210 115211 115212 115213 115214 115215 115216 115217 115218 115219 115220 115221 115222 115223 115224 115225 115226 115227 115228 115229 115230 115231 115232 115233 115234 115235 115236 115237 115238 115239 115240 115241 115242 115243 115244 115245 115246 115247 115248 115249 115250 115251 115252 115253 115254 115255 115256 115257 115258 115259 115260 115261 115262 115263 115264 115265 115266 115267 115268 115269 115270 115271 115272 115273 115274 115275 115276 115277 115278 115279 115280 115281 115282 115283 115284 115285 115286 115287 115288 115289 115290 115291 115292 115293 115294 115295 115296 115297 115298 115299 115300 115301 115302 115303 115304 115305 115306 115307 115308 115309 115310 115311 115312 115313 115314 115315 115316 115317 115318 115319 115320 115321 115322 115323 115324 115325 115326 115327 115328 115329 115330 115331 115332 115333 115334 115335 115336 115337 115338 115339 115340 115341 115342 115343 115344 115345 115346 115347 115348 115349 115350 115351 115352 115353 115354 115355 115356 115357 115358 115359 115360 115361 115362 115363 115364 115365 115366 115367 115368 115369 115370 115371 115372 115373 115374 115375 115376 115377 115378 115379 115380 115381 115382 115383 115384 115385 115386 115387 115388 115389 115390 115391 115392 115393 115394 115395 115396 115397 115398 115399 115400 115401 115402 115403 115404 115405 115406 115407 115408 115409 115410 115411 115412 115413 115414 115415 115416 115417 115418 115419 115420 115421 115422 115423 115424 115425 115426 115427 115428 115429 115430 115431 115432 115433 115434 115435 115436 115437 115438 115439 115440 115441 115442 115443 115444 115445 115446 115447 115448 115449 115450 115451 115452 115453 115454 115455 115456 115457 115458 115459 115460 115461 115462 115463 115464 115465 115466 115467 115468 115469 115470 115471 115472 115473 115474 115475 115476 115477 115478 115479 115480 115481 115482 115483 115484 115485 115486 115487 115488 115489 115490 115491 115492 115493 115494 |
** yy_action. Used to detect hash collisions.
** yy_shift_ofst[] For each state, the offset into yy_action for
** shifting terminals.
** yy_reduce_ofst[] For each state, the offset into yy_action for
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
*/
#define YY_ACTTAB_COUNT (1497)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 306, 212, 432, 955, 639, 191, 955, 295, 559, 88,
/* 10 */ 88, 88, 88, 81, 86, 86, 86, 86, 85, 85,
/* 20 */ 84, 84, 84, 83, 330, 185, 184, 183, 635, 635,
/* 30 */ 292, 606, 606, 88, 88, 88, 88, 683, 86, 86,
/* 40 */ 86, 86, 85, 85, 84, 84, 84, 83, 330, 16,
/* 50 */ 436, 597, 89, 90, 80, 600, 599, 601, 601, 87,
/* 60 */ 87, 88, 88, 88, 88, 684, 86, 86, 86, 86,
/* 70 */ 85, 85, 84, 84, 84, 83, 330, 306, 559, 84,
/* 80 */ 84, 84, 83, 330, 65, 86, 86, 86, 86, 85,
/* 90 */ 85, 84, 84, 84, 83, 330, 635, 635, 634, 633,
/* 100 */ 182, 682, 550, 379, 376, 375, 17, 322, 606, 606,
/* 110 */ 371, 198, 479, 91, 374, 82, 79, 165, 85, 85,
/* 120 */ 84, 84, 84, 83, 330, 598, 635, 635, 107, 89,
/* 130 */ 90, 80, 600, 599, 601, 601, 87, 87, 88, 88,
/* 140 */ 88, 88, 186, 86, 86, 86, 86, 85, 85, 84,
/* 150 */ 84, 84, 83, 330, 306, 594, 594, 142, 328, 327,
/* 160 */ 484, 249, 344, 238, 635, 635, 634, 633, 585, 448,
/* 170 */ 526, 525, 229, 388, 1, 394, 450, 584, 449, 635,
/* 180 */ 635, 635, 635, 319, 395, 606, 606, 199, 157, 273,
/* 190 */ 382, 268, 381, 187, 635, 635, 634, 633, 311, 555,
/* 200 */ 266, 593, 593, 266, 347, 588, 89, 90, 80, 600,
/* 210 */ 599, 601, 601, 87, 87, 88, 88, 88, 88, 478,
/* 220 */ 86, 86, 86, 86, 85, 85, 84, 84, 84, 83,
/* 230 */ 330, 306, 272, 536, 634, 633, 146, 610, 197, 310,
/* 240 */ 575, 182, 482, 271, 379, 376, 375, 506, 21, 634,
/* 250 */ 633, 634, 633, 635, 635, 374, 611, 574, 548, 440,
/* 260 */ 111, 563, 606, 606, 634, 633, 324, 479, 608, 608,
/* 270 */ 608, 300, 435, 573, 119, 407, 210, 162, 562, 883,
/* 280 */ 592, 592, 306, 89, 90, 80, 600, 599, 601, 601,
/* 290 */ 87, 87, 88, 88, 88, 88, 506, 86, 86, 86,
/* 300 */ 86, 85, 85, 84, 84, 84, 83, 330, 620, 111,
/* 310 */ 635, 635, 361, 606, 606, 358, 249, 349, 248, 433,
/* 320 */ 243, 479, 586, 634, 633, 195, 611, 93, 119, 221,
/* 330 */ 575, 497, 534, 534, 89, 90, 80, 600, 599, 601,
/* 340 */ 601, 87, 87, 88, 88, 88, 88, 574, 86, 86,
/* 350 */ 86, 86, 85, 85, 84, 84, 84, 83, 330, 306,
/* 360 */ 77, 429, 638, 573, 589, 530, 240, 230, 242, 105,
/* 370 */ 249, 349, 248, 515, 588, 208, 460, 529, 564, 173,
/* 380 */ 634, 633, 970, 144, 430, 2, 424, 228, 380, 557,
/* 390 */ 606, 606, 190, 153, 159, 158, 514, 51, 632, 631,
/* 400 */ 630, 71, 536, 432, 954, 196, 610, 954, 614, 45,
/* 410 */ 18, 89, 90, 80, 600, 599, 601, 601, 87, 87,
/* 420 */ 88, 88, 88, 88, 261, 86, 86, 86, 86, 85,
/* 430 */ 85, 84, 84, 84, 83, 330, 306, 608, 608, 608,
/* 440 */ 542, 424, 402, 385, 241, 506, 451, 320, 211, 543,
/* 450 */ 164, 436, 386, 293, 451, 587, 108, 496, 111, 334,
/* 460 */ 391, 591, 424, 614, 27, 452, 453, 606, 606, 72,
/* 470 */ 257, 70, 259, 452, 339, 342, 564, 582, 68, 415,
/* 480 */ 469, 328, 327, 62, 614, 45, 110, 393, 89, 90,
/* 490 */ 80, 600, 599, 601, 601, 87, 87, 88, 88, 88,
/* 500 */ 88, 152, 86, 86, 86, 86, 85, 85, 84, 84,
/* 510 */ 84, 83, 330, 306, 110, 499, 520, 538, 402, 389,
/* 520 */ 424, 110, 566, 500, 593, 593, 454, 82, 79, 165,
/* 530 */ 424, 591, 384, 564, 340, 615, 188, 162, 424, 350,
/* 540 */ 616, 424, 614, 44, 606, 606, 445, 582, 300, 434,
/* 550 */ 151, 19, 614, 9, 568, 580, 348, 615, 469, 567,
/* 560 */ 614, 26, 616, 614, 45, 89, 90, 80, 600, 599,
/* 570 */ 601, 601, 87, 87, 88, 88, 88, 88, 411, 86,
/* 580 */ 86, 86, 86, 85, 85, 84, 84, 84, 83, 330,
/* 590 */ 306, 579, 110, 578, 521, 282, 433, 398, 400, 255,
/* 600 */ 486, 82, 79, 165, 487, 164, 82, 79, 165, 488,
/* 610 */ 488, 364, 387, 424, 544, 544, 509, 350, 362, 155,
/* 620 */ 191, 606, 606, 559, 642, 640, 333, 82, 79, 165,
/* 630 */ 305, 564, 507, 312, 357, 614, 45, 329, 596, 595,
/* 640 */ 194, 337, 89, 90, 80, 600, 599, 601, 601, 87,
/* 650 */ 87, 88, 88, 88, 88, 424, 86, 86, 86, 86,
/* 660 */ 85, 85, 84, 84, 84, 83, 330, 306, 20, 323,
/* 670 */ 150, 263, 211, 543, 421, 596, 595, 614, 22, 424,
/* 680 */ 193, 424, 284, 424, 391, 424, 509, 424, 577, 424,
/* 690 */ 186, 335, 424, 559, 424, 313, 120, 546, 606, 606,
/* 700 */ 67, 614, 47, 614, 50, 614, 48, 614, 100, 614,
/* 710 */ 99, 614, 101, 576, 614, 102, 614, 109, 326, 89,
/* 720 */ 90, 80, 600, 599, 601, 601, 87, 87, 88, 88,
/* 730 */ 88, 88, 424, 86, 86, 86, 86, 85, 85, 84,
/* 740 */ 84, 84, 83, 330, 306, 424, 311, 424, 585, 54,
/* 750 */ 424, 516, 517, 590, 614, 112, 424, 584, 424, 572,
/* 760 */ 424, 195, 424, 571, 424, 67, 424, 614, 94, 614,
/* 770 */ 98, 424, 614, 97, 264, 606, 606, 195, 614, 46,
/* 780 */ 614, 96, 614, 30, 614, 49, 614, 115, 614, 114,
/* 790 */ 418, 229, 388, 614, 113, 306, 89, 90, 80, 600,
/* 800 */ 599, 601, 601, 87, 87, 88, 88, 88, 88, 424,
/* 810 */ 86, 86, 86, 86, 85, 85, 84, 84, 84, 83,
/* 820 */ 330, 119, 424, 590, 110, 372, 606, 606, 195, 53,
/* 830 */ 250, 614, 29, 195, 472, 438, 729, 190, 302, 498,
/* 840 */ 14, 523, 641, 2, 614, 43, 306, 89, 90, 80,
/* 850 */ 600, 599, 601, 601, 87, 87, 88, 88, 88, 88,
/* 860 */ 424, 86, 86, 86, 86, 85, 85, 84, 84, 84,
/* 870 */ 83, 330, 424, 613, 964, 964, 354, 606, 606, 420,
/* 880 */ 312, 64, 614, 42, 391, 355, 283, 437, 301, 255,
/* 890 */ 414, 410, 495, 492, 614, 28, 471, 306, 89, 90,
/* 900 */ 80, 600, 599, 601, 601, 87, 87, 88, 88, 88,
/* 910 */ 88, 424, 86, 86, 86, 86, 85, 85, 84, 84,
/* 920 */ 84, 83, 330, 424, 110, 110, 110, 110, 606, 606,
/* 930 */ 110, 254, 13, 614, 41, 532, 531, 283, 481, 531,
/* 940 */ 457, 284, 119, 561, 356, 614, 40, 284, 306, 89,
/* 950 */ 78, 80, 600, 599, 601, 601, 87, 87, 88, 88,
/* 960 */ 88, 88, 424, 86, 86, 86, 86, 85, 85, 84,
/* 970 */ 84, 84, 83, 330, 110, 424, 341, 220, 555, 606,
/* 980 */ 606, 351, 555, 318, 614, 95, 413, 255, 83, 330,
/* 990 */ 284, 284, 255, 640, 333, 356, 255, 614, 39, 306,
/* 1000 */ 356, 90, 80, 600, 599, 601, 601, 87, 87, 88,
/* 1010 */ 88, 88, 88, 424, 86, 86, 86, 86, 85, 85,
/* 1020 */ 84, 84, 84, 83, 330, 424, 317, 316, 141, 465,
/* 1030 */ 606, 606, 219, 619, 463, 614, 10, 417, 462, 255,
/* 1040 */ 189, 510, 553, 351, 207, 363, 161, 614, 38, 315,
/* 1050 */ 218, 255, 255, 80, 600, 599, 601, 601, 87, 87,
/* 1060 */ 88, 88, 88, 88, 424, 86, 86, 86, 86, 85,
/* 1070 */ 85, 84, 84, 84, 83, 330, 76, 419, 255, 3,
/* 1080 */ 878, 461, 424, 247, 331, 331, 614, 37, 217, 76,
/* 1090 */ 419, 390, 3, 216, 215, 422, 4, 331, 331, 424,
/* 1100 */ 547, 12, 424, 545, 614, 36, 424, 541, 422, 424,
/* 1110 */ 540, 424, 214, 424, 408, 424, 539, 403, 605, 605,
/* 1120 */ 237, 614, 25, 119, 614, 24, 588, 408, 614, 45,
/* 1130 */ 118, 614, 35, 614, 34, 614, 33, 614, 23, 588,
/* 1140 */ 60, 223, 603, 602, 513, 378, 73, 74, 140, 139,
/* 1150 */ 424, 110, 265, 75, 426, 425, 59, 424, 610, 73,
/* 1160 */ 74, 549, 402, 404, 424, 373, 75, 426, 425, 604,
/* 1170 */ 138, 610, 614, 11, 392, 76, 419, 181, 3, 614,
/* 1180 */ 32, 271, 369, 331, 331, 493, 614, 31, 149, 608,
/* 1190 */ 608, 608, 607, 15, 422, 365, 614, 8, 137, 489,
/* 1200 */ 136, 190, 608, 608, 608, 607, 15, 485, 176, 135,
/* 1210 */ 7, 252, 477, 408, 174, 133, 175, 474, 57, 56,
/* 1220 */ 132, 130, 119, 76, 419, 588, 3, 468, 245, 464,
/* 1230 */ 171, 331, 331, 125, 123, 456, 447, 122, 446, 104,
/* 1240 */ 336, 231, 422, 166, 154, 73, 74, 332, 116, 431,
/* 1250 */ 121, 309, 75, 426, 425, 222, 106, 610, 308, 637,
/* 1260 */ 204, 408, 629, 627, 628, 6, 200, 428, 427, 290,
/* 1270 */ 203, 622, 201, 588, 62, 63, 289, 66, 419, 399,
/* 1280 */ 3, 401, 288, 92, 143, 331, 331, 287, 608, 608,
/* 1290 */ 608, 607, 15, 73, 74, 227, 422, 325, 69, 416,
/* 1300 */ 75, 426, 425, 612, 412, 610, 192, 61, 569, 209,
/* 1310 */ 396, 226, 278, 225, 383, 408, 527, 558, 276, 533,
/* 1320 */ 552, 528, 321, 523, 370, 508, 180, 588, 494, 179,
/* 1330 */ 366, 117, 253, 269, 522, 503, 608, 608, 608, 607,
/* 1340 */ 15, 551, 502, 58, 274, 524, 178, 73, 74, 304,
/* 1350 */ 501, 368, 303, 206, 75, 426, 425, 491, 360, 610,
/* 1360 */ 213, 177, 483, 131, 345, 298, 297, 296, 202, 294,
/* 1370 */ 480, 490, 466, 134, 172, 129, 444, 346, 470, 128,
/* 1380 */ 314, 459, 103, 127, 126, 148, 124, 167, 443, 235,
/* 1390 */ 608, 608, 608, 607, 15, 442, 439, 623, 234, 299,
/* 1400 */ 145, 583, 291, 377, 581, 160, 119, 156, 270, 636,
/* 1410 */ 971, 169, 279, 626, 520, 625, 473, 624, 170, 621,
/* 1420 */ 618, 119, 168, 55, 409, 423, 537, 609, 286, 285,
/* 1430 */ 405, 570, 560, 556, 5, 52, 458, 554, 147, 267,
/* 1440 */ 519, 504, 518, 406, 262, 239, 260, 512, 343, 511,
/* 1450 */ 258, 353, 565, 256, 224, 251, 359, 277, 275, 476,
/* 1460 */ 475, 246, 352, 244, 467, 455, 236, 233, 232, 307,
/* 1470 */ 441, 281, 205, 163, 397, 280, 535, 505, 330, 617,
/* 1480 */ 971, 971, 971, 971, 367, 971, 971, 971, 971, 971,
/* 1490 */ 971, 971, 971, 971, 971, 971, 338,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 19, 22, 22, 23, 1, 24, 26, 15, 27, 80,
/* 10 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
/* 20 */ 91, 92, 93, 94, 95, 108, 109, 110, 27, 28,
/* 30 */ 23, 50, 51, 80, 81, 82, 83, 122, 85, 86,
/* 40 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 22,
/* 50 */ 70, 23, 71, 72, 73, 74, 75, 76, 77, 78,
/* 60 */ 79, 80, 81, 82, 83, 122, 85, 86, 87, 88,
/* 70 */ 89, 90, 91, 92, 93, 94, 95, 19, 97, 91,
/* 80 */ 92, 93, 94, 95, 26, 85, 86, 87, 88, 89,
/* 90 */ 90, 91, 92, 93, 94, 95, 27, 28, 97, 98,
/* 100 */ 99, 122, 211, 102, 103, 104, 79, 19, 50, 51,
/* 110 */ 19, 122, 59, 55, 113, 224, 225, 226, 89, 90,
/* 120 */ 91, 92, 93, 94, 95, 23, 27, 28, 26, 71,
/* 130 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
/* 140 */ 82, 83, 51, 85, 86, 87, 88, 89, 90, 91,
/* 150 */ 92, 93, 94, 95, 19, 132, 133, 58, 89, 90,
/* 160 */ 21, 108, 109, 110, 27, 28, 97, 98, 33, 100,
/* 170 */ 7, 8, 119, 120, 22, 19, 107, 42, 109, 27,
/* 180 */ 28, 27, 28, 95, 28, 50, 51, 99, 100, 101,
/* 190 */ 102, 103, 104, 105, 27, 28, 97, 98, 107, 152,
/* 200 */ 112, 132, 133, 112, 65, 69, 71, 72, 73, 74,
/* 210 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 11,
/* 220 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
/* 230 */ 95, 19, 101, 97, 97, 98, 24, 101, 122, 157,
/* 240 */ 12, 99, 103, 112, 102, 103, 104, 152, 22, 97,
/* 250 */ 98, 97, 98, 27, 28, 113, 27, 29, 91, 164,
/* 260 */ 165, 124, 50, 51, 97, 98, 219, 59, 132, 133,
/* 270 */ 134, 22, 23, 45, 66, 47, 212, 213, 124, 140,
/* 280 */ 132, 133, 19, 71, 72, 73, 74, 75, 76, 77,
/* 290 */ 78, 79, 80, 81, 82, 83, 152, 85, 86, 87,
/* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 164, 165,
/* 310 */ 27, 28, 230, 50, 51, 233, 108, 109, 110, 70,
/* 320 */ 16, 59, 23, 97, 98, 26, 97, 22, 66, 185,
/* 330 */ 12, 187, 27, 28, 71, 72, 73, 74, 75, 76,
/* 340 */ 77, 78, 79, 80, 81, 82, 83, 29, 85, 86,
/* 350 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 19,
/* 360 */ 22, 148, 149, 45, 23, 47, 62, 154, 64, 156,
/* 370 */ 108, 109, 110, 37, 69, 23, 163, 59, 26, 26,
/* 380 */ 97, 98, 144, 145, 146, 147, 152, 200, 52, 23,
/* 390 */ 50, 51, 26, 22, 89, 90, 60, 210, 7, 8,
/* 400 */ 9, 138, 97, 22, 23, 26, 101, 26, 174, 175,
/* 410 */ 197, 71, 72, 73, 74, 75, 76, 77, 78, 79,
/* 420 */ 80, 81, 82, 83, 16, 85, 86, 87, 88, 89,
/* 430 */ 90, 91, 92, 93, 94, 95, 19, 132, 133, 134,
/* 440 */ 23, 152, 208, 209, 140, 152, 152, 111, 195, 196,
/* 450 */ 98, 70, 163, 160, 152, 23, 22, 164, 165, 246,
/* 460 */ 207, 27, 152, 174, 175, 171, 172, 50, 51, 137,
/* 470 */ 62, 139, 64, 171, 172, 222, 124, 27, 138, 24,
/* 480 */ 163, 89, 90, 130, 174, 175, 197, 163, 71, 72,
/* 490 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
/* 500 */ 83, 22, 85, 86, 87, 88, 89, 90, 91, 92,
/* 510 */ 93, 94, 95, 19, 197, 181, 182, 23, 208, 209,
/* 520 */ 152, 197, 26, 189, 132, 133, 232, 224, 225, 226,
/* 530 */ 152, 97, 91, 26, 232, 116, 212, 213, 152, 222,
/* 540 */ 121, 152, 174, 175, 50, 51, 243, 97, 22, 23,
/* 550 */ 22, 234, 174, 175, 177, 23, 239, 116, 163, 177,
/* 560 */ 174, 175, 121, 174, 175, 71, 72, 73, 74, 75,
/* 570 */ 76, 77, 78, 79, 80, 81, 82, 83, 24, 85,
/* 580 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
/* 590 */ 19, 23, 197, 11, 23, 227, 70, 208, 220, 152,
/* 600 */ 31, 224, 225, 226, 35, 98, 224, 225, 226, 108,
/* 610 */ 109, 110, 115, 152, 117, 118, 27, 222, 49, 123,
/* 620 */ 24, 50, 51, 27, 0, 1, 2, 224, 225, 226,
/* 630 */ 166, 124, 168, 169, 239, 174, 175, 170, 171, 172,
/* 640 */ 22, 194, 71, 72, 73, 74, 75, 76, 77, 78,
/* 650 */ 79, 80, 81, 82, 83, 152, 85, 86, 87, 88,
/* 660 */ 89, 90, 91, 92, 93, 94, 95, 19, 22, 208,
/* 670 */ 24, 23, 195, 196, 170, 171, 172, 174, 175, 152,
/* 680 */ 26, 152, 152, 152, 207, 152, 97, 152, 23, 152,
/* 690 */ 51, 244, 152, 97, 152, 247, 248, 23, 50, 51,
/* 700 */ 26, 174, 175, 174, 175, 174, 175, 174, 175, 174,
/* 710 */ 175, 174, 175, 23, 174, 175, 174, 175, 188, 71,
/* 720 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
/* 730 */ 82, 83, 152, 85, 86, 87, 88, 89, 90, 91,
/* 740 */ 92, 93, 94, 95, 19, 152, 107, 152, 33, 24,
/* 750 */ 152, 100, 101, 27, 174, 175, 152, 42, 152, 23,
/* 760 */ 152, 26, 152, 23, 152, 26, 152, 174, 175, 174,
/* 770 */ 175, 152, 174, 175, 23, 50, 51, 26, 174, 175,
/* 780 */ 174, 175, 174, 175, 174, 175, 174, 175, 174, 175,
/* 790 */ 163, 119, 120, 174, 175, 19, 71, 72, 73, 74,
/* 800 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 152,
/* 810 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
/* 820 */ 95, 66, 152, 97, 197, 23, 50, 51, 26, 53,
/* 830 */ 23, 174, 175, 26, 23, 23, 23, 26, 26, 26,
/* 840 */ 36, 106, 146, 147, 174, 175, 19, 71, 72, 73,
/* 850 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
/* 860 */ 152, 85, 86, 87, 88, 89, 90, 91, 92, 93,
/* 870 */ 94, 95, 152, 196, 119, 120, 19, 50, 51, 168,
/* 880 */ 169, 26, 174, 175, 207, 28, 152, 249, 250, 152,
/* 890 */ 163, 163, 163, 163, 174, 175, 163, 19, 71, 72,
/* 900 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
/* 910 */ 83, 152, 85, 86, 87, 88, 89, 90, 91, 92,
/* 920 */ 93, 94, 95, 152, 197, 197, 197, 197, 50, 51,
/* 930 */ 197, 194, 36, 174, 175, 191, 192, 152, 191, 192,
/* 940 */ 163, 152, 66, 124, 152, 174, 175, 152, 19, 71,
/* 950 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
/* 960 */ 82, 83, 152, 85, 86, 87, 88, 89, 90, 91,
/* 970 */ 92, 93, 94, 95, 197, 152, 100, 188, 152, 50,
/* 980 */ 51, 152, 152, 188, 174, 175, 252, 152, 94, 95,
/* 990 */ 152, 152, 152, 1, 2, 152, 152, 174, 175, 19,
/* 1000 */ 152, 72, 73, 74, 75, 76, 77, 78, 79, 80,
/* 1010 */ 81, 82, 83, 152, 85, 86, 87, 88, 89, 90,
/* 1020 */ 91, 92, 93, 94, 95, 152, 188, 188, 22, 194,
/* 1030 */ 50, 51, 240, 173, 194, 174, 175, 252, 194, 152,
/* 1040 */ 36, 181, 28, 152, 23, 219, 122, 174, 175, 219,
/* 1050 */ 221, 152, 152, 73, 74, 75, 76, 77, 78, 79,
/* 1060 */ 80, 81, 82, 83, 152, 85, 86, 87, 88, 89,
/* 1070 */ 90, 91, 92, 93, 94, 95, 19, 20, 152, 22,
/* 1080 */ 23, 194, 152, 240, 27, 28, 174, 175, 240, 19,
/* 1090 */ 20, 26, 22, 194, 194, 38, 22, 27, 28, 152,
/* 1100 */ 23, 22, 152, 116, 174, 175, 152, 23, 38, 152,
/* 1110 */ 23, 152, 221, 152, 57, 152, 23, 163, 50, 51,
/* 1120 */ 194, 174, 175, 66, 174, 175, 69, 57, 174, 175,
/* 1130 */ 40, 174, 175, 174, 175, 174, 175, 174, 175, 69,
/* 1140 */ 22, 53, 74, 75, 30, 53, 89, 90, 22, 22,
/* 1150 */ 152, 197, 23, 96, 97, 98, 22, 152, 101, 89,
/* 1160 */ 90, 91, 208, 209, 152, 53, 96, 97, 98, 101,
/* 1170 */ 22, 101, 174, 175, 152, 19, 20, 105, 22, 174,
/* 1180 */ 175, 112, 19, 27, 28, 20, 174, 175, 24, 132,
/* 1190 */ 133, 134, 135, 136, 38, 44, 174, 175, 107, 61,
/* 1200 */ 54, 26, 132, 133, 134, 135, 136, 54, 107, 22,
/* 1210 */ 5, 140, 1, 57, 36, 111, 122, 28, 79, 79,
/* 1220 */ 131, 123, 66, 19, 20, 69, 22, 1, 16, 20,
/* 1230 */ 125, 27, 28, 123, 111, 120, 23, 131, 23, 16,
/* 1240 */ 68, 142, 38, 15, 22, 89, 90, 3, 167, 4,
/* 1250 */ 248, 251, 96, 97, 98, 180, 180, 101, 251, 151,
/* 1260 */ 6, 57, 151, 13, 151, 26, 25, 151, 161, 202,
/* 1270 */ 153, 162, 153, 69, 130, 128, 203, 19, 20, 127,
/* 1280 */ 22, 126, 204, 129, 22, 27, 28, 205, 132, 133,
/* 1290 */ 134, 135, 136, 89, 90, 231, 38, 95, 137, 179,
/* 1300 */ 96, 97, 98, 206, 179, 101, 122, 107, 159, 159,
/* 1310 */ 125, 231, 216, 228, 107, 57, 184, 217, 216, 176,
/* 1320 */ 217, 176, 48, 106, 18, 184, 158, 69, 159, 158,
/* 1330 */ 46, 71, 237, 176, 176, 176, 132, 133, 134, 135,
/* 1340 */ 136, 217, 176, 137, 216, 178, 158, 89, 90, 179,
/* 1350 */ 176, 159, 179, 159, 96, 97, 98, 159, 159, 101,
/* 1360 */ 5, 158, 202, 22, 18, 10, 11, 12, 13, 14,
/* 1370 */ 190, 238, 17, 190, 158, 193, 41, 159, 202, 193,
/* 1380 */ 159, 202, 245, 193, 193, 223, 190, 32, 159, 34,
/* 1390 */ 132, 133, 134, 135, 136, 159, 39, 155, 43, 150,
/* 1400 */ 223, 177, 201, 178, 177, 186, 66, 199, 177, 152,
/* 1410 */ 253, 56, 215, 152, 182, 152, 202, 152, 63, 152,
/* 1420 */ 152, 66, 67, 242, 229, 152, 174, 152, 152, 152,
/* 1430 */ 152, 152, 152, 152, 199, 242, 202, 152, 198, 152,
/* 1440 */ 152, 152, 183, 192, 152, 215, 152, 183, 215, 183,
/* 1450 */ 152, 241, 214, 152, 211, 152, 152, 211, 211, 152,
/* 1460 */ 152, 241, 152, 152, 152, 152, 152, 152, 152, 114,
/* 1470 */ 152, 152, 235, 152, 152, 152, 174, 187, 95, 174,
/* 1480 */ 253, 253, 253, 253, 236, 253, 253, 253, 253, 253,
/* 1490 */ 253, 253, 253, 253, 253, 253, 141,
};
#define YY_SHIFT_USE_DFLT (-86)
#define YY_SHIFT_COUNT (429)
#define YY_SHIFT_MIN (-85)
#define YY_SHIFT_MAX (1383)
static const short yy_shift_ofst[] = {
/* 0 */ 992, 1057, 1355, 1156, 1204, 1204, 1, 262, -19, 135,
/* 10 */ 135, 776, 1204, 1204, 1204, 1204, 69, 69, 53, 208,
/* 20 */ 283, 755, 58, 725, 648, 571, 494, 417, 340, 263,
/* 30 */ 212, 827, 827, 827, 827, 827, 827, 827, 827, 827,
/* 40 */ 827, 827, 827, 827, 827, 827, 878, 827, 929, 980,
/* 50 */ 980, 1070, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204,
/* 60 */ 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204,
/* 70 */ 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204,
/* 80 */ 1258, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204,
/* 90 */ 1204, 1204, 1204, 1204, -71, -47, -47, -47, -47, -47,
/* 100 */ 0, 29, -12, 283, 283, 139, 91, 392, 392, 894,
/* 110 */ 672, 726, 1383, -86, -86, -86, 88, 318, 318, 99,
/* 120 */ 381, -20, 283, 283, 283, 283, 283, 283, 283, 283,
/* 130 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
/* 140 */ 283, 283, 283, 283, 624, 876, 726, 672, 1340, 1340,
/* 150 */ 1340, 1340, 1340, 1340, -86, -86, -86, 305, 136, 136,
/* 160 */ 142, 167, 226, 154, 137, 152, 283, 283, 283, 283,
/* 170 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
/* 180 */ 283, 283, 283, 336, 336, 336, 283, 283, 352, 283,
/* 190 */ 283, 283, 283, 283, 228, 283, 283, 283, 283, 283,
/* 200 */ 283, 283, 283, 283, 283, 501, 569, 596, 596, 596,
/* 210 */ 507, 497, 441, 391, 353, 156, 156, 857, 353, 857,
/* 220 */ 735, 813, 639, 715, 156, 332, 715, 715, 496, 419,
/* 230 */ 646, 1357, 1184, 1184, 1335, 1335, 1184, 1341, 1260, 1144,
/* 240 */ 1346, 1346, 1346, 1346, 1184, 1306, 1144, 1341, 1260, 1260,
/* 250 */ 1144, 1184, 1306, 1206, 1284, 1184, 1184, 1306, 1184, 1306,
/* 260 */ 1184, 1306, 1262, 1207, 1207, 1207, 1274, 1262, 1207, 1217,
/* 270 */ 1207, 1274, 1207, 1207, 1185, 1200, 1185, 1200, 1185, 1200,
/* 280 */ 1184, 1184, 1161, 1262, 1202, 1202, 1262, 1154, 1155, 1147,
/* 290 */ 1152, 1144, 1241, 1239, 1250, 1250, 1254, 1254, 1254, 1254,
/* 300 */ -86, -86, -86, -86, -86, -86, 1068, 304, 526, 249,
/* 310 */ 408, -83, 434, 812, 27, 811, 807, 802, 751, 589,
/* 320 */ 651, 163, 131, 674, 366, 450, 299, 148, 23, 102,
/* 330 */ 229, -21, 1245, 1244, 1222, 1099, 1228, 1172, 1223, 1215,
/* 340 */ 1213, 1115, 1106, 1123, 1110, 1209, 1105, 1212, 1226, 1098,
/* 350 */ 1089, 1140, 1139, 1104, 1189, 1178, 1094, 1211, 1205, 1187,
/* 360 */ 1101, 1071, 1153, 1175, 1146, 1138, 1151, 1091, 1164, 1165,
/* 370 */ 1163, 1069, 1072, 1148, 1112, 1134, 1127, 1129, 1126, 1092,
/* 380 */ 1114, 1118, 1088, 1090, 1093, 1087, 1084, 987, 1079, 1077,
/* 390 */ 1074, 1065, 924, 1021, 1014, 1004, 1006, 819, 739, 896,
/* 400 */ 855, 804, 739, 740, 736, 690, 654, 665, 618, 582,
/* 410 */ 568, 528, 554, 379, 532, 479, 455, 379, 432, 371,
/* 420 */ 341, 28, 338, 116, -11, -57, -85, 7, -8, 3,
};
#define YY_REDUCE_USE_DFLT (-110)
#define YY_REDUCE_COUNT (305)
#define YY_REDUCE_MIN (-109)
#define YY_REDUCE_MAX (1323)
static const short yy_reduce_ofst[] = {
/* 0 */ 238, 954, 213, 289, 310, 234, 144, 317, -109, 382,
/* 10 */ 377, 303, 461, 389, 378, 368, 302, 294, 253, 395,
/* 20 */ 293, 324, 403, 403, 403, 403, 403, 403, 403, 403,
/* 30 */ 403, 403, 403, 403, 403, 403, 403, 403, 403, 403,
/* 40 */ 403, 403, 403, 403, 403, 403, 403, 403, 403, 403,
/* 50 */ 403, 1022, 1012, 1005, 998, 963, 961, 959, 957, 950,
/* 60 */ 947, 930, 912, 873, 861, 823, 810, 771, 759, 720,
/* 70 */ 708, 670, 657, 619, 614, 612, 610, 608, 606, 604,
/* 80 */ 598, 595, 593, 580, 542, 540, 537, 535, 533, 531,
/* 90 */ 529, 527, 503, 386, 403, 403, 403, 403, 403, 403,
/* 100 */ 403, 403, 403, 95, 447, 82, 334, 504, 467, 403,
/* 110 */ 477, 464, 403, 403, 403, 403, 860, 747, 744, 785,
/* 120 */ 638, 638, 926, 891, 900, 899, 887, 844, 840, 835,
/* 130 */ 848, 830, 843, 829, 792, 839, 826, 737, 838, 795,
/* 140 */ 789, 47, 734, 530, 696, 777, 711, 677, 733, 730,
/* 150 */ 729, 728, 727, 627, 448, 64, 187, 1305, 1302, 1252,
/* 160 */ 1290, 1273, 1323, 1322, 1321, 1319, 1318, 1316, 1315, 1314,
/* 170 */ 1313, 1312, 1311, 1310, 1308, 1307, 1304, 1303, 1301, 1298,
/* 180 */ 1294, 1292, 1289, 1266, 1264, 1259, 1288, 1287, 1238, 1285,
/* 190 */ 1281, 1280, 1279, 1278, 1251, 1277, 1276, 1275, 1273, 1268,
/* 200 */ 1267, 1265, 1263, 1261, 1257, 1248, 1237, 1247, 1246, 1243,
/* 210 */ 1238, 1240, 1235, 1249, 1234, 1233, 1230, 1220, 1214, 1210,
/* 220 */ 1225, 1219, 1232, 1231, 1197, 1195, 1227, 1224, 1201, 1208,
/* 230 */ 1242, 1137, 1236, 1229, 1193, 1181, 1221, 1177, 1196, 1179,
/* 240 */ 1191, 1190, 1186, 1182, 1218, 1216, 1176, 1162, 1183, 1180,
/* 250 */ 1160, 1199, 1203, 1133, 1095, 1198, 1194, 1188, 1192, 1171,
/* 260 */ 1169, 1168, 1173, 1174, 1166, 1159, 1141, 1170, 1158, 1167,
/* 270 */ 1157, 1132, 1145, 1143, 1124, 1128, 1103, 1102, 1100, 1096,
/* 280 */ 1150, 1149, 1085, 1125, 1080, 1064, 1120, 1097, 1082, 1078,
/* 290 */ 1073, 1067, 1109, 1107, 1119, 1117, 1116, 1113, 1111, 1108,
/* 300 */ 1007, 1000, 1002, 1076, 1075, 1081,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 647, 964, 964, 964, 878, 878, 969, 964, 774, 802,
/* 10 */ 802, 938, 969, 969, 969, 876, 969, 969, 969, 964,
/* 20 */ 969, 778, 808, 969, 969, 969, 969, 969, 969, 969,
/* 30 */ 969, 937, 939, 816, 815, 918, 789, 813, 806, 810,
/* 40 */ 879, 872, 873, 871, 875, 880, 969, 809, 841, 856,
/* 50 */ 840, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 60 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 70 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 80 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 90 */ 969, 969, 969, 969, 850, 855, 862, 854, 851, 843,
/* 100 */ 842, 844, 845, 969, 969, 673, 739, 969, 969, 846,
/* 110 */ 969, 685, 847, 859, 858, 857, 680, 969, 969, 969,
/* 120 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 130 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 140 */ 969, 969, 969, 969, 647, 964, 969, 969, 964, 964,
/* 150 */ 964, 964, 964, 964, 956, 778, 768, 969, 969, 969,
/* 160 */ 969, 969, 969, 969, 969, 969, 969, 944, 942, 969,
/* 170 */ 891, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 180 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 190 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 200 */ 969, 969, 969, 969, 653, 969, 911, 774, 774, 774,
/* 210 */ 776, 754, 766, 655, 812, 791, 791, 923, 812, 923,
/* 220 */ 710, 733, 707, 802, 791, 874, 802, 802, 775, 766,
/* 230 */ 969, 949, 782, 782, 941, 941, 782, 821, 743, 812,
/* 240 */ 750, 750, 750, 750, 782, 670, 812, 821, 743, 743,
/* 250 */ 812, 782, 670, 917, 915, 782, 782, 670, 782, 670,
/* 260 */ 782, 670, 884, 741, 741, 741, 725, 884, 741, 710,
/* 270 */ 741, 725, 741, 741, 795, 790, 795, 790, 795, 790,
/* 280 */ 782, 782, 969, 884, 888, 888, 884, 807, 796, 805,
/* 290 */ 803, 812, 676, 728, 663, 663, 652, 652, 652, 652,
/* 300 */ 961, 961, 956, 712, 712, 695, 969, 969, 969, 969,
/* 310 */ 969, 969, 687, 969, 893, 969, 969, 969, 969, 969,
/* 320 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 330 */ 969, 828, 969, 648, 951, 969, 969, 948, 969, 969,
/* 340 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 350 */ 969, 969, 969, 969, 969, 969, 921, 969, 969, 969,
/* 360 */ 969, 969, 969, 914, 913, 969, 969, 969, 969, 969,
/* 370 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969,
/* 380 */ 969, 969, 969, 969, 969, 969, 969, 757, 969, 969,
/* 390 */ 969, 761, 969, 969, 969, 969, 969, 969, 804, 969,
/* 400 */ 797, 969, 877, 969, 969, 969, 969, 969, 969, 969,
/* 410 */ 969, 969, 969, 966, 969, 969, 969, 965, 969, 969,
/* 420 */ 969, 969, 969, 830, 969, 829, 833, 969, 661, 969,
/* 430 */ 644, 649, 960, 963, 962, 959, 958, 957, 952, 950,
/* 440 */ 947, 946, 945, 943, 940, 936, 897, 895, 902, 901,
/* 450 */ 900, 899, 898, 896, 894, 892, 818, 817, 814, 811,
/* 460 */ 753, 935, 890, 752, 749, 748, 669, 953, 920, 929,
/* 470 */ 928, 927, 822, 926, 925, 924, 922, 919, 906, 820,
/* 480 */ 819, 744, 882, 881, 672, 910, 909, 908, 912, 916,
/* 490 */ 907, 784, 751, 671, 668, 675, 679, 731, 732, 740,
/* 500 */ 738, 737, 736, 735, 734, 730, 681, 686, 724, 709,
/* 510 */ 708, 717, 716, 722, 721, 720, 719, 718, 715, 714,
/* 520 */ 713, 706, 705, 711, 704, 727, 726, 723, 703, 747,
/* 530 */ 746, 745, 742, 702, 701, 700, 833, 699, 698, 838,
/* 540 */ 837, 866, 826, 755, 759, 758, 762, 763, 771, 770,
/* 550 */ 769, 780, 781, 793, 792, 824, 823, 794, 779, 773,
/* 560 */ 772, 788, 787, 786, 785, 777, 767, 799, 798, 868,
/* 570 */ 783, 867, 865, 934, 933, 932, 931, 930, 870, 967,
/* 580 */ 968, 887, 889, 886, 801, 800, 885, 869, 839, 836,
/* 590 */ 690, 691, 905, 904, 903, 693, 692, 689, 688, 863,
/* 600 */ 860, 852, 864, 861, 853, 849, 848, 834, 832, 831,
/* 610 */ 827, 835, 760, 756, 825, 765, 764, 697, 696, 694,
/* 620 */ 678, 677, 674, 667, 665, 664, 666, 662, 660, 659,
/* 630 */ 658, 657, 656, 684, 683, 682, 654, 651, 650, 646,
/* 640 */ 645, 643,
};
/* The next table maps tokens into fallback tokens. If a construct
** like the following:
**
** %fallback ID X Y Z.
**
|
| ︙ | ︙ | |||
114905 114906 114907 114908 114909 114910 114911 114912 114913 114914 114915 114916 114917 114918 114919 114920 114921 114922 114923 114924 114925 | 27, /* MATCH => ID */ 27, /* NO => ID */ 27, /* KEY => ID */ 27, /* OF => ID */ 27, /* OFFSET => ID */ 27, /* PRAGMA => ID */ 27, /* RAISE => ID */ 27, /* REPLACE => ID */ 27, /* RESTRICT => ID */ 27, /* ROW => ID */ 27, /* TRIGGER => ID */ 27, /* VACUUM => ID */ 27, /* VIEW => ID */ 27, /* VIRTUAL => ID */ 27, /* REINDEX => ID */ 27, /* RENAME => ID */ 27, /* CTIME_KW => ID */ }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the | > > | 115553 115554 115555 115556 115557 115558 115559 115560 115561 115562 115563 115564 115565 115566 115567 115568 115569 115570 115571 115572 115573 115574 115575 | 27, /* MATCH => ID */ 27, /* NO => ID */ 27, /* KEY => ID */ 27, /* OF => ID */ 27, /* OFFSET => ID */ 27, /* PRAGMA => ID */ 27, /* RAISE => ID */ 27, /* RECURSIVE => ID */ 27, /* REPLACE => ID */ 27, /* RESTRICT => ID */ 27, /* ROW => ID */ 27, /* TRIGGER => ID */ 27, /* VACUUM => ID */ 27, /* VIEW => ID */ 27, /* VIRTUAL => ID */ 27, /* WITH => ID */ 27, /* REINDEX => ID */ 27, /* RENAME => ID */ 27, /* CTIME_KW => ID */ }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the |
| ︙ | ︙ | |||
115007 115008 115009 115010 115011 115012 115013 | "INDEXED", "ABORT", "ACTION", "AFTER", "ANALYZE", "ASC", "ATTACH", "BEFORE", "BY", "CASCADE", "CAST", "COLUMNKW", "CONFLICT", "DATABASE", "DESC", "DETACH", "EACH", "FAIL", "FOR", "IGNORE", "INITIALLY", "INSTEAD", "LIKE_KW", "MATCH", "NO", "KEY", "OF", "OFFSET", | | | > | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | > | < | | | > | 115657 115658 115659 115660 115661 115662 115663 115664 115665 115666 115667 115668 115669 115670 115671 115672 115673 115674 115675 115676 115677 115678 115679 115680 115681 115682 115683 115684 115685 115686 115687 115688 115689 115690 115691 115692 115693 115694 115695 115696 115697 115698 115699 115700 115701 115702 115703 115704 115705 115706 115707 115708 115709 115710 115711 115712 115713 115714 115715 115716 115717 115718 115719 115720 |
"INDEXED", "ABORT", "ACTION", "AFTER",
"ANALYZE", "ASC", "ATTACH", "BEFORE",
"BY", "CASCADE", "CAST", "COLUMNKW",
"CONFLICT", "DATABASE", "DESC", "DETACH",
"EACH", "FAIL", "FOR", "IGNORE",
"INITIALLY", "INSTEAD", "LIKE_KW", "MATCH",
"NO", "KEY", "OF", "OFFSET",
"PRAGMA", "RAISE", "RECURSIVE", "REPLACE",
"RESTRICT", "ROW", "TRIGGER", "VACUUM",
"VIEW", "VIRTUAL", "WITH", "REINDEX",
"RENAME", "CTIME_KW", "ANY", "OR",
"AND", "IS", "BETWEEN", "IN",
"ISNULL", "NOTNULL", "NE", "EQ",
"GT", "LE", "LT", "GE",
"ESCAPE", "BITAND", "BITOR", "LSHIFT",
"RSHIFT", "PLUS", "MINUS", "STAR",
"SLASH", "REM", "CONCAT", "COLLATE",
"BITNOT", "STRING", "JOIN_KW", "CONSTRAINT",
"DEFAULT", "NULL", "PRIMARY", "UNIQUE",
"CHECK", "REFERENCES", "AUTOINCR", "ON",
"INSERT", "DELETE", "UPDATE", "SET",
"DEFERRABLE", "FOREIGN", "DROP", "UNION",
"ALL", "EXCEPT", "INTERSECT", "SELECT",
"VALUES", "DISTINCT", "DOT", "FROM",
"JOIN", "USING", "ORDER", "GROUP",
"HAVING", "LIMIT", "WHERE", "INTO",
"INTEGER", "FLOAT", "BLOB", "VARIABLE",
"CASE", "WHEN", "THEN", "ELSE",
"INDEX", "ALTER", "ADD", "error",
"input", "cmdlist", "ecmd", "explain",
"cmdx", "cmd", "transtype", "trans_opt",
"nm", "savepoint_opt", "create_table", "create_table_args",
"createkw", "temp", "ifnotexists", "dbnm",
"columnlist", "conslist_opt", "table_options", "select",
"column", "columnid", "type", "carglist",
"typetoken", "typename", "signed", "plus_num",
"minus_num", "ccons", "term", "expr",
"onconf", "sortorder", "autoinc", "idxlist_opt",
"refargs", "defer_subclause", "refarg", "refact",
"init_deferred_pred_opt", "conslist", "tconscomma", "tcons",
"idxlist", "defer_subclause_opt", "orconf", "resolvetype",
"raisetype", "ifexists", "fullname", "selectnowith",
"oneselect", "with", "multiselect_op", "distinct",
"selcollist", "from", "where_opt", "groupby_opt",
"having_opt", "orderby_opt", "limit_opt", "values",
"nexprlist", "exprlist", "sclp", "as",
"seltablist", "stl_prefix", "joinop", "indexed_opt",
"on_opt", "using_opt", "joinop2", "idlist",
"sortlist", "setlist", "insert_cmd", "inscollist_opt",
"likeop", "between_op", "in_op", "case_operand",
"case_exprlist", "case_else", "uniqueflag", "collate",
"nmnum", "trigger_decl", "trigger_cmd_list", "trigger_time",
"trigger_event", "foreach_clause", "when_clause", "trigger_cmd",
"trnm", "tridxby", "database_kw_opt", "key_opt",
"add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist",
"vtabarg", "vtabargtoken", "lp", "anylist",
"wqlist",
};
#endif /* NDEBUG */
#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
|
| ︙ | ︙ | |||
115103 115104 115105 115106 115107 115108 115109 | /* 33 */ "create_table_args ::= AS select", /* 34 */ "table_options ::=", /* 35 */ "table_options ::= WITHOUT nm", /* 36 */ "columnlist ::= columnlist COMMA column", /* 37 */ "columnlist ::= column", /* 38 */ "column ::= columnid type carglist", /* 39 */ "columnid ::= nm", | | < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | > > | | | | | | | | | | | | | > | | | | | | | | < | | | | | | | | > | | | | | | < | | | | | | | | | | > | | | | | | < | | < < | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | > > > | | | | | | | < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > < < < < < | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | 115754 115755 115756 115757 115758 115759 115760 115761 115762 115763 115764 115765 115766 115767 115768 115769 115770 115771 115772 115773 115774 115775 115776 115777 115778 115779 115780 115781 115782 115783 115784 115785 115786 115787 115788 115789 115790 115791 115792 115793 115794 115795 115796 115797 115798 115799 115800 115801 115802 115803 115804 115805 115806 115807 115808 115809 115810 115811 115812 115813 115814 115815 115816 115817 115818 115819 115820 115821 115822 115823 115824 115825 115826 115827 115828 115829 115830 115831 115832 115833 115834 115835 115836 115837 115838 115839 115840 115841 115842 115843 115844 115845 115846 115847 115848 115849 115850 115851 115852 115853 115854 115855 115856 115857 115858 115859 115860 115861 115862 115863 115864 115865 115866 115867 115868 115869 115870 115871 115872 115873 115874 115875 115876 115877 115878 115879 115880 115881 115882 115883 115884 115885 115886 115887 115888 115889 115890 115891 115892 115893 115894 115895 115896 115897 115898 115899 115900 115901 115902 115903 115904 115905 115906 115907 115908 115909 115910 115911 115912 115913 115914 115915 115916 115917 115918 115919 115920 115921 115922 115923 115924 115925 115926 115927 115928 115929 115930 115931 115932 115933 115934 115935 115936 115937 115938 115939 115940 115941 115942 115943 115944 115945 115946 115947 115948 115949 115950 115951 115952 115953 115954 115955 115956 115957 115958 115959 115960 115961 115962 115963 115964 115965 115966 115967 115968 115969 115970 115971 115972 115973 115974 115975 115976 115977 115978 115979 115980 115981 115982 115983 115984 115985 115986 115987 115988 115989 115990 115991 115992 115993 115994 115995 115996 115997 115998 115999 116000 116001 116002 116003 116004 116005 116006 116007 116008 116009 116010 116011 116012 116013 116014 116015 116016 116017 116018 116019 116020 116021 116022 116023 116024 116025 116026 116027 116028 116029 116030 116031 116032 116033 116034 116035 116036 116037 116038 116039 116040 116041 116042 116043 116044 116045 116046 116047 116048 116049 116050 116051 116052 116053 116054 | /* 33 */ "create_table_args ::= AS select", /* 34 */ "table_options ::=", /* 35 */ "table_options ::= WITHOUT nm", /* 36 */ "columnlist ::= columnlist COMMA column", /* 37 */ "columnlist ::= column", /* 38 */ "column ::= columnid type carglist", /* 39 */ "columnid ::= nm", /* 40 */ "nm ::= ID|INDEXED", /* 41 */ "nm ::= STRING", /* 42 */ "nm ::= JOIN_KW", /* 43 */ "type ::=", /* 44 */ "type ::= typetoken", /* 45 */ "typetoken ::= typename", /* 46 */ "typetoken ::= typename LP signed RP", /* 47 */ "typetoken ::= typename LP signed COMMA signed RP", /* 48 */ "typename ::= ID|STRING", /* 49 */ "typename ::= typename ID|STRING", /* 50 */ "signed ::= plus_num", /* 51 */ "signed ::= minus_num", /* 52 */ "carglist ::= carglist ccons", /* 53 */ "carglist ::=", /* 54 */ "ccons ::= CONSTRAINT nm", /* 55 */ "ccons ::= DEFAULT term", /* 56 */ "ccons ::= DEFAULT LP expr RP", /* 57 */ "ccons ::= DEFAULT PLUS term", /* 58 */ "ccons ::= DEFAULT MINUS term", /* 59 */ "ccons ::= DEFAULT ID|INDEXED", /* 60 */ "ccons ::= NULL onconf", /* 61 */ "ccons ::= NOT NULL onconf", /* 62 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", /* 63 */ "ccons ::= UNIQUE onconf", /* 64 */ "ccons ::= CHECK LP expr RP", /* 65 */ "ccons ::= REFERENCES nm idxlist_opt refargs", /* 66 */ "ccons ::= defer_subclause", /* 67 */ "ccons ::= COLLATE ID|STRING", /* 68 */ "autoinc ::=", /* 69 */ "autoinc ::= AUTOINCR", /* 70 */ "refargs ::=", /* 71 */ "refargs ::= refargs refarg", /* 72 */ "refarg ::= MATCH nm", /* 73 */ "refarg ::= ON INSERT refact", /* 74 */ "refarg ::= ON DELETE refact", /* 75 */ "refarg ::= ON UPDATE refact", /* 76 */ "refact ::= SET NULL", /* 77 */ "refact ::= SET DEFAULT", /* 78 */ "refact ::= CASCADE", /* 79 */ "refact ::= RESTRICT", /* 80 */ "refact ::= NO ACTION", /* 81 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", /* 82 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", /* 83 */ "init_deferred_pred_opt ::=", /* 84 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", /* 85 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", /* 86 */ "conslist_opt ::=", /* 87 */ "conslist_opt ::= COMMA conslist", /* 88 */ "conslist ::= conslist tconscomma tcons", /* 89 */ "conslist ::= tcons", /* 90 */ "tconscomma ::= COMMA", /* 91 */ "tconscomma ::=", /* 92 */ "tcons ::= CONSTRAINT nm", /* 93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", /* 94 */ "tcons ::= UNIQUE LP idxlist RP onconf", /* 95 */ "tcons ::= CHECK LP expr RP onconf", /* 96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", /* 97 */ "defer_subclause_opt ::=", /* 98 */ "defer_subclause_opt ::= defer_subclause", /* 99 */ "onconf ::=", /* 100 */ "onconf ::= ON CONFLICT resolvetype", /* 101 */ "orconf ::=", /* 102 */ "orconf ::= OR resolvetype", /* 103 */ "resolvetype ::= raisetype", /* 104 */ "resolvetype ::= IGNORE", /* 105 */ "resolvetype ::= REPLACE", /* 106 */ "cmd ::= DROP TABLE ifexists fullname", /* 107 */ "ifexists ::= IF EXISTS", /* 108 */ "ifexists ::=", /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", /* 110 */ "cmd ::= DROP VIEW ifexists fullname", /* 111 */ "cmd ::= select", /* 112 */ "select ::= with selectnowith", /* 113 */ "selectnowith ::= oneselect", /* 114 */ "selectnowith ::= selectnowith multiselect_op oneselect", /* 115 */ "multiselect_op ::= UNION", /* 116 */ "multiselect_op ::= UNION ALL", /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT", /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", /* 119 */ "oneselect ::= values", /* 120 */ "values ::= VALUES LP nexprlist RP", /* 121 */ "values ::= values COMMA LP exprlist RP", /* 122 */ "distinct ::= DISTINCT", /* 123 */ "distinct ::= ALL", /* 124 */ "distinct ::=", /* 125 */ "sclp ::= selcollist COMMA", /* 126 */ "sclp ::=", /* 127 */ "selcollist ::= sclp expr as", /* 128 */ "selcollist ::= sclp STAR", /* 129 */ "selcollist ::= sclp nm DOT STAR", /* 130 */ "as ::= AS nm", /* 131 */ "as ::= ID|STRING", /* 132 */ "as ::=", /* 133 */ "from ::=", /* 134 */ "from ::= FROM seltablist", /* 135 */ "stl_prefix ::= seltablist joinop", /* 136 */ "stl_prefix ::=", /* 137 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", /* 138 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", /* 139 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", /* 140 */ "dbnm ::=", /* 141 */ "dbnm ::= DOT nm", /* 142 */ "fullname ::= nm dbnm", /* 143 */ "joinop ::= COMMA|JOIN", /* 144 */ "joinop ::= JOIN_KW JOIN", /* 145 */ "joinop ::= JOIN_KW nm JOIN", /* 146 */ "joinop ::= JOIN_KW nm nm JOIN", /* 147 */ "on_opt ::= ON expr", /* 148 */ "on_opt ::=", /* 149 */ "indexed_opt ::=", /* 150 */ "indexed_opt ::= INDEXED BY nm", /* 151 */ "indexed_opt ::= NOT INDEXED", /* 152 */ "using_opt ::= USING LP idlist RP", /* 153 */ "using_opt ::=", /* 154 */ "orderby_opt ::=", /* 155 */ "orderby_opt ::= ORDER BY sortlist", /* 156 */ "sortlist ::= sortlist COMMA expr sortorder", /* 157 */ "sortlist ::= expr sortorder", /* 158 */ "sortorder ::= ASC", /* 159 */ "sortorder ::= DESC", /* 160 */ "sortorder ::=", /* 161 */ "groupby_opt ::=", /* 162 */ "groupby_opt ::= GROUP BY nexprlist", /* 163 */ "having_opt ::=", /* 164 */ "having_opt ::= HAVING expr", /* 165 */ "limit_opt ::=", /* 166 */ "limit_opt ::= LIMIT expr", /* 167 */ "limit_opt ::= LIMIT expr OFFSET expr", /* 168 */ "limit_opt ::= LIMIT expr COMMA expr", /* 169 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt", /* 170 */ "where_opt ::=", /* 171 */ "where_opt ::= WHERE expr", /* 172 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt", /* 173 */ "setlist ::= setlist COMMA nm EQ expr", /* 174 */ "setlist ::= nm EQ expr", /* 175 */ "cmd ::= with insert_cmd INTO fullname inscollist_opt select", /* 176 */ "cmd ::= with insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", /* 177 */ "insert_cmd ::= INSERT orconf", /* 178 */ "insert_cmd ::= REPLACE", /* 179 */ "inscollist_opt ::=", /* 180 */ "inscollist_opt ::= LP idlist RP", /* 181 */ "idlist ::= idlist COMMA nm", /* 182 */ "idlist ::= nm", /* 183 */ "expr ::= term", /* 184 */ "expr ::= LP expr RP", /* 185 */ "term ::= NULL", /* 186 */ "expr ::= ID|INDEXED", /* 187 */ "expr ::= JOIN_KW", /* 188 */ "expr ::= nm DOT nm", /* 189 */ "expr ::= nm DOT nm DOT nm", /* 190 */ "term ::= INTEGER|FLOAT|BLOB", /* 191 */ "term ::= STRING", /* 192 */ "expr ::= VARIABLE", /* 193 */ "expr ::= expr COLLATE ID|STRING", /* 194 */ "expr ::= CAST LP expr AS typetoken RP", /* 195 */ "expr ::= ID|INDEXED LP distinct exprlist RP", /* 196 */ "expr ::= ID|INDEXED LP STAR RP", /* 197 */ "term ::= CTIME_KW", /* 198 */ "expr ::= expr AND expr", /* 199 */ "expr ::= expr OR expr", /* 200 */ "expr ::= expr LT|GT|GE|LE expr", /* 201 */ "expr ::= expr EQ|NE expr", /* 202 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", /* 203 */ "expr ::= expr PLUS|MINUS expr", /* 204 */ "expr ::= expr STAR|SLASH|REM expr", /* 205 */ "expr ::= expr CONCAT expr", /* 206 */ "likeop ::= LIKE_KW|MATCH", /* 207 */ "likeop ::= NOT LIKE_KW|MATCH", /* 208 */ "expr ::= expr likeop expr", /* 209 */ "expr ::= expr likeop expr ESCAPE expr", /* 210 */ "expr ::= expr ISNULL|NOTNULL", /* 211 */ "expr ::= expr NOT NULL", /* 212 */ "expr ::= expr IS expr", /* 213 */ "expr ::= expr IS NOT expr", /* 214 */ "expr ::= NOT expr", /* 215 */ "expr ::= BITNOT expr", /* 216 */ "expr ::= MINUS expr", /* 217 */ "expr ::= PLUS expr", /* 218 */ "between_op ::= BETWEEN", /* 219 */ "between_op ::= NOT BETWEEN", /* 220 */ "expr ::= expr between_op expr AND expr", /* 221 */ "in_op ::= IN", /* 222 */ "in_op ::= NOT IN", /* 223 */ "expr ::= expr in_op LP exprlist RP", /* 224 */ "expr ::= LP select RP", /* 225 */ "expr ::= expr in_op LP select RP", /* 226 */ "expr ::= expr in_op nm dbnm", /* 227 */ "expr ::= EXISTS LP select RP", /* 228 */ "expr ::= CASE case_operand case_exprlist case_else END", /* 229 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", /* 230 */ "case_exprlist ::= WHEN expr THEN expr", /* 231 */ "case_else ::= ELSE expr", /* 232 */ "case_else ::=", /* 233 */ "case_operand ::= expr", /* 234 */ "case_operand ::=", /* 235 */ "exprlist ::= nexprlist", /* 236 */ "exprlist ::=", /* 237 */ "nexprlist ::= nexprlist COMMA expr", /* 238 */ "nexprlist ::= expr", /* 239 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", /* 240 */ "uniqueflag ::= UNIQUE", /* 241 */ "uniqueflag ::=", /* 242 */ "idxlist_opt ::=", /* 243 */ "idxlist_opt ::= LP idxlist RP", /* 244 */ "idxlist ::= idxlist COMMA nm collate sortorder", /* 245 */ "idxlist ::= nm collate sortorder", /* 246 */ "collate ::=", /* 247 */ "collate ::= COLLATE ID|STRING", /* 248 */ "cmd ::= DROP INDEX ifexists fullname", /* 249 */ "cmd ::= VACUUM", /* 250 */ "cmd ::= VACUUM nm", /* 251 */ "cmd ::= PRAGMA nm dbnm", /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", /* 256 */ "nmnum ::= plus_num", /* 257 */ "nmnum ::= nm", /* 258 */ "nmnum ::= ON", /* 259 */ "nmnum ::= DELETE", /* 260 */ "nmnum ::= DEFAULT", /* 261 */ "plus_num ::= PLUS INTEGER|FLOAT", /* 262 */ "plus_num ::= INTEGER|FLOAT", /* 263 */ "minus_num ::= MINUS INTEGER|FLOAT", /* 264 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", /* 265 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", /* 266 */ "trigger_time ::= BEFORE", /* 267 */ "trigger_time ::= AFTER", /* 268 */ "trigger_time ::= INSTEAD OF", /* 269 */ "trigger_time ::=", /* 270 */ "trigger_event ::= DELETE|INSERT", /* 271 */ "trigger_event ::= UPDATE", /* 272 */ "trigger_event ::= UPDATE OF idlist", /* 273 */ "foreach_clause ::=", /* 274 */ "foreach_clause ::= FOR EACH ROW", /* 275 */ "when_clause ::=", /* 276 */ "when_clause ::= WHEN expr", /* 277 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", /* 278 */ "trigger_cmd_list ::= trigger_cmd SEMI", /* 279 */ "trnm ::= nm", /* 280 */ "trnm ::= nm DOT nm", /* 281 */ "tridxby ::=", /* 282 */ "tridxby ::= INDEXED BY nm", /* 283 */ "tridxby ::= NOT INDEXED", /* 284 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", /* 285 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", /* 286 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", /* 287 */ "trigger_cmd ::= select", /* 288 */ "expr ::= RAISE LP IGNORE RP", /* 289 */ "expr ::= RAISE LP raisetype COMMA nm RP", /* 290 */ "raisetype ::= ROLLBACK", /* 291 */ "raisetype ::= ABORT", /* 292 */ "raisetype ::= FAIL", /* 293 */ "cmd ::= DROP TRIGGER ifexists fullname", /* 294 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", /* 295 */ "cmd ::= DETACH database_kw_opt expr", /* 296 */ "key_opt ::=", /* 297 */ "key_opt ::= KEY expr", /* 298 */ "database_kw_opt ::= DATABASE", /* 299 */ "database_kw_opt ::=", /* 300 */ "cmd ::= REINDEX", /* 301 */ "cmd ::= REINDEX nm dbnm", /* 302 */ "cmd ::= ANALYZE", /* 303 */ "cmd ::= ANALYZE nm dbnm", /* 304 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", /* 305 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", /* 306 */ "add_column_fullname ::= fullname", /* 307 */ "kwcolumn_opt ::=", /* 308 */ "kwcolumn_opt ::= COLUMNKW", /* 309 */ "cmd ::= create_vtab", /* 310 */ "cmd ::= create_vtab LP vtabarglist RP", /* 311 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", /* 312 */ "vtabarglist ::= vtabarg", /* 313 */ "vtabarglist ::= vtabarglist COMMA vtabarg", /* 314 */ "vtabarg ::=", /* 315 */ "vtabarg ::= vtabarg vtabargtoken", /* 316 */ "vtabargtoken ::= ANY", /* 317 */ "vtabargtoken ::= lp anylist RP", /* 318 */ "lp ::= LP", /* 319 */ "anylist ::=", /* 320 */ "anylist ::= anylist LP anylist RP", /* 321 */ "anylist ::= anylist ANY", /* 322 */ "with ::=", /* 323 */ "with ::= WITH wqlist", /* 324 */ "with ::= WITH RECURSIVE wqlist", /* 325 */ "wqlist ::= nm idxlist_opt AS LP select RP", /* 326 */ "wqlist ::= wqlist COMMA nm idxlist_opt AS LP select RP", }; #endif /* NDEBUG */ #if YYSTACKDEPTH<=0 /* ** Try to increase the size of the parser stack. |
| ︙ | ︙ | |||
115470 115471 115472 115473 115474 115475 115476 |
** reduce or during error processing or when a parser is
** being destroyed before it is finished parsing.
**
** Note: during a reduce, the only symbols destroyed are those
** which appear on the RHS of the rule, but which are not used
** inside the C code.
*/
| | > > | | | | | | | | | > > | | < | < | | | | | | | > > > > > > | | | | | | | | | | < < < < < < < < | | | 116119 116120 116121 116122 116123 116124 116125 116126 116127 116128 116129 116130 116131 116132 116133 116134 116135 116136 116137 116138 116139 116140 116141 116142 116143 116144 116145 116146 116147 116148 116149 116150 116151 116152 116153 116154 116155 116156 116157 116158 116159 116160 116161 116162 116163 116164 116165 116166 116167 116168 116169 116170 116171 116172 116173 116174 116175 116176 116177 116178 116179 116180 116181 116182 116183 116184 116185 116186 116187 116188 116189 116190 116191 116192 116193 116194 116195 116196 116197 116198 116199 116200 116201 116202 |
** reduce or during error processing or when a parser is
** being destroyed before it is finished parsing.
**
** Note: during a reduce, the only symbols destroyed are those
** which appear on the RHS of the rule, but which are not used
** inside the C code.
*/
case 163: /* select */
case 195: /* selectnowith */
case 196: /* oneselect */
case 207: /* values */
{
sqlite3SelectDelete(pParse->db, (yypminor->yy3));
}
break;
case 174: /* term */
case 175: /* expr */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy346).pExpr);
}
break;
case 179: /* idxlist_opt */
case 188: /* idxlist */
case 200: /* selcollist */
case 203: /* groupby_opt */
case 205: /* orderby_opt */
case 208: /* nexprlist */
case 209: /* exprlist */
case 210: /* sclp */
case 220: /* sortlist */
case 221: /* setlist */
case 228: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
}
break;
case 194: /* fullname */
case 201: /* from */
case 212: /* seltablist */
case 213: /* stl_prefix */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy65));
}
break;
case 197: /* with */
case 252: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy59));
}
break;
case 202: /* where_opt */
case 204: /* having_opt */
case 216: /* on_opt */
case 227: /* case_operand */
case 229: /* case_else */
case 238: /* when_clause */
case 243: /* key_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy132));
}
break;
case 217: /* using_opt */
case 219: /* idlist */
case 223: /* inscollist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy408));
}
break;
case 234: /* trigger_cmd_list */
case 239: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy473));
}
break;
case 236: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy378).b);
}
break;
default: break; /* If no destructor action specified: do nothing */
}
}
/*
|
| ︙ | ︙ | |||
115784 115785 115786 115787 115788 115789 115790 |
/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
unsigned char nrhs; /* Number of right-hand side symbols in the rule */
} yyRuleInfo[] = {
| < < | | < > > | > > > > | | | | | < < < | | | | | | < < < < < < < | > | > > > > | > > | | | | | | > > > < < < | | | < | < < | | | | | | | | | | | | > | < | | | | | | > > > > | | | | > | | | | | | | < < < | | | | | | | | | | > | | < | | | < < | | | | | | > | | | | | | < < | | | | | | < | | > | > | > > > > | | | | | | | | | | | | | | | | | | | | | | | | < < | | | < < < | | < | | | | < | | | | > > > > | | | | | | | | | | < | | | | | | | < | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | 116433 116434 116435 116436 116437 116438 116439 116440 116441 116442 116443 116444 116445 116446 116447 116448 116449 116450 116451 116452 116453 116454 116455 116456 116457 116458 116459 116460 116461 116462 116463 116464 116465 116466 116467 116468 116469 116470 116471 116472 116473 116474 116475 116476 116477 116478 116479 116480 116481 116482 116483 116484 116485 116486 116487 116488 116489 116490 116491 116492 116493 116494 116495 116496 116497 116498 116499 116500 116501 116502 116503 116504 116505 116506 116507 116508 116509 116510 116511 116512 116513 116514 116515 116516 116517 116518 116519 116520 116521 116522 116523 116524 116525 116526 116527 116528 116529 116530 116531 116532 116533 116534 116535 116536 116537 116538 116539 116540 116541 116542 116543 116544 116545 116546 116547 116548 116549 116550 116551 116552 116553 116554 116555 116556 116557 116558 116559 116560 116561 116562 116563 116564 116565 116566 116567 116568 116569 116570 116571 116572 116573 116574 116575 116576 116577 116578 116579 116580 116581 116582 116583 116584 116585 116586 116587 116588 116589 116590 116591 116592 116593 116594 116595 116596 116597 116598 116599 116600 116601 116602 116603 116604 116605 116606 116607 116608 116609 116610 116611 116612 116613 116614 116615 116616 116617 116618 116619 116620 116621 116622 116623 116624 116625 116626 116627 116628 116629 116630 116631 116632 116633 116634 116635 116636 116637 116638 116639 116640 116641 116642 116643 116644 116645 116646 116647 116648 116649 116650 116651 116652 116653 116654 116655 116656 116657 116658 116659 116660 116661 116662 116663 116664 116665 116666 116667 116668 116669 116670 116671 116672 116673 116674 116675 116676 116677 116678 116679 116680 116681 116682 116683 116684 116685 116686 116687 116688 116689 116690 116691 116692 116693 116694 116695 116696 116697 116698 116699 116700 116701 116702 116703 116704 116705 116706 116707 116708 116709 116710 116711 |
/* The following table contains information about every rule that
** is used during the reduce.
*/
static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
unsigned char nrhs; /* Number of right-hand side symbols in the rule */
} yyRuleInfo[] = {
{ 144, 1 },
{ 145, 2 },
{ 145, 1 },
{ 146, 1 },
{ 146, 3 },
{ 147, 0 },
{ 147, 1 },
{ 147, 3 },
{ 148, 1 },
{ 149, 3 },
{ 151, 0 },
{ 151, 1 },
{ 151, 2 },
{ 150, 0 },
{ 150, 1 },
{ 150, 1 },
{ 150, 1 },
{ 149, 2 },
{ 149, 2 },
{ 149, 2 },
{ 153, 1 },
{ 153, 0 },
{ 149, 2 },
{ 149, 3 },
{ 149, 5 },
{ 149, 2 },
{ 154, 6 },
{ 156, 1 },
{ 158, 0 },
{ 158, 3 },
{ 157, 1 },
{ 157, 0 },
{ 155, 5 },
{ 155, 2 },
{ 162, 0 },
{ 162, 2 },
{ 160, 3 },
{ 160, 1 },
{ 164, 3 },
{ 165, 1 },
{ 152, 1 },
{ 152, 1 },
{ 152, 1 },
{ 166, 0 },
{ 166, 1 },
{ 168, 1 },
{ 168, 4 },
{ 168, 6 },
{ 169, 1 },
{ 169, 2 },
{ 170, 1 },
{ 170, 1 },
{ 167, 2 },
{ 167, 0 },
{ 173, 2 },
{ 173, 2 },
{ 173, 4 },
{ 173, 3 },
{ 173, 3 },
{ 173, 2 },
{ 173, 2 },
{ 173, 3 },
{ 173, 5 },
{ 173, 2 },
{ 173, 4 },
{ 173, 4 },
{ 173, 1 },
{ 173, 2 },
{ 178, 0 },
{ 178, 1 },
{ 180, 0 },
{ 180, 2 },
{ 182, 2 },
{ 182, 3 },
{ 182, 3 },
{ 182, 3 },
{ 183, 2 },
{ 183, 2 },
{ 183, 1 },
{ 183, 1 },
{ 183, 2 },
{ 181, 3 },
{ 181, 2 },
{ 184, 0 },
{ 184, 2 },
{ 184, 2 },
{ 161, 0 },
{ 161, 2 },
{ 185, 3 },
{ 185, 1 },
{ 186, 1 },
{ 186, 0 },
{ 187, 2 },
{ 187, 7 },
{ 187, 5 },
{ 187, 5 },
{ 187, 10 },
{ 189, 0 },
{ 189, 1 },
{ 176, 0 },
{ 176, 3 },
{ 190, 0 },
{ 190, 2 },
{ 191, 1 },
{ 191, 1 },
{ 191, 1 },
{ 149, 4 },
{ 193, 2 },
{ 193, 0 },
{ 149, 8 },
{ 149, 4 },
{ 149, 1 },
{ 163, 2 },
{ 195, 1 },
{ 195, 3 },
{ 198, 1 },
{ 198, 2 },
{ 198, 1 },
{ 196, 9 },
{ 196, 1 },
{ 207, 4 },
{ 207, 5 },
{ 199, 1 },
{ 199, 1 },
{ 199, 0 },
{ 210, 2 },
{ 210, 0 },
{ 200, 3 },
{ 200, 2 },
{ 200, 4 },
{ 211, 2 },
{ 211, 1 },
{ 211, 0 },
{ 201, 0 },
{ 201, 2 },
{ 213, 2 },
{ 213, 0 },
{ 212, 7 },
{ 212, 7 },
{ 212, 7 },
{ 159, 0 },
{ 159, 2 },
{ 194, 2 },
{ 214, 1 },
{ 214, 2 },
{ 214, 3 },
{ 214, 4 },
{ 216, 2 },
{ 216, 0 },
{ 215, 0 },
{ 215, 3 },
{ 215, 2 },
{ 217, 4 },
{ 217, 0 },
{ 205, 0 },
{ 205, 3 },
{ 220, 4 },
{ 220, 2 },
{ 177, 1 },
{ 177, 1 },
{ 177, 0 },
{ 203, 0 },
{ 203, 3 },
{ 204, 0 },
{ 204, 2 },
{ 206, 0 },
{ 206, 2 },
{ 206, 4 },
{ 206, 4 },
{ 149, 6 },
{ 202, 0 },
{ 202, 2 },
{ 149, 8 },
{ 221, 5 },
{ 221, 3 },
{ 149, 6 },
{ 149, 7 },
{ 222, 2 },
{ 222, 1 },
{ 223, 0 },
{ 223, 3 },
{ 219, 3 },
{ 219, 1 },
{ 175, 1 },
{ 175, 3 },
{ 174, 1 },
{ 175, 1 },
{ 175, 1 },
{ 175, 3 },
{ 175, 5 },
{ 174, 1 },
{ 174, 1 },
{ 175, 1 },
{ 175, 3 },
{ 175, 6 },
{ 175, 5 },
{ 175, 4 },
{ 174, 1 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 175, 3 },
{ 224, 1 },
{ 224, 2 },
{ 175, 3 },
{ 175, 5 },
{ 175, 2 },
{ 175, 3 },
{ 175, 3 },
{ 175, 4 },
{ 175, 2 },
{ 175, 2 },
{ 175, 2 },
{ 175, 2 },
{ 225, 1 },
{ 225, 2 },
{ 175, 5 },
{ 226, 1 },
{ 226, 2 },
{ 175, 5 },
{ 175, 3 },
{ 175, 5 },
{ 175, 4 },
{ 175, 4 },
{ 175, 5 },
{ 228, 5 },
{ 228, 4 },
{ 229, 2 },
{ 229, 0 },
{ 227, 1 },
{ 227, 0 },
{ 209, 1 },
{ 209, 0 },
{ 208, 3 },
{ 208, 1 },
{ 149, 12 },
{ 230, 1 },
{ 230, 0 },
{ 179, 0 },
{ 179, 3 },
{ 188, 5 },
{ 188, 3 },
{ 231, 0 },
{ 231, 2 },
{ 149, 4 },
{ 149, 1 },
{ 149, 2 },
{ 149, 3 },
{ 149, 5 },
{ 149, 6 },
{ 149, 5 },
{ 149, 6 },
{ 232, 1 },
{ 232, 1 },
{ 232, 1 },
{ 232, 1 },
{ 232, 1 },
{ 171, 2 },
{ 171, 1 },
{ 172, 2 },
{ 149, 5 },
{ 233, 11 },
{ 235, 1 },
{ 235, 1 },
{ 235, 2 },
{ 235, 0 },
{ 236, 1 },
{ 236, 1 },
|
| ︙ | ︙ | |||
116077 116078 116079 116080 116081 116082 116083 |
{ 240, 3 },
{ 241, 0 },
{ 241, 3 },
{ 241, 2 },
{ 239, 7 },
{ 239, 5 },
{ 239, 5 },
| < | | | | | | | | | | | | | | | | > > > > > | 116720 116721 116722 116723 116724 116725 116726 116727 116728 116729 116730 116731 116732 116733 116734 116735 116736 116737 116738 116739 116740 116741 116742 116743 116744 116745 116746 116747 116748 116749 116750 116751 116752 116753 116754 116755 116756 116757 116758 116759 116760 116761 116762 116763 116764 116765 116766 116767 116768 116769 116770 116771 116772 116773 |
{ 240, 3 },
{ 241, 0 },
{ 241, 3 },
{ 241, 2 },
{ 239, 7 },
{ 239, 5 },
{ 239, 5 },
{ 239, 1 },
{ 175, 4 },
{ 175, 6 },
{ 192, 1 },
{ 192, 1 },
{ 192, 1 },
{ 149, 4 },
{ 149, 6 },
{ 149, 3 },
{ 243, 0 },
{ 243, 2 },
{ 242, 1 },
{ 242, 0 },
{ 149, 1 },
{ 149, 3 },
{ 149, 1 },
{ 149, 3 },
{ 149, 6 },
{ 149, 6 },
{ 244, 1 },
{ 245, 0 },
{ 245, 1 },
{ 149, 1 },
{ 149, 4 },
{ 246, 8 },
{ 247, 1 },
{ 247, 3 },
{ 248, 0 },
{ 248, 2 },
{ 249, 1 },
{ 249, 3 },
{ 250, 1 },
{ 251, 0 },
{ 251, 4 },
{ 251, 2 },
{ 197, 0 },
{ 197, 2 },
{ 197, 3 },
{ 252, 6 },
{ 252, 8 },
};
static void yy_accept(yyParser*); /* Forward Declaration */
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
|
| ︙ | ︙ | |||
116180 116181 116182 116183 116184 116185 116186 |
case 7: /* explain ::= EXPLAIN QUERY PLAN */
{ sqlite3BeginParse(pParse, 2); }
break;
case 8: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
break;
case 9: /* cmd ::= BEGIN transtype trans_opt */
| | | | | | | 116827 116828 116829 116830 116831 116832 116833 116834 116835 116836 116837 116838 116839 116840 116841 116842 116843 116844 116845 116846 116847 116848 116849 116850 116851 |
case 7: /* explain ::= EXPLAIN QUERY PLAN */
{ sqlite3BeginParse(pParse, 2); }
break;
case 8: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
break;
case 9: /* cmd ::= BEGIN transtype trans_opt */
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy328);}
break;
case 13: /* transtype ::= */
{yygotominor.yy328 = TK_DEFERRED;}
break;
case 14: /* transtype ::= DEFERRED */
case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
{yygotominor.yy328 = yymsp[0].major;}
break;
case 17: /* cmd ::= COMMIT trans_opt */
case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
{sqlite3CommitTransaction(pParse);}
break;
case 19: /* cmd ::= ROLLBACK trans_opt */
{sqlite3RollbackTransaction(pParse);}
|
| ︙ | ︙ | |||
116216 116217 116218 116219 116220 116221 116222 |
case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
break;
case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
| | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > > > > > > > > > > | | | | | | | | | | > > > > > | > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | > | | | | | | | | | | > | < < | > | > > | > | < < < < < < < < < < < < < < < | < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | < | < < < | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | 116863 116864 116865 116866 116867 116868 116869 116870 116871 116872 116873 116874 116875 116876 116877 116878 116879 116880 116881 116882 116883 116884 116885 116886 116887 116888 116889 116890 116891 116892 116893 116894 116895 116896 116897 116898 116899 116900 116901 116902 116903 116904 116905 116906 116907 116908 116909 116910 116911 116912 116913 116914 116915 116916 116917 116918 116919 116920 116921 116922 116923 116924 116925 116926 116927 116928 116929 116930 116931 116932 116933 116934 116935 116936 116937 116938 116939 116940 116941 116942 116943 116944 116945 116946 116947 116948 116949 116950 116951 116952 116953 116954 116955 116956 116957 116958 116959 116960 116961 116962 116963 116964 116965 116966 116967 116968 116969 116970 116971 116972 116973 116974 116975 116976 116977 116978 116979 116980 116981 116982 116983 116984 116985 116986 116987 116988 116989 116990 116991 116992 116993 116994 116995 116996 116997 116998 116999 117000 117001 117002 117003 117004 117005 117006 117007 117008 117009 117010 117011 117012 117013 117014 117015 117016 117017 117018 117019 117020 117021 117022 117023 117024 117025 117026 117027 117028 117029 117030 117031 117032 117033 117034 117035 117036 117037 117038 117039 117040 117041 117042 117043 117044 117045 117046 117047 117048 117049 117050 117051 117052 117053 117054 117055 117056 117057 117058 117059 117060 117061 117062 117063 117064 117065 117066 117067 117068 117069 117070 117071 117072 117073 117074 117075 117076 117077 117078 117079 117080 117081 117082 117083 117084 117085 117086 117087 117088 117089 117090 117091 117092 117093 117094 117095 117096 117097 117098 117099 117100 117101 117102 117103 117104 117105 117106 117107 117108 117109 117110 117111 117112 117113 117114 117115 117116 117117 117118 117119 117120 117121 117122 117123 117124 117125 117126 117127 117128 117129 117130 117131 117132 117133 117134 117135 117136 117137 117138 117139 117140 117141 117142 117143 117144 117145 117146 117147 117148 117149 117150 117151 117152 117153 117154 117155 117156 117157 117158 117159 117160 117161 117162 117163 117164 117165 117166 117167 117168 117169 117170 117171 117172 117173 117174 117175 117176 117177 117178 117179 117180 117181 117182 117183 117184 117185 117186 117187 117188 117189 117190 117191 117192 117193 117194 117195 117196 117197 117198 117199 117200 117201 117202 117203 117204 117205 117206 117207 117208 117209 117210 117211 117212 117213 117214 117215 117216 117217 117218 117219 117220 117221 117222 117223 117224 117225 117226 117227 117228 117229 117230 117231 117232 117233 117234 117235 117236 117237 117238 117239 117240 117241 117242 117243 117244 117245 117246 117247 117248 117249 117250 117251 117252 117253 117254 117255 117256 117257 117258 117259 117260 117261 117262 117263 117264 117265 117266 117267 117268 117269 117270 117271 117272 117273 117274 117275 117276 117277 117278 117279 117280 117281 117282 117283 117284 117285 117286 117287 117288 117289 117290 117291 117292 117293 117294 117295 117296 117297 117298 117299 117300 117301 117302 117303 117304 117305 117306 117307 117308 117309 117310 117311 117312 117313 117314 117315 117316 117317 117318 117319 117320 117321 117322 117323 117324 117325 117326 117327 117328 117329 117330 117331 117332 117333 117334 117335 117336 117337 117338 117339 117340 117341 117342 117343 117344 117345 117346 117347 117348 117349 117350 117351 117352 117353 117354 117355 117356 117357 117358 117359 117360 117361 117362 117363 117364 117365 117366 117367 117368 117369 117370 117371 117372 117373 117374 117375 117376 117377 117378 117379 117380 117381 117382 117383 117384 117385 117386 117387 117388 117389 117390 117391 117392 117393 117394 117395 117396 117397 117398 117399 117400 117401 117402 117403 117404 117405 117406 117407 117408 117409 117410 117411 117412 117413 117414 117415 117416 117417 117418 117419 117420 117421 117422 117423 117424 117425 117426 117427 117428 117429 117430 117431 117432 117433 117434 117435 117436 117437 117438 117439 117440 117441 117442 117443 117444 117445 117446 117447 117448 117449 117450 117451 117452 117453 117454 117455 117456 117457 117458 117459 117460 117461 117462 117463 117464 117465 117466 117467 117468 117469 117470 117471 117472 117473 117474 117475 117476 117477 117478 117479 117480 117481 117482 117483 117484 117485 117486 117487 117488 117489 117490 117491 117492 117493 117494 117495 117496 117497 117498 117499 117500 117501 117502 117503 117504 117505 117506 117507 117508 117509 117510 117511 117512 117513 117514 117515 117516 117517 117518 117519 117520 117521 117522 117523 117524 117525 117526 117527 117528 117529 117530 117531 117532 117533 117534 117535 117536 117537 117538 117539 117540 117541 117542 117543 117544 117545 117546 117547 117548 117549 117550 117551 117552 117553 117554 117555 117556 117557 117558 117559 117560 117561 117562 117563 117564 117565 117566 117567 117568 117569 117570 117571 117572 117573 117574 117575 117576 117577 117578 117579 117580 117581 117582 117583 117584 117585 117586 117587 117588 117589 117590 117591 117592 117593 117594 117595 117596 117597 117598 117599 117600 117601 117602 117603 117604 117605 117606 117607 117608 117609 117610 117611 117612 117613 117614 117615 117616 117617 117618 117619 117620 117621 117622 117623 117624 117625 117626 117627 117628 117629 117630 117631 117632 117633 117634 117635 117636 117637 117638 117639 117640 117641 117642 117643 117644 117645 117646 117647 117648 117649 117650 117651 117652 117653 117654 117655 117656 117657 117658 117659 117660 117661 117662 117663 117664 117665 117666 117667 117668 117669 117670 117671 117672 117673 117674 117675 117676 117677 117678 117679 117680 117681 117682 117683 117684 117685 117686 117687 117688 117689 117690 117691 117692 117693 117694 117695 117696 117697 117698 117699 117700 117701 117702 117703 117704 117705 117706 117707 117708 117709 117710 117711 117712 117713 117714 117715 117716 117717 117718 117719 117720 117721 117722 117723 117724 117725 117726 117727 117728 117729 117730 117731 117732 117733 117734 117735 117736 117737 117738 117739 117740 117741 117742 117743 117744 117745 117746 117747 117748 117749 117750 117751 117752 117753 117754 117755 117756 117757 117758 117759 117760 117761 117762 117763 117764 117765 117766 117767 117768 117769 117770 117771 117772 117773 117774 117775 117776 117777 117778 117779 117780 117781 117782 117783 117784 117785 117786 117787 117788 117789 117790 117791 117792 117793 117794 117795 117796 117797 117798 117799 117800 117801 117802 117803 117804 117805 117806 117807 117808 117809 117810 117811 117812 117813 117814 117815 117816 117817 117818 117819 117820 117821 117822 117823 117824 117825 117826 117827 117828 117829 117830 117831 117832 117833 117834 117835 117836 117837 117838 117839 117840 117841 117842 117843 117844 117845 117846 117847 117848 117849 117850 117851 117852 117853 117854 117855 117856 117857 117858 117859 117860 117861 117862 117863 117864 117865 117866 117867 117868 117869 117870 117871 117872 117873 117874 117875 117876 117877 117878 117879 117880 117881 117882 117883 117884 117885 117886 117887 117888 117889 117890 117891 117892 117893 117894 117895 117896 117897 117898 117899 117900 117901 117902 117903 117904 117905 117906 117907 117908 117909 117910 117911 117912 117913 117914 117915 117916 117917 117918 117919 117920 117921 117922 117923 117924 117925 117926 117927 117928 117929 117930 117931 117932 117933 117934 117935 117936 117937 117938 117939 117940 117941 117942 117943 117944 117945 117946 117947 117948 117949 117950 117951 117952 117953 117954 117955 117956 117957 117958 117959 117960 117961 117962 117963 117964 117965 117966 117967 117968 117969 117970 117971 117972 117973 117974 117975 117976 117977 117978 117979 117980 117981 117982 117983 117984 117985 117986 |
case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
break;
case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy328,0,0,yymsp[-2].minor.yy328);
}
break;
case 27: /* createkw ::= CREATE */
{
pParse->db->lookaside.bEnabled = 0;
yygotominor.yy0 = yymsp[0].minor.yy0;
}
break;
case 28: /* ifnotexists ::= */
case 31: /* temp ::= */ yytestcase(yyruleno==31);
case 68: /* autoinc ::= */ yytestcase(yyruleno==68);
case 81: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==81);
case 83: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==83);
case 85: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==85);
case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
case 218: /* between_op ::= BETWEEN */ yytestcase(yyruleno==218);
case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
{yygotominor.yy328 = 0;}
break;
case 29: /* ifnotexists ::= IF NOT EXISTS */
case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
case 69: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==69);
case 84: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==84);
case 107: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==107);
case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
{yygotominor.yy328 = 1;}
break;
case 32: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
{
sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy186,0);
}
break;
case 33: /* create_table_args ::= AS select */
{
sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy3);
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
}
break;
case 34: /* table_options ::= */
{yygotominor.yy186 = 0;}
break;
case 35: /* table_options ::= WITHOUT nm */
{
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
yygotominor.yy186 = TF_WithoutRowid;
}else{
yygotominor.yy186 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
break;
case 38: /* column ::= columnid type carglist */
{
yygotominor.yy0.z = yymsp[-2].minor.yy0.z;
yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n;
}
break;
case 39: /* columnid ::= nm */
{
sqlite3AddColumn(pParse,&yymsp[0].minor.yy0);
yygotominor.yy0 = yymsp[0].minor.yy0;
pParse->constraintName.n = 0;
}
break;
case 40: /* nm ::= ID|INDEXED */
case 41: /* nm ::= STRING */ yytestcase(yyruleno==41);
case 42: /* nm ::= JOIN_KW */ yytestcase(yyruleno==42);
case 45: /* typetoken ::= typename */ yytestcase(yyruleno==45);
case 48: /* typename ::= ID|STRING */ yytestcase(yyruleno==48);
case 130: /* as ::= AS nm */ yytestcase(yyruleno==130);
case 131: /* as ::= ID|STRING */ yytestcase(yyruleno==131);
case 141: /* dbnm ::= DOT nm */ yytestcase(yyruleno==141);
case 150: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==150);
case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
case 256: /* nmnum ::= plus_num */ yytestcase(yyruleno==256);
case 257: /* nmnum ::= nm */ yytestcase(yyruleno==257);
case 258: /* nmnum ::= ON */ yytestcase(yyruleno==258);
case 259: /* nmnum ::= DELETE */ yytestcase(yyruleno==259);
case 260: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==260);
case 261: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==261);
case 262: /* plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==262);
case 263: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==263);
case 279: /* trnm ::= nm */ yytestcase(yyruleno==279);
{yygotominor.yy0 = yymsp[0].minor.yy0;}
break;
case 44: /* type ::= typetoken */
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
break;
case 46: /* typetoken ::= typename LP signed RP */
{
yygotominor.yy0.z = yymsp[-3].minor.yy0.z;
yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
break;
case 47: /* typetoken ::= typename LP signed COMMA signed RP */
{
yygotominor.yy0.z = yymsp[-5].minor.yy0.z;
yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
}
break;
case 49: /* typename ::= typename ID|STRING */
{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
break;
case 54: /* ccons ::= CONSTRAINT nm */
case 92: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==92);
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
case 55: /* ccons ::= DEFAULT term */
case 57: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==57);
{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy346);}
break;
case 56: /* ccons ::= DEFAULT LP expr RP */
{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy346);}
break;
case 58: /* ccons ::= DEFAULT MINUS term */
{
ExprSpan v;
v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy346.pExpr, 0, 0);
v.zStart = yymsp[-1].minor.yy0.z;
v.zEnd = yymsp[0].minor.yy346.zEnd;
sqlite3AddDefaultValue(pParse,&v);
}
break;
case 59: /* ccons ::= DEFAULT ID|INDEXED */
{
ExprSpan v;
spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0);
sqlite3AddDefaultValue(pParse,&v);
}
break;
case 61: /* ccons ::= NOT NULL onconf */
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy328);}
break;
case 62: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy328,yymsp[0].minor.yy328,yymsp[-2].minor.yy328);}
break;
case 63: /* ccons ::= UNIQUE onconf */
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy328,0,0,0,0);}
break;
case 64: /* ccons ::= CHECK LP expr RP */
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy346.pExpr);}
break;
case 65: /* ccons ::= REFERENCES nm idxlist_opt refargs */
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy328);}
break;
case 66: /* ccons ::= defer_subclause */
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy328);}
break;
case 67: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
case 70: /* refargs ::= */
{ yygotominor.yy328 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
case 71: /* refargs ::= refargs refarg */
{ yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
break;
case 72: /* refarg ::= MATCH nm */
case 73: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==73);
{ yygotominor.yy429.value = 0; yygotominor.yy429.mask = 0x000000; }
break;
case 74: /* refarg ::= ON DELETE refact */
{ yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
break;
case 75: /* refarg ::= ON UPDATE refact */
{ yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
break;
case 76: /* refact ::= SET NULL */
{ yygotominor.yy328 = OE_SetNull; /* EV: R-33326-45252 */}
break;
case 77: /* refact ::= SET DEFAULT */
{ yygotominor.yy328 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
case 78: /* refact ::= CASCADE */
{ yygotominor.yy328 = OE_Cascade; /* EV: R-33326-45252 */}
break;
case 79: /* refact ::= RESTRICT */
{ yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
break;
case 80: /* refact ::= NO ACTION */
{ yygotominor.yy328 = OE_None; /* EV: R-33326-45252 */}
break;
case 82: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
{yygotominor.yy328 = yymsp[0].minor.yy328;}
break;
case 86: /* conslist_opt ::= */
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
break;
case 87: /* conslist_opt ::= COMMA conslist */
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
break;
case 90: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);}
break;
case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);}
break;
case 95: /* tcons ::= CHECK LP expr RP onconf */
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
break;
case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
{
sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328);
sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328);
}
break;
case 99: /* onconf ::= */
{yygotominor.yy328 = OE_Default;}
break;
case 101: /* orconf ::= */
{yygotominor.yy186 = OE_Default;}
break;
case 102: /* orconf ::= OR resolvetype */
{yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
break;
case 104: /* resolvetype ::= IGNORE */
{yygotominor.yy328 = OE_Ignore;}
break;
case 105: /* resolvetype ::= REPLACE */
{yygotominor.yy328 = OE_Replace;}
break;
case 106: /* cmd ::= DROP TABLE ifexists fullname */
{
sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
}
break;
case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
{
sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328);
}
break;
case 110: /* cmd ::= DROP VIEW ifexists fullname */
{
sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
}
break;
case 111: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
sqlite3Select(pParse, yymsp[0].minor.yy3, &dest);
sqlite3ExplainBegin(pParse->pVdbe);
sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy3);
sqlite3ExplainFinish(pParse->pVdbe);
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
}
break;
case 112: /* select ::= with selectnowith */
{
if( yymsp[0].minor.yy3 ){
yymsp[0].minor.yy3->pWith = yymsp[-1].minor.yy59;
}else{
sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy59);
}
yygotominor.yy3 = yymsp[0].minor.yy3;
}
break;
case 113: /* selectnowith ::= oneselect */
case 119: /* oneselect ::= values */ yytestcase(yyruleno==119);
{yygotominor.yy3 = yymsp[0].minor.yy3;}
break;
case 114: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
if( yymsp[0].minor.yy3 ){
yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3;
if( yymsp[-1].minor.yy328!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
}
yygotominor.yy3 = yymsp[0].minor.yy3;
}
break;
case 116: /* multiselect_op ::= UNION ALL */
{yygotominor.yy328 = TK_ALL;}
break;
case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy65,yymsp[-4].minor.yy132,yymsp[-3].minor.yy14,yymsp[-2].minor.yy132,yymsp[-1].minor.yy14,yymsp[-7].minor.yy381,yymsp[0].minor.yy476.pLimit,yymsp[0].minor.yy476.pOffset);
}
break;
case 120: /* values ::= VALUES LP nexprlist RP */
{
yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
}
break;
case 121: /* values ::= values COMMA LP exprlist RP */
{
Select *pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
if( pRight ){
pRight->op = TK_ALL;
pRight->pPrior = yymsp[-4].minor.yy3;
yygotominor.yy3 = pRight;
}else{
yygotominor.yy3 = yymsp[-4].minor.yy3;
}
}
break;
case 122: /* distinct ::= DISTINCT */
{yygotominor.yy381 = SF_Distinct;}
break;
case 123: /* distinct ::= ALL */
case 124: /* distinct ::= */ yytestcase(yyruleno==124);
{yygotominor.yy381 = 0;}
break;
case 125: /* sclp ::= selcollist COMMA */
case 243: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==243);
{yygotominor.yy14 = yymsp[-1].minor.yy14;}
break;
case 126: /* sclp ::= */
case 154: /* orderby_opt ::= */ yytestcase(yyruleno==154);
case 161: /* groupby_opt ::= */ yytestcase(yyruleno==161);
case 236: /* exprlist ::= */ yytestcase(yyruleno==236);
case 242: /* idxlist_opt ::= */ yytestcase(yyruleno==242);
{yygotominor.yy14 = 0;}
break;
case 127: /* selcollist ::= sclp expr as */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr);
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1);
sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346);
}
break;
case 128: /* selcollist ::= sclp STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
}
break;
case 129: /* selcollist ::= sclp nm DOT STAR */
{
Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
}
break;
case 132: /* as ::= */
{yygotominor.yy0.n = 0;}
break;
case 133: /* from ::= */
{yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
break;
case 134: /* from ::= FROM seltablist */
{
yygotominor.yy65 = yymsp[0].minor.yy65;
sqlite3SrcListShiftJoinType(yygotominor.yy65);
}
break;
case 135: /* stl_prefix ::= seltablist joinop */
{
yygotominor.yy65 = yymsp[-1].minor.yy65;
if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328;
}
break;
case 136: /* stl_prefix ::= */
{yygotominor.yy65 = 0;}
break;
case 137: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0);
}
break;
case 138: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
}
break;
case 139: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){
yygotominor.yy65 = yymsp[-4].minor.yy65;
}else if( yymsp[-4].minor.yy65->nSrc==1 ){
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
if( yygotominor.yy65 ){
struct SrcList_item *pNew = &yygotominor.yy65->a[yygotominor.yy65->nSrc-1];
struct SrcList_item *pOld = yymsp[-4].minor.yy65->a;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy65);
}else{
Select *pSubquery;
sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy65);
pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,SF_NestedFrom,0,0);
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
}
}
break;
case 140: /* dbnm ::= */
case 149: /* indexed_opt ::= */ yytestcase(yyruleno==149);
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
break;
case 142: /* fullname ::= nm dbnm */
{yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
break;
case 143: /* joinop ::= COMMA|JOIN */
{ yygotominor.yy328 = JT_INNER; }
break;
case 144: /* joinop ::= JOIN_KW JOIN */
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
break;
case 145: /* joinop ::= JOIN_KW nm JOIN */
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
break;
case 146: /* joinop ::= JOIN_KW nm nm JOIN */
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
break;
case 147: /* on_opt ::= ON expr */
case 164: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==164);
case 171: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==171);
case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
case 233: /* case_operand ::= expr */ yytestcase(yyruleno==233);
{yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;}
break;
case 148: /* on_opt ::= */
case 163: /* having_opt ::= */ yytestcase(yyruleno==163);
case 170: /* where_opt ::= */ yytestcase(yyruleno==170);
case 232: /* case_else ::= */ yytestcase(yyruleno==232);
case 234: /* case_operand ::= */ yytestcase(yyruleno==234);
{yygotominor.yy132 = 0;}
break;
case 151: /* indexed_opt ::= NOT INDEXED */
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
break;
case 152: /* using_opt ::= USING LP idlist RP */
case 180: /* inscollist_opt ::= LP idlist RP */ yytestcase(yyruleno==180);
{yygotominor.yy408 = yymsp[-1].minor.yy408;}
break;
case 153: /* using_opt ::= */
case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
{yygotominor.yy408 = 0;}
break;
case 155: /* orderby_opt ::= ORDER BY sortlist */
case 162: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==162);
case 235: /* exprlist ::= nexprlist */ yytestcase(yyruleno==235);
{yygotominor.yy14 = yymsp[0].minor.yy14;}
break;
case 156: /* sortlist ::= sortlist COMMA expr sortorder */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy346.pExpr);
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
}
break;
case 157: /* sortlist ::= expr sortorder */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy346.pExpr);
if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328;
}
break;
case 158: /* sortorder ::= ASC */
case 160: /* sortorder ::= */ yytestcase(yyruleno==160);
{yygotominor.yy328 = SQLITE_SO_ASC;}
break;
case 159: /* sortorder ::= DESC */
{yygotominor.yy328 = SQLITE_SO_DESC;}
break;
case 165: /* limit_opt ::= */
{yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
break;
case 166: /* limit_opt ::= LIMIT expr */
{yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
break;
case 167: /* limit_opt ::= LIMIT expr OFFSET expr */
{yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
break;
case 168: /* limit_opt ::= LIMIT expr COMMA expr */
{yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
break;
case 169: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
{
sqlite3WithPush(pParse, yymsp[-5].minor.yy59, 1);
sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0);
sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132);
}
break;
case 172: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
{
sqlite3WithPush(pParse, yymsp[-7].minor.yy59, 1);
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0);
sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list");
sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186);
}
break;
case 173: /* setlist ::= setlist COMMA nm EQ expr */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr);
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
}
break;
case 174: /* setlist ::= nm EQ expr */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr);
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
}
break;
case 175: /* cmd ::= with insert_cmd INTO fullname inscollist_opt select */
{
sqlite3WithPush(pParse, yymsp[-5].minor.yy59, 1);
sqlite3Insert(pParse, yymsp[-2].minor.yy65, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);
}
break;
case 176: /* cmd ::= with insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
{
sqlite3WithPush(pParse, yymsp[-6].minor.yy59, 1);
sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);
}
break;
case 177: /* insert_cmd ::= INSERT orconf */
{yygotominor.yy186 = yymsp[0].minor.yy186;}
break;
case 178: /* insert_cmd ::= REPLACE */
{yygotominor.yy186 = OE_Replace;}
break;
case 181: /* idlist ::= idlist COMMA nm */
{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
break;
case 182: /* idlist ::= nm */
{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
break;
case 183: /* expr ::= term */
{yygotominor.yy346 = yymsp[0].minor.yy346;}
break;
case 184: /* expr ::= LP expr RP */
{yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
break;
case 185: /* term ::= NULL */
case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
{spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
break;
case 186: /* expr ::= ID|INDEXED */
case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
{spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
break;
case 188: /* expr ::= nm DOT nm */
{
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
}
break;
case 189: /* expr ::= nm DOT nm DOT nm */
{
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
}
break;
case 192: /* expr ::= VARIABLE */
{
if( yymsp[0].minor.yy0.n>=2 && yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1]) ){
/* When doing a nested parse, one can include terms in an expression
** that look like this: #1 #2 ... These terms refer to registers
** in the virtual machine. #N is the N-th register. */
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &yymsp[0].minor.yy0);
yygotominor.yy346.pExpr = 0;
}else{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);
if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable);
}
}else{
spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr);
}
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
}
break;
case 193: /* expr ::= expr COLLATE ID|STRING */
{
yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 194: /* expr ::= CAST LP expr AS typetoken RP */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0);
spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
}
break;
case 195: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
}
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
if( yymsp[-2].minor.yy381 && yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->flags |= EP_Distinct;
}
}
break;
case 196: /* expr ::= ID|INDEXED LP STAR RP */
{
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
}
break;
case 197: /* term ::= CTIME_KW */
{
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
}
break;
case 198: /* expr ::= expr AND expr */
case 199: /* expr ::= expr OR expr */ yytestcase(yyruleno==199);
case 200: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==200);
case 201: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==201);
case 202: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==202);
case 203: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==203);
case 204: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==204);
case 205: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==205);
{spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);}
break;
case 206: /* likeop ::= LIKE_KW|MATCH */
{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.bNot = 0;}
break;
case 207: /* likeop ::= NOT LIKE_KW|MATCH */
{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.bNot = 1;}
break;
case 208: /* expr ::= expr likeop expr */
{
ExprList *pList;
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy346.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy346.pExpr);
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy96.eOperator);
if( yymsp[-1].minor.yy96.bNot ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
}
break;
case 209: /* expr ::= expr likeop expr ESCAPE expr */
{
ExprList *pList;
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy346.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy96.eOperator);
if( yymsp[-3].minor.yy96.bNot ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
}
break;
case 210: /* expr ::= expr ISNULL|NOTNULL */
{spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
break;
case 211: /* expr ::= expr NOT NULL */
{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
break;
case 212: /* expr ::= expr IS expr */
{
spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
}
break;
case 213: /* expr ::= expr IS NOT expr */
{
spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
}
break;
case 214: /* expr ::= NOT expr */
case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
{spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
break;
case 216: /* expr ::= MINUS expr */
{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
break;
case 217: /* expr ::= PLUS expr */
{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
break;
case 220: /* expr ::= expr between_op expr AND expr */
{
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
}
break;
case 223: /* expr ::= expr in_op LP exprlist RP */
{
if( yymsp[-1].minor.yy14==0 ){
/* Expressions of the form
**
** expr1 IN ()
** expr1 NOT IN ()
**
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy328]);
sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy346.pExpr);
}else{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
}
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
}
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 224: /* expr ::= LP select RP */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 225: /* expr ::= expr in_op LP select RP */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 226: /* expr ::= expr in_op nm dbnm */
{
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SrcListDelete(pParse->db, pSrc);
}
if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
yygotominor.yy346.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
}
break;
case 227: /* expr ::= EXISTS LP select RP */
{
Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
if( p ){
p->x.pSelect = yymsp[-1].minor.yy3;
ExprSetProperty(p, EP_xIsSelect);
sqlite3ExprSetHeight(pParse, p);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy132 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy132) : yymsp[-2].minor.yy14;
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy132);
}
yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
}
break;
case 230: /* case_exprlist ::= WHEN expr THEN expr */
{
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
}
break;
case 237: /* nexprlist ::= nexprlist COMMA expr */
{yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);}
break;
case 238: /* nexprlist ::= expr */
{yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
break;
case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */
{
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy328,
&yymsp[-11].minor.yy0, yymsp[0].minor.yy132, SQLITE_SO_ASC, yymsp[-8].minor.yy328);
}
break;
case 240: /* uniqueflag ::= UNIQUE */
case 291: /* raisetype ::= ABORT */ yytestcase(yyruleno==291);
{yygotominor.yy328 = OE_Abort;}
break;
case 241: /* uniqueflag ::= */
{yygotominor.yy328 = OE_None;}
break;
case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */
{
Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
}
break;
case 245: /* idxlist ::= nm collate sortorder */
{
Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
}
break;
case 246: /* collate ::= */
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
break;
case 248: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
break;
case 249: /* cmd ::= VACUUM */
case 250: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==250);
{sqlite3Vacuum(pParse);}
break;
case 251: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
break;
case 264: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
Token all;
all.z = yymsp[-3].minor.yy0.z;
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
}
break;
case 265: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328);
yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
}
break;
case 266: /* trigger_time ::= BEFORE */
case 269: /* trigger_time ::= */ yytestcase(yyruleno==269);
{ yygotominor.yy328 = TK_BEFORE; }
break;
case 267: /* trigger_time ::= AFTER */
{ yygotominor.yy328 = TK_AFTER; }
break;
case 268: /* trigger_time ::= INSTEAD OF */
{ yygotominor.yy328 = TK_INSTEAD;}
break;
case 270: /* trigger_event ::= DELETE|INSERT */
case 271: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==271);
{yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
break;
case 272: /* trigger_event ::= UPDATE OF idlist */
{yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
break;
case 275: /* when_clause ::= */
case 296: /* key_opt ::= */ yytestcase(yyruleno==296);
{ yygotominor.yy132 = 0; }
break;
case 276: /* when_clause ::= WHEN expr */
case 297: /* key_opt ::= KEY expr */ yytestcase(yyruleno==297);
{ yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
break;
case 277: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
assert( yymsp[-2].minor.yy473!=0 );
yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473;
yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473;
yygotominor.yy473 = yymsp[-2].minor.yy473;
}
break;
case 278: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
assert( yymsp[-1].minor.yy473!=0 );
yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473;
yygotominor.yy473 = yymsp[-1].minor.yy473;
}
break;
case 280: /* trnm ::= nm DOT nm */
{
yygotominor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
"statements within triggers");
}
break;
case 282: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
case 283: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
case 284: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
{ yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); }
break;
case 285: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
{yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);}
break;
case 286: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
{yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
break;
case 287: /* trigger_cmd ::= select */
{yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
break;
case 288: /* expr ::= RAISE LP IGNORE RP */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->affinity = OE_Ignore;
}
yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 289: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
if( yygotominor.yy346.pExpr ) {
yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328;
}
yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 290: /* raisetype ::= ROLLBACK */
{yygotominor.yy328 = OE_Rollback;}
break;
case 292: /* raisetype ::= FAIL */
{yygotominor.yy328 = OE_Fail;}
break;
case 293: /* cmd ::= DROP TRIGGER ifexists fullname */
{
sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
}
break;
case 294: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132);
}
break;
case 295: /* cmd ::= DETACH database_kw_opt expr */
{
sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
}
break;
case 300: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
break;
case 301: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 302: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
break;
case 303: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 304: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
}
break;
case 305: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
{
sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
}
break;
case 306: /* add_column_fullname ::= fullname */
{
pParse->db->lookaside.bEnabled = 0;
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
}
break;
case 309: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
case 310: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
case 311: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy328);
}
break;
case 314: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
case 316: /* vtabargtoken ::= ANY */
case 317: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==317);
case 318: /* lp ::= LP */ yytestcase(yyruleno==318);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
case 322: /* with ::= */
{yygotominor.yy59 = 0;}
break;
case 323: /* with ::= WITH wqlist */
case 324: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==324);
{ yygotominor.yy59 = yymsp[0].minor.yy59; }
break;
case 325: /* wqlist ::= nm idxlist_opt AS LP select RP */
{
yygotominor.yy59 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy3);
}
break;
case 326: /* wqlist ::= wqlist COMMA nm idxlist_opt AS LP select RP */
{
yygotominor.yy59 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy59, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy3);
}
break;
default:
/* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
/* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
/* (2) cmdlist ::= ecmd */ yytestcase(yyruleno==2);
/* (3) ecmd ::= SEMI */ yytestcase(yyruleno==3);
/* (4) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==4);
/* (10) trans_opt ::= */ yytestcase(yyruleno==10);
/* (11) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==11);
/* (12) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==12);
/* (20) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==20);
/* (21) savepoint_opt ::= */ yytestcase(yyruleno==21);
/* (25) cmd ::= create_table create_table_args */ yytestcase(yyruleno==25);
/* (36) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==36);
/* (37) columnlist ::= column */ yytestcase(yyruleno==37);
/* (43) type ::= */ yytestcase(yyruleno==43);
/* (50) signed ::= plus_num */ yytestcase(yyruleno==50);
/* (51) signed ::= minus_num */ yytestcase(yyruleno==51);
/* (52) carglist ::= carglist ccons */ yytestcase(yyruleno==52);
/* (53) carglist ::= */ yytestcase(yyruleno==53);
/* (60) ccons ::= NULL onconf */ yytestcase(yyruleno==60);
/* (88) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==88);
/* (89) conslist ::= tcons */ yytestcase(yyruleno==89);
/* (91) tconscomma ::= */ yytestcase(yyruleno==91);
/* (273) foreach_clause ::= */ yytestcase(yyruleno==273);
/* (274) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==274);
/* (281) tridxby ::= */ yytestcase(yyruleno==281);
/* (298) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==298);
/* (299) database_kw_opt ::= */ yytestcase(yyruleno==299);
/* (307) kwcolumn_opt ::= */ yytestcase(yyruleno==307);
/* (308) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==308);
/* (312) vtabarglist ::= vtabarg */ yytestcase(yyruleno==312);
/* (313) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==313);
/* (315) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==315);
/* (319) anylist ::= */ yytestcase(yyruleno==319);
/* (320) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==320);
/* (321) anylist ::= anylist ANY */ yytestcase(yyruleno==321);
break;
};
assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
yygoto = yyRuleInfo[yyruleno].lhs;
yysize = yyRuleInfo[yyruleno].nrhs;
yypParser->yyidx -= yysize;
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
|
| ︙ | ︙ | |||
117652 117653 117654 117655 117656 117657 117658 | ** The code in this file implements a function that determines whether ** or not a given identifier is really an SQL keyword. The same thing ** might be implemented more directly using a hand-written hash table. ** But by using this automatically generated code, the size of the code ** is substantially reduced. This is important for embedded applications ** on platforms with limited memory. */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 118311 118312 118313 118314 118315 118316 118317 118318 118319 118320 118321 118322 118323 118324 118325 118326 118327 118328 118329 118330 118331 118332 118333 118334 118335 118336 118337 118338 118339 118340 118341 118342 118343 118344 118345 118346 118347 118348 118349 118350 118351 118352 118353 118354 118355 118356 118357 118358 118359 118360 118361 118362 118363 118364 118365 118366 118367 118368 118369 118370 118371 118372 118373 118374 118375 118376 118377 118378 118379 118380 118381 118382 118383 118384 118385 118386 118387 118388 118389 118390 118391 118392 118393 118394 118395 118396 118397 118398 118399 118400 118401 118402 118403 118404 118405 118406 118407 118408 118409 118410 118411 118412 118413 118414 118415 118416 118417 118418 118419 118420 118421 118422 118423 118424 118425 118426 118427 118428 118429 118430 118431 118432 118433 118434 118435 118436 118437 118438 118439 118440 118441 118442 118443 118444 |
** The code in this file implements a function that determines whether
** or not a given identifier is really an SQL keyword. The same thing
** might be implemented more directly using a hand-written hash table.
** But by using this automatically generated code, the size of the code
** is substantially reduced. This is important for embedded applications
** on platforms with limited memory.
*/
/* Hash score: 182 */
static int keywordCode(const char *z, int n){
/* zText[] encodes 834 bytes of keywords in 554 bytes */
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
/* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
/* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
/* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
/* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
/* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING */
/* VACUUMVIEWINITIALLY */
static const char zText[553] = {
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',
'V','I','E','W','I','N','I','T','I','A','L','L','Y',
};
static const unsigned char aHash[127] = {
76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
42, 12, 78, 15, 0, 116, 85, 54, 112, 0, 19, 0, 0,
121, 0, 119, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
0, 69, 6, 0, 48, 90, 102, 0, 118, 101, 0, 0, 44,
0, 103, 24, 0, 17, 0, 122, 53, 23, 0, 5, 110, 25,
96, 0, 0, 124, 106, 60, 123, 57, 28, 55, 0, 91, 0,
100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 120, 80, 113,
62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
};
static const unsigned char aNext[124] = {
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
73, 83, 0, 35, 68, 0, 0,
};
static const unsigned char aLen[124] = {
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
3, 5, 5, 6, 4, 9, 3,
};
static const unsigned short int aOffset[124] = {
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
521, 524, 529, 534, 540, 544, 549,
};
static const unsigned char aCode[124] = {
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
};
int h, i;
if( n<2 ) return TK_ID;
h = ((charMap(z[0])*4) ^
(charMap(z[n-1])*3) ^
n) % 127;
for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
|
| ︙ | ︙ | |||
117829 117830 117831 117832 117833 117834 117835 |
testcase( i==42 ); /* SET */
testcase( i==43 ); /* TEMPORARY */
testcase( i==44 ); /* TEMP */
testcase( i==45 ); /* OR */
testcase( i==46 ); /* UNIQUE */
testcase( i==47 ); /* QUERY */
testcase( i==48 ); /* WITHOUT */
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | 118488 118489 118490 118491 118492 118493 118494 118495 118496 118497 118498 118499 118500 118501 118502 118503 118504 118505 118506 118507 118508 118509 118510 118511 118512 118513 118514 118515 118516 118517 118518 118519 118520 118521 118522 118523 118524 118525 118526 118527 118528 118529 118530 118531 118532 118533 118534 118535 118536 118537 118538 118539 118540 118541 118542 118543 118544 118545 118546 118547 118548 118549 118550 118551 118552 118553 118554 118555 118556 118557 118558 118559 118560 118561 118562 118563 118564 118565 118566 118567 118568 118569 118570 118571 118572 118573 118574 118575 118576 118577 118578 118579 118580 118581 118582 118583 118584 118585 |
testcase( i==42 ); /* SET */
testcase( i==43 ); /* TEMPORARY */
testcase( i==44 ); /* TEMP */
testcase( i==45 ); /* OR */
testcase( i==46 ); /* UNIQUE */
testcase( i==47 ); /* QUERY */
testcase( i==48 ); /* WITHOUT */
testcase( i==49 ); /* WITH */
testcase( i==50 ); /* OUTER */
testcase( i==51 ); /* RELEASE */
testcase( i==52 ); /* ATTACH */
testcase( i==53 ); /* HAVING */
testcase( i==54 ); /* GROUP */
testcase( i==55 ); /* UPDATE */
testcase( i==56 ); /* BEGIN */
testcase( i==57 ); /* INNER */
testcase( i==58 ); /* RECURSIVE */
testcase( i==59 ); /* BETWEEN */
testcase( i==60 ); /* NOTNULL */
testcase( i==61 ); /* NOT */
testcase( i==62 ); /* NO */
testcase( i==63 ); /* NULL */
testcase( i==64 ); /* LIKE */
testcase( i==65 ); /* CASCADE */
testcase( i==66 ); /* ASC */
testcase( i==67 ); /* DELETE */
testcase( i==68 ); /* CASE */
testcase( i==69 ); /* COLLATE */
testcase( i==70 ); /* CREATE */
testcase( i==71 ); /* CURRENT_DATE */
testcase( i==72 ); /* DETACH */
testcase( i==73 ); /* IMMEDIATE */
testcase( i==74 ); /* JOIN */
testcase( i==75 ); /* INSERT */
testcase( i==76 ); /* MATCH */
testcase( i==77 ); /* PLAN */
testcase( i==78 ); /* ANALYZE */
testcase( i==79 ); /* PRAGMA */
testcase( i==80 ); /* ABORT */
testcase( i==81 ); /* VALUES */
testcase( i==82 ); /* VIRTUAL */
testcase( i==83 ); /* LIMIT */
testcase( i==84 ); /* WHEN */
testcase( i==85 ); /* WHERE */
testcase( i==86 ); /* RENAME */
testcase( i==87 ); /* AFTER */
testcase( i==88 ); /* REPLACE */
testcase( i==89 ); /* AND */
testcase( i==90 ); /* DEFAULT */
testcase( i==91 ); /* AUTOINCREMENT */
testcase( i==92 ); /* TO */
testcase( i==93 ); /* IN */
testcase( i==94 ); /* CAST */
testcase( i==95 ); /* COLUMN */
testcase( i==96 ); /* COMMIT */
testcase( i==97 ); /* CONFLICT */
testcase( i==98 ); /* CROSS */
testcase( i==99 ); /* CURRENT_TIMESTAMP */
testcase( i==100 ); /* CURRENT_TIME */
testcase( i==101 ); /* PRIMARY */
testcase( i==102 ); /* DEFERRED */
testcase( i==103 ); /* DISTINCT */
testcase( i==104 ); /* IS */
testcase( i==105 ); /* DROP */
testcase( i==106 ); /* FAIL */
testcase( i==107 ); /* FROM */
testcase( i==108 ); /* FULL */
testcase( i==109 ); /* GLOB */
testcase( i==110 ); /* BY */
testcase( i==111 ); /* IF */
testcase( i==112 ); /* ISNULL */
testcase( i==113 ); /* ORDER */
testcase( i==114 ); /* RESTRICT */
testcase( i==115 ); /* RIGHT */
testcase( i==116 ); /* ROLLBACK */
testcase( i==117 ); /* ROW */
testcase( i==118 ); /* UNION */
testcase( i==119 ); /* USING */
testcase( i==120 ); /* VACUUM */
testcase( i==121 ); /* VIEW */
testcase( i==122 ); /* INITIALLY */
testcase( i==123 ); /* ALL */
return aCode[i];
}
}
return TK_ID;
}
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
return keywordCode((char*)z, n);
}
#define SQLITE_N_KEYWORD 124
/************** End of keywordhash.h *****************************************/
/************** Continuing where we left off in tokenize.c *******************/
/*
** If X is a character that can be used in an identifier then
|
| ︙ | ︙ | |||
118154 118155 118156 118157 118158 118159 118160 |
return i;
}
case '?': {
*tokenType = TK_VARIABLE;
for(i=1; sqlite3Isdigit(z[i]); i++){}
return i;
}
| < < < < < < < < < < < > | > | 118815 118816 118817 118818 118819 118820 118821 118822 118823 118824 118825 118826 118827 118828 118829 118830 118831 118832 118833 118834 118835 118836 118837 |
return i;
}
case '?': {
*tokenType = TK_VARIABLE;
for(i=1; sqlite3Isdigit(z[i]); i++){}
return i;
}
#ifndef SQLITE_OMIT_TCL_VARIABLE
case '$':
#endif
case '@': /* For compatibility with MS SQL Server */
case '#':
case ':': {
int n = 0;
testcase( z[0]=='$' ); testcase( z[0]=='@' );
testcase( z[0]==':' ); testcase( z[0]=='#' );
*tokenType = TK_VARIABLE;
for(i=1; (c=z[i])!=0; i++){
if( IdChar(c) ){
n++;
#ifndef SQLITE_OMIT_TCL_VARIABLE
}else if( c=='(' && n>0 ){
do{
|
| ︙ | ︙ | |||
118354 118355 118356 118357 118358 118359 118360 118361 118362 118363 118364 118365 118366 118367 |
/* If the pParse->declareVtab flag is set, do not delete any table
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
** will take responsibility for freeing the Table structure.
*/
sqlite3DeleteTable(db, pParse->pNewTable);
}
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]);
sqlite3DbFree(db, pParse->azVar);
while( pParse->pAinc ){
AutoincInfo *p = pParse->pAinc;
pParse->pAinc = p->pNext;
sqlite3DbFree(db, p);
| > | 119006 119007 119008 119009 119010 119011 119012 119013 119014 119015 119016 119017 119018 119019 119020 |
/* If the pParse->declareVtab flag is set, do not delete any table
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
** will take responsibility for freeing the Table structure.
*/
sqlite3DeleteTable(db, pParse->pNewTable);
}
if( pParse->bFreeWith ) sqlite3WithDelete(db, pParse->pWith);
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]);
sqlite3DbFree(db, pParse->azVar);
while( pParse->pAinc ){
AutoincInfo *p = pParse->pAinc;
pParse->pAinc = p->pNext;
sqlite3DbFree(db, p);
|
| ︙ | ︙ | |||
118884 118885 118886 118887 118888 118889 118890 | /* If SQLite is already completely initialized, then this call ** to sqlite3_initialize() should be a no-op. But the initialization ** must be complete. So isInit must not be set until the very end ** of this routine. */ if( sqlite3GlobalConfig.isInit ) return SQLITE_OK; | < < < < < < < | 119537 119538 119539 119540 119541 119542 119543 119544 119545 119546 119547 119548 119549 119550 | /* If SQLite is already completely initialized, then this call ** to sqlite3_initialize() should be a no-op. But the initialization ** must be complete. So isInit must not be set until the very end ** of this routine. */ if( sqlite3GlobalConfig.isInit ) return SQLITE_OK; /* Make sure the mutex subsystem is initialized. If unable to ** initialize the mutex subsystem, return early with the error. ** If the system is so sick that we are unable to allocate a mutex, ** there is not much SQLite is going to be able to do. ** ** The mutex subsystem must take care of serializing its own ** initialization. |
| ︙ | ︙ | |||
122059 122060 122061 122062 122063 122064 122065 |
** Set or clear a flag that indicates that the database file is always well-
** formed and never corrupt. This flag is clear by default, indicating that
** database files might have arbitrary corruption. Setting the flag during
** testing causes certain assert() statements in the code to be activated
** that demonstrat invariants on well-formed database files.
*/
case SQLITE_TESTCTRL_NEVER_CORRUPT: {
| | | 122705 122706 122707 122708 122709 122710 122711 122712 122713 122714 122715 122716 122717 122718 122719 |
** Set or clear a flag that indicates that the database file is always well-
** formed and never corrupt. This flag is clear by default, indicating that
** database files might have arbitrary corruption. Setting the flag during
** testing causes certain assert() statements in the code to be activated
** that demonstrat invariants on well-formed database files.
*/
case SQLITE_TESTCTRL_NEVER_CORRUPT: {
sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);
break;
}
}
va_end(ap);
#endif /* SQLITE_OMIT_BUILTIN_TEST */
return rc;
|
| ︙ | ︙ | |||
124839 124840 124841 124842 124843 124844 124845 | } /* ** Set the pIdxInfo->estimatedRows variable to nRow. Unless this ** extension is currently being used by a version of SQLite too old to ** support estimatedRows. In that case this function is a no-op. */ | | | 125485 125486 125487 125488 125489 125490 125491 125492 125493 125494 125495 125496 125497 125498 125499 |
}
/*
** Set the pIdxInfo->estimatedRows variable to nRow. Unless this
** extension is currently being used by a version of SQLite too old to
** support estimatedRows. In that case this function is a no-op.
*/
static void fts3SetEstimatedRows(sqlite3_index_info *pIdxInfo, i64 nRow){
#if SQLITE_VERSION_NUMBER>=3008002
if( sqlite3_libversion_number()>=3008002 ){
pIdxInfo->estimatedRows = nRow;
}
#endif
}
|
| ︙ | ︙ | |||
124883 124884 124885 124886 124887 124888 124889 |
/* There exists an unusable MATCH constraint. This means that if
** the planner does elect to use the results of this call as part
** of the overall query plan the user will see an "unable to use
** function MATCH in the requested context" error. To discourage
** this, return a very high cost here. */
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
pInfo->estimatedCost = 1e50;
| | | 125529 125530 125531 125532 125533 125534 125535 125536 125537 125538 125539 125540 125541 125542 125543 |
/* There exists an unusable MATCH constraint. This means that if
** the planner does elect to use the results of this call as part
** of the overall query plan the user will see an "unable to use
** function MATCH in the requested context" error. To discourage
** this, return a very high cost here. */
pInfo->idxNum = FTS3_FULLSCAN_SEARCH;
pInfo->estimatedCost = 1e50;
fts3SetEstimatedRows(pInfo, ((sqlite3_int64)1) << 50);
return SQLITE_OK;
}
continue;
}
bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);
|
| ︙ | ︙ | |||
131057 131058 131059 131060 131061 131062 131063 |
}
/*
** Hash and comparison functions when the mode is FTS3_HASH_STRING
*/
static int fts3StrHash(const void *pKey, int nKey){
const char *z = (const char *)pKey;
| | | | 131703 131704 131705 131706 131707 131708 131709 131710 131711 131712 131713 131714 131715 131716 131717 131718 131719 131720 131721 131722 131723 |
}
/*
** Hash and comparison functions when the mode is FTS3_HASH_STRING
*/
static int fts3StrHash(const void *pKey, int nKey){
const char *z = (const char *)pKey;
unsigned h = 0;
if( nKey<=0 ) nKey = (int) strlen(z);
while( nKey > 0 ){
h = (h<<3) ^ h ^ *z++;
nKey--;
}
return (int)(h & 0x7fffffff);
}
static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
if( n1!=n2 ) return 1;
return strncmp((const char*)pKey1,(const char*)pKey2,n1);
}
/*
|
| ︙ | ︙ |
Changes to src/sqlite3.h.
| ︙ | ︙ | |||
103 104 105 106 107 108 109 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.8.3.1" #define SQLITE_VERSION_NUMBER 3008003 #define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 | #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** | > | 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 | #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ #define SQLITE_RECURSIVE 33 /* NULL NULL */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** |
| ︙ | ︙ |
Changes to src/tar.c.
| ︙ | ︙ | |||
334 335 336 337 338 339 340 |
const char *zName, /* Name of directory including final "/" */
int nName, /* Characters in zName */
unsigned int mTime /* Modification time */
){
int i;
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
if( i<=0 ) return;
| | | < | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
const char *zName, /* Name of directory including final "/" */
int nName, /* Characters in zName */
unsigned int mTime /* Modification time */
){
int i;
for(i=nName-1; i>0 && zName[i]!='/'; i--){}
if( i<=0 ) return;
if( i < tball.nPrevDirAlloc && tball.zPrevDir[i]==0 &&
memcmp(tball.zPrevDir, zName, i)==0 ) return;
db_multi_exec("INSERT OR IGNORE INTO dir VALUES('%#q')", i, zName);
if( sqlite3_changes(g.db)==0 ) return;
tar_add_directory_of(zName, i-1, mTime);
tar_add_header(zName, i, 0755, mTime, 0, '5');
if( i >= tball.nPrevDirAlloc ){
int nsize = tball.nPrevDirAlloc * 2;
if(i+1 > nsize)
|
| ︙ | ︙ |
Changes to src/th.c.
1 2 | /* | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/*
** The implementation of the TH core. This file contains the parser, and
** the implementation of the interface in th.h.
*/
#include "config.h"
#include "th.h"
#include <string.h>
#include <assert.h>
typedef struct Th_Command Th_Command;
typedef struct Th_Frame Th_Frame;
typedef struct Th_Variable Th_Variable;
/*
** Interpreter structure.
*/
struct Th_Interp {
Th_Vtab *pVtab; /* Copy of the argument passed to Th_CreateInterp() */
char *zResult; /* Current interpreter result (Th_Malloc()ed) */
int nResult; /* number of bytes in zResult */
Th_Hash *paCmd; /* Table of registered commands */
Th_Frame *pFrame; /* Current execution frame */
int isListMode; /* True if thSplitList() should operate in "list" mode */
};
/*
|
| ︙ | ︙ | |||
40 41 42 43 44 45 46 | ** Each stack frame (variable scope) is represented by an instance ** of this structure. Variable values set using the Th_SetVar command ** are stored in the Th_Frame.paVar hash table member of the associated ** stack frame object. ** ** When an interpreter is created, a single Th_Frame structure is also ** allocated - the global variable scope. Th_Interp.pFrame (the current | | | | | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
** Each stack frame (variable scope) is represented by an instance
** of this structure. Variable values set using the Th_SetVar command
** are stored in the Th_Frame.paVar hash table member of the associated
** stack frame object.
**
** When an interpreter is created, a single Th_Frame structure is also
** allocated - the global variable scope. Th_Interp.pFrame (the current
** interpreter frame) is initialised to point to this Th_Frame. It is
** not deleted for the lifetime of the interpreter (because the global
** frame never goes out of scope).
**
** New stack frames are created by the Th_InFrame() function. Before
** invoking its callback function, Th_InFrame() allocates a new Th_Frame
** structure with pCaller set to the current frame (Th_Interp.pFrame),
** and sets the current frame to the new frame object. After the callback
** has been invoked, the allocated Th_Frame is deleted and the value
** of the current frame pointer restored.
**
** By default, the Th_SetVar(), Th_UnsetVar() and Th_GetVar() functions
** access variable values in the current frame. If they need to access
** the global frame, they do so by traversing the pCaller pointer list.
** Likewise, the Th_LinkVar() function uses the pCaller pointers to
** link to variables located in the global or other stack frames.
*/
struct Th_Frame {
Th_Hash *paVar; /* Variables defined in this scope */
Th_Frame *pCaller; /* Calling frame */
};
|
| ︙ | ︙ | |||
82 83 84 85 86 87 88 |
** a hash table mapping between array key name (a th1 string) and
** a pointer to the Th_Variable structure holding the scalar
** value.
*/
struct Th_Variable {
int nRef; /* Number of references to this structure */
int nData; /* Number of bytes at Th_Variable.zData */
| | | | | | | | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
** a hash table mapping between array key name (a th1 string) and
** a pointer to the Th_Variable structure holding the scalar
** value.
*/
struct Th_Variable {
int nRef; /* Number of references to this structure */
int nData; /* Number of bytes at Th_Variable.zData */
char *zData; /* Data for scalar variables */
Th_Hash *pHash; /* Data for array variables */
};
/*
** Hash table API:
*/
#define TH_HASHSIZE 257
struct Th_Hash {
Th_HashEntry *a[TH_HASHSIZE];
};
static int thEvalLocal(Th_Interp *, const char *, int);
static int thSplitList(Th_Interp*, const char*, int, char***, int **, int*);
static int thHexdigit(char c);
static int thEndOfLine(const char *, int);
static int thPushFrame(Th_Interp*, Th_Frame*);
static void thPopFrame(Th_Interp*);
static int thFreeVariable(Th_HashEntry*, void*);
static int thFreeCommand(Th_HashEntry*, void*);
/*
** The following are used by both the expression and language parsers.
** Given that the start of the input string (z, n) is a language
** construct of the relevant type (a command enclosed in [], an escape
** sequence etc.), these functions determine the number of bytes
** of the input consumed by the construct. For example:
**
** int nByte;
** thNextCommand(interp, "[expr $a+1] $nIter", 18, &nByte);
**
** results in variable nByte being set to 11. Or,
**
** thNextVarname(interp, "$a+1", 4, &nByte);
**
** results in nByte being set to 2.
*/
static int thNextCommand(Th_Interp*, const char *z, int n, int *pN);
static int thNextEscape (Th_Interp*, const char *z, int n, int *pN);
static int thNextVarname(Th_Interp*, const char *z, int n, int *pN);
static int thNextNumber (Th_Interp*, const char *z, int n, int *pN);
static int thNextSpace (Th_Interp*, const char *z, int n, int *pN);
/*
** Given that the input string (z, n) contains a language construct of
** the relevant type (a command enclosed in [], an escape sequence
** like "\xFF" or a variable reference like "${varname}", perform
** substitution on the string and store the resulting string in
** the interpreter result.
*/
static int thSubstCommand(Th_Interp*, const char *z, int n);
static int thSubstEscape (Th_Interp*, const char *z, int n);
static int thSubstVarname(Th_Interp*, const char *z, int n);
/*
** Given that there is a th1 word located at the start of the input
** string (z, n), determine the length in bytes of that word. If the
** isCmd argument is non-zero, then an unescaped ";" byte not
** located inside of a block or quoted string is considered to mark
** the end of the word.
*/
static int thNextWord(Th_Interp*, const char *z, int n, int *pN, int isCmd);
/*
** Perform substitution on the word contained in the input string (z, n).
** Store the resulting string in the interpreter result.
|
| ︙ | ︙ | |||
174 175 176 177 178 179 180 | /* ** Append nAdd bytes of content copied from zAdd to the end of buffer ** pBuffer. If there is not enough space currently allocated, resize ** the allocation to make space. */ static int thBufferWrite( | | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
/*
** Append nAdd bytes of content copied from zAdd to the end of buffer
** pBuffer. If there is not enough space currently allocated, resize
** the allocation to make space.
*/
static int thBufferWrite(
Th_Interp *interp,
Buffer *pBuffer,
const char *zAdd,
int nAdd
){
int nReq;
if( nAdd<0 ){
nAdd = th_strlen(zAdd);
}
|
| ︙ | ︙ | |||
256 257 258 259 260 261 262 263 | /* ** Argument pEntry points to an entry in a stack frame hash table ** (Th_Frame.paVar). Decrement the reference count of the Th_Variable ** structure that the entry points to. Free the Th_Variable if its ** reference count reaches 0. ** ** Argument pContext is a pointer to the interpreter structure. */ | > > | > > > > > | > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
/*
** Argument pEntry points to an entry in a stack frame hash table
** (Th_Frame.paVar). Decrement the reference count of the Th_Variable
** structure that the entry points to. Free the Th_Variable if its
** reference count reaches 0.
**
** Argument pContext is a pointer to the interpreter structure.
**
** Returns non-zero if the Th_Variable was actually freed.
*/
static int thFreeVariable(Th_HashEntry *pEntry, void *pContext){
Th_Variable *pValue = (Th_Variable *)pEntry->pData;
pValue->nRef--;
assert( pValue->nRef>=0 );
if( pValue->nRef==0 ){
Th_Interp *interp = (Th_Interp *)pContext;
Th_Free(interp, pValue->zData);
if( pValue->pHash ){
Th_HashIterate(interp, pValue->pHash, thFreeVariable, pContext);
Th_HashDelete(interp, pValue->pHash);
}
Th_Free(interp, pValue);
pEntry->pData = 0;
return 1;
}
return 0;
}
/*
** Argument pEntry points to an entry in the command hash table
** (Th_Interp.paCmd). Delete the Th_Command structure that the
** entry points to.
**
** Argument pContext is a pointer to the interpreter structure.
**
** Always returns non-zero.
*/
static int thFreeCommand(Th_HashEntry *pEntry, void *pContext){
Th_Command *pCommand = (Th_Command *)pEntry->pData;
if( pCommand->xDel ){
pCommand->xDel((Th_Interp *)pContext, pCommand->pContext);
}
Th_Free((Th_Interp *)pContext, pEntry->pData);
pEntry->pData = 0;
return 1;
}
/*
** Push a new frame onto the stack.
*/
static int thPushFrame(Th_Interp *interp, Th_Frame *pFrame){
pFrame->paVar = Th_HashNew(interp);
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 | Th_Frame *pFrame = interp->pFrame; Th_HashIterate(interp, pFrame->paVar, thFreeVariable, (void *)interp); Th_HashDelete(interp, pFrame->paVar); interp->pFrame = pFrame->pCaller; } /* | | | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
Th_Frame *pFrame = interp->pFrame;
Th_HashIterate(interp, pFrame->paVar, thFreeVariable, (void *)interp);
Th_HashDelete(interp, pFrame->paVar);
interp->pFrame = pFrame->pCaller;
}
/*
** The first part of the string (zInput,nInput) contains an escape
** sequence. Set *pnEscape to the number of bytes in the escape sequence.
** If there is a parse error, return TH_ERROR and set the interpreter
** result to an error message. Otherwise return TH_OK.
*/
static int thNextEscape(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnEscape
){
int i = 2;
assert(nInput>0);
assert(zInput[0]=='\\');
|
| ︙ | ︙ | |||
342 343 344 345 346 347 348 | } *pnEscape = i; return TH_OK; } /* ** The first part of the string (zInput,nInput) contains a variable | | | | | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
}
*pnEscape = i;
return TH_OK;
}
/*
** The first part of the string (zInput,nInput) contains a variable
** reference. Set *pnVarname to the number of bytes in the variable
** reference. If there is a parse error, return TH_ERROR and set the
** interpreter result to an error message. Otherwise return TH_OK.
*/
int thNextVarname(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnVarname
){
int i;
assert(nInput>0);
assert(zInput[0]=='$');
|
| ︙ | ︙ | |||
399 400 401 402 403 404 405 | *pnVarname = i; return TH_OK; } /* ** The first part of the string (zInput,nInput) contains a command | | | | | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
*pnVarname = i;
return TH_OK;
}
/*
** The first part of the string (zInput,nInput) contains a command
** enclosed in a "[]" block. Set *pnCommand to the number of bytes in
** the variable reference. If there is a parse error, return TH_ERROR
** and set the interpreter result to an error message. Otherwise return
** TH_OK.
*/
int thNextCommand(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnCommand
){
int nBrace = 0;
int nSquare = 0;
int i;
assert(nInput>0);
|
| ︙ | ︙ | |||
436 437 438 439 440 441 442 | *pnCommand = i; return TH_OK; } /* | | | | | | | | | | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
*pnCommand = i;
return TH_OK;
}
/*
** Set *pnSpace to the number of whitespace bytes at the start of
** input string (zInput, nInput). Always return TH_OK.
*/
int thNextSpace(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnSpace
){
int i;
for(i=0; i<nInput && th_isspace(zInput[i]); i++);
*pnSpace = i;
return TH_OK;
}
/*
** The first byte of the string (zInput,nInput) is not white-space.
** Set *pnWord to the number of bytes in the th1 word that starts
** with this byte. If a complete word cannot be parsed or some other
** error occurs, return TH_ERROR and set the interpreter result to
** an error message. Otherwise return TH_OK.
**
** If the isCmd argument is non-zero, then an unescaped ";" byte not
** located inside of a block or quoted string is considered to mark
** the end of the word.
*/
static int thNextWord(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnWord,
int isCmd
){
int iEnd = 0;
assert( !th_isspace(zInput[0]) );
|
| ︙ | ︙ | |||
529 530 531 532 533 534 535 | assert(nWord>=2); assert(zWord[0]=='[' && zWord[nWord-1]==']'); return thEvalLocal(interp, &zWord[1], nWord-2); } /* ** The input string (zWord, nWord) contains a th1 variable reference | | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
assert(nWord>=2);
assert(zWord[0]=='[' && zWord[nWord-1]==']');
return thEvalLocal(interp, &zWord[1], nWord-2);
}
/*
** The input string (zWord, nWord) contains a th1 variable reference
** (a '$' byte followed by a variable name). Perform substitution on
** the input string and store the resulting string in the interpreter
** result.
*/
static int thSubstVarname(
Th_Interp *interp,
const char *zWord,
int nWord
){
|
| ︙ | ︙ | |||
570 571 572 573 574 575 576 |
}
}
return Th_GetVar(interp, &zWord[1], nWord-1);
}
/*
** The input string (zWord, nWord) contains a th1 escape sequence.
| | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
}
}
return Th_GetVar(interp, &zWord[1], nWord-1);
}
/*
** The input string (zWord, nWord) contains a th1 escape sequence.
** Perform substitution on the input string and store the resulting
** string in the interpreter result.
*/
static int thSubstEscape(
Th_Interp *interp,
const char *zWord,
int nWord
){
|
| ︙ | ︙ | |||
606 607 608 609 610 611 612 | Th_SetResult(interp, &c, 1); return TH_OK; } /* ** The input string (zWord, nWord) contains a th1 word. Perform | | | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
Th_SetResult(interp, &c, 1);
return TH_OK;
}
/*
** The input string (zWord, nWord) contains a th1 word. Perform
** substitution on the input string and store the resulting
** string in the interpreter result.
*/
static int thSubstWord(
Th_Interp *interp,
const char *zWord,
int nWord
){
|
| ︙ | ︙ | |||
638 639 640 641 642 643 644 |
int nGet;
int (*xGet)(Th_Interp *, const char*, int, int *) = 0;
int (*xSubst)(Th_Interp *, const char*, int) = 0;
switch( zWord[i] ){
case '\\':
| | | | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
int nGet;
int (*xGet)(Th_Interp *, const char*, int, int *) = 0;
int (*xSubst)(Th_Interp *, const char*, int) = 0;
switch( zWord[i] ){
case '\\':
xGet = thNextEscape; xSubst = thSubstEscape;
break;
case '[':
if( !interp->isListMode ){
xGet = thNextCommand; xSubst = thSubstCommand;
break;
}
case '$':
if( !interp->isListMode ){
xGet = thNextVarname; xSubst = thSubstVarname;
break;
}
default: {
thBufferWrite(interp, &output, &zWord[i], 1);
continue; /* Go to the next iteration of the for(...) loop */
}
}
|
| ︙ | ︙ | |||
683 684 685 686 687 688 689 | /* ** Return true if one of the following is true of the buffer pointed ** to by zInput, length nInput: ** ** + It is empty, or ** + It contains nothing but white-space, or | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
/*
** Return true if one of the following is true of the buffer pointed
** to by zInput, length nInput:
**
** + It is empty, or
** + It contains nothing but white-space, or
** + It contains no non-white-space characters before the first
** newline character.
**
** Otherwise return false.
*/
static int thEndOfLine(const char *zInput, int nInput){
int i;
for(i=0; i<nInput && zInput[i]!='\n' && th_isspace(zInput[i]); i++);
|
| ︙ | ︙ | |||
723 724 725 726 727 728 729 | ** Th_SplitList(interp, zList, nList, &argv, &argl, &argc); ** ** // Free all memory allocated by Th_SplitList(). The arrays pointed ** // to by argv and argl are invalidated by this call. ** // ** Th_Free(interp, argv); ** | | | | | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
** Th_SplitList(interp, zList, nList, &argv, &argl, &argc);
**
** // Free all memory allocated by Th_SplitList(). The arrays pointed
** // to by argv and argl are invalidated by this call.
** //
** Th_Free(interp, argv);
**
*/
static int thSplitList(
Th_Interp *interp, /* Interpreter context */
const char *zList, /* Pointer to buffer containing input list */
int nList, /* Size of buffer pointed to by zList */
char ***pazElem, /* OUT: Array of list elements */
int **panElem, /* OUT: Lengths of each list element */
int *pnCount /* OUT: Number of list elements */
){
int rc = TH_OK;
Buffer strbuf;
Buffer lenbuf;
|
| ︙ | ︙ | |||
772 773 774 775 776 777 778 |
}
}
assert((lenbuf.nBuf/sizeof(int))==nCount);
assert((pazElem && panElem) || (!pazElem && !panElem));
if( pazElem && rc==TH_OK ){
int i;
| | | | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
}
}
assert((lenbuf.nBuf/sizeof(int))==nCount);
assert((pazElem && panElem) || (!pazElem && !panElem));
if( pazElem && rc==TH_OK ){
int i;
char *zElem;
int *anElem;
char **azElem = Th_Malloc(interp,
sizeof(char*) * nCount + /* azElem */
sizeof(int) * nCount + /* anElem */
strbuf.nBuf /* space for list element strings */
);
anElem = (int *)&azElem[nCount];
zElem = (char *)&anElem[nCount];
memcpy(anElem, lenbuf.zBuf, lenbuf.nBuf);
memcpy(zElem, strbuf.zBuf, strbuf.nBuf);
for(i=0; i<nCount;i++){
azElem[i] = zElem;
zElem += (anElem[i] + 1);
}
*pazElem = azElem;
*panElem = anElem;
}
if( pnCount ){
*pnCount = nCount;
}
finish:
thBufferFree(interp, &strbuf);
thBufferFree(interp, &lenbuf);
return rc;
}
/*
|
| ︙ | ︙ | |||
874 875 876 877 878 879 880 |
/* Call the command procedure. */
if( rc==TH_OK ){
Th_Command *p = (Th_Command *)(pEntry->pData);
const char **azArg = (const char **)argv;
rc = p->xProc(interp, p->pContext, argc, azArg, argl);
}
| | | | 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
/* Call the command procedure. */
if( rc==TH_OK ){
Th_Command *p = (Th_Command *)(pEntry->pData);
const char **azArg = (const char **)argv;
rc = p->xProc(interp, p->pContext, argc, azArg, argl);
}
/* If an error occurred, add this command to the stack trace report. */
if( rc==TH_ERROR ){
char *zRes;
int nRes;
char *zStack = 0;
int nStack = 0;
zRes = Th_TakeResult(interp, &nRes);
if( TH_OK==Th_GetVar(interp, (char *)"::th_stack_trace", -1) ){
zStack = Th_TakeResult(interp, &nStack);
}
Th_ListAppend(interp, &zStack, &nStack, zFirst, zInput-zFirst);
Th_SetVar(interp, (char *)"::th_stack_trace", -1, zStack, nStack);
Th_SetResult(interp, zRes, nRes);
|
| ︙ | ︙ | |||
910 911 912 913 914 915 916 | ** Th_Frame structure. If unsuccessful (no such frame), return 0 and ** leave an error message in the interpreter result. ** ** Argument iFrame is interpreted as follows: ** ** * If iFrame is 0, this means the current frame. ** | | | | | 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 |
** Th_Frame structure. If unsuccessful (no such frame), return 0 and
** leave an error message in the interpreter result.
**
** Argument iFrame is interpreted as follows:
**
** * If iFrame is 0, this means the current frame.
**
** * If iFrame is negative, then the nth frame up the stack, where
** n is the absolute value of iFrame. A value of -1 means the
** calling procedure.
**
** * If iFrame is +ve, then the nth frame from the bottom of the
** stack. An iFrame value of 1 means the toplevel (global) frame.
*/
static Th_Frame *getFrame(Th_Interp *interp, int iFrame){
Th_Frame *p = interp->pFrame;
int i;
if( iFrame>0 ){
for(i=0; p; i++){
|
| ︙ | ︙ | |||
946 947 948 949 950 951 952 | return p; } /* ** Evaluate th1 script (zProgram, nProgram) in the frame identified by ** argument iFrame. Leave either an error message or a result in the | | | | | 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
return p;
}
/*
** Evaluate th1 script (zProgram, nProgram) in the frame identified by
** argument iFrame. Leave either an error message or a result in the
** interpreter result and return a th1 error code (TH_OK, TH_ERROR,
** TH_RETURN, TH_CONTINUE or TH_BREAK).
*/
int Th_Eval(Th_Interp *interp, int iFrame, const char *zProgram, int nProgram){
int rc = TH_OK;
Th_Frame *pSavedFrame = interp->pFrame;
/* Set Th_Interp.pFrame to the frame that this script is to be
** evaluated in. The current frame is saved in pSavedFrame and will
** be restored before this function returns.
*/
interp->pFrame = getFrame(interp, iFrame);
if( !interp->pFrame ){
rc = TH_ERROR;
}else{
int nInput = nProgram;
if( nInput<0 ){
nInput = th_strlen(zProgram);
}
rc = thEvalLocal(interp, zProgram, nInput);
}
interp->pFrame = pSavedFrame;
|
| ︙ | ︙ | |||
993 994 995 996 997 998 999 | ** array variable. If the variable is a scalar, *pzInner is set to 0. ** If it is an array variable, (*pzInner, *pnInner) is set to the ** array key name. */ static int thAnalyseVarname( const char *zVarname, int nVarname, | | | | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
** array variable. If the variable is a scalar, *pzInner is set to 0.
** If it is an array variable, (*pzInner, *pnInner) is set to the
** array key name.
*/
static int thAnalyseVarname(
const char *zVarname,
int nVarname,
const char **pzOuter, /* OUT: Pointer to scalar/array name */
int *pnOuter, /* OUT: Number of bytes at *pzOuter */
const char **pzInner, /* OUT: Pointer to array key (or null) */
int *pnInner, /* OUT: Number of bytes at *pzInner */
int *pisGlobal /* OUT: Set to true if this is a global ref */
){
const char *zOuter = zVarname;
int nOuter;
const char *zInner = 0;
int nInner = 0;
|
| ︙ | ︙ | |||
1040 1041 1042 1043 1044 1045 1046 1047 1048 | *pnOuter = nOuter; *pzInner = zInner; *pnInner = nInner; *pisGlobal = isGlobal; return TH_OK; } /* ** Input string (zVar, nVar) contains a variable name. This function locates | > > > > > > > > > > > > > > > | > | | | | | > > > > > > | > > > | 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
*pnOuter = nOuter;
*pzInner = zInner;
*pnInner = nInner;
*pisGlobal = isGlobal;
return TH_OK;
}
/*
** The Find structure is used to return extra information to callers of the
** thFindValue function. The fields within it are populated by thFindValue
** as soon as the necessary information is available. Callers should check
** each field of interest upon return.
*/
struct Find {
Th_HashEntry *pValueEntry; /* Pointer to the scalar or array hash entry */
Th_HashEntry *pElemEntry; /* Pointer to array element hash entry, if any */
const char *zElem; /* Name of array element, if applicable */
int nElem; /* Length of array element name, if applicable */
};
typedef struct Find Find;
/*
** Input string (zVar, nVar) contains a variable name. This function locates
** the Th_Variable structure associated with the named variable. The
** variable name may be a global or local scalar or array variable
**
** If the create argument is non-zero and the named variable does not exist
** it is created. Otherwise, an error is left in the interpreter result
** and NULL returned.
**
** If the arrayok argument is false and the named variable is an array,
** an error is left in the interpreter result and NULL returned. If
** arrayok is true an array name is Ok.
*/
static Th_Variable *thFindValue(
Th_Interp *interp,
const char *zVar, /* Pointer to variable name */
int nVar, /* Number of bytes at nVar */
int create, /* If true, create the variable if not found */
int arrayok, /* If true, an array is Ok. Otherwise array==error */
int noerror, /* If false, set interpreter result to error */
Find *pFind /* If non-zero, place output here */
){
const char *zOuter;
int nOuter;
const char *zInner;
int nInner;
int isGlobal;
Th_HashEntry *pEntry;
Th_Frame *pFrame = interp->pFrame;
Th_Variable *pValue;
thAnalyseVarname(zVar, nVar, &zOuter, &nOuter, &zInner, &nInner, &isGlobal);
if( pFind ){
memset(pFind, 0, sizeof(Find));
pFind->zElem = zInner;
pFind->nElem = nInner;
}
if( isGlobal ){
while( pFrame->pCaller ) pFrame = pFrame->pCaller;
}
pEntry = Th_HashFind(interp, pFrame->paVar, zOuter, nOuter, create);
assert(pEntry || create<=0);
if( pFind ){
pFind->pValueEntry = pEntry;
}
if( !pEntry ){
goto no_such_var;
}
pValue = (Th_Variable *)pEntry->pData;
if( !pValue ){
assert(create);
|
| ︙ | ︙ | |||
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
if( !pValue->pHash ){
if( !create ){
goto no_such_var;
}
pValue->pHash = Th_HashNew(interp);
}
pEntry = Th_HashFind(interp, pValue->pHash, zInner, nInner, create);
if( !pEntry ){
goto no_such_var;
}
pValue = (Th_Variable *)pEntry->pData;
if( !pValue ){
assert(create);
pValue = Th_Malloc(interp, sizeof(Th_Variable));
| > > > > | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
if( !pValue->pHash ){
if( !create ){
goto no_such_var;
}
pValue->pHash = Th_HashNew(interp);
}
pEntry = Th_HashFind(interp, pValue->pHash, zInner, nInner, create);
assert(pEntry || create<=0);
if( pFind ){
pFind->pElemEntry = pEntry;
}
if( !pEntry ){
goto no_such_var;
}
pValue = (Th_Variable *)pEntry->pData;
if( !pValue ){
assert(create);
pValue = Th_Malloc(interp, sizeof(Th_Variable));
|
| ︙ | ︙ | |||
1133 1134 1135 1136 1137 1138 1139 |
if( !noerror ){
Th_ErrorMessage(interp, "no such variable:", zVar, nVar);
}
return 0;
}
/*
| | | | | | | | | | 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
if( !noerror ){
Th_ErrorMessage(interp, "no such variable:", zVar, nVar);
}
return 0;
}
/*
** String (zVar, nVar) must contain the name of a scalar variable or
** array member. Look up the variable, store its current value in
** the interpreter result and return TH_OK.
**
** If the named variable does not exist, return TH_ERROR and leave
** an error message in the interpreter result.
*/
int Th_GetVar(Th_Interp *interp, const char *zVar, int nVar){
Th_Variable *pValue;
pValue = thFindValue(interp, zVar, nVar, 0, 0, 0, 0);
if( !pValue ){
return TH_ERROR;
}
if( !pValue->zData ){
Th_ErrorMessage(interp, "no such variable:", zVar, nVar);
return TH_ERROR;
}
return Th_SetResult(interp, pValue->zData, pValue->nData);
}
/*
** Return true if variable (zVar, nVar) exists.
*/
int Th_ExistsVar(Th_Interp *interp, const char *zVar, int nVar){
Th_Variable *pValue = thFindValue(interp, zVar, nVar, 0, 1, 1, 0);
return pValue && (pValue->zData || pValue->pHash);
}
/*
** String (zVar, nVar) must contain the name of a scalar variable or
** array member. If the variable does not exist it is created. The
** variable is set to the value supplied in string (zValue, nValue).
**
** If (zVar, nVar) refers to an existing array, TH_ERROR is returned
** and an error message left in the interpreter result.
*/
int Th_SetVar(
Th_Interp *interp,
const char *zVar,
int nVar,
const char *zValue,
int nValue
){
Th_Variable *pValue;
pValue = thFindValue(interp, zVar, nVar, 1, 0, 0, 0);
if( !pValue ){
return TH_ERROR;
}
if( nValue<0 ){
nValue = th_strlen(zValue);
}
|
| ︙ | ︙ | |||
1208 1209 1210 1211 1212 1213 1214 | /* ** Create a variable link so that accessing variable (zLocal, nLocal) is ** the same as accessing variable (zLink, nLink) in stack frame iFrame. */ int Th_LinkVar( Th_Interp *interp, /* Interpreter */ | | | | > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | | | | | > > > > > > > > | | 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 |
/*
** Create a variable link so that accessing variable (zLocal, nLocal) is
** the same as accessing variable (zLink, nLink) in stack frame iFrame.
*/
int Th_LinkVar(
Th_Interp *interp, /* Interpreter */
const char *zLocal, int nLocal, /* Local varname */
int iFrame, /* Stack frame of linked var */
const char *zLink, int nLink /* Linked varname */
){
Th_Frame *pSavedFrame = interp->pFrame;
Th_Frame *pFrame;
Th_HashEntry *pEntry;
Th_Variable *pValue;
pFrame = getFrame(interp, iFrame);
if( !pFrame ){
return TH_ERROR;
}
pSavedFrame = interp->pFrame;
interp->pFrame = pFrame;
pValue = thFindValue(interp, zLink, nLink, 1, 1, 0, 0);
interp->pFrame = pSavedFrame;
pEntry = Th_HashFind(interp, interp->pFrame->paVar, zLocal, nLocal, 1);
if( pEntry->pData ){
Th_ErrorMessage(interp, "variable exists:", zLocal, nLocal);
return TH_ERROR;
}
pEntry->pData = (void *)pValue;
pValue->nRef++;
return TH_OK;
}
/*
** Input string (zVar, nVar) must contain the name of a scalar variable,
** an array, or an array member. If the identified variable exists, it
** is deleted and TH_OK returned. Otherwise, an error message is left
** in the interpreter result and TH_ERROR is returned.
*/
int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){
Find find;
Th_Variable *pValue;
Th_HashEntry *pEntry;
int rc = TH_ERROR;
pValue = thFindValue(interp, zVar, nVar, 0, 1, 0, &find);
if( !pValue ){
return rc;
}
if( pValue->zData || pValue->pHash ){
rc = TH_OK;
}else {
Th_ErrorMessage(interp, "no such variable:", zVar, nVar);
}
/*
** The variable may be shared by more than one frame; therefore, make sure
** it is actually freed prior to freeing the parent structure. The values
** for the variable must be freed now so the variable appears undefined in
** all frames. The hash entry in the current frame must also be deleted
** now; otherwise, if the current stack frame is later popped, it will try
** to delete a variable which has already been freed.
*/
if( find.zElem ){
pEntry = find.pElemEntry;
}else{
pEntry = find.pValueEntry;
}
assert( pEntry );
assert( pValue );
if( thFreeVariable(pEntry, (void *)interp) ){
if( find.zElem ){
Th_Variable *pValue2 = find.pValueEntry->pData;
Th_HashFind(interp, pValue2->pHash, find.zElem, find.nElem, -1);
}else if( pEntry->pData ){
Th_Free(interp, pEntry->pData);
pEntry->pData = 0;
}
}else{
if( pValue->zData ){
Th_Free(interp, pValue->zData);
pValue->zData = 0;
}
if( pValue->pHash ){
Th_HashIterate(interp, pValue->pHash, thFreeVariable, (void *)interp);
Th_HashDelete(interp, pValue->pHash);
pValue->pHash = 0;
}
if( find.zElem ){
Th_Variable *pValue2 = find.pValueEntry->pData;
Th_HashFind(interp, pValue2->pHash, find.zElem, find.nElem, -1);
}
}
if( !find.zElem ){
Th_HashFind(interp, interp->pFrame->paVar, zVar, nVar, -1);
}
return rc;
}
/*
** Return an allocated buffer containing a copy of string (z, n). The
** caller is responsible for eventually calling Th_Free() to free
** the returned buffer.
*/
|
| ︙ | ︙ | |||
1297 1298 1299 1300 1301 1302 1303 |
*/
int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const char *z, int n){
if( interp ){
char *zRes = 0;
int nRes = 0;
Th_SetVar(interp, (char *)"::th_stack_trace", -1, 0, 0);
| | | 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
*/
int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const char *z, int n){
if( interp ){
char *zRes = 0;
int nRes = 0;
Th_SetVar(interp, (char *)"::th_stack_trace", -1, 0, 0);
Th_StringAppend(interp, &zRes, &nRes, zPre, -1);
if( zRes[nRes-1]=='"' ){
Th_StringAppend(interp, &zRes, &nRes, z, n);
Th_StringAppend(interp, &zRes, &nRes, (const char *)"\"", 1);
}else{
Th_StringAppend(interp, &zRes, &nRes, (const char *)" ", 1);
Th_StringAppend(interp, &zRes, &nRes, z, n);
|
| ︙ | ︙ | |||
1379 1380 1381 1382 1383 1384 1385 |
return zResult;
}else{
return (char *)Th_Malloc(pInterp, 1);
}
}
| | | | | | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
return zResult;
}else{
return (char *)Th_Malloc(pInterp, 1);
}
}
/*
** Wrappers around the supplied malloc() and free()
*/
void *Th_Malloc(Th_Interp *pInterp, int nByte){
void *p = pInterp->pVtab->xMalloc(nByte);
if( p ){
memset(p, 0, nByte);
}
return p;
}
void Th_Free(Th_Interp *pInterp, void *z){
if( z ){
pInterp->pVtab->xFree(z);
}
}
/*
** Install a new th1 command.
**
** If a command of the same name already exists, it is deleted automatically.
*/
int Th_CreateCommand(
Th_Interp *interp,
const char *zName, /* New command name */
Th_CommandProc xProc, /* Command callback proc */
void *pContext, /* Value to pass as second arg to xProc */
void (*xDel)(Th_Interp *, void *) /* Command destructor callback */
){
Th_HashEntry *pEntry;
Th_Command *pCommand;
|
| ︙ | ︙ | |||
1423 1424 1425 1426 1427 1428 1429 |
}else{
pCommand = Th_Malloc(interp, sizeof(Th_Command));
}
pCommand->xProc = xProc;
pCommand->pContext = pContext;
pCommand->xDel = xDel;
pEntry->pData = (void *)pCommand;
| | | | | | | | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
}else{
pCommand = Th_Malloc(interp, sizeof(Th_Command));
}
pCommand->xProc = xProc;
pCommand->pContext = pContext;
pCommand->xDel = xDel;
pEntry->pData = (void *)pCommand;
return TH_OK;
}
/*
** Rename the existing command (zName, nName) to (zNew, nNew). If nNew is 0,
** the command is deleted instead of renamed.
**
** If successful, TH_OK is returned. If command zName does not exist, or
** if command zNew already exists, an error message is left in the
** interpreter result and TH_ERROR is returned.
*/
int Th_RenameCommand(
Th_Interp *interp,
const char *zName, /* Existing command name */
int nName, /* Number of bytes at zName */
const char *zNew, /* New command name */
int nNew /* Number of bytes at zNew */
){
Th_HashEntry *pEntry;
Th_HashEntry *pNewEntry;
pEntry = Th_HashFind(interp, interp->paCmd, zName, nName, 0);
if( !pEntry ){
|
| ︙ | ︙ | |||
1497 1498 1499 1500 1501 1502 1503 | ** Split a th1 list into its component elements. The list to split is ** passed via arguments (zList, nList). If successful, TH_OK is returned. ** If an error occurs (if (zList, nList) is not a valid list) an error ** message is left in the interpreter result and TH_ERROR returned. ** ** If successful, *pnCount is set to the number of elements in the list. ** panElem is set to point at an array of *pnCount integers - the lengths | | | 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 | ** Split a th1 list into its component elements. The list to split is ** passed via arguments (zList, nList). If successful, TH_OK is returned. ** If an error occurs (if (zList, nList) is not a valid list) an error ** message is left in the interpreter result and TH_ERROR returned. ** ** If successful, *pnCount is set to the number of elements in the list. ** panElem is set to point at an array of *pnCount integers - the lengths ** of the element values. *pazElem is set to point at an array of ** pointers to buffers containing the array element's data. ** ** To free the arrays allocated at *pazElem and *panElem, the caller ** should call Th_Free() on *pazElem only. Exactly one such call to ** Th_Free() must be made per call to Th_SplitList(). ** ** Example: |
| ︙ | ︙ | |||
1523 1524 1525 1526 1527 1528 1529 | ** } ** ** Th_Free(interp, azElem); ** */ int Th_SplitList( Th_Interp *interp, | | | | | | | | | 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 |
** }
**
** Th_Free(interp, azElem);
**
*/
int Th_SplitList(
Th_Interp *interp,
const char *zList, /* Pointer to buffer containing list */
int nList, /* Number of bytes at zList */
char ***pazElem, /* OUT: Array of pointers to element data */
int **panElem, /* OUT: Array of element data lengths */
int *pnCount /* OUT: Number of elements in list */
){
int rc;
interp->isListMode = 1;
rc = thSplitList(interp, zList, nList, pazElem, panElem, pnCount);
interp->isListMode = 0;
if( rc ){
Th_ErrorMessage(interp, "Expected list, got: \"", zList, nList);
}
return rc;
}
/*
** Append a new element to an existing th1 list. The element to append
** to the list is (zElem, nElem).
**
** A pointer to the existing list must be stored at *pzList when this
** function is called. The length must be stored in *pnList. The value
** of *pzList must either be NULL (in which case *pnList must be 0), or
** a pointer to memory obtained from Th_Malloc().
**
** This function calls Th_Free() to free the buffer at *pzList and sets
** *pzList to point to a new buffer containing the new list value. *pnList
** is similarly updated before returning. The return value is always TH_OK.
**
** Example:
**
** char *zList = 0;
** int nList = 0;
** for (...) {
** char *zElem = <some expression>;
** Th_ListAppend(interp, &zList, &nList, zElem, -1);
** }
** Th_SetResult(interp, zList, nList);
** Th_Free(interp, zList);
**
*/
int Th_ListAppend(
Th_Interp *interp, /* Interpreter context */
char **pzList, /* IN/OUT: Ptr to ptr to list */
int *pnList, /* IN/OUT: Current length of *pzList */
const char *zElem, /* Data to append */
int nElem /* Length of nElem */
){
Buffer output;
int i;
int hasSpecialChar = 0;
int hasEscapeChar = 0;
|
| ︙ | ︙ | |||
1621 1622 1623 1624 1625 1626 1627 | /* ** Append a new element to an existing th1 string. This function uses ** the same interface as the Th_ListAppend() function. */ int Th_StringAppend( Th_Interp *interp, /* Interpreter context */ | | | | 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 |
/*
** Append a new element to an existing th1 string. This function uses
** the same interface as the Th_ListAppend() function.
*/
int Th_StringAppend(
Th_Interp *interp, /* Interpreter context */
char **pzStr, /* IN/OUT: Ptr to ptr to list */
int *pnStr, /* IN/OUT: Current length of *pzStr */
const char *zElem, /* Data to append */
int nElem /* Length of nElem */
){
char *zNew;
int nNew;
if( nElem<0 ){
nElem = th_strlen(zElem);
|
| ︙ | ︙ | |||
1645 1646 1647 1648 1649 1650 1651 | Th_Free(interp, *pzStr); *pzStr = zNew; *pnStr = nNew; return TH_OK; } | | | | 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 |
Th_Free(interp, *pzStr);
*pzStr = zNew;
*pnStr = nNew;
return TH_OK;
}
/*
** Delete an interpreter.
*/
void Th_DeleteInterp(Th_Interp *interp){
assert(interp->pFrame);
assert(0==interp->pFrame->pCaller);
/* Delete the contents of the global frame. */
thPopFrame(interp);
/* Delete any result currently stored in the interpreter. */
Th_SetResult(interp, 0, 0);
/* Delete all registered commands and the command hash-table itself. */
Th_HashIterate(interp, interp->paCmd, thFreeCommand, (void *)interp);
Th_HashDelete(interp, interp->paCmd);
/* Delete the interpreter structure itself. */
Th_Free(interp, (void *)interp);
}
/*
** Create a new interpreter.
*/
Th_Interp * Th_CreateInterp(Th_Vtab *pVtab){
Th_Interp *p;
/* Allocate and initialise the interpreter and the global frame */
p = pVtab->xMalloc(sizeof(Th_Interp) + sizeof(Th_Frame));
|
| ︙ | ︙ | |||
1700 1701 1702 1703 1704 1705 1706 |
typedef struct Expr Expr;
struct Expr {
Operator *pOp;
Expr *pParent;
Expr *pLeft;
Expr *pRight;
| | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 |
typedef struct Expr Expr;
struct Expr {
Operator *pOp;
Expr *pParent;
Expr *pLeft;
Expr *pRight;
char *zValue; /* Pointer to literal value */
int nValue; /* Length of literal value buffer */
};
/* Unary operators */
#define OP_UNARY_MINUS 2
#define OP_UNARY_PLUS 3
#define OP_BITWISE_NOT 4
|
| ︙ | ︙ | |||
1756 1757 1758 1759 1760 1761 1762 |
/* Note: all unary operators have (iPrecedence==1) */
{"-", OP_UNARY_MINUS, 1, ARG_NUMBER},
{"+", OP_UNARY_PLUS, 1, ARG_NUMBER},
{"~", OP_BITWISE_NOT, 1, ARG_INTEGER},
{"!", OP_LOGICAL_NOT, 1, ARG_INTEGER},
/* Binary operators. It is important to the parsing in Th_Expr() that
| | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 |
/* Note: all unary operators have (iPrecedence==1) */
{"-", OP_UNARY_MINUS, 1, ARG_NUMBER},
{"+", OP_UNARY_PLUS, 1, ARG_NUMBER},
{"~", OP_BITWISE_NOT, 1, ARG_INTEGER},
{"!", OP_LOGICAL_NOT, 1, ARG_INTEGER},
/* Binary operators. It is important to the parsing in Th_Expr() that
* the two-character symbols ("==") appear before the one-character
* ones ("="). And that the priorities of all binary operators are
* integers between 2 and 12.
*/
{"<<", OP_LEFTSHIFT, 4, ARG_INTEGER},
{">>", OP_RIGHTSHIFT, 4, ARG_INTEGER},
{"<=", OP_LE, 5, ARG_NUMBER},
{">=", OP_GE, 5, ARG_NUMBER},
|
| ︙ | ︙ | |||
1787 1788 1789 1790 1791 1792 1793 |
{"|", OP_BITWISE_OR, 10, ARG_INTEGER},
{0,0,0,0}
};
/*
** The first part of the string (zInput,nInput) contains a number.
| | | | | | 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 |
{"|", OP_BITWISE_OR, 10, ARG_INTEGER},
{0,0,0,0}
};
/*
** The first part of the string (zInput,nInput) contains a number.
** Set *pnVarname to the number of bytes in the numeric string.
*/
static int thNextNumber(
Th_Interp *interp,
const char *zInput,
int nInput,
int *pnLiteral
){
int i;
int seenDot = 0;
for(i=0; i<nInput; i++){
char c = zInput[i];
if( (seenDot || c!='.') && !th_isdigit(c) ) break;
|
| ︙ | ︙ | |||
1862 1863 1864 1865 1866 1867 1868 |
if( rc==TH_OK ){
eArgType = pExpr->pOp->eArgType;
if( eArgType==ARG_NUMBER ){
if( (zLeft==0 || TH_OK==Th_ToInt(0, zLeft, nLeft, &iLeft))
&& (zRight==0 || TH_OK==Th_ToInt(0, zRight, nRight, &iRight))
){
eArgType = ARG_INTEGER;
| | | | 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 |
if( rc==TH_OK ){
eArgType = pExpr->pOp->eArgType;
if( eArgType==ARG_NUMBER ){
if( (zLeft==0 || TH_OK==Th_ToInt(0, zLeft, nLeft, &iLeft))
&& (zRight==0 || TH_OK==Th_ToInt(0, zRight, nRight, &iRight))
){
eArgType = ARG_INTEGER;
}else if(
(zLeft && TH_OK!=Th_ToDouble(interp, zLeft, nLeft, &fLeft)) ||
(zRight && TH_OK!=Th_ToDouble(interp, zRight, nRight, &fRight))
){
/* A type error. */
rc = TH_ERROR;
}
}else if( eArgType==ARG_INTEGER ){
rc = Th_ToInt(interp, zLeft, nLeft, &iLeft);
if( rc==TH_OK && zRight ){
rc = Th_ToInt(interp, zRight, nRight, &iRight);
}
}
}
if( rc==TH_OK && eArgType==ARG_INTEGER ){
int iRes = 0;
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: iRes = iLeft*iRight; break;
case OP_DIVIDE:
|
| ︙ | ︙ | |||
1976 1977 1978 1979 1980 1981 1982 |
assert(nToken>0);
#define ISTERM(x) (apToken[x] && (!apToken[x]->pOp || apToken[x]->pLeft))
for(jj=0; jj<nToken; jj++){
if( apToken[jj]->pOp && apToken[jj]->pOp->eOp==OP_OPEN_BRACKET ){
int nNest = 1;
| | | 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 |
assert(nToken>0);
#define ISTERM(x) (apToken[x] && (!apToken[x]->pOp || apToken[x]->pLeft))
for(jj=0; jj<nToken; jj++){
if( apToken[jj]->pOp && apToken[jj]->pOp->eOp==OP_OPEN_BRACKET ){
int nNest = 1;
int iLeft = jj;
for(jj++; jj<nToken; jj++){
Operator *pOp = apToken[jj]->pOp;
if( pOp && pOp->eOp==OP_OPEN_BRACKET ) nNest++;
if( pOp && pOp->eOp==OP_CLOSE_BRACKET ) nNest--;
if( nNest==0 ) break;
}
|
| ︙ | ︙ | |||
2050 2051 2052 2053 2054 2055 2056 | } /* ** Parse a string containing a TH expression to a list of tokens. */ static int exprParse( Th_Interp *interp, /* Interpreter to leave error message in */ | | | 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 |
}
/*
** Parse a string containing a TH expression to a list of tokens.
*/
static int exprParse(
Th_Interp *interp, /* Interpreter to leave error message in */
const char *zExpr, /* Pointer to input string */
int nExpr, /* Number of bytes at zExpr */
Expr ***papToken, /* OUT: Array of tokens. */
int *pnToken /* OUT: Size of token array */
){
int i;
int rc = TH_OK;
|
| ︙ | ︙ | |||
2125 2126 2127 2128 2129 2130 2131 |
assert( !pNew->pOp );
pNew->zValue = Th_Malloc(interp, pNew->nValue);
memcpy(pNew->zValue, z, pNew->nValue);
i += pNew->nValue;
}
if( (nToken%16)==0 ){
/* Grow the apToken array. */
| | | 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 |
assert( !pNew->pOp );
pNew->zValue = Th_Malloc(interp, pNew->nValue);
memcpy(pNew->zValue, z, pNew->nValue);
i += pNew->nValue;
}
if( (nToken%16)==0 ){
/* Grow the apToken array. */
Expr **apTokenOld = apToken;
apToken = Th_Malloc(interp, sizeof(Expr *)*(nToken+16));
memcpy(apToken, apTokenOld, sizeof(Expr *)*nToken);
}
/* Put the new token at the end of the apToken array */
apToken[nToken] = pNew;
nToken++;
|
| ︙ | ︙ | |||
2150 2151 2152 2153 2154 2155 2156 | } /* ** Evaluate the string (zExpr, nExpr) as a Th expression. Store ** the result in the interpreter interp and return TH_OK if ** successful. If an error occurs, store an error message in ** the interpreter result and return an error code. | | | | 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 |
}
/*
** Evaluate the string (zExpr, nExpr) as a Th expression. Store
** the result in the interpreter interp and return TH_OK if
** successful. If an error occurs, store an error message in
** the interpreter result and return an error code.
*/
int Th_Expr(Th_Interp *interp, const char *zExpr, int nExpr){
int rc; /* Return Code */
int i; /* Loop counter */
int nToken = 0;
Expr **apToken = 0;
if( nExpr<0 ){
nExpr = th_strlen(zExpr);
}
/* Parse the expression to a list of tokens. */
rc = exprParse(interp, zExpr, nExpr, &apToken, &nToken);
/* If the parsing was successful, create an expression tree from
** the parsed list of tokens. If successful, apToken[0] is set
** to point to the root of the expression tree.
*/
if( rc==TH_OK ){
rc = exprMakeTree(interp, apToken, nToken);
}
if( rc!=TH_OK ){
Th_ErrorMessage(interp, "syntax error in expression: \"", zExpr, nExpr);
|
| ︙ | ︙ | |||
2205 2206 2207 2208 2209 2210 2211 | return p; } /* ** Iterate through all values currently stored in the hash table. Invoke ** the callback function xCallback for each entry. The second argument ** passed to xCallback is a copy of the fourth argument passed to this | | > | | | | > | | | | 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 |
return p;
}
/*
** Iterate through all values currently stored in the hash table. Invoke
** the callback function xCallback for each entry. The second argument
** passed to xCallback is a copy of the fourth argument passed to this
** function. The return value from the callback function xCallback is
** ignored.
*/
void Th_HashIterate(
Th_Interp *interp,
Th_Hash *pHash,
int (*xCallback)(Th_HashEntry *pEntry, void *pContext),
void *pContext
){
int i;
for(i=0; i<TH_HASHSIZE; i++){
Th_HashEntry *pEntry;
Th_HashEntry *pNext;
for(pEntry=pHash->a[i]; pEntry; pEntry=pNext){
pNext = pEntry->pNext;
xCallback(pEntry, pContext);
}
}
}
/*
** Helper function for Th_HashDelete(). Always returns non-zero.
*/
static int xFreeHashEntry(Th_HashEntry *pEntry, void *pContext){
Th_Free((Th_Interp *)pContext, (void *)pEntry);
return 1;
}
/*
** Free a hash-table previously allocated by Th_HashNew().
*/
void Th_HashDelete(Th_Interp *interp, Th_Hash *pHash){
if( pHash ){
Th_HashIterate(interp, pHash, xFreeHashEntry, (void *)interp);
Th_Free(interp, pHash);
}
}
/*
** This function is used to insert or delete hash table items, or to
** query a hash table for an existing item.
**
** If parameter op is less than zero, then the hash-table element
** identified by (zKey, nKey) is removed from the hash-table if it
** exists. NULL is returned.
**
** Otherwise, if the hash-table contains an item with key (zKey, nKey),
** a pointer to the associated Th_HashEntry is returned. If parameter
** op is greater than zero, then a new entry is added if one cannot
** be found. If op is zero, then NULL is returned if the item is
** not already present in the hash-table.
*/
Th_HashEntry *Th_HashFind(
Th_Interp *interp,
Th_Hash *pHash,
const char *zKey,
int nKey,
int op /* -ve = delete, 0 = find, +ve = insert */
){
unsigned int iKey = 0;
int i;
|
| ︙ | ︙ | |||
2324 2325 2326 2327 2328 2329 2330 | ** '\n' 0x0A ** '\v' 0x0B ** '\f' 0x0C ** '\r' 0x0D ** ** Whitespace characters have the 0x01 flag set. Decimal digits have the ** 0x2 flag set. Single byte printable characters have the 0x4 flag set. | | | 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 |
** '\n' 0x0A
** '\v' 0x0B
** '\f' 0x0C
** '\r' 0x0D
**
** Whitespace characters have the 0x01 flag set. Decimal digits have the
** 0x2 flag set. Single byte printable characters have the 0x4 flag set.
** Alphabet characters have the 0x8 bit set.
**
** The special list characters have the 0x10 flag set
**
** { } [ ] \ ; ' "
**
** " 0x22
**
|
| ︙ | ︙ | |||
2475 2476 2477 2478 2479 2480 2481 | } *pResult = sign<0 ? -v1 : v1; return z - zBegin; } /* ** Try to convert the string passed as arguments (z, n) to an integer. | | | | | 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 |
}
*pResult = sign<0 ? -v1 : v1;
return z - zBegin;
}
/*
** Try to convert the string passed as arguments (z, n) to an integer.
** If successful, store the result in *piOut and return TH_OK.
**
** If the string cannot be converted to an integer, return TH_ERROR.
** If the interp argument is not NULL, leave an error message in the
** interpreter result too.
*/
int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){
int i = 0;
int iOut = 0;
if( n<0 ){
|
| ︙ | ︙ | |||
2510 2511 2512 2513 2514 2515 2516 | *piOut = iOut; return TH_OK; } /* ** Try to convert the string passed as arguments (z, n) to a double. | | | | | | | | 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 |
*piOut = iOut;
return TH_OK;
}
/*
** Try to convert the string passed as arguments (z, n) to a double.
** If successful, store the result in *pfOut and return TH_OK.
**
** If the string cannot be converted to a double, return TH_ERROR.
** If the interp argument is not NULL, leave an error message in the
** interpreter result too.
*/
int Th_ToDouble(
Th_Interp *interp,
const char *z,
int n,
double *pfOut
){
if( !sqlite3IsNumber((const char *)z, 0) ){
Th_ErrorMessage(interp, "expected number, got: \"", z, n);
return TH_ERROR;
}
|
| ︙ | ︙ | |||
2564 2565 2566 2567 2568 2569 2570 |
/*
** Set the result of the interpreter to the th1 representation of
** the double fVal and return TH_OK.
*/
int Th_SetResultDouble(Th_Interp *interp, double fVal){
int i; /* Iterator variable */
double v = fVal; /* Input value */
| | | | | | | | 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 |
/*
** Set the result of the interpreter to the th1 representation of
** the double fVal and return TH_OK.
*/
int Th_SetResultDouble(Th_Interp *interp, double fVal){
int i; /* Iterator variable */
double v = fVal; /* Input value */
char zBuf[128]; /* Output buffer */
char *z = zBuf; /* Output cursor */
int iDot = 0; /* Digit after which to place decimal point */
int iExp = 0; /* Exponent (NN in eNN) */
const char *zExp; /* String representation of iExp */
/* Precision: */
#define INSIGNIFICANT 0.000000000001
#define ROUNDER 0.0000000000005
double insignificant = INSIGNIFICANT;
/* If the real value is negative, write a '-' character to the
* output and transform v to the corresponding positive number.
*/
if( v<0.0 ){
*z++ = '-';
v *= -1.0;
}
/* Normalize v to a value between 1.0 and 10.0. Integer
* variable iExp is set to the exponent. i.e the original
* value is (v * 10^iExp) (or the negative thereof).
*/
if( v>0.0 ){
while( (v+ROUNDER)>=10.0 ) { iExp++; v *= 0.1; }
while( (v+ROUNDER)<1.0 ) { iExp--; v *= 10.0; }
}
v += ROUNDER;
/* For a small (<12) positive exponent, move the decimal point
|
| ︙ | ︙ |
Changes to src/th.h.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | typedef struct Th_Vtab Th_Vtab; /* ** Opaque handle for interpeter. */ typedef struct Th_Interp Th_Interp; | | | | | | | | | | | | | | | | | | | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | typedef struct Th_Vtab Th_Vtab; /* ** Opaque handle for interpeter. */ typedef struct Th_Interp Th_Interp; /* ** Create and delete interpreters. */ Th_Interp * Th_CreateInterp(Th_Vtab *pVtab); void Th_DeleteInterp(Th_Interp *); /* ** Evaluate an TH program in the stack frame identified by parameter ** iFrame, according to the following rules: ** ** * If iFrame is 0, this means the current frame. ** ** * If iFrame is negative, then the nth frame up the stack, where n is ** the absolute value of iFrame. A value of -1 means the calling ** procedure. ** ** * If iFrame is +ve, then the nth frame from the bottom of the stack. ** An iFrame value of 1 means the toplevel (global) frame. */ int Th_Eval(Th_Interp *interp, int iFrame, const char *zProg, int nProg); /* ** Evaluate a TH expression. The result is stored in the ** interpreter result. */ int Th_Expr(Th_Interp *interp, const char *, int); /* ** Access TH variables in the current stack frame. If the variable name ** begins with "::", the lookup is in the top level (global) frame. */ int Th_ExistsVar(Th_Interp *, const char *, int); int Th_GetVar(Th_Interp *, const char *, int); int Th_SetVar(Th_Interp *, const char *, int, const char *, int); int Th_LinkVar(Th_Interp *, const char *, int, int, const char *, int); int Th_UnsetVar(Th_Interp *, const char *, int); typedef int (*Th_CommandProc)(Th_Interp *, void *, int, const char **, int *); /* ** Register new commands. */ int Th_CreateCommand( Th_Interp *interp, const char *zName, /* int (*xProc)(Th_Interp *, void *, int, const char **, int *), */ Th_CommandProc xProc, void *pContext, void (*xDel)(Th_Interp *, void *) ); /* ** Delete or rename commands. */ int Th_RenameCommand(Th_Interp *, const char *, int, const char *, int); /* ** Push a new stack frame (local variable context) onto the interpreter ** stack, call the function supplied as parameter xCall with the two ** context arguments, ** ** xCall(interp, pContext1, pContext2) ** ** , then pop the frame off of the interpreter stack. The value returned ** by the xCall() function is returned as the result of this function. ** ** This is intended for use by the implementation of commands such as ** those created by [proc]. */ int Th_InFrame(Th_Interp *interp, int (*xCall)(Th_Interp *, void *pContext1, void *pContext2), void *pContext1, void *pContext2 ); /* ** Valid return codes for xProc callbacks. */ #define TH_OK 0 #define TH_ERROR 1 #define TH_BREAK 2 #define TH_RETURN 3 #define TH_CONTINUE 4 /* ** Set and get the interpreter result. */ int Th_SetResult(Th_Interp *, const char *, int); const char *Th_GetResult(Th_Interp *, int *); char *Th_TakeResult(Th_Interp *, int *); /* ** Set an error message as the interpreter result. This also ** sets the global stack-trace variable $::th_stack_trace. */ int Th_ErrorMessage(Th_Interp *, const char *, const char *, int); /* ** Access the memory management functions associated with the specified ** interpreter. */ void *Th_Malloc(Th_Interp *, int); void Th_Free(Th_Interp *, void *); /* ** Functions for handling TH lists. */ int Th_ListAppend(Th_Interp *, char **, int *, const char *, int); int Th_SplitList(Th_Interp *, const char *, int, char ***, int **, int *); int Th_StringAppend(Th_Interp *, char **, int *, const char *, int); /* ** Functions for handling numbers and pointers. */ int Th_ToInt(Th_Interp *, const char *, int, int *); int Th_ToDouble(Th_Interp *, const char *, int, double *); int Th_SetResultInt(Th_Interp *, int); int Th_SetResultDouble(Th_Interp *, double); |
| ︙ | ︙ | |||
172 173 174 175 176 177 178 | void *pData; char *zKey; int nKey; Th_HashEntry *pNext; /* Internal use only */ }; Th_Hash *Th_HashNew(Th_Interp *); void Th_HashDelete(Th_Interp *, Th_Hash *); | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
void *pData;
char *zKey;
int nKey;
Th_HashEntry *pNext; /* Internal use only */
};
Th_Hash *Th_HashNew(Th_Interp *);
void Th_HashDelete(Th_Interp *, Th_Hash *);
void Th_HashIterate(Th_Interp*,Th_Hash*,int (*x)(Th_HashEntry*, void*),void*);
Th_HashEntry *Th_HashFind(Th_Interp*, Th_Hash*, const char*, int, int);
/*
** Useful functions from th_lang.c.
*/
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg);
typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand;
int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*);
|
Changes to src/th_lang.c.
1 2 | /* | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
/*
** This file contains the implementation of all of the TH language
** built-in commands.
**
** All built-in commands are implemented using the public interface
** declared in th.h, so this file serves as both a part of the language
** implementation and an example of how to extend the language with
** new commands.
*/
#include "config.h"
#include "th.h"
#include <string.h>
#include <assert.h>
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
Th_ErrorMessage(interp, "wrong # args: should be \"", zMsg, -1);
return TH_ERROR;
}
/*
** Syntax:
**
** catch script ?varname?
*/
static int catch_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int rc;
if( argc!=2 && argc!=3 ){
return Th_WrongNumArgs(interp, "catch script ?varname?");
}
rc = Th_Eval(interp, 0, argv[1], -1);
if( argc==3 ){
int nResult;
const char *zResult = Th_GetResult(interp, &nResult);
Th_SetVar(interp, argv[2], argl[2], zResult, nResult);
}
Th_SetResultInt(interp, rc);
return TH_OK;
}
/*
** TH Syntax:
**
** if expr1 body1 ?elseif expr2 body2? ? ?else? bodyN?
*/
static int if_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int rc = TH_OK;
int iCond; /* Result of evaluating expression */
int i;
|
| ︙ | ︙ | |||
92 93 94 95 96 97 98 | return rc; wrong_args: return Th_WrongNumArgs(interp, "if ..."); } /* | | | | | | | | | | | | | | | | | | | | | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
return rc;
wrong_args:
return Th_WrongNumArgs(interp, "if ...");
}
/*
** TH Syntax:
**
** expr expr
*/
static int expr_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
if( argc!=2 ){
return Th_WrongNumArgs(interp, "expr expression");
}
return Th_Expr(interp, argv[1], argl[1]);
}
/*
** Evaluate the th1 script (zBody, nBody) in the local stack frame.
** Return the result of the evaluation, except if the result
** is TH_CONTINUE, return TH_OK instead.
*/
static int eval_loopbody(Th_Interp *interp, const char *zBody, int nBody){
int rc = Th_Eval(interp, 0, zBody, nBody);
if( rc==TH_CONTINUE ){
rc = TH_OK;
}
return rc;
}
/*
** TH Syntax:
**
** for init condition incr script
*/
static int for_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int rc;
int iCond;
if( argc!=5 ){
return Th_WrongNumArgs(interp, "for init condition incr script");
}
/* Evaluate the 'init' script */
rc = Th_Eval(interp, 0, argv[1], -1);
while( rc==TH_OK
&& TH_OK==(rc = Th_Expr(interp, argv[2], -1))
&& TH_OK==(rc = Th_ToInt(interp, Th_GetResult(interp, 0), -1, &iCond))
&& iCond
&& TH_OK==(rc = eval_loopbody(interp, argv[4], argl[4]))
){
rc = Th_Eval(interp, 0, argv[3], -1);
}
if( rc==TH_BREAK ) rc = TH_OK;
return rc;
}
/*
** TH Syntax:
**
** list ?arg1 ?arg2? ...?
*/
static int list_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
char *zList = 0;
int nList = 0;
int i;
for(i=1; i<argc; i++){
Th_ListAppend(interp, &zList, &nList, argv[i], argl[i]);
}
Th_SetResult(interp, zList, nList);
Th_Free(interp, zList);
return TH_OK;
}
/*
** TH Syntax:
**
** lindex list index
*/
static int lindex_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int iElem;
int rc;
char **azElem;
int *anElem;
|
| ︙ | ︙ | |||
225 226 227 228 229 230 231 |
Th_Free(interp, azElem);
}
return rc;
}
/*
| | | | | | | | | | | | | | | | | | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
Th_Free(interp, azElem);
}
return rc;
}
/*
** TH Syntax:
**
** llength list
*/
static int llength_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int nElem;
int rc;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "llength list");
}
rc = Th_SplitList(interp, argv[1], argl[1], 0, 0, &nElem);
if( rc==TH_OK ){
Th_SetResultInt(interp, nElem);
}
return rc;
}
/*
** TH Syntax:
**
** set varname ?value?
*/
static int set_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
if( argc!=2 && argc!=3 ){
return Th_WrongNumArgs(interp, "set varname ?value?");
}
if( argc==3 ){
Th_SetVar(interp, argv[1], argl[1], argv[2], argl[2]);
}
return Th_GetVar(interp, argv[1], argl[1]);
}
/*
** When a new command is created using the built-in [proc] command, an
** instance of the following structure is allocated and populated. A
** pointer to the structure is passed as the context (second) argument
** to function proc_call1() when the new command is executed.
*/
typedef struct ProcDefn ProcDefn;
struct ProcDefn {
int nParam; /* Number of formal (non "args") parameters */
char **azParam; /* Parameter names */
int *anParam; /* Lengths of parameter names */
char **azDefault; /* Default values */
int *anDefault; /* Lengths of default values */
int hasArgs; /* True if there is an "args" parameter */
char *zProgram; /* Body of proc */
int nProgram; /* Number of bytes at zProgram */
char *zUsage; /* Usage message */
int nUsage; /* Number of bytes at zUsage */
};
/* This structure is used to temporarily store arguments passed to an
** invocation of a command created using [proc]. A pointer to an
** instance is passed as the second argument to the proc_call2() function.
*/
typedef struct ProcArgs ProcArgs;
struct ProcArgs {
int argc;
const char **argv;
int *argl;
|
| ︙ | ︙ | |||
321 322 323 324 325 326 327 | int i; ProcDefn *p = (ProcDefn *)pContext1; ProcArgs *pArgs = (ProcArgs *)pContext2; /* Check if there are the right number of arguments. If there are ** not, generate a usage message for the command. */ | | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
int i;
ProcDefn *p = (ProcDefn *)pContext1;
ProcArgs *pArgs = (ProcArgs *)pContext2;
/* Check if there are the right number of arguments. If there are
** not, generate a usage message for the command.
*/
if( (pArgs->argc>(p->nParam+1) && !p->hasArgs)
|| (pArgs->argc<=(p->nParam) && !p->azDefault[pArgs->argc-1])
){
char *zUsage = 0;
int nUsage = 0;
Th_StringAppend(interp, &zUsage, &nUsage, pArgs->argv[0], pArgs->argl[0]);
Th_StringAppend(interp, &zUsage, &nUsage, p->zUsage, p->nUsage);
Th_StringAppend(interp, &zUsage, &nUsage, (const char *)"", 1);
|
| ︙ | ︙ | |||
372 373 374 375 376 377 378 | /* ** This function is the command callback registered for all commands ** created using the [proc] command. The second argument, pContext, ** is a pointer to the associated ProcDefn structure. */ static int proc_call1( Th_Interp *interp, | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
/*
** This function is the command callback registered for all commands
** created using the [proc] command. The second argument, pContext,
** is a pointer to the associated ProcDefn structure.
*/
static int proc_call1(
Th_Interp *interp,
void *pContext,
int argc,
const char **argv,
int *argl
){
int rc;
ProcDefn *p = (ProcDefn *)pContext;
ProcArgs procargs;
|
| ︙ | ︙ | |||
398 399 400 401 402 403 404 |
if( rc==TH_RETURN ){
rc = TH_OK;
}
return rc;
}
/*
| | | | | | | | | | | | | | | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
if( rc==TH_RETURN ){
rc = TH_OK;
}
return rc;
}
/*
** This function is registered as the delete callback for all commands
** created using the built-in [proc] command. It is called automatically
** when a command created using [proc] is deleted.
**
** It frees the ProcDefn structure allocated when the command was created.
*/
static void proc_del(Th_Interp *interp, void *pContext){
ProcDefn *p = (ProcDefn *)pContext;
Th_Free(interp, (void *)p->zUsage);
Th_Free(interp, (void *)p);
}
/*
** TH Syntax:
**
** proc name arglist code
*/
static int proc_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int rc;
char *zName;
ProcDefn *p;
int nByte;
int i;
char *zSpace;
char **azParam;
int *anParam;
int nParam;
char *zUsage = 0; /* Build up a usage message here */
int nUsage = 0; /* Number of bytes at zUsage */
if( argc!=4 ){
return Th_WrongNumArgs(interp, "proc name arglist code");
}
if( Th_SplitList(interp, argv[2], argl[2], &azParam, &anParam, &nParam) ){
return TH_ERROR;
}
/* Allocate the new ProcDefn structure. */
nByte = sizeof(ProcDefn) + /* ProcDefn structure */
(sizeof(char *) + sizeof(int)) * nParam + /* azParam, anParam */
(sizeof(char *) + sizeof(int)) * nParam + /* azDefault, anDefault */
argl[3] + /* zProgram */
argl[2]; /* Space for copies of parameter names and default values */
p = (ProcDefn *)Th_Malloc(interp, nByte);
/* If the last parameter in the parameter list is "args", then set the
** ProcDefn.hasArgs flag. The "args" parameter does not require an
** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
*/
if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){
p->hasArgs = 1;
nParam--;
}
p->nParam = nParam;
p->azParam = (char **)&p[1];
p->anParam = (int *)&p->azParam[nParam];
p->azDefault = (char **)&p->anParam[nParam];
p->anDefault = (int *)&p->azDefault[nParam];
p->zProgram = (char *)&p->anDefault[nParam];
memcpy(p->zProgram, argv[3], argl[3]);
p->nProgram = argl[3];
zSpace = &p->zProgram[p->nProgram];
for(i=0; i<nParam; i++){
char **az;
int *an;
int n;
if( Th_SplitList(interp, azParam[i], anParam[i], &az, &an, &n) ){
goto error_out;
}
|
| ︙ | ︙ | |||
535 536 537 538 539 540 541 | error_out: Th_Free(interp, azParam); Th_Free(interp, zUsage); return TH_ERROR; } /* | | | | | | | | | | | | | | | | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
error_out:
Th_Free(interp, azParam);
Th_Free(interp, zUsage);
return TH_ERROR;
}
/*
** TH Syntax:
**
** rename oldcmd newcmd
*/
static int rename_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
if( argc!=3 ){
return Th_WrongNumArgs(interp, "rename oldcmd newcmd");
}
return Th_RenameCommand(interp, argv[1], argl[1], argv[2], argl[2]);
}
/*
** TH Syntax:
**
** break ?value...?
** continue ?value...?
** ok ?value...?
** error ?value...?
*/
static int simple_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "return ?value?");
}
if( argc==2 ){
Th_SetResult(interp, argv[1], argl[1]);
}
return FOSSIL_PTR_TO_INT(ctx);
}
/*
** TH Syntax:
**
** return ?-code code? ?value?
*/
static int return_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int iCode = TH_RETURN;
if( argc<1 || argc>4 ){
return Th_WrongNumArgs(interp, "return ?-code code? ?value?");
}
if( argc>2 ){
|
| ︙ | ︙ | |||
636 637 638 639 640 641 642 |
}
if( iRes==0 ){
iRes = nLeft-nRight;
}
if( iRes<0 ) iRes = -1;
if( iRes>0 ) iRes = 1;
| | < < < < | > > > | > | | | | | | | > | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
}
if( iRes==0 ){
iRes = nLeft-nRight;
}
if( iRes<0 ) iRes = -1;
if( iRes>0 ) iRes = 1;
return Th_SetResultInt(interp, iRes);
}
/*
** TH Syntax:
**
** string first NEEDLE HAYSTACK
*/
static int string_first_command(
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
){
int nNeedle;
int nHaystack;
int iRes = -1;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "string first needle haystack");
}
nNeedle = argl[2];
nHaystack = argl[3];
if( nNeedle && nHaystack && nNeedle<=nHaystack ){
const char *zNeedle = argv[2];
const char *zHaystack = argv[3];
int i;
for(i=0; i<=(nHaystack-nNeedle); i++){
if( 0==memcmp(zNeedle, &zHaystack[i], nNeedle) ){
iRes = i;
break;
}
}
}
return Th_SetResultInt(interp, iRes);
}
/*
** TH Syntax:
**
** string is CLASS STRING
|
| ︙ | ︙ | |||
709 710 711 712 713 714 715 |
** TH Syntax:
**
** string last NEEDLE HAYSTACK
*/
static int string_last_command(
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
){
| < < < | < | > > > | > | | | | | | | > | 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
** TH Syntax:
**
** string last NEEDLE HAYSTACK
*/
static int string_last_command(
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
){
int nNeedle;
int nHaystack;
int iRes = -1;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "string last needle haystack");
}
nNeedle = argl[2];
nHaystack = argl[3];
if( nNeedle && nHaystack && nNeedle<=nHaystack ){
const char *zNeedle = argv[2];
const char *zHaystack = argv[3];
int i;
for(i=nHaystack-nNeedle; i>=0; i--){
if( 0==memcmp(zNeedle, &zHaystack[i], nNeedle) ){
iRes = i;
break;
}
}
}
return Th_SetResultInt(interp, iRes);
}
/*
** TH Syntax:
**
** string length STRING
|
| ︙ | ︙ | |||
865 866 867 868 869 870 871 | /* ** TH Syntax: ** ** unset VAR */ static int unset_command( | | | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
/*
** TH Syntax:
**
** unset VAR
*/
static int unset_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
if( argc!=2 ){
return Th_WrongNumArgs(interp, "unset var");
}
return Th_UnsetVar(interp, argv[1], argl[1]);
}
int Th_CallSubCommand(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl,
Th_SubCommand *aSub
){
if( argc>1 ){
|
| ︙ | ︙ | |||
914 915 916 917 918 919 920 | ** string is CLASS STRING ** string last NEEDLE HAYSTACK ?STARTINDEX? ** string length STRING ** string range STRING FIRST LAST ** string repeat STRING COUNT */ static int string_command( | | | 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
** string is CLASS STRING
** string last NEEDLE HAYSTACK ?STARTINDEX?
** string length STRING
** string range STRING FIRST LAST
** string repeat STRING COUNT
*/
static int string_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
Th_SubCommand aSub[] = {
{ "compare", string_compare_command },
|
| ︙ | ︙ | |||
942 943 944 945 946 947 948 | /* ** TH Syntax: ** ** info exists VARNAME */ static int info_command( | | | | | | | | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 |
/*
** TH Syntax:
**
** info exists VARNAME
*/
static int info_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
Th_SubCommand aSub[] = {
{ "exists", info_exists_command },
{ 0, 0 }
};
return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
}
/*
** Convert the script level frame specification (used by the commands
** [uplevel] and [upvar]) in (zFrame, nFrame) to an integer frame as
** used by Th_LinkVar() and Th_Eval(). If successful, write the integer
** frame level to *piFrame and return TH_OK. Otherwise, return TH_ERROR
** and leave an error message in the interpreter result.
*/
static int thToFrame(
Th_Interp *interp,
const char *zFrame,
int nFrame,
int *piFrame
){
int iFrame;
if( th_isdigit(zFrame[0]) ){
int rc = Th_ToInt(interp, zFrame, nFrame, &iFrame);
if( rc!=TH_OK ) return rc;
iFrame = iFrame * -1;
|
| ︙ | ︙ | |||
990 991 992 993 994 995 996 | /* ** TH Syntax: ** ** uplevel ?LEVEL? SCRIPT */ static int uplevel_command( | | | | | | | | | | | | | | 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 |
/*
** TH Syntax:
**
** uplevel ?LEVEL? SCRIPT
*/
static int uplevel_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int iFrame = -1;
if( argc!=2 && argc!=3 ){
return Th_WrongNumArgs(interp, "uplevel ?level? script...");
}
if( argc==3 && TH_OK!=thToFrame(interp, argv[1], argl[1], &iFrame) ){
return TH_ERROR;
}
return Th_Eval(interp, iFrame, argv[argc-1], -1);
}
/*
** TH Syntax:
**
** upvar ?FRAME? OTHERVAR MYVAR ?OTHERVAR MYVAR ...?
*/
static int upvar_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int iVar = 1;
int iFrame = -1;
int rc = TH_OK;
int i;
if( TH_OK==thToFrame(0, argv[1], argl[1], &iFrame) ){
iVar++;
}
if( argc==iVar || (argc-iVar)%2 ){
return Th_WrongNumArgs(interp,
"upvar frame othervar myvar ?othervar myvar...?");
}
for(i=iVar; rc==TH_OK && i<argc; i=i+2){
rc = Th_LinkVar(interp, argv[i+1], argl[i+1], iFrame, argv[i], argl[i]);
}
return rc;
}
/*
** TH Syntax:
**
** breakpoint ARGS
**
** This command does nothing at all. Its purpose in life is to serve
** as a point for setting breakpoints in a debugger.
*/
static int breakpoint_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
int cnt = 0;
cnt++;
return TH_OK;
}
|
| ︙ | ︙ | |||
1076 1077 1078 1079 1080 1081 1082 |
{"expr", expr_command, 0},
{"for", for_command, 0},
{"if", if_command, 0},
{"info", info_command, 0},
{"lindex", lindex_command, 0},
{"list", list_command, 0},
{"llength", llength_command, 0},
| | | | | | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
{"expr", expr_command, 0},
{"for", for_command, 0},
{"if", if_command, 0},
{"info", info_command, 0},
{"lindex", lindex_command, 0},
{"list", list_command, 0},
{"llength", llength_command, 0},
{"proc", proc_command, 0},
{"rename", rename_command, 0},
{"set", set_command, 0},
{"string", string_command, 0},
{"unset", unset_command, 0},
{"uplevel", uplevel_command, 0},
{"upvar", upvar_command, 0},
{"breakpoint", breakpoint_command, 0},
{"return", return_command, 0},
{"break", simple_command, (void *)TH_BREAK},
{"continue", simple_command, (void *)TH_CONTINUE},
{"error", simple_command, (void *)TH_ERROR},
{0, 0, 0}
};
int i;
/* Add the language commands. */
for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 |
g.interp = Th_CreateInterp(&vtab);
created = 1;
}
if( forceReset || created ){
th_register_language(g.interp); /* Basic scripting commands. */
}
#ifdef FOSSIL_ENABLE_TCL
| > | | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
g.interp = Th_CreateInterp(&vtab);
created = 1;
}
if( forceReset || created ){
th_register_language(g.interp); /* Basic scripting commands. */
}
#ifdef FOSSIL_ENABLE_TCL
if( forceTcl || fossil_getenv("TH1_ENABLE_TCL")!=0 ||
db_get_boolean("tcl", 0) ){
if( !g.tcl.setup ){
g.tcl.setup = db_get("tcl-setup", 0); /* Grab Tcl setup script. */
}
th_register_tcl(g.interp, &g.tcl); /* Tcl integration commands. */
}
#endif
for(i=0; i<sizeof(aCommand)/sizeof(aCommand[0]); i++){
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
533 534 535 536 537 538 539 |
rid, zTktId
);
}else{
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
}
manifest_crosslink_begin();
| | > > > | > | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
rid, zTktId
);
}else{
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
}
manifest_crosslink_begin();
result = (manifest_crosslink(rid, pTicket, MC_NONE)==0);
assert( blob_is_reset(pTicket) );
if( !result ){
result = manifest_crosslink_end(MC_PERMIT_HOOKS);
}else{
manifest_crosslink_end(MC_NONE);
}
return result;
}
/*
** Subscript command: submit_ticket
**
** Construct and submit a new ticket artifact. The fields of the artifact
|
| ︙ | ︙ |
Changes to src/winfile.c.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
*/
#include "config.h"
#ifdef _WIN32
/* This code is for win32 only */
#include <sys/stat.h>
#include <windows.h>
#include "winfile.h"
/*
** Fill stat buf with information received from stat() or lstat().
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
int win32_stat(const char *zFilename, struct fossilStat *buf, int isWd){
| > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
*/
#include "config.h"
#ifdef _WIN32
/* This code is for win32 only */
#include <sys/stat.h>
#include <windows.h>
#include "winfile.h"
#ifndef LABEL_SECURITY_INFORMATION
# define LABEL_SECURITY_INFORMATION (0x00000010L)
#endif
/*
** Fill stat buf with information received from stat() or lstat().
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
int win32_stat(const char *zFilename, struct fossilStat *buf, int isWd){
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
850 851 852 853 854 855 856 |
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int xfer_run_script(const char *zScript, const char *zUuid){
| | | | | | | | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int xfer_run_script(const char *zScript, const char *zUuid){
int rc;
if( !zScript ) return TH_OK;
Th_FossilInit(TH_INIT_DEFAULT);
if( zUuid ){
rc = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
if( rc!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
return rc;
}
}
rc = Th_Eval(g.interp, 0, zScript, -1);
if( rc!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
}
return rc;
}
/*
** Runs the pre-transfer TH1 script, if any, and returns its return code.
** This script may be run multiple times. If the script performs actions
** that cannot be redone, it should use an internal [if] guard similar to
** the following:
|
| ︙ | ︙ | |||
912 913 914 915 916 917 918 | Xfer xfer; int deltaFlag = 0; int isClone = 0; int nGimme = 0; int size; int recvConfig = 0; char *zNow; | | | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
Xfer xfer;
int deltaFlag = 0;
int isClone = 0;
int nGimme = 0;
int size;
int recvConfig = 0;
char *zNow;
int rc;
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
fossil_redirect_home();
}
g.zLogin = "anonymous";
login_set_anon_nobody_capabilities();
login_check_credentials();
|
| ︙ | ︙ | |||
942 943 944 945 946 947 948 |
g.xferPanic = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
);
manifest_crosslink_begin();
| | | | 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
g.xferPanic = 1;
db_begin_transaction();
db_multi_exec(
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
);
manifest_crosslink_begin();
rc = xfer_run_common_script();
if( rc==TH_ERROR ){
cgi_reset_content();
@ error common\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
while( blob_line(xfer.pIn, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
if( blob_size(&xfer.line)==0 ) continue;
|
| ︙ | ︙ | |||
1270 1271 1272 1273 1274 1275 1276 |
cgi_reset_content();
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
| | | | | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 |
cgi_reset_content();
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
if( rc==TH_OK ){
rc = xfer_run_script(xfer_push_code(), 0);
if( rc==TH_ERROR ){
cgi_reset_content();
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
}
request_phantoms(&xfer, 500);
}
|
| ︙ | ︙ | |||
1299 1300 1301 1302 1303 1304 1305 |
send_unclustered(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}
if( recvConfig ){
configure_finalize_receive();
}
db_multi_exec("DROP TABLE onremote");
| | | 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 |
send_unclustered(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}
if( recvConfig ){
configure_finalize_receive();
}
db_multi_exec("DROP TABLE onremote");
manifest_crosslink_end(MC_PERMIT_HOOKS);
/* Send the server timestamp last, in case prior processing happened
** to use up a significant fraction of our time window.
*/
zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
@ # timestamp %s(zNow)
free(zNow);
|
| ︙ | ︙ | |||
1926 1927 1928 1929 1930 1931 1932 |
fossil_force_newline();
fossil_print(
"%s finished with %lld bytes sent, %lld bytes received\n",
zOpType, nSent, nRcvd);
transport_close(GLOBAL_URL());
transport_global_shutdown(GLOBAL_URL());
db_multi_exec("DROP TABLE onremote");
| | | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 |
fossil_force_newline();
fossil_print(
"%s finished with %lld bytes sent, %lld bytes received\n",
zOpType, nSent, nRcvd);
transport_close(GLOBAL_URL());
transport_global_shutdown(GLOBAL_URL());
db_multi_exec("DROP TABLE onremote");
manifest_crosslink_end(MC_PERMIT_HOOKS);
content_enable_dephantomize(1);
db_end_transaction(0);
return nErr;
}
|
Changes to test/merge2.test.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# Tests of the delta mechanism.
#
set filelist [glob $testdir/*]
foreach f $filelist {
if {[file isdir $f]} continue
set base [file root [file tail $f]]
set f1 [read_file $f]
write_file t1 $f1
for {set i 0} {$i<100} {incr i} {
expr {srand($i*2)}
write_file t2 [set f2 [random_changes $f1 2 4 0 0.1]]
expr {srand($i*2+1)}
write_file t3 [set f3 [random_changes $f1 2 4 2 0.1]]
| > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Tests of the delta mechanism.
#
set filelist [glob $testdir/*]
foreach f $filelist {
if {[file isdir $f]} continue
set base [file root [file tail $f]]
if {$base eq "utf"} continue
set f1 [read_file $f]
write_file t1 $f1
for {set i 0} {$i<100} {incr i} {
expr {srand($i*2)}
write_file t2 [set f2 [random_changes $f1 2 4 0 0.1]]
expr {srand($i*2+1)}
write_file t3 [set f3 [random_changes $f1 2 4 2 0.1]]
|
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
###############################################################################
fossil test-th-eval "catch {bad}; info exists var; set th_stack_trace"
test th1-info-exists-6 {$RESULT eq {bad}}
###############################################################################
fossil test-th-eval "set var 1; unset var"
test th1-unset-1 {$RESULT eq {var}}
###############################################################################
fossil test-th-eval "unset var"
test th1-unset-2 {$RESULT eq {TH_ERROR: no such variable: var}}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
###############################################################################
fossil test-th-eval "catch {bad}; info exists var; set th_stack_trace"
test th1-info-exists-6 {$RESULT eq {bad}}
###############################################################################
fossil test-th-eval "set var(1) 1; info exists var"
test th1-info-exists-7 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "set var(1) 1; unset var(1); info exists var"
test th1-info-exists-8 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "set var(1) 1; unset var; info exists var"
test th1-info-exists-9 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "set var(1) 1; info exists var(1)"
test th1-info-exists-10 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "set var(1) 1; unset var(1); info exists var(1)"
test th1-info-exists-11 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "set var(1) 1; unset var; info exists var(1)"
test th1-info-exists-12 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "set var 1; unset var"
test th1-unset-1 {$RESULT eq {var}}
###############################################################################
fossil test-th-eval "unset var"
test th1-unset-2 {$RESULT eq {TH_ERROR: no such variable: var}}
###############################################################################
fossil test-th-eval "set var 1; unset var; unset var"
test th1-unset-3 {$RESULT eq {TH_ERROR: no such variable: var}}
###############################################################################
fossil test-th-eval "set gv 1; proc p {} {upvar 1 gv lv; unset lv}; p; unset gv"
test th1-unset-4 {$RESULT eq {TH_ERROR: no such variable: gv}}
###############################################################################
fossil test-th-eval "set gv 1; upvar 0 gv gv2; info exists gv2"
test th1-unset-5 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "set gv 1; upvar 0 gv gv2; unset gv; unset gv2"
test th1-unset-6 {$RESULT eq {TH_ERROR: no such variable: gv2}}
###############################################################################
fossil test-th-eval "set gv 1; upvar 0 gv gv2(1); unset gv; unset gv2(1)"
test th1-unset-7 {$RESULT eq {TH_ERROR: no such variable: gv2(1)}}
###############################################################################
fossil test-th-eval "set gv(1) 1; upvar 0 gv(1) gv2; unset gv(1); unset gv2"
test th1-unset-8 {$RESULT eq {TH_ERROR: no such variable: gv2}}
###############################################################################
fossil test-th-eval "string first {} {}"
test th1-string-first-1 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string first {} {a}"
test th1-string-first-2 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string first {a} {}"
test th1-string-first-3 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string first {a} {a}"
test th1-string-first-4 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "string first {a} {aa}"
test th1-string-first-5 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "string first {aa} {a}"
test th1-string-first-6 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string first {ab} {abc}"
test th1-string-first-7 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "string first {bc} {abc}"
test th1-string-first-8 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "string first {AB} {abc}"
test th1-string-first-9 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string last {} {}"
test th1-string-last-1 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string last {} {a}"
test th1-string-last-2 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string last {a} {}"
test th1-string-last-3 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string last {a} {a}"
test th1-string-last-4 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "string last {a} {aa}"
test th1-string-last-5 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "string last {aa} {a}"
test th1-string-last-6 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "string last {ab} {abc}"
test th1-string-last-7 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "string last {bc} {abc}"
test th1-string-last-8 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "string last {AB} {abc}"
test th1-string-last-9 {$RESULT eq {-1}}
|
Changes to test/valgrind-www.tcl.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 |
#
# Then examine the valgrind-out.txt file for issues.
#
proc run_query {url} {
set fd [open q.txt w]
puts $fd "GET $url HTTP/1.0\r\n\r"
close $fd
| < | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#
# Then examine the valgrind-out.txt file for issues.
#
proc run_query {url} {
set fd [open q.txt w]
puts $fd "GET $url HTTP/1.0\r\n\r"
close $fd
return [exec valgrind ./fossil test-http <q.txt 2>@ stderr]
}
set todo {}
foreach url {
/home
/timeline
/brlist
/taglist
|
| ︙ | ︙ |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
1711 1712 1713 1714 1715 1716 1717 |
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
| | | | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c $(SRCDIR)/../win/Makefile.mingw
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw
$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
|
| ︙ | ︙ |
Changes to win/Makefile.mingw.mistachkin.
| ︙ | ︙ | |||
1711 1712 1713 1714 1715 1716 1717 |
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
| | | | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c $(SRCDIR)/../win/Makefile.mingw.mistachkin
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $(OBJDIR)/sqlite3.o
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $(OBJDIR)/cson_amalgamation.o
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw.mistachkin
$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $(OBJDIR)/shell.o
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -c $(SRCDIR)/th.c -o $(OBJDIR)/th.o
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -c $(SRCDIR)/th_lang.c -o $(OBJDIR)/th_lang.o
|
| ︙ | ︙ |
Changes to win/Makefile.msc.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR) !ifdef FOSSIL_ENABLE_SSL INCL = $(INCL) -I$(SSLINCDIR) !endif | | | > > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR) !ifdef FOSSIL_ENABLE_SSL INCL = $(INCL) -I$(SSLINCDIR) !endif CFLAGS = -nologo LDFLAGS = /NODEFAULTLIB:msvcrt /MANIFEST:NO !ifdef DEBUG CFLAGS = $(CFLAGS) -Zi -MTd -Od LDFLAGS = $(LDFLAGS) /DEBUG !else CFLAGS = $(CFLAGS) -MT -O2 !endif BCC = $(CC) $(CFLAGS) TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL) RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL) LIBS = $(ZLIB) ws2_32.lib advapi32.lib LIBDIR = -LIBPATH:$(ZLIBDIR) |
| ︙ | ︙ | |||
446 447 448 449 450 451 452 | mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** mkversion$E: $B\src\mkversion.c $(BCC) $** | | | | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** mkversion$E: $B\src\mkversion.c $(BCC) $** $(OX)\shell$O : $(SRCDIR)\shell.c $B\win\Makefile.msc $(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c $(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c $B\win\Makefile.msc $(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SRCDIR)\sqlite3.c $(OX)\th$O : $(SRCDIR)\th.c $(TCC) /Fo$@ -c $** $(OX)\th_lang$O : $(SRCDIR)\th_lang.c $(TCC) /Fo$@ -c $** |
| ︙ | ︙ |