diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 6 | ||||
-rw-r--r-- | src/select.c | 6 | ||||
-rw-r--r-- | src/shell.c.in | 12 | ||||
-rw-r--r-- | src/sqlite.h.in | 2 | ||||
-rw-r--r-- | src/sqliteInt.h | 2 | ||||
-rw-r--r-- | src/vdbe.c | 29 | ||||
-rw-r--r-- | src/where.c | 4 | ||||
-rw-r--r-- | src/wherecode.c | 3 |
8 files changed, 44 insertions, 20 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 9e7ba05d6..c61b19060 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3987,7 +3987,7 @@ static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){ /* Forward declaration */ static int unixGetTempname(int nBuf, char *zBuf); -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) static int unixFcntlExternalReader(unixFile*, int*); #endif @@ -4114,7 +4114,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ case SQLITE_FCNTL_EXTERNAL_READER: { -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) return unixFcntlExternalReader((unixFile*)id, (int*)pArg); #else *(int*)pArg = 0; @@ -4287,7 +4287,7 @@ static int unixGetpagesize(void){ #endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */ -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) /* ** Object used to represent an shared memory buffer. diff --git a/src/select.c b/src/select.c index 9ff5c6c53..4671dfa6d 100644 --- a/src/select.c +++ b/src/select.c @@ -8331,7 +8331,11 @@ int sqlite3Select( } if( iOrderByCol ){ - sqlite3ExprToRegister(p->pEList->a[iOrderByCol-1].pExpr, iAMem+j); + Expr *pX = p->pEList->a[iOrderByCol-1].pExpr; + Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX); + if( ALWAYS(pBase!=0) && pBase->op!=TK_AGG_COLUMN ){ + sqlite3ExprToRegister(pX, iAMem+j); + } } } sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr, diff --git a/src/shell.c.in b/src/shell.c.in index 6773b2b4e..546107138 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8955,6 +8955,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("%s: empty file\n", sCtx.zFile); import_cleanup(&sCtx); rc = 1; + sqlite3_free(zCreate); goto meta_command_exit; } zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs); @@ -10905,7 +10906,7 @@ static int do_meta_command(char *zLine, ShellState *p){ #ifdef YYCOVERAGE {"parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE,0,"" }, #endif - {"pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,0, "OFFSET " }, + {"pending_byte", SQLITE_TESTCTRL_PENDING_BYTE,1, "OFFSET " }, {"prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE,0, "" }, {"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" }, {"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" }, @@ -12749,8 +12750,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ if( azCmd[i][0]=='.' ){ rc = do_meta_command(azCmd[i], &data); if( rc ){ - free(azCmd); - return rc==2 ? 0 : rc; + if( rc==2 ) rc = 0; + goto shell_main_exit; } }else{ open_db(&data, 0); @@ -12763,8 +12764,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ eputf("Error: unable to process SQL: %s\n", azCmd[i]); } sqlite3_free(zErrMsg); - free(azCmd); - return rc!=0 ? rc : 1; + if( rc==0 ) rc = 1; + goto shell_main_exit; } } } @@ -12824,6 +12825,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ expertFinish(&data, 1, 0); } #endif + shell_main_exit: free(azCmd); set_table_name(&data, 0); if( data.db ){ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8cca64836..ae8208842 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10832,6 +10832,8 @@ int sqlite3_deserialize( #if defined(__wasi__) # undef SQLITE_WASI # define SQLITE_WASI 1 +# undef SQLITE_OMIT_WAL +# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ # ifndef SQLITE_OMIT_LOAD_EXTENSION # define SQLITE_OMIT_LOAD_EXTENSION # endif diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f4f8fc5e4..7d313e408 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3460,7 +3460,7 @@ struct NameContext { #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */ #define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */ #define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */ -#define NC_Complex 0x002000 /* True if a function or subquery seen */ +/* 0x002000 // available for reuse */ #define NC_AllowWin 0x004000 /* Window functions are allowed here */ #define NC_HasWin 0x008000 /* One or more window functions seen */ #define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */ diff --git a/src/vdbe.c b/src/vdbe.c index 6bfcb0ee1..28f12e054 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -9015,14 +9015,29 @@ case OP_ReleaseReg: { /* Opcode: Noop * * * * * ** -** Do nothing. This instruction is often useful as a jump -** destination. +** Do nothing. Continue downward to the next opcode. */ -/* -** The magic Explain opcode are only inserted when explain==2 (which -** is to say when the EXPLAIN QUERY PLAN syntax is used.) -** This opcode records information from the optimizer. It is the -** the same as a no-op. This opcodesnever appears in a real VM program. +/* Opcode: Explain P1 P2 P3 P4 * +** +** This is the same as OP_Noop during normal query execution. The +** purpose of this opcode is to hold information about the query +** plan for the purpose of EXPLAIN QUERY PLAN output. +** +** The P4 value is human-readable text that describes the query plan +** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". +** +** The P1 value is the ID of the current element and P2 is the parent +** element for the case of nested query plan elements. If P2 is zero +** then this element is a top-level element. +** +** For loop elements, P3 is the estimated code of each invocation of this +** element. +** +** As with all opcodes, the meanings of the parameters for OP_Explain +** are subject to change from one release to the next. Applications +** should not attempt to interpret or use any of the information +** contined in the OP_Explain opcode. The information provided by this +** opcode is intended for testing and debugging use only. */ default: { /* This is really OP_Noop, OP_Explain */ assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain ); diff --git a/src/where.c b/src/where.c index 335d6a4e9..71a8241e3 100644 --- a/src/where.c +++ b/src/where.c @@ -5290,7 +5290,7 @@ static LogEst whereSortingCost( ** smaller tables. The central table is called the "fact" table. ** The smaller tables that get joined are "dimension tables". ** -** SIDE EFFECT: +** SIDE EFFECT: (and really the whole point of this subroutine) ** ** If pWInfo describes a star-query, then the cost on WhereLoops for the ** fact table is reduced. This heuristic helps keep fact tables in @@ -5302,7 +5302,7 @@ static LogEst whereSortingCost( */ static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){ int nLoop = pWInfo->nLevel; /* Number of terms in the join */ - if( nRowEst==0 && nLoop>=4 ){ + if( nRowEst==0 && nLoop>=5 ){ /* Check to see if we are dealing with a star schema and if so, reduce ** the cost of fact tables relative to dimension tables, as a heuristic ** to help keep the fact tables in outer loops. diff --git a/src/wherecode.c b/src/wherecode.c index 30624be8a..80fbbfac4 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -218,7 +218,8 @@ int sqlite3WhereExplainOneScan( zMsg = sqlite3StrAccumFinish(&str); sqlite3ExplainBreakpoint("",zMsg); ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v), - pParse->addrExplain, 0, zMsg,P4_DYNAMIC); + pParse->addrExplain, pLoop->rRun, + zMsg, P4_DYNAMIC); } return ret; } |