Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update the built-in SQLite to the latest 3.28.0 alpha version. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
41974e0881d69af99fc9b5dd9892039b |
User & Date: | drh 2019-04-03 18:33:38.146 |
Context
2019-04-06
| ||
19:03 | Sync and Clone HTTP requests omit the extra /xfer path element from the end. This should work fine with all versions of Fossil server published since 2010, but might require that the /xfer path element be added manually to the URL for server instances that predate check-in [94bb313444b0165e]. ... (check-in: 19c60b7f user: drh tags: trunk) | |
2019-04-03
| ||
18:33 | Update the built-in SQLite to the latest 3.28.0 alpha version. ... (check-in: 41974e08 user: drh tags: trunk) | |
2019-04-02
| ||
03:26 | The abbreviated certbot command didn't work here on my first Let's Encrypt renewal after writing the tls-nginx.md document, so changed that advice to use the full-strength form. ... (check-in: dadd1342 user: wyoung tags: trunk) | |
Changes
Changes to src/shell.c.
︙ | ︙ | |||
2179 2180 2181 2182 2183 2184 2185 | } pBuf = sqlite3_malloc64( nIn ? nIn : 1 ); if( pBuf==0 ){ sqlite3_result_error_nomem(ctx); fclose(in); return; } | | | 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 | } pBuf = sqlite3_malloc64( nIn ? nIn : 1 ); if( pBuf==0 ){ sqlite3_result_error_nomem(ctx); fclose(in); return; } if( nIn==(sqlite3_int64)fread(pBuf, 1, (size_t)nIn, in) ){ sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free); }else{ sqlite3_result_error_code(ctx, SQLITE_IOERR); sqlite3_free(pBuf); } fclose(in); } |
︙ | ︙ | |||
2314 2315 2316 2317 2318 2319 2320 | #endif } /* ** Argument zFile is the name of a file that will be created and/or written ** by SQL function writefile(). This function ensures that the directory ** zFile will be written to exists, creating it if required. The permissions | | > | < | | 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 2353 2354 2355 2356 2357 | #endif } /* ** Argument zFile is the name of a file that will be created and/or written ** by SQL function writefile(). This function ensures that the directory ** zFile will be written to exists, creating it if required. The permissions ** for any path components created by this function are set in accordance ** with the current umask. ** ** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise, ** SQLITE_OK is returned if the directory is successfully created, or ** SQLITE_ERROR otherwise. */ static int makeDirectory( const char *zFile ){ char *zCopy = sqlite3_mprintf("%s", zFile); int rc = SQLITE_OK; if( zCopy==0 ){ rc = SQLITE_NOMEM; }else{ int nCopy = (int)strlen(zCopy); int i = 1; while( rc==SQLITE_OK ){ struct stat sStat; int rc2; for(; zCopy[i]!='/' && i<nCopy; i++); if( i==nCopy ) break; zCopy[i] = '\0'; rc2 = fileStat(zCopy, &sStat); if( rc2!=0 ){ if( mkdir(zCopy, 0777) ) rc = SQLITE_ERROR; }else{ if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR; } zCopy[i] = '/'; i++; } |
︙ | ︙ | |||
2501 2502 2503 2504 2505 2506 2507 | } if( argc==4 ){ mtime = sqlite3_value_int64(argv[3]); } res = writeFile(context, zFile, argv[1], mode, mtime); if( res==1 && errno==ENOENT ){ | | | 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 | } if( argc==4 ){ mtime = sqlite3_value_int64(argv[3]); } res = writeFile(context, zFile, argv[1], mode, mtime); if( res==1 && errno==ENOENT ){ if( makeDirectory(zFile)==SQLITE_OK ){ res = writeFile(context, zFile, argv[1], mode, mtime); } } if( argc>2 && res!=0 ){ if( S_ISLNK(mode) ){ ctxErrorMsg(context, "failed to create symlink: %s", zFile); |
︙ | ︙ | |||
10426 10427 10428 10429 10430 10431 10432 | sqlite3SelectTrace = savedSelectTrace; #endif #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE) sqlite3WhereTrace = savedWhereTrace; #endif } | < < < > > > | > | | | | 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 | sqlite3SelectTrace = savedSelectTrace; #endif #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE) sqlite3WhereTrace = savedWhereTrace; #endif } /* Create the TEMP table used to store parameter bindings */ static void bind_table_init(ShellState *p){ int wrSchema = 0; sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); sqlite3_exec(p->db, "CREATE TABLE IF NOT EXISTS temp.sqlite_parameters(\n" " key TEXT PRIMARY KEY,\n" " value ANY\n" ") WITHOUT ROWID;", 0, 0, 0); sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); } /* ** Bind parameters on a prepared statement. ** ** Parameter bindings are taken from a TEMP table of the form: ** ** CREATE TEMP TABLE sqlite_parameters(key TEXT PRIMARY KEY, value) ** WITHOUT ROWID; ** ** No bindings occur if this table does not exist. The special character '$' ** is included in the table name to help prevent collisions with actual tables. ** The table must be in the TEMP schema. */ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){ int nVar; int i; int rc; sqlite3_stmt *pQ = 0; nVar = sqlite3_bind_parameter_count(pStmt); if( nVar==0 ) return; /* Nothing to do */ if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters", "key", 0, 0, 0, 0, 0)!=SQLITE_OK ){ return; /* Parameter table does not exist */ } rc = sqlite3_prepare_v2(pArg->db, "SELECT value FROM temp.sqlite_parameters" " WHERE key=?1", -1, &pQ, 0); if( rc || pQ==0 ) return; for(i=1; i<=nVar; i++){ char zNum[30]; const char *zVar = sqlite3_bind_parameter_name(pStmt, i); if( zVar==0 ){ sqlite3_snprintf(sizeof(zNum),zNum,"?%d",i); |
︙ | ︙ | |||
11131 11132 11133 11134 11135 11136 11137 | ** start of the description of what that command does. */ static const char *(azHelp[]) = { #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE) ".archive ... Manage SQL archives", " Each command must have exactly one of the following options:", " -c, --create Create a new archive", | | > | 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 | ** start of the description of what that command does. */ static const char *(azHelp[]) = { #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE) ".archive ... Manage SQL archives", " Each command must have exactly one of the following options:", " -c, --create Create a new archive", " -u, --update Add files or update files with changed mtime", " -i, --insert Like -u but always add even if mtime unchanged", " -t, --list List contents of archive", " -x, --extract Extract files from archive", " Optional arguments:", " -v, --verbose Print each filename as it is processed", " -f FILE, --file FILE Operate on archive FILE (default is current db)", " -a FILE, --append FILE Operate on FILE opened using the apndvfs VFS", " -C DIR, --directory DIR Change to directory DIR to read/extract files", |
︙ | ︙ | |||
12452 12453 12454 12455 12456 12457 12458 | { "number of triggers:", "SELECT count(*) FROM %s WHERE type='trigger'" }, { "number of views:", "SELECT count(*) FROM %s WHERE type='view'" }, { "schema size:", "SELECT total(length(sql)) FROM %s" }, }; | | > | | > > > > > > > > > > | 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 | { "number of triggers:", "SELECT count(*) FROM %s WHERE type='trigger'" }, { "number of views:", "SELECT count(*) FROM %s WHERE type='view'" }, { "schema size:", "SELECT total(length(sql)) FROM %s" }, }; int i, rc; unsigned iDataVersion; char *zSchemaTab; char *zDb = nArg>=2 ? azArg[1] : "main"; sqlite3_stmt *pStmt = 0; unsigned char aHdr[100]; open_db(p, 0); if( p->db==0 ) return 1; rc = sqlite3_prepare_v2(p->db, "SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1", -1, &pStmt, 0); if( rc ){ if( !sqlite3_compileoption_used("ENABLE_DBPAGE_VTAB") ){ utf8_printf(stderr, "the \".dbinfo\" command requires the " "-DSQLITE_ENABLE_DBPAGE_VTAB compile-time options\n"); }else{ utf8_printf(stderr, "error: %s\n", sqlite3_errmsg(p->db)); } sqlite3_finalize(pStmt); return 1; } sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC); if( sqlite3_step(pStmt)==SQLITE_ROW && sqlite3_column_bytes(pStmt,0)>100 ){ memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100); sqlite3_finalize(pStmt); }else{ |
︙ | ︙ | |||
13055 13056 13057 13058 13059 13060 13061 | return SQLITE_ERROR; } /* ** Values for ArCommand.eCmd. */ #define AR_CMD_CREATE 1 | | | | > | | | | | | > | 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 | return SQLITE_ERROR; } /* ** Values for ArCommand.eCmd. */ #define AR_CMD_CREATE 1 #define AR_CMD_UPDATE 2 #define AR_CMD_INSERT 3 #define AR_CMD_EXTRACT 4 #define AR_CMD_LIST 5 #define AR_CMD_HELP 6 /* ** Other (non-command) switches. */ #define AR_SWITCH_VERBOSE 7 #define AR_SWITCH_FILE 8 #define AR_SWITCH_DIRECTORY 9 #define AR_SWITCH_APPEND 10 #define AR_SWITCH_DRYRUN 11 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){ switch( eSwitch ){ case AR_CMD_CREATE: case AR_CMD_EXTRACT: case AR_CMD_LIST: case AR_CMD_UPDATE: case AR_CMD_INSERT: case AR_CMD_HELP: if( pAr->eCmd ){ return arErrorMsg(pAr, "multiple command options"); } pAr->eCmd = eSwitch; break; |
︙ | ︙ | |||
13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 | const char *zLong; char cShort; u8 eSwitch; u8 bArg; } aSwitch[] = { { "create", 'c', AR_CMD_CREATE, 0 }, { "extract", 'x', AR_CMD_EXTRACT, 0 }, { "list", 't', AR_CMD_LIST, 0 }, { "update", 'u', AR_CMD_UPDATE, 0 }, { "help", 'h', AR_CMD_HELP, 0 }, { "verbose", 'v', AR_SWITCH_VERBOSE, 0 }, { "file", 'f', AR_SWITCH_FILE, 1 }, { "append", 'a', AR_SWITCH_APPEND, 1 }, { "directory", 'C', AR_SWITCH_DIRECTORY, 1 }, | > | 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 | const char *zLong; char cShort; u8 eSwitch; u8 bArg; } aSwitch[] = { { "create", 'c', AR_CMD_CREATE, 0 }, { "extract", 'x', AR_CMD_EXTRACT, 0 }, { "insert", 'i', AR_CMD_INSERT, 0 }, { "list", 't', AR_CMD_LIST, 0 }, { "update", 'u', AR_CMD_UPDATE, 0 }, { "help", 'h', AR_CMD_HELP, 0 }, { "verbose", 'v', AR_SWITCH_VERBOSE, 0 }, { "file", 'f', AR_SWITCH_FILE, 1 }, { "append", 'a', AR_SWITCH_APPEND, 1 }, { "directory", 'C', AR_SWITCH_DIRECTORY, 1 }, |
︙ | ︙ | |||
13456 13457 13458 13459 13460 13461 13462 | } } return rc; } /* | | > > > > > | > > | > | 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 | } } return rc; } /* ** Implementation of .ar "create", "insert", and "update" commands. ** ** create -> Create a new SQL archive ** insert -> Insert or reinsert all files listed ** update -> Insert files that have changed or that were not ** previously in the archive ** ** Create the "sqlar" table in the database if it does not already exist. ** Then add each file in the azFile[] array to the archive. Directories ** are added recursively. If argument bVerbose is non-zero, a message is ** printed on stdout for each file archived. ** ** The create command is the same as update, except that it drops ** any existing "sqlar" table before beginning. The "insert" command ** always overwrites every file named on the command-line, where as ** "update" only overwrites if the size or mtime or mode has changed. */ static int arCreateOrUpdateCommand( ArCommand *pAr, /* Command arguments and options */ int bUpdate, /* true for a --create. */ int bOnlyIfChanged /* Only update if file has changed */ ){ const char *zCreate = "CREATE TABLE IF NOT EXISTS sqlar(\n" " name TEXT PRIMARY KEY, -- name of the file\n" " mode INT, -- access permissions\n" " mtime INT, -- last modification time\n" " sz INT, -- original file size\n" |
︙ | ︙ | |||
13490 13491 13492 13493 13494 13495 13496 | " mode,\n" " mtime,\n" " CASE substr(lsmode(mode),1,1)\n" " WHEN '-' THEN length(data)\n" " WHEN 'd' THEN 0\n" " ELSE -1 END,\n" " sqlar_compress(data)\n" | | | > | | > | 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 | " mode,\n" " mtime,\n" " CASE substr(lsmode(mode),1,1)\n" " WHEN '-' THEN length(data)\n" " WHEN 'd' THEN 0\n" " ELSE -1 END,\n" " sqlar_compress(data)\n" " FROM fsdir(%Q,%Q) AS disk\n" " WHERE lsmode(mode) NOT LIKE '?%%'%s;" , "REPLACE INTO %s(name,mode,mtime,data)\n" " SELECT\n" " %s,\n" " mode,\n" " mtime,\n" " data\n" " FROM fsdir(%Q,%Q) AS disk\n" " WHERE lsmode(mode) NOT LIKE '?%%'%s;" }; int i; /* For iterating through azFile[] */ int rc; /* Return code */ const char *zTab = 0; /* SQL table into which to insert */ char *zSql; char zTemp[50]; char *zExists = 0; arExecSql(pAr, "PRAGMA page_size=512"); rc = arExecSql(pAr, "SAVEPOINT ar;"); if( rc!=SQLITE_OK ) return rc; zTemp[0] = 0; if( pAr->bZip ){ /* Initialize the zipfile virtual table, if necessary */ |
︙ | ︙ | |||
13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 | zTab = "sqlar"; if( bUpdate==0 ){ rc = arExecSql(pAr, zDrop); if( rc!=SQLITE_OK ) goto end_ar_transaction; } rc = arExecSql(pAr, zCreate); } for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){ char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab, pAr->bVerbose ? "shell_putsnl(name)" : "name", | > > > > > > > > > > > | > | 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 | zTab = "sqlar"; if( bUpdate==0 ){ rc = arExecSql(pAr, zDrop); if( rc!=SQLITE_OK ) goto end_ar_transaction; } rc = arExecSql(pAr, zCreate); } if( bOnlyIfChanged ){ zExists = sqlite3_mprintf( " AND NOT EXISTS(" "SELECT 1 FROM %s AS mem" " WHERE mem.name=disk.name" " AND mem.mtime=disk.mtime" " AND mem.mode=disk.mode)", zTab); }else{ zExists = sqlite3_mprintf(""); } if( zExists==0 ) rc = SQLITE_NOMEM; for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){ char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab, pAr->bVerbose ? "shell_putsnl(name)" : "name", pAr->azArg[i], pAr->zDir, zExists); rc = arExecSql(pAr, zSql2); sqlite3_free(zSql2); } end_ar_transaction: if( rc!=SQLITE_OK ){ sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0); }else{ rc = arExecSql(pAr, "RELEASE ar;"); if( pAr->bZip && pAr->zFile ){ zSql = sqlite3_mprintf("DROP TABLE %s", zTemp); arExecSql(pAr, zSql); sqlite3_free(zSql); } } sqlite3_free(zExists); return rc; } /* ** Implementation of ".ar" dot command. */ static int arDotCommand( |
︙ | ︙ | |||
13592 13593 13594 13595 13596 13597 13598 | cmd.zSrcTable = sqlite3_mprintf("zipfile(%Q)", cmd.zFile); } } cmd.bZip = 1; }else if( cmd.zFile ){ int flags; if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS; | | > | 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 | cmd.zSrcTable = sqlite3_mprintf("zipfile(%Q)", cmd.zFile); } } cmd.bZip = 1; }else if( cmd.zFile ){ int flags; if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS; if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_INSERT || cmd.eCmd==AR_CMD_UPDATE ){ flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE; }else{ flags = SQLITE_OPEN_READONLY; } cmd.db = 0; if( cmd.bDryRun ){ utf8_printf(pState->out, "-- open database '%s'%s\n", cmd.zFile, |
︙ | ︙ | |||
13629 13630 13631 13632 13633 13634 13635 | goto end_ar_command; } cmd.zSrcTable = sqlite3_mprintf("sqlar"); } switch( cmd.eCmd ){ case AR_CMD_CREATE: | | > > > > | | 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 | goto end_ar_command; } cmd.zSrcTable = sqlite3_mprintf("sqlar"); } switch( cmd.eCmd ){ case AR_CMD_CREATE: rc = arCreateOrUpdateCommand(&cmd, 0, 0); break; case AR_CMD_EXTRACT: rc = arExtractCommand(&cmd); break; case AR_CMD_LIST: rc = arListCommand(&cmd); break; case AR_CMD_HELP: arUsage(pState->out); break; case AR_CMD_INSERT: rc = arCreateOrUpdateCommand(&cmd, 1, 0); break; default: assert( cmd.eCmd==AR_CMD_UPDATE ); rc = arCreateOrUpdateCommand(&cmd, 1, 1); break; } } end_ar_command: if( cmd.db!=pState->db ){ close_db(cmd.db); } |
︙ | ︙ | |||
14779 14780 14781 14782 14783 14784 14785 | open_db(p,0); if( nArg<=1 ) goto parameter_syntax_error; /* .parameter clear ** Clear all bind parameters by dropping the TEMP table that holds them. */ if( nArg==2 && strcmp(azArg[1],"clear")==0 ){ | > > > | > | | | 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 | open_db(p,0); if( nArg<=1 ) goto parameter_syntax_error; /* .parameter clear ** Clear all bind parameters by dropping the TEMP table that holds them. */ if( nArg==2 && strcmp(azArg[1],"clear")==0 ){ int wrSchema = 0; sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema); sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0); sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;", 0, 0, 0); sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0); }else /* .parameter list ** List all bind parameters. */ if( nArg==2 && strcmp(azArg[1],"list")==0 ){ sqlite3_stmt *pStmt = 0; int rx; int len = 0; rx = sqlite3_prepare_v2(p->db, "SELECT max(length(key)) " "FROM temp.sqlite_parameters;", -1, &pStmt, 0); if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ len = sqlite3_column_int(pStmt, 0); if( len>40 ) len = 40; } sqlite3_finalize(pStmt); pStmt = 0; if( len ){ rx = sqlite3_prepare_v2(p->db, "SELECT key, quote(value) " "FROM temp.sqlite_parameters;", -1, &pStmt, 0); while( sqlite3_step(pStmt)==SQLITE_ROW ){ utf8_printf(p->out, "%-*s %s\n", len, sqlite3_column_text(pStmt,0), sqlite3_column_text(pStmt,1)); } sqlite3_finalize(pStmt); } }else |
︙ | ︙ | |||
14833 14834 14835 14836 14837 14838 14839 | int rx; char *zSql; sqlite3_stmt *pStmt; const char *zKey = azArg[2]; const char *zValue = azArg[3]; bind_table_init(p); zSql = sqlite3_mprintf( | | | | 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 | int rx; char *zSql; sqlite3_stmt *pStmt; const char *zKey = azArg[2]; const char *zValue = azArg[3]; bind_table_init(p); zSql = sqlite3_mprintf( "REPLACE INTO temp.sqlite_parameters(key,value)" "VALUES(%Q,%s);", zKey, zValue); if( zSql==0 ) shell_out_of_memory(); pStmt = 0; rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rx!=SQLITE_OK ){ sqlite3_finalize(pStmt); pStmt = 0; zSql = sqlite3_mprintf( "REPLACE INTO temp.sqlite_parameters(key,value)" "VALUES(%Q,%Q);", zKey, zValue); if( zSql==0 ) shell_out_of_memory(); rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rx!=SQLITE_OK ){ utf8_printf(p->out, "Error: %s\n", sqlite3_errmsg(p->db)); sqlite3_finalize(pStmt); |
︙ | ︙ | |||
14865 14866 14867 14868 14869 14870 14871 | /* .parameter unset NAME ** Remove the NAME binding from the parameter binding table, if it ** exists. */ if( nArg==3 && strcmp(azArg[1],"unset")==0 ){ char *zSql = sqlite3_mprintf( | | | 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 | /* .parameter unset NAME ** Remove the NAME binding from the parameter binding table, if it ** exists. */ if( nArg==3 && strcmp(azArg[1],"unset")==0 ){ char *zSql = sqlite3_mprintf( "DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]); if( zSql==0 ) shell_out_of_memory(); sqlite3_exec(p->db, zSql, 0, 0, 0); sqlite3_free(zSql); }else /* If no command name matches, show a syntax error */ parameter_syntax_error: showHelp(p->out, "parameter"); |
︙ | ︙ |
Changes to src/sqlite3.c.
︙ | ︙ | |||
1160 1161 1162 1163 1164 1165 1166 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.28.0" #define SQLITE_VERSION_NUMBER 3028000 | | | 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.28.0" #define SQLITE_VERSION_NUMBER 3028000 #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f" /* ** 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 |
︙ | ︙ | |||
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 | ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled with mutexing code omitted due to the | > > > | 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #else # define sqlite3_compileoption_used(X) 0 # define sqlite3_compileoption_get(X) ((void*)0) #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled with mutexing code omitted due to the |
︙ | ︙ | |||
3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 | ** features include but are not limited to the following: ** <ul> ** <li> The [PRAGMA writable_schema=ON] statement. ** <li> Writes to the [sqlite_dbpage] virtual table. ** <li> Direct writes to [shadow tables]. ** </ul> ** </dd> ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */ #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */ #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */ | > > > > > > > > > > > > | | 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 | ** features include but are not limited to the following: ** <ul> ** <li> The [PRAGMA writable_schema=ON] statement. ** <li> Writes to the [sqlite_dbpage] virtual table. ** <li> Direct writes to [shadow tables]. ** </ul> ** </dd> ** ** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt> ** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the ** "writable_schema" flag. This has the same effect and is logically equivalent ** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF]. ** The first argument to this setting is an integer which is 0 to disable ** the writable_schema, positive to enable writable_schema, or negative to ** leave the setting unchanged. The second parameter is a pointer to an ** integer into which is written 0 or 1 to indicate whether the writable_schema ** is enabled or disabled following this call. ** </dd> ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */ #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */ #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */ #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */ #define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** METHOD: sqlite3 ** ** ^The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. ^The extended result |
︙ | ︙ | |||
5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 | ** <tr><td><b>sqlite3_value_type</b><td>→<td>Default ** datatype of the value ** <tr><td><b>sqlite3_value_numeric_type </b> ** <td>→ <td>Best numeric datatype of the value ** <tr><td><b>sqlite3_value_nochange </b> ** <td>→ <td>True if the column is unchanged in an UPDATE ** against a virtual table. ** </table></blockquote> ** ** <b>Details:</b> ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects ** are used to pass parameter information into implementation of | > > | 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 | ** <tr><td><b>sqlite3_value_type</b><td>→<td>Default ** datatype of the value ** <tr><td><b>sqlite3_value_numeric_type </b> ** <td>→ <td>Best numeric datatype of the value ** <tr><td><b>sqlite3_value_nochange </b> ** <td>→ <td>True if the column is unchanged in an UPDATE ** against a virtual table. ** <tr><td><b>sqlite3_value_frombind </b> ** <td>→ <td>True if value originated a bound parameter ** </table></blockquote> ** ** <b>Details:</b> ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects ** are used to pass parameter information into implementation of |
︙ | ︙ | |||
6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 | ** the value for that column returned without setting a result (probably ** because it queried [sqlite3_vtab_nochange()] and found that the column ** was unchanging). ^Within an [xUpdate] method, any value for which ** sqlite3_value_nochange(X) is true will in all other respects appear ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other ** than within an [xUpdate] method call for an UPDATE statement, then ** the return value is arbitrary and meaningless. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** | > > > > > | 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 | ** the value for that column returned without setting a result (probably ** because it queried [sqlite3_vtab_nochange()] and found that the column ** was unchanging). ^Within an [xUpdate] method, any value for which ** sqlite3_value_nochange(X) is true will in all other respects appear ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other ** than within an [xUpdate] method call for an UPDATE statement, then ** the return value is arbitrary and meaningless. ** ** ^The sqlite3_value_frombind(X) interface returns non-zero if the ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] ** interfaces. ^If X comes from an SQL literal value, or a table column, ** and expression, then sqlite3_value_frombind(X) returns zero. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** |
︙ | ︙ | |||
6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); SQLITE_API int sqlite3_value_nochange(sqlite3_value*); /* ** CAPI3REF: Finding The Subtype Of SQL Values ** METHOD: sqlite3_value ** ** The sqlite3_value_subtype(V) function returns the subtype for ** an [application-defined SQL function] argument V. The subtype | > | 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); SQLITE_API int sqlite3_value_nochange(sqlite3_value*); SQLITE_API int sqlite3_value_frombind(sqlite3_value*); /* ** CAPI3REF: Finding The Subtype Of SQL Values ** METHOD: sqlite3_value ** ** The sqlite3_value_subtype(V) function returns the subtype for ** an [application-defined SQL function] argument V. The subtype |
︙ | ︙ | |||
11941 11942 11943 11944 11945 11946 11947 | ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) | | | 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 | ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changeset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the ** responsibility of the caller to eventually free the new buffer using ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) ** are set to zero and an SQLite error code returned. */ SQLITE_API int sqlite3rebaser_rebase( sqlite3_rebaser*, |
︙ | ︙ | |||
13532 13533 13534 13535 13536 13537 13538 | #define TK_WITH 81 #define TK_CURRENT 82 #define TK_FOLLOWING 83 #define TK_PARTITION 84 #define TK_PRECEDING 85 #define TK_RANGE 86 #define TK_UNBOUNDED 87 | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 | #define TK_WITH 81 #define TK_CURRENT 82 #define TK_FOLLOWING 83 #define TK_PARTITION 84 #define TK_PRECEDING 85 #define TK_RANGE 86 #define TK_UNBOUNDED 87 #define TK_EXCLUDE 88 #define TK_GROUPS 89 #define TK_OTHERS 90 #define TK_TIES 91 #define TK_REINDEX 92 #define TK_RENAME 93 #define TK_CTIME_KW 94 #define TK_ANY 95 #define TK_BITAND 96 #define TK_BITOR 97 #define TK_LSHIFT 98 #define TK_RSHIFT 99 #define TK_PLUS 100 #define TK_MINUS 101 #define TK_STAR 102 #define TK_SLASH 103 #define TK_REM 104 #define TK_CONCAT 105 #define TK_COLLATE 106 #define TK_BITNOT 107 #define TK_ON 108 #define TK_INDEXED 109 #define TK_STRING 110 #define TK_JOIN_KW 111 #define TK_CONSTRAINT 112 #define TK_DEFAULT 113 #define TK_NULL 114 #define TK_PRIMARY 115 #define TK_UNIQUE 116 #define TK_CHECK 117 #define TK_REFERENCES 118 #define TK_AUTOINCR 119 #define TK_INSERT 120 #define TK_DELETE 121 #define TK_UPDATE 122 #define TK_SET 123 #define TK_DEFERRABLE 124 #define TK_FOREIGN 125 #define TK_DROP 126 #define TK_UNION 127 #define TK_ALL 128 #define TK_EXCEPT 129 #define TK_INTERSECT 130 #define TK_SELECT 131 #define TK_VALUES 132 #define TK_DISTINCT 133 #define TK_DOT 134 #define TK_FROM 135 #define TK_JOIN 136 #define TK_USING 137 #define TK_ORDER 138 #define TK_GROUP 139 #define TK_HAVING 140 #define TK_LIMIT 141 #define TK_WHERE 142 #define TK_INTO 143 #define TK_NOTHING 144 #define TK_FLOAT 145 #define TK_BLOB 146 #define TK_INTEGER 147 #define TK_VARIABLE 148 #define TK_CASE 149 #define TK_WHEN 150 #define TK_THEN 151 #define TK_ELSE 152 #define TK_INDEX 153 #define TK_ALTER 154 #define TK_ADD 155 #define TK_WINDOW 156 #define TK_OVER 157 #define TK_FILTER 158 #define TK_TRUEFALSE 159 #define TK_ISNOT 160 #define TK_FUNCTION 161 #define TK_COLUMN 162 #define TK_AGG_FUNCTION 163 #define TK_AGG_COLUMN 164 #define TK_UMINUS 165 #define TK_UPLUS 166 #define TK_TRUTH 167 #define TK_REGISTER 168 #define TK_VECTOR 169 #define TK_SELECT_COLUMN 170 #define TK_IF_NULL_ROW 171 #define TK_ASTERISK 172 #define TK_SPAN 173 #define TK_END_OF_FILE 174 #define TK_UNCLOSED_STRING 175 #define TK_SPACE 176 #define TK_ILLEGAL 177 /* The token codes above must all fit in 8 bits */ #define TKFLG_MASK 0xff /* Flags that can be added to a token code when it is not ** being stored in a u8: */ #define TKFLG_DONTFOLD 0x100 /* Omit constant folding optimizations */ |
︙ | ︙ | |||
14556 14557 14558 14559 14560 14561 14562 | int nData; /* Size of pData. 0 if none. */ int nZero; /* Extra zero data appended after pData,nData */ }; SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, int flags, int seekResult); SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); | < < < | 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 | int nData; /* Size of pData. 0 if none. */ int nZero; /* Extra zero data appended after pData,nData */ }; SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, int flags, int seekResult); SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags); SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags); SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*); |
︙ | ︙ | |||
14916 14917 14918 14919 14920 14921 14922 | #define OP_Cast 85 /* synopsis: affinity(r[P1]) */ #define OP_Permutation 86 #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ #define OP_Column 90 /* synopsis: r[P3]=PX */ #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ | > > > > | | | | | | | | | | | | < < < < | | | | 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 | #define OP_Cast 85 /* synopsis: affinity(r[P1]) */ #define OP_Permutation 86 #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ #define OP_Column 90 /* synopsis: r[P3]=PX */ #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ #define OP_Count 93 /* synopsis: r[P2]=count() */ #define OP_ReadCookie 94 #define OP_SetCookie 95 #define OP_BitAnd 96 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ #define OP_BitOr 97 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ #define OP_ShiftLeft 98 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ #define OP_ShiftRight 99 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ #define OP_Add 100 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ #define OP_Subtract 101 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ #define OP_Multiply 102 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ #define OP_Divide 103 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ #define OP_Remainder 104 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ #define OP_Concat 105 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ #define OP_ReopenIdx 106 /* synopsis: root=P2 iDb=P3 */ #define OP_BitNot 107 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ #define OP_OpenRead 108 /* synopsis: root=P2 iDb=P3 */ #define OP_OpenWrite 109 /* synopsis: root=P2 iDb=P3 */ #define OP_String8 110 /* same as TK_STRING, synopsis: r[P2]='P4' */ #define OP_OpenDup 111 #define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */ #define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */ #define OP_SorterOpen 114 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ #define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */ #define OP_Close 117 |
︙ | ︙ | |||
14965 14966 14967 14968 14969 14970 14971 | #define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */ #define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */ #define OP_Destroy 136 #define OP_Clear 137 #define OP_ResetSorter 138 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ #define OP_SqlExec 140 | < | | | | > | 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 | #define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */ #define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */ #define OP_Destroy 136 #define OP_Clear 137 #define OP_ResetSorter 138 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ #define OP_SqlExec 140 #define OP_ParseSchema 141 #define OP_LoadAnalysis 142 #define OP_DropTable 143 #define OP_DropIndex 144 #define OP_Real 145 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ #define OP_DropTrigger 146 #define OP_IntegrityCk 147 #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */ #define OP_Param 149 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */ #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */ #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
︙ | ︙ | |||
15020 15021 15022 15023 15024 15025 15026 | /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ /* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\ /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\ /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\ /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\ /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ | | | | | | | 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 | /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ /* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\ /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\ /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\ /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\ /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ /* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ /* 104 */ 0x26, 0x26, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00,\ /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\ /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ /* 144 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,} /* The sqlite3P2Values() routine is able to run faster if it knows ** the value of the largest JUMP opcode. The smaller the maximum ** JUMP opcode the better, so the mkopcodeh.tcl script that |
︙ | ︙ | |||
16477 16478 16479 16480 16481 16482 16483 | /* ** Bits of the sqlite3.dbOptFlags field that are used by the ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to ** selectively disable various optimizations. */ #define SQLITE_QueryFlattener 0x0001 /* Query flattening */ | | | 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 | /* ** Bits of the sqlite3.dbOptFlags field that are used by the ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to ** selectively disable various optimizations. */ #define SQLITE_QueryFlattener 0x0001 /* Query flattening */ #define SQLITE_WindowFunc 0x0002 /* Use xInverse for window functions */ #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */ #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */ #define SQLITE_DistinctOpt 0x0010 /* DISTINCT using indexes */ #define SQLITE_CoverIdxScan 0x0020 /* Covering index scans */ #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */ #define SQLITE_Transitive 0x0080 /* Transitive constraints */ #define SQLITE_OmitNoopJoin 0x0100 /* Omit unused tables in joins */ |
︙ | ︙ | |||
16595 16596 16597 16598 16599 16600 16601 | #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a ** single query - might change over time */ #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */ #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */ #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ | < | 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 | #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a ** single query - might change over time */ #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */ #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */ #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ /* ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are ** used to create the initializers for the FuncDef structures. ** ** FUNCTION(zName, nArg, iArg, bNC, xFunc) |
︙ | ︙ | |||
17401 17402 17403 17404 17405 17406 17407 17408 17409 | int regReturn; /* Register used to hold return address */ } sub; } y; }; /* ** The following are the meanings of bits in the Expr.flags field. */ #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */ | > > > > | | | > | 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 | int regReturn; /* Register used to hold return address */ } sub; } y; }; /* ** The following are the meanings of bits in the Expr.flags field. ** Value restrictions: ** ** EP_Agg == NC_HasAgg == SF_HasAgg ** EP_Win == NC_HasWin */ #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */ #define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */ #define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */ #define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */ #define EP_Agg 0x000010 /* Contains one or more aggregate functions */ #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */ #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */ #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */ #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */ #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */ #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ #define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */ #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ #define EP_Win 0x008000 /* Contains window functions */ #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */ #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ #define EP_Alias 0x400000 /* Is an alias for a result set column */ #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */ #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */ #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */ #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */ /* ** The EP_Propagate mask is a set of properties that automatically propagate ** upwards into parent nodes. */ #define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc) |
︙ | ︙ | |||
17668 17669 17670 17671 17672 17673 17674 | Select *pWinSelect; /* SELECT statement for any window functions */ }; /* ** Allowed values for the NameContext, ncFlags field. ** ** Value constraints (all checked via assert()): | | > > | 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 | Select *pWinSelect; /* SELECT statement for any window functions */ }; /* ** Allowed values for the NameContext, ncFlags field. ** ** Value constraints (all checked via assert()): ** NC_HasAgg == SF_HasAgg == EP_Agg ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX ** NC_HasWin == EP_Win ** */ #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */ #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ #define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ #define NC_UEList 0x0080 /* True if uNC.pEList is used */ #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */ #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */ #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ #define NC_Complex 0x2000 /* True if a function or subquery seen */ #define NC_AllowWin 0x4000 /* Window functions are allowed here */ #define NC_HasWin 0x8000 /* One or more window functions seen */ /* ** An instance of the following object describes a single ON CONFLICT ** clause in an upsert. ** ** The pUpsertTarget field is only set if the ON CONFLICT clause includes ** conflict-target clause. (In "ON CONFLICT(a,b)" the "(a,b)" is the |
︙ | ︙ | |||
18440 18441 18442 18443 18444 18445 18446 | struct TreeView { int iLevel; /* Which level of the tree we are on */ u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */ }; #endif /* SQLITE_DEBUG */ /* | | | > | > > | < > > > | > > | 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 | struct TreeView { int iLevel; /* Which level of the tree we are on */ u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */ }; #endif /* SQLITE_DEBUG */ /* ** This object is used in various ways, all related to window functions ** ** (1) A single instance of this structure is attached to the ** the Expr.pWin field for each window function in an expression tree. ** This object holds the information contained in the OVER clause, ** plus additional fields used during code generation. ** ** (2) All window functions in a single SELECT form a linked-list ** attached to Select.pWin. The Window.pFunc and Window.pExpr ** fields point back to the expression that is the window function. ** ** (3) The terms of the WINDOW clause of a SELECT are instances of this ** object on a linked list attached to Select.pWinDefn. ** ** The uses (1) and (2) are really the same Window object that just happens ** to be accessible in two different ways. Use case (3) are separate objects. */ struct Window { char *zName; /* Name of window (may be NULL) */ char *zBase; /* Name of base window for chaining (may be NULL) */ ExprList *pPartition; /* PARTITION BY clause */ ExprList *pOrderBy; /* ORDER BY clause */ u8 eFrmType; /* TK_RANGE, TK_GROUPS, TK_ROWS, or 0 */ u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */ u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */ u8 bImplicitFrame; /* True if frame was implicitly specified */ u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */ Expr *pStart; /* Expression for "<expr> PRECEDING" */ Expr *pEnd; /* Expression for "<expr> FOLLOWING" */ Window *pNextWin; /* Next window function belonging to this SELECT */ Expr *pFilter; /* The FILTER expression */ FuncDef *pFunc; /* The function */ int iEphCsr; /* Partition buffer or Peer buffer */ int regAccum; int regResult; int csrApp; /* Function cursor (used by min/max) */ int regApp; /* Function register (also used by min/max) */ int regPart; /* Array of registers for PARTITION BY values */ Expr *pOwner; /* Expression object this window is attached to */ int nBufferCol; /* Number of columns in buffer table */ int iArgCol; /* Offset of first argument for this function */ int regOne; /* Register containing constant value 1 */ int regStartRowid; int regEndRowid; }; #ifndef SQLITE_OMIT_WINDOWFUNC SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*); SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p); SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8); SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*); SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*); SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*); SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*); SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*); SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p); SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p); SQLITE_PRIVATE void sqlite3WindowFunctions(void); SQLITE_PRIVATE void sqlite3WindowChain(Parse*, Window*, Window*); SQLITE_PRIVATE Window *sqlite3WindowAssemble(Parse*, Window*, ExprList*, ExprList*, Token*); #else # define sqlite3WindowDelete(a,b) # define sqlite3WindowFunctions() # define sqlite3WindowAttach(a,b,c) #endif /* |
︙ | ︙ | |||
20147 20148 20149 20150 20151 20152 20153 | */ #define MEM_Null 0x0001 /* Value is NULL (or a pointer) */ #define MEM_Str 0x0002 /* Value is a string */ #define MEM_Int 0x0004 /* Value is an integer */ #define MEM_Real 0x0008 /* Value is a real number */ #define MEM_Blob 0x0010 /* Value is a BLOB */ #define MEM_AffMask 0x001f /* Mask of affinity bits */ | | | | 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 | */ #define MEM_Null 0x0001 /* Value is NULL (or a pointer) */ #define MEM_Str 0x0002 /* Value is a string */ #define MEM_Int 0x0004 /* Value is an integer */ #define MEM_Real 0x0008 /* Value is a real number */ #define MEM_Blob 0x0010 /* Value is a BLOB */ #define MEM_AffMask 0x001f /* Mask of affinity bits */ #define MEM_FromBind 0x0020 /* Value originates from sqlite3_bind() */ /* Available 0x0040 */ #define MEM_Undefined 0x0080 /* Value is undefined */ #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */ #define MEM_TypeMask 0xc1df /* Mask of type bits */ /* Whenever Mem contains a valid string or blob representation, one of ** the following flags must be set to determine the memory management ** policy for Mem.z. The MEM_Term flag tells us whether or not the ** string is \000 or \u0000 terminated */ |
︙ | ︙ | |||
28784 28785 28786 28787 28788 28789 28790 28791 28792 | #endif /* SQLITE_OMIT_WINDOWFUNC */ #ifndef SQLITE_OMIT_WINDOWFUNC /* ** Generate a human-readable explanation for a Window object */ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){ pView = sqlite3TreeViewPush(pView, more); if( pWin->zName ){ | > > > > > > | | > > > > > > > > > | | | > > > > > > | > > > > > > > > > > > > > > > > > | 28821 28822 28823 28824 28825 28826 28827 28828 28829 28830 28831 28832 28833 28834 28835 28836 28837 28838 28839 28840 28841 28842 28843 28844 28845 28846 28847 28848 28849 28850 28851 28852 28853 28854 28855 28856 28857 28858 28859 28860 28861 28862 28863 28864 28865 28866 28867 28868 28869 28870 28871 28872 28873 28874 28875 28876 28877 28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 28890 | #endif /* SQLITE_OMIT_WINDOWFUNC */ #ifndef SQLITE_OMIT_WINDOWFUNC /* ** Generate a human-readable explanation for a Window object */ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){ int nElement = 0; if( pWin->pFilter ){ sqlite3TreeViewItem(pView, "FILTER", 1); sqlite3TreeViewExpr(pView, pWin->pFilter, 0); sqlite3TreeViewPop(pView); } pView = sqlite3TreeViewPush(pView, more); if( pWin->zName ){ sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin); }else{ sqlite3TreeViewLine(pView, "OVER (%p)", pWin); } if( pWin->zBase ) nElement++; if( pWin->pOrderBy ) nElement++; if( pWin->eFrmType ) nElement++; if( pWin->eExclude ) nElement++; if( pWin->zBase ){ sqlite3TreeViewPush(pView, (--nElement)>0); sqlite3TreeViewLine(pView, "window: %s", pWin->zBase); sqlite3TreeViewPop(pView); } if( pWin->pPartition ){ sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY"); } if( pWin->pOrderBy ){ sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); } if( pWin->eFrmType ){ char zBuf[30]; const char *zFrmType = "ROWS"; if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS"; sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType, pWin->bImplicitFrame ? " (implied)" : ""); sqlite3TreeViewItem(pView, zBuf, (--nElement)>0); sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1); sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0); sqlite3TreeViewPop(pView); } if( pWin->eExclude ){ char zBuf[30]; const char *zExclude; switch( pWin->eExclude ){ case TK_NO: zExclude = "NO OTHERS"; break; case TK_CURRENT: zExclude = "CURRENT ROW"; break; case TK_GROUP: zExclude = "GROUP"; break; case TK_TIES: zExclude = "TIES"; break; default: sqlite3_snprintf(sizeof(zBuf),zBuf,"invalid(%d)", pWin->eExclude); zExclude = zBuf; break; } sqlite3TreeViewPush(pView, 0); sqlite3TreeViewLine(pView, "EXCLUDE %s", zExclude); sqlite3TreeViewPop(pView); } sqlite3TreeViewPop(pView); } #endif /* SQLITE_OMIT_WINDOWFUNC */ #ifndef SQLITE_OMIT_WINDOWFUNC /* ** Generate a human-readable explanation for a Window Function object |
︙ | ︙ | |||
32122 32123 32124 32125 32126 32127 32128 | /* 85 */ "Cast" OpHelp("affinity(r[P1])"), /* 86 */ "Permutation" OpHelp(""), /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), /* 90 */ "Column" OpHelp("r[P3]=PX"), /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | > > > > | | | | | | | | | | | | < < < < < | | > | 32197 32198 32199 32200 32201 32202 32203 32204 32205 32206 32207 32208 32209 32210 32211 32212 32213 32214 32215 32216 32217 32218 32219 32220 32221 32222 32223 32224 32225 32226 32227 32228 32229 | /* 85 */ "Cast" OpHelp("affinity(r[P1])"), /* 86 */ "Permutation" OpHelp(""), /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), /* 90 */ "Column" OpHelp("r[P3]=PX"), /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), /* 93 */ "Count" OpHelp("r[P2]=count()"), /* 94 */ "ReadCookie" OpHelp(""), /* 95 */ "SetCookie" OpHelp(""), /* 96 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), /* 97 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), /* 98 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), /* 99 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), /* 100 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), /* 101 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), /* 102 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), /* 103 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), /* 104 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), /* 105 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), /* 106 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), /* 107 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), /* 108 */ "OpenRead" OpHelp("root=P2 iDb=P3"), /* 109 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), /* 110 */ "String8" OpHelp("r[P2]='P4'"), /* 111 */ "OpenDup" OpHelp(""), /* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"), /* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"), /* 114 */ "SorterOpen" OpHelp(""), /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), /* 117 */ "Close" OpHelp(""), |
︙ | ︙ | |||
32171 32172 32173 32174 32175 32176 32177 | /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"), /* 136 */ "Destroy" OpHelp(""), /* 137 */ "Clear" OpHelp(""), /* 138 */ "ResetSorter" OpHelp(""), /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), /* 140 */ "SqlExec" OpHelp(""), | < | | | | > | 32246 32247 32248 32249 32250 32251 32252 32253 32254 32255 32256 32257 32258 32259 32260 32261 32262 32263 32264 | /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"), /* 136 */ "Destroy" OpHelp(""), /* 137 */ "Clear" OpHelp(""), /* 138 */ "ResetSorter" OpHelp(""), /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), /* 140 */ "SqlExec" OpHelp(""), /* 141 */ "ParseSchema" OpHelp(""), /* 142 */ "LoadAnalysis" OpHelp(""), /* 143 */ "DropTable" OpHelp(""), /* 144 */ "DropIndex" OpHelp(""), /* 145 */ "Real" OpHelp("r[P2]=P4"), /* 146 */ "DropTrigger" OpHelp(""), /* 147 */ "IntegrityCk" OpHelp(""), /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), /* 149 */ "Param" OpHelp(""), /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
︙ | ︙ | |||
59202 59203 59204 59205 59206 59207 59208 59209 59210 59211 59212 59213 59214 59215 59216 59217 59218 | ** actually needed. */ static void walCleanupHash(Wal *pWal){ WalHashLoc sLoc; /* Hash table location */ int iLimit = 0; /* Zero values greater than this */ int nByte; /* Number of bytes to zero in aPgno[] */ int i; /* Used to iterate through aHash[] */ assert( pWal->writeLock ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 ); if( pWal->hdr.mxFrame==0 ) return; /* Obtain pointers to the hash-table and page-number array containing ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed | > | | > | 59277 59278 59279 59280 59281 59282 59283 59284 59285 59286 59287 59288 59289 59290 59291 59292 59293 59294 59295 59296 59297 59298 59299 59300 59301 59302 59303 59304 59305 59306 59307 | ** actually needed. */ static void walCleanupHash(Wal *pWal){ WalHashLoc sLoc; /* Hash table location */ int iLimit = 0; /* Zero values greater than this */ int nByte; /* Number of bytes to zero in aPgno[] */ int i; /* Used to iterate through aHash[] */ int rc; /* Return code form walHashGet() */ assert( pWal->writeLock ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 ); if( pWal->hdr.mxFrame==0 ) return; /* Obtain pointers to the hash-table and page-number array containing ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed ** that the page said hash-table and array reside on is already mapped.(1) */ assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) ); assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] ); rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */ /* Zero all hash-table entries that correspond to frame numbers greater ** than pWal->hdr.mxFrame. */ iLimit = pWal->hdr.mxFrame - sLoc.iZero; assert( iLimit>0 ); for(i=0; i<HASHTABLE_NSLOT; i++){ |
︙ | ︙ | |||
63920 63921 63922 63923 63924 63925 63926 | ** when saveCursorPosition() was called. Note that this call deletes the ** saved position info stored by saveCursorPosition(), so there can be ** at most one effective restoreCursorPosition() call after each ** saveCursorPosition(). */ static int btreeRestoreCursorPosition(BtCursor *pCur){ int rc; | | > > > | > | 63997 63998 63999 64000 64001 64002 64003 64004 64005 64006 64007 64008 64009 64010 64011 64012 64013 64014 64015 64016 64017 64018 64019 64020 64021 64022 | ** when saveCursorPosition() was called. Note that this call deletes the ** saved position info stored by saveCursorPosition(), so there can be ** at most one effective restoreCursorPosition() call after each ** saveCursorPosition(). */ static int btreeRestoreCursorPosition(BtCursor *pCur){ int rc; int skipNext = 0; assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState>=CURSOR_REQUIRESEEK ); if( pCur->eState==CURSOR_FAULT ){ return pCur->skipNext; } pCur->eState = CURSOR_INVALID; if( sqlite3FaultSim(410) ){ rc = SQLITE_IOERR; }else{ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext); } if( rc==SQLITE_OK ){ sqlite3_free(pCur->pKey); pCur->pKey = 0; assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID ); if( skipNext ) pCur->skipNext = skipNext; if( pCur->skipNext && pCur->eState==CURSOR_VALID ){ pCur->eState = CURSOR_SKIPNEXT; |
︙ | ︙ | |||
64519 64520 64521 64522 64523 64524 64525 | /* This block handles pages with two or fewer free blocks and nMaxFrag ** or fewer fragmented bytes. In this case it is faster to move the ** two (or one) blocks of cells using memmove() and add the required ** offsets to each pointer in the cell-pointer array than it is to ** reconstruct the entire page. */ if( (int)data[hdr+7]<=nMaxFrag ){ int iFree = get2byte(&data[hdr+1]); | | < < < < > > > | 64600 64601 64602 64603 64604 64605 64606 64607 64608 64609 64610 64611 64612 64613 64614 64615 64616 64617 64618 64619 64620 64621 64622 64623 64624 64625 64626 64627 64628 64629 64630 64631 64632 64633 64634 64635 64636 | /* This block handles pages with two or fewer free blocks and nMaxFrag ** or fewer fragmented bytes. In this case it is faster to move the ** two (or one) blocks of cells using memmove() and add the required ** offsets to each pointer in the cell-pointer array than it is to ** reconstruct the entire page. */ if( (int)data[hdr+7]<=nMaxFrag ){ int iFree = get2byte(&data[hdr+1]); if( iFree>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage); if( iFree ){ int iFree2 = get2byte(&data[iFree]); if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage); if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){ u8 *pEnd = &data[cellOffset + nCell*2]; u8 *pAddr; int sz2 = 0; int sz = get2byte(&data[iFree+2]); int top = get2byte(&data[hdr+5]); if( top>=iFree ){ return SQLITE_CORRUPT_PAGE(pPage); } if( iFree2 ){ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage); sz2 = get2byte(&data[iFree2+2]); if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); sz += sz2; }else if( iFree+sz>usableSize ){ return SQLITE_CORRUPT_PAGE(pPage); } cbrk = top+sz; assert( cbrk+(iFree-top) <= usableSize ); memmove(&data[cbrk], &data[top], iFree-top); for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){ pc = get2byte(pAddr); if( pc<iFree ){ put2byte(pAddr, pc+sz); } else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); } |
︙ | ︙ | |||
65100 65101 65102 65103 65104 65105 65106 | } testcase( pPage->nCell==MX_CELL(pBt) ); /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only ** possible for a root page of a table that contains no rows) then the ** offset to the cell content area will equal the page size minus the ** bytes of reserved space. */ assert( pPage->nCell>0 | | | 65180 65181 65182 65183 65184 65185 65186 65187 65188 65189 65190 65191 65192 65193 65194 | } testcase( pPage->nCell==MX_CELL(pBt) ); /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only ** possible for a root page of a table that contains no rows) then the ** offset to the cell content area will equal the page size minus the ** bytes of reserved space. */ assert( pPage->nCell>0 || get2byteNotZero(&data[5])==(int)pBt->usableSize || CORRUPT_DB ); pPage->nFree = -1; /* Indicate that this value is yet uncomputed */ pPage->isInit = 1; if( pBt->db->flags & SQLITE_CellSizeCk ){ return btreeCellSizeCheck(pPage); } return SQLITE_OK; |
︙ | ︙ | |||
68357 68358 68359 68360 68361 68362 68363 | assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 ); *pRes = 1; rc = SQLITE_OK; } return rc; } | < < < < < < < < < < < < < < < < < | 68437 68438 68439 68440 68441 68442 68443 68444 68445 68446 68447 68448 68449 68450 | assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 ); *pRes = 1; rc = SQLITE_OK; } return rc; } /* Move the cursor to the last entry in the table. Return SQLITE_OK ** on success. Set *pRes to 0 if the cursor actually points to something ** or set *pRes to 1 if the table is empty. */ SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ int rc; |
︙ | ︙ | |||
69277 69278 69279 69280 69281 69282 69283 | int rc; /* Return Code */ int nFree; /* Initial number of pages on free-list */ assert( sqlite3_mutex_held(pBt->mutex) ); assert( CORRUPT_DB || iPage>1 ); assert( !pMemPage || pMemPage->pgno==iPage ); | > | > | 69340 69341 69342 69343 69344 69345 69346 69347 69348 69349 69350 69351 69352 69353 69354 69355 69356 | int rc; /* Return Code */ int nFree; /* Initial number of pages on free-list */ assert( sqlite3_mutex_held(pBt->mutex) ); assert( CORRUPT_DB || iPage>1 ); assert( !pMemPage || pMemPage->pgno==iPage ); if( iPage<2 || iPage>pBt->nPage ){ return SQLITE_CORRUPT_BKPT; } if( pMemPage ){ pPage = pMemPage; sqlite3PagerRef(pPage->pDbPage); }else{ pPage = btreePageLookup(pBt, iPage); } |
︙ | ︙ | |||
70646 70647 70648 70649 70650 70651 70652 | if( apOld[i]->nFree<0 ){ rc = btreeComputeFreeSpace(apOld[i]); if( rc ){ memset(apOld, 0, (i)*sizeof(MemPage*)); goto balance_cleanup; } } | < | 70711 70712 70713 70714 70715 70716 70717 70718 70719 70720 70721 70722 70723 70724 | if( apOld[i]->nFree<0 ){ rc = btreeComputeFreeSpace(apOld[i]); if( rc ){ memset(apOld, 0, (i)*sizeof(MemPage*)); goto balance_cleanup; } } if( (i--)==0 ) break; if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){ apDiv[i] = pParent->apOvfl[0]; pgno = get4byte(apDiv[i]); szNew[i] = pParent->xCellSize(pParent, apDiv[i]); pParent->nOverflow = 0; |
︙ | ︙ | |||
70690 70691 70692 70693 70694 70695 70696 70697 70698 70699 70700 70701 70702 70703 70704 70705 70706 | } dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc); } } /* Make nMaxCells a multiple of 4 in order to preserve 8-byte ** alignment */ nMaxCells = (nMaxCells + 3)&~3; /* ** Allocate space for memory structures */ szScratch = nMaxCells*sizeof(u8*) /* b.apCell */ + nMaxCells*sizeof(u16) /* b.szCell */ + pBt->pageSize; /* aSpace1 */ | > | | 70754 70755 70756 70757 70758 70759 70760 70761 70762 70763 70764 70765 70766 70767 70768 70769 70770 70771 70772 70773 70774 70775 70776 70777 70778 70779 | } dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc); } } /* Make nMaxCells a multiple of 4 in order to preserve 8-byte ** alignment */ nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl)); nMaxCells = (nMaxCells + 3)&~3; /* ** Allocate space for memory structures */ szScratch = nMaxCells*sizeof(u8*) /* b.apCell */ + nMaxCells*sizeof(u16) /* b.szCell */ + pBt->pageSize; /* aSpace1 */ assert( szScratch<=7*(int)pBt->pageSize ); b.apCell = sqlite3StackAllocRaw(0, szScratch ); if( b.apCell==0 ){ rc = SQLITE_NOMEM_BKPT; goto balance_cleanup; } b.szCell = (u16*)&b.apCell[nMaxCells]; aSpace1 = (u8*)&b.szCell[nMaxCells]; |
︙ | ︙ | |||
71250 71251 71252 71253 71254 71255 71256 | ** by smaller than the child due to the database header, and so all the ** free space needs to be up front. */ assert( nNew==1 || CORRUPT_DB ); rc = defragmentPage(apNew[0], -1); testcase( rc!=SQLITE_OK ); assert( apNew[0]->nFree == | > | | 71315 71316 71317 71318 71319 71320 71321 71322 71323 71324 71325 71326 71327 71328 71329 71330 | ** by smaller than the child due to the database header, and so all the ** free space needs to be up front. */ assert( nNew==1 || CORRUPT_DB ); rc = defragmentPage(apNew[0], -1); testcase( rc!=SQLITE_OK ); assert( apNew[0]->nFree == (get2byteNotZero(&apNew[0]->aData[5]) - apNew[0]->cellOffset - apNew[0]->nCell*2) || rc!=SQLITE_OK ); copyNodeContent(apNew[0], pParent, &rc); freePage(apNew[0], &rc); }else if( ISAUTOVACUUM && !leafCorrection ){ /* Fix the pointer map entries associated with the right-child of each ** sibling page. All other pointer map entries have already been taken |
︙ | ︙ | |||
71915 71916 71917 71918 71919 71920 71921 | assert( cursorOwnsBtShared(pCur) ); assert( pBt->inTransaction==TRANS_WRITE ); assert( (pBt->btsFlags & BTS_READ_ONLY)==0 ); assert( pCur->curFlags & BTCF_WriteFlag ); assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); assert( !hasReadConflicts(p, pCur->pgnoRoot) ); | > | > > > < | 71981 71982 71983 71984 71985 71986 71987 71988 71989 71990 71991 71992 71993 71994 71995 71996 71997 71998 71999 72000 | assert( cursorOwnsBtShared(pCur) ); assert( pBt->inTransaction==TRANS_WRITE ); assert( (pBt->btsFlags & BTS_READ_ONLY)==0 ); assert( pCur->curFlags & BTCF_WriteFlag ); assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); assert( !hasReadConflicts(p, pCur->pgnoRoot) ); assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); if( pCur->eState==CURSOR_REQUIRESEEK ){ rc = btreeRestoreCursorPosition(pCur); if( rc ) return rc; } assert( pCur->eState==CURSOR_VALID ); iCellDepth = pCur->iPage; iCellIdx = pCur->ix; pPage = pCur->pPage; pCell = findCell(pPage, iCellIdx); if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT; |
︙ | ︙ | |||
74385 74386 74387 74388 74389 74390 74391 | /* This is a pointer type. There may be a flag to indicate what to ** do with the pointer. */ assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) + ((p->flags&MEM_Ephem)!=0 ? 1 : 0) + ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 ); /* No other bits set */ | | | 74454 74455 74456 74457 74458 74459 74460 74461 74462 74463 74464 74465 74466 74467 74468 | /* This is a pointer type. There may be a flag to indicate what to ** do with the pointer. */ assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) + ((p->flags&MEM_Ephem)!=0 ? 1 : 0) + ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 ); /* No other bits set */ assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype|MEM_FromBind |MEM_Dyn|MEM_Ephem|MEM_Static))==0 ); }else{ /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn, ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */ } }else{ /* The MEM_Cleared bit is only allowed on NULLs */ |
︙ | ︙ | |||
81472 81473 81474 81475 81476 81477 81478 81479 81480 81481 81482 81483 81484 81485 | return aType[pVal->flags&MEM_AffMask]; } /* Return true if a parameter to xUpdate represents an unchanged column */ SQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){ return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero); } /* Make a copy of an sqlite3_value object */ SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){ sqlite3_value *pNew; if( pOrig==0 ) return 0; pNew = sqlite3_malloc( sizeof(*pNew) ); | > > > > > | 81541 81542 81543 81544 81545 81546 81547 81548 81549 81550 81551 81552 81553 81554 81555 81556 81557 81558 81559 | return aType[pVal->flags&MEM_AffMask]; } /* Return true if a parameter to xUpdate represents an unchanged column */ SQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){ return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero); } /* Return true if a parameter value originated from an sqlite3_bind() */ SQLITE_API int sqlite3_value_frombind(sqlite3_value *pVal){ return (pVal->flags&MEM_FromBind)!=0; } /* Make a copy of an sqlite3_value object */ SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){ sqlite3_value *pNew; if( pOrig==0 ) return 0; pNew = sqlite3_malloc( sizeof(*pNew) ); |
︙ | ︙ | |||
83503 83504 83505 83506 83507 83508 83509 | #endif /* ** Invoke the VDBE coverage callback, if that callback is defined. This ** feature is used for test suite validation only and does not appear an ** production builds. ** | | | > | > > > > > > > > | | < | | | 83577 83578 83579 83580 83581 83582 83583 83584 83585 83586 83587 83588 83589 83590 83591 83592 83593 83594 83595 83596 83597 83598 83599 83600 83601 83602 83603 83604 83605 83606 83607 83608 83609 83610 83611 83612 83613 83614 83615 83616 83617 | #endif /* ** Invoke the VDBE coverage callback, if that callback is defined. This ** feature is used for test suite validation only and does not appear an ** production builds. ** ** M is the type of branch. I is the direction taken for this instance of ** the branch. ** ** M: 2 - two-way branch (I=0: fall-thru 1: jump ) ** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL ) ** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3) ** ** In other words, if M is 2, then I is either 0 (for fall-through) or ** 1 (for when the branch is taken). If M is 3, the I is 0 for an ** ordinary fall-through, I is 1 if the branch was taken, and I is 2 ** if the result of comparison is NULL. For M=3, I=2 the jump may or ** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5. ** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2 ** depending on if the operands are less than, equal, or greater than. ** ** iSrcLine is the source code line (from the __LINE__ macro) that ** generated the VDBE instruction combined with flag bits. The source ** code line number is in the lower 24 bits of iSrcLine and the upper ** 8 bytes are flags. The lower three bits of the flags indicate ** values for I that should never occur. For example, if the branch is ** always taken, the flags should be 0x05 since the fall-through and ** alternate branch are never taken. If a branch is never taken then ** flags should be 0x06 since only the fall-through approach is allowed. ** ** Bit 0x08 of the flags indicates an OP_Jump opcode that is only ** interested in equal or not-equal. In other words, I==0 and I==2 ** should be treated as equivalent ** ** Since only a line number is retained, not the filename, this macro ** only works for amalgamation builds. But that is ok, since these macros ** should be no-ops except for special builds used to measure test coverage. */ #if !defined(SQLITE_VDBE_COVERAGE) # define VdbeBranchTaken(I,M) |
︙ | ︙ | |||
83545 83546 83547 83548 83549 83550 83551 83552 83553 83554 83555 83556 83557 83558 | /* The upper 8 bits of iSrcLine are flags. The lower three bits of ** the flags indicate directions that the branch can never go. If ** a branch really does go in one of those directions, assert right ** away. */ mNever = iSrcLine >> 24; assert( (I & mNever)==0 ); if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/ I |= mNever; if( M==2 ) I |= 0x04; if( M==4 ){ I |= 0x08; if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/ } sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg, | > > > > > > > > > > > > | 83627 83628 83629 83630 83631 83632 83633 83634 83635 83636 83637 83638 83639 83640 83641 83642 83643 83644 83645 83646 83647 83648 83649 83650 83651 83652 | /* The upper 8 bits of iSrcLine are flags. The lower three bits of ** the flags indicate directions that the branch can never go. If ** a branch really does go in one of those directions, assert right ** away. */ mNever = iSrcLine >> 24; assert( (I & mNever)==0 ); if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/ /* Invoke the branch coverage callback with three arguments: ** iSrcLine - the line number of the VdbeCoverage() macro, with ** flags removed. ** I - Mask of bits 0x07 indicating which cases are are ** fulfilled by this instance of the jump. 0x01 means ** fall-thru, 0x02 means taken, 0x04 means NULL. Any ** impossible cases (ex: if the comparison is never NULL) ** are filled in automatically so that the coverage ** measurement logic does not flag those impossible cases ** as missed coverage. ** M - Type of jump. Same as M argument above */ I |= mNever; if( M==2 ) I |= 0x04; if( M==4 ){ I |= 0x08; if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/ } sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg, |
︙ | ︙ | |||
84706 84707 84708 84709 84710 84711 84712 | assert( pOp->p1>0 && pOp->p1<=p->nVar ); assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) ); pVar = &p->aVar[pOp->p1 - 1]; if( sqlite3VdbeMemTooBig(pVar) ){ goto too_big; } pOut = &aMem[pOp->p2]; | > | > > | 84800 84801 84802 84803 84804 84805 84806 84807 84808 84809 84810 84811 84812 84813 84814 84815 84816 84817 | assert( pOp->p1>0 && pOp->p1<=p->nVar ); assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) ); pVar = &p->aVar[pOp->p1 - 1]; if( sqlite3VdbeMemTooBig(pVar) ){ goto too_big; } pOut = &aMem[pOp->p2]; if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut); memcpy(pOut, pVar, MEMCELLSIZE); pOut->flags &= ~(MEM_Dyn|MEM_Ephem); pOut->flags |= MEM_Static|MEM_FromBind; UPDATE_MAX_BLOBSIZE(pOut); break; } /* Opcode: Move P1 P2 P3 * * ** Synopsis: r[P2@P3]=r[P1@P3] ** |
︙ | ︙ | |||
85204 85205 85206 85207 85208 85209 85210 | ** without data loss, then jump immediately to P2, or if P2==0 ** raise an SQLITE_MISMATCH exception. */ case OP_MustBeInt: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; if( (pIn1->flags & MEM_Int)==0 ){ applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); | < > > | 85301 85302 85303 85304 85305 85306 85307 85308 85309 85310 85311 85312 85313 85314 85315 85316 85317 85318 85319 85320 85321 85322 85323 85324 85325 | ** without data loss, then jump immediately to P2, or if P2==0 ** raise an SQLITE_MISMATCH exception. */ case OP_MustBeInt: { /* jump, in1 */ pIn1 = &aMem[pOp->p1]; if( (pIn1->flags & MEM_Int)==0 ){ applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding); if( (pIn1->flags & MEM_Int)==0 ){ VdbeBranchTaken(1, 2); if( pOp->p2==0 ){ rc = SQLITE_MISMATCH; goto abort_due_to_error; }else{ goto jump_to_p2; } } } VdbeBranchTaken(0, 2); MemSetTypeFlag(pIn1, MEM_Int); break; } #ifndef SQLITE_OMIT_FLOATING_POINT /* Opcode: RealAffinity P1 * * * * ** |
︙ | ︙ | |||
85388 85389 85390 85391 85392 85393 85394 | if( (flags1 | flags3)&MEM_Null ){ /* One or both operands are NULL */ if( pOp->p5 & SQLITE_NULLEQ ){ /* If SQLITE_NULLEQ is set (which will only happen if the operator is ** OP_Eq or OP_Ne) then take the jump or not depending on whether ** or not both operands are null. */ | < | | 85486 85487 85488 85489 85490 85491 85492 85493 85494 85495 85496 85497 85498 85499 85500 85501 85502 85503 85504 85505 85506 85507 85508 | if( (flags1 | flags3)&MEM_Null ){ /* One or both operands are NULL */ if( pOp->p5 & SQLITE_NULLEQ ){ /* If SQLITE_NULLEQ is set (which will only happen if the operator is ** OP_Eq or OP_Ne) then take the jump or not depending on whether ** or not both operands are null. */ assert( (flags1 & MEM_Cleared)==0 ); assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB ); testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 ); if( (flags1&flags3&MEM_Null)!=0 && (flags3&MEM_Cleared)==0 ){ res = 0; /* Operands are equal */ }else{ res = ((flags3 & MEM_Null) ? -1 : +1); /* Operands are not equal */ } }else{ /* SQLITE_NULLEQ is clear and at least one operand is NULL, ** then the result is always NULL. ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. */ if( pOp->p5 & SQLITE_STOREP2 ){ |
︙ | ︙ | |||
85515 85516 85517 85518 85519 85520 85521 | if( (pOp->opcode==OP_Eq)==res2 ) break; } memAboutToChange(p, pOut); MemSetTypeFlag(pOut, MEM_Int); pOut->u.i = res2; REGISTER_TRACE(pOp->p2, pOut); }else{ | | | 85612 85613 85614 85615 85616 85617 85618 85619 85620 85621 85622 85623 85624 85625 85626 | if( (pOp->opcode==OP_Eq)==res2 ) break; } memAboutToChange(p, pOut); MemSetTypeFlag(pOut, MEM_Int); pOut->u.i = res2; REGISTER_TRACE(pOp->p2, pOut); }else{ VdbeBranchTaken(res2!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3); if( res2 ){ goto jump_to_p2; } } break; } |
︙ | ︙ | |||
87076 87077 87078 87079 87080 87081 87082 87083 87084 87085 87086 87087 87088 87089 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; pCx->isEphemeral = 1; pCx->pKeyInfo = pOrig->pKeyInfo; pCx->isTable = pOrig->isTable; pCx->pgnoRoot = pOrig->pgnoRoot; rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR, pCx->pKeyInfo, pCx->uc.pCursor); /* The sqlite3BtreeCursor() routine can only fail for the first cursor ** opened for a database. Since there is already an open cursor when this ** opcode is run, the sqlite3BtreeCursor() cannot fail */ assert( rc==SQLITE_OK ); break; | > | 87173 87174 87175 87176 87177 87178 87179 87180 87181 87182 87183 87184 87185 87186 87187 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; pCx->isEphemeral = 1; pCx->pKeyInfo = pOrig->pKeyInfo; pCx->isTable = pOrig->isTable; pCx->pgnoRoot = pOrig->pgnoRoot; pCx->isOrdered = pOrig->isOrdered; rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR, pCx->pKeyInfo, pCx->uc.pCursor); /* The sqlite3BtreeCursor() routine can only fail for the first cursor ** opened for a database. Since there is already an open cursor when this ** opcode is run, the sqlite3BtreeCursor() cannot fail */ assert( rc==SQLITE_OK ); break; |
︙ | ︙ | |||
88584 88585 88586 88587 88588 88589 88590 | #ifdef SQLITE_TEST sqlite3_sort_count++; sqlite3_search_count--; #endif p->aCounter[SQLITE_STMTSTATUS_SORT]++; /* Fall through into OP_Rewind */ } | | < < < < > < < < | 88682 88683 88684 88685 88686 88687 88688 88689 88690 88691 88692 88693 88694 88695 88696 88697 88698 88699 88700 88701 88702 88703 88704 88705 88706 88707 88708 88709 88710 88711 88712 88713 88714 88715 88716 88717 88718 88719 88720 88721 88722 88723 88724 88725 88726 88727 88728 | #ifdef SQLITE_TEST sqlite3_sort_count++; sqlite3_search_count--; #endif p->aCounter[SQLITE_STMTSTATUS_SORT]++; /* Fall through into OP_Rewind */ } /* Opcode: Rewind P1 P2 * * * ** ** The next use of the Rowid or Column or Next instruction for P1 ** will refer to the first entry in the database table or index. ** If the table or index is empty, jump immediately to P2. ** If the table or index is not empty, fall through to the following ** instruction. ** ** This opcode leaves the cursor configured to move in forward order, ** from the beginning toward the end. In other words, the cursor is ** configured to use Next, not Prev. */ case OP_Rewind: { /* jump */ VdbeCursor *pC; BtCursor *pCrsr; int res; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p5==0 ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) ); res = 1; #ifdef SQLITE_DEBUG pC->seekOp = OP_Rewind; #endif if( isSorter(pC) ){ rc = sqlite3VdbeSorterRewind(pC, &res); }else{ assert( pC->eCurType==CURTYPE_BTREE ); pCrsr = pC->uc.pCursor; assert( pCrsr ); rc = sqlite3BtreeFirst(pCrsr, &res); pC->deferredMoveto = 0; pC->cacheStatus = CACHE_STALE; } if( rc ) goto abort_due_to_error; pC->nullRow = (u8)res; assert( pOp->p2>0 && pOp->p2<p->nOp ); VdbeBranchTaken(res!=0,2); |
︙ | ︙ | |||
90004 90005 90006 90007 90008 90009 90010 90011 90012 90013 90014 90015 90016 90017 | Mem *pMem; assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); assert( pOp->p3==0 || pOp->opcode==OP_AggValue ); pMem = &aMem[pOp->p1]; assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 ); #ifndef SQLITE_OMIT_WINDOWFUNC if( pOp->p3 ){ rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc); pMem = &aMem[pOp->p3]; }else #endif { rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc); } | > | 90096 90097 90098 90099 90100 90101 90102 90103 90104 90105 90106 90107 90108 90109 90110 | Mem *pMem; assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); assert( pOp->p3==0 || pOp->opcode==OP_AggValue ); pMem = &aMem[pOp->p1]; assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 ); #ifndef SQLITE_OMIT_WINDOWFUNC if( pOp->p3 ){ memAboutToChange(p, &aMem[pOp->p3]); rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc); pMem = &aMem[pOp->p3]; }else #endif { rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc); } |
︙ | ︙ | |||
95422 95423 95424 95425 95426 95427 95428 95429 95430 95431 95432 95433 95434 95435 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->x.pList==0 ); assert( pExpr->x.pSelect==0 ); pOrig = pEList->a[j].pExpr; if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); return WRC_Abort; } if( sqlite3ExprVectorSize(pOrig)!=1 ){ sqlite3ErrorMsg(pParse, "row value misused"); return WRC_Abort; } resolveAlias(pParse, pEList, j, pExpr, "", nSubquery); cnt = 1; | > > > > | 95515 95516 95517 95518 95519 95520 95521 95522 95523 95524 95525 95526 95527 95528 95529 95530 95531 95532 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->x.pList==0 ); assert( pExpr->x.pSelect==0 ); pOrig = pEList->a[j].pExpr; if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); return WRC_Abort; } if( (pNC->ncFlags&NC_AllowWin)==0 && ExprHasProperty(pOrig, EP_Win) ){ sqlite3ErrorMsg(pParse, "misuse of aliased window function %s",zAs); return WRC_Abort; } if( sqlite3ExprVectorSize(pOrig)!=1 ){ sqlite3ErrorMsg(pParse, "row value misused"); return WRC_Abort; } resolveAlias(pParse, pEList, j, pExpr, "", nSubquery); cnt = 1; |
︙ | ︙ | |||
95713 95714 95715 95716 95717 95718 95719 95720 95721 95722 95723 95724 95725 95726 | int no_such_func = 0; /* True if no such function exists */ int wrong_num_args = 0; /* True if wrong number of arguments */ int is_agg = 0; /* True if is an aggregate function */ int nId; /* Number of characters in function name */ const char *zId; /* The function name. */ FuncDef *pDef; /* Information about the function */ u8 enc = ENC(pParse->db); /* The database encoding */ assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); zId = pExpr->u.zToken; nId = sqlite3Strlen30(zId); pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); if( pDef==0 ){ pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); | > | 95810 95811 95812 95813 95814 95815 95816 95817 95818 95819 95820 95821 95822 95823 95824 | int no_such_func = 0; /* True if no such function exists */ int wrong_num_args = 0; /* True if wrong number of arguments */ int is_agg = 0; /* True if is an aggregate function */ int nId; /* Number of characters in function name */ const char *zId; /* The function name. */ FuncDef *pDef; /* Information about the function */ u8 enc = ENC(pParse->db); /* The database encoding */ int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin)); assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); zId = pExpr->u.zToken; nId = sqlite3Strlen30(zId); pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); if( pDef==0 ){ pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
︙ | ︙ | |||
95834 95835 95836 95837 95838 95839 95840 95841 | pNC->nErr++; }else if( wrong_num_args ){ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", nId, zId); pNC->nErr++; } if( is_agg ){ #ifndef SQLITE_OMIT_WINDOWFUNC | > > > | | < > | 95932 95933 95934 95935 95936 95937 95938 95939 95940 95941 95942 95943 95944 95945 95946 95947 95948 95949 95950 95951 95952 95953 95954 95955 95956 95957 95958 95959 95960 95961 95962 95963 95964 95965 95966 95967 95968 95969 95970 95971 95972 95973 95974 95975 95976 95977 95978 95979 95980 95981 95982 95983 95984 95985 95986 95987 95988 95989 95990 | pNC->nErr++; }else if( wrong_num_args ){ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", nId, zId); pNC->nErr++; } if( is_agg ){ /* Window functions may not be arguments of aggregate functions. ** Or arguments of other window functions. But aggregate functions ** may be arguments for window functions. */ #ifndef SQLITE_OMIT_WINDOWFUNC pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0)); #else pNC->ncFlags &= ~NC_AllowAgg; #endif } } sqlite3WalkExprList(pWalker, pList); if( is_agg ){ #ifndef SQLITE_OMIT_WINDOWFUNC if( pExpr->y.pWin ){ Select *pSel = pNC->pWinSelect; sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef); sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition); sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy); sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); if( 0==pSel->pWin || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin) ){ pExpr->y.pWin->pNextWin = pSel->pWin; pSel->pWin = pExpr->y.pWin; } pNC->ncFlags |= NC_HasWin; }else #endif /* SQLITE_OMIT_WINDOWFUNC */ { NameContext *pNC2 = pNC; pExpr->op = TK_AGG_FUNCTION; pExpr->op2 = 0; while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){ pExpr->op2++; pNC2 = pNC2->pNext; } assert( pDef!=0 ); if( pNC2 ){ assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX); } } pNC->ncFlags |= savedAllowFlags; } /* FIX ME: Compute pExpr->affinity based on the expected return ** type of the function */ return WRC_Prune; } #ifndef SQLITE_OMIT_SUBQUERY |
︙ | ︙ | |||
96412 96413 96414 96415 96416 96417 96418 | p->pOrderBy = 0; } /* Recursively resolve names in all subqueries */ for(i=0; i<p->pSrc->nSrc; i++){ struct SrcList_item *pItem = &p->pSrc->a[i]; | | | 96513 96514 96515 96516 96517 96518 96519 96520 96521 96522 96523 96524 96525 96526 96527 | p->pOrderBy = 0; } /* Recursively resolve names in all subqueries */ for(i=0; i<p->pSrc->nSrc; i++){ struct SrcList_item *pItem = &p->pSrc->a[i]; if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ NameContext *pNC; /* Used to iterate name contexts */ int nRef = 0; /* Refcount for pOuterNC and outer contexts */ const char *zSavedContext = pParse->zAuthContext; /* Count the total number of references to pOuterNC and all of its ** parent contexts. After resolving references to expressions in ** pItem->pSelect, check if this value has changed. If so, then |
︙ | ︙ | |||
96636 96637 96638 96639 96640 96641 96642 | NameContext *pNC, /* Namespace to resolve expressions in. */ Expr *pExpr /* The expression to be analyzed. */ ){ u16 savedHasAgg; Walker w; if( pExpr==0 ) return SQLITE_OK; | | | > > | > | < | 96737 96738 96739 96740 96741 96742 96743 96744 96745 96746 96747 96748 96749 96750 96751 96752 96753 96754 96755 96756 96757 96758 96759 96760 96761 96762 96763 96764 96765 96766 96767 96768 96769 96770 96771 96772 | NameContext *pNC, /* Namespace to resolve expressions in. */ Expr *pExpr /* The expression to be analyzed. */ ){ u16 savedHasAgg; Walker w; if( pExpr==0 ) return SQLITE_OK; savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); w.pParse = pNC->pParse; w.xExprCallback = resolveExprStep; w.xSelectCallback = resolveSelectStep; w.xSelectCallback2 = 0; w.u.pNC = pNC; #if SQLITE_MAX_EXPR_DEPTH>0 w.pParse->nHeight += pExpr->nHeight; if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){ return SQLITE_ERROR; } #endif sqlite3WalkExpr(&w, pExpr); #if SQLITE_MAX_EXPR_DEPTH>0 w.pParse->nHeight -= pExpr->nHeight; #endif assert( EP_Agg==NC_HasAgg ); assert( EP_Win==NC_HasWin ); testcase( pNC->ncFlags & NC_HasAgg ); testcase( pNC->ncFlags & NC_HasWin ); ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); pNC->ncFlags |= savedHasAgg; return pNC->nErr>0 || w.pParse->nErr>0; } /* ** Resolve all names for all expression in an expression list. This is ** just like sqlite3ResolveExprNames() except that it works for an expression |
︙ | ︙ | |||
101786 101787 101788 101789 101790 101791 101792 101793 101794 101795 101796 101797 101798 101799 | ** an ordinary JOIN. The p argument is the WHERE clause. If the WHERE ** clause requires that some column of the right table of the LEFT JOIN ** be non-NULL, then the LEFT JOIN can be safely converted into an ** ordinary join. */ SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ Walker w; w.xExprCallback = impliesNotNullRow; w.xSelectCallback = 0; w.xSelectCallback2 = 0; w.eCode = 0; w.u.iCur = iTab; sqlite3WalkExpr(&w, p); return w.eCode; | > > > > > > > > > > > | 101889 101890 101891 101892 101893 101894 101895 101896 101897 101898 101899 101900 101901 101902 101903 101904 101905 101906 101907 101908 101909 101910 101911 101912 101913 | ** an ordinary JOIN. The p argument is the WHERE clause. If the WHERE ** clause requires that some column of the right table of the LEFT JOIN ** be non-NULL, then the LEFT JOIN can be safely converted into an ** ordinary join. */ SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ Walker w; p = sqlite3ExprSkipCollate(p); while( p ){ if( p->op==TK_NOTNULL ){ p = p->pLeft; }else if( p->op==TK_AND ){ if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; p = p->pRight; }else{ break; } } w.xExprCallback = impliesNotNullRow; w.xSelectCallback = 0; w.xSelectCallback2 = 0; w.eCode = 0; w.u.iCur = iTab; sqlite3WalkExpr(&w, p); return w.eCode; |
︙ | ︙ | |||
106959 106960 106961 106962 106963 106964 106965 106966 106967 106968 106969 106970 106971 106972 | zSql = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); if( zSql==0 ){ /* This can result either from an OOM or because the formatted string ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set ** an error */ if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG; return; } pParse->nested++; memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); sqlite3RunParser(pParse, zSql, &zErrMsg); sqlite3DbFree(db, zErrMsg); | > | 107073 107074 107075 107076 107077 107078 107079 107080 107081 107082 107083 107084 107085 107086 107087 | zSql = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); if( zSql==0 ){ /* This can result either from an OOM or because the formatted string ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set ** an error */ if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG; pParse->nErr++; return; } pParse->nested++; memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); sqlite3RunParser(pParse, zSql, &zErrMsg); sqlite3DbFree(db, zErrMsg); |
︙ | ︙ | |||
108099 108100 108101 108102 108103 108104 108105 | } if( nTerm==1 && pCol && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0 && sortOrder!=SQLITE_SO_DESC ){ if( IN_RENAME_OBJECT && pList ){ | > | | 108214 108215 108216 108217 108218 108219 108220 108221 108222 108223 108224 108225 108226 108227 108228 108229 | } if( nTerm==1 && pCol && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0 && sortOrder!=SQLITE_SO_DESC ){ if( IN_RENAME_OBJECT && pList ){ Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[0].pExpr); sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pCExpr); } pTab->iPKey = iCol; pTab->keyConf = (u8)onError; assert( autoInc==0 || autoInc==1 ); pTab->tabFlags |= autoInc*TF_Autoincrement; if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder; }else if( autoInc ){ |
︙ | ︙ | |||
109848 109849 109850 109851 109852 109853 109854 109855 109856 109857 109858 109859 109860 | } pDb = &db->aDb[iDb]; assert( pTab!=0 ); assert( pParse->nErr==0 ); if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 && db->init.busy==0 #if SQLITE_USER_AUTHENTICATION && sqlite3UserAuthTable(pTab->zName)==0 #endif #ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX && sqlite3StrICmp(&pTab->zName[7],"master")!=0 #endif | > < | 109964 109965 109966 109967 109968 109969 109970 109971 109972 109973 109974 109975 109976 109977 109978 109979 109980 109981 109982 109983 109984 | } pDb = &db->aDb[iDb]; assert( pTab!=0 ); assert( pParse->nErr==0 ); if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 && db->init.busy==0 && pTblName!=0 #if SQLITE_USER_AUTHENTICATION && sqlite3UserAuthTable(pTab->zName)==0 #endif #ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX && sqlite3StrICmp(&pTab->zName[7],"master")!=0 #endif ){ sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName); goto exit_create_index; } #ifndef SQLITE_OMIT_VIEW if( pTab->pSelect ){ sqlite3ErrorMsg(pParse, "views may not be indexed"); |
︙ | ︙ | |||
109958 109959 109960 109961 109962 109963 109964 109965 109966 109967 109968 109969 109970 109971 109972 109973 109974 109975 109976 109977 109978 109979 109980 109981 109982 109983 109984 109985 109986 109987 109988 109989 | pList = sqlite3ExprListAppend(pParse, 0, sqlite3ExprAlloc(db, TK_ID, &prevCol, 0)); if( pList==0 ) goto exit_create_index; assert( pList->nExpr==1 ); sqlite3ExprListSetSortOrder(pList, sortOrder); }else{ sqlite3ExprListCheckLength(pParse, pList, "index"); } /* Figure out how many bytes of space are required to store explicitly ** specified collation sequence names. */ for(i=0; i<pList->nExpr; i++){ Expr *pExpr = pList->a[i].pExpr; assert( pExpr!=0 ); if( pExpr->op==TK_COLLATE ){ nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken)); } } /* ** Allocate the index structure. */ nName = sqlite3Strlen30(zName); nExtraCol = pPk ? pPk->nKeyCol : 1; pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol, nName + nExtra + 1, &zExtra); if( db->mallocFailed ){ goto exit_create_index; } assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) ); assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); | > > | 110074 110075 110076 110077 110078 110079 110080 110081 110082 110083 110084 110085 110086 110087 110088 110089 110090 110091 110092 110093 110094 110095 110096 110097 110098 110099 110100 110101 110102 110103 110104 110105 110106 110107 | pList = sqlite3ExprListAppend(pParse, 0, sqlite3ExprAlloc(db, TK_ID, &prevCol, 0)); if( pList==0 ) goto exit_create_index; assert( pList->nExpr==1 ); sqlite3ExprListSetSortOrder(pList, sortOrder); }else{ sqlite3ExprListCheckLength(pParse, pList, "index"); if( pParse->nErr ) goto exit_create_index; } /* Figure out how many bytes of space are required to store explicitly ** specified collation sequence names. */ for(i=0; i<pList->nExpr; i++){ Expr *pExpr = pList->a[i].pExpr; assert( pExpr!=0 ); if( pExpr->op==TK_COLLATE ){ nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken)); } } /* ** Allocate the index structure. */ nName = sqlite3Strlen30(zName); nExtraCol = pPk ? pPk->nKeyCol : 1; assert( pList->nExpr + nExtraCol <= 32767 /* Fits in i16 */ ); pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol, nName + nExtra + 1, &zExtra); if( db->mallocFailed ){ goto exit_create_index; } assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) ); assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); |
︙ | ︙ | |||
119230 119231 119232 119233 119234 119235 119236 119237 119238 119239 119240 119241 119242 119243 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*), void (*xValue)(sqlite3_context*), void (*xInv)(sqlite3_context*,int,sqlite3_value**), void(*xDestroy)(void*)); /* Version 3.26.0 and later */ const char *(*normalized_sql)(sqlite3_stmt*); }; /* ** This is the function signature used for all extension entry points. It ** is also defined in the file "loadext.c". */ typedef int (*sqlite3_loadext_entry)( | > > > | 119348 119349 119350 119351 119352 119353 119354 119355 119356 119357 119358 119359 119360 119361 119362 119363 119364 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*), void (*xValue)(sqlite3_context*), void (*xInv)(sqlite3_context*,int,sqlite3_value**), void(*xDestroy)(void*)); /* Version 3.26.0 and later */ const char *(*normalized_sql)(sqlite3_stmt*); /* Version 3.28.0 and later */ int (*stmt_isexplain)(sqlite3_stmt*); int (*value_frombind)(sqlite3_value*); }; /* ** This is the function signature used for all extension entry points. It ** is also defined in the file "loadext.c". */ typedef int (*sqlite3_loadext_entry)( |
︙ | ︙ | |||
119519 119520 119521 119522 119523 119524 119525 119526 119527 119528 119529 119530 119531 119532 | #define sqlite3_str_errcode sqlite3_api->str_errcode #define sqlite3_str_length sqlite3_api->str_length #define sqlite3_str_value sqlite3_api->str_value /* Version 3.25.0 and later */ #define sqlite3_create_window_function sqlite3_api->create_window_function /* Version 3.26.0 and later */ #define sqlite3_normalized_sql sqlite3_api->normalized_sql #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) /* This case when the file really is being compiled as a loadable ** extension */ # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; | > > > | 119640 119641 119642 119643 119644 119645 119646 119647 119648 119649 119650 119651 119652 119653 119654 119655 119656 | #define sqlite3_str_errcode sqlite3_api->str_errcode #define sqlite3_str_length sqlite3_api->str_length #define sqlite3_str_value sqlite3_api->str_value /* Version 3.25.0 and later */ #define sqlite3_create_window_function sqlite3_api->create_window_function /* Version 3.26.0 and later */ #define sqlite3_normalized_sql sqlite3_api->normalized_sql /* Version 3.28.0 and later */ #define sqlite3_stmt_isexplain sqlite3_api->isexplain #define sqlite3_value_frombind sqlite3_api->frombind #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) /* This case when the file really is being compiled as a loadable ** extension */ # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; |
︙ | ︙ | |||
133857 133858 133859 133860 133861 133862 133863 | /* ** This routine implements the OP_Vacuum opcode of the VDBE. */ SQLITE_PRIVATE int sqlite3RunVacuum( char **pzErrMsg, /* Write error message here */ sqlite3 *db, /* Database connection */ int iDb, /* Which attached DB to vacuum */ | | > > > > | 133981 133982 133983 133984 133985 133986 133987 133988 133989 133990 133991 133992 133993 133994 133995 133996 133997 133998 133999 134000 134001 134002 134003 134004 134005 134006 134007 134008 134009 134010 134011 134012 134013 134014 134015 134016 134017 134018 134019 134020 134021 134022 134023 134024 134025 134026 134027 134028 134029 | /* ** This routine implements the OP_Vacuum opcode of the VDBE. */ SQLITE_PRIVATE int sqlite3RunVacuum( char **pzErrMsg, /* Write error message here */ sqlite3 *db, /* Database connection */ int iDb, /* Which attached DB to vacuum */ sqlite3_value *pOut /* Write results here, if not NULL. VACUUM INTO */ ){ int rc = SQLITE_OK; /* Return code from service routines */ Btree *pMain; /* The database being vacuumed */ Btree *pTemp; /* The temporary database we vacuum into */ u32 saved_mDbFlags; /* Saved value of db->mDbFlags */ u64 saved_flags; /* Saved value of db->flags */ int saved_nChange; /* Saved value of db->nChange */ int saved_nTotalChange; /* Saved value of db->nTotalChange */ u32 saved_openFlags; /* Saved value of db->openFlags */ u8 saved_mTrace; /* Saved trace settings */ Db *pDb = 0; /* Database to detach at end of vacuum */ int isMemDb; /* True if vacuuming a :memory: database */ int nRes; /* Bytes of reserved space at the end of each page */ int nDb; /* Number of attached databases */ const char *zDbMain; /* Schema name of database to vacuum */ const char *zOut; /* Name of output file */ if( !db->autoCommit ){ sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction"); return SQLITE_ERROR; } if( db->nVdbeActive>1 ){ sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress"); return SQLITE_ERROR; } saved_openFlags = db->openFlags; if( pOut ){ if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){ sqlite3SetString(pzErrMsg, db, "non-text filename"); return SQLITE_ERROR; } zOut = (const char*)sqlite3_value_text(pOut); db->openFlags &= ~SQLITE_OPEN_READONLY; db->openFlags |= SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE; }else{ zOut = ""; } /* Save the current value of the database flags so that it can be ** restored before returning. Then set the writable-schema flag, and ** disable CHECK and foreign key constraints. */ |
︙ | ︙ | |||
133926 133927 133928 133929 133930 133931 133932 133933 133934 133935 133936 133937 133938 133939 | ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ nDb = db->nDb; rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut); if( rc!=SQLITE_OK ) goto end_of_vacuum; assert( (db->nDb-1)==nDb ); pDb = &db->aDb[nDb]; assert( strcmp(pDb->zDbSName,"vacuum_db")==0 ); pTemp = pDb->pBt; if( pOut ){ sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp)); | > | 134054 134055 134056 134057 134058 134059 134060 134061 134062 134063 134064 134065 134066 134067 134068 | ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ nDb = db->nDb; rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut); db->openFlags = saved_openFlags; if( rc!=SQLITE_OK ) goto end_of_vacuum; assert( (db->nDb-1)==nDb ); pDb = &db->aDb[nDb]; assert( strcmp(pDb->zDbSName,"vacuum_db")==0 ); pTemp = pDb->pBt; if( pOut ){ sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp)); |
︙ | ︙ | |||
138162 138163 138164 138165 138166 138167 138168 138169 | ** that compares BLOBs. */ #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS continue; #else u32 x = pLevel->iLikeRepCntr; if( x>0 ){ skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1)); } | > > < | 138291 138292 138293 138294 138295 138296 138297 138298 138299 138300 138301 138302 138303 138304 138305 138306 138307 | ** that compares BLOBs. */ #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS continue; #else u32 x = pLevel->iLikeRepCntr; if( x>0 ){ skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1)); VdbeCoverageIf(v, (x&1)==1); VdbeCoverageIf(v, (x&1)==0); } #endif } #ifdef WHERETRACE_ENABLED /* 0xffff */ if( sqlite3WhereTrace ){ VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d", pWC->nTerm-j, pTerm, iLoop)); } |
︙ | ︙ | |||
143187 143188 143189 143190 143191 143192 143193 | /* First call xBestIndex() with all constraints usable. */ WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName)); WHERETRACE(0x40, (" VirtualOne: all usable\n")); rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn); /* If the call to xBestIndex() with all terms enabled produced a plan | | | | | | | 143317 143318 143319 143320 143321 143322 143323 143324 143325 143326 143327 143328 143329 143330 143331 143332 143333 143334 143335 | /* First call xBestIndex() with all constraints usable. */ WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName)); WHERETRACE(0x40, (" VirtualOne: all usable\n")); rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn); /* If the call to xBestIndex() with all terms enabled produced a plan ** that does not require any source tables (IOW: a plan with mBest==0) ** and does not use an IN(...) operator, then there is no point in making ** any further calls to xBestIndex() since they will all return the same ** result (if the xBestIndex() implementation is sane). */ if( rc==SQLITE_OK && ((mBest = (pNew->prereq & ~mPrereq))!=0 || bIn) ){ int seenZero = 0; /* True if a plan with no prereqs seen */ int seenZeroNoIN = 0; /* Plan with no prereqs and no IN(...) seen */ Bitmask mPrev = 0; Bitmask mBestNoIn = 0; /* If the plan produced by the earlier call uses an IN(...) term, call ** xBestIndex again, this time with IN(...) terms disabled. */ |
︙ | ︙ | |||
145424 145425 145426 145427 145428 145429 145430 145431 145432 145433 145434 145435 145436 145437 | p->nValue++; p->nStep = 0; } sqlite3_result_int64(pCtx, p->nValue); } } /* ** Implementation of built-in window function rank(). Assumes that ** the window frame has been set to: ** ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW */ static void rankStepFunc( | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 145554 145555 145556 145557 145558 145559 145560 145561 145562 145563 145564 145565 145566 145567 145568 145569 145570 145571 145572 145573 145574 145575 145576 145577 145578 145579 145580 145581 145582 145583 145584 145585 145586 145587 145588 145589 145590 145591 145592 145593 145594 145595 145596 145597 145598 145599 145600 145601 145602 145603 145604 145605 145606 145607 145608 145609 145610 145611 145612 145613 145614 145615 145616 145617 145618 145619 145620 145621 145622 145623 145624 145625 145626 145627 145628 145629 145630 145631 145632 145633 145634 145635 145636 145637 145638 145639 145640 145641 145642 145643 145644 145645 145646 145647 145648 145649 145650 145651 145652 145653 145654 145655 145656 145657 | p->nValue++; p->nStep = 0; } sqlite3_result_int64(pCtx, p->nValue); } } /* ** Implementation of built-in window function nth_value(). This ** implementation is used in "slow mode" only - when the EXCLUDE clause ** is not set to the default value "NO OTHERS". */ struct NthValueCtx { i64 nStep; sqlite3_value *pValue; }; static void nth_valueStepFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct NthValueCtx *p; p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p ){ i64 iVal; switch( sqlite3_value_numeric_type(apArg[1]) ){ case SQLITE_INTEGER: iVal = sqlite3_value_int64(apArg[1]); break; case SQLITE_FLOAT: { double fVal = sqlite3_value_double(apArg[1]); if( ((i64)fVal)!=fVal ) goto error_out; iVal = (i64)fVal; break; } default: goto error_out; } if( iVal<=0 ) goto error_out; p->nStep++; if( iVal==p->nStep ){ p->pValue = sqlite3_value_dup(apArg[0]); if( !p->pValue ){ sqlite3_result_error_nomem(pCtx); } } } UNUSED_PARAMETER(nArg); UNUSED_PARAMETER(apArg); return; error_out: sqlite3_result_error( pCtx, "second argument to nth_value must be a positive integer", -1 ); } static void nth_valueFinalizeFunc(sqlite3_context *pCtx){ struct NthValueCtx *p; p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, 0); if( p && p->pValue ){ sqlite3_result_value(pCtx, p->pValue); sqlite3_value_free(p->pValue); p->pValue = 0; } } #define nth_valueInvFunc noopStepFunc #define nth_valueValueFunc noopValueFunc static void first_valueStepFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct NthValueCtx *p; p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p && p->pValue==0 ){ p->pValue = sqlite3_value_dup(apArg[0]); if( !p->pValue ){ sqlite3_result_error_nomem(pCtx); } } UNUSED_PARAMETER(nArg); UNUSED_PARAMETER(apArg); } static void first_valueFinalizeFunc(sqlite3_context *pCtx){ struct NthValueCtx *p; p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p && p->pValue ){ sqlite3_result_value(pCtx, p->pValue); sqlite3_value_free(p->pValue); p->pValue = 0; } } #define first_valueInvFunc noopStepFunc #define first_valueValueFunc noopValueFunc /* ** Implementation of built-in window function rank(). Assumes that ** the window frame has been set to: ** ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW */ static void rankStepFunc( |
︙ | ︙ | |||
145459 145460 145461 145462 145463 145464 145465 | } } /* ** Implementation of built-in window function percent_rank(). Assumes that ** the window frame has been set to: ** | | | | | < | < < < | < > > > > > > > > > > > | < > | | | | < | < | > > > > > > > > > > | | > | | < | > > > > > > > > > > > | | > | 145679 145680 145681 145682 145683 145684 145685 145686 145687 145688 145689 145690 145691 145692 145693 145694 145695 145696 145697 145698 145699 145700 145701 145702 145703 145704 145705 145706 145707 145708 145709 145710 145711 145712 145713 145714 145715 145716 145717 145718 145719 145720 145721 145722 145723 145724 145725 145726 145727 145728 145729 145730 145731 145732 145733 145734 145735 145736 145737 145738 145739 145740 145741 145742 145743 145744 145745 145746 145747 145748 145749 145750 145751 145752 145753 145754 145755 145756 145757 145758 145759 145760 145761 145762 145763 145764 145765 145766 145767 145768 145769 145770 145771 145772 145773 145774 145775 145776 145777 145778 145779 145780 145781 145782 145783 145784 145785 145786 145787 145788 145789 145790 145791 145792 145793 145794 145795 145796 145797 145798 145799 145800 145801 145802 145803 145804 145805 145806 145807 145808 145809 145810 145811 145812 145813 145814 145815 145816 145817 145818 145819 145820 145821 145822 145823 145824 145825 145826 145827 145828 145829 145830 145831 145832 145833 145834 145835 145836 145837 145838 145839 145840 145841 145842 | } } /* ** Implementation of built-in window function percent_rank(). Assumes that ** the window frame has been set to: ** ** GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING */ static void percent_rankStepFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct CallCount *p; UNUSED_PARAMETER(nArg); assert( nArg==0 ); UNUSED_PARAMETER(apArg); p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p ){ p->nTotal++; } } static void percent_rankInvFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct CallCount *p; UNUSED_PARAMETER(nArg); assert( nArg==0 ); UNUSED_PARAMETER(apArg); p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); p->nStep++; } static void percent_rankValueFunc(sqlite3_context *pCtx){ struct CallCount *p; p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p ){ p->nValue = p->nStep; if( p->nTotal>1 ){ double r = (double)p->nValue / (double)(p->nTotal-1); sqlite3_result_double(pCtx, r); }else{ sqlite3_result_double(pCtx, 0.0); } } } #define percent_rankFinalizeFunc percent_rankValueFunc /* ** Implementation of built-in window function cume_dist(). Assumes that ** the window frame has been set to: ** ** GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING */ static void cume_distStepFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct CallCount *p; UNUSED_PARAMETER(nArg); assert( nArg==0 ); UNUSED_PARAMETER(apArg); p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p ){ p->nTotal++; } } static void cume_distInvFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct CallCount *p; UNUSED_PARAMETER(nArg); assert( nArg==0 ); UNUSED_PARAMETER(apArg); p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p)); p->nStep++; } static void cume_distValueFunc(sqlite3_context *pCtx){ struct CallCount *p; p = (struct CallCount*)sqlite3_aggregate_context(pCtx, 0); if( p ){ double r = (double)(p->nStep) / (double)(p->nTotal); sqlite3_result_double(pCtx, r); } } #define cume_distFinalizeFunc cume_distValueFunc /* ** Context object for ntile() window function. */ struct NtileCtx { i64 nTotal; /* Total rows in partition */ i64 nParam; /* Parameter passed to ntile(N) */ i64 iRow; /* Current row */ }; /* ** Implementation of ntile(). This assumes that the window frame has ** been coerced to: ** ** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING */ static void ntileStepFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct NtileCtx *p; assert( nArg==1 ); UNUSED_PARAMETER(nArg); p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p ){ if( p->nTotal==0 ){ p->nParam = sqlite3_value_int64(apArg[0]); if( p->nParam<=0 ){ sqlite3_result_error( pCtx, "argument of ntile must be a positive integer", -1 ); } } p->nTotal++; } } static void ntileInvFunc( sqlite3_context *pCtx, int nArg, sqlite3_value **apArg ){ struct NtileCtx *p; assert( nArg==1 ); UNUSED_PARAMETER(nArg); UNUSED_PARAMETER(apArg); p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); p->iRow++; } static void ntileValueFunc(sqlite3_context *pCtx){ struct NtileCtx *p; p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); if( p && p->nParam>0 ){ int nSize = (p->nTotal / p->nParam); if( nSize==0 ){ sqlite3_result_int64(pCtx, p->iRow+1); }else{ i64 nLarge = p->nTotal - p->nParam*nSize; i64 iSmall = nLarge*(nSize+1); i64 iRow = p->iRow; assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal ); if( iRow<iSmall ){ sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1)); }else{ sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize); } } } } #define ntileFinalizeFunc ntileValueFunc /* ** Context object for last_value() window function. */ struct LastValueCtx { sqlite3_value *pVal; int nVal; |
︙ | ︙ | |||
145632 145633 145634 145635 145636 145637 145638 | sqlite3_value_free(p->pVal); p->pVal = 0; } } } static void last_valueValueFunc(sqlite3_context *pCtx){ struct LastValueCtx *p; | | | 145878 145879 145880 145881 145882 145883 145884 145885 145886 145887 145888 145889 145890 145891 145892 | sqlite3_value_free(p->pVal); p->pVal = 0; } } } static void last_valueValueFunc(sqlite3_context *pCtx){ struct LastValueCtx *p; p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, 0); if( p && p->pVal ){ sqlite3_result_value(pCtx, p->pVal); } } static void last_valueFinalizeFunc(sqlite3_context *pCtx){ struct LastValueCtx *p; p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p)); |
︙ | ︙ | |||
145722 145723 145724 145725 145726 145727 145728 | ** Register those built-in window functions that are not also aggregates. */ SQLITE_PRIVATE void sqlite3WindowFunctions(void){ static FuncDef aWindowFuncs[] = { WINDOWFUNCX(row_number, 0, 0), WINDOWFUNCX(dense_rank, 0, 0), WINDOWFUNCX(rank, 0, 0), | | | | | | > > > > > > > > > > > | 145968 145969 145970 145971 145972 145973 145974 145975 145976 145977 145978 145979 145980 145981 145982 145983 145984 145985 145986 145987 145988 145989 145990 145991 145992 145993 145994 145995 145996 145997 145998 145999 146000 146001 146002 146003 146004 146005 146006 146007 | ** Register those built-in window functions that are not also aggregates. */ SQLITE_PRIVATE void sqlite3WindowFunctions(void){ static FuncDef aWindowFuncs[] = { WINDOWFUNCX(row_number, 0, 0), WINDOWFUNCX(dense_rank, 0, 0), WINDOWFUNCX(rank, 0, 0), WINDOWFUNCALL(percent_rank, 0, 0), WINDOWFUNCALL(cume_dist, 0, 0), WINDOWFUNCALL(ntile, 1, 0), WINDOWFUNCALL(last_value, 1, 0), WINDOWFUNCALL(nth_value, 2, 0), WINDOWFUNCALL(first_value, 1, 0), WINDOWFUNCNOOP(lead, 1, 0), WINDOWFUNCNOOP(lead, 2, 0), WINDOWFUNCNOOP(lead, 3, 0), WINDOWFUNCNOOP(lag, 1, 0), WINDOWFUNCNOOP(lag, 2, 0), WINDOWFUNCNOOP(lag, 3, 0), }; sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs)); } static Window *windowFind(Parse *pParse, Window *pList, const char *zName){ Window *p; for(p=pList; p; p=p->pNextWin){ if( sqlite3StrICmp(p->zName, zName)==0 ) break; } if( p==0 ){ sqlite3ErrorMsg(pParse, "no such window: %s", zName); } return p; } /* ** This function is called immediately after resolving the function name ** for a window function within a SELECT statement. Argument pList is a ** linked list of WINDOW definitions for the current SELECT statement. ** Argument pFunc is the function definition just resolved and pWin ** is the Window object representing the associated OVER clause. This |
︙ | ︙ | |||
145761 145762 145763 145764 145765 145766 145767 | */ SQLITE_PRIVATE void sqlite3WindowUpdate( Parse *pParse, Window *pList, /* List of named windows for this SELECT */ Window *pWin, /* Window frame to update */ FuncDef *pFunc /* Window function definition */ ){ | | | < < < | < < < | > > > > > > > > > > > | > | > | | | | > > > | > > | | | > | < < | | | | | | > > > > > > > | 146018 146019 146020 146021 146022 146023 146024 146025 146026 146027 146028 146029 146030 146031 146032 146033 146034 146035 146036 146037 146038 146039 146040 146041 146042 146043 146044 146045 146046 146047 146048 146049 146050 146051 146052 146053 146054 146055 146056 146057 146058 146059 146060 146061 146062 146063 146064 146065 146066 146067 146068 146069 146070 146071 146072 146073 146074 146075 146076 146077 146078 146079 146080 146081 146082 146083 146084 146085 146086 146087 146088 146089 146090 146091 | */ SQLITE_PRIVATE void sqlite3WindowUpdate( Parse *pParse, Window *pList, /* List of named windows for this SELECT */ Window *pWin, /* Window frame to update */ FuncDef *pFunc /* Window function definition */ ){ if( pWin->zName && pWin->eFrmType==0 ){ Window *p = windowFind(pParse, pList, pWin->zName); if( p==0 ) return; pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0); pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0); pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0); pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0); pWin->eStart = p->eStart; pWin->eEnd = p->eEnd; pWin->eFrmType = p->eFrmType; pWin->eExclude = p->eExclude; }else{ sqlite3WindowChain(pParse, pWin, pList); } if( (pWin->eFrmType==TK_RANGE) && (pWin->pStart || pWin->pEnd) && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1) ){ sqlite3ErrorMsg(pParse, "RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression" ); }else if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){ sqlite3 *db = pParse->db; if( pWin->pFilter ){ sqlite3ErrorMsg(pParse, "FILTER clause may only be used with aggregate window functions" ); }else{ struct WindowUpdate { const char *zFunc; int eFrmType; int eStart; int eEnd; } aUp[] = { { row_numberName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT }, { dense_rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT }, { rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT }, { percent_rankName, TK_GROUPS, TK_CURRENT, TK_UNBOUNDED }, { cume_distName, TK_GROUPS, TK_FOLLOWING, TK_UNBOUNDED }, { ntileName, TK_ROWS, TK_CURRENT, TK_UNBOUNDED }, { leadName, TK_ROWS, TK_UNBOUNDED, TK_UNBOUNDED }, { lagName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT }, }; int i; for(i=0; i<ArraySize(aUp); i++){ if( pFunc->zName==aUp[i].zFunc ){ sqlite3ExprDelete(db, pWin->pStart); sqlite3ExprDelete(db, pWin->pEnd); pWin->pEnd = pWin->pStart = 0; pWin->eFrmType = aUp[i].eFrmType; pWin->eStart = aUp[i].eStart; pWin->eEnd = aUp[i].eEnd; pWin->eExclude = 0; if( pWin->eStart==TK_FOLLOWING ){ pWin->pStart = sqlite3Expr(db, TK_INTEGER, "1"); } break; } } } } pWin->pFunc = pFunc; } /* ** Context object passed through sqlite3WalkExprList() to |
︙ | ︙ | |||
146007 146008 146009 146010 146011 146012 146013 146014 146015 146016 146017 146018 146019 146020 | } } /* Assign a cursor number for the ephemeral table used to buffer rows. ** The OpenEphemeral instruction is coded later, after it is known how ** many columns the table will have. */ pMWin->iEphCsr = pParse->nTab++; selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist); selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist); pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0); /* Append the PARTITION BY and ORDER BY expressions to the to the ** sub-select expression list. They are required to figure out where | > | 146282 146283 146284 146285 146286 146287 146288 146289 146290 146291 146292 146293 146294 146295 146296 | } } /* Assign a cursor number for the ephemeral table used to buffer rows. ** The OpenEphemeral instruction is coded later, after it is known how ** many columns the table will have. */ pMWin->iEphCsr = pParse->nTab++; pParse->nTab += 3; selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist); selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist); pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0); /* Append the PARTITION BY and ORDER BY expressions to the to the ** sub-select expression list. They are required to figure out where |
︙ | ︙ | |||
146062 146063 146064 146065 146066 146067 146068 146069 146070 146071 146072 146073 146074 146075 146076 146077 146078 146079 146080 146081 146082 146083 146084 146085 146086 146087 146088 146089 146090 146091 146092 146093 146094 146095 | }else{ pSub->selFlags |= SF_Expanded; p->selFlags &= ~SF_Aggregate; sqlite3SelectPrep(pParse, pSub, 0); } sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr); }else{ sqlite3SelectDelete(db, pSub); } if( db->mallocFailed ) rc = SQLITE_NOMEM; } return rc; } /* ** Free the Window object passed as the second argument. */ SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){ if( p ){ sqlite3ExprDelete(db, p->pFilter); sqlite3ExprListDelete(db, p->pPartition); sqlite3ExprListDelete(db, p->pOrderBy); sqlite3ExprDelete(db, p->pEnd); sqlite3ExprDelete(db, p->pStart); sqlite3DbFree(db, p->zName); sqlite3DbFree(db, p); } } /* ** Free the linked list of Window objects starting at the second argument. */ | > > > > | 146338 146339 146340 146341 146342 146343 146344 146345 146346 146347 146348 146349 146350 146351 146352 146353 146354 146355 146356 146357 146358 146359 146360 146361 146362 146363 146364 146365 146366 146367 146368 146369 146370 146371 146372 146373 146374 146375 | }else{ pSub->selFlags |= SF_Expanded; p->selFlags &= ~SF_Aggregate; sqlite3SelectPrep(pParse, pSub, 0); } sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr); sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr); sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+2, pMWin->iEphCsr); sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+3, pMWin->iEphCsr); }else{ sqlite3SelectDelete(db, pSub); } if( db->mallocFailed ) rc = SQLITE_NOMEM; } return rc; } /* ** Free the Window object passed as the second argument. */ SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){ if( p ){ sqlite3ExprDelete(db, p->pFilter); sqlite3ExprListDelete(db, p->pPartition); sqlite3ExprListDelete(db, p->pOrderBy); sqlite3ExprDelete(db, p->pEnd); sqlite3ExprDelete(db, p->pStart); sqlite3DbFree(db, p->zName); sqlite3DbFree(db, p->zBase); sqlite3DbFree(db, p); } } /* ** Free the linked list of Window objects starting at the second argument. */ |
︙ | ︙ | |||
146118 146119 146120 146121 146122 146123 146124 | } /* ** Allocate and return a new Window object describing a Window Definition. */ SQLITE_PRIVATE Window *sqlite3WindowAlloc( Parse *pParse, /* Parsing context */ | | | > > | | | < < | < < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 146398 146399 146400 146401 146402 146403 146404 146405 146406 146407 146408 146409 146410 146411 146412 146413 146414 146415 146416 146417 146418 146419 146420 146421 146422 146423 146424 146425 146426 146427 146428 146429 146430 146431 146432 146433 146434 146435 146436 146437 146438 146439 146440 146441 146442 146443 146444 146445 146446 146447 146448 146449 146450 146451 146452 146453 146454 146455 146456 146457 146458 146459 146460 146461 146462 146463 146464 146465 146466 146467 146468 146469 146470 146471 146472 146473 146474 146475 146476 146477 146478 146479 146480 146481 146482 146483 146484 146485 146486 146487 146488 146489 146490 146491 146492 146493 146494 146495 146496 146497 146498 146499 146500 146501 146502 146503 146504 146505 146506 146507 146508 146509 146510 146511 146512 146513 146514 146515 146516 146517 146518 146519 146520 146521 146522 146523 146524 146525 146526 146527 146528 146529 146530 146531 146532 146533 146534 146535 146536 146537 146538 | } /* ** Allocate and return a new Window object describing a Window Definition. */ SQLITE_PRIVATE Window *sqlite3WindowAlloc( Parse *pParse, /* Parsing context */ int eType, /* Frame type. TK_RANGE, TK_ROWS, TK_GROUPS, or 0 */ int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */ Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */ int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */ Expr *pEnd, /* End window size if TK_FOLLOWING or PRECEDING */ u8 eExclude /* EXCLUDE clause */ ){ Window *pWin = 0; int bImplicitFrame = 0; /* Parser assures the following: */ assert( eType==0 || eType==TK_RANGE || eType==TK_ROWS || eType==TK_GROUPS ); assert( eStart==TK_CURRENT || eStart==TK_PRECEDING || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING ); assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING ); assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) ); assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) ); if( eType==0 ){ bImplicitFrame = 1; eType = TK_RANGE; } /* Additionally, the ** starting boundary type may not occur earlier in the following list than ** the ending boundary type: ** ** UNBOUNDED PRECEDING ** <expr> PRECEDING ** CURRENT ROW ** <expr> FOLLOWING ** UNBOUNDED FOLLOWING ** ** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending ** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting ** frame boundary. */ if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING) || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT)) ){ sqlite3ErrorMsg(pParse, "unsupported frame specification"); goto windowAllocErr; } pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( pWin==0 ) goto windowAllocErr; pWin->eFrmType = eType; pWin->eStart = eStart; pWin->eEnd = eEnd; if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_WindowFunc) ){ eExclude = TK_NO; } pWin->eExclude = eExclude; pWin->bImplicitFrame = bImplicitFrame; pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd); pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart); return pWin; windowAllocErr: sqlite3ExprDelete(pParse->db, pEnd); sqlite3ExprDelete(pParse->db, pStart); return 0; } /* ** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window ** pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the ** equivalent nul-terminated string. */ SQLITE_PRIVATE Window *sqlite3WindowAssemble( Parse *pParse, Window *pWin, ExprList *pPartition, ExprList *pOrderBy, Token *pBase ){ if( pWin ){ pWin->pPartition = pPartition; pWin->pOrderBy = pOrderBy; if( pBase ){ pWin->zBase = sqlite3DbStrNDup(pParse->db, pBase->z, pBase->n); } }else{ sqlite3ExprListDelete(pParse->db, pPartition); sqlite3ExprListDelete(pParse->db, pOrderBy); } return pWin; } /* ** Window *pWin has just been created from a WINDOW clause. Tokne pBase ** is the base window. Earlier windows from the same WINDOW clause are ** stored in the linked list starting at pWin->pNextWin. This function ** either updates *pWin according to the base specification, or else ** leaves an error in pParse. */ SQLITE_PRIVATE void sqlite3WindowChain(Parse *pParse, Window *pWin, Window *pList){ if( pWin->zBase ){ sqlite3 *db = pParse->db; Window *pExist = windowFind(pParse, pList, pWin->zBase); if( pExist ){ const char *zErr = 0; /* Check for errors */ if( pWin->pPartition ){ zErr = "PARTITION clause"; }else if( pExist->pOrderBy && pWin->pOrderBy ){ zErr = "ORDER BY clause"; }else if( pExist->bImplicitFrame==0 ){ zErr = "frame specification"; } if( zErr ){ sqlite3ErrorMsg(pParse, "cannot override %s of window: %s", zErr, pWin->zBase ); }else{ pWin->pPartition = sqlite3ExprListDup(db, pExist->pPartition, 0); if( pExist->pOrderBy ){ assert( pWin->pOrderBy==0 ); pWin->pOrderBy = sqlite3ExprListDup(db, pExist->pOrderBy, 0); } sqlite3DbFree(db, pWin->zBase); pWin->zBase = 0; } } } } /* ** Attach window object pWin to expression p. */ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ if( p ){ assert( p->op==TK_FUNCTION ); |
︙ | ︙ | |||
146208 146209 146210 146211 146212 146213 146214 | } /* ** Return 0 if the two window objects are identical, or non-zero otherwise. ** Identical window objects can be processed in a single scan. */ SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){ | | > | > > | | | | > > > > > > > > > > > > > | 146554 146555 146556 146557 146558 146559 146560 146561 146562 146563 146564 146565 146566 146567 146568 146569 146570 146571 146572 146573 146574 146575 146576 146577 146578 146579 146580 146581 146582 146583 146584 146585 146586 146587 146588 146589 146590 146591 146592 146593 146594 146595 146596 146597 146598 146599 146600 146601 146602 146603 146604 146605 146606 146607 146608 | } /* ** Return 0 if the two window objects are identical, or non-zero otherwise. ** Identical window objects can be processed in a single scan. */ SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){ if( p1->eFrmType!=p2->eFrmType ) return 1; if( p1->eStart!=p2->eStart ) return 1; if( p1->eEnd!=p2->eEnd ) return 1; if( p1->eExclude!=p2->eExclude ) return 1; if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1; if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1; if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1; if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1; return 0; } /* ** This is called by code in select.c before it calls sqlite3WhereBegin() ** to begin iterating through the sub-query results. It is used to allocate ** and initialize registers and cursors used by sqlite3WindowCodeStep(). */ SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){ Window *pWin; Vdbe *v = sqlite3GetVdbe(pParse); /* Allocate registers to use for PARTITION BY values, if any. Initialize ** said registers to NULL. */ if( pMWin->pPartition ){ int nExpr = pMWin->pPartition->nExpr; pMWin->regPart = pParse->nMem+1; pParse->nMem += nExpr; sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nExpr-1); } pMWin->regOne = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regOne); if( pMWin->eExclude ){ pMWin->regStartRowid = ++pParse->nMem; pMWin->regEndRowid = ++pParse->nMem; pMWin->csrApp = pParse->nTab++; sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid); sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid); sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr); return; } for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *p = pWin->pFunc; if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){ /* The inline versions of min() and max() require a single ephemeral ** table and 3 registers. The registers are used as follows: |
︙ | ︙ | |||
146261 146262 146263 146264 146265 146266 146267 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2); sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO); sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1); } else if( p->zName==nth_valueName || p->zName==first_valueName ){ /* Allocate two registers at pWin->regApp. These will be used to ** store the start and end index of the current frame. */ | < < > > > > > > | | > > | | > > > > > > > > > > | > > | | | > | | > > | 146623 146624 146625 146626 146627 146628 146629 146630 146631 146632 146633 146634 146635 146636 146637 146638 146639 146640 146641 146642 146643 146644 146645 146646 146647 146648 146649 146650 146651 146652 146653 146654 146655 146656 146657 146658 146659 146660 146661 146662 146663 146664 146665 146666 146667 146668 146669 146670 146671 146672 146673 146674 146675 146676 146677 146678 146679 146680 146681 146682 146683 146684 146685 146686 146687 146688 146689 146690 146691 146692 146693 146694 146695 146696 146697 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2); sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO); sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1); } else if( p->zName==nth_valueName || p->zName==first_valueName ){ /* Allocate two registers at pWin->regApp. These will be used to ** store the start and end index of the current frame. */ pWin->regApp = pParse->nMem+1; pWin->csrApp = pParse->nTab++; pParse->nMem += 2; sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr); } else if( p->zName==leadName || p->zName==lagName ){ pWin->csrApp = pParse->nTab++; sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr); } } } #define WINDOW_STARTING_INT 0 #define WINDOW_ENDING_INT 1 #define WINDOW_NTH_VALUE_INT 2 #define WINDOW_STARTING_NUM 3 #define WINDOW_ENDING_NUM 4 /* ** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the ** value of the second argument to nth_value() (eCond==2) has just been ** evaluated and the result left in register reg. This function generates VM ** code to check that the value is a non-negative integer and throws an ** exception if it is not. */ static void windowCheckValue(Parse *pParse, int reg, int eCond){ static const char *azErr[] = { "frame starting offset must be a non-negative integer", "frame ending offset must be a non-negative integer", "second argument to nth_value must be a positive integer", "frame starting offset must be a non-negative number", "frame ending offset must be a non-negative number", }; static int aOp[] = { OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge }; Vdbe *v = sqlite3GetVdbe(pParse); int regZero = sqlite3GetTempReg(pParse); assert( eCond>=0 && eCond<ArraySize(azErr) ); sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero); if( eCond>=WINDOW_STARTING_NUM ){ int regString = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC); sqlite3VdbeAddOp3(v, OP_Ge, regString, sqlite3VdbeCurrentAddr(v)+2, reg); sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC|SQLITE_JUMPIFNULL); VdbeCoverage(v); assert( eCond==3 || eCond==4 ); VdbeCoverageIf(v, eCond==3); VdbeCoverageIf(v, eCond==4); }else{ sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2); VdbeCoverage(v); assert( eCond==0 || eCond==1 || eCond==2 ); VdbeCoverageIf(v, eCond==0); VdbeCoverageIf(v, eCond==1); VdbeCoverageIf(v, eCond==2); } sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg); VdbeCoverageNeverNullIf(v, eCond==0); /* NULL case captured by */ VdbeCoverageNeverNullIf(v, eCond==1); /* the OP_MustBeInt */ VdbeCoverageNeverNullIf(v, eCond==2); VdbeCoverageNeverNullIf(v, eCond==3); /* NULL case caught by */ VdbeCoverageNeverNullIf(v, eCond==4); /* the OP_Ge */ sqlite3MayAbort(pParse); sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort); sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC); sqlite3ReleaseTempReg(pParse, regZero); } /* |
︙ | ︙ | |||
146340 146341 146342 146343 146344 146345 146346 | ** number of rows in the current partition. */ static void windowAggStep( Parse *pParse, Window *pMWin, /* Linked list of window functions */ int csr, /* Read arguments from this cursor */ int bInverse, /* True to invoke xInverse instead of xStep */ | | < | < < | > | > < < < < < | | | < | < < | | | | | | | | < < < < < | | < < < < | | < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > | | < < < > > | | | < | | | > | > | < < < < < < | | | > > > > | | > > > > > | > > | > | > > > | < < < < < | > | > | | | > > > > > > | | > > > > | | | | | > > > > > > | | > | | < > | > | > | > | > > > | > > > > | < < < < < > | < | > | | | > | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | > | | | | | | | | | | | | | | | | | | | | | | | | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < > | < < | | | | | | | > < | < < < < < < < < < < < > | < | < < < < > | < < < < < < < < < < | < | < < < < < < < > < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < | > > | | < < < > > | < > | < > | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > > < < | < < < < | < | | < < < < < < < | | < < < < > > | < < < < | | < | | < | < < | < < | | < < < < < < | < < < < < < < < < < | < | | < < | > > | | < < < < < < < < | < < | | < < < < | < | | | | < < < < < < | < < < | < | < < < < | < < < < | < | < < | < | < < < | < < < < < < < < < < < < | | | < | < < < < < < < < | | < < > < < > < < | < > > | | > | | | | < | > > > > > > > | > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < > | | > | | < | | | | | < < < < < | < > | > | < < < < < | < < < | < < > | < < < < < < < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | | > > | > | > < < < < < < | < < < < | | | < > | < > > | | > > | < < | < | < | < | | < < | < < > | | < | < > < < < < < < | < < | < < < < | | < > | < < < < < < < < < < < < < < | | < < < > | | > > | > > > | | | < < > > | | | | | | | < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < | < < < | < < < | < | < < < | < < | < < < < < | | < | | | | < < < < < < < < < < < < < < | < < < | < < < < < | < | | < | | < < | < < < < | < | | | < | | < < < < < < | | > | 146723 146724 146725 146726 146727 146728 146729 146730 146731 146732 146733 146734 146735 146736 146737 146738 146739 146740 146741 146742 146743 146744 146745 146746 146747 146748 146749 146750 146751 146752 146753 146754 146755 146756 146757 146758 146759 146760 146761 146762 146763 146764 146765 146766 146767 146768 146769 146770 146771 146772 146773 146774 146775 146776 146777 146778 146779 146780 146781 146782 146783 146784 146785 146786 146787 146788 146789 146790 146791 146792 146793 146794 146795 146796 146797 146798 146799 146800 146801 146802 146803 146804 146805 146806 146807 146808 146809 146810 146811 146812 146813 146814 146815 146816 146817 146818 146819 146820 146821 146822 146823 146824 146825 146826 146827 146828 146829 146830 146831 146832 146833 146834 146835 146836 146837 146838 146839 146840 146841 146842 146843 146844 146845 146846 146847 146848 146849 146850 146851 146852 146853 146854 146855 146856 146857 146858 146859 146860 146861 146862 146863 146864 146865 146866 146867 146868 146869 146870 146871 146872 146873 146874 146875 146876 146877 146878 146879 146880 146881 146882 146883 146884 146885 146886 146887 146888 146889 146890 146891 146892 146893 146894 146895 146896 146897 146898 146899 146900 146901 146902 146903 146904 146905 146906 146907 146908 146909 146910 146911 146912 146913 146914 146915 146916 146917 146918 146919 146920 146921 146922 146923 146924 146925 146926 146927 146928 146929 146930 146931 146932 146933 146934 146935 146936 146937 146938 146939 146940 146941 146942 146943 146944 146945 146946 146947 146948 146949 146950 146951 146952 146953 146954 146955 146956 146957 146958 146959 146960 146961 146962 146963 146964 146965 146966 146967 146968 146969 146970 146971 146972 146973 146974 146975 146976 146977 146978 146979 146980 146981 146982 146983 146984 146985 146986 146987 146988 146989 146990 146991 146992 146993 146994 146995 146996 146997 146998 146999 147000 147001 147002 147003 147004 147005 147006 147007 147008 147009 147010 147011 147012 147013 147014 147015 147016 147017 147018 147019 147020 147021 147022 147023 147024 147025 147026 147027 147028 147029 147030 147031 147032 147033 147034 147035 147036 147037 147038 147039 147040 147041 147042 147043 147044 147045 147046 147047 147048 147049 147050 147051 147052 147053 147054 147055 147056 147057 147058 147059 147060 147061 147062 147063 147064 147065 147066 147067 147068 147069 147070 147071 147072 147073 147074 147075 147076 147077 147078 147079 147080 147081 147082 147083 147084 147085 147086 147087 147088 147089 147090 147091 147092 147093 147094 147095 147096 147097 147098 147099 147100 147101 147102 147103 147104 147105 147106 147107 147108 147109 147110 147111 147112 147113 147114 147115 147116 147117 147118 147119 147120 147121 147122 147123 147124 147125 147126 147127 147128 147129 147130 147131 147132 147133 147134 147135 147136 147137 147138 147139 147140 147141 147142 147143 147144 147145 147146 147147 147148 147149 147150 147151 147152 147153 147154 147155 147156 147157 147158 147159 147160 147161 147162 147163 147164 147165 147166 147167 147168 147169 147170 147171 147172 147173 147174 147175 147176 147177 147178 147179 147180 147181 147182 147183 147184 147185 147186 147187 147188 147189 147190 147191 147192 147193 147194 147195 147196 147197 147198 147199 147200 147201 147202 147203 147204 147205 147206 147207 147208 147209 147210 147211 147212 147213 147214 147215 147216 147217 147218 147219 147220 147221 147222 147223 147224 147225 147226 147227 147228 147229 147230 147231 147232 147233 147234 147235 147236 147237 147238 147239 147240 147241 147242 147243 147244 147245 147246 147247 147248 147249 147250 147251 147252 147253 147254 147255 147256 147257 147258 147259 147260 147261 147262 147263 147264 147265 147266 147267 147268 147269 147270 147271 147272 147273 147274 147275 147276 147277 147278 147279 147280 147281 147282 147283 147284 147285 147286 147287 147288 147289 147290 147291 147292 147293 147294 147295 147296 147297 147298 147299 147300 147301 147302 147303 147304 147305 147306 147307 147308 147309 147310 147311 147312 147313 147314 147315 147316 147317 147318 147319 147320 147321 147322 147323 147324 147325 147326 147327 147328 147329 147330 147331 147332 147333 147334 147335 147336 147337 147338 147339 147340 147341 147342 147343 147344 147345 147346 147347 147348 147349 147350 147351 147352 147353 147354 147355 147356 147357 147358 147359 147360 147361 147362 147363 147364 147365 147366 | ** number of rows in the current partition. */ static void windowAggStep( Parse *pParse, Window *pMWin, /* Linked list of window functions */ int csr, /* Read arguments from this cursor */ int bInverse, /* True to invoke xInverse instead of xStep */ int reg /* Array of registers */ ){ Vdbe *v = sqlite3GetVdbe(pParse); Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pFunc; int regArg; int nArg = windowArgCount(pWin); int i; for(i=0; i<nArg; i++){ if( i!=1 || pFunc->zName!=nth_valueName ){ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i); }else{ sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i); } } regArg = reg; if( pMWin->regStartRowid==0 && (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && (pWin->eStart!=TK_UNBOUNDED) ){ int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg); VdbeCoverage(v); if( bInverse==0 ){ sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1); sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp); sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2); sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2); }else{ sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1); VdbeCoverageNeverTaken(v); sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); } sqlite3VdbeJumpHere(v, addrIsNull); }else if( pWin->regApp ){ assert( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ); assert( bInverse==0 || bInverse==1 ); sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1); }else if( pFunc->xSFunc!=noopStepFunc ){ int addrIf = 0; if( pWin->pFilter ){ int regTmp; assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr ); assert( nArg || pWin->pOwner->x.pList==0 ); regTmp = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp); addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1); VdbeCoverage(v); sqlite3ReleaseTempReg(pParse, regTmp); } if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ CollSeq *pColl; assert( nArg>0 ); pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr); sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ); } sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep, bInverse, regArg, pWin->regAccum); sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF); sqlite3VdbeChangeP5(v, (u8)nArg); if( addrIf ) sqlite3VdbeJumpHere(v, addrIf); } } } typedef struct WindowCodeArg WindowCodeArg; typedef struct WindowCsrAndReg WindowCsrAndReg; struct WindowCsrAndReg { int csr; int reg; }; struct WindowCodeArg { Parse *pParse; Window *pMWin; Vdbe *pVdbe; int regGosub; int addrGosub; int regArg; int eDelete; WindowCsrAndReg start; WindowCsrAndReg current; WindowCsrAndReg end; }; /* ** Values that may be passed as the second argument to windowCodeOp(). */ #define WINDOW_RETURN_ROW 1 #define WINDOW_AGGINVERSE 2 #define WINDOW_AGGSTEP 3 /* ** Generate VM code to read the window frames peer values from cursor csr into ** an array of registers starting at reg. */ static void windowReadPeerValues( WindowCodeArg *p, int csr, int reg ){ Window *pMWin = p->pMWin; ExprList *pOrderBy = pMWin->pOrderBy; if( pOrderBy ){ Vdbe *v = sqlite3GetVdbe(p->pParse); ExprList *pPart = pMWin->pPartition; int iColOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0); int i; for(i=0; i<pOrderBy->nExpr; i++){ sqlite3VdbeAddOp3(v, OP_Column, csr, iColOff+i, reg+i); } } } /* ** Generate VM code to invoke either xValue() (bFin==0) or xFinalize() ** (bFin==1) for each window function in the linked list starting at ** pMWin. Or, for built-in window-functions that do not use the standard ** API, generate the equivalent VM code. */ static void windowAggFinal(WindowCodeArg *p, int bFin){ Parse *pParse = p->pParse; Window *pMWin = p->pMWin; Vdbe *v = sqlite3GetVdbe(pParse); Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ if( pMWin->regStartRowid==0 && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) && (pWin->eStart!=TK_UNBOUNDED) ){ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult); sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); }else if( pWin->regApp ){ assert( pMWin->regStartRowid==0 ); }else{ int nArg = windowArgCount(pWin); if( bFin ){ sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg); sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF); sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult); sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum); }else{ sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult); sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF); } } } } /* ** Generate code to calculate the current values of all window functions in the ** p->pMWin list by doing a full scan of the current window frame. Store the ** results in the Window.regResult registers, ready to return the upper ** layer. */ static void windowFullScan(WindowCodeArg *p){ Window *pWin; Parse *pParse = p->pParse; Window *pMWin = p->pMWin; Vdbe *v = p->pVdbe; int regCRowid = 0; /* Current rowid value */ int regCPeer = 0; /* Current peer values */ int regRowid = 0; /* AggStep rowid value */ int regPeer = 0; /* AggStep peer values */ int nPeer; int lblNext; int lblBrk; int addrNext; int csr = pMWin->csrApp; nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0); lblNext = sqlite3VdbeMakeLabel(pParse); lblBrk = sqlite3VdbeMakeLabel(pParse); regCRowid = sqlite3GetTempReg(pParse); regRowid = sqlite3GetTempReg(pParse); if( nPeer ){ regCPeer = sqlite3GetTempRange(pParse, nPeer); regPeer = sqlite3GetTempRange(pParse, nPeer); } sqlite3VdbeAddOp2(v, OP_Rowid, pMWin->iEphCsr, regCRowid); windowReadPeerValues(p, pMWin->iEphCsr, regCPeer); for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum); } sqlite3VdbeAddOp3(v, OP_SeekGE, csr, lblBrk, pMWin->regStartRowid); VdbeCoverage(v); addrNext = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp2(v, OP_Rowid, csr, regRowid); sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, lblBrk, regRowid); VdbeCoverageNeverNull(v); if( pMWin->eExclude==TK_CURRENT ){ sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid); VdbeCoverageNeverNull(v); }else if( pMWin->eExclude!=TK_NO ){ int addr; int addrEq = 0; KeyInfo *pKeyInfo = 0; if( pMWin->pOrderBy ){ pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy, 0, 0); } if( pMWin->eExclude==TK_TIES ){ addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, 0, regRowid); VdbeCoverageNeverNull(v); } if( pKeyInfo ){ windowReadPeerValues(p, csr, regPeer); sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer); sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO); addr = sqlite3VdbeCurrentAddr(v)+1; sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr); VdbeCoverageEqNe(v); }else{ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblNext); } if( addrEq ) sqlite3VdbeJumpHere(v, addrEq); } windowAggStep(pParse, pMWin, csr, 0, p->regArg); sqlite3VdbeResolveLabel(v, lblNext); sqlite3VdbeAddOp2(v, OP_Next, csr, addrNext); VdbeCoverage(v); sqlite3VdbeJumpHere(v, addrNext-1); sqlite3VdbeJumpHere(v, addrNext+1); sqlite3ReleaseTempReg(pParse, regRowid); sqlite3ReleaseTempReg(pParse, regCRowid); if( nPeer ){ sqlite3ReleaseTempRange(pParse, regPeer, nPeer); sqlite3ReleaseTempRange(pParse, regCPeer, nPeer); } windowAggFinal(p, 1); } /* ** Invoke the sub-routine at regGosub (generated by code in select.c) to ** return the current row of Window.iEphCsr. If all window functions are ** aggregate window functions that use the standard API, a single ** OP_Gosub instruction is all that this routine generates. Extra VM code ** for per-row processing is only generated for the following built-in window ** functions: ** ** nth_value() ** first_value() ** lag() ** lead() */ static void windowReturnOneRow(WindowCodeArg *p){ Window *pMWin = p->pMWin; Vdbe *v = p->pVdbe; if( pMWin->regStartRowid ){ windowFullScan(p); }else{ Parse *pParse = p->pParse; Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pFunc; if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){ int csr = pWin->csrApp; int lbl = sqlite3VdbeMakeLabel(pParse); int tmpReg = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult); if( pFunc->zName==nth_valueName ){ sqlite3VdbeAddOp3(v, OP_Column,pMWin->iEphCsr,pWin->iArgCol+1,tmpReg); windowCheckValue(pParse, tmpReg, 2); }else{ sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg); } sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg); sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg); VdbeCoverageNeverNull(v); sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg); VdbeCoverageNeverTaken(v); sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult); sqlite3VdbeResolveLabel(v, lbl); sqlite3ReleaseTempReg(pParse, tmpReg); } else if( pFunc->zName==leadName || pFunc->zName==lagName ){ int nArg = pWin->pOwner->x.pList->nExpr; int csr = pWin->csrApp; int lbl = sqlite3VdbeMakeLabel(pParse); int tmpReg = sqlite3GetTempReg(pParse); int iEph = pMWin->iEphCsr; if( nArg<3 ){ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult); }else{ sqlite3VdbeAddOp3(v, OP_Column, iEph,pWin->iArgCol+2,pWin->regResult); } sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg); if( nArg<2 ){ int val = (pFunc->zName==leadName ? 1 : -1); sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val); }else{ int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract); int tmpReg2 = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2); sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg); sqlite3ReleaseTempReg(pParse, tmpReg2); } sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult); sqlite3VdbeResolveLabel(v, lbl); sqlite3ReleaseTempReg(pParse, tmpReg); } } } sqlite3VdbeAddOp2(v, OP_Gosub, p->regGosub, p->addrGosub); } /* ** Generate code to set the accumulator register for each window function ** in the linked list passed as the second argument to NULL. And perform ** any equivalent initialization required by any built-in window functions ** in the list. */ static int windowInitAccum(Parse *pParse, Window *pMWin){ Vdbe *v = sqlite3GetVdbe(pParse); int regArg; int nArg = 0; Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pFunc; sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum); nArg = MAX(nArg, windowArgCount(pWin)); if( pMWin->regStartRowid==0 ){ if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp); sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1); } if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){ assert( pWin->eStart!=TK_UNBOUNDED ); sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp); sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1); } } } regArg = pParse->nMem+1; pParse->nMem += nArg; return regArg; } /* ** Return true if the current frame should be cached in the ephemeral table, ** even if there are no xInverse() calls required. */ static int windowCacheFrame(Window *pMWin){ Window *pWin; if( pMWin->regStartRowid ) return 1; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pFunc; if( (pFunc->zName==nth_valueName) || (pFunc->zName==first_valueName) || (pFunc->zName==leadName) || (pFunc->zName==lagName) ){ return 1; } } return 0; } /* ** regOld and regNew are each the first register in an array of size ** pOrderBy->nExpr. This function generates code to compare the two ** arrays of registers using the collation sequences and other comparison ** parameters specified by pOrderBy. ** ** If the two arrays are not equal, the contents of regNew is copied to ** regOld and control falls through. Otherwise, if the contents of the arrays ** are equal, an OP_Goto is executed. The address of the OP_Goto is returned. */ static void windowIfNewPeer( Parse *pParse, ExprList *pOrderBy, int regNew, /* First in array of new values */ int regOld, /* First in array of old values */ int addr /* Jump here */ ){ Vdbe *v = sqlite3GetVdbe(pParse); if( pOrderBy ){ int nVal = pOrderBy->nExpr; KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0); sqlite3VdbeAddOp3(v, OP_Compare, regOld, regNew, nVal); sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO); sqlite3VdbeAddOp3(v, OP_Jump, sqlite3VdbeCurrentAddr(v)+1, addr, sqlite3VdbeCurrentAddr(v)+1 ); VdbeCoverageEqNe(v); sqlite3VdbeAddOp3(v, OP_Copy, regNew, regOld, nVal-1); }else{ sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); } } /* ** This function is called as part of generating VM programs for RANGE ** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for ** the ORDER BY term in the window, it generates code equivalent to: ** ** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl; ** ** A special type of arithmetic is used such that if csr.peerVal is not ** a numeric type (real or integer), then the result of the addition is ** a copy of csr1.peerVal. */ static void windowCodeRangeTest( WindowCodeArg *p, int op, /* OP_Ge or OP_Gt */ int csr1, int regVal, int csr2, int lbl ){ Parse *pParse = p->pParse; Vdbe *v = sqlite3GetVdbe(pParse); int reg1 = sqlite3GetTempReg(pParse); int reg2 = sqlite3GetTempReg(pParse); int arith = OP_Add; int addrGe; int regString = ++pParse->nMem; assert( op==OP_Ge || op==OP_Gt || op==OP_Le ); assert( p->pMWin->pOrderBy && p->pMWin->pOrderBy->nExpr==1 ); if( p->pMWin->pOrderBy->a[0].sortOrder ){ switch( op ){ case OP_Ge: op = OP_Le; break; case OP_Gt: op = OP_Lt; break; default: assert( op==OP_Le ); op = OP_Ge; break; } arith = OP_Subtract; } windowReadPeerValues(p, csr1, reg1); windowReadPeerValues(p, csr2, reg2); /* Check if the peer value for csr1 value is a text or blob by comparing ** it to the smallest possible string - ''. If it is, jump over the ** OP_Add or OP_Subtract operation and proceed directly to the comparison. */ sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC); addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1); VdbeCoverage(v); sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1); sqlite3VdbeJumpHere(v, addrGe); sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v); sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le ); testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge); testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt); testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le); testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt); sqlite3ReleaseTempReg(pParse, reg1); sqlite3ReleaseTempReg(pParse, reg2); } /* ** Helper function for sqlite3WindowCodeStep(). Each call to this function ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE ** operation. Refer to the header comment for sqlite3WindowCodeStep() for ** details. */ static int windowCodeOp( WindowCodeArg *p, /* Context object */ int op, /* WINDOW_RETURN_ROW, AGGSTEP or AGGINVERSE */ int regCountdown, /* Register for OP_IfPos countdown */ int jumpOnEof /* Jump here if stepped cursor reaches EOF */ ){ int csr, reg; Parse *pParse = p->pParse; Window *pMWin = p->pMWin; int ret = 0; Vdbe *v = p->pVdbe; int addrIf = 0; int addrContinue = 0; int addrGoto = 0; int bPeer = (pMWin->eFrmType!=TK_ROWS); int lblDone = sqlite3VdbeMakeLabel(pParse); int addrNextRange = 0; /* Special case - WINDOW_AGGINVERSE is always a no-op if the frame ** starts with UNBOUNDED PRECEDING. */ if( op==WINDOW_AGGINVERSE && pMWin->eStart==TK_UNBOUNDED ){ assert( regCountdown==0 && jumpOnEof==0 ); return 0; } if( regCountdown>0 ){ if( pMWin->eFrmType==TK_RANGE ){ addrNextRange = sqlite3VdbeCurrentAddr(v); assert( op==WINDOW_AGGINVERSE || op==WINDOW_AGGSTEP ); if( op==WINDOW_AGGINVERSE ){ if( pMWin->eStart==TK_FOLLOWING ){ windowCodeRangeTest( p, OP_Le, p->current.csr, regCountdown, p->start.csr, lblDone ); }else{ windowCodeRangeTest( p, OP_Ge, p->start.csr, regCountdown, p->current.csr, lblDone ); } }else{ windowCodeRangeTest( p, OP_Gt, p->end.csr, regCountdown, p->current.csr, lblDone ); } }else{ addrIf = sqlite3VdbeAddOp3(v, OP_IfPos, regCountdown, 0, 1); VdbeCoverage(v); } } if( op==WINDOW_RETURN_ROW && pMWin->regStartRowid==0 ){ windowAggFinal(p, 0); } addrContinue = sqlite3VdbeCurrentAddr(v); switch( op ){ case WINDOW_RETURN_ROW: csr = p->current.csr; reg = p->current.reg; windowReturnOneRow(p); break; case WINDOW_AGGINVERSE: csr = p->start.csr; reg = p->start.reg; if( pMWin->regStartRowid ){ assert( pMWin->regEndRowid ); sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regStartRowid, 1); }else{ windowAggStep(pParse, pMWin, csr, 1, p->regArg); } break; default: assert( op==WINDOW_AGGSTEP ); csr = p->end.csr; reg = p->end.reg; if( pMWin->regStartRowid ){ assert( pMWin->regEndRowid ); sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regEndRowid, 1); }else{ windowAggStep(pParse, pMWin, csr, 0, p->regArg); } break; } if( op==p->eDelete ){ sqlite3VdbeAddOp1(v, OP_Delete, csr); sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION); } if( jumpOnEof ){ sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+2); VdbeCoverage(v); ret = sqlite3VdbeAddOp0(v, OP_Goto); }else{ sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+1+bPeer); VdbeCoverage(v); if( bPeer ){ addrGoto = sqlite3VdbeAddOp0(v, OP_Goto); } } if( bPeer ){ int nReg = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0); int regTmp = (nReg ? sqlite3GetTempRange(pParse, nReg) : 0); windowReadPeerValues(p, csr, regTmp); windowIfNewPeer(pParse, pMWin->pOrderBy, regTmp, reg, addrContinue); sqlite3ReleaseTempRange(pParse, regTmp, nReg); } if( addrNextRange ){ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNextRange); } sqlite3VdbeResolveLabel(v, lblDone); if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto); if( addrIf ) sqlite3VdbeJumpHere(v, addrIf); return ret; } /* ** Allocate and return a duplicate of the Window object indicated by the ** third argument. Set the Window.pOwner field of the new object to ** pOwner. */ SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){ Window *pNew = 0; if( ALWAYS(p) ){ pNew = sqlite3DbMallocZero(db, sizeof(Window)); if( pNew ){ pNew->zName = sqlite3DbStrDup(db, p->zName); pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0); pNew->pFunc = p->pFunc; pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0); pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0); pNew->eFrmType = p->eFrmType; pNew->eEnd = p->eEnd; pNew->eStart = p->eStart; pNew->eExclude = p->eExclude; pNew->pStart = sqlite3ExprDup(db, p->pStart, 0); pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0); pNew->pOwner = pOwner; } } return pNew; } |
︙ | ︙ | |||
147391 147392 147393 147394 147395 147396 147397 147398 147399 147400 147401 | *pp = sqlite3WindowDup(db, 0, pWin); if( *pp==0 ) break; pp = &((*pp)->pNextWin); } return pRet; } /* ** sqlite3WhereBegin() has already been called for the SELECT statement ** passed as the second argument when this function is invoked. It generates | > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > > > > > > | < < < > > > > | < | < | < < > | > > > > > > > > > > > > | < < | | | > > > > | > > | > > > > > > | > > > > > > > > > > > > | > > > > > > > | | | > > > > > > > > > | > > > > > > > > > | > > > > > | > | | > > > > | > > > | | | | > > > > | > > > > > > > > > | > > > > > > > > > > > > > > | > | > | > > > | | > > > | > > > > > > | < < | < < < < < < < > | | > > > > > > > > > > > > > > > > > | > > > > > | > > > > > | > > > > > | > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < > > > > > > > | 147378 147379 147380 147381 147382 147383 147384 147385 147386 147387 147388 147389 147390 147391 147392 147393 147394 147395 147396 147397 147398 147399 147400 147401 147402 147403 147404 147405 147406 147407 147408 147409 147410 147411 147412 147413 147414 147415 147416 147417 147418 147419 147420 147421 147422 147423 147424 147425 147426 147427 147428 147429 147430 147431 147432 147433 147434 147435 147436 147437 147438 147439 147440 147441 147442 147443 147444 147445 147446 147447 147448 147449 147450 147451 147452 147453 147454 147455 147456 147457 147458 147459 147460 147461 147462 147463 147464 147465 147466 147467 147468 147469 147470 147471 147472 147473 147474 147475 147476 147477 147478 147479 147480 147481 147482 147483 147484 147485 147486 147487 147488 147489 147490 147491 147492 147493 147494 147495 147496 147497 147498 147499 147500 147501 147502 147503 147504 147505 147506 147507 147508 147509 147510 147511 147512 147513 147514 147515 147516 147517 147518 147519 147520 147521 147522 147523 147524 147525 147526 147527 147528 147529 147530 147531 147532 147533 147534 147535 147536 147537 147538 147539 147540 147541 147542 147543 147544 147545 147546 147547 147548 147549 147550 147551 147552 147553 147554 147555 147556 147557 147558 147559 147560 147561 147562 147563 147564 147565 147566 147567 147568 147569 147570 147571 147572 147573 147574 147575 147576 147577 147578 147579 147580 147581 147582 147583 147584 147585 147586 147587 147588 147589 147590 147591 147592 147593 147594 147595 147596 147597 147598 147599 147600 147601 147602 147603 147604 147605 147606 147607 147608 147609 147610 147611 147612 147613 147614 147615 147616 147617 147618 147619 147620 147621 147622 147623 147624 147625 147626 147627 147628 147629 147630 147631 147632 147633 147634 147635 147636 147637 147638 147639 147640 147641 147642 147643 147644 147645 147646 147647 147648 147649 147650 147651 147652 147653 147654 147655 147656 147657 147658 147659 147660 147661 147662 147663 147664 147665 147666 147667 147668 147669 147670 147671 147672 147673 147674 147675 147676 147677 147678 147679 147680 147681 147682 147683 147684 147685 147686 147687 147688 147689 147690 147691 147692 147693 147694 147695 147696 147697 147698 147699 147700 147701 147702 147703 147704 147705 147706 147707 147708 147709 147710 147711 147712 147713 147714 147715 147716 147717 147718 147719 147720 147721 147722 147723 147724 147725 147726 147727 147728 147729 147730 147731 147732 147733 147734 147735 147736 147737 147738 147739 147740 147741 147742 147743 147744 147745 147746 147747 147748 147749 147750 147751 147752 147753 147754 147755 147756 147757 147758 147759 147760 147761 147762 147763 147764 147765 147766 147767 147768 147769 147770 147771 147772 147773 147774 147775 147776 147777 147778 147779 147780 147781 147782 147783 147784 147785 147786 147787 147788 147789 147790 147791 147792 147793 147794 147795 147796 147797 147798 147799 147800 147801 147802 147803 147804 147805 147806 147807 147808 147809 147810 147811 147812 147813 147814 147815 147816 147817 147818 147819 147820 147821 147822 147823 147824 147825 147826 147827 147828 147829 147830 147831 147832 147833 147834 147835 147836 147837 147838 147839 147840 147841 147842 147843 147844 147845 147846 147847 147848 147849 147850 147851 147852 147853 147854 147855 147856 147857 147858 147859 147860 147861 147862 147863 147864 147865 147866 147867 147868 147869 147870 147871 147872 147873 147874 147875 147876 147877 147878 147879 147880 147881 147882 147883 147884 147885 147886 147887 147888 147889 147890 147891 147892 147893 147894 147895 147896 147897 147898 147899 147900 147901 147902 147903 147904 147905 147906 147907 147908 147909 147910 147911 147912 147913 147914 147915 147916 147917 147918 147919 147920 147921 147922 147923 147924 147925 147926 147927 147928 147929 147930 147931 147932 147933 147934 147935 147936 147937 147938 147939 147940 147941 147942 147943 147944 147945 147946 147947 147948 147949 147950 147951 147952 147953 147954 147955 147956 147957 147958 147959 147960 147961 147962 147963 147964 147965 147966 147967 147968 147969 147970 147971 147972 147973 147974 147975 147976 147977 147978 147979 147980 147981 147982 147983 147984 147985 147986 147987 147988 147989 147990 147991 147992 147993 147994 147995 147996 147997 147998 147999 148000 148001 148002 148003 148004 148005 148006 148007 148008 148009 148010 148011 148012 148013 148014 148015 148016 148017 148018 148019 148020 148021 148022 148023 148024 148025 148026 148027 148028 148029 148030 148031 148032 148033 148034 148035 148036 148037 148038 148039 148040 148041 148042 148043 148044 148045 148046 148047 148048 148049 148050 148051 148052 148053 148054 148055 148056 148057 148058 148059 148060 148061 148062 148063 148064 148065 148066 148067 148068 148069 148070 | *pp = sqlite3WindowDup(db, 0, pWin); if( *pp==0 ) break; pp = &((*pp)->pNextWin); } return pRet; } /* ** Return true if it can be determined at compile time that expression ** pExpr evaluates to a value that, when cast to an integer, is greater ** than zero. False otherwise. ** ** If an OOM error occurs, this function sets the Parse.db.mallocFailed ** flag and returns zero. */ static int windowExprGtZero(Parse *pParse, Expr *pExpr){ int ret = 0; sqlite3 *db = pParse->db; sqlite3_value *pVal = 0; sqlite3ValueFromExpr(db, pExpr, db->enc, SQLITE_AFF_NUMERIC, &pVal); if( pVal && sqlite3_value_int(pVal)>0 ){ ret = 1; } sqlite3ValueFree(pVal); return ret; } /* ** sqlite3WhereBegin() has already been called for the SELECT statement ** passed as the second argument when this function is invoked. It generates ** code to populate the Window.regResult register for each window function ** and invoke the sub-routine at instruction addrGosub once for each row. ** sqlite3WhereEnd() is always called before returning. ** ** This function handles several different types of window frames, which ** require slightly different processing. The following pseudo code is ** used to implement window frames of the form: ** ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING ** ** Other window frame types use variants of the following: ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** ** if( first row of partition ){ ** // Rewind three cursors, all open on the eph table. ** Rewind(csrEnd); ** Rewind(csrStart); ** Rewind(csrCurrent); ** ** regEnd = <expr2> // FOLLOWING expression ** regStart = <expr1> // PRECEDING expression ** }else{ ** // First time this branch is taken, the eph table contains two ** // rows. The first row in the partition, which all three cursors ** // currently point to, and the following row. ** AGGSTEP ** if( (regEnd--)<=0 ){ ** RETURN_ROW ** if( (regStart--)<=0 ){ ** AGGINVERSE ** } ** } ** } ** } ** flush: ** AGGSTEP ** while( 1 ){ ** RETURN ROW ** if( csrCurrent is EOF ) break; ** if( (regStart--)<=0 ){ ** AggInverse(csrStart) ** Next(csrStart) ** } ** } ** ** The pseudo-code above uses the following shorthand: ** ** AGGSTEP: invoke the aggregate xStep() function for each window function ** with arguments read from the current row of cursor csrEnd, then ** step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()). ** ** RETURN_ROW: return a row to the caller based on the contents of the ** current row of csrCurrent and the current state of all ** aggregates. Then step cursor csrCurrent forward one row. ** ** AGGINVERSE: invoke the aggregate xInverse() function for each window ** functions with arguments read from the current row of cursor ** csrStart. Then step csrStart forward one row. ** ** There are two other ROWS window frames that are handled significantly ** differently from the above - "BETWEEN <expr> PRECEDING AND <expr> PRECEDING" ** and "BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING". These are special ** cases because they change the order in which the three cursors (csrStart, ** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that ** use UNBOUNDED or CURRENT ROW are much simpler variations on one of these ** three. ** ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** }else{ ** if( (regEnd--)<=0 ){ ** AGGSTEP ** } ** RETURN_ROW ** if( (regStart--)<=0 ){ ** AGGINVERSE ** } ** } ** } ** flush: ** if( (regEnd--)<=0 ){ ** AGGSTEP ** } ** RETURN_ROW ** ** ** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = regEnd - <expr1> ** }else{ ** AGGSTEP ** if( (regEnd--)<=0 ){ ** RETURN_ROW ** } ** if( (regStart--)<=0 ){ ** AGGINVERSE ** } ** } ** } ** flush: ** AGGSTEP ** while( 1 ){ ** if( (regEnd--)<=0 ){ ** RETURN_ROW ** if( eof ) break; ** } ** if( (regStart--)<=0 ){ ** AGGINVERSE ** if( eof ) break ** } ** } ** while( !eof csrCurrent ){ ** RETURN_ROW ** } ** ** For the most part, the patterns above are adapted to support UNBOUNDED by ** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and ** CURRENT ROW by assuming that it is equivilent to "0 PRECEDING/FOLLOWING". ** This is optimized of course - branches that will never be taken and ** conditions that are always true are omitted from the VM code. The only ** exceptional case is: ** ** ROWS BETWEEN <expr1> FOLLOWING AND UNBOUNDED FOLLOWING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regStart = <expr1> ** }else{ ** AGGSTEP ** } ** } ** flush: ** AGGSTEP ** while( 1 ){ ** if( (regStart--)<=0 ){ ** AGGINVERSE ** if( eof ) break ** } ** RETURN_ROW ** } ** while( !eof csrCurrent ){ ** RETURN_ROW ** } ** ** Also requiring special handling are the cases: ** ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING ** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING ** ** when (expr1 < expr2). This is detected at runtime, not by this function. ** To handle this case, the pseudo-code programs depicted above are modified ** slightly to be: ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** if( regEnd < regStart ){ ** RETURN_ROW ** delete eph table contents ** continue ** } ** ... ** ** The new "continue" statement in the above jumps to the next iteration ** of the outer loop - the one started by sqlite3WhereBegin(). ** ** The various GROUPS cases are implemented using the same patterns as ** ROWS. The VM code is modified slightly so that: ** ** 1. The else branch in the main loop is only taken if the row just ** added to the ephemeral table is the start of a new group. In ** other words, it becomes: ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** }else if( new group ){ ** ... ** } ** } ** ** 2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or ** AGGINVERSE step processes the current row of the relevant cursor and ** all subsequent rows belonging to the same group. ** ** RANGE window frames are a little different again. As for GROUPS, the ** main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE ** deal in groups instead of rows. As for ROWS and GROUPS, there are three ** basic cases: ** ** RANGE BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** }else{ ** AGGSTEP ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ ** RETURN_ROW ** while( csrStart.key + regStart) < csrCurrent.key ){ ** AGGINVERSE ** } ** } ** } ** } ** flush: ** AGGSTEP ** while( 1 ){ ** RETURN ROW ** if( csrCurrent is EOF ) break; ** while( csrStart.key + regStart) < csrCurrent.key ){ ** AGGINVERSE ** } ** } ** } ** ** In the above notation, "csr.key" means the current value of the ORDER BY ** expression (there is only ever 1 for a RANGE that uses an <expr> FOLLOWING ** or <expr PRECEDING) read from cursor csr. ** ** RANGE BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** }else{ ** if( (csrEnd.key + regEnd) <= csrCurrent.key ){ ** AGGSTEP ** } ** while( (csrStart.key + regStart) < csrCurrent.key ){ ** AGGINVERSE ** } ** RETURN_ROW ** } ** } ** flush: ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){ ** AGGSTEP ** } ** while( (csrStart.key + regStart) < csrCurrent.key ){ ** AGGINVERSE ** } ** RETURN_ROW ** ** RANGE BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING ** ** ... loop started by sqlite3WhereBegin() ... ** if( new partition ){ ** Gosub flush ** } ** Insert new row into eph table. ** if( first row of partition ){ ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent) ** regEnd = <expr2> ** regStart = <expr1> ** }else{ ** AGGSTEP ** while( (csrCurrent.key + regEnd) < csrEnd.key ){ ** while( (csrCurrent.key + regStart) > csrStart.key ){ ** AGGINVERSE ** } ** RETURN_ROW ** } ** } ** } ** flush: ** AGGSTEP ** while( 1 ){ ** while( (csrCurrent.key + regStart) > csrStart.key ){ ** AGGINVERSE ** if( eof ) break "while( 1 )" loop. ** } ** RETURN_ROW ** } ** while( !eof csrCurrent ){ ** RETURN_ROW ** } ** ** The text above leaves out many details. Refer to the code and comments ** below for a more complete picture. */ SQLITE_PRIVATE void sqlite3WindowCodeStep( Parse *pParse, /* Parse context */ Select *p, /* Rewritten SELECT statement */ WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */ int regGosub, /* Register for OP_Gosub */ int addrGosub /* OP_Gosub here to return each row */ ){ Window *pMWin = p->pWin; ExprList *pOrderBy = pMWin->pOrderBy; Vdbe *v = sqlite3GetVdbe(pParse); int csrWrite; /* Cursor used to write to eph. table */ int csrInput = p->pSrc->a[0].iCursor; /* Cursor of sub-select */ int nInput = p->pSrc->a[0].pTab->nCol; /* Number of cols returned by sub */ int iInput; /* To iterate through sub cols */ int addrNe; /* Address of OP_Ne */ int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */ int addrInteger = 0; /* Address of OP_Integer */ int addrEmpty; /* Address of OP_Rewind in flush: */ int regStart = 0; /* Value of <expr> PRECEDING */ int regEnd = 0; /* Value of <expr> FOLLOWING */ int regNew; /* Array of registers holding new input row */ int regRecord; /* regNew array in record form */ int regRowid; /* Rowid for regRecord in eph table */ int regNewPeer = 0; /* Peer values for new row (part of regNew) */ int regPeer = 0; /* Peer values for current row */ int regFlushPart = 0; /* Register for "Gosub flush_partition" */ WindowCodeArg s; /* Context object for sub-routines */ int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */ assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_CURRENT || pMWin->eStart==TK_FOLLOWING || pMWin->eStart==TK_UNBOUNDED ); assert( pMWin->eEnd==TK_FOLLOWING || pMWin->eEnd==TK_CURRENT || pMWin->eEnd==TK_UNBOUNDED || pMWin->eEnd==TK_PRECEDING ); assert( pMWin->eExclude==0 || pMWin->eExclude==TK_CURRENT || pMWin->eExclude==TK_GROUP || pMWin->eExclude==TK_TIES || pMWin->eExclude==TK_NO ); lblWhereEnd = sqlite3VdbeMakeLabel(pParse); /* Fill in the context object */ memset(&s, 0, sizeof(WindowCodeArg)); s.pParse = pParse; s.pMWin = pMWin; s.pVdbe = v; s.regGosub = regGosub; s.addrGosub = addrGosub; s.current.csr = pMWin->iEphCsr; csrWrite = s.current.csr+1; s.start.csr = s.current.csr+2; s.end.csr = s.current.csr+3; /* Figure out when rows may be deleted from the ephemeral table. There ** are four options - they may never be deleted (eDelete==0), they may ** be deleted as soon as they are no longer part of the window frame ** (eDelete==WINDOW_AGGINVERSE), they may be deleted as after the row ** has been returned to the caller (WINDOW_RETURN_ROW), or they may ** be deleted after they enter the frame (WINDOW_AGGSTEP). */ switch( pMWin->eStart ){ case TK_FOLLOWING: if( pMWin->eFrmType!=TK_RANGE && windowExprGtZero(pParse, pMWin->pStart) ){ s.eDelete = WINDOW_RETURN_ROW; } break; case TK_UNBOUNDED: if( windowCacheFrame(pMWin)==0 ){ if( pMWin->eEnd==TK_PRECEDING ){ if( pMWin->eFrmType!=TK_RANGE && windowExprGtZero(pParse, pMWin->pEnd) ){ s.eDelete = WINDOW_AGGSTEP; } }else{ s.eDelete = WINDOW_RETURN_ROW; } } break; default: s.eDelete = WINDOW_AGGINVERSE; break; } /* Allocate registers for the array of values from the sub-query, the ** samve values in record form, and the rowid used to insert said record ** into the ephemeral table. */ regNew = pParse->nMem+1; pParse->nMem += nInput; regRecord = ++pParse->nMem; regRowid = ++pParse->nMem; /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING" ** clause, allocate registers to store the results of evaluating each ** <expr>. */ if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){ regStart = ++pParse->nMem; } if( pMWin->eEnd==TK_PRECEDING || pMWin->eEnd==TK_FOLLOWING ){ regEnd = ++pParse->nMem; } /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of ** registers to store copies of the ORDER BY expressions (peer values) ** for the main loop, and for each cursor (start, current and end). */ if( pMWin->eFrmType!=TK_ROWS ){ int nPeer = (pOrderBy ? pOrderBy->nExpr : 0); regNewPeer = regNew + pMWin->nBufferCol; if( pMWin->pPartition ) regNewPeer += pMWin->pPartition->nExpr; regPeer = pParse->nMem+1; pParse->nMem += nPeer; s.start.reg = pParse->nMem+1; pParse->nMem += nPeer; s.current.reg = pParse->nMem+1; pParse->nMem += nPeer; s.end.reg = pParse->nMem+1; pParse->nMem += nPeer; } /* Load the column values for the row returned by the sub-select ** into an array of registers starting at regNew. Assemble them into ** a record in register regRecord. */ for(iInput=0; iInput<nInput; iInput++){ sqlite3VdbeAddOp3(v, OP_Column, csrInput, iInput, regNew+iInput); } sqlite3VdbeAddOp3(v, OP_MakeRecord, regNew, nInput, regRecord); /* An input row has just been read into an array of registers starting ** at regNew. If the window has a PARTITION clause, this block generates ** VM code to check if the input row is the start of a new partition. ** If so, it does an OP_Gosub to an address to be filled in later. The ** address of the OP_Gosub is stored in local variable addrGosubFlush. */ if( pMWin->pPartition ){ int addr; ExprList *pPart = pMWin->pPartition; int nPart = pPart->nExpr; int regNewPart = regNew + pMWin->nBufferCol; KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0); regFlushPart = ++pParse->nMem; addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart, nPart); sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO); sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2); VdbeCoverageEqNe(v); addrGosubFlush = sqlite3VdbeAddOp1(v, OP_Gosub, regFlushPart); VdbeComment((v, "call flush_partition")); sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1); } /* Insert the new row into the ephemeral table */ sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid); sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid); addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid); VdbeCoverageNeverNull(v); /* This block is run for the first row of each partition */ s.regArg = windowInitAccum(pParse, pMWin); if( regStart ){ sqlite3ExprCode(pParse, pMWin->pStart, regStart); windowCheckValue(pParse, regStart, 0 + (pMWin->eFrmType==TK_RANGE ? 3 : 0)); } if( regEnd ){ sqlite3ExprCode(pParse, pMWin->pEnd, regEnd); windowCheckValue(pParse, regEnd, 1 + (pMWin->eFrmType==TK_RANGE ? 3 : 0)); } if( pMWin->eStart==pMWin->eEnd && regStart ){ int op = ((pMWin->eStart==TK_FOLLOWING) ? OP_Ge : OP_Le); int addrGe = sqlite3VdbeAddOp3(v, op, regStart, 0, regEnd); VdbeCoverageNeverNullIf(v, op==OP_Ge); /* NeverNull because bound <expr> */ VdbeCoverageNeverNullIf(v, op==OP_Le); /* values previously checked */ windowAggFinal(&s, 0); sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1); VdbeCoverageNeverTaken(v); windowReturnOneRow(&s); sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr); sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd); sqlite3VdbeJumpHere(v, addrGe); } if( pMWin->eStart==TK_FOLLOWING && pMWin->eFrmType!=TK_RANGE && regEnd ){ assert( pMWin->eEnd==TK_FOLLOWING ); sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regStart); } if( pMWin->eStart!=TK_UNBOUNDED ){ sqlite3VdbeAddOp2(v, OP_Rewind, s.start.csr, 1); VdbeCoverageNeverTaken(v); } sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1); VdbeCoverageNeverTaken(v); sqlite3VdbeAddOp2(v, OP_Rewind, s.end.csr, 1); VdbeCoverageNeverTaken(v); if( regPeer && pOrderBy ){ sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, pOrderBy->nExpr-1); sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.start.reg, pOrderBy->nExpr-1); sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.current.reg, pOrderBy->nExpr-1); sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.end.reg, pOrderBy->nExpr-1); } sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd); sqlite3VdbeJumpHere(v, addrNe); /* Beginning of the block executed for the second and subsequent rows. */ if( regPeer ){ windowIfNewPeer(pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd); } if( pMWin->eStart==TK_FOLLOWING ){ windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0); if( pMWin->eEnd!=TK_UNBOUNDED ){ if( pMWin->eFrmType==TK_RANGE ){ int lbl = sqlite3VdbeMakeLabel(pParse); int addrNext = sqlite3VdbeCurrentAddr(v); windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl); windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0); sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNext); sqlite3VdbeResolveLabel(v, lbl); }else{ windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 0); windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); } } }else if( pMWin->eEnd==TK_PRECEDING ){ int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE); windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0); if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0); if( !bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); }else{ int addr = 0; windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0); if( pMWin->eEnd!=TK_UNBOUNDED ){ if( pMWin->eFrmType==TK_RANGE ){ int lbl = 0; addr = sqlite3VdbeCurrentAddr(v); if( regEnd ){ lbl = sqlite3VdbeMakeLabel(pParse); windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl); } windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0); windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); if( regEnd ){ sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); sqlite3VdbeResolveLabel(v, lbl); } }else{ if( regEnd ){ addr = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0, 1); VdbeCoverage(v); } windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0); windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); if( regEnd ) sqlite3VdbeJumpHere(v, addr); } } } /* End of the main input loop */ sqlite3VdbeResolveLabel(v, lblWhereEnd); sqlite3WhereEnd(pWInfo); /* Fall through */ if( pMWin->pPartition ){ addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart); sqlite3VdbeJumpHere(v, addrGosubFlush); } addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite); VdbeCoverage(v); if( pMWin->eEnd==TK_PRECEDING ){ int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE); windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0); if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0); }else if( pMWin->eStart==TK_FOLLOWING ){ int addrStart; int addrBreak1; int addrBreak2; int addrBreak3; windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0); if( pMWin->eFrmType==TK_RANGE ){ addrStart = sqlite3VdbeCurrentAddr(v); addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1); addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1); }else if( pMWin->eEnd==TK_UNBOUNDED ){ addrStart = sqlite3VdbeCurrentAddr(v); addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regStart, 1); addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, 0, 1); }else{ assert( pMWin->eEnd==TK_FOLLOWING ); addrStart = sqlite3VdbeCurrentAddr(v); addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 1); addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1); } sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart); sqlite3VdbeJumpHere(v, addrBreak2); addrStart = sqlite3VdbeCurrentAddr(v); addrBreak3 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1); sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart); sqlite3VdbeJumpHere(v, addrBreak1); sqlite3VdbeJumpHere(v, addrBreak3); }else{ int addrBreak; int addrStart; windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0); addrStart = sqlite3VdbeCurrentAddr(v); addrBreak = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1); windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0); sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart); sqlite3VdbeJumpHere(v, addrBreak); } sqlite3VdbeJumpHere(v, addrEmpty); sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr); if( pMWin->pPartition ){ if( pMWin->regStartRowid ){ sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid); sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid); } sqlite3VdbeChangeP1(v, addrInteger, sqlite3VdbeCurrentAddr(v)); sqlite3VdbeAddOp1(v, OP_Return, regFlushPart); } } #endif /* SQLITE_OMIT_WINDOWFUNC */ /************** End of window.c **********************************************/ /************** Begin file parse.c *******************************************/ |
︙ | ︙ | |||
147727 147728 147729 147730 147731 147732 147733 | ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int | | | < | | | | | | | | | > | < | | > > | | | | | | | | | | | | 148308 148309 148310 148311 148312 148313 148314 148315 148316 148317 148318 148319 148320 148321 148322 148323 148324 148325 148326 148327 148328 148329 148330 148331 148332 148333 148334 148335 148336 148337 148338 148339 148340 148341 148342 148343 148344 148345 148346 148347 148348 148349 148350 148351 148352 148353 148354 148355 148356 148357 148358 148359 148360 148361 148362 148363 148364 148365 148366 148367 148368 148369 | ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int #define YYNOCODE 284 #define YYACTIONTYPE unsigned short int #define YYWILDCARD 95 #define sqlite3ParserTOKENTYPE Token typedef union { int yyinit; sqlite3ParserTOKENTYPE yy0; u8 yy10; const char* yy104; Expr* yy130; SrcList* yy147; IdList* yy200; struct FrameBound yy273; Window* yy395; int yy420; Upsert* yy426; ExprList* yy442; Select* yy491; struct TrigEvent yy498; With* yy523; TriggerStep* yy524; struct {int value; int mask;} yy527; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define sqlite3ParserARG_SDECL #define sqlite3ParserARG_PDECL #define sqlite3ParserARG_PARAM #define sqlite3ParserARG_FETCH #define sqlite3ParserARG_STORE #define sqlite3ParserCTX_SDECL Parse *pParse; #define sqlite3ParserCTX_PDECL ,Parse *pParse #define sqlite3ParserCTX_PARAM ,pParse #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; #define YYFALLBACK 1 #define YYNSTATE 541 #define YYNRULE 375 #define YYNTOKEN 159 #define YY_MAX_SHIFT 540 #define YY_MIN_SHIFTREDUCE 784 #define YY_MAX_SHIFTREDUCE 1158 #define YY_ERROR_ACTION 1159 #define YY_ACCEPT_ACTION 1160 #define YY_NO_ACTION 1161 #define YY_MIN_REDUCE 1162 #define YY_MAX_REDUCE 1536 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. ** ** Applications can choose to define yytestcase() in the %include section |
︙ | ︙ | |||
147840 147841 147842 147843 147844 147845 147846 | ** 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. ** *********** Begin parsing tables **********************************************/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > < < < < < < < < | | | | | | | | | | | | | | | | | > > > > > > > > > > < < < < < < < < < < | | | | | | | | | | | | | | | | > > > > > > > > > > > < < < < < < < < < < < | | | | | | | | | | | | | | > > > > > > > > > > > > > < < < < < < < < < < < < < | | | | | | | | | | | | | > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | > | > | < | < | | | < | > | | | | | | | | | | | | | | | | | | | | | | | | | | < < | | > > | | | | | | < < | > > | | | | | | | | | | < < | | > > | | < | | > | | | | | | | | | | | | | > > > > > > > > > | | | | | | | | | | | | > | | | | | | < | | | | | | > | | | | | | | | | | | | > | | | | | | | | | | | | | < < < < < < < < < < < | | | | | | | | | | | | | | | > > > > > > > > > > > > < < | | | | | | | | | < | > | < > | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | 148422 148423 148424 148425 148426 148427 148428 148429 148430 148431 148432 148433 148434 148435 148436 148437 148438 148439 148440 148441 148442 148443 148444 148445 148446 148447 148448 148449 148450 148451 148452 148453 148454 148455 148456 148457 148458 148459 148460 148461 148462 148463 148464 148465 148466 148467 148468 148469 148470 148471 148472 148473 148474 148475 148476 148477 148478 148479 148480 148481 148482 148483 148484 148485 148486 148487 148488 148489 148490 148491 148492 148493 148494 148495 148496 148497 148498 148499 148500 148501 148502 148503 148504 148505 148506 148507 148508 148509 148510 148511 148512 148513 148514 148515 148516 148517 148518 148519 148520 148521 148522 148523 148524 148525 148526 148527 148528 148529 148530 148531 148532 148533 148534 148535 148536 148537 148538 148539 148540 148541 148542 148543 148544 148545 148546 148547 148548 148549 148550 148551 148552 148553 148554 148555 148556 148557 148558 148559 148560 148561 148562 148563 148564 148565 148566 148567 148568 148569 148570 148571 148572 148573 148574 148575 148576 148577 148578 148579 148580 148581 148582 148583 148584 148585 148586 148587 148588 148589 148590 148591 148592 148593 148594 148595 148596 148597 148598 148599 148600 148601 148602 148603 148604 148605 148606 148607 148608 148609 148610 148611 148612 148613 148614 148615 148616 148617 148618 148619 148620 148621 148622 148623 148624 148625 148626 148627 148628 148629 148630 148631 148632 148633 148634 148635 148636 148637 148638 148639 148640 148641 148642 148643 148644 148645 148646 148647 148648 148649 148650 148651 148652 148653 148654 148655 148656 148657 148658 148659 148660 148661 148662 148663 148664 148665 148666 148667 148668 148669 148670 148671 148672 148673 148674 148675 148676 148677 148678 148679 148680 148681 148682 148683 148684 148685 148686 148687 148688 148689 148690 148691 148692 148693 148694 148695 148696 148697 148698 148699 148700 148701 148702 148703 148704 148705 148706 148707 148708 148709 148710 148711 148712 148713 148714 148715 148716 148717 148718 148719 148720 148721 148722 148723 148724 148725 148726 148727 148728 148729 148730 148731 148732 148733 148734 148735 148736 148737 148738 148739 148740 148741 148742 148743 148744 148745 148746 148747 148748 148749 148750 148751 148752 148753 148754 148755 148756 148757 148758 148759 148760 148761 148762 148763 148764 148765 148766 148767 148768 148769 148770 148771 148772 148773 148774 148775 148776 148777 148778 148779 148780 148781 148782 148783 148784 148785 148786 148787 148788 148789 148790 148791 148792 148793 148794 148795 148796 148797 148798 148799 148800 148801 148802 148803 148804 148805 148806 148807 148808 148809 148810 148811 148812 148813 148814 148815 148816 148817 148818 148819 148820 148821 148822 148823 148824 148825 148826 148827 148828 148829 148830 148831 148832 148833 148834 148835 148836 148837 148838 148839 148840 148841 148842 148843 148844 148845 148846 148847 148848 148849 148850 148851 148852 148853 148854 148855 148856 148857 148858 148859 148860 148861 148862 148863 148864 148865 148866 148867 148868 148869 148870 148871 148872 148873 148874 148875 148876 148877 148878 148879 148880 148881 148882 148883 148884 148885 148886 148887 148888 148889 148890 148891 148892 148893 148894 148895 148896 148897 148898 148899 148900 148901 148902 148903 148904 148905 148906 148907 148908 148909 148910 148911 148912 148913 148914 148915 148916 148917 148918 148919 148920 148921 148922 148923 148924 148925 148926 148927 148928 148929 148930 148931 148932 148933 148934 148935 148936 148937 148938 148939 148940 148941 148942 148943 148944 148945 148946 148947 148948 148949 148950 148951 148952 148953 148954 148955 148956 148957 148958 148959 148960 148961 148962 148963 148964 148965 148966 148967 148968 148969 148970 148971 148972 148973 148974 148975 148976 148977 148978 148979 148980 148981 148982 148983 148984 148985 148986 148987 148988 148989 148990 148991 148992 148993 148994 148995 148996 148997 148998 148999 149000 149001 149002 149003 149004 149005 149006 149007 149008 149009 149010 149011 149012 149013 149014 149015 149016 149017 149018 149019 149020 149021 149022 149023 149024 149025 149026 149027 149028 149029 149030 149031 | ** 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. ** *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (2142) static const YYACTIONTYPE yy_action[] = { /* 0 */ 388, 112, 109, 209, 535, 190, 442, 259, 1160, 1, /* 10 */ 1, 540, 2, 1164, 535, 1292, 1500, 371, 289, 384, /* 20 */ 134, 1484, 1427, 1164, 1202, 69, 69, 1241, 289, 492, /* 30 */ 134, 915, 382, 296, 175, 42, 42, 1241, 242, 916, /* 40 */ 112, 109, 209, 119, 120, 110, 1136, 1136, 981, 984, /* 50 */ 974, 974, 117, 117, 118, 118, 118, 118, 1291, 264, /* 60 */ 264, 264, 264, 112, 109, 209, 112, 109, 209, 264, /* 70 */ 264, 1115, 532, 1134, 532, 176, 270, 453, 239, 206, /* 80 */ 379, 450, 532, 356, 380, 219, 118, 118, 118, 118, /* 90 */ 111, 444, 535, 1233, 1233, 219, 116, 116, 116, 116, /* 100 */ 115, 115, 114, 114, 114, 113, 415, 258, 258, 112, /* 110 */ 109, 209, 1115, 42, 42, 419, 384, 1391, 1504, 1115, /* 120 */ 532, 1115, 1116, 1117, 1134, 419, 1463, 351, 116, 116, /* 130 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 961, /* 140 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117, /* 150 */ 117, 118, 118, 118, 118, 952, 1228, 1207, 1115, 951, /* 160 */ 412, 411, 1115, 1116, 1117, 1228, 535, 876, 1140, 1115, /* 170 */ 1116, 1117, 875, 1142, 941, 114, 114, 114, 113, 415, /* 180 */ 1089, 1141, 1089, 118, 118, 118, 118, 42, 42, 202, /* 190 */ 951, 951, 953, 116, 116, 116, 116, 115, 115, 114, /* 200 */ 114, 114, 113, 415, 1465, 1143, 350, 1143, 1115, 1116, /* 210 */ 1117, 231, 415, 384, 472, 469, 468, 412, 411, 442, /* 220 */ 96, 311, 430, 299, 467, 116, 116, 116, 116, 115, /* 230 */ 115, 114, 114, 114, 113, 415, 160, 119, 120, 110, /* 240 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118, /* 250 */ 118, 118, 115, 115, 114, 114, 114, 113, 415, 529, /* 260 */ 529, 529, 1143, 121, 1143, 116, 116, 116, 116, 115, /* 270 */ 115, 114, 114, 114, 113, 415, 941, 337, 1463, 506, /* 280 */ 491, 1067, 1530, 384, 160, 1530, 288, 526, 1115, 274, /* 290 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113, /* 300 */ 415, 16, 16, 406, 535, 93, 512, 119, 120, 110, /* 310 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118, /* 320 */ 118, 118, 141, 311, 231, 54, 54, 472, 469, 468, /* 330 */ 427, 79, 368, 1156, 288, 526, 32, 467, 1115, 1116, /* 340 */ 1117, 1323, 1480, 540, 2, 1164, 971, 971, 982, 985, /* 350 */ 289, 384, 134, 459, 1065, 533, 80, 870, 870, 1241, /* 360 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113, /* 370 */ 415, 818, 82, 1115, 1476, 119, 120, 110, 1136, 1136, /* 380 */ 981, 984, 974, 974, 117, 117, 118, 118, 118, 118, /* 390 */ 403, 264, 264, 238, 535, 1426, 250, 267, 336, 475, /* 400 */ 331, 474, 236, 459, 532, 1157, 961, 459, 329, 397, /* 410 */ 373, 513, 1450, 159, 975, 70, 70, 219, 413, 413, /* 420 */ 413, 818, 952, 1115, 1116, 1117, 951, 534, 116, 116, /* 430 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 1115, /* 440 */ 535, 442, 264, 264, 1115, 1390, 535, 419, 384, 422, /* 450 */ 1115, 517, 326, 1245, 304, 532, 1084, 951, 951, 953, /* 460 */ 493, 70, 70, 167, 509, 532, 1084, 70, 70, 1084, /* 470 */ 440, 535, 119, 120, 110, 1136, 1136, 981, 984, 974, /* 480 */ 974, 117, 117, 118, 118, 118, 118, 881, 535, 1115, /* 490 */ 1116, 1117, 55, 55, 1115, 1116, 1117, 517, 288, 526, /* 500 */ 1115, 1116, 1117, 517, 420, 494, 516, 113, 415, 13, /* 510 */ 13, 275, 482, 836, 349, 301, 535, 303, 500, 5, /* 520 */ 480, 1457, 138, 395, 6, 116, 116, 116, 116, 115, /* 530 */ 115, 114, 114, 114, 113, 415, 1458, 13, 13, 6, /* 540 */ 535, 1024, 1115, 535, 473, 384, 535, 435, 312, 822, /* 550 */ 1084, 400, 837, 159, 518, 181, 1115, 483, 502, 811, /* 560 */ 1084, 70, 70, 1084, 70, 70, 1115, 50, 50, 119, /* 570 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117, /* 580 */ 118, 118, 118, 118, 95, 338, 264, 264, 1115, 264, /* 590 */ 264, 302, 1115, 1116, 1117, 495, 3, 498, 535, 532, /* 600 */ 517, 404, 532, 484, 801, 287, 1115, 1116, 1117, 519, /* 610 */ 811, 337, 501, 12, 535, 381, 1115, 1116, 1117, 70, /* 620 */ 70, 401, 116, 116, 116, 116, 115, 115, 114, 114, /* 630 */ 114, 113, 415, 1115, 1084, 13, 13, 535, 1115, 1116, /* 640 */ 1117, 1115, 384, 902, 1084, 1211, 815, 1084, 393, 402, /* 650 */ 160, 435, 312, 1532, 369, 284, 143, 297, 70, 70, /* 660 */ 510, 1457, 337, 433, 6, 901, 119, 120, 110, 1136, /* 670 */ 1136, 981, 984, 974, 974, 117, 117, 118, 118, 118, /* 680 */ 118, 1045, 426, 1115, 1116, 1117, 449, 535, 12, 264, /* 690 */ 264, 1115, 1116, 1117, 285, 535, 1046, 265, 265, 1004, /* 700 */ 288, 526, 532, 789, 790, 791, 190, 140, 70, 70, /* 710 */ 532, 1047, 1323, 535, 309, 298, 13, 13, 383, 116, /* 720 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 415, /* 730 */ 277, 535, 856, 190, 13, 13, 1383, 497, 278, 384, /* 740 */ 278, 362, 857, 1100, 410, 376, 264, 264, 184, 900, /* 750 */ 1210, 1239, 70, 70, 1182, 1455, 187, 535, 6, 532, /* 760 */ 535, 434, 207, 119, 120, 110, 1136, 1136, 981, 984, /* 770 */ 974, 974, 117, 117, 118, 118, 118, 118, 13, 13, /* 780 */ 398, 13, 13, 264, 264, 393, 264, 264, 414, 1185, /* 790 */ 390, 425, 185, 1396, 1084, 514, 532, 485, 9, 532, /* 800 */ 242, 464, 1067, 1531, 1084, 488, 1531, 1084, 425, 424, /* 810 */ 1396, 1398, 520, 1029, 1029, 456, 116, 116, 116, 116, /* 820 */ 115, 115, 114, 114, 114, 113, 415, 535, 235, 264, /* 830 */ 264, 508, 535, 393, 208, 1134, 384, 264, 264, 448, /* 840 */ 962, 448, 532, 261, 264, 264, 900, 507, 15, 15, /* 850 */ 532, 1026, 271, 44, 44, 1026, 1095, 532, 535, 900, /* 860 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117, /* 870 */ 117, 118, 118, 118, 118, 1065, 425, 1045, 1396, 56, /* 880 */ 56, 535, 368, 1066, 1231, 1231, 1134, 454, 535, 324, /* 890 */ 389, 355, 1046, 234, 233, 232, 512, 459, 459, 459, /* 900 */ 272, 448, 57, 57, 1095, 1438, 329, 1047, 535, 58, /* 910 */ 58, 421, 477, 116, 116, 116, 116, 115, 115, 114, /* 920 */ 114, 114, 113, 415, 1323, 535, 515, 535, 523, 59, /* 930 */ 59, 208, 273, 384, 310, 1435, 1323, 946, 876, 1240, /* 940 */ 1236, 317, 1456, 875, 136, 6, 60, 60, 61, 61, /* 950 */ 319, 535, 322, 384, 535, 1157, 900, 119, 120, 110, /* 960 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118, /* 970 */ 118, 118, 45, 45, 535, 46, 46, 119, 120, 110, /* 980 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118, /* 990 */ 118, 118, 399, 338, 276, 48, 48, 337, 1477, 479, /* 1000 */ 535, 107, 1451, 535, 455, 535, 1119, 95, 1338, 235, /* 1010 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113, /* 1020 */ 415, 49, 49, 123, 62, 62, 63, 63, 535, 408, /* 1030 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113, /* 1040 */ 415, 535, 142, 535, 481, 535, 1323, 535, 1503, 64, /* 1050 */ 64, 845, 1454, 1337, 535, 6, 535, 1119, 535, 357, /* 1060 */ 535, 353, 14, 14, 65, 65, 125, 125, 66, 66, /* 1070 */ 535, 389, 535, 291, 535, 51, 51, 67, 67, 68, /* 1080 */ 68, 52, 52, 292, 1453, 98, 535, 6, 535, 481, /* 1090 */ 535, 147, 147, 148, 148, 75, 75, 535, 915, 535, /* 1100 */ 827, 201, 200, 528, 390, 384, 916, 53, 53, 71, /* 1110 */ 71, 126, 126, 515, 409, 288, 526, 216, 72, 72, /* 1120 */ 127, 127, 391, 161, 535, 384, 535, 263, 206, 119, /* 1130 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117, /* 1140 */ 118, 118, 118, 118, 535, 128, 128, 124, 124, 119, /* 1150 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117, /* 1160 */ 118, 118, 118, 118, 446, 146, 146, 102, 1209, 100, /* 1170 */ 1133, 212, 139, 535, 38, 437, 1062, 308, 535, 370, /* 1180 */ 95, 295, 116, 116, 116, 116, 115, 115, 114, 114, /* 1190 */ 114, 113, 415, 535, 145, 145, 535, 938, 535, 132, /* 1200 */ 132, 535, 116, 116, 116, 116, 115, 115, 114, 114, /* 1210 */ 114, 113, 415, 535, 131, 131, 1151, 129, 129, 130, /* 1220 */ 130, 30, 74, 74, 535, 17, 535, 218, 535, 943, /* 1230 */ 441, 1277, 241, 241, 76, 76, 443, 101, 313, 241, /* 1240 */ 465, 95, 1023, 237, 1023, 73, 73, 43, 43, 47, /* 1250 */ 47, 335, 31, 327, 447, 266, 95, 384, 1276, 835, /* 1260 */ 834, 334, 193, 1007, 436, 429, 237, 825, 842, 843, /* 1270 */ 1011, 909, 873, 955, 241, 107, 1022, 384, 1022, 197, /* 1280 */ 1441, 119, 120, 110, 1136, 1136, 981, 984, 974, 974, /* 1290 */ 117, 117, 118, 118, 118, 118, 809, 305, 1264, 137, /* 1300 */ 1415, 119, 108, 110, 1136, 1136, 981, 984, 974, 974, /* 1310 */ 117, 117, 118, 118, 118, 118, 874, 522, 825, 107, /* 1320 */ 283, 1011, 1414, 1470, 955, 451, 314, 1273, 318, 321, /* 1330 */ 323, 325, 1224, 1208, 116, 116, 116, 116, 115, 115, /* 1340 */ 114, 114, 114, 113, 415, 330, 339, 340, 1285, 1322, /* 1350 */ 1260, 1271, 521, 1328, 116, 116, 116, 116, 115, 115, /* 1360 */ 114, 114, 114, 113, 415, 1191, 256, 1493, 1184, 1173, /* 1370 */ 460, 1172, 1174, 1257, 384, 342, 1487, 344, 346, 199, /* 1380 */ 195, 367, 11, 211, 307, 445, 1307, 428, 1315, 375, /* 1390 */ 203, 1207, 470, 188, 384, 189, 525, 1490, 1151, 120, /* 1400 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118, /* 1410 */ 118, 118, 118, 333, 1387, 1386, 245, 300, 348, 1434, /* 1420 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118, /* 1430 */ 118, 118, 118, 198, 360, 163, 1432, 1148, 78, 81, /* 1440 */ 392, 82, 1392, 439, 173, 105, 527, 157, 4, 165, /* 1450 */ 1312, 116, 116, 116, 116, 115, 115, 114, 114, 114, /* 1460 */ 113, 415, 530, 93, 35, 431, 432, 1304, 168, 463, /* 1470 */ 221, 116, 116, 116, 116, 115, 115, 114, 114, 114, /* 1480 */ 113, 415, 169, 170, 171, 416, 372, 438, 1318, 177, /* 1490 */ 452, 374, 36, 225, 1381, 87, 458, 524, 257, 1403, /* 1500 */ 316, 105, 527, 227, 4, 182, 461, 160, 320, 228, /* 1510 */ 377, 1175, 229, 476, 405, 1227, 1226, 1225, 530, 827, /* 1520 */ 961, 1218, 378, 1199, 1198, 407, 103, 103, 281, 1217, /* 1530 */ 8, 332, 1197, 104, 1502, 416, 537, 536, 282, 487, /* 1540 */ 951, 416, 490, 496, 1268, 92, 341, 243, 244, 1461, /* 1550 */ 1269, 1267, 122, 524, 1266, 515, 10, 288, 526, 343, /* 1560 */ 352, 1460, 354, 99, 504, 94, 499, 251, 1181, 503, /* 1570 */ 194, 951, 951, 953, 954, 27, 961, 1250, 345, 347, /* 1580 */ 1249, 358, 103, 103, 359, 34, 538, 1110, 1367, 104, /* 1590 */ 255, 416, 537, 536, 539, 1170, 951, 286, 252, 254, /* 1600 */ 149, 1165, 1419, 135, 1420, 785, 279, 1418, 417, 1417, /* 1610 */ 1195, 196, 150, 290, 210, 269, 151, 1021, 133, 1194, /* 1620 */ 1019, 935, 162, 386, 387, 77, 1192, 951, 951, 953, /* 1630 */ 954, 27, 1479, 1104, 418, 164, 153, 268, 217, 166, /* 1640 */ 859, 306, 366, 366, 365, 253, 363, 220, 1035, 798, /* 1650 */ 172, 939, 105, 527, 155, 4, 394, 174, 396, 83, /* 1660 */ 84, 85, 213, 86, 294, 1038, 156, 223, 222, 530, /* 1670 */ 1034, 144, 293, 18, 224, 241, 315, 1027, 1145, 178, /* 1680 */ 457, 226, 37, 179, 800, 334, 462, 230, 328, 466, /* 1690 */ 180, 471, 416, 88, 19, 20, 89, 280, 838, 158, /* 1700 */ 191, 478, 215, 1097, 524, 90, 204, 192, 987, 91, /* 1710 */ 152, 1070, 39, 154, 1071, 504, 486, 40, 489, 205, /* 1720 */ 505, 260, 105, 527, 214, 4, 908, 961, 262, 183, /* 1730 */ 240, 21, 903, 103, 103, 107, 22, 1086, 23, 530, /* 1740 */ 104, 1074, 416, 537, 536, 24, 1088, 951, 25, 1093, /* 1750 */ 1090, 1094, 7, 33, 511, 186, 26, 1002, 385, 95, /* 1760 */ 988, 986, 416, 288, 526, 990, 1044, 246, 1043, 247, /* 1770 */ 991, 28, 41, 106, 524, 956, 810, 29, 951, 951, /* 1780 */ 953, 954, 27, 531, 869, 504, 423, 248, 249, 1495, /* 1790 */ 503, 1494, 361, 364, 1105, 1161, 1161, 961, 1161, 1161, /* 1800 */ 1161, 1161, 1161, 103, 103, 1161, 1161, 1161, 1161, 1161, /* 1810 */ 104, 1161, 416, 537, 536, 1104, 418, 951, 1161, 268, /* 1820 */ 1161, 1161, 1161, 1161, 366, 366, 365, 253, 363, 1161, /* 1830 */ 1161, 798, 1161, 1161, 1161, 1161, 105, 527, 1161, 4, /* 1840 */ 1161, 1161, 1161, 1161, 213, 1161, 294, 1161, 951, 951, /* 1850 */ 953, 954, 27, 530, 293, 1161, 1161, 1161, 1161, 1161, /* 1860 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, /* 1870 */ 1161, 1161, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161, /* 1880 */ 1161, 1161, 1161, 1161, 215, 1161, 1161, 1161, 524, 1161, /* 1890 */ 1161, 1161, 152, 1161, 1161, 154, 105, 527, 1161, 4, /* 1900 */ 1161, 1161, 1161, 1161, 1161, 1161, 214, 1161, 1161, 1161, /* 1910 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 880, /* 1920 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161, /* 1930 */ 1161, 951, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161, /* 1940 */ 385, 1161, 1161, 1161, 1161, 288, 526, 1161, 524, 1161, /* 1950 */ 1161, 1161, 1161, 1161, 1161, 1161, 97, 527, 1161, 4, /* 1960 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 423, 1161, /* 1970 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 1161, /* 1980 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161, /* 1990 */ 1161, 951, 268, 1161, 1161, 1161, 416, 366, 366, 365, /* 2000 */ 253, 363, 1161, 1161, 798, 1161, 1161, 1161, 524, 1161, /* 2010 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 213, 1161, 294, /* 2020 */ 1161, 1161, 951, 951, 953, 954, 27, 293, 1161, 1161, /* 2030 */ 1161, 961, 1161, 1161, 1161, 1161, 1161, 103, 103, 1161, /* 2040 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161, /* 2050 */ 1161, 951, 1161, 1161, 1161, 1161, 1161, 215, 1161, 1161, /* 2060 */ 1161, 1161, 1161, 1161, 1161, 152, 1161, 1161, 154, 1161, /* 2070 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 214, /* 2080 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 1161, 1161, /* 2090 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, /* 2100 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, /* 2110 */ 1161, 1161, 1161, 385, 1161, 1161, 1161, 1161, 288, 526, /* 2120 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, /* 2130 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, /* 2140 */ 1161, 423, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 172, 242, 243, 244, 167, 167, 167, 186, 159, 160, /* 10 */ 161, 162, 163, 164, 167, 191, 187, 179, 169, 19, /* 20 */ 171, 162, 263, 164, 195, 188, 189, 178, 169, 178, /* 30 */ 171, 31, 188, 167, 22, 188, 189, 178, 24, 39, /* 40 */ 242, 243, 244, 43, 44, 45, 46, 47, 48, 49, /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 210, /* 60 */ 211, 210, 211, 242, 243, 244, 242, 243, 244, 210, /* 70 */ 211, 59, 223, 59, 223, 22, 237, 249, 227, 228, /* 80 */ 188, 253, 223, 246, 188, 236, 54, 55, 56, 57, /* 90 */ 58, 167, 167, 206, 207, 236, 96, 97, 98, 99, /* 100 */ 100, 101, 102, 103, 104, 105, 106, 210, 211, 242, /* 110 */ 243, 244, 59, 188, 189, 266, 19, 251, 201, 59, /* 120 */ 223, 109, 110, 111, 110, 266, 279, 280, 96, 97, /* 130 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 94, /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, /* 150 */ 53, 54, 55, 56, 57, 110, 195, 196, 59, 114, /* 160 */ 100, 101, 109, 110, 111, 204, 167, 128, 108, 109, /* 170 */ 110, 111, 133, 113, 73, 102, 103, 104, 105, 106, /* 180 */ 83, 121, 85, 54, 55, 56, 57, 188, 189, 26, /* 190 */ 145, 146, 147, 96, 97, 98, 99, 100, 101, 102, /* 200 */ 103, 104, 105, 106, 279, 145, 281, 147, 109, 110, /* 210 */ 111, 112, 106, 19, 115, 116, 117, 100, 101, 167, /* 220 */ 26, 120, 121, 122, 125, 96, 97, 98, 99, 100, /* 230 */ 101, 102, 103, 104, 105, 106, 81, 43, 44, 45, /* 240 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, /* 250 */ 56, 57, 100, 101, 102, 103, 104, 105, 106, 183, /* 260 */ 184, 185, 145, 69, 147, 96, 97, 98, 99, 100, /* 270 */ 101, 102, 103, 104, 105, 106, 73, 167, 279, 280, /* 280 */ 167, 22, 23, 19, 81, 26, 131, 132, 59, 237, /* 290 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 300 */ 106, 188, 189, 19, 167, 142, 167, 43, 44, 45, /* 310 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, /* 320 */ 56, 57, 212, 120, 112, 188, 189, 115, 116, 117, /* 330 */ 238, 67, 22, 23, 131, 132, 22, 125, 109, 110, /* 340 */ 111, 167, 161, 162, 163, 164, 46, 47, 48, 49, /* 350 */ 169, 19, 171, 167, 95, 127, 24, 129, 130, 178, /* 360 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 370 */ 106, 59, 143, 59, 167, 43, 44, 45, 46, 47, /* 380 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 390 */ 106, 210, 211, 26, 167, 209, 112, 113, 114, 115, /* 400 */ 116, 117, 118, 167, 223, 95, 94, 167, 124, 235, /* 410 */ 178, 272, 273, 167, 114, 188, 189, 236, 183, 184, /* 420 */ 185, 109, 110, 109, 110, 111, 114, 167, 96, 97, /* 430 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 59, /* 440 */ 167, 167, 210, 211, 59, 209, 167, 266, 19, 209, /* 450 */ 59, 224, 23, 211, 16, 223, 76, 145, 146, 147, /* 460 */ 233, 188, 189, 72, 84, 223, 86, 188, 189, 89, /* 470 */ 238, 167, 43, 44, 45, 46, 47, 48, 49, 50, /* 480 */ 51, 52, 53, 54, 55, 56, 57, 102, 167, 109, /* 490 */ 110, 111, 188, 189, 109, 110, 111, 224, 131, 132, /* 500 */ 109, 110, 111, 224, 264, 19, 233, 105, 106, 188, /* 510 */ 189, 237, 233, 35, 167, 77, 167, 79, 138, 22, /* 520 */ 274, 275, 22, 202, 278, 96, 97, 98, 99, 100, /* 530 */ 101, 102, 103, 104, 105, 106, 275, 188, 189, 278, /* 540 */ 167, 11, 59, 167, 66, 19, 167, 121, 122, 23, /* 550 */ 76, 202, 74, 167, 178, 72, 59, 178, 84, 59, /* 560 */ 86, 188, 189, 89, 188, 189, 59, 188, 189, 43, /* 570 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, /* 580 */ 54, 55, 56, 57, 26, 167, 210, 211, 59, 210, /* 590 */ 211, 153, 109, 110, 111, 109, 22, 224, 167, 223, /* 600 */ 224, 123, 223, 224, 21, 215, 109, 110, 111, 233, /* 610 */ 110, 167, 138, 186, 167, 225, 109, 110, 111, 188, /* 620 */ 189, 203, 96, 97, 98, 99, 100, 101, 102, 103, /* 630 */ 104, 105, 106, 59, 76, 188, 189, 167, 109, 110, /* 640 */ 111, 59, 19, 136, 86, 197, 23, 89, 167, 202, /* 650 */ 81, 121, 122, 269, 270, 224, 212, 178, 188, 189, /* 660 */ 274, 275, 167, 80, 278, 136, 43, 44, 45, 46, /* 670 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 680 */ 57, 12, 113, 109, 110, 111, 259, 167, 186, 210, /* 690 */ 211, 109, 110, 111, 224, 167, 27, 210, 211, 116, /* 700 */ 131, 132, 223, 7, 8, 9, 167, 212, 188, 189, /* 710 */ 223, 42, 167, 167, 178, 234, 188, 189, 179, 96, /* 720 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, /* 730 */ 202, 167, 63, 167, 188, 189, 153, 167, 199, 19, /* 740 */ 201, 175, 73, 23, 224, 179, 210, 211, 202, 26, /* 750 */ 197, 178, 188, 189, 178, 275, 254, 167, 278, 223, /* 760 */ 167, 259, 167, 43, 44, 45, 46, 47, 48, 49, /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 188, 189, /* 780 */ 235, 188, 189, 210, 211, 167, 210, 211, 224, 181, /* 790 */ 182, 167, 202, 167, 76, 202, 223, 178, 22, 223, /* 800 */ 24, 19, 22, 23, 86, 178, 26, 89, 184, 185, /* 810 */ 184, 185, 178, 120, 121, 122, 96, 97, 98, 99, /* 820 */ 100, 101, 102, 103, 104, 105, 106, 167, 46, 210, /* 830 */ 211, 66, 167, 167, 111, 59, 19, 210, 211, 167, /* 840 */ 23, 167, 223, 23, 210, 211, 26, 82, 188, 189, /* 850 */ 223, 29, 234, 188, 189, 33, 91, 223, 167, 136, /* 860 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, /* 870 */ 53, 54, 55, 56, 57, 95, 252, 12, 252, 188, /* 880 */ 189, 167, 22, 23, 206, 207, 110, 65, 167, 16, /* 890 */ 108, 167, 27, 120, 121, 122, 167, 167, 167, 167, /* 900 */ 234, 167, 188, 189, 139, 167, 124, 42, 167, 188, /* 910 */ 189, 167, 102, 96, 97, 98, 99, 100, 101, 102, /* 920 */ 103, 104, 105, 106, 167, 167, 138, 167, 63, 188, /* 930 */ 189, 111, 260, 19, 260, 167, 167, 23, 128, 209, /* 940 */ 209, 209, 275, 133, 156, 278, 188, 189, 188, 189, /* 950 */ 77, 167, 79, 19, 167, 95, 136, 43, 44, 45, /* 960 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, /* 970 */ 56, 57, 188, 189, 167, 188, 189, 43, 44, 45, /* 980 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, /* 990 */ 56, 57, 235, 167, 260, 188, 189, 167, 157, 158, /* 1000 */ 167, 26, 273, 167, 235, 167, 59, 26, 241, 46, /* 1010 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 1020 */ 106, 188, 189, 22, 188, 189, 188, 189, 167, 203, /* 1030 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 1040 */ 106, 167, 212, 167, 277, 167, 167, 167, 23, 188, /* 1050 */ 189, 26, 275, 241, 167, 278, 167, 110, 167, 220, /* 1060 */ 167, 222, 188, 189, 188, 189, 188, 189, 188, 189, /* 1070 */ 167, 108, 167, 167, 167, 188, 189, 188, 189, 188, /* 1080 */ 189, 188, 189, 167, 275, 151, 167, 278, 167, 277, /* 1090 */ 167, 188, 189, 188, 189, 188, 189, 167, 31, 167, /* 1100 */ 119, 100, 101, 181, 182, 19, 39, 188, 189, 188, /* 1110 */ 189, 188, 189, 138, 235, 131, 132, 24, 188, 189, /* 1120 */ 188, 189, 267, 268, 167, 19, 167, 227, 228, 43, /* 1130 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, /* 1140 */ 54, 55, 56, 57, 167, 188, 189, 188, 189, 43, /* 1150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, /* 1160 */ 54, 55, 56, 57, 19, 188, 189, 150, 197, 152, /* 1170 */ 26, 15, 22, 167, 24, 122, 23, 23, 167, 26, /* 1180 */ 26, 167, 96, 97, 98, 99, 100, 101, 102, 103, /* 1190 */ 104, 105, 106, 167, 188, 189, 167, 144, 167, 188, /* 1200 */ 189, 167, 96, 97, 98, 99, 100, 101, 102, 103, /* 1210 */ 104, 105, 106, 167, 188, 189, 60, 188, 189, 188, /* 1220 */ 189, 22, 188, 189, 167, 22, 167, 134, 167, 23, /* 1230 */ 23, 167, 26, 26, 188, 189, 23, 151, 23, 26, /* 1240 */ 23, 26, 145, 26, 147, 188, 189, 188, 189, 188, /* 1250 */ 189, 114, 53, 23, 109, 22, 26, 19, 167, 113, /* 1260 */ 114, 124, 24, 23, 61, 167, 26, 59, 7, 8, /* 1270 */ 59, 23, 23, 59, 26, 26, 145, 19, 147, 135, /* 1280 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51, /* 1290 */ 52, 53, 54, 55, 56, 57, 23, 167, 229, 26, /* 1300 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51, /* 1310 */ 52, 53, 54, 55, 56, 57, 23, 207, 110, 26, /* 1320 */ 226, 110, 167, 283, 110, 167, 167, 167, 167, 167, /* 1330 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101, /* 1340 */ 102, 103, 104, 105, 106, 167, 167, 167, 167, 167, /* 1350 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101, /* 1360 */ 102, 103, 104, 105, 106, 167, 255, 134, 167, 167, /* 1370 */ 256, 167, 167, 226, 19, 226, 167, 226, 226, 186, /* 1380 */ 213, 165, 214, 265, 261, 261, 217, 230, 217, 217, /* 1390 */ 200, 196, 192, 220, 19, 220, 248, 170, 60, 44, /* 1400 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, /* 1410 */ 55, 56, 57, 191, 191, 191, 134, 230, 230, 174, /* 1420 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, /* 1430 */ 55, 56, 57, 214, 216, 265, 174, 38, 262, 262, /* 1440 */ 174, 143, 251, 108, 22, 19, 20, 43, 22, 205, /* 1450 */ 240, 96, 97, 98, 99, 100, 101, 102, 103, 104, /* 1460 */ 105, 106, 36, 142, 239, 18, 174, 217, 208, 18, /* 1470 */ 173, 96, 97, 98, 99, 100, 101, 102, 103, 104, /* 1480 */ 105, 106, 208, 208, 208, 59, 217, 217, 205, 205, /* 1490 */ 174, 240, 239, 173, 217, 150, 62, 71, 174, 258, /* 1500 */ 257, 19, 20, 173, 22, 22, 193, 81, 174, 173, /* 1510 */ 193, 174, 173, 108, 64, 190, 190, 190, 36, 119, /* 1520 */ 94, 198, 193, 190, 192, 106, 100, 101, 250, 198, /* 1530 */ 48, 190, 190, 107, 190, 109, 110, 111, 250, 193, /* 1540 */ 114, 59, 193, 137, 232, 108, 231, 174, 88, 282, /* 1550 */ 232, 232, 141, 71, 232, 138, 22, 131, 132, 231, /* 1560 */ 220, 282, 174, 150, 82, 140, 139, 25, 177, 87, /* 1570 */ 219, 145, 146, 147, 148, 149, 94, 221, 231, 231, /* 1580 */ 221, 218, 100, 101, 217, 26, 176, 13, 245, 107, /* 1590 */ 6, 109, 110, 111, 166, 166, 114, 247, 168, 168, /* 1600 */ 180, 166, 186, 194, 186, 4, 194, 186, 3, 186, /* 1610 */ 186, 22, 180, 155, 15, 93, 180, 23, 16, 186, /* 1620 */ 23, 132, 268, 271, 271, 186, 186, 145, 146, 147, /* 1630 */ 148, 149, 0, 1, 2, 143, 123, 5, 24, 135, /* 1640 */ 20, 16, 10, 11, 12, 13, 14, 137, 1, 17, /* 1650 */ 135, 144, 19, 20, 123, 22, 61, 143, 37, 53, /* 1660 */ 53, 53, 30, 53, 32, 109, 123, 134, 34, 36, /* 1670 */ 1, 5, 40, 22, 108, 26, 153, 68, 75, 68, /* 1680 */ 41, 134, 24, 108, 20, 124, 19, 118, 23, 67, /* 1690 */ 22, 67, 59, 22, 22, 22, 22, 67, 28, 37, /* 1700 */ 23, 22, 70, 23, 71, 142, 157, 23, 23, 26, /* 1710 */ 78, 23, 22, 81, 23, 82, 24, 22, 24, 134, /* 1720 */ 87, 23, 19, 20, 92, 22, 109, 94, 23, 22, /* 1730 */ 34, 34, 136, 100, 101, 26, 34, 85, 34, 36, /* 1740 */ 107, 23, 109, 110, 111, 34, 83, 114, 34, 90, /* 1750 */ 75, 75, 44, 22, 24, 26, 34, 23, 126, 26, /* 1760 */ 23, 23, 59, 131, 132, 23, 23, 26, 23, 22, /* 1770 */ 11, 22, 22, 22, 71, 23, 23, 22, 145, 146, /* 1780 */ 147, 148, 149, 26, 128, 82, 154, 134, 134, 134, /* 1790 */ 87, 134, 23, 15, 1, 284, 284, 94, 284, 284, /* 1800 */ 284, 284, 284, 100, 101, 284, 284, 284, 284, 284, /* 1810 */ 107, 284, 109, 110, 111, 1, 2, 114, 284, 5, /* 1820 */ 284, 284, 284, 284, 10, 11, 12, 13, 14, 284, /* 1830 */ 284, 17, 284, 284, 284, 284, 19, 20, 284, 22, /* 1840 */ 284, 284, 284, 284, 30, 284, 32, 284, 145, 146, /* 1850 */ 147, 148, 149, 36, 40, 284, 284, 284, 284, 284, /* 1860 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, /* 1870 */ 284, 284, 284, 284, 284, 284, 59, 284, 284, 284, /* 1880 */ 284, 284, 284, 284, 70, 284, 284, 284, 71, 284, /* 1890 */ 284, 284, 78, 284, 284, 81, 19, 20, 284, 22, /* 1900 */ 284, 284, 284, 284, 284, 284, 92, 284, 284, 284, /* 1910 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 102, /* 1920 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284, /* 1930 */ 284, 114, 284, 284, 284, 284, 59, 284, 284, 284, /* 1940 */ 126, 284, 284, 284, 284, 131, 132, 284, 71, 284, /* 1950 */ 284, 284, 284, 284, 284, 284, 19, 20, 284, 22, /* 1960 */ 284, 284, 145, 146, 147, 148, 149, 284, 154, 284, /* 1970 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 284, /* 1980 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284, /* 1990 */ 284, 114, 5, 284, 284, 284, 59, 10, 11, 12, /* 2000 */ 13, 14, 284, 284, 17, 284, 284, 284, 71, 284, /* 2010 */ 284, 284, 284, 284, 284, 284, 284, 30, 284, 32, /* 2020 */ 284, 284, 145, 146, 147, 148, 149, 40, 284, 284, /* 2030 */ 284, 94, 284, 284, 284, 284, 284, 100, 101, 284, /* 2040 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284, /* 2050 */ 284, 114, 284, 284, 284, 284, 284, 70, 284, 284, /* 2060 */ 284, 284, 284, 284, 284, 78, 284, 284, 81, 284, /* 2070 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 92, /* 2080 */ 284, 284, 145, 146, 147, 148, 149, 284, 284, 284, /* 2090 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, /* 2100 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, /* 2110 */ 284, 284, 284, 126, 284, 284, 284, 284, 131, 132, /* 2120 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, /* 2130 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, /* 2140 */ 284, 154, 284, 284, 284, 284, 284, 284, 284, 284, /* 2150 */ 284, 284, }; #define YY_SHIFT_COUNT (540) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (1987) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1814, 1632, 1987, 1426, 1426, 155, 1482, 1633, 1703, 1877, /* 10 */ 1877, 1877, 203, 0, 0, 264, 1106, 1877, 1877, 1877, /* 20 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, /* 30 */ 60, 60, 380, 380, 99, 569, 155, 155, 155, 155, /* 40 */ 155, 155, 97, 194, 332, 429, 526, 623, 720, 817, /* 50 */ 914, 934, 1086, 1238, 1106, 1106, 1106, 1106, 1106, 1106, /* 60 */ 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, /* 70 */ 1106, 1106, 1258, 1106, 1355, 1375, 1375, 1817, 1877, 1877, /* 80 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, /* 90 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, /* 100 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, /* 110 */ 1937, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, /* 120 */ 1877, 1877, 1877, 1877, 32, 129, 129, 129, 129, 129, /* 130 */ 169, 152, 73, 582, 583, 782, 582, 117, 117, 582, /* 140 */ 367, 367, 367, 367, 426, 402, 106, 2142, 2142, 284, /* 150 */ 284, 284, 229, 12, 391, 12, 12, 669, 669, 474, /* 160 */ 483, 259, 780, 582, 582, 582, 582, 582, 582, 582, /* 170 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, /* 180 */ 582, 582, 582, 582, 558, 558, 582, 530, 718, 718, /* 190 */ 947, 841, 841, 947, 788, 984, 2142, 2142, 2142, 312, /* 200 */ 45, 45, 53, 212, 314, 385, 497, 507, 529, 574, /* 210 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 101, /* 220 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, /* 230 */ 582, 582, 478, 478, 478, 582, 582, 582, 582, 820, /* 240 */ 582, 582, 582, 776, 765, 582, 582, 865, 582, 582, /* 250 */ 582, 582, 582, 582, 582, 582, 693, 822, 228, 14, /* 260 */ 14, 14, 14, 723, 228, 228, 810, 1001, 696, 1156, /* 270 */ 163, 486, 486, 1145, 163, 163, 1145, 981, 1025, 963, /* 280 */ 1067, 1067, 1067, 486, 975, 975, 1017, 1144, 39, 1150, /* 290 */ 1338, 1282, 1282, 1399, 1399, 1282, 1298, 1335, 1422, 1404, /* 300 */ 1321, 1447, 1447, 1447, 1447, 1282, 1451, 1321, 1321, 1335, /* 310 */ 1422, 1404, 1404, 1321, 1282, 1451, 1345, 1434, 1282, 1451, /* 320 */ 1483, 1282, 1451, 1282, 1451, 1483, 1405, 1405, 1405, 1450, /* 330 */ 1483, 1405, 1400, 1405, 1450, 1405, 1405, 1483, 1419, 1419, /* 340 */ 1483, 1406, 1437, 1406, 1437, 1406, 1437, 1406, 1437, 1282, /* 350 */ 1460, 1460, 1411, 1417, 1534, 1282, 1413, 1411, 1425, 1427, /* 360 */ 1321, 1542, 1559, 1574, 1574, 1584, 1584, 1584, 2142, 2142, /* 370 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, /* 380 */ 2142, 2142, 2142, 2142, 300, 438, 310, 860, 873, 773, /* 390 */ 500, 1153, 1199, 1093, 1053, 1154, 1203, 1206, 1207, 1213, /* 400 */ 1215, 1217, 1230, 1208, 1146, 1261, 1137, 1211, 1240, 1248, /* 410 */ 1249, 1097, 1131, 1273, 1293, 1214, 1233, 1601, 1605, 1589, /* 420 */ 1458, 1599, 1522, 1602, 1594, 1597, 1489, 1492, 1513, 1614, /* 430 */ 1504, 1620, 1510, 1625, 1647, 1515, 1507, 1531, 1595, 1621, /* 440 */ 1514, 1606, 1607, 1608, 1610, 1543, 1556, 1634, 1533, 1669, /* 450 */ 1666, 1651, 1566, 1523, 1609, 1649, 1611, 1603, 1639, 1547, /* 460 */ 1575, 1658, 1664, 1667, 1561, 1569, 1668, 1622, 1671, 1672, /* 470 */ 1665, 1673, 1624, 1670, 1674, 1630, 1662, 1677, 1563, 1679, /* 480 */ 1680, 1549, 1684, 1685, 1683, 1688, 1690, 1692, 1691, 1695, /* 490 */ 1694, 1585, 1698, 1705, 1617, 1696, 1707, 1596, 1709, 1697, /* 500 */ 1702, 1704, 1711, 1652, 1675, 1663, 1708, 1676, 1659, 1714, /* 510 */ 1718, 1731, 1730, 1729, 1733, 1722, 1734, 1709, 1737, 1738, /* 520 */ 1742, 1743, 1741, 1745, 1747, 1759, 1749, 1750, 1752, 1753, /* 530 */ 1751, 1755, 1757, 1656, 1653, 1654, 1655, 1657, 1769, 1778, /* 540 */ 1793, }; #define YY_REDUCE_COUNT (383) #define YY_REDUCE_MIN (-241) #define YY_REDUCE_MAX (1440) static const short yy_reduce_ofst[] = { /* 0 */ -151, 181, -141, 376, 379, -149, -153, -75, -1, 227, /* 10 */ 273, 279, 232, -176, -133, -241, -179, 321, 349, 447, /* 20 */ 528, 373, 546, 590, 431, 470, 593, -163, 520, 564, /* 30 */ 624, 626, 246, 386, 539, 479, 536, 573, 576, 619, /* 40 */ 627, 634, -202, -202, -202, -202, -202, -202, -202, -202, /* 50 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, /* 60 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, /* 70 */ -202, -202, -202, -202, -202, -202, -202, 113, 137, 304, /* 80 */ 660, 665, 691, 714, 721, 741, 758, 760, 784, 787, /* 90 */ 807, 833, 836, 838, 861, 874, 876, 878, 880, 887, /* 100 */ 889, 891, 893, 903, 905, 907, 919, 921, 923, 930, /* 110 */ 932, 957, 959, 977, 1006, 1011, 1026, 1029, 1031, 1034, /* 120 */ 1046, 1057, 1059, 1061, -202, -202, -202, -202, -202, -202, /* 130 */ -202, -202, -202, 240, -172, -39, 139, 76, 235, 566, /* 140 */ -103, 487, -103, 487, 502, -202, -202, -202, -202, -171, /* 150 */ -171, -171, -134, -161, 110, 52, 274, -113, 678, 261, /* 160 */ 444, 384, 384, -162, 481, 618, 666, 495, 186, 236, /* 170 */ 730, 731, 672, 174, 674, 545, 757, 734, 769, 732, /* 180 */ 418, 830, 826, 879, 480, 667, 729, 427, 777, 809, /* 190 */ 608, 767, 812, 922, 839, 242, 855, 900, 390, -156, /* 200 */ -108, -104, -76, -83, 207, 260, 347, 570, 595, 724, /* 210 */ 738, 744, 768, 906, 916, 1014, 1064, 1091, 1098, 92, /* 220 */ 1113, 1130, 1133, 1155, 1158, 1159, 1160, 1161, 1162, 1163, /* 230 */ 1164, 1165, 448, 553, 971, 1166, 1178, 1179, 1180, 1069, /* 240 */ 1181, 1182, 1183, 1094, 1040, 1184, 1185, 1110, 1186, 260, /* 250 */ 1198, 1201, 1202, 1204, 1205, 1209, 1114, 1111, 1167, 1147, /* 260 */ 1149, 1151, 1152, 1069, 1167, 1167, 1168, 1193, 1216, 1118, /* 270 */ 1169, 1157, 1187, 1123, 1171, 1172, 1124, 1200, 1190, 1195, /* 280 */ 1222, 1223, 1224, 1188, 1173, 1175, 1148, 1218, 1219, 1227, /* 290 */ 1170, 1245, 1262, 1176, 1177, 1266, 1191, 1210, 1225, 1244, /* 300 */ 1250, 1260, 1274, 1275, 1276, 1292, 1297, 1269, 1270, 1251, /* 310 */ 1253, 1283, 1284, 1277, 1316, 1320, 1241, 1243, 1324, 1330, /* 320 */ 1313, 1334, 1336, 1337, 1339, 1317, 1325, 1326, 1327, 1323, /* 330 */ 1329, 1333, 1332, 1341, 1331, 1342, 1344, 1346, 1278, 1288, /* 340 */ 1349, 1312, 1315, 1318, 1328, 1319, 1347, 1322, 1348, 1373, /* 350 */ 1267, 1279, 1356, 1340, 1343, 1388, 1350, 1359, 1351, 1363, /* 360 */ 1367, 1391, 1410, 1430, 1431, 1428, 1429, 1435, 1352, 1353, /* 370 */ 1354, 1420, 1416, 1418, 1421, 1423, 1432, 1409, 1412, 1424, /* 380 */ 1433, 1439, 1440, 1436, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 1536, 1536, 1536, 1376, 1159, 1265, 1159, 1159, 1159, 1376, /* 10 */ 1376, 1376, 1159, 1295, 1295, 1429, 1190, 1159, 1159, 1159, /* 20 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1375, 1159, 1159, /* 30 */ 1159, 1159, 1459, 1459, 1159, 1159, 1159, 1159, 1159, 1159, /* 40 */ 1159, 1159, 1159, 1301, 1159, 1159, 1159, 1159, 1159, 1377, /* 50 */ 1378, 1159, 1159, 1159, 1428, 1430, 1393, 1311, 1310, 1309, /* 60 */ 1308, 1411, 1282, 1306, 1299, 1303, 1371, 1372, 1370, 1374, /* 70 */ 1378, 1377, 1159, 1302, 1342, 1356, 1341, 1159, 1159, 1159, /* 80 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 90 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 100 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 110 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 120 */ 1159, 1159, 1159, 1159, 1350, 1355, 1361, 1354, 1351, 1344, /* 130 */ 1343, 1345, 1346, 1159, 1180, 1229, 1159, 1159, 1159, 1159, /* 140 */ 1447, 1446, 1159, 1159, 1190, 1347, 1348, 1358, 1357, 1436, /* 150 */ 1492, 1491, 1394, 1159, 1159, 1159, 1159, 1159, 1159, 1459, /* 160 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 170 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 180 */ 1159, 1159, 1159, 1159, 1459, 1459, 1159, 1190, 1459, 1459, /* 190 */ 1186, 1336, 1335, 1186, 1289, 1159, 1442, 1265, 1256, 1159, /* 200 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 210 */ 1159, 1159, 1159, 1433, 1431, 1159, 1159, 1159, 1159, 1159, /* 220 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 230 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 240 */ 1159, 1159, 1159, 1261, 1159, 1159, 1159, 1159, 1159, 1159, /* 250 */ 1159, 1159, 1159, 1159, 1159, 1486, 1159, 1406, 1243, 1261, /* 260 */ 1261, 1261, 1261, 1263, 1244, 1242, 1255, 1190, 1166, 1528, /* 270 */ 1305, 1284, 1284, 1525, 1305, 1305, 1525, 1204, 1506, 1201, /* 280 */ 1295, 1295, 1295, 1284, 1289, 1289, 1373, 1262, 1255, 1159, /* 290 */ 1528, 1270, 1270, 1527, 1527, 1270, 1394, 1314, 1320, 1232, /* 300 */ 1305, 1238, 1238, 1238, 1238, 1270, 1177, 1305, 1305, 1314, /* 310 */ 1320, 1232, 1232, 1305, 1270, 1177, 1410, 1522, 1270, 1177, /* 320 */ 1384, 1270, 1177, 1270, 1177, 1384, 1230, 1230, 1230, 1219, /* 330 */ 1384, 1230, 1204, 1230, 1219, 1230, 1230, 1384, 1388, 1388, /* 340 */ 1384, 1288, 1283, 1288, 1283, 1288, 1283, 1288, 1283, 1270, /* 350 */ 1469, 1469, 1300, 1289, 1379, 1270, 1159, 1300, 1298, 1296, /* 360 */ 1305, 1183, 1222, 1489, 1489, 1485, 1485, 1485, 1533, 1533, /* 370 */ 1442, 1501, 1190, 1190, 1190, 1190, 1501, 1206, 1206, 1190, /* 380 */ 1190, 1190, 1190, 1501, 1159, 1159, 1159, 1159, 1159, 1159, /* 390 */ 1496, 1159, 1395, 1274, 1159, 1159, 1159, 1159, 1159, 1159, /* 400 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 410 */ 1159, 1159, 1159, 1159, 1159, 1159, 1325, 1159, 1162, 1439, /* 420 */ 1159, 1159, 1437, 1159, 1159, 1159, 1159, 1159, 1159, 1275, /* 430 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 440 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1524, 1159, /* 450 */ 1159, 1159, 1159, 1159, 1159, 1409, 1408, 1159, 1159, 1272, /* 460 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 470 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 480 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 490 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1297, 1159, /* 500 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 510 */ 1159, 1159, 1159, 1474, 1290, 1159, 1159, 1515, 1159, 1159, /* 520 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, /* 530 */ 1159, 1159, 1510, 1246, 1327, 1159, 1326, 1330, 1159, 1171, /* 540 */ 1159, }; /********** End of lemon-generated parsing tables *****************************/ /* The next table maps tokens (terminal symbols) into fallback tokens. ** If a construct like the following: ** ** %fallback ID X Y Z. |
︙ | ︙ | |||
148510 148511 148512 148513 148514 148515 148516 148517 148518 148519 148520 148521 148522 148523 | 59, /* WITH => ID */ 59, /* CURRENT => ID */ 59, /* FOLLOWING => ID */ 59, /* PARTITION => ID */ 59, /* PRECEDING => ID */ 59, /* RANGE => ID */ 59, /* UNBOUNDED => ID */ 59, /* REINDEX => ID */ 59, /* RENAME => ID */ 59, /* CTIME_KW => ID */ }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the | > > > > | 149125 149126 149127 149128 149129 149130 149131 149132 149133 149134 149135 149136 149137 149138 149139 149140 149141 149142 | 59, /* WITH => ID */ 59, /* CURRENT => ID */ 59, /* FOLLOWING => ID */ 59, /* PARTITION => ID */ 59, /* PRECEDING => ID */ 59, /* RANGE => ID */ 59, /* UNBOUNDED => ID */ 59, /* EXCLUDE => ID */ 59, /* GROUPS => ID */ 59, /* OTHERS => ID */ 59, /* TIES => ID */ 59, /* REINDEX => ID */ 59, /* RENAME => ID */ 59, /* CTIME_KW => ID */ }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the |
︙ | ︙ | |||
148688 148689 148690 148691 148692 148693 148694 | /* 81 */ "WITH", /* 82 */ "CURRENT", /* 83 */ "FOLLOWING", /* 84 */ "PARTITION", /* 85 */ "PRECEDING", /* 86 */ "RANGE", /* 87 */ "UNBOUNDED", | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > | 149307 149308 149309 149310 149311 149312 149313 149314 149315 149316 149317 149318 149319 149320 149321 149322 149323 149324 149325 149326 149327 149328 149329 149330 149331 149332 149333 149334 149335 149336 149337 149338 149339 149340 149341 149342 149343 149344 149345 149346 149347 149348 149349 149350 149351 149352 149353 149354 149355 149356 149357 149358 149359 149360 149361 149362 149363 149364 149365 149366 149367 149368 149369 149370 149371 149372 149373 149374 149375 149376 149377 149378 149379 149380 149381 149382 149383 149384 149385 149386 149387 149388 149389 149390 149391 149392 149393 149394 149395 149396 149397 149398 149399 149400 149401 149402 149403 149404 149405 149406 149407 149408 149409 149410 149411 149412 149413 149414 149415 149416 149417 149418 149419 149420 149421 149422 149423 149424 149425 149426 149427 149428 149429 149430 149431 149432 149433 149434 149435 149436 149437 149438 149439 149440 149441 149442 149443 149444 149445 149446 149447 149448 149449 149450 149451 149452 149453 149454 149455 149456 149457 149458 149459 149460 149461 149462 149463 149464 149465 149466 149467 149468 149469 149470 149471 149472 149473 149474 149475 149476 149477 149478 149479 149480 149481 149482 149483 149484 149485 149486 149487 149488 149489 149490 149491 149492 149493 149494 149495 149496 149497 149498 149499 149500 149501 149502 149503 149504 149505 149506 149507 149508 149509 149510 149511 149512 149513 149514 149515 149516 | /* 81 */ "WITH", /* 82 */ "CURRENT", /* 83 */ "FOLLOWING", /* 84 */ "PARTITION", /* 85 */ "PRECEDING", /* 86 */ "RANGE", /* 87 */ "UNBOUNDED", /* 88 */ "EXCLUDE", /* 89 */ "GROUPS", /* 90 */ "OTHERS", /* 91 */ "TIES", /* 92 */ "REINDEX", /* 93 */ "RENAME", /* 94 */ "CTIME_KW", /* 95 */ "ANY", /* 96 */ "BITAND", /* 97 */ "BITOR", /* 98 */ "LSHIFT", /* 99 */ "RSHIFT", /* 100 */ "PLUS", /* 101 */ "MINUS", /* 102 */ "STAR", /* 103 */ "SLASH", /* 104 */ "REM", /* 105 */ "CONCAT", /* 106 */ "COLLATE", /* 107 */ "BITNOT", /* 108 */ "ON", /* 109 */ "INDEXED", /* 110 */ "STRING", /* 111 */ "JOIN_KW", /* 112 */ "CONSTRAINT", /* 113 */ "DEFAULT", /* 114 */ "NULL", /* 115 */ "PRIMARY", /* 116 */ "UNIQUE", /* 117 */ "CHECK", /* 118 */ "REFERENCES", /* 119 */ "AUTOINCR", /* 120 */ "INSERT", /* 121 */ "DELETE", /* 122 */ "UPDATE", /* 123 */ "SET", /* 124 */ "DEFERRABLE", /* 125 */ "FOREIGN", /* 126 */ "DROP", /* 127 */ "UNION", /* 128 */ "ALL", /* 129 */ "EXCEPT", /* 130 */ "INTERSECT", /* 131 */ "SELECT", /* 132 */ "VALUES", /* 133 */ "DISTINCT", /* 134 */ "DOT", /* 135 */ "FROM", /* 136 */ "JOIN", /* 137 */ "USING", /* 138 */ "ORDER", /* 139 */ "GROUP", /* 140 */ "HAVING", /* 141 */ "LIMIT", /* 142 */ "WHERE", /* 143 */ "INTO", /* 144 */ "NOTHING", /* 145 */ "FLOAT", /* 146 */ "BLOB", /* 147 */ "INTEGER", /* 148 */ "VARIABLE", /* 149 */ "CASE", /* 150 */ "WHEN", /* 151 */ "THEN", /* 152 */ "ELSE", /* 153 */ "INDEX", /* 154 */ "ALTER", /* 155 */ "ADD", /* 156 */ "WINDOW", /* 157 */ "OVER", /* 158 */ "FILTER", /* 159 */ "input", /* 160 */ "cmdlist", /* 161 */ "ecmd", /* 162 */ "cmdx", /* 163 */ "explain", /* 164 */ "cmd", /* 165 */ "transtype", /* 166 */ "trans_opt", /* 167 */ "nm", /* 168 */ "savepoint_opt", /* 169 */ "create_table", /* 170 */ "create_table_args", /* 171 */ "createkw", /* 172 */ "temp", /* 173 */ "ifnotexists", /* 174 */ "dbnm", /* 175 */ "columnlist", /* 176 */ "conslist_opt", /* 177 */ "table_options", /* 178 */ "select", /* 179 */ "columnname", /* 180 */ "carglist", /* 181 */ "typetoken", /* 182 */ "typename", /* 183 */ "signed", /* 184 */ "plus_num", /* 185 */ "minus_num", /* 186 */ "scanpt", /* 187 */ "ccons", /* 188 */ "term", /* 189 */ "expr", /* 190 */ "onconf", /* 191 */ "sortorder", /* 192 */ "autoinc", /* 193 */ "eidlist_opt", /* 194 */ "refargs", /* 195 */ "defer_subclause", /* 196 */ "refarg", /* 197 */ "refact", /* 198 */ "init_deferred_pred_opt", /* 199 */ "conslist", /* 200 */ "tconscomma", /* 201 */ "tcons", /* 202 */ "sortlist", /* 203 */ "eidlist", /* 204 */ "defer_subclause_opt", /* 205 */ "orconf", /* 206 */ "resolvetype", /* 207 */ "raisetype", /* 208 */ "ifexists", /* 209 */ "fullname", /* 210 */ "selectnowith", /* 211 */ "oneselect", /* 212 */ "wqlist", /* 213 */ "multiselect_op", /* 214 */ "distinct", /* 215 */ "selcollist", /* 216 */ "from", /* 217 */ "where_opt", /* 218 */ "groupby_opt", /* 219 */ "having_opt", /* 220 */ "orderby_opt", /* 221 */ "limit_opt", /* 222 */ "window_clause", /* 223 */ "values", /* 224 */ "nexprlist", /* 225 */ "sclp", /* 226 */ "as", /* 227 */ "seltablist", /* 228 */ "stl_prefix", /* 229 */ "joinop", /* 230 */ "indexed_opt", /* 231 */ "on_opt", /* 232 */ "using_opt", /* 233 */ "exprlist", /* 234 */ "xfullname", /* 235 */ "idlist", /* 236 */ "with", /* 237 */ "setlist", /* 238 */ "insert_cmd", /* 239 */ "idlist_opt", /* 240 */ "upsert", /* 241 */ "over_clause", /* 242 */ "likeop", /* 243 */ "between_op", /* 244 */ "in_op", /* 245 */ "paren_exprlist", /* 246 */ "case_operand", /* 247 */ "case_exprlist", /* 248 */ "case_else", /* 249 */ "uniqueflag", /* 250 */ "collate", /* 251 */ "vinto", /* 252 */ "nmnum", /* 253 */ "trigger_decl", /* 254 */ "trigger_cmd_list", /* 255 */ "trigger_time", /* 256 */ "trigger_event", /* 257 */ "foreach_clause", /* 258 */ "when_clause", /* 259 */ "trigger_cmd", /* 260 */ "trnm", /* 261 */ "tridxby", /* 262 */ "database_kw_opt", /* 263 */ "key_opt", /* 264 */ "add_column_fullname", /* 265 */ "kwcolumn_opt", /* 266 */ "create_vtab", /* 267 */ "vtabarglist", /* 268 */ "vtabarg", /* 269 */ "vtabargtoken", /* 270 */ "lp", /* 271 */ "anylist", /* 272 */ "windowdefn_list", /* 273 */ "windowdefn", /* 274 */ "window", /* 275 */ "frame_opt", /* 276 */ "part_opt", /* 277 */ "filter_opt", /* 278 */ "range_or_rows", /* 279 */ "frame_bound", /* 280 */ "frame_bound_s", /* 281 */ "frame_bound_e", /* 282 */ "frame_exclude_opt", /* 283 */ "frame_exclude", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { |
︙ | ︙ | |||
149175 149176 149177 149178 149179 149180 149181 | /* 283 */ "lp ::= LP", /* 284 */ "with ::= WITH wqlist", /* 285 */ "with ::= WITH RECURSIVE wqlist", /* 286 */ "wqlist ::= nm eidlist_opt AS LP select RP", /* 287 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", /* 288 */ "windowdefn_list ::= windowdefn", /* 289 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | | | | | > > > | | | | < | | | | | | < < | | | | > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 149800 149801 149802 149803 149804 149805 149806 149807 149808 149809 149810 149811 149812 149813 149814 149815 149816 149817 149818 149819 149820 149821 149822 149823 149824 149825 149826 149827 149828 149829 149830 149831 149832 149833 149834 149835 149836 149837 149838 149839 149840 149841 149842 149843 149844 149845 149846 149847 149848 149849 149850 149851 149852 149853 149854 149855 149856 149857 149858 149859 149860 149861 149862 149863 149864 149865 149866 149867 149868 149869 149870 149871 149872 149873 149874 149875 149876 149877 149878 149879 149880 149881 149882 149883 149884 149885 149886 149887 149888 149889 149890 149891 149892 149893 149894 149895 149896 149897 149898 | /* 283 */ "lp ::= LP", /* 284 */ "with ::= WITH wqlist", /* 285 */ "with ::= WITH RECURSIVE wqlist", /* 286 */ "wqlist ::= nm eidlist_opt AS LP select RP", /* 287 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", /* 288 */ "windowdefn_list ::= windowdefn", /* 289 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", /* 290 */ "windowdefn ::= nm AS LP window RP", /* 291 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", /* 292 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", /* 293 */ "window ::= ORDER BY sortlist frame_opt", /* 294 */ "window ::= nm ORDER BY sortlist frame_opt", /* 295 */ "window ::= frame_opt", /* 296 */ "window ::= nm frame_opt", /* 297 */ "frame_opt ::=", /* 298 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", /* 299 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", /* 300 */ "range_or_rows ::= RANGE|ROWS|GROUPS", /* 301 */ "frame_bound_s ::= frame_bound", /* 302 */ "frame_bound_s ::= UNBOUNDED PRECEDING", /* 303 */ "frame_bound_e ::= frame_bound", /* 304 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", /* 305 */ "frame_bound ::= expr PRECEDING|FOLLOWING", /* 306 */ "frame_bound ::= CURRENT ROW", /* 307 */ "frame_exclude_opt ::=", /* 308 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", /* 309 */ "frame_exclude ::= NO OTHERS", /* 310 */ "frame_exclude ::= CURRENT ROW", /* 311 */ "frame_exclude ::= GROUP|TIES", /* 312 */ "window_clause ::= WINDOW windowdefn_list", /* 313 */ "over_clause ::= filter_opt OVER LP window RP", /* 314 */ "over_clause ::= filter_opt OVER nm", /* 315 */ "filter_opt ::=", /* 316 */ "filter_opt ::= FILTER LP WHERE expr RP", /* 317 */ "input ::= cmdlist", /* 318 */ "cmdlist ::= cmdlist ecmd", /* 319 */ "cmdlist ::= ecmd", /* 320 */ "ecmd ::= SEMI", /* 321 */ "ecmd ::= cmdx SEMI", /* 322 */ "ecmd ::= explain cmdx", /* 323 */ "trans_opt ::=", /* 324 */ "trans_opt ::= TRANSACTION", /* 325 */ "trans_opt ::= TRANSACTION nm", /* 326 */ "savepoint_opt ::= SAVEPOINT", /* 327 */ "savepoint_opt ::=", /* 328 */ "cmd ::= create_table create_table_args", /* 329 */ "columnlist ::= columnlist COMMA columnname carglist", /* 330 */ "columnlist ::= columnname carglist", /* 331 */ "nm ::= ID|INDEXED", /* 332 */ "nm ::= STRING", /* 333 */ "nm ::= JOIN_KW", /* 334 */ "typetoken ::= typename", /* 335 */ "typename ::= ID|STRING", /* 336 */ "signed ::= plus_num", /* 337 */ "signed ::= minus_num", /* 338 */ "carglist ::= carglist ccons", /* 339 */ "carglist ::=", /* 340 */ "ccons ::= NULL onconf", /* 341 */ "conslist_opt ::= COMMA conslist", /* 342 */ "conslist ::= conslist tconscomma tcons", /* 343 */ "conslist ::= tcons", /* 344 */ "tconscomma ::=", /* 345 */ "defer_subclause_opt ::= defer_subclause", /* 346 */ "resolvetype ::= raisetype", /* 347 */ "selectnowith ::= oneselect", /* 348 */ "oneselect ::= values", /* 349 */ "sclp ::= selcollist COMMA", /* 350 */ "as ::= ID|STRING", /* 351 */ "expr ::= term", /* 352 */ "likeop ::= LIKE_KW|MATCH", /* 353 */ "exprlist ::= nexprlist", /* 354 */ "nmnum ::= plus_num", /* 355 */ "nmnum ::= nm", /* 356 */ "nmnum ::= ON", /* 357 */ "nmnum ::= DELETE", /* 358 */ "nmnum ::= DEFAULT", /* 359 */ "plus_num ::= INTEGER|FLOAT", /* 360 */ "foreach_clause ::=", /* 361 */ "foreach_clause ::= FOR EACH ROW", /* 362 */ "trnm ::= nm", /* 363 */ "tridxby ::=", /* 364 */ "database_kw_opt ::= DATABASE", /* 365 */ "database_kw_opt ::=", /* 366 */ "kwcolumn_opt ::=", /* 367 */ "kwcolumn_opt ::= COLUMNKW", /* 368 */ "vtabarglist ::= vtabarg", /* 369 */ "vtabarglist ::= vtabarglist COMMA vtabarg", /* 370 */ "vtabarg ::= vtabarg vtabargtoken", /* 371 */ "anylist ::=", /* 372 */ "anylist ::= anylist LP anylist RP", /* 373 */ "anylist ::= anylist ANY", /* 374 */ "with ::=", }; #endif /* NDEBUG */ #if YYSTACKDEPTH<=0 /* ** Try to increase the size of the parser stack. Return the number |
︙ | ︙ | |||
149379 149380 149381 149382 149383 149384 149385 | ** 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. */ /********* Begin destructor definitions ***************************************/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 150010 150011 150012 150013 150014 150015 150016 150017 150018 150019 150020 150021 150022 150023 150024 150025 150026 150027 150028 150029 150030 150031 150032 150033 150034 150035 150036 150037 150038 150039 150040 150041 150042 150043 150044 150045 150046 150047 150048 150049 150050 150051 150052 150053 150054 150055 150056 150057 150058 150059 150060 150061 150062 150063 150064 150065 150066 150067 150068 150069 150070 150071 150072 150073 150074 150075 150076 150077 150078 150079 150080 150081 150082 150083 150084 150085 150086 150087 150088 150089 150090 150091 150092 150093 150094 150095 150096 150097 150098 150099 150100 150101 150102 150103 150104 150105 150106 150107 150108 150109 150110 150111 150112 150113 150114 | ** 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. */ /********* Begin destructor definitions ***************************************/ case 178: /* select */ case 210: /* selectnowith */ case 211: /* oneselect */ case 223: /* values */ { sqlite3SelectDelete(pParse->db, (yypminor->yy491)); } break; case 188: /* term */ case 189: /* expr */ case 217: /* where_opt */ case 219: /* having_opt */ case 231: /* on_opt */ case 246: /* case_operand */ case 248: /* case_else */ case 251: /* vinto */ case 258: /* when_clause */ case 263: /* key_opt */ case 277: /* filter_opt */ { sqlite3ExprDelete(pParse->db, (yypminor->yy130)); } break; case 193: /* eidlist_opt */ case 202: /* sortlist */ case 203: /* eidlist */ case 215: /* selcollist */ case 218: /* groupby_opt */ case 220: /* orderby_opt */ case 224: /* nexprlist */ case 225: /* sclp */ case 233: /* exprlist */ case 237: /* setlist */ case 245: /* paren_exprlist */ case 247: /* case_exprlist */ case 276: /* part_opt */ { sqlite3ExprListDelete(pParse->db, (yypminor->yy442)); } break; case 209: /* fullname */ case 216: /* from */ case 227: /* seltablist */ case 228: /* stl_prefix */ case 234: /* xfullname */ { sqlite3SrcListDelete(pParse->db, (yypminor->yy147)); } break; case 212: /* wqlist */ { sqlite3WithDelete(pParse->db, (yypminor->yy523)); } break; case 222: /* window_clause */ case 272: /* windowdefn_list */ { sqlite3WindowListDelete(pParse->db, (yypminor->yy395)); } break; case 232: /* using_opt */ case 235: /* idlist */ case 239: /* idlist_opt */ { sqlite3IdListDelete(pParse->db, (yypminor->yy200)); } break; case 241: /* over_clause */ case 273: /* windowdefn */ case 274: /* window */ case 275: /* frame_opt */ { sqlite3WindowDelete(pParse->db, (yypminor->yy395)); } break; case 254: /* trigger_cmd_list */ case 259: /* trigger_cmd */ { sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy524)); } break; case 256: /* trigger_event */ { sqlite3IdListDelete(pParse->db, (yypminor->yy498).b); } break; case 279: /* frame_bound */ case 280: /* frame_bound_s */ case 281: /* frame_bound_e */ { sqlite3ExprDelete(pParse->db, (yypminor->yy273).pExpr); } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
149764 149765 149766 149767 149768 149769 149770 | yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | | | | < | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 150395 150396 150397 150398 150399 150400 150401 150402 150403 150404 150405 150406 150407 150408 150409 150410 150411 150412 150413 150414 150415 150416 150417 150418 150419 150420 150421 150422 150423 150424 150425 150426 150427 150428 150429 150430 150431 150432 150433 150434 150435 150436 150437 150438 150439 150440 150441 150442 150443 150444 150445 150446 150447 150448 150449 150450 150451 150452 150453 150454 150455 150456 150457 150458 150459 150460 150461 150462 150463 150464 150465 150466 150467 150468 150469 150470 150471 150472 150473 150474 150475 150476 150477 150478 150479 150480 150481 150482 150483 150484 150485 150486 150487 150488 150489 150490 150491 150492 150493 150494 150495 150496 150497 150498 150499 150500 150501 150502 150503 150504 150505 150506 150507 150508 150509 150510 150511 150512 150513 150514 150515 150516 150517 150518 150519 150520 150521 150522 150523 150524 150525 150526 150527 150528 150529 150530 150531 150532 150533 150534 150535 150536 150537 150538 150539 150540 150541 150542 150543 150544 150545 150546 150547 150548 150549 150550 150551 150552 150553 150554 150555 150556 150557 150558 150559 150560 150561 150562 150563 150564 150565 150566 150567 150568 150569 150570 150571 150572 150573 150574 150575 150576 150577 150578 150579 150580 150581 150582 150583 150584 150585 150586 150587 150588 150589 150590 150591 150592 150593 150594 150595 150596 150597 150598 150599 150600 150601 150602 150603 150604 150605 150606 150607 150608 150609 150610 150611 150612 150613 150614 150615 150616 150617 150618 150619 150620 150621 150622 150623 150624 150625 150626 150627 150628 150629 150630 150631 150632 150633 150634 150635 150636 150637 150638 150639 150640 150641 150642 150643 150644 150645 150646 150647 150648 150649 150650 150651 150652 150653 150654 150655 150656 150657 150658 150659 150660 150661 150662 150663 150664 150665 150666 150667 150668 150669 150670 150671 150672 150673 150674 150675 150676 150677 150678 150679 150680 150681 150682 150683 150684 150685 150686 150687 150688 150689 150690 150691 150692 150693 150694 150695 150696 150697 150698 150699 150700 150701 150702 150703 150704 150705 150706 150707 150708 150709 150710 150711 150712 150713 150714 150715 150716 150717 150718 150719 150720 150721 150722 150723 150724 150725 150726 150727 150728 150729 150730 150731 150732 150733 150734 150735 150736 150737 150738 150739 150740 150741 150742 150743 150744 150745 150746 150747 150748 150749 150750 150751 150752 150753 150754 150755 150756 150757 150758 150759 150760 150761 150762 150763 150764 150765 150766 150767 150768 150769 150770 150771 150772 150773 150774 150775 150776 150777 150778 150779 150780 150781 150782 150783 | yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { 163, /* (0) explain ::= EXPLAIN */ 163, /* (1) explain ::= EXPLAIN QUERY PLAN */ 162, /* (2) cmdx ::= cmd */ 164, /* (3) cmd ::= BEGIN transtype trans_opt */ 165, /* (4) transtype ::= */ 165, /* (5) transtype ::= DEFERRED */ 165, /* (6) transtype ::= IMMEDIATE */ 165, /* (7) transtype ::= EXCLUSIVE */ 164, /* (8) cmd ::= COMMIT|END trans_opt */ 164, /* (9) cmd ::= ROLLBACK trans_opt */ 164, /* (10) cmd ::= SAVEPOINT nm */ 164, /* (11) cmd ::= RELEASE savepoint_opt nm */ 164, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ 169, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ 171, /* (14) createkw ::= CREATE */ 173, /* (15) ifnotexists ::= */ 173, /* (16) ifnotexists ::= IF NOT EXISTS */ 172, /* (17) temp ::= TEMP */ 172, /* (18) temp ::= */ 170, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ 170, /* (20) create_table_args ::= AS select */ 177, /* (21) table_options ::= */ 177, /* (22) table_options ::= WITHOUT nm */ 179, /* (23) columnname ::= nm typetoken */ 181, /* (24) typetoken ::= */ 181, /* (25) typetoken ::= typename LP signed RP */ 181, /* (26) typetoken ::= typename LP signed COMMA signed RP */ 182, /* (27) typename ::= typename ID|STRING */ 186, /* (28) scanpt ::= */ 187, /* (29) ccons ::= CONSTRAINT nm */ 187, /* (30) ccons ::= DEFAULT scanpt term scanpt */ 187, /* (31) ccons ::= DEFAULT LP expr RP */ 187, /* (32) ccons ::= DEFAULT PLUS term scanpt */ 187, /* (33) ccons ::= DEFAULT MINUS term scanpt */ 187, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */ 187, /* (35) ccons ::= NOT NULL onconf */ 187, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */ 187, /* (37) ccons ::= UNIQUE onconf */ 187, /* (38) ccons ::= CHECK LP expr RP */ 187, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */ 187, /* (40) ccons ::= defer_subclause */ 187, /* (41) ccons ::= COLLATE ID|STRING */ 192, /* (42) autoinc ::= */ 192, /* (43) autoinc ::= AUTOINCR */ 194, /* (44) refargs ::= */ 194, /* (45) refargs ::= refargs refarg */ 196, /* (46) refarg ::= MATCH nm */ 196, /* (47) refarg ::= ON INSERT refact */ 196, /* (48) refarg ::= ON DELETE refact */ 196, /* (49) refarg ::= ON UPDATE refact */ 197, /* (50) refact ::= SET NULL */ 197, /* (51) refact ::= SET DEFAULT */ 197, /* (52) refact ::= CASCADE */ 197, /* (53) refact ::= RESTRICT */ 197, /* (54) refact ::= NO ACTION */ 195, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ 195, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ 198, /* (57) init_deferred_pred_opt ::= */ 198, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */ 198, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ 176, /* (60) conslist_opt ::= */ 200, /* (61) tconscomma ::= COMMA */ 201, /* (62) tcons ::= CONSTRAINT nm */ 201, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ 201, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */ 201, /* (65) tcons ::= CHECK LP expr RP onconf */ 201, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ 204, /* (67) defer_subclause_opt ::= */ 190, /* (68) onconf ::= */ 190, /* (69) onconf ::= ON CONFLICT resolvetype */ 205, /* (70) orconf ::= */ 205, /* (71) orconf ::= OR resolvetype */ 206, /* (72) resolvetype ::= IGNORE */ 206, /* (73) resolvetype ::= REPLACE */ 164, /* (74) cmd ::= DROP TABLE ifexists fullname */ 208, /* (75) ifexists ::= IF EXISTS */ 208, /* (76) ifexists ::= */ 164, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ 164, /* (78) cmd ::= DROP VIEW ifexists fullname */ 164, /* (79) cmd ::= select */ 178, /* (80) select ::= WITH wqlist selectnowith */ 178, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */ 178, /* (82) select ::= selectnowith */ 210, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */ 213, /* (84) multiselect_op ::= UNION */ 213, /* (85) multiselect_op ::= UNION ALL */ 213, /* (86) multiselect_op ::= EXCEPT|INTERSECT */ 211, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ 211, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ 223, /* (89) values ::= VALUES LP nexprlist RP */ 223, /* (90) values ::= values COMMA LP nexprlist RP */ 214, /* (91) distinct ::= DISTINCT */ 214, /* (92) distinct ::= ALL */ 214, /* (93) distinct ::= */ 225, /* (94) sclp ::= */ 215, /* (95) selcollist ::= sclp scanpt expr scanpt as */ 215, /* (96) selcollist ::= sclp scanpt STAR */ 215, /* (97) selcollist ::= sclp scanpt nm DOT STAR */ 226, /* (98) as ::= AS nm */ 226, /* (99) as ::= */ 216, /* (100) from ::= */ 216, /* (101) from ::= FROM seltablist */ 228, /* (102) stl_prefix ::= seltablist joinop */ 228, /* (103) stl_prefix ::= */ 227, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ 227, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ 227, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ 227, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ 174, /* (108) dbnm ::= */ 174, /* (109) dbnm ::= DOT nm */ 209, /* (110) fullname ::= nm */ 209, /* (111) fullname ::= nm DOT nm */ 234, /* (112) xfullname ::= nm */ 234, /* (113) xfullname ::= nm DOT nm */ 234, /* (114) xfullname ::= nm DOT nm AS nm */ 234, /* (115) xfullname ::= nm AS nm */ 229, /* (116) joinop ::= COMMA|JOIN */ 229, /* (117) joinop ::= JOIN_KW JOIN */ 229, /* (118) joinop ::= JOIN_KW nm JOIN */ 229, /* (119) joinop ::= JOIN_KW nm nm JOIN */ 231, /* (120) on_opt ::= ON expr */ 231, /* (121) on_opt ::= */ 230, /* (122) indexed_opt ::= */ 230, /* (123) indexed_opt ::= INDEXED BY nm */ 230, /* (124) indexed_opt ::= NOT INDEXED */ 232, /* (125) using_opt ::= USING LP idlist RP */ 232, /* (126) using_opt ::= */ 220, /* (127) orderby_opt ::= */ 220, /* (128) orderby_opt ::= ORDER BY sortlist */ 202, /* (129) sortlist ::= sortlist COMMA expr sortorder */ 202, /* (130) sortlist ::= expr sortorder */ 191, /* (131) sortorder ::= ASC */ 191, /* (132) sortorder ::= DESC */ 191, /* (133) sortorder ::= */ 218, /* (134) groupby_opt ::= */ 218, /* (135) groupby_opt ::= GROUP BY nexprlist */ 219, /* (136) having_opt ::= */ 219, /* (137) having_opt ::= HAVING expr */ 221, /* (138) limit_opt ::= */ 221, /* (139) limit_opt ::= LIMIT expr */ 221, /* (140) limit_opt ::= LIMIT expr OFFSET expr */ 221, /* (141) limit_opt ::= LIMIT expr COMMA expr */ 164, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ 217, /* (143) where_opt ::= */ 217, /* (144) where_opt ::= WHERE expr */ 164, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ 237, /* (146) setlist ::= setlist COMMA nm EQ expr */ 237, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */ 237, /* (148) setlist ::= nm EQ expr */ 237, /* (149) setlist ::= LP idlist RP EQ expr */ 164, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ 164, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ 240, /* (152) upsert ::= */ 240, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ 240, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ 240, /* (155) upsert ::= ON CONFLICT DO NOTHING */ 238, /* (156) insert_cmd ::= INSERT orconf */ 238, /* (157) insert_cmd ::= REPLACE */ 239, /* (158) idlist_opt ::= */ 239, /* (159) idlist_opt ::= LP idlist RP */ 235, /* (160) idlist ::= idlist COMMA nm */ 235, /* (161) idlist ::= nm */ 189, /* (162) expr ::= LP expr RP */ 189, /* (163) expr ::= ID|INDEXED */ 189, /* (164) expr ::= JOIN_KW */ 189, /* (165) expr ::= nm DOT nm */ 189, /* (166) expr ::= nm DOT nm DOT nm */ 188, /* (167) term ::= NULL|FLOAT|BLOB */ 188, /* (168) term ::= STRING */ 188, /* (169) term ::= INTEGER */ 189, /* (170) expr ::= VARIABLE */ 189, /* (171) expr ::= expr COLLATE ID|STRING */ 189, /* (172) expr ::= CAST LP expr AS typetoken RP */ 189, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */ 189, /* (174) expr ::= ID|INDEXED LP STAR RP */ 189, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */ 189, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */ 188, /* (177) term ::= CTIME_KW */ 189, /* (178) expr ::= LP nexprlist COMMA expr RP */ 189, /* (179) expr ::= expr AND expr */ 189, /* (180) expr ::= expr OR expr */ 189, /* (181) expr ::= expr LT|GT|GE|LE expr */ 189, /* (182) expr ::= expr EQ|NE expr */ 189, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ 189, /* (184) expr ::= expr PLUS|MINUS expr */ 189, /* (185) expr ::= expr STAR|SLASH|REM expr */ 189, /* (186) expr ::= expr CONCAT expr */ 242, /* (187) likeop ::= NOT LIKE_KW|MATCH */ 189, /* (188) expr ::= expr likeop expr */ 189, /* (189) expr ::= expr likeop expr ESCAPE expr */ 189, /* (190) expr ::= expr ISNULL|NOTNULL */ 189, /* (191) expr ::= expr NOT NULL */ 189, /* (192) expr ::= expr IS expr */ 189, /* (193) expr ::= expr IS NOT expr */ 189, /* (194) expr ::= NOT expr */ 189, /* (195) expr ::= BITNOT expr */ 189, /* (196) expr ::= PLUS|MINUS expr */ 243, /* (197) between_op ::= BETWEEN */ 243, /* (198) between_op ::= NOT BETWEEN */ 189, /* (199) expr ::= expr between_op expr AND expr */ 244, /* (200) in_op ::= IN */ 244, /* (201) in_op ::= NOT IN */ 189, /* (202) expr ::= expr in_op LP exprlist RP */ 189, /* (203) expr ::= LP select RP */ 189, /* (204) expr ::= expr in_op LP select RP */ 189, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */ 189, /* (206) expr ::= EXISTS LP select RP */ 189, /* (207) expr ::= CASE case_operand case_exprlist case_else END */ 247, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */ 247, /* (209) case_exprlist ::= WHEN expr THEN expr */ 248, /* (210) case_else ::= ELSE expr */ 248, /* (211) case_else ::= */ 246, /* (212) case_operand ::= expr */ 246, /* (213) case_operand ::= */ 233, /* (214) exprlist ::= */ 224, /* (215) nexprlist ::= nexprlist COMMA expr */ 224, /* (216) nexprlist ::= expr */ 245, /* (217) paren_exprlist ::= */ 245, /* (218) paren_exprlist ::= LP exprlist RP */ 164, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ 249, /* (220) uniqueflag ::= UNIQUE */ 249, /* (221) uniqueflag ::= */ 193, /* (222) eidlist_opt ::= */ 193, /* (223) eidlist_opt ::= LP eidlist RP */ 203, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */ 203, /* (225) eidlist ::= nm collate sortorder */ 250, /* (226) collate ::= */ 250, /* (227) collate ::= COLLATE ID|STRING */ 164, /* (228) cmd ::= DROP INDEX ifexists fullname */ 164, /* (229) cmd ::= VACUUM vinto */ 164, /* (230) cmd ::= VACUUM nm vinto */ 251, /* (231) vinto ::= INTO expr */ 251, /* (232) vinto ::= */ 164, /* (233) cmd ::= PRAGMA nm dbnm */ 164, /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */ 164, /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */ 164, /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */ 164, /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */ 184, /* (238) plus_num ::= PLUS INTEGER|FLOAT */ 185, /* (239) minus_num ::= MINUS INTEGER|FLOAT */ 164, /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ 253, /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ 255, /* (242) trigger_time ::= BEFORE|AFTER */ 255, /* (243) trigger_time ::= INSTEAD OF */ 255, /* (244) trigger_time ::= */ 256, /* (245) trigger_event ::= DELETE|INSERT */ 256, /* (246) trigger_event ::= UPDATE */ 256, /* (247) trigger_event ::= UPDATE OF idlist */ 258, /* (248) when_clause ::= */ 258, /* (249) when_clause ::= WHEN expr */ 254, /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ 254, /* (251) trigger_cmd_list ::= trigger_cmd SEMI */ 260, /* (252) trnm ::= nm DOT nm */ 261, /* (253) tridxby ::= INDEXED BY nm */ 261, /* (254) tridxby ::= NOT INDEXED */ 259, /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ 259, /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ 259, /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ 259, /* (258) trigger_cmd ::= scanpt select scanpt */ 189, /* (259) expr ::= RAISE LP IGNORE RP */ 189, /* (260) expr ::= RAISE LP raisetype COMMA nm RP */ 207, /* (261) raisetype ::= ROLLBACK */ 207, /* (262) raisetype ::= ABORT */ 207, /* (263) raisetype ::= FAIL */ 164, /* (264) cmd ::= DROP TRIGGER ifexists fullname */ 164, /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ 164, /* (266) cmd ::= DETACH database_kw_opt expr */ 263, /* (267) key_opt ::= */ 263, /* (268) key_opt ::= KEY expr */ 164, /* (269) cmd ::= REINDEX */ 164, /* (270) cmd ::= REINDEX nm dbnm */ 164, /* (271) cmd ::= ANALYZE */ 164, /* (272) cmd ::= ANALYZE nm dbnm */ 164, /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */ 164, /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ 264, /* (275) add_column_fullname ::= fullname */ 164, /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ 164, /* (277) cmd ::= create_vtab */ 164, /* (278) cmd ::= create_vtab LP vtabarglist RP */ 266, /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ 268, /* (280) vtabarg ::= */ 269, /* (281) vtabargtoken ::= ANY */ 269, /* (282) vtabargtoken ::= lp anylist RP */ 270, /* (283) lp ::= LP */ 236, /* (284) with ::= WITH wqlist */ 236, /* (285) with ::= WITH RECURSIVE wqlist */ 212, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */ 212, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ 272, /* (288) windowdefn_list ::= windowdefn */ 272, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */ 273, /* (290) windowdefn ::= nm AS LP window RP */ 274, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ 274, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ 274, /* (293) window ::= ORDER BY sortlist frame_opt */ 274, /* (294) window ::= nm ORDER BY sortlist frame_opt */ 274, /* (295) window ::= frame_opt */ 274, /* (296) window ::= nm frame_opt */ 275, /* (297) frame_opt ::= */ 275, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ 275, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ 278, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */ 280, /* (301) frame_bound_s ::= frame_bound */ 280, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */ 281, /* (303) frame_bound_e ::= frame_bound */ 281, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */ 279, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */ 279, /* (306) frame_bound ::= CURRENT ROW */ 282, /* (307) frame_exclude_opt ::= */ 282, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */ 283, /* (309) frame_exclude ::= NO OTHERS */ 283, /* (310) frame_exclude ::= CURRENT ROW */ 283, /* (311) frame_exclude ::= GROUP|TIES */ 222, /* (312) window_clause ::= WINDOW windowdefn_list */ 241, /* (313) over_clause ::= filter_opt OVER LP window RP */ 241, /* (314) over_clause ::= filter_opt OVER nm */ 277, /* (315) filter_opt ::= */ 277, /* (316) filter_opt ::= FILTER LP WHERE expr RP */ 159, /* (317) input ::= cmdlist */ 160, /* (318) cmdlist ::= cmdlist ecmd */ 160, /* (319) cmdlist ::= ecmd */ 161, /* (320) ecmd ::= SEMI */ 161, /* (321) ecmd ::= cmdx SEMI */ 161, /* (322) ecmd ::= explain cmdx */ 166, /* (323) trans_opt ::= */ 166, /* (324) trans_opt ::= TRANSACTION */ 166, /* (325) trans_opt ::= TRANSACTION nm */ 168, /* (326) savepoint_opt ::= SAVEPOINT */ 168, /* (327) savepoint_opt ::= */ 164, /* (328) cmd ::= create_table create_table_args */ 175, /* (329) columnlist ::= columnlist COMMA columnname carglist */ 175, /* (330) columnlist ::= columnname carglist */ 167, /* (331) nm ::= ID|INDEXED */ 167, /* (332) nm ::= STRING */ 167, /* (333) nm ::= JOIN_KW */ 181, /* (334) typetoken ::= typename */ 182, /* (335) typename ::= ID|STRING */ 183, /* (336) signed ::= plus_num */ 183, /* (337) signed ::= minus_num */ 180, /* (338) carglist ::= carglist ccons */ 180, /* (339) carglist ::= */ 187, /* (340) ccons ::= NULL onconf */ 176, /* (341) conslist_opt ::= COMMA conslist */ 199, /* (342) conslist ::= conslist tconscomma tcons */ 199, /* (343) conslist ::= tcons */ 200, /* (344) tconscomma ::= */ 204, /* (345) defer_subclause_opt ::= defer_subclause */ 206, /* (346) resolvetype ::= raisetype */ 210, /* (347) selectnowith ::= oneselect */ 211, /* (348) oneselect ::= values */ 225, /* (349) sclp ::= selcollist COMMA */ 226, /* (350) as ::= ID|STRING */ 189, /* (351) expr ::= term */ 242, /* (352) likeop ::= LIKE_KW|MATCH */ 233, /* (353) exprlist ::= nexprlist */ 252, /* (354) nmnum ::= plus_num */ 252, /* (355) nmnum ::= nm */ 252, /* (356) nmnum ::= ON */ 252, /* (357) nmnum ::= DELETE */ 252, /* (358) nmnum ::= DEFAULT */ 184, /* (359) plus_num ::= INTEGER|FLOAT */ 257, /* (360) foreach_clause ::= */ 257, /* (361) foreach_clause ::= FOR EACH ROW */ 260, /* (362) trnm ::= nm */ 261, /* (363) tridxby ::= */ 262, /* (364) database_kw_opt ::= DATABASE */ 262, /* (365) database_kw_opt ::= */ 265, /* (366) kwcolumn_opt ::= */ 265, /* (367) kwcolumn_opt ::= COLUMNKW */ 267, /* (368) vtabarglist ::= vtabarg */ 267, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */ 268, /* (370) vtabarg ::= vtabarg vtabargtoken */ 271, /* (371) anylist ::= */ 271, /* (372) anylist ::= anylist LP anylist RP */ 271, /* (373) anylist ::= anylist ANY */ 236, /* (374) with ::= */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number ** of symbols on the right-hand side of that rule. */ static const signed char yyRuleInfoNRhs[] = { -1, /* (0) explain ::= EXPLAIN */ -3, /* (1) explain ::= EXPLAIN QUERY PLAN */ |
︙ | ︙ | |||
150428 150429 150430 150431 150432 150433 150434 | -1, /* (283) lp ::= LP */ -2, /* (284) with ::= WITH wqlist */ -3, /* (285) with ::= WITH RECURSIVE wqlist */ -6, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */ -8, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ -1, /* (288) windowdefn_list ::= windowdefn */ -3, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | | | | | > > > | | | | < | | | | | | < < | | | | > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 151065 151066 151067 151068 151069 151070 151071 151072 151073 151074 151075 151076 151077 151078 151079 151080 151081 151082 151083 151084 151085 151086 151087 151088 151089 151090 151091 151092 151093 151094 151095 151096 151097 151098 151099 151100 151101 151102 151103 151104 151105 151106 151107 151108 151109 151110 151111 151112 151113 151114 151115 151116 151117 151118 151119 151120 151121 151122 151123 151124 151125 151126 151127 151128 151129 151130 151131 151132 151133 151134 151135 151136 151137 151138 151139 151140 151141 151142 151143 151144 151145 151146 151147 151148 151149 151150 151151 151152 151153 151154 151155 151156 151157 151158 151159 151160 151161 151162 151163 | -1, /* (283) lp ::= LP */ -2, /* (284) with ::= WITH wqlist */ -3, /* (285) with ::= WITH RECURSIVE wqlist */ -6, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */ -8, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ -1, /* (288) windowdefn_list ::= windowdefn */ -3, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */ -5, /* (290) windowdefn ::= nm AS LP window RP */ -5, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ -6, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ -4, /* (293) window ::= ORDER BY sortlist frame_opt */ -5, /* (294) window ::= nm ORDER BY sortlist frame_opt */ -1, /* (295) window ::= frame_opt */ -2, /* (296) window ::= nm frame_opt */ 0, /* (297) frame_opt ::= */ -3, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ -6, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ -1, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */ -1, /* (301) frame_bound_s ::= frame_bound */ -2, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */ -1, /* (303) frame_bound_e ::= frame_bound */ -2, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */ -2, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */ -2, /* (306) frame_bound ::= CURRENT ROW */ 0, /* (307) frame_exclude_opt ::= */ -2, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */ -2, /* (309) frame_exclude ::= NO OTHERS */ -2, /* (310) frame_exclude ::= CURRENT ROW */ -1, /* (311) frame_exclude ::= GROUP|TIES */ -2, /* (312) window_clause ::= WINDOW windowdefn_list */ -5, /* (313) over_clause ::= filter_opt OVER LP window RP */ -3, /* (314) over_clause ::= filter_opt OVER nm */ 0, /* (315) filter_opt ::= */ -5, /* (316) filter_opt ::= FILTER LP WHERE expr RP */ -1, /* (317) input ::= cmdlist */ -2, /* (318) cmdlist ::= cmdlist ecmd */ -1, /* (319) cmdlist ::= ecmd */ -1, /* (320) ecmd ::= SEMI */ -2, /* (321) ecmd ::= cmdx SEMI */ -2, /* (322) ecmd ::= explain cmdx */ 0, /* (323) trans_opt ::= */ -1, /* (324) trans_opt ::= TRANSACTION */ -2, /* (325) trans_opt ::= TRANSACTION nm */ -1, /* (326) savepoint_opt ::= SAVEPOINT */ 0, /* (327) savepoint_opt ::= */ -2, /* (328) cmd ::= create_table create_table_args */ -4, /* (329) columnlist ::= columnlist COMMA columnname carglist */ -2, /* (330) columnlist ::= columnname carglist */ -1, /* (331) nm ::= ID|INDEXED */ -1, /* (332) nm ::= STRING */ -1, /* (333) nm ::= JOIN_KW */ -1, /* (334) typetoken ::= typename */ -1, /* (335) typename ::= ID|STRING */ -1, /* (336) signed ::= plus_num */ -1, /* (337) signed ::= minus_num */ -2, /* (338) carglist ::= carglist ccons */ 0, /* (339) carglist ::= */ -2, /* (340) ccons ::= NULL onconf */ -2, /* (341) conslist_opt ::= COMMA conslist */ -3, /* (342) conslist ::= conslist tconscomma tcons */ -1, /* (343) conslist ::= tcons */ 0, /* (344) tconscomma ::= */ -1, /* (345) defer_subclause_opt ::= defer_subclause */ -1, /* (346) resolvetype ::= raisetype */ -1, /* (347) selectnowith ::= oneselect */ -1, /* (348) oneselect ::= values */ -2, /* (349) sclp ::= selcollist COMMA */ -1, /* (350) as ::= ID|STRING */ -1, /* (351) expr ::= term */ -1, /* (352) likeop ::= LIKE_KW|MATCH */ -1, /* (353) exprlist ::= nexprlist */ -1, /* (354) nmnum ::= plus_num */ -1, /* (355) nmnum ::= nm */ -1, /* (356) nmnum ::= ON */ -1, /* (357) nmnum ::= DELETE */ -1, /* (358) nmnum ::= DEFAULT */ -1, /* (359) plus_num ::= INTEGER|FLOAT */ 0, /* (360) foreach_clause ::= */ -3, /* (361) foreach_clause ::= FOR EACH ROW */ -1, /* (362) trnm ::= nm */ 0, /* (363) tridxby ::= */ -1, /* (364) database_kw_opt ::= DATABASE */ 0, /* (365) database_kw_opt ::= */ 0, /* (366) kwcolumn_opt ::= */ -1, /* (367) kwcolumn_opt ::= COLUMNKW */ -1, /* (368) vtabarglist ::= vtabarg */ -3, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */ -2, /* (370) vtabarg ::= vtabarg vtabargtoken */ 0, /* (371) anylist ::= */ -4, /* (372) anylist ::= anylist LP anylist RP */ -2, /* (373) anylist ::= anylist ANY */ 0, /* (374) with ::= */ }; static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. |
︙ | ︙ | |||
150603 150604 150605 150606 150607 150608 150609 | case 1: /* explain ::= EXPLAIN QUERY PLAN */ { pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } break; case 3: /* cmd ::= BEGIN transtype trans_opt */ | | | > | | 151246 151247 151248 151249 151250 151251 151252 151253 151254 151255 151256 151257 151258 151259 151260 151261 151262 151263 151264 151265 151266 151267 151268 151269 | case 1: /* explain ::= EXPLAIN QUERY PLAN */ { pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } break; case 3: /* cmd ::= BEGIN transtype trans_opt */ {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy420);} break; case 4: /* transtype ::= */ {yymsp[1].minor.yy420 = TK_DEFERRED;} break; case 5: /* transtype ::= DEFERRED */ case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); case 300: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==300); {yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/} break; case 8: /* cmd ::= COMMIT|END trans_opt */ case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); {sqlite3EndTransaction(pParse,yymsp[-1].major);} break; case 10: /* cmd ::= SAVEPOINT nm */ { |
︙ | ︙ | |||
150634 150635 150636 150637 150638 150639 150640 | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); } break; case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { | | | | | | | | | | | 151278 151279 151280 151281 151282 151283 151284 151285 151286 151287 151288 151289 151290 151291 151292 151293 151294 151295 151296 151297 151298 151299 151300 151301 151302 151303 151304 151305 151306 151307 151308 151309 151310 151311 151312 151313 151314 151315 151316 151317 151318 151319 151320 151321 151322 151323 151324 151325 151326 151327 151328 151329 151330 151331 151332 | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); } break; case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy420,0,0,yymsp[-2].minor.yy420); } break; case 14: /* createkw ::= CREATE */ {disableLookaside(pParse);} break; case 15: /* ifnotexists ::= */ case 18: /* temp ::= */ yytestcase(yyruleno==18); case 21: /* table_options ::= */ yytestcase(yyruleno==21); case 42: /* autoinc ::= */ yytestcase(yyruleno==42); case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57); case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67); case 76: /* ifexists ::= */ yytestcase(yyruleno==76); case 93: /* distinct ::= */ yytestcase(yyruleno==93); case 226: /* collate ::= */ yytestcase(yyruleno==226); {yymsp[1].minor.yy420 = 0;} break; case 16: /* ifnotexists ::= IF NOT EXISTS */ {yymsp[-2].minor.yy420 = 1;} break; case 17: /* temp ::= TEMP */ case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43); {yymsp[0].minor.yy420 = 1;} break; case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ { sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy420,0); } break; case 20: /* create_table_args ::= AS select */ { sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy491); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491); } break; case 22: /* table_options ::= WITHOUT nm */ { if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ yymsp[-1].minor.yy420 = TF_WithoutRowid | TF_NoVisibleRowid; }else{ yymsp[-1].minor.yy420 = 0; sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); } } break; case 23: /* columnname ::= nm typetoken */ {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} break; |
︙ | ︙ | |||
150703 150704 150705 150706 150707 150708 150709 | break; case 27: /* typename ::= typename ID|STRING */ {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} break; case 28: /* scanpt ::= */ { assert( yyLookahead!=YYNOCODE ); | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 151347 151348 151349 151350 151351 151352 151353 151354 151355 151356 151357 151358 151359 151360 151361 151362 151363 151364 151365 151366 151367 151368 151369 151370 151371 151372 151373 151374 151375 151376 151377 151378 151379 151380 151381 151382 151383 151384 151385 151386 151387 151388 151389 151390 151391 151392 151393 151394 151395 151396 151397 151398 151399 151400 151401 151402 151403 151404 151405 151406 151407 151408 151409 151410 151411 151412 151413 151414 151415 151416 151417 151418 151419 151420 151421 151422 151423 151424 151425 151426 151427 151428 151429 151430 151431 151432 151433 151434 151435 151436 151437 151438 151439 151440 151441 151442 151443 151444 151445 151446 151447 151448 151449 151450 151451 151452 151453 151454 151455 151456 151457 151458 151459 151460 151461 151462 151463 151464 151465 151466 151467 151468 151469 151470 151471 151472 151473 151474 151475 151476 151477 151478 151479 151480 151481 151482 151483 151484 151485 151486 151487 151488 151489 151490 151491 151492 151493 151494 151495 151496 151497 151498 151499 151500 151501 151502 151503 151504 151505 151506 151507 151508 151509 151510 151511 151512 151513 151514 151515 151516 151517 151518 151519 151520 151521 151522 151523 151524 151525 151526 151527 151528 151529 151530 151531 151532 151533 151534 151535 151536 151537 151538 151539 151540 151541 151542 151543 151544 151545 151546 151547 151548 151549 151550 151551 151552 151553 151554 151555 151556 151557 151558 151559 151560 151561 151562 151563 151564 151565 151566 151567 151568 151569 151570 151571 151572 151573 151574 151575 151576 151577 151578 151579 151580 151581 151582 151583 151584 151585 151586 151587 151588 151589 151590 151591 151592 151593 151594 151595 151596 151597 151598 151599 151600 151601 151602 151603 151604 151605 151606 151607 151608 151609 151610 151611 151612 151613 151614 151615 151616 151617 151618 151619 151620 151621 151622 151623 151624 151625 151626 151627 151628 151629 151630 151631 151632 151633 151634 151635 151636 151637 151638 151639 151640 151641 151642 151643 151644 151645 151646 151647 151648 151649 151650 151651 151652 151653 151654 151655 151656 151657 151658 151659 151660 151661 151662 151663 151664 151665 151666 151667 151668 151669 151670 151671 151672 151673 151674 151675 151676 151677 151678 151679 151680 151681 151682 151683 151684 151685 151686 151687 151688 151689 151690 151691 151692 151693 151694 151695 151696 151697 151698 151699 151700 151701 151702 151703 151704 151705 151706 151707 151708 151709 151710 151711 151712 151713 151714 151715 151716 151717 151718 151719 151720 151721 151722 151723 151724 151725 151726 151727 151728 151729 151730 151731 151732 151733 151734 151735 151736 151737 151738 151739 151740 151741 151742 151743 151744 151745 151746 151747 151748 151749 151750 151751 151752 151753 151754 151755 151756 151757 151758 151759 151760 151761 151762 151763 151764 151765 151766 151767 151768 151769 151770 151771 151772 151773 151774 151775 151776 151777 151778 151779 151780 151781 151782 151783 151784 151785 151786 151787 151788 151789 151790 151791 151792 151793 151794 151795 151796 151797 151798 151799 151800 151801 151802 151803 151804 151805 151806 151807 151808 151809 151810 151811 151812 151813 151814 151815 151816 151817 151818 151819 151820 151821 151822 151823 151824 151825 151826 151827 151828 151829 151830 151831 151832 151833 151834 151835 151836 151837 151838 151839 151840 151841 151842 151843 151844 151845 151846 151847 151848 151849 151850 151851 151852 151853 151854 151855 151856 151857 151858 151859 151860 151861 151862 151863 151864 151865 151866 151867 151868 151869 151870 151871 151872 151873 151874 151875 151876 151877 151878 151879 151880 151881 151882 151883 151884 151885 151886 151887 151888 151889 151890 151891 151892 151893 151894 151895 151896 151897 151898 151899 151900 151901 151902 151903 151904 151905 151906 151907 151908 151909 151910 151911 151912 151913 151914 151915 151916 151917 151918 151919 151920 151921 151922 151923 151924 151925 151926 151927 151928 151929 151930 151931 151932 151933 151934 151935 151936 151937 151938 151939 151940 151941 151942 151943 151944 151945 151946 151947 151948 151949 151950 151951 151952 151953 151954 151955 151956 151957 151958 151959 151960 151961 151962 151963 151964 151965 151966 151967 151968 151969 151970 151971 151972 151973 151974 151975 151976 151977 151978 151979 151980 151981 151982 151983 151984 151985 151986 151987 151988 151989 151990 151991 151992 151993 151994 151995 151996 151997 151998 151999 152000 152001 152002 152003 152004 152005 152006 152007 152008 152009 152010 152011 152012 152013 152014 152015 152016 152017 152018 152019 152020 152021 152022 152023 152024 152025 152026 152027 152028 152029 152030 152031 152032 152033 152034 152035 152036 152037 152038 152039 152040 152041 152042 152043 152044 152045 152046 152047 152048 152049 152050 152051 152052 152053 152054 152055 152056 152057 152058 152059 152060 152061 152062 152063 152064 152065 152066 152067 152068 152069 152070 152071 152072 152073 152074 152075 152076 152077 152078 152079 152080 152081 152082 152083 152084 152085 152086 152087 152088 152089 152090 152091 152092 152093 152094 152095 152096 152097 152098 152099 152100 152101 152102 152103 152104 152105 152106 152107 152108 152109 152110 152111 152112 152113 152114 152115 152116 152117 152118 152119 152120 152121 152122 152123 152124 152125 152126 152127 152128 152129 152130 152131 152132 152133 152134 152135 152136 152137 152138 152139 152140 152141 152142 152143 152144 152145 152146 152147 152148 152149 152150 152151 152152 152153 152154 152155 152156 152157 152158 152159 152160 152161 152162 152163 152164 152165 152166 152167 152168 152169 152170 152171 152172 152173 152174 152175 152176 152177 152178 152179 152180 152181 152182 152183 152184 152185 152186 152187 152188 152189 152190 152191 152192 152193 152194 152195 152196 152197 152198 152199 152200 152201 152202 152203 152204 152205 152206 152207 152208 152209 152210 152211 152212 152213 152214 152215 152216 152217 152218 152219 152220 152221 152222 152223 152224 152225 152226 152227 152228 152229 152230 152231 152232 152233 152234 152235 152236 152237 152238 152239 152240 152241 152242 152243 152244 152245 152246 152247 152248 152249 152250 152251 152252 152253 152254 152255 152256 152257 152258 152259 | break; case 27: /* typename ::= typename ID|STRING */ {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} break; case 28: /* scanpt ::= */ { assert( yyLookahead!=YYNOCODE ); yymsp[1].minor.yy104 = yyLookaheadToken.z; } break; case 29: /* ccons ::= CONSTRAINT nm */ case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62); {pParse->constraintName = yymsp[0].minor.yy0;} break; case 30: /* ccons ::= DEFAULT scanpt term scanpt */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy104,yymsp[0].minor.yy104);} break; case 31: /* ccons ::= DEFAULT LP expr RP */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} break; case 32: /* ccons ::= DEFAULT PLUS term scanpt */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104);} break; case 33: /* ccons ::= DEFAULT MINUS term scanpt */ { Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy130, 0); sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104); } break; case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */ { Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0); if( p ){ sqlite3ExprIdToTrueFalse(p); testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) ); } sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); } break; case 35: /* ccons ::= NOT NULL onconf */ {sqlite3AddNotNull(pParse, yymsp[0].minor.yy420);} break; case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy420,yymsp[0].minor.yy420,yymsp[-2].minor.yy420);} break; case 37: /* ccons ::= UNIQUE onconf */ {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy420,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; case 38: /* ccons ::= CHECK LP expr RP */ {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy130);} break; case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */ {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy420);} break; case 40: /* ccons ::= defer_subclause */ {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy420);} break; case 41: /* ccons ::= COLLATE ID|STRING */ {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} break; case 44: /* refargs ::= */ { yymsp[1].minor.yy420 = OE_None*0x0101; /* EV: R-19803-45884 */} break; case 45: /* refargs ::= refargs refarg */ { yymsp[-1].minor.yy420 = (yymsp[-1].minor.yy420 & ~yymsp[0].minor.yy527.mask) | yymsp[0].minor.yy527.value; } break; case 46: /* refarg ::= MATCH nm */ { yymsp[-1].minor.yy527.value = 0; yymsp[-1].minor.yy527.mask = 0x000000; } break; case 47: /* refarg ::= ON INSERT refact */ { yymsp[-2].minor.yy527.value = 0; yymsp[-2].minor.yy527.mask = 0x000000; } break; case 48: /* refarg ::= ON DELETE refact */ { yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420; yymsp[-2].minor.yy527.mask = 0x0000ff; } break; case 49: /* refarg ::= ON UPDATE refact */ { yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420<<8; yymsp[-2].minor.yy527.mask = 0x00ff00; } break; case 50: /* refact ::= SET NULL */ { yymsp[-1].minor.yy420 = OE_SetNull; /* EV: R-33326-45252 */} break; case 51: /* refact ::= SET DEFAULT */ { yymsp[-1].minor.yy420 = OE_SetDflt; /* EV: R-33326-45252 */} break; case 52: /* refact ::= CASCADE */ { yymsp[0].minor.yy420 = OE_Cascade; /* EV: R-33326-45252 */} break; case 53: /* refact ::= RESTRICT */ { yymsp[0].minor.yy420 = OE_Restrict; /* EV: R-33326-45252 */} break; case 54: /* refact ::= NO ACTION */ { yymsp[-1].minor.yy420 = OE_None; /* EV: R-33326-45252 */} break; case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ {yymsp[-2].minor.yy420 = 0;} break; case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71); case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156); {yymsp[-1].minor.yy420 = yymsp[0].minor.yy420;} break; case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75); case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198); case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201); case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227); {yymsp[-1].minor.yy420 = 1;} break; case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ {yymsp[-1].minor.yy420 = 0;} break; case 61: /* tconscomma ::= COMMA */ {pParse->constraintName.n = 0;} break; case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy420,yymsp[-2].minor.yy420,0);} break; case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */ {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy420,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; case 65: /* tcons ::= CHECK LP expr RP onconf */ {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy130);} break; case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy420); sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy420); } break; case 68: /* onconf ::= */ case 70: /* orconf ::= */ yytestcase(yyruleno==70); {yymsp[1].minor.yy420 = OE_Default;} break; case 69: /* onconf ::= ON CONFLICT resolvetype */ {yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;} break; case 72: /* resolvetype ::= IGNORE */ {yymsp[0].minor.yy420 = OE_Ignore;} break; case 73: /* resolvetype ::= REPLACE */ case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157); {yymsp[0].minor.yy420 = OE_Replace;} break; case 74: /* cmd ::= DROP TABLE ifexists fullname */ { sqlite3DropTable(pParse, yymsp[0].minor.yy147, 0, yymsp[-1].minor.yy420); } break; case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy491, yymsp[-7].minor.yy420, yymsp[-5].minor.yy420); } break; case 78: /* cmd ::= DROP VIEW ifexists fullname */ { sqlite3DropTable(pParse, yymsp[0].minor.yy147, 1, yymsp[-1].minor.yy420); } break; case 79: /* cmd ::= select */ { SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; sqlite3Select(pParse, yymsp[0].minor.yy491, &dest); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491); } break; case 80: /* select ::= WITH wqlist selectnowith */ { Select *p = yymsp[0].minor.yy491; if( p ){ p->pWith = yymsp[-1].minor.yy523; parserDoubleLinkSelect(pParse, p); }else{ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523); } yymsp[-2].minor.yy491 = p; } break; case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */ { Select *p = yymsp[0].minor.yy491; if( p ){ p->pWith = yymsp[-1].minor.yy523; parserDoubleLinkSelect(pParse, p); }else{ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523); } yymsp[-3].minor.yy491 = p; } break; case 82: /* select ::= selectnowith */ { Select *p = yymsp[0].minor.yy491; if( p ){ parserDoubleLinkSelect(pParse, p); } yymsp[0].minor.yy491 = p; /*A-overwrites-X*/ } break; case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */ { Select *pRhs = yymsp[0].minor.yy491; Select *pLhs = yymsp[-2].minor.yy491; if( pRhs && pRhs->pPrior ){ SrcList *pFrom; Token x; x.n = 0; parserDoubleLinkSelect(pParse, pRhs); pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); } if( pRhs ){ pRhs->op = (u8)yymsp[-1].minor.yy420; pRhs->pPrior = pLhs; if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; pRhs->selFlags &= ~SF_MultiValue; if( yymsp[-1].minor.yy420!=TK_ALL ) pParse->hasCompound = 1; }else{ sqlite3SelectDelete(pParse->db, pLhs); } yymsp[-2].minor.yy491 = pRhs; } break; case 84: /* multiselect_op ::= UNION */ case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86); {yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-OP*/} break; case 85: /* multiselect_op ::= UNION ALL */ {yymsp[-1].minor.yy420 = TK_ALL;} break; case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { yymsp[-8].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy147,yymsp[-4].minor.yy130,yymsp[-3].minor.yy442,yymsp[-2].minor.yy130,yymsp[-1].minor.yy442,yymsp[-7].minor.yy420,yymsp[0].minor.yy130); } break; case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ { yymsp[-9].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy442,yymsp[-6].minor.yy147,yymsp[-5].minor.yy130,yymsp[-4].minor.yy442,yymsp[-3].minor.yy130,yymsp[-1].minor.yy442,yymsp[-8].minor.yy420,yymsp[0].minor.yy130); if( yymsp[-9].minor.yy491 ){ yymsp[-9].minor.yy491->pWinDefn = yymsp[-2].minor.yy395; }else{ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy395); } } break; case 89: /* values ::= VALUES LP nexprlist RP */ { yymsp[-3].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0); } break; case 90: /* values ::= values COMMA LP nexprlist RP */ { Select *pRight, *pLeft = yymsp[-4].minor.yy491; pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0); if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; if( pRight ){ pRight->op = TK_ALL; pRight->pPrior = pLeft; yymsp[-4].minor.yy491 = pRight; }else{ yymsp[-4].minor.yy491 = pLeft; } } break; case 91: /* distinct ::= DISTINCT */ {yymsp[0].minor.yy420 = SF_Distinct;} break; case 92: /* distinct ::= ALL */ {yymsp[0].minor.yy420 = SF_All;} break; case 94: /* sclp ::= */ case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127); case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134); case 214: /* exprlist ::= */ yytestcase(yyruleno==214); case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217); case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222); {yymsp[1].minor.yy442 = 0;} break; case 95: /* selcollist ::= sclp scanpt expr scanpt as */ { yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[-2].minor.yy130); if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[0].minor.yy0, 1); sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy442,yymsp[-3].minor.yy104,yymsp[-1].minor.yy104); } break; case 96: /* selcollist ::= sclp scanpt STAR */ { Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, p); } break; case 97: /* selcollist ::= sclp scanpt nm DOT STAR */ { Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, pDot); } break; case 98: /* as ::= AS nm */ case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109); case 238: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==238); case 239: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==239); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; case 100: /* from ::= */ {yymsp[1].minor.yy147 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy147));} break; case 101: /* from ::= FROM seltablist */ { yymsp[-1].minor.yy147 = yymsp[0].minor.yy147; sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy147); } break; case 102: /* stl_prefix ::= seltablist joinop */ { if( ALWAYS(yymsp[-1].minor.yy147 && yymsp[-1].minor.yy147->nSrc>0) ) yymsp[-1].minor.yy147->a[yymsp[-1].minor.yy147->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy420; } break; case 103: /* stl_prefix ::= */ {yymsp[1].minor.yy147 = 0;} break; case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200); sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy147, &yymsp[-2].minor.yy0); } break; case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { yymsp[-8].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy147,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200); sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy147, yymsp[-4].minor.yy442); } break; case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy491,yymsp[-1].minor.yy130,yymsp[0].minor.yy200); } break; case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { if( yymsp[-6].minor.yy147==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy130==0 && yymsp[0].minor.yy200==0 ){ yymsp[-6].minor.yy147 = yymsp[-4].minor.yy147; }else if( yymsp[-4].minor.yy147->nSrc==1 ){ yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200); if( yymsp[-6].minor.yy147 ){ struct SrcList_item *pNew = &yymsp[-6].minor.yy147->a[yymsp[-6].minor.yy147->nSrc-1]; struct SrcList_item *pOld = yymsp[-4].minor.yy147->a; pNew->zName = pOld->zName; pNew->zDatabase = pOld->zDatabase; pNew->pSelect = pOld->pSelect; if( pOld->fg.isTabFunc ){ pNew->u1.pFuncArg = pOld->u1.pFuncArg; pOld->u1.pFuncArg = 0; pOld->fg.isTabFunc = 0; pNew->fg.isTabFunc = 1; } pOld->zName = pOld->zDatabase = 0; pOld->pSelect = 0; } sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy147); }else{ Select *pSubquery; sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy147); pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy147,0,0,0,0,SF_NestedFrom,0); yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy130,yymsp[0].minor.yy200); } } break; case 108: /* dbnm ::= */ case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122); {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} break; case 110: /* fullname ::= nm */ { yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0); } yymsp[0].minor.yy147 = yylhsminor.yy147; break; case 111: /* fullname ::= nm DOT nm */ { yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy147 = yylhsminor.yy147; break; case 112: /* xfullname ::= nm */ {yymsp[0].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} break; case 113: /* xfullname ::= nm DOT nm */ {yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 114: /* xfullname ::= nm DOT nm AS nm */ { yymsp[-4].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ if( yymsp[-4].minor.yy147 ) yymsp[-4].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; case 115: /* xfullname ::= nm AS nm */ { yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ if( yymsp[-2].minor.yy147 ) yymsp[-2].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; case 116: /* joinop ::= COMMA|JOIN */ { yymsp[0].minor.yy420 = JT_INNER; } break; case 117: /* joinop ::= JOIN_KW JOIN */ {yymsp[-1].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} break; case 118: /* joinop ::= JOIN_KW nm JOIN */ {yymsp[-2].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} break; case 119: /* joinop ::= JOIN_KW nm nm JOIN */ {yymsp[-3].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} break; case 120: /* on_opt ::= ON expr */ case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137); case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144); case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210); case 231: /* vinto ::= INTO expr */ yytestcase(yyruleno==231); {yymsp[-1].minor.yy130 = yymsp[0].minor.yy130;} break; case 121: /* on_opt ::= */ case 136: /* having_opt ::= */ yytestcase(yyruleno==136); case 138: /* limit_opt ::= */ yytestcase(yyruleno==138); case 143: /* where_opt ::= */ yytestcase(yyruleno==143); case 211: /* case_else ::= */ yytestcase(yyruleno==211); case 213: /* case_operand ::= */ yytestcase(yyruleno==213); case 232: /* vinto ::= */ yytestcase(yyruleno==232); {yymsp[1].minor.yy130 = 0;} break; case 123: /* indexed_opt ::= INDEXED BY nm */ {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} break; case 124: /* indexed_opt ::= NOT INDEXED */ {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} break; case 125: /* using_opt ::= USING LP idlist RP */ {yymsp[-3].minor.yy200 = yymsp[-1].minor.yy200;} break; case 126: /* using_opt ::= */ case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158); {yymsp[1].minor.yy200 = 0;} break; case 128: /* orderby_opt ::= ORDER BY sortlist */ case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135); {yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;} break; case 129: /* sortlist ::= sortlist COMMA expr sortorder */ { yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy130); sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy420); } break; case 130: /* sortlist ::= expr sortorder */ { yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy130); /*A-overwrites-Y*/ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy420); } break; case 131: /* sortorder ::= ASC */ {yymsp[0].minor.yy420 = SQLITE_SO_ASC;} break; case 132: /* sortorder ::= DESC */ {yymsp[0].minor.yy420 = SQLITE_SO_DESC;} break; case 133: /* sortorder ::= */ {yymsp[1].minor.yy420 = SQLITE_SO_UNDEFINED;} break; case 139: /* limit_opt ::= LIMIT expr */ {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,0);} break; case 140: /* limit_opt ::= LIMIT expr OFFSET expr */ {yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);} break; case 141: /* limit_opt ::= LIMIT expr COMMA expr */ {yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,yymsp[-2].minor.yy130);} break; case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy147, &yymsp[-1].minor.yy0); sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy147,yymsp[0].minor.yy130,0,0); } break; case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ { sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy147, &yymsp[-3].minor.yy0); sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list"); sqlite3Update(pParse,yymsp[-4].minor.yy147,yymsp[-1].minor.yy442,yymsp[0].minor.yy130,yymsp[-5].minor.yy420,0,0,0); } break; case 146: /* setlist ::= setlist COMMA nm EQ expr */ { yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy130); sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1); } break; case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ { yymsp[-6].minor.yy442 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy442, yymsp[-3].minor.yy200, yymsp[0].minor.yy130); } break; case 148: /* setlist ::= nm EQ expr */ { yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy130); sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1); } yymsp[-2].minor.yy442 = yylhsminor.yy442; break; case 149: /* setlist ::= LP idlist RP EQ expr */ { yymsp[-4].minor.yy442 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy200, yymsp[0].minor.yy130); } break; case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { sqlite3Insert(pParse, yymsp[-3].minor.yy147, yymsp[-1].minor.yy491, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, yymsp[0].minor.yy426); } break; case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ { sqlite3Insert(pParse, yymsp[-3].minor.yy147, 0, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, 0); } break; case 152: /* upsert ::= */ { yymsp[1].minor.yy426 = 0; } break; case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ { yymsp[-10].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy442,yymsp[-5].minor.yy130,yymsp[-1].minor.yy442,yymsp[0].minor.yy130);} break; case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ { yymsp[-7].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy442,yymsp[-2].minor.yy130,0,0); } break; case 155: /* upsert ::= ON CONFLICT DO NOTHING */ { yymsp[-3].minor.yy426 = sqlite3UpsertNew(pParse->db,0,0,0,0); } break; case 159: /* idlist_opt ::= LP idlist RP */ {yymsp[-2].minor.yy200 = yymsp[-1].minor.yy200;} break; case 160: /* idlist ::= idlist COMMA nm */ {yymsp[-2].minor.yy200 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy200,&yymsp[0].minor.yy0);} break; case 161: /* idlist ::= nm */ {yymsp[0].minor.yy200 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} break; case 162: /* expr ::= LP expr RP */ {yymsp[-2].minor.yy130 = yymsp[-1].minor.yy130;} break; case 163: /* expr ::= ID|INDEXED */ case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164); {yymsp[0].minor.yy130=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 165: /* expr ::= nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); if( IN_RENAME_OBJECT ){ sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); } yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); } yymsp[-2].minor.yy130 = yylhsminor.yy130; break; case 166: /* expr ::= nm DOT nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3); if( IN_RENAME_OBJECT ){ sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); } yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); } yymsp[-4].minor.yy130 = yylhsminor.yy130; break; case 167: /* term ::= NULL|FLOAT|BLOB */ case 168: /* term ::= STRING */ yytestcase(yyruleno==168); {yymsp[0].minor.yy130=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 169: /* term ::= INTEGER */ { yylhsminor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); } yymsp[0].minor.yy130 = yylhsminor.yy130; break; case 170: /* expr ::= VARIABLE */ { if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ u32 n = yymsp[0].minor.yy0.n; yymsp[0].minor.yy130 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy130, n); }else{ /* 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. */ Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ assert( t.n>=2 ); if( pParse->nested==0 ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); yymsp[0].minor.yy130 = 0; }else{ yymsp[0].minor.yy130 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); if( yymsp[0].minor.yy130 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy130->iTable); } } } break; case 171: /* expr ::= expr COLLATE ID|STRING */ { yymsp[-2].minor.yy130 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy130, &yymsp[0].minor.yy0, 1); } break; case 172: /* expr ::= CAST LP expr AS typetoken RP */ { yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy130, yymsp[-3].minor.yy130, 0); } break; case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */ { yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy420); } yymsp[-4].minor.yy130 = yylhsminor.yy130; break; case 174: /* expr ::= ID|INDEXED LP STAR RP */ { yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); } yymsp[-3].minor.yy130 = yylhsminor.yy130; break; case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */ { yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy442, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy420); sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395); } yymsp[-5].minor.yy130 = yylhsminor.yy130; break; case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */ { yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395); } yymsp[-4].minor.yy130 = yylhsminor.yy130; break; case 177: /* term ::= CTIME_KW */ { yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); } yymsp[0].minor.yy130 = yylhsminor.yy130; break; case 178: /* expr ::= LP nexprlist COMMA expr RP */ { ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy442, yymsp[-1].minor.yy130); yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); if( yymsp[-4].minor.yy130 ){ yymsp[-4].minor.yy130->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } } break; case 179: /* expr ::= expr AND expr */ case 180: /* expr ::= expr OR expr */ yytestcase(yyruleno==180); case 181: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==181); case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182); case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183); case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184); case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185); case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186); {yymsp[-2].minor.yy130=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);} break; case 187: /* likeop ::= NOT LIKE_KW|MATCH */ {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} break; case 188: /* expr ::= expr likeop expr */ { ExprList *pList; int bNot = yymsp[-1].minor.yy0.n & 0x80000000; yymsp[-1].minor.yy0.n &= 0x7fffffff; pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy130); pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy130); yymsp[-2].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); if( bNot ) yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy130, 0); if( yymsp[-2].minor.yy130 ) yymsp[-2].minor.yy130->flags |= EP_InfixFunc; } break; case 189: /* expr ::= expr likeop expr ESCAPE expr */ { ExprList *pList; int bNot = yymsp[-3].minor.yy0.n & 0x80000000; yymsp[-3].minor.yy0.n &= 0x7fffffff; pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130); pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy130); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130); yymsp[-4].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); if( bNot ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0); if( yymsp[-4].minor.yy130 ) yymsp[-4].minor.yy130->flags |= EP_InfixFunc; } break; case 190: /* expr ::= expr ISNULL|NOTNULL */ {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy130,0);} break; case 191: /* expr ::= expr NOT NULL */ {yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy130,0);} break; case 192: /* expr ::= expr IS expr */ { yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy130,yymsp[0].minor.yy130); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-2].minor.yy130, TK_ISNULL); } break; case 193: /* expr ::= expr IS NOT expr */ { yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy130,yymsp[0].minor.yy130); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-3].minor.yy130, TK_NOTNULL); } break; case 194: /* expr ::= NOT expr */ case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195); {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy130, 0);/*A-overwrites-B*/} break; case 196: /* expr ::= PLUS|MINUS expr */ { yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy130, 0); /*A-overwrites-B*/ } break; case 197: /* between_op ::= BETWEEN */ case 200: /* in_op ::= IN */ yytestcase(yyruleno==200); {yymsp[0].minor.yy420 = 0;} break; case 199: /* expr ::= expr between_op expr AND expr */ { ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130); yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy130, 0); if( yymsp[-4].minor.yy130 ){ yymsp[-4].minor.yy130->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0); } break; case 202: /* expr ::= expr in_op LP exprlist RP */ { if( yymsp[-1].minor.yy442==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. */ if( IN_RENAME_OBJECT==0 ){ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy130); yymsp[-4].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy420],1); } }else if( yymsp[-1].minor.yy442->nExpr==1 ){ /* Expressions of the form: ** ** expr1 IN (?1) ** expr1 NOT IN (?2) ** ** with exactly one value on the RHS can be simplified to something ** like this: ** ** expr1 == ?1 ** expr1 <> ?2 ** ** But, the RHS of the == or <> is marked with the EP_Generic flag ** so that it may not contribute to the computation of comparison ** affinity or the collating sequence to use for comparison. Otherwise, ** the semantics would be subtly different from IN or NOT IN. */ Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr; yymsp[-1].minor.yy442->a[0].pExpr = 0; sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442); /* pRHS cannot be NULL because a malloc error would have been detected ** before now and control would have never reached this point */ if( ALWAYS(pRHS) ){ pRHS->flags &= ~EP_Collate; pRHS->flags |= EP_Generic; } yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, yymsp[-3].minor.yy420 ? TK_NE : TK_EQ, yymsp[-4].minor.yy130, pRHS); }else{ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0); if( yymsp[-4].minor.yy130 ){ yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy442; sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442); } if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0); } } break; case 203: /* expr ::= LP select RP */ { yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy130, yymsp[-1].minor.yy491); } break; case 204: /* expr ::= expr in_op LP select RP */ { yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0); sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, yymsp[-1].minor.yy491); if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0); } break; case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */ { SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); if( yymsp[0].minor.yy442 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy442); yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0); sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, pSelect); if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0); } break; case 206: /* expr ::= EXISTS LP select RP */ { Expr *p; p = yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy491); } break; case 207: /* expr ::= CASE case_operand case_exprlist case_else END */ { yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy130, 0); if( yymsp[-4].minor.yy130 ){ yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy130 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy130) : yymsp[-2].minor.yy442; sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442); sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy130); } } break; case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy130); yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy130); } break; case 209: /* case_exprlist ::= WHEN expr THEN expr */ { yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130); yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy130); } break; case 212: /* case_operand ::= expr */ {yymsp[0].minor.yy130 = yymsp[0].minor.yy130; /*A-overwrites-X*/} break; case 215: /* nexprlist ::= nexprlist COMMA expr */ {yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy130);} break; case 216: /* nexprlist ::= expr */ {yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy130); /*A-overwrites-Y*/} break; case 218: /* paren_exprlist ::= LP exprlist RP */ case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223); {yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;} break; case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ { sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy420, &yymsp[-11].minor.yy0, yymsp[0].minor.yy130, SQLITE_SO_ASC, yymsp[-8].minor.yy420, SQLITE_IDXTYPE_APPDEF); if( IN_RENAME_OBJECT && pParse->pNewIndex ){ sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); } } break; case 220: /* uniqueflag ::= UNIQUE */ case 262: /* raisetype ::= ABORT */ yytestcase(yyruleno==262); {yymsp[0].minor.yy420 = OE_Abort;} break; case 221: /* uniqueflag ::= */ {yymsp[1].minor.yy420 = OE_None;} break; case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */ { yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420); } break; case 225: /* eidlist ::= nm collate sortorder */ { yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420); /*A-overwrites-Y*/ } break; case 228: /* cmd ::= DROP INDEX ifexists fullname */ {sqlite3DropIndex(pParse, yymsp[0].minor.yy147, yymsp[-1].minor.yy420);} break; case 229: /* cmd ::= VACUUM vinto */ {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy130);} break; case 230: /* cmd ::= VACUUM nm vinto */ {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy130);} break; case 233: /* cmd ::= PRAGMA nm dbnm */ {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} break; case 234: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} break; |
︙ | ︙ | |||
151623 151624 151625 151626 151627 151628 151629 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} break; case 240: /* 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; | | | | | | | | | | | | | | | | | 152267 152268 152269 152270 152271 152272 152273 152274 152275 152276 152277 152278 152279 152280 152281 152282 152283 152284 152285 152286 152287 152288 152289 152290 152291 152292 152293 152294 152295 152296 152297 152298 152299 152300 152301 152302 152303 152304 152305 152306 152307 152308 152309 152310 152311 152312 152313 152314 152315 152316 152317 152318 152319 152320 152321 152322 152323 152324 152325 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} break; case 240: /* 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.yy524, &all); } break; case 241: /* 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.yy420, yymsp[-4].minor.yy498.a, yymsp[-4].minor.yy498.b, yymsp[-2].minor.yy147, yymsp[0].minor.yy130, yymsp[-10].minor.yy420, yymsp[-8].minor.yy420); yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ } break; case 242: /* trigger_time ::= BEFORE|AFTER */ { yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/ } break; case 243: /* trigger_time ::= INSTEAD OF */ { yymsp[-1].minor.yy420 = TK_INSTEAD;} break; case 244: /* trigger_time ::= */ { yymsp[1].minor.yy420 = TK_BEFORE; } break; case 245: /* trigger_event ::= DELETE|INSERT */ case 246: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==246); {yymsp[0].minor.yy498.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy498.b = 0;} break; case 247: /* trigger_event ::= UPDATE OF idlist */ {yymsp[-2].minor.yy498.a = TK_UPDATE; yymsp[-2].minor.yy498.b = yymsp[0].minor.yy200;} break; case 248: /* when_clause ::= */ case 267: /* key_opt ::= */ yytestcase(yyruleno==267); case 315: /* filter_opt ::= */ yytestcase(yyruleno==315); { yymsp[1].minor.yy130 = 0; } break; case 249: /* when_clause ::= WHEN expr */ case 268: /* key_opt ::= KEY expr */ yytestcase(yyruleno==268); { yymsp[-1].minor.yy130 = yymsp[0].minor.yy130; } break; case 250: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ { assert( yymsp[-2].minor.yy524!=0 ); yymsp[-2].minor.yy524->pLast->pNext = yymsp[-1].minor.yy524; yymsp[-2].minor.yy524->pLast = yymsp[-1].minor.yy524; } break; case 251: /* trigger_cmd_list ::= trigger_cmd SEMI */ { assert( yymsp[-1].minor.yy524!=0 ); yymsp[-1].minor.yy524->pLast = yymsp[-1].minor.yy524; } break; case 252: /* trnm ::= nm DOT nm */ { yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; sqlite3ErrorMsg(pParse, "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
︙ | ︙ | |||
151693 151694 151695 151696 151697 151698 151699 | { sqlite3ErrorMsg(pParse, "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | < | < > > > > | | > > > > > | > > > | | > | > > | | | > | | < | | | < < < | > > > | | | | | | | > > | | | | | | | < | | > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 152337 152338 152339 152340 152341 152342 152343 152344 152345 152346 152347 152348 152349 152350 152351 152352 152353 152354 152355 152356 152357 152358 152359 152360 152361 152362 152363 152364 152365 152366 152367 152368 152369 152370 152371 152372 152373 152374 152375 152376 152377 152378 152379 152380 152381 152382 152383 152384 152385 152386 152387 152388 152389 152390 152391 152392 152393 152394 152395 152396 152397 152398 152399 152400 152401 152402 152403 152404 152405 152406 152407 152408 152409 152410 152411 152412 152413 152414 152415 152416 152417 152418 152419 152420 152421 152422 152423 152424 152425 152426 152427 152428 152429 152430 152431 152432 152433 152434 152435 152436 152437 152438 152439 152440 152441 152442 152443 152444 152445 152446 152447 152448 152449 152450 152451 152452 152453 152454 152455 152456 152457 152458 152459 152460 152461 152462 152463 152464 152465 152466 152467 152468 152469 152470 152471 152472 152473 152474 152475 152476 152477 152478 152479 152480 152481 152482 152483 152484 152485 152486 152487 152488 152489 152490 152491 152492 152493 152494 152495 152496 152497 152498 152499 152500 152501 152502 152503 152504 152505 152506 152507 152508 152509 152510 152511 152512 152513 152514 152515 152516 152517 152518 152519 152520 152521 152522 152523 152524 152525 152526 152527 152528 152529 152530 152531 152532 152533 152534 152535 152536 152537 152538 152539 152540 152541 152542 152543 152544 152545 152546 152547 152548 152549 152550 152551 152552 152553 152554 152555 152556 152557 152558 152559 152560 152561 152562 152563 152564 152565 152566 152567 152568 152569 152570 152571 152572 152573 152574 152575 152576 152577 152578 152579 152580 152581 152582 152583 152584 152585 152586 152587 152588 152589 152590 152591 152592 152593 152594 152595 152596 152597 152598 152599 152600 152601 152602 152603 152604 152605 152606 152607 152608 152609 152610 152611 152612 152613 152614 152615 152616 152617 152618 152619 152620 152621 152622 152623 152624 152625 152626 152627 152628 152629 152630 152631 152632 152633 152634 152635 152636 152637 152638 152639 152640 152641 152642 152643 152644 152645 152646 152647 152648 152649 152650 152651 152652 152653 152654 152655 152656 152657 | { sqlite3ErrorMsg(pParse, "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ {yylhsminor.yy524 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy130, yymsp[-6].minor.yy420, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy104);} yymsp[-7].minor.yy524 = yylhsminor.yy524; break; case 256: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { yylhsminor.yy524 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy200,yymsp[-2].minor.yy491,yymsp[-6].minor.yy420,yymsp[-1].minor.yy426,yymsp[-7].minor.yy104,yymsp[0].minor.yy104);/*yylhsminor.yy524-overwrites-yymsp[-6].minor.yy420*/ } yymsp[-7].minor.yy524 = yylhsminor.yy524; break; case 257: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ {yylhsminor.yy524 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy130, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy104);} yymsp[-5].minor.yy524 = yylhsminor.yy524; break; case 258: /* trigger_cmd ::= scanpt select scanpt */ {yylhsminor.yy524 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy491, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); /*yylhsminor.yy524-overwrites-yymsp[-1].minor.yy491*/} yymsp[-2].minor.yy524 = yylhsminor.yy524; break; case 259: /* expr ::= RAISE LP IGNORE RP */ { yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); if( yymsp[-3].minor.yy130 ){ yymsp[-3].minor.yy130->affinity = OE_Ignore; } } break; case 260: /* expr ::= RAISE LP raisetype COMMA nm RP */ { yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); if( yymsp[-5].minor.yy130 ) { yymsp[-5].minor.yy130->affinity = (char)yymsp[-3].minor.yy420; } } break; case 261: /* raisetype ::= ROLLBACK */ {yymsp[0].minor.yy420 = OE_Rollback;} break; case 263: /* raisetype ::= FAIL */ {yymsp[0].minor.yy420 = OE_Fail;} break; case 264: /* cmd ::= DROP TRIGGER ifexists fullname */ { sqlite3DropTrigger(pParse,yymsp[0].minor.yy147,yymsp[-1].minor.yy420); } break; case 265: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { sqlite3Attach(pParse, yymsp[-3].minor.yy130, yymsp[-1].minor.yy130, yymsp[0].minor.yy130); } break; case 266: /* cmd ::= DETACH database_kw_opt expr */ { sqlite3Detach(pParse, yymsp[0].minor.yy130); } break; case 269: /* cmd ::= REINDEX */ {sqlite3Reindex(pParse, 0, 0);} break; case 270: /* cmd ::= REINDEX nm dbnm */ {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; case 271: /* cmd ::= ANALYZE */ {sqlite3Analyze(pParse, 0, 0);} break; case 272: /* cmd ::= ANALYZE nm dbnm */ {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; case 273: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy147,&yymsp[0].minor.yy0); } break; case 274: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ { yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); } break; case 275: /* add_column_fullname ::= fullname */ { disableLookaside(pParse); sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy147); } break; case 276: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ { sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy147, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; case 277: /* cmd ::= create_vtab */ {sqlite3VtabFinishParse(pParse,0);} break; case 278: /* cmd ::= create_vtab LP vtabarglist RP */ {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} break; case 279: /* 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.yy420); } break; case 280: /* vtabarg ::= */ {sqlite3VtabArgInit(pParse);} break; case 281: /* vtabargtoken ::= ANY */ case 282: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==282); case 283: /* lp ::= LP */ yytestcase(yyruleno==283); {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} break; case 284: /* with ::= WITH wqlist */ case 285: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==285); { sqlite3WithPush(pParse, yymsp[0].minor.yy523, 1); } break; case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */ { yymsp[-5].minor.yy523 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491); /*A-overwrites-X*/ } break; case 287: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ { yymsp[-7].minor.yy523 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491); } break; case 288: /* windowdefn_list ::= windowdefn */ { yylhsminor.yy395 = yymsp[0].minor.yy395; } yymsp[0].minor.yy395 = yylhsminor.yy395; break; case 289: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { assert( yymsp[0].minor.yy395!=0 ); sqlite3WindowChain(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy395); yymsp[0].minor.yy395->pNextWin = yymsp[-2].minor.yy395; yylhsminor.yy395 = yymsp[0].minor.yy395; } yymsp[-2].minor.yy395 = yylhsminor.yy395; break; case 290: /* windowdefn ::= nm AS LP window RP */ { if( ALWAYS(yymsp[-1].minor.yy395) ){ yymsp[-1].minor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); } yylhsminor.yy395 = yymsp[-1].minor.yy395; } yymsp[-4].minor.yy395 = yylhsminor.yy395; break; case 291: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { yymsp[-4].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, 0); } break; case 292: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, &yymsp[-5].minor.yy0); } yymsp[-5].minor.yy395 = yylhsminor.yy395; break; case 293: /* window ::= ORDER BY sortlist frame_opt */ { yymsp[-3].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, 0); } break; case 294: /* window ::= nm ORDER BY sortlist frame_opt */ { yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); } yymsp[-4].minor.yy395 = yylhsminor.yy395; break; case 295: /* window ::= frame_opt */ { yylhsminor.yy395 = yymsp[0].minor.yy395; } yymsp[0].minor.yy395 = yylhsminor.yy395; break; case 296: /* window ::= nm frame_opt */ { yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, 0, &yymsp[-1].minor.yy0); } yymsp[-1].minor.yy395 = yylhsminor.yy395; break; case 297: /* frame_opt ::= */ { yymsp[1].minor.yy395 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); } break; case 298: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy420, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy10); } yymsp[-2].minor.yy395 = yylhsminor.yy395; break; case 299: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy420, yymsp[-3].minor.yy273.eType, yymsp[-3].minor.yy273.pExpr, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, yymsp[0].minor.yy10); } yymsp[-5].minor.yy395 = yylhsminor.yy395; break; case 301: /* frame_bound_s ::= frame_bound */ case 303: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==303); {yylhsminor.yy273 = yymsp[0].minor.yy273;} yymsp[0].minor.yy273 = yylhsminor.yy273; break; case 302: /* frame_bound_s ::= UNBOUNDED PRECEDING */ case 304: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==304); case 306: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==306); {yylhsminor.yy273.eType = yymsp[-1].major; yylhsminor.yy273.pExpr = 0;} yymsp[-1].minor.yy273 = yylhsminor.yy273; break; case 305: /* frame_bound ::= expr PRECEDING|FOLLOWING */ {yylhsminor.yy273.eType = yymsp[0].major; yylhsminor.yy273.pExpr = yymsp[-1].minor.yy130;} yymsp[-1].minor.yy273 = yylhsminor.yy273; break; case 307: /* frame_exclude_opt ::= */ {yymsp[1].minor.yy10 = 0;} break; case 308: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ {yymsp[-1].minor.yy10 = yymsp[0].minor.yy10;} break; case 309: /* frame_exclude ::= NO OTHERS */ case 310: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==310); {yymsp[-1].minor.yy10 = yymsp[-1].major; /*A-overwrites-X*/} break; case 311: /* frame_exclude ::= GROUP|TIES */ {yymsp[0].minor.yy10 = yymsp[0].major; /*A-overwrites-X*/} break; case 312: /* window_clause ::= WINDOW windowdefn_list */ { yymsp[-1].minor.yy395 = yymsp[0].minor.yy395; } break; case 313: /* over_clause ::= filter_opt OVER LP window RP */ { yylhsminor.yy395 = yymsp[-1].minor.yy395; assert( yylhsminor.yy395!=0 ); yylhsminor.yy395->pFilter = yymsp[-4].minor.yy130; } yymsp[-4].minor.yy395 = yylhsminor.yy395; break; case 314: /* over_clause ::= filter_opt OVER nm */ { yylhsminor.yy395 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( yylhsminor.yy395 ){ yylhsminor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); yylhsminor.yy395->pFilter = yymsp[-2].minor.yy130; }else{ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy130); } } yymsp[-2].minor.yy395 = yylhsminor.yy395; break; case 316: /* filter_opt ::= FILTER LP WHERE expr RP */ { yymsp[-4].minor.yy130 = yymsp[-1].minor.yy130; } break; default: /* (317) input ::= cmdlist */ yytestcase(yyruleno==317); /* (318) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==318); /* (319) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=319); /* (320) ecmd ::= SEMI */ yytestcase(yyruleno==320); /* (321) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==321); /* (322) ecmd ::= explain cmdx */ yytestcase(yyruleno==322); /* (323) trans_opt ::= */ yytestcase(yyruleno==323); /* (324) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==324); /* (325) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==325); /* (326) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==326); /* (327) savepoint_opt ::= */ yytestcase(yyruleno==327); /* (328) cmd ::= create_table create_table_args */ yytestcase(yyruleno==328); /* (329) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==329); /* (330) columnlist ::= columnname carglist */ yytestcase(yyruleno==330); /* (331) nm ::= ID|INDEXED */ yytestcase(yyruleno==331); /* (332) nm ::= STRING */ yytestcase(yyruleno==332); /* (333) nm ::= JOIN_KW */ yytestcase(yyruleno==333); /* (334) typetoken ::= typename */ yytestcase(yyruleno==334); /* (335) typename ::= ID|STRING */ yytestcase(yyruleno==335); /* (336) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=336); /* (337) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=337); /* (338) carglist ::= carglist ccons */ yytestcase(yyruleno==338); /* (339) carglist ::= */ yytestcase(yyruleno==339); /* (340) ccons ::= NULL onconf */ yytestcase(yyruleno==340); /* (341) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==341); /* (342) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==342); /* (343) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=343); /* (344) tconscomma ::= */ yytestcase(yyruleno==344); /* (345) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=345); /* (346) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=346); /* (347) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=347); /* (348) oneselect ::= values */ yytestcase(yyruleno==348); /* (349) sclp ::= selcollist COMMA */ yytestcase(yyruleno==349); /* (350) as ::= ID|STRING */ yytestcase(yyruleno==350); /* (351) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=351); /* (352) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==352); /* (353) exprlist ::= nexprlist */ yytestcase(yyruleno==353); /* (354) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=354); /* (355) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=355); /* (356) nmnum ::= ON */ yytestcase(yyruleno==356); /* (357) nmnum ::= DELETE */ yytestcase(yyruleno==357); /* (358) nmnum ::= DEFAULT */ yytestcase(yyruleno==358); /* (359) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==359); /* (360) foreach_clause ::= */ yytestcase(yyruleno==360); /* (361) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==361); /* (362) trnm ::= nm */ yytestcase(yyruleno==362); /* (363) tridxby ::= */ yytestcase(yyruleno==363); /* (364) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==364); /* (365) database_kw_opt ::= */ yytestcase(yyruleno==365); /* (366) kwcolumn_opt ::= */ yytestcase(yyruleno==366); /* (367) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==367); /* (368) vtabarglist ::= vtabarg */ yytestcase(yyruleno==368); /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==369); /* (370) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==370); /* (371) anylist ::= */ yytestcase(yyruleno==371); /* (372) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==372); /* (373) anylist ::= anylist ANY */ yytestcase(yyruleno==373); /* (374) with ::= */ yytestcase(yyruleno==374); break; /********** End reduce actions ************************************************/ }; assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) ); yygoto = yyRuleInfoLhs[yyruleno]; yysize = yyRuleInfoNRhs[yyruleno]; yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto); |
︙ | ︙ | |||
152440 152441 152442 152443 152444 152445 152446 | ** 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. */ | | | | | | | | | | | | | | | > > | | < | < | | | | | | | | | | | | | | | | | | | | > | | | | < < | | | > | | | | | | | > | | | | | < | | | | | > | < | | | | | | | | | | | | | | | | | | < | | | > | > | | | < | | | | | | | | | | > | | | < | 153106 153107 153108 153109 153110 153111 153112 153113 153114 153115 153116 153117 153118 153119 153120 153121 153122 153123 153124 153125 153126 153127 153128 153129 153130 153131 153132 153133 153134 153135 153136 153137 153138 153139 153140 153141 153142 153143 153144 153145 153146 153147 153148 153149 153150 153151 153152 153153 153154 153155 153156 153157 153158 153159 153160 153161 153162 153163 153164 153165 153166 153167 153168 153169 153170 153171 153172 153173 153174 153175 153176 153177 153178 153179 153180 153181 153182 153183 153184 153185 153186 153187 153188 153189 153190 153191 153192 153193 153194 153195 153196 153197 153198 153199 153200 153201 153202 153203 153204 153205 153206 153207 153208 153209 153210 153211 153212 153213 153214 153215 153216 153217 153218 153219 153220 153221 153222 153223 153224 153225 153226 153227 153228 153229 153230 153231 153232 153233 153234 153235 153236 153237 153238 153239 153240 153241 153242 153243 153244 153245 153246 153247 153248 153249 153250 153251 153252 153253 153254 153255 153256 153257 | ** 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: 214 */ /* zKWText[] encodes 950 bytes of keyword text in 629 bytes */ /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYCONSTRAINTERSECTIES */ /* AVEPOINTOFFSETRANSACTIONATURALTERAISEXCEPTRIGGEREFERENCES */ /* UNIQUERYWITHOUTERELEASEXCLUSIVEXISTSATTACHAVINGLOBEGINNERANGE */ /* BETWEENOTHINGROUPSCASCADETACHCASECOLLATECREATECURRENT_DATE */ /* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTUPDATEVALUES */ /* VIRTUALIMITWHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULT */ /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */ /* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWING */ /* FROMFULLIFISNULLORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */ /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */ static const char zKWText[628] = { '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','L','U','D','E','L','E', 'T','E','M','P','O','R','A','R','Y','C','O','N','S','T','R','A','I','N', 'T','E','R','S','E','C','T','I','E','S','A','V','E','P','O','I','N','T', 'O','F','F','S','E','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','E','P','T','R','I', 'G','G','E','R','E','F','E','R','E','N','C','E','S','U','N','I','Q','U', 'E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S','E', 'X','C','L','U','S','I','V','E','X','I','S','T','S','A','T','T','A','C', 'H','A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N', 'G','E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U', 'P','S','C','A','S','C','A','D','E','T','A','C','H','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','I','M','M','E','D','I','A','T','E','J','O','I', 'N','S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N', 'A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','U','P','D', 'A','T','E','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M', 'I','T','W','H','E','N','O','T','N','U','L','L','W','H','E','R','E','C', 'U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','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','A','R','T','I','T','I', 'O','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D', 'R','O','P','R','E','C','E','D','I','N','G','F','A','I','L','F','I','L', 'T','E','R','E','P','L','A','C','E','F','O','L','L','O','W','I','N','G', 'F','R','O','M','F','U','L','L','I','F','I','S','N','U','L','L','O','R', 'D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O','V', 'E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S', 'U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I','N', 'G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B','Y', 'I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y', }; /* aKWHash[i] is the hash value for the i-th keyword */ static const unsigned char aKWHash[127] = { 75, 111, 127, 73, 108, 29, 0, 0, 83, 0, 77, 63, 0, 37, 33, 78, 15, 0, 126, 86, 57, 120, 128, 19, 0, 0, 133, 0, 131, 123, 0, 22, 98, 0, 9, 0, 0, 117, 71, 0, 69, 6, 0, 49, 95, 140, 0, 129, 106, 0, 0, 54, 0, 109, 24, 0, 17, 0, 134, 56, 23, 26, 5, 58, 135, 101, 0, 0, 139, 112, 62, 138, 59, 115, 65, 0, 96, 0, 105, 45, 0, 104, 0, 0, 0, 100, 97, 102, 107, 119, 14, 31, 118, 0, 81, 0, 136, 116, 137, 61, 124, 132, 80, 121, 88, 30, 85, 0, 0, 99, 35, 125, 122, 0, 130, 0, 0, 41, 0, 91, 89, 90, 0, 20, 87, 113, 82, }; /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 ** then the i-th keyword has no more hash collisions. Otherwise, ** the next keyword with the same hash is aKWHash[i]-1. */ static const unsigned char aKWNext[140] = { 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, 0, 0, 21, 0, 0, 12, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 28, 0, 0, 38, 0, 0, 0, 44, 0, 0, 0, 3, 0, 0, 67, 1, 66, 0, 0, 0, 36, 0, 47, 0, 0, 0, 0, 0, 48, 50, 76, 0, 0, 42, 0, 60, 0, 0, 0, 43, 0, 16, 55, 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 93, 0, 0, 8, 0, 110, 0, 103, 40, 53, 70, 0, 114, 0, 74, 52, 0, 0, 92, 39, 46, 0, 68, 32, 84, 0, 34, 27, 25, 18, 94, 0, 64, 79, }; /* aKWLen[i] is the length (in bytes) of the i-th keyword */ static const unsigned char aKWLen[140] = { 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, 7, 6, 9, 4, 2, 10, 9, 4, 9, 4, 6, 2, 3, 11, 6, 2, 7, 5, 5, 6, 7, 10, 6, 5, 7, 4, 5, 7, 9, 6, 6, 6, 4, 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6, 12, 9, 4, 6, 4, 5, 4, 7, 6, 5, 6, 6, 7, 5, 4, 7, 3, 2, 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9, 4, 4, 2, 6, 5, 8, 6, 4, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7, }; /* aKWOffset[i] is the index into zKWText[] of the start of ** the text for the i-th keyword. */ static const unsigned short int aKWOffset[140] = { 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, 90, 90, 94, 99, 106, 114, 117, 123, 126, 126, 129, 131, 136, 140, 141, 146, 150, 154, 159, 165, 175, 178, 183, 183, 187, 191, 197, 205, 211, 216, 221, 224, 227, 231, 236, 242, 248, 248, 254, 255, 259, 265, 269, 276, 282, 294, 303, 305, 311, 315, 320, 322, 329, 334, 339, 345, 351, 357, 362, 365, 365, 365, 368, 372, 375, 384, 388, 394, 396, 403, 405, 407, 416, 420, 426, 432, 440, 445, 445, 445, 461, 470, 477, 478, 485, 488, 497, 501, 506, 513, 522, 526, 530, 532, 538, 542, 550, 556, 559, 564, 572, 572, 576, 585, 590, 595, 601, 604, 607, 610, 612, 617, 621, }; /* aKWCode[i] is the parser symbol code for the i-th keyword */ static const unsigned char aKWCode[140] = { 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_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR, TK_CONSTRAINT, TK_INTERSECT, TK_TIES, TK_SAVEPOINT, TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCEPT, TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_EXCLUSIVE, TK_EXISTS, TK_ATTACH, TK_HAVING, TK_LIKE_KW, TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RECURSIVE, TK_AFTER, TK_RENAME, 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_CURRENT, TK_PARTITION, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING, TK_FAIL, TK_FILTER, TK_REPLACE, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY, }; /* Check to see if z[0..n-1] is a keyword. If it is, write the ** parser symbol code for that keyword into *pType. Always ** return the integer n (the length of the token). */ static int keywordCode(const char *z, int n, int *pType){ int i, j; const char *zKW; |
︙ | ︙ | |||
152623 152624 152625 152626 152627 152628 152629 | testcase( i==18 ); /* SELECT */ testcase( i==19 ); /* TABLE */ testcase( i==20 ); /* LEFT */ testcase( i==21 ); /* THEN */ testcase( i==22 ); /* END */ testcase( i==23 ); /* DEFERRABLE */ testcase( i==24 ); /* ELSE */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | 153289 153290 153291 153292 153293 153294 153295 153296 153297 153298 153299 153300 153301 153302 153303 153304 153305 153306 153307 153308 153309 153310 153311 153312 153313 153314 153315 153316 153317 153318 153319 153320 153321 153322 153323 153324 153325 153326 153327 153328 153329 153330 153331 153332 153333 153334 153335 153336 153337 153338 153339 153340 153341 153342 153343 153344 153345 153346 153347 153348 153349 153350 153351 153352 153353 153354 153355 153356 153357 153358 153359 153360 153361 153362 153363 153364 153365 153366 153367 153368 153369 153370 153371 153372 153373 153374 153375 153376 153377 153378 153379 153380 153381 153382 153383 153384 153385 153386 153387 153388 153389 153390 153391 153392 153393 153394 153395 153396 153397 153398 153399 153400 153401 153402 153403 153404 153405 153406 153407 153408 153409 153410 153411 153412 153413 153414 153415 153416 153417 153418 153419 153420 153421 153422 153423 153424 153425 153426 153427 153428 153429 | testcase( i==18 ); /* SELECT */ testcase( i==19 ); /* TABLE */ testcase( i==20 ); /* LEFT */ testcase( i==21 ); /* THEN */ testcase( i==22 ); /* END */ testcase( i==23 ); /* DEFERRABLE */ testcase( i==24 ); /* ELSE */ testcase( i==25 ); /* EXCLUDE */ testcase( i==26 ); /* DELETE */ testcase( i==27 ); /* TEMPORARY */ testcase( i==28 ); /* TEMP */ testcase( i==29 ); /* OR */ testcase( i==30 ); /* CONSTRAINT */ testcase( i==31 ); /* INTERSECT */ testcase( i==32 ); /* TIES */ testcase( i==33 ); /* SAVEPOINT */ testcase( i==34 ); /* INTO */ testcase( i==35 ); /* OFFSET */ testcase( i==36 ); /* OF */ testcase( i==37 ); /* SET */ testcase( i==38 ); /* TRANSACTION */ testcase( i==39 ); /* ACTION */ testcase( i==40 ); /* ON */ testcase( i==41 ); /* NATURAL */ testcase( i==42 ); /* ALTER */ testcase( i==43 ); /* RAISE */ testcase( i==44 ); /* EXCEPT */ testcase( i==45 ); /* TRIGGER */ testcase( i==46 ); /* REFERENCES */ testcase( i==47 ); /* UNIQUE */ testcase( i==48 ); /* QUERY */ testcase( i==49 ); /* WITHOUT */ testcase( i==50 ); /* WITH */ testcase( i==51 ); /* OUTER */ testcase( i==52 ); /* RELEASE */ testcase( i==53 ); /* EXCLUSIVE */ testcase( i==54 ); /* EXISTS */ testcase( i==55 ); /* ATTACH */ testcase( i==56 ); /* HAVING */ testcase( i==57 ); /* GLOB */ testcase( i==58 ); /* BEGIN */ testcase( i==59 ); /* INNER */ testcase( i==60 ); /* RANGE */ testcase( i==61 ); /* BETWEEN */ testcase( i==62 ); /* NOTHING */ testcase( i==63 ); /* GROUPS */ testcase( i==64 ); /* GROUP */ testcase( i==65 ); /* CASCADE */ testcase( i==66 ); /* ASC */ testcase( i==67 ); /* DETACH */ testcase( i==68 ); /* CASE */ testcase( i==69 ); /* COLLATE */ testcase( i==70 ); /* CREATE */ testcase( i==71 ); /* CURRENT_DATE */ testcase( i==72 ); /* IMMEDIATE */ testcase( i==73 ); /* JOIN */ testcase( i==74 ); /* INSERT */ testcase( i==75 ); /* LIKE */ testcase( i==76 ); /* MATCH */ testcase( i==77 ); /* PLAN */ testcase( i==78 ); /* ANALYZE */ testcase( i==79 ); /* PRAGMA */ testcase( i==80 ); /* ABORT */ testcase( i==81 ); /* UPDATE */ testcase( i==82 ); /* VALUES */ testcase( i==83 ); /* VIRTUAL */ testcase( i==84 ); /* LIMIT */ testcase( i==85 ); /* WHEN */ testcase( i==86 ); /* NOTNULL */ testcase( i==87 ); /* NOT */ testcase( i==88 ); /* NO */ testcase( i==89 ); /* NULL */ testcase( i==90 ); /* WHERE */ testcase( i==91 ); /* RECURSIVE */ testcase( i==92 ); /* AFTER */ testcase( i==93 ); /* RENAME */ testcase( i==94 ); /* AND */ testcase( i==95 ); /* DEFAULT */ testcase( i==96 ); /* AUTOINCREMENT */ testcase( i==97 ); /* TO */ testcase( i==98 ); /* IN */ testcase( i==99 ); /* CAST */ testcase( i==100 ); /* COLUMN */ testcase( i==101 ); /* COMMIT */ testcase( i==102 ); /* CONFLICT */ testcase( i==103 ); /* CROSS */ testcase( i==104 ); /* CURRENT_TIMESTAMP */ testcase( i==105 ); /* CURRENT_TIME */ testcase( i==106 ); /* CURRENT */ testcase( i==107 ); /* PARTITION */ testcase( i==108 ); /* DEFERRED */ testcase( i==109 ); /* DISTINCT */ testcase( i==110 ); /* IS */ testcase( i==111 ); /* DROP */ testcase( i==112 ); /* PRECEDING */ testcase( i==113 ); /* FAIL */ testcase( i==114 ); /* FILTER */ testcase( i==115 ); /* REPLACE */ testcase( i==116 ); /* FOLLOWING */ testcase( i==117 ); /* FROM */ testcase( i==118 ); /* FULL */ testcase( i==119 ); /* IF */ testcase( i==120 ); /* ISNULL */ testcase( i==121 ); /* ORDER */ testcase( i==122 ); /* RESTRICT */ testcase( i==123 ); /* OTHERS */ testcase( i==124 ); /* OVER */ testcase( i==125 ); /* RIGHT */ testcase( i==126 ); /* ROLLBACK */ testcase( i==127 ); /* ROWS */ testcase( i==128 ); /* ROW */ testcase( i==129 ); /* UNBOUNDED */ testcase( i==130 ); /* UNION */ testcase( i==131 ); /* USING */ testcase( i==132 ); /* VACUUM */ testcase( i==133 ); /* VIEW */ testcase( i==134 ); /* WINDOW */ testcase( i==135 ); /* DO */ testcase( i==136 ); /* BY */ testcase( i==137 ); /* INITIALLY */ testcase( i==138 ); /* ALL */ testcase( i==139 ); /* PRIMARY */ *pType = aKWCode[i]; break; } } return n; } SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ int id = TK_ID; keywordCode((char*)z, n, &id); return id; } #define SQLITE_N_KEYWORD 140 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){ if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR; *pzName = zKWText + aKWOffset[i]; *pnName = aKWLen[i]; return SQLITE_OK; } SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; } |
︙ | ︙ | |||
154713 154714 154715 154716 154717 154718 154719 154720 154721 154722 154723 154724 154725 154726 | { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer }, { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension }, { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose }, { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG }, { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP }, { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase }, { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ for(i=0; i<ArraySize(aFlagOp); i++){ if( aFlagOp[i].op==op ){ int onoff = va_arg(ap, int); int *pRes = va_arg(ap, int*); | > > | 155383 155384 155385 155386 155387 155388 155389 155390 155391 155392 155393 155394 155395 155396 155397 155398 | { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer }, { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension }, { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose }, { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG }, { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP }, { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase }, { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive }, { SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema| SQLITE_NoSchemaError }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ for(i=0; i<ArraySize(aFlagOp); i++){ if( aFlagOp[i].op==op ){ int onoff = va_arg(ap, int); int *pRes = va_arg(ap, int*); |
︙ | ︙ | |||
168494 168495 168496 168497 168498 168499 168500 | pHash = (Fts3Hash *)sqlite3_user_data(context); zName = sqlite3_value_text(argv[0]); nName = sqlite3_value_bytes(argv[0])+1; if( argc==2 ){ | | | 169166 169167 169168 169169 169170 169171 169172 169173 169174 169175 169176 169177 169178 169179 169180 | pHash = (Fts3Hash *)sqlite3_user_data(context); zName = sqlite3_value_text(argv[0]); nName = sqlite3_value_bytes(argv[0])+1; if( argc==2 ){ if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[1]) ){ void *pOld; int n = sqlite3_value_bytes(argv[1]); if( zName==0 || n!=sizeof(pPtr) ){ sqlite3_result_error(context, "argument type mismatch", -1); return; } pPtr = *(void **)sqlite3_value_blob(argv[1]); |
︙ | ︙ | |||
168521 168522 168523 168524 168525 168526 168527 | if( !pPtr ){ char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName); sqlite3_result_error(context, zErr, -1); sqlite3_free(zErr); return; } } | | | 169193 169194 169195 169196 169197 169198 169199 169200 169201 169202 169203 169204 169205 169206 169207 | if( !pPtr ){ char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName); sqlite3_result_error(context, zErr, -1); sqlite3_free(zErr); return; } } if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[0]) ){ sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT); } } SQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){ static const char isFtsIdChar[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ |
︙ | ︙ | |||
184158 184159 184160 184161 184162 184163 184164 | ** ** The human readable string takes the form of a Tcl list with one ** entry for each cell in the r-tree node. Each entry is itself a ** list, containing the 8-byte rowid/pageno followed by the ** <num-dimension>*2 coordinates. */ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ | < > > > > > > > > < < > | < < | < | < | < < < < < < | < | | > | 184830 184831 184832 184833 184834 184835 184836 184837 184838 184839 184840 184841 184842 184843 184844 184845 184846 184847 184848 184849 184850 184851 184852 184853 184854 184855 184856 184857 184858 184859 184860 184861 184862 184863 184864 184865 184866 184867 184868 184869 184870 184871 184872 184873 184874 184875 184876 184877 184878 184879 184880 184881 184882 | ** ** The human readable string takes the form of a Tcl list with one ** entry for each cell in the r-tree node. Each entry is itself a ** list, containing the 8-byte rowid/pageno followed by the ** <num-dimension>*2 coordinates. */ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ RtreeNode node; Rtree tree; int ii; int nData; int errCode; sqlite3_str *pOut; UNUSED_PARAMETER(nArg); memset(&node, 0, sizeof(RtreeNode)); memset(&tree, 0, sizeof(Rtree)); tree.nDim = (u8)sqlite3_value_int(apArg[0]); if( tree.nDim<1 || tree.nDim>5 ) return; tree.nDim2 = tree.nDim*2; tree.nBytesPerCell = 8 + 8 * tree.nDim; node.zData = (u8 *)sqlite3_value_blob(apArg[1]); nData = sqlite3_value_bytes(apArg[1]); if( nData<4 ) return; if( nData<NCELL(&node)*tree.nBytesPerCell ) return; pOut = sqlite3_str_new(0); for(ii=0; ii<NCELL(&node); ii++){ RtreeCell cell; int jj; nodeGetCell(&tree, &node, ii, &cell); if( ii>0 ) sqlite3_str_append(pOut, " ", 1); sqlite3_str_appendf(pOut, "{%lld", cell.iRowid); for(jj=0; jj<tree.nDim2; jj++){ #ifndef SQLITE_RTREE_INT_ONLY sqlite3_str_appendf(pOut, " %g", (double)cell.aCoord[jj].f); #else sqlite3_str_appendf(pOut, " %d", cell.aCoord[jj].i); #endif } sqlite3_str_append(pOut, "}", 1); } errCode = sqlite3_str_errcode(pOut); sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free); sqlite3_result_error_code(ctx, errCode); } /* This routine implements an SQL function that returns the "depth" parameter ** from the front of a blob that is an r-tree node. For example: ** ** SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1; ** |
︙ | ︙ | |||
198078 198079 198080 198081 198082 198083 198084 | if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect); } return rc; } /* | | | 198746 198747 198748 198749 198750 198751 198752 198753 198754 198755 198756 198757 198758 198759 198760 | if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect); } return rc; } /* ** This function is called from within sqlite3changeset_apply_v2() when ** a conflict is encountered and resolved using conflict resolution ** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE).. ** It adds a conflict resolution record to the buffer in ** SessionApplyCtx.rebase, which will eventually be returned to the caller ** of apply_v2() as the "rebase" buffer. ** ** Return SQLITE_OK if successful, or an SQLite error code otherwise. |
︙ | ︙ | |||
200857 200858 200859 200860 200861 200862 200863 200864 | /* ** Empty (but do not delete) a hash table. */ static void sqlite3Fts5HashClear(Fts5Hash*); static int sqlite3Fts5HashQuery( Fts5Hash*, /* Hash table to query */ const char *pTerm, int nTerm, /* Query term */ | > | | 201525 201526 201527 201528 201529 201530 201531 201532 201533 201534 201535 201536 201537 201538 201539 201540 201541 | /* ** Empty (but do not delete) a hash table. */ static void sqlite3Fts5HashClear(Fts5Hash*); static int sqlite3Fts5HashQuery( Fts5Hash*, /* Hash table to query */ int nPre, const char *pTerm, int nTerm, /* Query term */ void **ppObj, /* OUT: Pointer to doclist for pTerm */ int *pnDoclist /* OUT: Size of doclist in bytes */ ); static int sqlite3Fts5HashScanInit( Fts5Hash*, /* Hash table to query */ const char *pTerm, int nTerm /* Query prefix */ ); |
︙ | ︙ | |||
202928 202929 202930 202931 202932 202933 202934 | } *pnScore = nScore; if( piPos ){ sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2; if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken; if( iAdj<0 ) iAdj = 0; | | | 203597 203598 203599 203600 203601 203602 203603 203604 203605 203606 203607 203608 203609 203610 203611 | } *pnScore = nScore; if( piPos ){ sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2; if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken; if( iAdj<0 ) iAdj = 0; *piPos = (int)iAdj; } return rc; } /* ** Return the value in pVal interpreted as utf-8 text. Except, if pVal |
︙ | ︙ | |||
203156 203157 203158 203159 203160 203161 203162 | /* Allocate the Fts5Bm25Data object */ nPhrase = pApi->xPhraseCount(pFts); nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double); p = (Fts5Bm25Data*)sqlite3_malloc64(nByte); if( p==0 ){ rc = SQLITE_NOMEM; }else{ | | | 203825 203826 203827 203828 203829 203830 203831 203832 203833 203834 203835 203836 203837 203838 203839 | /* Allocate the Fts5Bm25Data object */ nPhrase = pApi->xPhraseCount(pFts); nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double); p = (Fts5Bm25Data*)sqlite3_malloc64(nByte); if( p==0 ){ rc = SQLITE_NOMEM; }else{ memset(p, 0, (size_t)nByte); p->nPhrase = nPhrase; p->aIDF = (double*)&p[1]; p->aFreq = &p->aIDF[nPhrase]; } /* Calculate the average document length for this FTS5 table */ if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow); |
︙ | ︙ | |||
203319 203320 203321 203322 203323 203324 203325 | nNew = nNew * 2; } pNew = sqlite3_realloc64(pBuf->p, nNew); if( pNew==0 ){ *pRc = SQLITE_NOMEM; return 1; }else{ | | | 203988 203989 203990 203991 203992 203993 203994 203995 203996 203997 203998 203999 204000 204001 204002 | nNew = nNew * 2; } pNew = sqlite3_realloc64(pBuf->p, nNew); if( pNew==0 ){ *pRc = SQLITE_NOMEM; return 1; }else{ pBuf->nSpace = (int)nNew; pBuf->p = pNew; } } return 0; } |
︙ | ︙ | |||
203543 203544 203545 203546 203547 203548 203549 | static void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){ void *pRet = 0; if( *pRc==SQLITE_OK ){ pRet = sqlite3_malloc64(nByte); if( pRet==0 ){ if( nByte>0 ) *pRc = SQLITE_NOMEM; }else{ | | | 204212 204213 204214 204215 204216 204217 204218 204219 204220 204221 204222 204223 204224 204225 204226 | static void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){ void *pRet = 0; if( *pRc==SQLITE_OK ){ pRet = sqlite3_malloc64(nByte); if( pRet==0 ){ if( nByte>0 ) *pRc = SQLITE_NOMEM; }else{ memset(pRet, 0, (size_t)nByte); } } return pRet; } /* ** Return a nul-terminated copy of the string indicated by pIn. If nIn |
︙ | ︙ | |||
204012 204013 204014 204015 204016 204017 204018 | } } if( p==0 ){ *pzErr = sqlite3_mprintf("parse error in tokenize directive"); rc = SQLITE_ERROR; }else{ rc = sqlite3Fts5GetTokenizer(pGlobal, | | | 204681 204682 204683 204684 204685 204686 204687 204688 204689 204690 204691 204692 204693 204694 204695 | } } if( p==0 ){ *pzErr = sqlite3_mprintf("parse error in tokenize directive"); rc = SQLITE_ERROR; }else{ rc = sqlite3Fts5GetTokenizer(pGlobal, (const char**)azArg, (int)nArg, &pConfig->pTok, &pConfig->pTokApi, pzErr ); } } } sqlite3_free(azArg); |
︙ | ︙ | |||
204122 204123 204124 204125 204126 204127 204128 | assert( *pRc==SQLITE_OK ); *pbQuoted = 0; *pzOut = 0; if( zOut==0 ){ *pRc = SQLITE_NOMEM; }else{ | | | 204791 204792 204793 204794 204795 204796 204797 204798 204799 204800 204801 204802 204803 204804 204805 | assert( *pRc==SQLITE_OK ); *pbQuoted = 0; *pzOut = 0; if( zOut==0 ){ *pRc = SQLITE_NOMEM; }else{ memcpy(zOut, zIn, (size_t)(nIn+1)); if( fts5_isopenquote(zOut[0]) ){ int ii = fts5Dequote(zOut); zRet = &zIn[ii]; *pbQuoted = 1; }else{ zRet = fts5ConfigSkipBareword(zIn); if( zRet ){ |
︙ | ︙ | |||
206136 206137 206138 206139 206140 206141 206142 | if( pNear==0 ){ sqlite3_int64 nByte; nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*); pRet = sqlite3_malloc64(nByte); if( pRet==0 ){ pParse->rc = SQLITE_NOMEM; }else{ | | | 206805 206806 206807 206808 206809 206810 206811 206812 206813 206814 206815 206816 206817 206818 206819 | if( pNear==0 ){ sqlite3_int64 nByte; nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*); pRet = sqlite3_malloc64(nByte); if( pRet==0 ){ pParse->rc = SQLITE_NOMEM; }else{ memset(pRet, 0, (size_t)nByte); } }else if( (pNear->nPhrase % SZALLOC)==0 ){ int nNew = pNear->nPhrase + SZALLOC; sqlite3_int64 nByte; nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*); pRet = (Fts5ExprNearset*)sqlite3_realloc64(pNear, nByte); |
︙ | ︙ | |||
206212 206213 206214 206215 206216 206217 206218 | if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ Fts5ExprTerm *pSyn; sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte); if( pSyn==0 ){ rc = SQLITE_NOMEM; }else{ | | | 206881 206882 206883 206884 206885 206886 206887 206888 206889 206890 206891 206892 206893 206894 206895 | if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ Fts5ExprTerm *pSyn; sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte); if( pSyn==0 ){ rc = SQLITE_NOMEM; }else{ memset(pSyn, 0, (size_t)nByte); pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer); memcpy(pSyn->zTerm, pToken, nToken); pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym; pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn; } }else{ Fts5ExprTerm *pTerm; |
︙ | ︙ | |||
206372 206373 206374 206375 206376 206377 206378 | Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; if( pColsetOrig ){ sqlite3_int64 nByte; Fts5Colset *pColset; nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int); pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte); if( pColset ){ | | | 207041 207042 207043 207044 207045 207046 207047 207048 207049 207050 207051 207052 207053 207054 207055 | Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; if( pColsetOrig ){ sqlite3_int64 nByte; Fts5Colset *pColset; nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int); pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte); if( pColset ){ memcpy(pColset, pColsetOrig, (size_t)nByte); } pNew->pRoot->pNear->pColset = pColset; } } if( pOrig->nTerm ){ int i; /* Used to iterate through phrase terms */ |
︙ | ︙ | |||
206589 206590 206591 206592 206593 206594 206595 | */ static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ Fts5Colset *pRet; if( pOrig ){ sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int); pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte); if( pRet ){ | | | 207258 207259 207260 207261 207262 207263 207264 207265 207266 207267 207268 207269 207270 207271 207272 | */ static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ Fts5Colset *pRet; if( pOrig ){ sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int); pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte); if( pRet ){ memcpy(pRet, pOrig, (size_t)nByte); } }else{ pRet = 0; } return pRet; } |
︙ | ︙ | |||
207606 207607 207608 207609 207610 207611 207612 | nByte = sizeof(Fts5HashEntry*) * pNew->nSlot; pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte); if( pNew->aSlot==0 ){ sqlite3_free(pNew); *ppNew = 0; rc = SQLITE_NOMEM; }else{ | | | 208275 208276 208277 208278 208279 208280 208281 208282 208283 208284 208285 208286 208287 208288 208289 | nByte = sizeof(Fts5HashEntry*) * pNew->nSlot; pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte); if( pNew->aSlot==0 ){ sqlite3_free(pNew); *ppNew = 0; rc = SQLITE_NOMEM; }else{ memset(pNew->aSlot, 0, (size_t)nByte); } } return rc; } /* ** Free a hash table object. |
︙ | ︙ | |||
207690 207691 207692 207693 207694 207695 207696 | sqlite3_free(apOld); pHash->nSlot = nNew; pHash->aSlot = apNew; return SQLITE_OK; } | | > > > > > | > | | | | | > > | | | > | > > | 208359 208360 208361 208362 208363 208364 208365 208366 208367 208368 208369 208370 208371 208372 208373 208374 208375 208376 208377 208378 208379 208380 208381 208382 208383 208384 208385 208386 208387 208388 208389 208390 208391 208392 208393 208394 208395 208396 208397 208398 208399 208400 208401 208402 208403 208404 208405 208406 208407 208408 208409 208410 208411 208412 208413 | sqlite3_free(apOld); pHash->nSlot = nNew; pHash->aSlot = apNew; return SQLITE_OK; } static int fts5HashAddPoslistSize( Fts5Hash *pHash, Fts5HashEntry *p, Fts5HashEntry *p2 ){ int nRet = 0; if( p->iSzPoslist ){ u8 *pPtr = p2 ? (u8*)p2 : (u8*)p; int nData = p->nData; if( pHash->eDetail==FTS5_DETAIL_NONE ){ assert( nData==p->iSzPoslist ); if( p->bDel ){ pPtr[nData++] = 0x00; if( p->bContent ){ pPtr[nData++] = 0x00; } } }else{ int nSz = (nData - p->iSzPoslist - 1); /* Size in bytes */ int nPos = nSz*2 + p->bDel; /* Value of nPos field */ assert( p->bDel==0 || p->bDel==1 ); if( nPos<=127 ){ pPtr[p->iSzPoslist] = (u8)nPos; }else{ int nByte = sqlite3Fts5GetVarintLen((u32)nPos); memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz); sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos); nData += (nByte-1); } } nRet = nData - p->nData; if( p2==0 ){ p->iSzPoslist = 0; p->bDel = 0; p->bContent = 0; p->nData = nData; } } return nRet; } /* ** Add an entry to the in-memory hash table. The key is the concatenation ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos). ** ** (bByte || pToken) -> (iRowid,iCol,iPos) |
︙ | ︙ | |||
207776 207777 207778 207779 207780 207781 207782 | iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); } /* Allocate new Fts5HashEntry and add it to the hash table. */ p = (Fts5HashEntry*)sqlite3_malloc64(nByte); if( !p ) return SQLITE_NOMEM; memset(p, 0, sizeof(Fts5HashEntry)); | | | 208456 208457 208458 208459 208460 208461 208462 208463 208464 208465 208466 208467 208468 208469 208470 | iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken); } /* Allocate new Fts5HashEntry and add it to the hash table. */ p = (Fts5HashEntry*)sqlite3_malloc64(nByte); if( !p ) return SQLITE_NOMEM; memset(p, 0, sizeof(Fts5HashEntry)); p->nAlloc = (int)nByte; zKey = fts5EntryKey(p); zKey[0] = bByte; memcpy(&zKey[1], pToken, nToken); assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) ); p->nKey = nToken; zKey[nToken+1] = '\0'; p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry); |
︙ | ︙ | |||
207831 207832 207833 207834 207835 207836 207837 | assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) ); pPtr = (u8*)p; /* If this is a new rowid, append the 4-byte size field for the previous ** entry, and the new rowid for this entry. */ if( iRowid!=p->iRowid ){ | | | 208511 208512 208513 208514 208515 208516 208517 208518 208519 208520 208521 208522 208523 208524 208525 | assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) ); pPtr = (u8*)p; /* If this is a new rowid, append the 4-byte size field for the previous ** entry, and the new rowid for this entry. */ if( iRowid!=p->iRowid ){ fts5HashAddPoslistSize(pHash, p, 0); p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid); p->iRowid = iRowid; bNew = 1; p->iSzPoslist = p->nData; if( pHash->eDetail!=FTS5_DETAIL_NONE ){ p->nData += 1; p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1); |
︙ | ︙ | |||
207948 207949 207950 207951 207952 207953 207954 | ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot); if( !ap ) return SQLITE_NOMEM; memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot); for(iSlot=0; iSlot<pHash->nSlot; iSlot++){ Fts5HashEntry *pIter; for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){ | > | > | 208628 208629 208630 208631 208632 208633 208634 208635 208636 208637 208638 208639 208640 208641 208642 208643 208644 | ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot); if( !ap ) return SQLITE_NOMEM; memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot); for(iSlot=0; iSlot<pHash->nSlot; iSlot++){ Fts5HashEntry *pIter; for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){ if( pTerm==0 || (pIter->nKey+1>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm)) ){ Fts5HashEntry *pEntry = pIter; pEntry->pScanNext = 0; for(i=0; ap[i]; i++){ pEntry = fts5HashEntryMerge(pEntry, ap[i]); ap[i] = 0; } ap[i] = pEntry; |
︙ | ︙ | |||
207976 207977 207978 207979 207980 207981 207982 207983 | } /* ** Query the hash table for a doclist associated with term pTerm/nTerm. */ static int sqlite3Fts5HashQuery( Fts5Hash *pHash, /* Hash table to query */ const char *pTerm, int nTerm, /* Query term */ | > | > > > > > > | | > | > > | | 208658 208659 208660 208661 208662 208663 208664 208665 208666 208667 208668 208669 208670 208671 208672 208673 208674 208675 208676 208677 208678 208679 208680 208681 208682 208683 208684 208685 208686 208687 208688 208689 208690 208691 208692 208693 208694 208695 208696 208697 208698 208699 208700 208701 | } /* ** Query the hash table for a doclist associated with term pTerm/nTerm. */ static int sqlite3Fts5HashQuery( Fts5Hash *pHash, /* Hash table to query */ int nPre, const char *pTerm, int nTerm, /* Query term */ void **ppOut, /* OUT: Pointer to new object */ int *pnDoclist /* OUT: Size of doclist in bytes */ ){ unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm); char *zKey = 0; Fts5HashEntry *p; for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ zKey = fts5EntryKey(p); assert( p->nKey+1==(int)strlen(zKey) ); if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break; } if( p ){ int nHashPre = sizeof(Fts5HashEntry) + nTerm + 1; int nList = p->nData - nHashPre; u8 *pRet = (u8*)(*ppOut = sqlite3_malloc64(nPre + nList + 10)); if( pRet ){ Fts5HashEntry *pFaux = (Fts5HashEntry*)&pRet[nPre-nHashPre]; memcpy(&pRet[nPre], &((u8*)p)[nHashPre], nList); nList += fts5HashAddPoslistSize(pHash, p, pFaux); *pnDoclist = nList; }else{ *pnDoclist = 0; return SQLITE_NOMEM; } }else{ *ppOut = 0; *pnDoclist = 0; } return SQLITE_OK; } static int sqlite3Fts5HashScanInit( |
︙ | ︙ | |||
208028 208029 208030 208031 208032 208033 208034 | const u8 **ppDoclist, /* OUT: pointer to doclist */ int *pnDoclist /* OUT: size of doclist in bytes */ ){ Fts5HashEntry *p; if( (p = pHash->pScan) ){ char *zKey = fts5EntryKey(p); int nTerm = (int)strlen(zKey); | | | 208720 208721 208722 208723 208724 208725 208726 208727 208728 208729 208730 208731 208732 208733 208734 | const u8 **ppDoclist, /* OUT: pointer to doclist */ int *pnDoclist /* OUT: size of doclist in bytes */ ){ Fts5HashEntry *p; if( (p = pHash->pScan) ){ char *zKey = fts5EntryKey(p); int nTerm = (int)strlen(zKey); fts5HashAddPoslistSize(pHash, p, 0); *pzTerm = zKey; *ppDoclist = (const u8*)&zKey[nTerm+1]; *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); }else{ *pzTerm = 0; *ppDoclist = 0; *pnDoclist = 0; |
︙ | ︙ | |||
210498 210499 210500 210501 210502 210503 210504 | */ static void fts5SegIterHashInit( Fts5Index *p, /* FTS5 backend */ const u8 *pTerm, int nTerm, /* Term to seek to */ int flags, /* Mask of FTS5INDEX_XXX flags */ Fts5SegIter *pIter /* Object to populate */ ){ | < > > > > > > > > > < | > > > > > > | < < < < | 211190 211191 211192 211193 211194 211195 211196 211197 211198 211199 211200 211201 211202 211203 211204 211205 211206 211207 211208 211209 211210 211211 211212 211213 211214 211215 211216 211217 211218 211219 211220 211221 211222 211223 211224 211225 211226 211227 211228 211229 211230 211231 211232 211233 211234 211235 211236 211237 | */ static void fts5SegIterHashInit( Fts5Index *p, /* FTS5 backend */ const u8 *pTerm, int nTerm, /* Term to seek to */ int flags, /* Mask of FTS5INDEX_XXX flags */ Fts5SegIter *pIter /* Object to populate */ ){ int nList = 0; const u8 *z = 0; int n = 0; Fts5Data *pLeaf = 0; assert( p->pHash ); assert( p->rc==SQLITE_OK ); if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){ const u8 *pList = 0; p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm); sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList); n = (z ? (int)strlen((const char*)z) : 0); if( pList ){ pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data)); if( pLeaf ){ pLeaf->p = (u8*)pList; } } }else{ p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data), (const char*)pTerm, nTerm, (void**)&pLeaf, &nList ); if( pLeaf ){ pLeaf->p = (u8*)&pLeaf[1]; } z = pTerm; n = nTerm; pIter->flags |= FTS5_SEGITER_ONETERM; } if( pLeaf ){ sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z); pLeaf->nn = pLeaf->szLeaf = nList; pIter->pLeaf = pLeaf; pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid); pIter->iEndofDoclist = pLeaf->nn; if( flags & FTS5INDEX_QUERY_DESC ){ pIter->flags |= FTS5_SEGITER_REVERSE; |
︙ | ︙ | |||
215239 215240 215241 215242 215243 215244 215245 | rc = fts5NewTransaction(pTab); if( rc==SQLITE_OK ){ nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int); pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte); if( pCsr ){ Fts5Global *pGlobal = pTab->pGlobal; | | | 215940 215941 215942 215943 215944 215945 215946 215947 215948 215949 215950 215951 215952 215953 215954 | rc = fts5NewTransaction(pTab); if( rc==SQLITE_OK ){ nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int); pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte); if( pCsr ){ Fts5Global *pGlobal = pTab->pGlobal; memset(pCsr, 0, (size_t)nByte); pCsr->aColumnSize = (int*)&pCsr[1]; pCsr->pNext = pGlobal->pCsr; pGlobal->pCsr = pCsr; pCsr->iCsrId = ++pGlobal->iNextId; }else{ rc = SQLITE_NOMEM; } |
︙ | ︙ | |||
215520 215521 215522 215523 215524 215525 215526 | const char *zRank = pCsr->zRank; const char *zRankArgs = pCsr->zRankArgs; nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr); nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1); pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte); if( pSorter==0 ) return SQLITE_NOMEM; | | | 216221 216222 216223 216224 216225 216226 216227 216228 216229 216230 216231 216232 216233 216234 216235 | const char *zRank = pCsr->zRank; const char *zRankArgs = pCsr->zRankArgs; nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr); nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1); pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte); if( pSorter==0 ) return SQLITE_NOMEM; memset(pSorter, 0, (size_t)nByte); pSorter->nIdx = nPhrase; /* TODO: It would be better to have some system for reusing statement ** handles here, rather than preparing a new one for each query. But that ** is not possible as SQLite reference counts the virtual table objects. ** And since the statement required here reads from this very virtual ** table, saving it creates a circular reference. |
︙ | ︙ | |||
217254 217255 217256 217257 217258 217259 217260 | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); | | | 217955 217956 217957 217958 217959 217960 217961 217962 217963 217964 217965 217966 217967 217968 217969 | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); sqlite3_result_text(pCtx, "fts5: 2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f", -1, SQLITE_TRANSIENT); } /* ** Return true if zName is the extension on one of the shadow tables used ** by this module. */ static int fts5ShadowName(const char *zName){ |
︙ | ︙ | |||
217677 217678 217679 217680 217681 217682 217683 | sqlite3_int64 nByte; /* Bytes of space to allocate */ nByte = sizeof(Fts5Storage) /* Fts5Storage object */ + pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */ *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte); if( !p ) return SQLITE_NOMEM; | | | 218378 218379 218380 218381 218382 218383 218384 218385 218386 218387 218388 218389 218390 218391 218392 | sqlite3_int64 nByte; /* Bytes of space to allocate */ nByte = sizeof(Fts5Storage) /* Fts5Storage object */ + pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */ *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte); if( !p ) return SQLITE_NOMEM; memset(p, 0, (size_t)nByte); p->aTotalSize = (i64*)&p[1]; p->pConfig = pConfig; p->pIndex = pIndex; if( bCreate ){ if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ int nDefn = 32 + pConfig->nCol*10; |
︙ | ︙ | |||
220587 220588 220589 220590 220591 220592 220593 | static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){ int i = 0; int iTbl = 0; while( i<128 ){ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ]; int n = (aFts5UnicodeData[iTbl] >> 5) + i; for(; i<128 && i<n; i++){ | | | 221288 221289 221290 221291 221292 221293 221294 221295 221296 221297 221298 221299 221300 221301 221302 | static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){ int i = 0; int iTbl = 0; while( i<128 ){ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ]; int n = (aFts5UnicodeData[iTbl] >> 5) + i; for(; i<128 && i<n; i++){ aAscii[i] = (u8)bToken; } iTbl++; } } /* ** 2015 May 30 |
︙ | ︙ | |||
222018 222019 222020 222021 222022 222023 222024 | #endif return rc; } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ | | | | 222719 222720 222721 222722 222723 222724 222725 222726 222727 222728 222729 222730 222731 222732 | #endif return rc; } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ #if __LINE__!=222726 #undef SQLITE_SOURCE_ID #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2aalt2" #endif /* Return the source-id for this library */ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } /************************** End of sqlite3.c ******************************/ |
Changes to src/sqlite3.h.
︙ | ︙ | |||
121 122 123 124 125 126 127 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.28.0" #define SQLITE_VERSION_NUMBER 3028000 | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.28.0" #define SQLITE_VERSION_NUMBER 3028000 #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f" /* ** 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 |
︙ | ︙ | |||
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled with mutexing code omitted due to the | > > > | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #else # define sqlite3_compileoption_used(X) 0 # define sqlite3_compileoption_get(X) ((void*)0) #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled with mutexing code omitted due to the |
︙ | ︙ | |||
2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 | ** features include but are not limited to the following: ** <ul> ** <li> The [PRAGMA writable_schema=ON] statement. ** <li> Writes to the [sqlite_dbpage] virtual table. ** <li> Direct writes to [shadow tables]. ** </ul> ** </dd> ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */ #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */ #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */ | > > > > > > > > > > > > | | 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 | ** features include but are not limited to the following: ** <ul> ** <li> The [PRAGMA writable_schema=ON] statement. ** <li> Writes to the [sqlite_dbpage] virtual table. ** <li> Direct writes to [shadow tables]. ** </ul> ** </dd> ** ** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt> ** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the ** "writable_schema" flag. This has the same effect and is logically equivalent ** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF]. ** The first argument to this setting is an integer which is 0 to disable ** the writable_schema, positive to enable writable_schema, or negative to ** leave the setting unchanged. The second parameter is a pointer to an ** integer into which is written 0 or 1 to indicate whether the writable_schema ** is enabled or disabled following this call. ** </dd> ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */ #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */ #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */ #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */ #define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** METHOD: sqlite3 ** ** ^The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. ^The extended result |
︙ | ︙ | |||
4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 | ** <tr><td><b>sqlite3_value_type</b><td>→<td>Default ** datatype of the value ** <tr><td><b>sqlite3_value_numeric_type </b> ** <td>→ <td>Best numeric datatype of the value ** <tr><td><b>sqlite3_value_nochange </b> ** <td>→ <td>True if the column is unchanged in an UPDATE ** against a virtual table. ** </table></blockquote> ** ** <b>Details:</b> ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects ** are used to pass parameter information into implementation of | > > | 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 | ** <tr><td><b>sqlite3_value_type</b><td>→<td>Default ** datatype of the value ** <tr><td><b>sqlite3_value_numeric_type </b> ** <td>→ <td>Best numeric datatype of the value ** <tr><td><b>sqlite3_value_nochange </b> ** <td>→ <td>True if the column is unchanged in an UPDATE ** against a virtual table. ** <tr><td><b>sqlite3_value_frombind </b> ** <td>→ <td>True if value originated a bound parameter ** </table></blockquote> ** ** <b>Details:</b> ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects ** are used to pass parameter information into implementation of |
︙ | ︙ | |||
5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 | ** the value for that column returned without setting a result (probably ** because it queried [sqlite3_vtab_nochange()] and found that the column ** was unchanging). ^Within an [xUpdate] method, any value for which ** sqlite3_value_nochange(X) is true will in all other respects appear ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other ** than within an [xUpdate] method call for an UPDATE statement, then ** the return value is arbitrary and meaningless. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** | > > > > > | 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 | ** the value for that column returned without setting a result (probably ** because it queried [sqlite3_vtab_nochange()] and found that the column ** was unchanging). ^Within an [xUpdate] method, any value for which ** sqlite3_value_nochange(X) is true will in all other respects appear ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other ** than within an [xUpdate] method call for an UPDATE statement, then ** the return value is arbitrary and meaningless. ** ** ^The sqlite3_value_frombind(X) interface returns non-zero if the ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] ** interfaces. ^If X comes from an SQL literal value, or a table column, ** and expression, then sqlite3_value_frombind(X) returns zero. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** |
︙ | ︙ | |||
5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); SQLITE_API int sqlite3_value_nochange(sqlite3_value*); /* ** CAPI3REF: Finding The Subtype Of SQL Values ** METHOD: sqlite3_value ** ** The sqlite3_value_subtype(V) function returns the subtype for ** an [application-defined SQL function] argument V. The subtype | > | 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); SQLITE_API int sqlite3_value_nochange(sqlite3_value*); SQLITE_API int sqlite3_value_frombind(sqlite3_value*); /* ** CAPI3REF: Finding The Subtype Of SQL Values ** METHOD: sqlite3_value ** ** The sqlite3_value_subtype(V) function returns the subtype for ** an [application-defined SQL function] argument V. The subtype |
︙ | ︙ | |||
10902 10903 10904 10905 10906 10907 10908 | ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) | | | 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 | ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changeset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the ** responsibility of the caller to eventually free the new buffer using ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) ** are set to zero and an SQLite error code returned. */ SQLITE_API int sqlite3rebaser_rebase( sqlite3_rebaser*, |
︙ | ︙ |