| | @@ -20,13 +20,10 @@ |
| 20 | 20 | #define SQLITE_CORE 1 |
| 21 | 21 | #define SQLITE_AMALGAMATION 1 |
| 22 | 22 | #ifndef SQLITE_PRIVATE |
| 23 | 23 | # define SQLITE_PRIVATE static |
| 24 | 24 | #endif |
| 25 | | -#ifndef SQLITE_API |
| 26 | | -# define SQLITE_API |
| 27 | | -#endif |
| 28 | 25 | /************** Begin file sqliteInt.h ***************************************/ |
| 29 | 26 | /* |
| 30 | 27 | ** 2001 September 15 |
| 31 | 28 | ** |
| 32 | 29 | ** The author disclaims copyright to this source code. In place of |
| | @@ -250,20 +247,24 @@ |
| 250 | 247 | extern "C" { |
| 251 | 248 | #endif |
| 252 | 249 | |
| 253 | 250 | |
| 254 | 251 | /* |
| 255 | | -** Add the ability to override 'extern' |
| 252 | +** Provide the ability to override linkage features of the interface. |
| 256 | 253 | */ |
| 257 | 254 | #ifndef SQLITE_EXTERN |
| 258 | 255 | # define SQLITE_EXTERN extern |
| 259 | 256 | #endif |
| 260 | | - |
| 261 | 257 | #ifndef SQLITE_API |
| 262 | 258 | # define SQLITE_API |
| 263 | 259 | #endif |
| 264 | | - |
| 260 | +#ifndef SQLITE_CDECL |
| 261 | +# define SQLITE_CDECL |
| 262 | +#endif |
| 263 | +#ifndef SQLITE_STDCALL |
| 264 | +# define SQLITE_STDCALL |
| 265 | +#endif |
| 265 | 266 | |
| 266 | 267 | /* |
| 267 | 268 | ** These no-op macros are used in front of interfaces to mark those |
| 268 | 269 | ** interfaces as either deprecated or experimental. New applications |
| 269 | 270 | ** should not use deprecated interfaces - they are supported for backwards |
| | @@ -316,11 +317,11 @@ |
| 316 | 317 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 317 | 318 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 318 | 319 | */ |
| 319 | 320 | #define SQLITE_VERSION "3.8.9" |
| 320 | 321 | #define SQLITE_VERSION_NUMBER 3008009 |
| 321 | | -#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45" |
| 322 | +#define SQLITE_SOURCE_ID "2015-03-30 23:43:56 395bb3e677a6551b06ba96fc58c393132b93d1e8" |
| 322 | 323 | |
| 323 | 324 | /* |
| 324 | 325 | ** CAPI3REF: Run-Time Library Version Numbers |
| 325 | 326 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 326 | 327 | ** |
| | @@ -349,13 +350,13 @@ |
| 349 | 350 | ** [SQLITE_SOURCE_ID] C preprocessor macro. |
| 350 | 351 | ** |
| 351 | 352 | ** See also: [sqlite_version()] and [sqlite_source_id()]. |
| 352 | 353 | */ |
| 353 | 354 | SQLITE_API const char sqlite3_version[] = SQLITE_VERSION; |
| 354 | | -SQLITE_API const char *sqlite3_libversion(void); |
| 355 | | -SQLITE_API const char *sqlite3_sourceid(void); |
| 356 | | -SQLITE_API int sqlite3_libversion_number(void); |
| 355 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void); |
| 356 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void); |
| 357 | +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void); |
| 357 | 358 | |
| 358 | 359 | /* |
| 359 | 360 | ** CAPI3REF: Run-Time Library Compilation Options Diagnostics |
| 360 | 361 | ** |
| 361 | 362 | ** ^The sqlite3_compileoption_used() function returns 0 or 1 |
| | @@ -376,12 +377,12 @@ |
| 376 | 377 | ** |
| 377 | 378 | ** See also: SQL functions [sqlite_compileoption_used()] and |
| 378 | 379 | ** [sqlite_compileoption_get()] and the [compile_options pragma]. |
| 379 | 380 | */ |
| 380 | 381 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| 381 | | -SQLITE_API int sqlite3_compileoption_used(const char *zOptName); |
| 382 | | -SQLITE_API const char *sqlite3_compileoption_get(int N); |
| 382 | +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName); |
| 383 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N); |
| 383 | 384 | #endif |
| 384 | 385 | |
| 385 | 386 | /* |
| 386 | 387 | ** CAPI3REF: Test To See If The Library Is Threadsafe |
| 387 | 388 | ** |
| | @@ -416,11 +417,11 @@ |
| 416 | 417 | ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() |
| 417 | 418 | ** is unchanged by calls to sqlite3_config().)^ |
| 418 | 419 | ** |
| 419 | 420 | ** See the [threading mode] documentation for additional information. |
| 420 | 421 | */ |
| 421 | | -SQLITE_API int sqlite3_threadsafe(void); |
| 422 | +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void); |
| 422 | 423 | |
| 423 | 424 | /* |
| 424 | 425 | ** CAPI3REF: Database Connection Handle |
| 425 | 426 | ** KEYWORDS: {database connection} {database connections} |
| 426 | 427 | ** |
| | @@ -512,12 +513,12 @@ |
| 512 | 513 | ** from [sqlite3_open()], [sqlite3_open16()], or |
| 513 | 514 | ** [sqlite3_open_v2()], and not previously closed. |
| 514 | 515 | ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer |
| 515 | 516 | ** argument is a harmless no-op. |
| 516 | 517 | */ |
| 517 | | -SQLITE_API int sqlite3_close(sqlite3*); |
| 518 | | -SQLITE_API int sqlite3_close_v2(sqlite3*); |
| 518 | +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*); |
| 519 | +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*); |
| 519 | 520 | |
| 520 | 521 | /* |
| 521 | 522 | ** The type for a callback function. |
| 522 | 523 | ** This is legacy and deprecated. It is included for historical |
| 523 | 524 | ** compatibility and is not documented. |
| | @@ -583,11 +584,11 @@ |
| 583 | 584 | ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. |
| 584 | 585 | ** <li> The application must not modify the SQL statement text passed into |
| 585 | 586 | ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. |
| 586 | 587 | ** </ul> |
| 587 | 588 | */ |
| 588 | | -SQLITE_API int sqlite3_exec( |
| 589 | +SQLITE_API int SQLITE_STDCALL sqlite3_exec( |
| 589 | 590 | sqlite3*, /* An open database */ |
| 590 | 591 | const char *sql, /* SQL to be evaluated */ |
| 591 | 592 | int (*callback)(void*,int,char**,char**), /* Callback function */ |
| 592 | 593 | void *, /* 1st argument to callback */ |
| 593 | 594 | char **errmsg /* Error msg written here */ |
| | @@ -1157,10 +1158,17 @@ |
| 1157 | 1158 | ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This |
| 1158 | 1159 | ** opcode causes the xFileControl method to swap the file handle with the one |
| 1159 | 1160 | ** pointed to by the pArg argument. This capability is used during testing |
| 1160 | 1161 | ** and only needs to be supported when SQLITE_TEST is defined. |
| 1161 | 1162 | ** |
| 1163 | +** <li>[[SQLITE_FCNTL_WAL_BLOCK]] |
| 1164 | +** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might |
| 1165 | +** be advantageous to block on the next WAL lock if the lock is not immediately |
| 1166 | +** available. The WAL subsystem issues this signal during rare |
| 1167 | +** circumstances in order to fix a problem with priority inversion. |
| 1168 | +** Applications should <em>not</em> use this file-control. |
| 1169 | +** |
| 1162 | 1170 | ** </ul> |
| 1163 | 1171 | */ |
| 1164 | 1172 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1165 | 1173 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| 1166 | 1174 | #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 |
| | @@ -1181,10 +1189,11 @@ |
| 1181 | 1189 | #define SQLITE_FCNTL_TRACE 19 |
| 1182 | 1190 | #define SQLITE_FCNTL_HAS_MOVED 20 |
| 1183 | 1191 | #define SQLITE_FCNTL_SYNC 21 |
| 1184 | 1192 | #define SQLITE_FCNTL_COMMIT_PHASETWO 22 |
| 1185 | 1193 | #define SQLITE_FCNTL_WIN32_SET_HANDLE 23 |
| 1194 | +#define SQLITE_FCNTL_WAL_BLOCK 24 |
| 1186 | 1195 | |
| 1187 | 1196 | /* deprecated names */ |
| 1188 | 1197 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 1189 | 1198 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 1190 | 1199 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -1535,14 +1544,14 @@ |
| 1535 | 1544 | ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied |
| 1536 | 1545 | ** implementation of sqlite3_os_init() or sqlite3_os_end() |
| 1537 | 1546 | ** must return [SQLITE_OK] on success and some other [error code] upon |
| 1538 | 1547 | ** failure. |
| 1539 | 1548 | */ |
| 1540 | | -SQLITE_API int sqlite3_initialize(void); |
| 1541 | | -SQLITE_API int sqlite3_shutdown(void); |
| 1542 | | -SQLITE_API int sqlite3_os_init(void); |
| 1543 | | -SQLITE_API int sqlite3_os_end(void); |
| 1549 | +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void); |
| 1550 | +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void); |
| 1551 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void); |
| 1552 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void); |
| 1544 | 1553 | |
| 1545 | 1554 | /* |
| 1546 | 1555 | ** CAPI3REF: Configuring The SQLite Library |
| 1547 | 1556 | ** |
| 1548 | 1557 | ** The sqlite3_config() interface is used to make global configuration |
| | @@ -1569,11 +1578,11 @@ |
| 1569 | 1578 | ** |
| 1570 | 1579 | ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. |
| 1571 | 1580 | ** ^If the option is unknown or SQLite is unable to set the option |
| 1572 | 1581 | ** then this routine returns a non-zero [error code]. |
| 1573 | 1582 | */ |
| 1574 | | -SQLITE_API int sqlite3_config(int, ...); |
| 1583 | +SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...); |
| 1575 | 1584 | |
| 1576 | 1585 | /* |
| 1577 | 1586 | ** CAPI3REF: Configure database connections |
| 1578 | 1587 | ** |
| 1579 | 1588 | ** The sqlite3_db_config() interface is used to make configuration |
| | @@ -1587,11 +1596,11 @@ |
| 1587 | 1596 | ** Subsequent arguments vary depending on the configuration verb. |
| 1588 | 1597 | ** |
| 1589 | 1598 | ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if |
| 1590 | 1599 | ** the call is considered successful. |
| 1591 | 1600 | */ |
| 1592 | | -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); |
| 1601 | +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...); |
| 1593 | 1602 | |
| 1594 | 1603 | /* |
| 1595 | 1604 | ** CAPI3REF: Memory Allocation Routines |
| 1596 | 1605 | ** |
| 1597 | 1606 | ** An instance of this object defines the interface between SQLite |
| | @@ -1747,11 +1756,11 @@ |
| 1747 | 1756 | ** disabled, the following SQLite interfaces become non-operational: |
| 1748 | 1757 | ** <ul> |
| 1749 | 1758 | ** <li> [sqlite3_memory_used()] |
| 1750 | 1759 | ** <li> [sqlite3_memory_highwater()] |
| 1751 | 1760 | ** <li> [sqlite3_soft_heap_limit64()] |
| 1752 | | -** <li> [sqlite3_status()] |
| 1761 | +** <li> [sqlite3_status64()] |
| 1753 | 1762 | ** </ul>)^ |
| 1754 | 1763 | ** ^Memory allocation statistics are enabled by default unless SQLite is |
| 1755 | 1764 | ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory |
| 1756 | 1765 | ** allocation statistics are disabled by default. |
| 1757 | 1766 | ** </dd> |
| | @@ -2075,11 +2084,11 @@ |
| 2075 | 2084 | ** |
| 2076 | 2085 | ** ^The sqlite3_extended_result_codes() routine enables or disables the |
| 2077 | 2086 | ** [extended result codes] feature of SQLite. ^The extended result |
| 2078 | 2087 | ** codes are disabled by default for historical compatibility. |
| 2079 | 2088 | */ |
| 2080 | | -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
| 2089 | +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff); |
| 2081 | 2090 | |
| 2082 | 2091 | /* |
| 2083 | 2092 | ** CAPI3REF: Last Insert Rowid |
| 2084 | 2093 | ** |
| 2085 | 2094 | ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) |
| | @@ -2126,11 +2135,11 @@ |
| 2126 | 2135 | ** function is running and thus changes the last insert [rowid], |
| 2127 | 2136 | ** then the value returned by [sqlite3_last_insert_rowid()] is |
| 2128 | 2137 | ** unpredictable and might not equal either the old or the new |
| 2129 | 2138 | ** last insert [rowid]. |
| 2130 | 2139 | */ |
| 2131 | | -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); |
| 2140 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*); |
| 2132 | 2141 | |
| 2133 | 2142 | /* |
| 2134 | 2143 | ** CAPI3REF: Count The Number Of Rows Modified |
| 2135 | 2144 | ** |
| 2136 | 2145 | ** ^This function returns the number of rows modified, inserted or |
| | @@ -2178,11 +2187,11 @@ |
| 2178 | 2187 | ** |
| 2179 | 2188 | ** If a separate thread makes changes on the same database connection |
| 2180 | 2189 | ** while [sqlite3_changes()] is running then the value returned |
| 2181 | 2190 | ** is unpredictable and not meaningful. |
| 2182 | 2191 | */ |
| 2183 | | -SQLITE_API int sqlite3_changes(sqlite3*); |
| 2192 | +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*); |
| 2184 | 2193 | |
| 2185 | 2194 | /* |
| 2186 | 2195 | ** CAPI3REF: Total Number Of Rows Modified |
| 2187 | 2196 | ** |
| 2188 | 2197 | ** ^This function returns the total number of rows inserted, modified or |
| | @@ -2201,11 +2210,11 @@ |
| 2201 | 2210 | ** |
| 2202 | 2211 | ** If a separate thread makes changes on the same database connection |
| 2203 | 2212 | ** while [sqlite3_total_changes()] is running then the value |
| 2204 | 2213 | ** returned is unpredictable and not meaningful. |
| 2205 | 2214 | */ |
| 2206 | | -SQLITE_API int sqlite3_total_changes(sqlite3*); |
| 2215 | +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*); |
| 2207 | 2216 | |
| 2208 | 2217 | /* |
| 2209 | 2218 | ** CAPI3REF: Interrupt A Long-Running Query |
| 2210 | 2219 | ** |
| 2211 | 2220 | ** ^This function causes any pending database operation to abort and |
| | @@ -2240,11 +2249,11 @@ |
| 2240 | 2249 | ** that are started after the sqlite3_interrupt() call returns. |
| 2241 | 2250 | ** |
| 2242 | 2251 | ** If the database connection closes while [sqlite3_interrupt()] |
| 2243 | 2252 | ** is running then bad things will likely happen. |
| 2244 | 2253 | */ |
| 2245 | | -SQLITE_API void sqlite3_interrupt(sqlite3*); |
| 2254 | +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*); |
| 2246 | 2255 | |
| 2247 | 2256 | /* |
| 2248 | 2257 | ** CAPI3REF: Determine If An SQL Statement Is Complete |
| 2249 | 2258 | ** |
| 2250 | 2259 | ** These routines are useful during command-line input to determine if the |
| | @@ -2275,12 +2284,12 @@ |
| 2275 | 2284 | ** UTF-8 string. |
| 2276 | 2285 | ** |
| 2277 | 2286 | ** The input to [sqlite3_complete16()] must be a zero-terminated |
| 2278 | 2287 | ** UTF-16 string in native byte order. |
| 2279 | 2288 | */ |
| 2280 | | -SQLITE_API int sqlite3_complete(const char *sql); |
| 2281 | | -SQLITE_API int sqlite3_complete16(const void *sql); |
| 2289 | +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql); |
| 2290 | +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql); |
| 2282 | 2291 | |
| 2283 | 2292 | /* |
| 2284 | 2293 | ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors |
| 2285 | 2294 | ** KEYWORDS: {busy-handler callback} {busy handler} |
| 2286 | 2295 | ** |
| | @@ -2336,11 +2345,11 @@ |
| 2336 | 2345 | ** result in undefined behavior. |
| 2337 | 2346 | ** |
| 2338 | 2347 | ** A busy handler must not close the database connection |
| 2339 | 2348 | ** or [prepared statement] that invoked the busy handler. |
| 2340 | 2349 | */ |
| 2341 | | -SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
| 2350 | +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
| 2342 | 2351 | |
| 2343 | 2352 | /* |
| 2344 | 2353 | ** CAPI3REF: Set A Busy Timeout |
| 2345 | 2354 | ** |
| 2346 | 2355 | ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps |
| | @@ -2358,11 +2367,11 @@ |
| 2358 | 2367 | ** was defined (using [sqlite3_busy_handler()]) prior to calling |
| 2359 | 2368 | ** this routine, that other busy handler is cleared.)^ |
| 2360 | 2369 | ** |
| 2361 | 2370 | ** See also: [PRAGMA busy_timeout] |
| 2362 | 2371 | */ |
| 2363 | | -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
| 2372 | +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms); |
| 2364 | 2373 | |
| 2365 | 2374 | /* |
| 2366 | 2375 | ** CAPI3REF: Convenience Routines For Running Queries |
| 2367 | 2376 | ** |
| 2368 | 2377 | ** This is a legacy interface that is preserved for backwards compatibility. |
| | @@ -2432,19 +2441,19 @@ |
| 2432 | 2441 | ** interface defined here. As a consequence, errors that occur in the |
| 2433 | 2442 | ** wrapper layer outside of the internal [sqlite3_exec()] call are not |
| 2434 | 2443 | ** reflected in subsequent calls to [sqlite3_errcode()] or |
| 2435 | 2444 | ** [sqlite3_errmsg()]. |
| 2436 | 2445 | */ |
| 2437 | | -SQLITE_API int sqlite3_get_table( |
| 2446 | +SQLITE_API int SQLITE_STDCALL sqlite3_get_table( |
| 2438 | 2447 | sqlite3 *db, /* An open database */ |
| 2439 | 2448 | const char *zSql, /* SQL to be evaluated */ |
| 2440 | 2449 | char ***pazResult, /* Results of the query */ |
| 2441 | 2450 | int *pnRow, /* Number of result rows written here */ |
| 2442 | 2451 | int *pnColumn, /* Number of result columns written here */ |
| 2443 | 2452 | char **pzErrmsg /* Error msg written here */ |
| 2444 | 2453 | ); |
| 2445 | | -SQLITE_API void sqlite3_free_table(char **result); |
| 2454 | +SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result); |
| 2446 | 2455 | |
| 2447 | 2456 | /* |
| 2448 | 2457 | ** CAPI3REF: Formatted String Printing Functions |
| 2449 | 2458 | ** |
| 2450 | 2459 | ** These routines are work-alikes of the "printf()" family of functions |
| | @@ -2546,14 +2555,14 @@ |
| 2546 | 2555 | ** |
| 2547 | 2556 | ** ^(The "%z" formatting option works like "%s" but with the |
| 2548 | 2557 | ** addition that after the string has been read and copied into |
| 2549 | 2558 | ** the result, [sqlite3_free()] is called on the input string.)^ |
| 2550 | 2559 | */ |
| 2551 | | -SQLITE_API char *sqlite3_mprintf(const char*,...); |
| 2552 | | -SQLITE_API char *sqlite3_vmprintf(const char*, va_list); |
| 2553 | | -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); |
| 2554 | | -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); |
| 2560 | +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...); |
| 2561 | +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list); |
| 2562 | +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...); |
| 2563 | +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list); |
| 2555 | 2564 | |
| 2556 | 2565 | /* |
| 2557 | 2566 | ** CAPI3REF: Memory Allocation Subsystem |
| 2558 | 2567 | ** |
| 2559 | 2568 | ** The SQLite core uses these three routines for all of its own |
| | @@ -2639,16 +2648,16 @@ |
| 2639 | 2648 | ** |
| 2640 | 2649 | ** The application must not read or write any part of |
| 2641 | 2650 | ** a block of memory after it has been released using |
| 2642 | 2651 | ** [sqlite3_free()] or [sqlite3_realloc()]. |
| 2643 | 2652 | */ |
| 2644 | | -SQLITE_API void *sqlite3_malloc(int); |
| 2645 | | -SQLITE_API void *sqlite3_malloc64(sqlite3_uint64); |
| 2646 | | -SQLITE_API void *sqlite3_realloc(void*, int); |
| 2647 | | -SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64); |
| 2648 | | -SQLITE_API void sqlite3_free(void*); |
| 2649 | | -SQLITE_API sqlite3_uint64 sqlite3_msize(void*); |
| 2653 | +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int); |
| 2654 | +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64); |
| 2655 | +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int); |
| 2656 | +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64); |
| 2657 | +SQLITE_API void SQLITE_STDCALL sqlite3_free(void*); |
| 2658 | +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*); |
| 2650 | 2659 | |
| 2651 | 2660 | /* |
| 2652 | 2661 | ** CAPI3REF: Memory Allocator Statistics |
| 2653 | 2662 | ** |
| 2654 | 2663 | ** SQLite provides these two interfaces for reporting on the status |
| | @@ -2669,12 +2678,12 @@ |
| 2669 | 2678 | ** [sqlite3_memory_used()] if and only if the parameter to |
| 2670 | 2679 | ** [sqlite3_memory_highwater()] is true. ^The value returned |
| 2671 | 2680 | ** by [sqlite3_memory_highwater(1)] is the high-water mark |
| 2672 | 2681 | ** prior to the reset. |
| 2673 | 2682 | */ |
| 2674 | | -SQLITE_API sqlite3_int64 sqlite3_memory_used(void); |
| 2675 | | -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); |
| 2683 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void); |
| 2684 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag); |
| 2676 | 2685 | |
| 2677 | 2686 | /* |
| 2678 | 2687 | ** CAPI3REF: Pseudo-Random Number Generator |
| 2679 | 2688 | ** |
| 2680 | 2689 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| | @@ -2693,11 +2702,11 @@ |
| 2693 | 2702 | ** ^If the previous call to this routine had an N of 1 or more and a |
| 2694 | 2703 | ** non-NULL P then the pseudo-randomness is generated |
| 2695 | 2704 | ** internally and without recourse to the [sqlite3_vfs] xRandomness |
| 2696 | 2705 | ** method. |
| 2697 | 2706 | */ |
| 2698 | | -SQLITE_API void sqlite3_randomness(int N, void *P); |
| 2707 | +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P); |
| 2699 | 2708 | |
| 2700 | 2709 | /* |
| 2701 | 2710 | ** CAPI3REF: Compile-Time Authorization Callbacks |
| 2702 | 2711 | ** |
| 2703 | 2712 | ** ^This routine registers an authorizer callback with a particular |
| | @@ -2775,11 +2784,11 @@ |
| 2775 | 2784 | ** [sqlite3_prepare()] or its variants. Authorization is not |
| 2776 | 2785 | ** performed during statement evaluation in [sqlite3_step()], unless |
| 2777 | 2786 | ** as stated in the previous paragraph, sqlite3_step() invokes |
| 2778 | 2787 | ** sqlite3_prepare_v2() to reprepare a statement after a schema change. |
| 2779 | 2788 | */ |
| 2780 | | -SQLITE_API int sqlite3_set_authorizer( |
| 2789 | +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer( |
| 2781 | 2790 | sqlite3*, |
| 2782 | 2791 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
| 2783 | 2792 | void *pUserData |
| 2784 | 2793 | ); |
| 2785 | 2794 | |
| | @@ -2879,12 +2888,12 @@ |
| 2879 | 2888 | ** digits in the time are meaningless. Future versions of SQLite |
| 2880 | 2889 | ** might provide greater resolution on the profiler callback. The |
| 2881 | 2890 | ** sqlite3_profile() function is considered experimental and is |
| 2882 | 2891 | ** subject to change in future versions of SQLite. |
| 2883 | 2892 | */ |
| 2884 | | -SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 2885 | | -SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
| 2893 | +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 2894 | +SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*, |
| 2886 | 2895 | void(*xProfile)(void*,const char*,sqlite3_uint64), void*); |
| 2887 | 2896 | |
| 2888 | 2897 | /* |
| 2889 | 2898 | ** CAPI3REF: Query Progress Callbacks |
| 2890 | 2899 | ** |
| | @@ -2914,11 +2923,11 @@ |
| 2914 | 2923 | ** the database connection that invoked the progress handler. |
| 2915 | 2924 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 2916 | 2925 | ** database connections for the meaning of "modify" in this paragraph. |
| 2917 | 2926 | ** |
| 2918 | 2927 | */ |
| 2919 | | -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
| 2928 | +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
| 2920 | 2929 | |
| 2921 | 2930 | /* |
| 2922 | 2931 | ** CAPI3REF: Opening A New Database Connection |
| 2923 | 2932 | ** |
| 2924 | 2933 | ** ^These routines open an SQLite database file as specified by the |
| | @@ -3142,19 +3151,19 @@ |
| 3142 | 3151 | ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various |
| 3143 | 3152 | ** features that require the use of temporary files may fail. |
| 3144 | 3153 | ** |
| 3145 | 3154 | ** See also: [sqlite3_temp_directory] |
| 3146 | 3155 | */ |
| 3147 | | -SQLITE_API int sqlite3_open( |
| 3156 | +SQLITE_API int SQLITE_STDCALL sqlite3_open( |
| 3148 | 3157 | const char *filename, /* Database filename (UTF-8) */ |
| 3149 | 3158 | sqlite3 **ppDb /* OUT: SQLite db handle */ |
| 3150 | 3159 | ); |
| 3151 | | -SQLITE_API int sqlite3_open16( |
| 3160 | +SQLITE_API int SQLITE_STDCALL sqlite3_open16( |
| 3152 | 3161 | const void *filename, /* Database filename (UTF-16) */ |
| 3153 | 3162 | sqlite3 **ppDb /* OUT: SQLite db handle */ |
| 3154 | 3163 | ); |
| 3155 | | -SQLITE_API int sqlite3_open_v2( |
| 3164 | +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2( |
| 3156 | 3165 | const char *filename, /* Database filename (UTF-8) */ |
| 3157 | 3166 | sqlite3 **ppDb, /* OUT: SQLite db handle */ |
| 3158 | 3167 | int flags, /* Flags */ |
| 3159 | 3168 | const char *zVfs /* Name of VFS module to use */ |
| 3160 | 3169 | ); |
| | @@ -3196,23 +3205,25 @@ |
| 3196 | 3205 | ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and |
| 3197 | 3206 | ** is not a database file pathname pointer that SQLite passed into the xOpen |
| 3198 | 3207 | ** VFS method, then the behavior of this routine is undefined and probably |
| 3199 | 3208 | ** undesirable. |
| 3200 | 3209 | */ |
| 3201 | | -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); |
| 3202 | | -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); |
| 3203 | | -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); |
| 3210 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam); |
| 3211 | +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); |
| 3212 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64); |
| 3204 | 3213 | |
| 3205 | 3214 | |
| 3206 | 3215 | /* |
| 3207 | 3216 | ** CAPI3REF: Error Codes And Messages |
| 3208 | 3217 | ** |
| 3209 | | -** ^The sqlite3_errcode() interface returns the numeric [result code] or |
| 3210 | | -** [extended result code] for the most recent failed sqlite3_* API call |
| 3211 | | -** associated with a [database connection]. If a prior API call failed |
| 3212 | | -** but the most recent API call succeeded, the return value from |
| 3213 | | -** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() |
| 3218 | +** ^If the most recent sqlite3_* API call associated with |
| 3219 | +** [database connection] D failed, then the sqlite3_errcode(D) interface |
| 3220 | +** returns the numeric [result code] or [extended result code] for that |
| 3221 | +** API call. |
| 3222 | +** If the most recent API call was successful, |
| 3223 | +** then the return value from sqlite3_errcode() is undefined. |
| 3224 | +** ^The sqlite3_extended_errcode() |
| 3214 | 3225 | ** interface is the same except that it always returns the |
| 3215 | 3226 | ** [extended result code] even when extended result codes are |
| 3216 | 3227 | ** disabled. |
| 3217 | 3228 | ** |
| 3218 | 3229 | ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language |
| | @@ -3239,15 +3250,15 @@ |
| 3239 | 3250 | ** |
| 3240 | 3251 | ** If an interface fails with SQLITE_MISUSE, that means the interface |
| 3241 | 3252 | ** was invoked incorrectly by the application. In that case, the |
| 3242 | 3253 | ** error code and message may or may not be set. |
| 3243 | 3254 | */ |
| 3244 | | -SQLITE_API int sqlite3_errcode(sqlite3 *db); |
| 3245 | | -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); |
| 3246 | | -SQLITE_API const char *sqlite3_errmsg(sqlite3*); |
| 3247 | | -SQLITE_API const void *sqlite3_errmsg16(sqlite3*); |
| 3248 | | -SQLITE_API const char *sqlite3_errstr(int); |
| 3255 | +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db); |
| 3256 | +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db); |
| 3257 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*); |
| 3258 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*); |
| 3259 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int); |
| 3249 | 3260 | |
| 3250 | 3261 | /* |
| 3251 | 3262 | ** CAPI3REF: SQL Statement Object |
| 3252 | 3263 | ** KEYWORDS: {prepared statement} {prepared statements} |
| 3253 | 3264 | ** |
| | @@ -3310,11 +3321,11 @@ |
| 3310 | 3321 | ** created by an untrusted script can be contained using the |
| 3311 | 3322 | ** [max_page_count] [PRAGMA]. |
| 3312 | 3323 | ** |
| 3313 | 3324 | ** New run-time limit categories may be added in future releases. |
| 3314 | 3325 | */ |
| 3315 | | -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
| 3326 | +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal); |
| 3316 | 3327 | |
| 3317 | 3328 | /* |
| 3318 | 3329 | ** CAPI3REF: Run-Time Limit Categories |
| 3319 | 3330 | ** KEYWORDS: {limit category} {*limit categories} |
| 3320 | 3331 | ** |
| | @@ -3460,32 +3471,32 @@ |
| 3460 | 3471 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 3461 | 3472 | ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. |
| 3462 | 3473 | ** </li> |
| 3463 | 3474 | ** </ol> |
| 3464 | 3475 | */ |
| 3465 | | -SQLITE_API int sqlite3_prepare( |
| 3476 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare( |
| 3466 | 3477 | sqlite3 *db, /* Database handle */ |
| 3467 | 3478 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 3468 | 3479 | int nByte, /* Maximum length of zSql in bytes. */ |
| 3469 | 3480 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 3470 | 3481 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 3471 | 3482 | ); |
| 3472 | | -SQLITE_API int sqlite3_prepare_v2( |
| 3483 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2( |
| 3473 | 3484 | sqlite3 *db, /* Database handle */ |
| 3474 | 3485 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 3475 | 3486 | int nByte, /* Maximum length of zSql in bytes. */ |
| 3476 | 3487 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 3477 | 3488 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 3478 | 3489 | ); |
| 3479 | | -SQLITE_API int sqlite3_prepare16( |
| 3490 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16( |
| 3480 | 3491 | sqlite3 *db, /* Database handle */ |
| 3481 | 3492 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 3482 | 3493 | int nByte, /* Maximum length of zSql in bytes. */ |
| 3483 | 3494 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 3484 | 3495 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 3485 | 3496 | ); |
| 3486 | | -SQLITE_API int sqlite3_prepare16_v2( |
| 3497 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2( |
| 3487 | 3498 | sqlite3 *db, /* Database handle */ |
| 3488 | 3499 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 3489 | 3500 | int nByte, /* Maximum length of zSql in bytes. */ |
| 3490 | 3501 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 3491 | 3502 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| | @@ -3496,11 +3507,11 @@ |
| 3496 | 3507 | ** |
| 3497 | 3508 | ** ^This interface can be used to retrieve a saved copy of the original |
| 3498 | 3509 | ** SQL text used to create a [prepared statement] if that statement was |
| 3499 | 3510 | ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. |
| 3500 | 3511 | */ |
| 3501 | | -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3512 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt); |
| 3502 | 3513 | |
| 3503 | 3514 | /* |
| 3504 | 3515 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3505 | 3516 | ** |
| 3506 | 3517 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| | @@ -3527,11 +3538,11 @@ |
| 3527 | 3538 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 3528 | 3539 | ** sqlite3_stmt_readonly() to return true since, while those statements |
| 3529 | 3540 | ** change the configuration of a database connection, they do not make |
| 3530 | 3541 | ** changes to the content of the database files on disk. |
| 3531 | 3542 | */ |
| 3532 | | -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3543 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3533 | 3544 | |
| 3534 | 3545 | /* |
| 3535 | 3546 | ** CAPI3REF: Determine If A Prepared Statement Has Been Reset |
| 3536 | 3547 | ** |
| 3537 | 3548 | ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the |
| | @@ -3546,11 +3557,11 @@ |
| 3546 | 3557 | ** to locate all prepared statements associated with a database |
| 3547 | 3558 | ** connection that are in need of being reset. This can be used, |
| 3548 | 3559 | ** for example, in diagnostic routines to search for prepared |
| 3549 | 3560 | ** statements that are holding a transaction open. |
| 3550 | 3561 | */ |
| 3551 | | -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); |
| 3562 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*); |
| 3552 | 3563 | |
| 3553 | 3564 | /* |
| 3554 | 3565 | ** CAPI3REF: Dynamically Typed Value Object |
| 3555 | 3566 | ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} |
| 3556 | 3567 | ** |
| | @@ -3707,23 +3718,23 @@ |
| 3707 | 3718 | ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. |
| 3708 | 3719 | ** |
| 3709 | 3720 | ** See also: [sqlite3_bind_parameter_count()], |
| 3710 | 3721 | ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. |
| 3711 | 3722 | */ |
| 3712 | | -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); |
| 3713 | | -SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, |
| 3723 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); |
| 3724 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, |
| 3714 | 3725 | void(*)(void*)); |
| 3715 | | -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); |
| 3716 | | -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); |
| 3717 | | -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); |
| 3718 | | -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); |
| 3719 | | -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 3720 | | -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3721 | | -SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 3726 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double); |
| 3727 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int); |
| 3728 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); |
| 3729 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int); |
| 3730 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
| 3731 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3732 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
| 3722 | 3733 | void(*)(void*), unsigned char encoding); |
| 3723 | | -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3724 | | -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3734 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3735 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3725 | 3736 | |
| 3726 | 3737 | /* |
| 3727 | 3738 | ** CAPI3REF: Number Of SQL Parameters |
| 3728 | 3739 | ** |
| 3729 | 3740 | ** ^This routine can be used to find the number of [SQL parameters] |
| | @@ -3739,11 +3750,11 @@ |
| 3739 | 3750 | ** |
| 3740 | 3751 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3741 | 3752 | ** [sqlite3_bind_parameter_name()], and |
| 3742 | 3753 | ** [sqlite3_bind_parameter_index()]. |
| 3743 | 3754 | */ |
| 3744 | | -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); |
| 3755 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*); |
| 3745 | 3756 | |
| 3746 | 3757 | /* |
| 3747 | 3758 | ** CAPI3REF: Name Of A Host Parameter |
| 3748 | 3759 | ** |
| 3749 | 3760 | ** ^The sqlite3_bind_parameter_name(P,N) interface returns |
| | @@ -3766,11 +3777,11 @@ |
| 3766 | 3777 | ** |
| 3767 | 3778 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3768 | 3779 | ** [sqlite3_bind_parameter_count()], and |
| 3769 | 3780 | ** [sqlite3_bind_parameter_index()]. |
| 3770 | 3781 | */ |
| 3771 | | -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); |
| 3782 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int); |
| 3772 | 3783 | |
| 3773 | 3784 | /* |
| 3774 | 3785 | ** CAPI3REF: Index Of A Parameter With A Given Name |
| 3775 | 3786 | ** |
| 3776 | 3787 | ** ^Return the index of an SQL parameter given its name. ^The |
| | @@ -3782,20 +3793,20 @@ |
| 3782 | 3793 | ** |
| 3783 | 3794 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3784 | 3795 | ** [sqlite3_bind_parameter_count()], and |
| 3785 | 3796 | ** [sqlite3_bind_parameter_index()]. |
| 3786 | 3797 | */ |
| 3787 | | -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); |
| 3798 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); |
| 3788 | 3799 | |
| 3789 | 3800 | /* |
| 3790 | 3801 | ** CAPI3REF: Reset All Bindings On A Prepared Statement |
| 3791 | 3802 | ** |
| 3792 | 3803 | ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset |
| 3793 | 3804 | ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. |
| 3794 | 3805 | ** ^Use this routine to reset all host parameters to NULL. |
| 3795 | 3806 | */ |
| 3796 | | -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); |
| 3807 | +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*); |
| 3797 | 3808 | |
| 3798 | 3809 | /* |
| 3799 | 3810 | ** CAPI3REF: Number Of Columns In A Result Set |
| 3800 | 3811 | ** |
| 3801 | 3812 | ** ^Return the number of columns in the result set returned by the |
| | @@ -3802,11 +3813,11 @@ |
| 3802 | 3813 | ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL |
| 3803 | 3814 | ** statement that does not return data (for example an [UPDATE]). |
| 3804 | 3815 | ** |
| 3805 | 3816 | ** See also: [sqlite3_data_count()] |
| 3806 | 3817 | */ |
| 3807 | | -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); |
| 3818 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt); |
| 3808 | 3819 | |
| 3809 | 3820 | /* |
| 3810 | 3821 | ** CAPI3REF: Column Names In A Result Set |
| 3811 | 3822 | ** |
| 3812 | 3823 | ** ^These routines return the name assigned to a particular column |
| | @@ -3830,12 +3841,12 @@ |
| 3830 | 3841 | ** ^The name of a result column is the value of the "AS" clause for |
| 3831 | 3842 | ** that column, if there is an AS clause. If there is no AS clause |
| 3832 | 3843 | ** then the name of the column is unspecified and may change from |
| 3833 | 3844 | ** one release of SQLite to the next. |
| 3834 | 3845 | */ |
| 3835 | | -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); |
| 3836 | | -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); |
| 3846 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N); |
| 3847 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N); |
| 3837 | 3848 | |
| 3838 | 3849 | /* |
| 3839 | 3850 | ** CAPI3REF: Source Of Data In A Query Result |
| 3840 | 3851 | ** |
| 3841 | 3852 | ** ^These routines provide a means to determine the database, table, and |
| | @@ -3878,16 +3889,16 @@ |
| 3878 | 3889 | ** If two or more threads call one or more |
| 3879 | 3890 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 3880 | 3891 | ** for the same [prepared statement] and result column |
| 3881 | 3892 | ** at the same time then the results are undefined. |
| 3882 | 3893 | */ |
| 3883 | | -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); |
| 3884 | | -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); |
| 3885 | | -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); |
| 3886 | | -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); |
| 3887 | | -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); |
| 3888 | | -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); |
| 3894 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int); |
| 3895 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int); |
| 3896 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int); |
| 3897 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int); |
| 3898 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int); |
| 3899 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int); |
| 3889 | 3900 | |
| 3890 | 3901 | /* |
| 3891 | 3902 | ** CAPI3REF: Declared Datatype Of A Query Result |
| 3892 | 3903 | ** |
| 3893 | 3904 | ** ^(The first parameter is a [prepared statement]. |
| | @@ -3914,12 +3925,12 @@ |
| 3914 | 3925 | ** data stored in that column is of the declared type. SQLite is |
| 3915 | 3926 | ** strongly typed, but the typing is dynamic not static. ^Type |
| 3916 | 3927 | ** is associated with individual values, not with the containers |
| 3917 | 3928 | ** used to hold those values. |
| 3918 | 3929 | */ |
| 3919 | | -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); |
| 3920 | | -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); |
| 3930 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int); |
| 3931 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int); |
| 3921 | 3932 | |
| 3922 | 3933 | /* |
| 3923 | 3934 | ** CAPI3REF: Evaluate An SQL Statement |
| 3924 | 3935 | ** |
| 3925 | 3936 | ** After a [prepared statement] has been prepared using either |
| | @@ -3994,11 +4005,11 @@ |
| 3994 | 4005 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead |
| 3995 | 4006 | ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, |
| 3996 | 4007 | ** then the more specific [error codes] are returned directly |
| 3997 | 4008 | ** by sqlite3_step(). The use of the "v2" interface is recommended. |
| 3998 | 4009 | */ |
| 3999 | | -SQLITE_API int sqlite3_step(sqlite3_stmt*); |
| 4010 | +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*); |
| 4000 | 4011 | |
| 4001 | 4012 | /* |
| 4002 | 4013 | ** CAPI3REF: Number of columns in a result set |
| 4003 | 4014 | ** |
| 4004 | 4015 | ** ^The sqlite3_data_count(P) interface returns the number of columns in the |
| | @@ -4014,11 +4025,11 @@ |
| 4014 | 4025 | ** where it always returns zero since each step of that multi-step |
| 4015 | 4026 | ** pragma returns 0 columns of data. |
| 4016 | 4027 | ** |
| 4017 | 4028 | ** See also: [sqlite3_column_count()] |
| 4018 | 4029 | */ |
| 4019 | | -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 4030 | +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt); |
| 4020 | 4031 | |
| 4021 | 4032 | /* |
| 4022 | 4033 | ** CAPI3REF: Fundamental Datatypes |
| 4023 | 4034 | ** KEYWORDS: SQLITE_TEXT |
| 4024 | 4035 | ** |
| | @@ -4210,20 +4221,20 @@ |
| 4210 | 4221 | ** of these routines, a default value is returned. The default value |
| 4211 | 4222 | ** is either the integer 0, the floating point number 0.0, or a NULL |
| 4212 | 4223 | ** pointer. Subsequent calls to [sqlite3_errcode()] will return |
| 4213 | 4224 | ** [SQLITE_NOMEM].)^ |
| 4214 | 4225 | */ |
| 4215 | | -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); |
| 4216 | | -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); |
| 4217 | | -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); |
| 4218 | | -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); |
| 4219 | | -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); |
| 4220 | | -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); |
| 4221 | | -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); |
| 4222 | | -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); |
| 4223 | | -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); |
| 4224 | | -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); |
| 4226 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol); |
| 4227 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol); |
| 4228 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol); |
| 4229 | +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol); |
| 4230 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol); |
| 4231 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol); |
| 4232 | +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol); |
| 4233 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol); |
| 4234 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol); |
| 4235 | +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol); |
| 4225 | 4236 | |
| 4226 | 4237 | /* |
| 4227 | 4238 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 4228 | 4239 | ** |
| 4229 | 4240 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| | @@ -4246,11 +4257,11 @@ |
| 4246 | 4257 | ** resource leaks. It is a grievous error for the application to try to use |
| 4247 | 4258 | ** a prepared statement after it has been finalized. Any use of a prepared |
| 4248 | 4259 | ** statement after it has been finalized can result in undefined and |
| 4249 | 4260 | ** undesirable behavior such as segfaults and heap corruption. |
| 4250 | 4261 | */ |
| 4251 | | -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); |
| 4262 | +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt); |
| 4252 | 4263 | |
| 4253 | 4264 | /* |
| 4254 | 4265 | ** CAPI3REF: Reset A Prepared Statement Object |
| 4255 | 4266 | ** |
| 4256 | 4267 | ** The sqlite3_reset() function is called to reset a [prepared statement] |
| | @@ -4272,11 +4283,11 @@ |
| 4272 | 4283 | ** [sqlite3_reset(S)] returns an appropriate [error code]. |
| 4273 | 4284 | ** |
| 4274 | 4285 | ** ^The [sqlite3_reset(S)] interface does not change the values |
| 4275 | 4286 | ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. |
| 4276 | 4287 | */ |
| 4277 | | -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 4288 | +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt); |
| 4278 | 4289 | |
| 4279 | 4290 | /* |
| 4280 | 4291 | ** CAPI3REF: Create Or Redefine SQL Functions |
| 4281 | 4292 | ** KEYWORDS: {function creation routines} |
| 4282 | 4293 | ** KEYWORDS: {application-defined SQL function} |
| | @@ -4371,31 +4382,31 @@ |
| 4371 | 4382 | ** ^An application-defined function is permitted to call other |
| 4372 | 4383 | ** SQLite interfaces. However, such calls must not |
| 4373 | 4384 | ** close the database connection nor finalize or reset the prepared |
| 4374 | 4385 | ** statement in which the function is running. |
| 4375 | 4386 | */ |
| 4376 | | -SQLITE_API int sqlite3_create_function( |
| 4387 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function( |
| 4377 | 4388 | sqlite3 *db, |
| 4378 | 4389 | const char *zFunctionName, |
| 4379 | 4390 | int nArg, |
| 4380 | 4391 | int eTextRep, |
| 4381 | 4392 | void *pApp, |
| 4382 | 4393 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), |
| 4383 | 4394 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), |
| 4384 | 4395 | void (*xFinal)(sqlite3_context*) |
| 4385 | 4396 | ); |
| 4386 | | -SQLITE_API int sqlite3_create_function16( |
| 4397 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16( |
| 4387 | 4398 | sqlite3 *db, |
| 4388 | 4399 | const void *zFunctionName, |
| 4389 | 4400 | int nArg, |
| 4390 | 4401 | int eTextRep, |
| 4391 | 4402 | void *pApp, |
| 4392 | 4403 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), |
| 4393 | 4404 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), |
| 4394 | 4405 | void (*xFinal)(sqlite3_context*) |
| 4395 | 4406 | ); |
| 4396 | | -SQLITE_API int sqlite3_create_function_v2( |
| 4407 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2( |
| 4397 | 4408 | sqlite3 *db, |
| 4398 | 4409 | const char *zFunctionName, |
| 4399 | 4410 | int nArg, |
| 4400 | 4411 | int eTextRep, |
| 4401 | 4412 | void *pApp, |
| | @@ -4437,16 +4448,16 @@ |
| 4437 | 4448 | ** to be supported. However, new applications should avoid |
| 4438 | 4449 | ** the use of these functions. To encourage programmers to avoid |
| 4439 | 4450 | ** these functions, we will not explain what they do. |
| 4440 | 4451 | */ |
| 4441 | 4452 | #ifndef SQLITE_OMIT_DEPRECATED |
| 4442 | | -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 4443 | | -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 4444 | | -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 4445 | | -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4446 | | -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4447 | | -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
| 4453 | +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*); |
| 4454 | +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*); |
| 4455 | +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| 4456 | +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void); |
| 4457 | +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void); |
| 4458 | +SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
| 4448 | 4459 | void*,sqlite3_int64); |
| 4449 | 4460 | #endif |
| 4450 | 4461 | |
| 4451 | 4462 | /* |
| 4452 | 4463 | ** CAPI3REF: Obtaining SQL Function Parameter Values |
| | @@ -4491,22 +4502,22 @@ |
| 4491 | 4502 | ** or [sqlite3_value_text16()]. |
| 4492 | 4503 | ** |
| 4493 | 4504 | ** These routines must be called from the same thread as |
| 4494 | 4505 | ** the SQL function that supplied the [sqlite3_value*] parameters. |
| 4495 | 4506 | */ |
| 4496 | | -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); |
| 4497 | | -SQLITE_API int sqlite3_value_bytes(sqlite3_value*); |
| 4498 | | -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); |
| 4499 | | -SQLITE_API double sqlite3_value_double(sqlite3_value*); |
| 4500 | | -SQLITE_API int sqlite3_value_int(sqlite3_value*); |
| 4501 | | -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); |
| 4502 | | -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); |
| 4503 | | -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); |
| 4504 | | -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); |
| 4505 | | -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); |
| 4506 | | -SQLITE_API int sqlite3_value_type(sqlite3_value*); |
| 4507 | | -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); |
| 4507 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*); |
| 4508 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*); |
| 4509 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*); |
| 4510 | +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*); |
| 4511 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*); |
| 4512 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*); |
| 4513 | +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*); |
| 4514 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*); |
| 4515 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*); |
| 4516 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*); |
| 4517 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*); |
| 4518 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*); |
| 4508 | 4519 | |
| 4509 | 4520 | /* |
| 4510 | 4521 | ** CAPI3REF: Obtain Aggregate Function Context |
| 4511 | 4522 | ** |
| 4512 | 4523 | ** Implementations of aggregate SQL functions use this |
| | @@ -4546,11 +4557,11 @@ |
| 4546 | 4557 | ** function. |
| 4547 | 4558 | ** |
| 4548 | 4559 | ** This routine must be called from the same thread in which |
| 4549 | 4560 | ** the aggregate SQL function is running. |
| 4550 | 4561 | */ |
| 4551 | | -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); |
| 4562 | +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes); |
| 4552 | 4563 | |
| 4553 | 4564 | /* |
| 4554 | 4565 | ** CAPI3REF: User Data For Functions |
| 4555 | 4566 | ** |
| 4556 | 4567 | ** ^The sqlite3_user_data() interface returns a copy of |
| | @@ -4560,11 +4571,11 @@ |
| 4560 | 4571 | ** registered the application defined function. |
| 4561 | 4572 | ** |
| 4562 | 4573 | ** This routine must be called from the same thread in which |
| 4563 | 4574 | ** the application-defined function is running. |
| 4564 | 4575 | */ |
| 4565 | | -SQLITE_API void *sqlite3_user_data(sqlite3_context*); |
| 4576 | +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*); |
| 4566 | 4577 | |
| 4567 | 4578 | /* |
| 4568 | 4579 | ** CAPI3REF: Database Connection For Functions |
| 4569 | 4580 | ** |
| 4570 | 4581 | ** ^The sqlite3_context_db_handle() interface returns a copy of |
| | @@ -4571,11 +4582,11 @@ |
| 4571 | 4582 | ** the pointer to the [database connection] (the 1st parameter) |
| 4572 | 4583 | ** of the [sqlite3_create_function()] |
| 4573 | 4584 | ** and [sqlite3_create_function16()] routines that originally |
| 4574 | 4585 | ** registered the application defined function. |
| 4575 | 4586 | */ |
| 4576 | | -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); |
| 4587 | +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*); |
| 4577 | 4588 | |
| 4578 | 4589 | /* |
| 4579 | 4590 | ** CAPI3REF: Function Auxiliary Data |
| 4580 | 4591 | ** |
| 4581 | 4592 | ** These functions may be used by (non-aggregate) SQL functions to |
| | @@ -4623,12 +4634,12 @@ |
| 4623 | 4634 | ** values and [parameters] and expressions composed from the same.)^ |
| 4624 | 4635 | ** |
| 4625 | 4636 | ** These routines must be called from the same thread in which |
| 4626 | 4637 | ** the SQL function is running. |
| 4627 | 4638 | */ |
| 4628 | | -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 4629 | | -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 4639 | +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N); |
| 4640 | +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 4630 | 4641 | |
| 4631 | 4642 | |
| 4632 | 4643 | /* |
| 4633 | 4644 | ** CAPI3REF: Constants Defining Special Destructor Behavior |
| 4634 | 4645 | ** |
| | @@ -4759,30 +4770,30 @@ |
| 4759 | 4770 | ** |
| 4760 | 4771 | ** If these routines are called from within the different thread |
| 4761 | 4772 | ** than the one containing the application-defined function that received |
| 4762 | 4773 | ** the [sqlite3_context] pointer, the results are undefined. |
| 4763 | 4774 | */ |
| 4764 | | -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
| 4765 | | -SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, |
| 4775 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
| 4776 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*, |
| 4766 | 4777 | sqlite3_uint64,void(*)(void*)); |
| 4767 | | -SQLITE_API void sqlite3_result_double(sqlite3_context*, double); |
| 4768 | | -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); |
| 4769 | | -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); |
| 4770 | | -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); |
| 4771 | | -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); |
| 4772 | | -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); |
| 4773 | | -SQLITE_API void sqlite3_result_int(sqlite3_context*, int); |
| 4774 | | -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); |
| 4775 | | -SQLITE_API void sqlite3_result_null(sqlite3_context*); |
| 4776 | | -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); |
| 4777 | | -SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, |
| 4778 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double); |
| 4779 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int); |
| 4780 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int); |
| 4781 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*); |
| 4782 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*); |
| 4783 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int); |
| 4784 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int); |
| 4785 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64); |
| 4786 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*); |
| 4787 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); |
| 4788 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, |
| 4778 | 4789 | void(*)(void*), unsigned char encoding); |
| 4779 | | -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 4780 | | -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4781 | | -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4782 | | -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 4783 | | -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 4790 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
| 4791 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4792 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4793 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 4794 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 4784 | 4795 | |
| 4785 | 4796 | /* |
| 4786 | 4797 | ** CAPI3REF: Define New Collating Sequences |
| 4787 | 4798 | ** |
| 4788 | 4799 | ** ^These functions add, remove, or modify a [collation] associated |
| | @@ -4859,26 +4870,26 @@ |
| 4859 | 4870 | ** is unfortunate but cannot be changed without breaking backwards |
| 4860 | 4871 | ** compatibility. |
| 4861 | 4872 | ** |
| 4862 | 4873 | ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. |
| 4863 | 4874 | */ |
| 4864 | | -SQLITE_API int sqlite3_create_collation( |
| 4875 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation( |
| 4865 | 4876 | sqlite3*, |
| 4866 | 4877 | const char *zName, |
| 4867 | 4878 | int eTextRep, |
| 4868 | 4879 | void *pArg, |
| 4869 | 4880 | int(*xCompare)(void*,int,const void*,int,const void*) |
| 4870 | 4881 | ); |
| 4871 | | -SQLITE_API int sqlite3_create_collation_v2( |
| 4882 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2( |
| 4872 | 4883 | sqlite3*, |
| 4873 | 4884 | const char *zName, |
| 4874 | 4885 | int eTextRep, |
| 4875 | 4886 | void *pArg, |
| 4876 | 4887 | int(*xCompare)(void*,int,const void*,int,const void*), |
| 4877 | 4888 | void(*xDestroy)(void*) |
| 4878 | 4889 | ); |
| 4879 | | -SQLITE_API int sqlite3_create_collation16( |
| 4890 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16( |
| 4880 | 4891 | sqlite3*, |
| 4881 | 4892 | const void *zName, |
| 4882 | 4893 | int eTextRep, |
| 4883 | 4894 | void *pArg, |
| 4884 | 4895 | int(*xCompare)(void*,int,const void*,int,const void*) |
| | @@ -4908,16 +4919,16 @@ |
| 4908 | 4919 | ** |
| 4909 | 4920 | ** The callback function should register the desired collation using |
| 4910 | 4921 | ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or |
| 4911 | 4922 | ** [sqlite3_create_collation_v2()]. |
| 4912 | 4923 | */ |
| 4913 | | -SQLITE_API int sqlite3_collation_needed( |
| 4924 | +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed( |
| 4914 | 4925 | sqlite3*, |
| 4915 | 4926 | void*, |
| 4916 | 4927 | void(*)(void*,sqlite3*,int eTextRep,const char*) |
| 4917 | 4928 | ); |
| 4918 | | -SQLITE_API int sqlite3_collation_needed16( |
| 4929 | +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16( |
| 4919 | 4930 | sqlite3*, |
| 4920 | 4931 | void*, |
| 4921 | 4932 | void(*)(void*,sqlite3*,int eTextRep,const void*) |
| 4922 | 4933 | ); |
| 4923 | 4934 | |
| | @@ -4927,15 +4938,15 @@ |
| 4927 | 4938 | ** called right after sqlite3_open(). |
| 4928 | 4939 | ** |
| 4929 | 4940 | ** The code to implement this API is not available in the public release |
| 4930 | 4941 | ** of SQLite. |
| 4931 | 4942 | */ |
| 4932 | | -SQLITE_API int sqlite3_key( |
| 4943 | +SQLITE_API int SQLITE_STDCALL sqlite3_key( |
| 4933 | 4944 | sqlite3 *db, /* Database to be rekeyed */ |
| 4934 | 4945 | const void *pKey, int nKey /* The key */ |
| 4935 | 4946 | ); |
| 4936 | | -SQLITE_API int sqlite3_key_v2( |
| 4947 | +SQLITE_API int SQLITE_STDCALL sqlite3_key_v2( |
| 4937 | 4948 | sqlite3 *db, /* Database to be rekeyed */ |
| 4938 | 4949 | const char *zDbName, /* Name of the database */ |
| 4939 | 4950 | const void *pKey, int nKey /* The key */ |
| 4940 | 4951 | ); |
| 4941 | 4952 | |
| | @@ -4945,35 +4956,35 @@ |
| 4945 | 4956 | ** database is decrypted. |
| 4946 | 4957 | ** |
| 4947 | 4958 | ** The code to implement this API is not available in the public release |
| 4948 | 4959 | ** of SQLite. |
| 4949 | 4960 | */ |
| 4950 | | -SQLITE_API int sqlite3_rekey( |
| 4961 | +SQLITE_API int SQLITE_STDCALL sqlite3_rekey( |
| 4951 | 4962 | sqlite3 *db, /* Database to be rekeyed */ |
| 4952 | 4963 | const void *pKey, int nKey /* The new key */ |
| 4953 | 4964 | ); |
| 4954 | | -SQLITE_API int sqlite3_rekey_v2( |
| 4965 | +SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2( |
| 4955 | 4966 | sqlite3 *db, /* Database to be rekeyed */ |
| 4956 | 4967 | const char *zDbName, /* Name of the database */ |
| 4957 | 4968 | const void *pKey, int nKey /* The new key */ |
| 4958 | 4969 | ); |
| 4959 | 4970 | |
| 4960 | 4971 | /* |
| 4961 | 4972 | ** Specify the activation key for a SEE database. Unless |
| 4962 | 4973 | ** activated, none of the SEE routines will work. |
| 4963 | 4974 | */ |
| 4964 | | -SQLITE_API void sqlite3_activate_see( |
| 4975 | +SQLITE_API void SQLITE_STDCALL sqlite3_activate_see( |
| 4965 | 4976 | const char *zPassPhrase /* Activation phrase */ |
| 4966 | 4977 | ); |
| 4967 | 4978 | #endif |
| 4968 | 4979 | |
| 4969 | 4980 | #ifdef SQLITE_ENABLE_CEROD |
| 4970 | 4981 | /* |
| 4971 | 4982 | ** Specify the activation key for a CEROD database. Unless |
| 4972 | 4983 | ** activated, none of the CEROD routines will work. |
| 4973 | 4984 | */ |
| 4974 | | -SQLITE_API void sqlite3_activate_cerod( |
| 4985 | +SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod( |
| 4975 | 4986 | const char *zPassPhrase /* Activation phrase */ |
| 4976 | 4987 | ); |
| 4977 | 4988 | #endif |
| 4978 | 4989 | |
| 4979 | 4990 | /* |
| | @@ -4991,11 +5002,11 @@ |
| 4991 | 5002 | ** method of the default [sqlite3_vfs] object. If the xSleep() method |
| 4992 | 5003 | ** of the default VFS is not implemented correctly, or not implemented at |
| 4993 | 5004 | ** all, then the behavior of sqlite3_sleep() may deviate from the description |
| 4994 | 5005 | ** in the previous paragraphs. |
| 4995 | 5006 | */ |
| 4996 | | -SQLITE_API int sqlite3_sleep(int); |
| 5007 | +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int); |
| 4997 | 5008 | |
| 4998 | 5009 | /* |
| 4999 | 5010 | ** CAPI3REF: Name Of The Folder Holding Temporary Files |
| 5000 | 5011 | ** |
| 5001 | 5012 | ** ^(If this global variable is made to point to a string which is |
| | @@ -5109,11 +5120,11 @@ |
| 5109 | 5120 | ** |
| 5110 | 5121 | ** If another thread changes the autocommit status of the database |
| 5111 | 5122 | ** connection while this routine is running, then the return value |
| 5112 | 5123 | ** is undefined. |
| 5113 | 5124 | */ |
| 5114 | | -SQLITE_API int sqlite3_get_autocommit(sqlite3*); |
| 5125 | +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*); |
| 5115 | 5126 | |
| 5116 | 5127 | /* |
| 5117 | 5128 | ** CAPI3REF: Find The Database Handle Of A Prepared Statement |
| 5118 | 5129 | ** |
| 5119 | 5130 | ** ^The sqlite3_db_handle interface returns the [database connection] handle |
| | @@ -5121,11 +5132,11 @@ |
| 5121 | 5132 | ** returned by sqlite3_db_handle is the same [database connection] |
| 5122 | 5133 | ** that was the first argument |
| 5123 | 5134 | ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to |
| 5124 | 5135 | ** create the statement in the first place. |
| 5125 | 5136 | */ |
| 5126 | | -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
| 5137 | +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*); |
| 5127 | 5138 | |
| 5128 | 5139 | /* |
| 5129 | 5140 | ** CAPI3REF: Return The Filename For A Database Connection |
| 5130 | 5141 | ** |
| 5131 | 5142 | ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename |
| | @@ -5137,20 +5148,20 @@ |
| 5137 | 5148 | ** ^The filename returned by this function is the output of the |
| 5138 | 5149 | ** xFullPathname method of the [VFS]. ^In other words, the filename |
| 5139 | 5150 | ** will be an absolute pathname, even if the filename used |
| 5140 | 5151 | ** to open the database originally was a URI or relative pathname. |
| 5141 | 5152 | */ |
| 5142 | | -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); |
| 5153 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName); |
| 5143 | 5154 | |
| 5144 | 5155 | /* |
| 5145 | 5156 | ** CAPI3REF: Determine if a database is read-only |
| 5146 | 5157 | ** |
| 5147 | 5158 | ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N |
| 5148 | 5159 | ** of connection D is read-only, 0 if it is read/write, or -1 if N is not |
| 5149 | 5160 | ** the name of a database on connection D. |
| 5150 | 5161 | */ |
| 5151 | | -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); |
| 5162 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName); |
| 5152 | 5163 | |
| 5153 | 5164 | /* |
| 5154 | 5165 | ** CAPI3REF: Find the next prepared statement |
| 5155 | 5166 | ** |
| 5156 | 5167 | ** ^This interface returns a pointer to the next [prepared statement] after |
| | @@ -5161,11 +5172,11 @@ |
| 5161 | 5172 | ** |
| 5162 | 5173 | ** The [database connection] pointer D in a call to |
| 5163 | 5174 | ** [sqlite3_next_stmt(D,S)] must refer to an open database |
| 5164 | 5175 | ** connection and in particular must not be a NULL pointer. |
| 5165 | 5176 | */ |
| 5166 | | -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
| 5177 | +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
| 5167 | 5178 | |
| 5168 | 5179 | /* |
| 5169 | 5180 | ** CAPI3REF: Commit And Rollback Notification Callbacks |
| 5170 | 5181 | ** |
| 5171 | 5182 | ** ^The sqlite3_commit_hook() interface registers a callback |
| | @@ -5209,12 +5220,12 @@ |
| 5209 | 5220 | ** ^The rollback callback is not invoked if a transaction is |
| 5210 | 5221 | ** automatically rolled back because the database connection is closed. |
| 5211 | 5222 | ** |
| 5212 | 5223 | ** See also the [sqlite3_update_hook()] interface. |
| 5213 | 5224 | */ |
| 5214 | | -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); |
| 5215 | | -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
| 5225 | +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); |
| 5226 | +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
| 5216 | 5227 | |
| 5217 | 5228 | /* |
| 5218 | 5229 | ** CAPI3REF: Data Change Notification Callbacks |
| 5219 | 5230 | ** |
| 5220 | 5231 | ** ^The sqlite3_update_hook() interface registers a callback function |
| | @@ -5260,11 +5271,11 @@ |
| 5260 | 5271 | ** the first call on D. |
| 5261 | 5272 | ** |
| 5262 | 5273 | ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] |
| 5263 | 5274 | ** interfaces. |
| 5264 | 5275 | */ |
| 5265 | | -SQLITE_API void *sqlite3_update_hook( |
| 5276 | +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook( |
| 5266 | 5277 | sqlite3*, |
| 5267 | 5278 | void(*)(void *,int ,char const *,char const *,sqlite3_int64), |
| 5268 | 5279 | void* |
| 5269 | 5280 | ); |
| 5270 | 5281 | |
| | @@ -5300,11 +5311,11 @@ |
| 5300 | 5311 | ** This interface is threadsafe on processors where writing a |
| 5301 | 5312 | ** 32-bit integer is atomic. |
| 5302 | 5313 | ** |
| 5303 | 5314 | ** See Also: [SQLite Shared-Cache Mode] |
| 5304 | 5315 | */ |
| 5305 | | -SQLITE_API int sqlite3_enable_shared_cache(int); |
| 5316 | +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int); |
| 5306 | 5317 | |
| 5307 | 5318 | /* |
| 5308 | 5319 | ** CAPI3REF: Attempt To Free Heap Memory |
| 5309 | 5320 | ** |
| 5310 | 5321 | ** ^The sqlite3_release_memory() interface attempts to free N bytes |
| | @@ -5316,11 +5327,11 @@ |
| 5316 | 5327 | ** ^The sqlite3_release_memory() routine is a no-op returning zero |
| 5317 | 5328 | ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. |
| 5318 | 5329 | ** |
| 5319 | 5330 | ** See also: [sqlite3_db_release_memory()] |
| 5320 | 5331 | */ |
| 5321 | | -SQLITE_API int sqlite3_release_memory(int); |
| 5332 | +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int); |
| 5322 | 5333 | |
| 5323 | 5334 | /* |
| 5324 | 5335 | ** CAPI3REF: Free Memory Used By A Database Connection |
| 5325 | 5336 | ** |
| 5326 | 5337 | ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap |
| | @@ -5329,11 +5340,11 @@ |
| 5329 | 5340 | ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
| 5330 | 5341 | ** omitted. |
| 5331 | 5342 | ** |
| 5332 | 5343 | ** See also: [sqlite3_release_memory()] |
| 5333 | 5344 | */ |
| 5334 | | -SQLITE_API int sqlite3_db_release_memory(sqlite3*); |
| 5345 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*); |
| 5335 | 5346 | |
| 5336 | 5347 | /* |
| 5337 | 5348 | ** CAPI3REF: Impose A Limit On Heap Size |
| 5338 | 5349 | ** |
| 5339 | 5350 | ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the |
| | @@ -5381,11 +5392,11 @@ |
| 5381 | 5392 | ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. |
| 5382 | 5393 | ** |
| 5383 | 5394 | ** The circumstances under which SQLite will enforce the soft heap limit may |
| 5384 | 5395 | ** changes in future releases of SQLite. |
| 5385 | 5396 | */ |
| 5386 | | -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); |
| 5397 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N); |
| 5387 | 5398 | |
| 5388 | 5399 | /* |
| 5389 | 5400 | ** CAPI3REF: Deprecated Soft Heap Limit Interface |
| 5390 | 5401 | ** DEPRECATED |
| 5391 | 5402 | ** |
| | @@ -5392,11 +5403,11 @@ |
| 5392 | 5403 | ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] |
| 5393 | 5404 | ** interface. This routine is provided for historical compatibility |
| 5394 | 5405 | ** only. All new applications should use the |
| 5395 | 5406 | ** [sqlite3_soft_heap_limit64()] interface rather than this one. |
| 5396 | 5407 | */ |
| 5397 | | -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); |
| 5408 | +SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N); |
| 5398 | 5409 | |
| 5399 | 5410 | |
| 5400 | 5411 | /* |
| 5401 | 5412 | ** CAPI3REF: Extract Metadata About A Column Of A Table |
| 5402 | 5413 | ** |
| | @@ -5461,11 +5472,11 @@ |
| 5461 | 5472 | ** |
| 5462 | 5473 | ** ^This function causes all database schemas to be read from disk and |
| 5463 | 5474 | ** parsed, if that has not already been done, and returns an error if |
| 5464 | 5475 | ** any errors are encountered while loading the schema. |
| 5465 | 5476 | */ |
| 5466 | | -SQLITE_API int sqlite3_table_column_metadata( |
| 5477 | +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata( |
| 5467 | 5478 | sqlite3 *db, /* Connection handle */ |
| 5468 | 5479 | const char *zDbName, /* Database name or NULL */ |
| 5469 | 5480 | const char *zTableName, /* Table name */ |
| 5470 | 5481 | const char *zColumnName, /* Column name */ |
| 5471 | 5482 | char const **pzDataType, /* OUTPUT: Declared data type */ |
| | @@ -5507,11 +5518,11 @@ |
| 5507 | 5518 | ** [sqlite3_enable_load_extension()] prior to calling this API, |
| 5508 | 5519 | ** otherwise an error will be returned. |
| 5509 | 5520 | ** |
| 5510 | 5521 | ** See also the [load_extension() SQL function]. |
| 5511 | 5522 | */ |
| 5512 | | -SQLITE_API int sqlite3_load_extension( |
| 5523 | +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension( |
| 5513 | 5524 | sqlite3 *db, /* Load the extension into this database connection */ |
| 5514 | 5525 | const char *zFile, /* Name of the shared library containing extension */ |
| 5515 | 5526 | const char *zProc, /* Entry point. Derived from zFile if 0 */ |
| 5516 | 5527 | char **pzErrMsg /* Put error message here if not 0 */ |
| 5517 | 5528 | ); |
| | @@ -5527,11 +5538,11 @@ |
| 5527 | 5538 | ** ^Extension loading is off by default. |
| 5528 | 5539 | ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 |
| 5529 | 5540 | ** to turn extension loading on and call it with onoff==0 to turn |
| 5530 | 5541 | ** it back off again. |
| 5531 | 5542 | */ |
| 5532 | | -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| 5543 | +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| 5533 | 5544 | |
| 5534 | 5545 | /* |
| 5535 | 5546 | ** CAPI3REF: Automatically Load Statically Linked Extensions |
| 5536 | 5547 | ** |
| 5537 | 5548 | ** ^This interface causes the xEntryPoint() function to be invoked for |
| | @@ -5565,11 +5576,11 @@ |
| 5565 | 5576 | ** will be called more than once for each database connection that is opened. |
| 5566 | 5577 | ** |
| 5567 | 5578 | ** See also: [sqlite3_reset_auto_extension()] |
| 5568 | 5579 | ** and [sqlite3_cancel_auto_extension()] |
| 5569 | 5580 | */ |
| 5570 | | -SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); |
| 5581 | +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void)); |
| 5571 | 5582 | |
| 5572 | 5583 | /* |
| 5573 | 5584 | ** CAPI3REF: Cancel Automatic Extension Loading |
| 5574 | 5585 | ** |
| 5575 | 5586 | ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the |
| | @@ -5577,19 +5588,19 @@ |
| 5577 | 5588 | ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] |
| 5578 | 5589 | ** routine returns 1 if initialization routine X was successfully |
| 5579 | 5590 | ** unregistered and it returns 0 if X was not on the list of initialization |
| 5580 | 5591 | ** routines. |
| 5581 | 5592 | */ |
| 5582 | | -SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); |
| 5593 | +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); |
| 5583 | 5594 | |
| 5584 | 5595 | /* |
| 5585 | 5596 | ** CAPI3REF: Reset Automatic Extension Loading |
| 5586 | 5597 | ** |
| 5587 | 5598 | ** ^This interface disables all automatic extensions previously |
| 5588 | 5599 | ** registered using [sqlite3_auto_extension()]. |
| 5589 | 5600 | */ |
| 5590 | | -SQLITE_API void sqlite3_reset_auto_extension(void); |
| 5601 | +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void); |
| 5591 | 5602 | |
| 5592 | 5603 | /* |
| 5593 | 5604 | ** The interface to the virtual-table mechanism is currently considered |
| 5594 | 5605 | ** to be experimental. The interface might change in incompatible ways. |
| 5595 | 5606 | ** If this is a problem for you, do not use the interface at this time. |
| | @@ -5788,17 +5799,17 @@ |
| 5788 | 5799 | ** be invoked if the call to sqlite3_create_module_v2() fails. |
| 5789 | 5800 | ** ^The sqlite3_create_module() |
| 5790 | 5801 | ** interface is equivalent to sqlite3_create_module_v2() with a NULL |
| 5791 | 5802 | ** destructor. |
| 5792 | 5803 | */ |
| 5793 | | -SQLITE_API int sqlite3_create_module( |
| 5804 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_module( |
| 5794 | 5805 | sqlite3 *db, /* SQLite connection to register module with */ |
| 5795 | 5806 | const char *zName, /* Name of the module */ |
| 5796 | 5807 | const sqlite3_module *p, /* Methods for the module */ |
| 5797 | 5808 | void *pClientData /* Client data for xCreate/xConnect */ |
| 5798 | 5809 | ); |
| 5799 | | -SQLITE_API int sqlite3_create_module_v2( |
| 5810 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2( |
| 5800 | 5811 | sqlite3 *db, /* SQLite connection to register module with */ |
| 5801 | 5812 | const char *zName, /* Name of the module */ |
| 5802 | 5813 | const sqlite3_module *p, /* Methods for the module */ |
| 5803 | 5814 | void *pClientData, /* Client data for xCreate/xConnect */ |
| 5804 | 5815 | void(*xDestroy)(void*) /* Module destructor function */ |
| | @@ -5822,11 +5833,11 @@ |
| 5822 | 5833 | ** is delivered up to the client application, the string will be automatically |
| 5823 | 5834 | ** freed by sqlite3_free() and the zErrMsg field will be zeroed. |
| 5824 | 5835 | */ |
| 5825 | 5836 | struct sqlite3_vtab { |
| 5826 | 5837 | const sqlite3_module *pModule; /* The module for this virtual table */ |
| 5827 | | - int nRef; /* NO LONGER USED */ |
| 5838 | + int nRef; /* Number of open cursors */ |
| 5828 | 5839 | char *zErrMsg; /* Error message from sqlite3_mprintf() */ |
| 5829 | 5840 | /* Virtual table implementations will typically add additional fields */ |
| 5830 | 5841 | }; |
| 5831 | 5842 | |
| 5832 | 5843 | /* |
| | @@ -5857,11 +5868,11 @@ |
| 5857 | 5868 | ** ^The [xCreate] and [xConnect] methods of a |
| 5858 | 5869 | ** [virtual table module] call this interface |
| 5859 | 5870 | ** to declare the format (the names and datatypes of the columns) of |
| 5860 | 5871 | ** the virtual tables they implement. |
| 5861 | 5872 | */ |
| 5862 | | -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL); |
| 5873 | +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL); |
| 5863 | 5874 | |
| 5864 | 5875 | /* |
| 5865 | 5876 | ** CAPI3REF: Overload A Function For A Virtual Table |
| 5866 | 5877 | ** |
| 5867 | 5878 | ** ^(Virtual tables can provide alternative implementations of functions |
| | @@ -5875,11 +5886,11 @@ |
| 5875 | 5886 | ** of the new function always causes an exception to be thrown. So |
| 5876 | 5887 | ** the new function is not good for anything by itself. Its only |
| 5877 | 5888 | ** purpose is to be a placeholder function that can be overloaded |
| 5878 | 5889 | ** by a [virtual table]. |
| 5879 | 5890 | */ |
| 5880 | | -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); |
| 5891 | +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); |
| 5881 | 5892 | |
| 5882 | 5893 | /* |
| 5883 | 5894 | ** The interface to the virtual-table mechanism defined above (back up |
| 5884 | 5895 | ** to a comment remarkably similar to this one) is currently considered |
| 5885 | 5896 | ** to be experimental. The interface might change in incompatible ways. |
| | @@ -5972,11 +5983,11 @@ |
| 5972 | 5983 | ** zero-filled blob to read or write using the incremental-blob interface. |
| 5973 | 5984 | ** |
| 5974 | 5985 | ** To avoid a resource leak, every open [BLOB handle] should eventually |
| 5975 | 5986 | ** be released by a call to [sqlite3_blob_close()]. |
| 5976 | 5987 | */ |
| 5977 | | -SQLITE_API int sqlite3_blob_open( |
| 5988 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open( |
| 5978 | 5989 | sqlite3*, |
| 5979 | 5990 | const char *zDb, |
| 5980 | 5991 | const char *zTable, |
| 5981 | 5992 | const char *zColumn, |
| 5982 | 5993 | sqlite3_int64 iRow, |
| | @@ -6004,11 +6015,11 @@ |
| 6004 | 6015 | ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle |
| 6005 | 6016 | ** always returns zero. |
| 6006 | 6017 | ** |
| 6007 | 6018 | ** ^This function sets the database handle error code and message. |
| 6008 | 6019 | */ |
| 6009 | | -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); |
| 6020 | +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); |
| 6010 | 6021 | |
| 6011 | 6022 | /* |
| 6012 | 6023 | ** CAPI3REF: Close A BLOB Handle |
| 6013 | 6024 | ** |
| 6014 | 6025 | ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed |
| | @@ -6026,11 +6037,11 @@ |
| 6026 | 6037 | ** with a null pointer (such as would be returned by a failed call to |
| 6027 | 6038 | ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function |
| 6028 | 6039 | ** is passed a valid open blob handle, the values returned by the |
| 6029 | 6040 | ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning. |
| 6030 | 6041 | */ |
| 6031 | | -SQLITE_API int sqlite3_blob_close(sqlite3_blob *); |
| 6042 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *); |
| 6032 | 6043 | |
| 6033 | 6044 | /* |
| 6034 | 6045 | ** CAPI3REF: Return The Size Of An Open BLOB |
| 6035 | 6046 | ** |
| 6036 | 6047 | ** ^Returns the size in bytes of the BLOB accessible via the |
| | @@ -6041,11 +6052,11 @@ |
| 6041 | 6052 | ** This routine only works on a [BLOB handle] which has been created |
| 6042 | 6053 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 6043 | 6054 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 6044 | 6055 | ** to this routine results in undefined and probably undesirable behavior. |
| 6045 | 6056 | */ |
| 6046 | | -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); |
| 6057 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *); |
| 6047 | 6058 | |
| 6048 | 6059 | /* |
| 6049 | 6060 | ** CAPI3REF: Read Data From A BLOB Incrementally |
| 6050 | 6061 | ** |
| 6051 | 6062 | ** ^(This function is used to read data from an open [BLOB handle] into a |
| | @@ -6069,11 +6080,11 @@ |
| 6069 | 6080 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 6070 | 6081 | ** to this routine results in undefined and probably undesirable behavior. |
| 6071 | 6082 | ** |
| 6072 | 6083 | ** See also: [sqlite3_blob_write()]. |
| 6073 | 6084 | */ |
| 6074 | | -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); |
| 6085 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); |
| 6075 | 6086 | |
| 6076 | 6087 | /* |
| 6077 | 6088 | ** CAPI3REF: Write Data Into A BLOB Incrementally |
| 6078 | 6089 | ** |
| 6079 | 6090 | ** ^(This function is used to write data into an open [BLOB handle] from a |
| | @@ -6110,11 +6121,11 @@ |
| 6110 | 6121 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 6111 | 6122 | ** to this routine results in undefined and probably undesirable behavior. |
| 6112 | 6123 | ** |
| 6113 | 6124 | ** See also: [sqlite3_blob_read()]. |
| 6114 | 6125 | */ |
| 6115 | | -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); |
| 6126 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); |
| 6116 | 6127 | |
| 6117 | 6128 | /* |
| 6118 | 6129 | ** CAPI3REF: Virtual File System Objects |
| 6119 | 6130 | ** |
| 6120 | 6131 | ** A virtual filesystem (VFS) is an [sqlite3_vfs] object |
| | @@ -6141,13 +6152,13 @@ |
| 6141 | 6152 | ** |
| 6142 | 6153 | ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. |
| 6143 | 6154 | ** ^(If the default VFS is unregistered, another VFS is chosen as |
| 6144 | 6155 | ** the default. The choice for the new VFS is arbitrary.)^ |
| 6145 | 6156 | */ |
| 6146 | | -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); |
| 6147 | | -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); |
| 6148 | | -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
| 6157 | +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName); |
| 6158 | +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); |
| 6159 | +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*); |
| 6149 | 6160 | |
| 6150 | 6161 | /* |
| 6151 | 6162 | ** CAPI3REF: Mutexes |
| 6152 | 6163 | ** |
| 6153 | 6164 | ** The SQLite core uses these routines for thread |
| | @@ -6256,15 +6267,15 @@ |
| 6256 | 6267 | ** sqlite3_mutex_leave() is a NULL pointer, then all three routines |
| 6257 | 6268 | ** behave as no-ops. |
| 6258 | 6269 | ** |
| 6259 | 6270 | ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. |
| 6260 | 6271 | */ |
| 6261 | | -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); |
| 6262 | | -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); |
| 6263 | | -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); |
| 6264 | | -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); |
| 6265 | | -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); |
| 6272 | +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int); |
| 6273 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*); |
| 6274 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*); |
| 6275 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*); |
| 6276 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*); |
| 6266 | 6277 | |
| 6267 | 6278 | /* |
| 6268 | 6279 | ** CAPI3REF: Mutex Methods Object |
| 6269 | 6280 | ** |
| 6270 | 6281 | ** An instance of this structure defines the low-level routines |
| | @@ -6370,12 +6381,12 @@ |
| 6370 | 6381 | ** call to sqlite3_mutex_held() to fail, so a non-zero return is |
| 6371 | 6382 | ** the appropriate thing to do. The sqlite3_mutex_notheld() |
| 6372 | 6383 | ** interface should also return 1 when given a NULL pointer. |
| 6373 | 6384 | */ |
| 6374 | 6385 | #ifndef NDEBUG |
| 6375 | | -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); |
| 6376 | | -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); |
| 6386 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*); |
| 6387 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*); |
| 6377 | 6388 | #endif |
| 6378 | 6389 | |
| 6379 | 6390 | /* |
| 6380 | 6391 | ** CAPI3REF: Mutex Types |
| 6381 | 6392 | ** |
| | @@ -6407,11 +6418,11 @@ |
| 6407 | 6418 | ** serializes access to the [database connection] given in the argument |
| 6408 | 6419 | ** when the [threading mode] is Serialized. |
| 6409 | 6420 | ** ^If the [threading mode] is Single-thread or Multi-thread then this |
| 6410 | 6421 | ** routine returns a NULL pointer. |
| 6411 | 6422 | */ |
| 6412 | | -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); |
| 6423 | +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*); |
| 6413 | 6424 | |
| 6414 | 6425 | /* |
| 6415 | 6426 | ** CAPI3REF: Low-Level Control Of Database Files |
| 6416 | 6427 | ** |
| 6417 | 6428 | ** ^The [sqlite3_file_control()] interface makes a direct call to the |
| | @@ -6441,11 +6452,11 @@ |
| 6441 | 6452 | ** an incorrect zDbName and an SQLITE_ERROR return from the underlying |
| 6442 | 6453 | ** xFileControl method. |
| 6443 | 6454 | ** |
| 6444 | 6455 | ** See also: [SQLITE_FCNTL_LOCKSTATE] |
| 6445 | 6456 | */ |
| 6446 | | -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); |
| 6457 | +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); |
| 6447 | 6458 | |
| 6448 | 6459 | /* |
| 6449 | 6460 | ** CAPI3REF: Testing Interface |
| 6450 | 6461 | ** |
| 6451 | 6462 | ** ^The sqlite3_test_control() interface is used to read out internal |
| | @@ -6460,11 +6471,11 @@ |
| 6460 | 6471 | ** The details of the operation codes, their meanings, the parameters |
| 6461 | 6472 | ** they take, and what they do are all subject to change without notice. |
| 6462 | 6473 | ** Unlike most of the SQLite API, this function is not guaranteed to |
| 6463 | 6474 | ** operate consistently from one release to the next. |
| 6464 | 6475 | */ |
| 6465 | | -SQLITE_API int sqlite3_test_control(int op, ...); |
| 6476 | +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...); |
| 6466 | 6477 | |
| 6467 | 6478 | /* |
| 6468 | 6479 | ** CAPI3REF: Testing Interface Operation Codes |
| 6469 | 6480 | ** |
| 6470 | 6481 | ** These constants are the valid operation code parameters used |
| | @@ -6500,11 +6511,11 @@ |
| 6500 | 6511 | #define SQLITE_TESTCTRL_LAST 25 |
| 6501 | 6512 | |
| 6502 | 6513 | /* |
| 6503 | 6514 | ** CAPI3REF: SQLite Runtime Status |
| 6504 | 6515 | ** |
| 6505 | | -** ^This interface is used to retrieve runtime status information |
| 6516 | +** ^These interfaces are used to retrieve runtime status information |
| 6506 | 6517 | ** about the performance of SQLite, and optionally to reset various |
| 6507 | 6518 | ** highwater marks. ^The first argument is an integer code for |
| 6508 | 6519 | ** the specific parameter to measure. ^(Recognized integer codes |
| 6509 | 6520 | ** are of the form [status parameters | SQLITE_STATUS_...].)^ |
| 6510 | 6521 | ** ^The current value of the parameter is returned into *pCurrent. |
| | @@ -6514,23 +6525,26 @@ |
| 6514 | 6525 | ** value. For those parameters |
| 6515 | 6526 | ** nothing is written into *pHighwater and the resetFlag is ignored.)^ |
| 6516 | 6527 | ** ^(Other parameters record only the highwater mark and not the current |
| 6517 | 6528 | ** value. For these latter parameters nothing is written into *pCurrent.)^ |
| 6518 | 6529 | ** |
| 6519 | | -** ^The sqlite3_status() routine returns SQLITE_OK on success and a |
| 6520 | | -** non-zero [error code] on failure. |
| 6530 | +** ^The sqlite3_status() and sqlite3_status64() routines return |
| 6531 | +** SQLITE_OK on success and a non-zero [error code] on failure. |
| 6521 | 6532 | ** |
| 6522 | | -** This routine is threadsafe but is not atomic. This routine can be |
| 6523 | | -** called while other threads are running the same or different SQLite |
| 6524 | | -** interfaces. However the values returned in *pCurrent and |
| 6525 | | -** *pHighwater reflect the status of SQLite at different points in time |
| 6526 | | -** and it is possible that another thread might change the parameter |
| 6527 | | -** in between the times when *pCurrent and *pHighwater are written. |
| 6533 | +** If either the current value or the highwater mark is too large to |
| 6534 | +** be represented by a 32-bit integer, then the values returned by |
| 6535 | +** sqlite3_status() are undefined. |
| 6528 | 6536 | ** |
| 6529 | 6537 | ** See also: [sqlite3_db_status()] |
| 6530 | 6538 | */ |
| 6531 | | -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); |
| 6539 | +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); |
| 6540 | +SQLITE_API int SQLITE_STDCALL sqlite3_status64( |
| 6541 | + int op, |
| 6542 | + sqlite3_int64 *pCurrent, |
| 6543 | + sqlite3_int64 *pHighwater, |
| 6544 | + int resetFlag |
| 6545 | +); |
| 6532 | 6546 | |
| 6533 | 6547 | |
| 6534 | 6548 | /* |
| 6535 | 6549 | ** CAPI3REF: Status Parameters |
| 6536 | 6550 | ** KEYWORDS: {status parameters} |
| | @@ -6644,11 +6658,11 @@ |
| 6644 | 6658 | ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a |
| 6645 | 6659 | ** non-zero [error code] on failure. |
| 6646 | 6660 | ** |
| 6647 | 6661 | ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. |
| 6648 | 6662 | */ |
| 6649 | | -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); |
| 6663 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); |
| 6650 | 6664 | |
| 6651 | 6665 | /* |
| 6652 | 6666 | ** CAPI3REF: Status Parameters for database connections |
| 6653 | 6667 | ** KEYWORDS: {SQLITE_DBSTATUS options} |
| 6654 | 6668 | ** |
| | @@ -6773,11 +6787,11 @@ |
| 6773 | 6787 | ** ^If the resetFlg is true, then the counter is reset to zero after this |
| 6774 | 6788 | ** interface call returns. |
| 6775 | 6789 | ** |
| 6776 | 6790 | ** See also: [sqlite3_status()] and [sqlite3_db_status()]. |
| 6777 | 6791 | */ |
| 6778 | | -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
| 6792 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
| 6779 | 6793 | |
| 6780 | 6794 | /* |
| 6781 | 6795 | ** CAPI3REF: Status Parameters for prepared statements |
| 6782 | 6796 | ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} |
| 6783 | 6797 | ** |
| | @@ -7242,20 +7256,20 @@ |
| 7242 | 7256 | ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() |
| 7243 | 7257 | ** APIs are not strictly speaking threadsafe. If they are invoked at the |
| 7244 | 7258 | ** same time as another thread is invoking sqlite3_backup_step() it is |
| 7245 | 7259 | ** possible that they return invalid values. |
| 7246 | 7260 | */ |
| 7247 | | -SQLITE_API sqlite3_backup *sqlite3_backup_init( |
| 7261 | +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init( |
| 7248 | 7262 | sqlite3 *pDest, /* Destination database handle */ |
| 7249 | 7263 | const char *zDestName, /* Destination database name */ |
| 7250 | 7264 | sqlite3 *pSource, /* Source database handle */ |
| 7251 | 7265 | const char *zSourceName /* Source database name */ |
| 7252 | 7266 | ); |
| 7253 | | -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); |
| 7254 | | -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); |
| 7255 | | -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); |
| 7256 | | -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); |
| 7267 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage); |
| 7268 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p); |
| 7269 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p); |
| 7270 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p); |
| 7257 | 7271 | |
| 7258 | 7272 | /* |
| 7259 | 7273 | ** CAPI3REF: Unlock Notification |
| 7260 | 7274 | ** |
| 7261 | 7275 | ** ^When running in shared-cache mode, a database operation may fail with |
| | @@ -7367,11 +7381,11 @@ |
| 7367 | 7381 | ** by an sqlite3_step() call. ^(If there is a blocking connection, then the |
| 7368 | 7382 | ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in |
| 7369 | 7383 | ** the special "DROP TABLE/INDEX" case, the extended error code is just |
| 7370 | 7384 | ** SQLITE_LOCKED.)^ |
| 7371 | 7385 | */ |
| 7372 | | -SQLITE_API int sqlite3_unlock_notify( |
| 7386 | +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify( |
| 7373 | 7387 | sqlite3 *pBlocked, /* Waiting connection */ |
| 7374 | 7388 | void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ |
| 7375 | 7389 | void *pNotifyArg /* Argument to pass to xNotify */ |
| 7376 | 7390 | ); |
| 7377 | 7391 | |
| | @@ -7382,12 +7396,12 @@ |
| 7382 | 7396 | ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications |
| 7383 | 7397 | ** and extensions to compare the contents of two buffers containing UTF-8 |
| 7384 | 7398 | ** strings in a case-independent fashion, using the same definition of "case |
| 7385 | 7399 | ** independence" that SQLite uses internally when comparing identifiers. |
| 7386 | 7400 | */ |
| 7387 | | -SQLITE_API int sqlite3_stricmp(const char *, const char *); |
| 7388 | | -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); |
| 7401 | +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *); |
| 7402 | +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int); |
| 7389 | 7403 | |
| 7390 | 7404 | /* |
| 7391 | 7405 | ** CAPI3REF: String Globbing |
| 7392 | 7406 | * |
| 7393 | 7407 | ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches |
| | @@ -7398,11 +7412,11 @@ |
| 7398 | 7412 | ** sensitive. |
| 7399 | 7413 | ** |
| 7400 | 7414 | ** Note that this routine returns zero on a match and non-zero if the strings |
| 7401 | 7415 | ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. |
| 7402 | 7416 | */ |
| 7403 | | -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr); |
| 7417 | +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr); |
| 7404 | 7418 | |
| 7405 | 7419 | /* |
| 7406 | 7420 | ** CAPI3REF: Error Logging Interface |
| 7407 | 7421 | ** |
| 7408 | 7422 | ** ^The [sqlite3_log()] interface writes a message into the [error log] |
| | @@ -7421,11 +7435,11 @@ |
| 7421 | 7435 | ** will not use dynamically allocated memory. The log message is stored in |
| 7422 | 7436 | ** a fixed-length buffer on the stack. If the log message is longer than |
| 7423 | 7437 | ** a few hundred characters, it will be truncated to the length of the |
| 7424 | 7438 | ** buffer. |
| 7425 | 7439 | */ |
| 7426 | | -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); |
| 7440 | +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...); |
| 7427 | 7441 | |
| 7428 | 7442 | /* |
| 7429 | 7443 | ** CAPI3REF: Write-Ahead Log Commit Hook |
| 7430 | 7444 | ** |
| 7431 | 7445 | ** ^The [sqlite3_wal_hook()] function is used to register a callback that |
| | @@ -7456,11 +7470,11 @@ |
| 7456 | 7470 | ** previously registered write-ahead log callback. ^Note that the |
| 7457 | 7471 | ** [sqlite3_wal_autocheckpoint()] interface and the |
| 7458 | 7472 | ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will |
| 7459 | 7473 | ** those overwrite any prior [sqlite3_wal_hook()] settings. |
| 7460 | 7474 | */ |
| 7461 | | -SQLITE_API void *sqlite3_wal_hook( |
| 7475 | +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook( |
| 7462 | 7476 | sqlite3*, |
| 7463 | 7477 | int(*)(void *,sqlite3*,const char*,int), |
| 7464 | 7478 | void* |
| 7465 | 7479 | ); |
| 7466 | 7480 | |
| | @@ -7490,11 +7504,11 @@ |
| 7490 | 7504 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 7491 | 7505 | ** pages. The use of this interface |
| 7492 | 7506 | ** is only necessary if the default setting is found to be suboptimal |
| 7493 | 7507 | ** for a particular application. |
| 7494 | 7508 | */ |
| 7495 | | -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 7509 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 7496 | 7510 | |
| 7497 | 7511 | /* |
| 7498 | 7512 | ** CAPI3REF: Checkpoint a database |
| 7499 | 7513 | ** |
| 7500 | 7514 | ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to |
| | @@ -7511,11 +7525,11 @@ |
| 7511 | 7525 | ** interface was added. This interface is retained for backwards |
| 7512 | 7526 | ** compatibility and as a convenience for applications that need to manually |
| 7513 | 7527 | ** start a callback but which do not need the full power (and corresponding |
| 7514 | 7528 | ** complication) of [sqlite3_wal_checkpoint_v2()]. |
| 7515 | 7529 | */ |
| 7516 | | -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); |
| 7530 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); |
| 7517 | 7531 | |
| 7518 | 7532 | /* |
| 7519 | 7533 | ** CAPI3REF: Checkpoint a database |
| 7520 | 7534 | ** |
| 7521 | 7535 | ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint |
| | @@ -7604,11 +7618,11 @@ |
| 7604 | 7618 | ** [sqlite3_errcode()] and [sqlite3_errmsg()]. |
| 7605 | 7619 | ** |
| 7606 | 7620 | ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface |
| 7607 | 7621 | ** from SQL. |
| 7608 | 7622 | */ |
| 7609 | | -SQLITE_API int sqlite3_wal_checkpoint_v2( |
| 7623 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2( |
| 7610 | 7624 | sqlite3 *db, /* Database handle */ |
| 7611 | 7625 | const char *zDb, /* Name of attached database (or NULL) */ |
| 7612 | 7626 | int eMode, /* SQLITE_CHECKPOINT_* value */ |
| 7613 | 7627 | int *pnLog, /* OUT: Size of WAL log in frames */ |
| 7614 | 7628 | int *pnCkpt /* OUT: Total number of frames checkpointed */ |
| | @@ -7640,11 +7654,11 @@ |
| 7640 | 7654 | ** |
| 7641 | 7655 | ** At present, there is only one option that may be configured using |
| 7642 | 7656 | ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options |
| 7643 | 7657 | ** may be added in the future. |
| 7644 | 7658 | */ |
| 7645 | | -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); |
| 7659 | +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...); |
| 7646 | 7660 | |
| 7647 | 7661 | /* |
| 7648 | 7662 | ** CAPI3REF: Virtual Table Configuration Options |
| 7649 | 7663 | ** |
| 7650 | 7664 | ** These macros define the various options to the |
| | @@ -7693,11 +7707,11 @@ |
| 7693 | 7707 | ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], |
| 7694 | 7708 | ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode |
| 7695 | 7709 | ** of the SQL statement that triggered the call to the [xUpdate] method of the |
| 7696 | 7710 | ** [virtual table]. |
| 7697 | 7711 | */ |
| 7698 | | -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); |
| 7712 | +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *); |
| 7699 | 7713 | |
| 7700 | 7714 | /* |
| 7701 | 7715 | ** CAPI3REF: Conflict resolution modes |
| 7702 | 7716 | ** KEYWORDS: {conflict resolution mode} |
| 7703 | 7717 | ** |
| | @@ -7797,11 +7811,11 @@ |
| 7797 | 7811 | ** as if the loop did not exist - it returns non-zero and leave the variable |
| 7798 | 7812 | ** that pOut points to unchanged. |
| 7799 | 7813 | ** |
| 7800 | 7814 | ** See also: [sqlite3_stmt_scanstatus_reset()] |
| 7801 | 7815 | */ |
| 7802 | | -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus( |
| 7816 | +SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus( |
| 7803 | 7817 | sqlite3_stmt *pStmt, /* Prepared statement for which info desired */ |
| 7804 | 7818 | int idx, /* Index of loop to report on */ |
| 7805 | 7819 | int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */ |
| 7806 | 7820 | void *pOut /* Result written here */ |
| 7807 | 7821 | ); |
| | @@ -7812,11 +7826,11 @@ |
| 7812 | 7826 | ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters. |
| 7813 | 7827 | ** |
| 7814 | 7828 | ** This API is only available if the library is built with pre-processor |
| 7815 | 7829 | ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined. |
| 7816 | 7830 | */ |
| 7817 | | -SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); |
| 7831 | +SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); |
| 7818 | 7832 | |
| 7819 | 7833 | |
| 7820 | 7834 | /* |
| 7821 | 7835 | ** Undo the hack that converts floating point types to integer for |
| 7822 | 7836 | ** builds on processors without floating point support. |
| | @@ -7867,11 +7881,11 @@ |
| 7867 | 7881 | ** Register a geometry callback named zGeom that can be used as part of an |
| 7868 | 7882 | ** R-Tree geometry query as follows: |
| 7869 | 7883 | ** |
| 7870 | 7884 | ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...) |
| 7871 | 7885 | */ |
| 7872 | | -SQLITE_API int sqlite3_rtree_geometry_callback( |
| 7886 | +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback( |
| 7873 | 7887 | sqlite3 *db, |
| 7874 | 7888 | const char *zGeom, |
| 7875 | 7889 | int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*), |
| 7876 | 7890 | void *pContext |
| 7877 | 7891 | ); |
| | @@ -7893,11 +7907,11 @@ |
| 7893 | 7907 | ** Register a 2nd-generation geometry callback named zScore that can be |
| 7894 | 7908 | ** used as part of an R-Tree geometry query as follows: |
| 7895 | 7909 | ** |
| 7896 | 7910 | ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...) |
| 7897 | 7911 | */ |
| 7898 | | -SQLITE_API int sqlite3_rtree_query_callback( |
| 7912 | +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback( |
| 7899 | 7913 | sqlite3 *db, |
| 7900 | 7914 | const char *zQueryFunc, |
| 7901 | 7915 | int (*xQueryFunc)(sqlite3_rtree_query_info*), |
| 7902 | 7916 | void *pContext, |
| 7903 | 7917 | void (*xDestructor)(void*) |
| | @@ -8911,10 +8925,24 @@ |
| 8911 | 8925 | ** |
| 8912 | 8926 | ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40 |
| 8913 | 8927 | */ |
| 8914 | 8928 | typedef INT16_TYPE LogEst; |
| 8915 | 8929 | |
| 8930 | +/* |
| 8931 | +** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer |
| 8932 | +*/ |
| 8933 | +#ifndef SQLITE_PTRSIZE |
| 8934 | +# if defined(__SIZEOF_POINTER__) |
| 8935 | +# define SQLITE_PTRSIZE __SIZEOF_POINTER__ |
| 8936 | +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 8937 | + defined(_M_ARM) || defined(__arm__) || defined(__x86) |
| 8938 | +# define SQLITE_PTRSIZE 4 |
| 8939 | +# else |
| 8940 | +# define SQLITE_PTRSIZE 8 |
| 8941 | +# endif |
| 8942 | +#endif |
| 8943 | + |
| 8916 | 8944 | /* |
| 8917 | 8945 | ** Macros to determine whether the machine is big or little endian, |
| 8918 | 8946 | ** and whether or not that determination is run-time or compile-time. |
| 8919 | 8947 | ** |
| 8920 | 8948 | ** For best performance, an attempt is made to guess at the byte-order |
| | @@ -9123,12 +9151,12 @@ |
| 9123 | 9151 | */ |
| 9124 | 9152 | #ifdef SQLITE_OMIT_WSD |
| 9125 | 9153 | #define SQLITE_WSD const |
| 9126 | 9154 | #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v))) |
| 9127 | 9155 | #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config) |
| 9128 | | -SQLITE_API int sqlite3_wsd_init(int N, int J); |
| 9129 | | -SQLITE_API void *sqlite3_wsd_find(void *K, int L); |
| 9156 | +SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J); |
| 9157 | +SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L); |
| 9130 | 9158 | #else |
| 9131 | 9159 | #define SQLITE_WSD |
| 9132 | 9160 | #define GLOBAL(t,v) v |
| 9133 | 9161 | #define sqlite3GlobalConfig sqlite3Config |
| 9134 | 9162 | #endif |
| | @@ -9361,12 +9389,22 @@ |
| 9361 | 9389 | #define BTREE_DATA_VERSION 15 /* A virtual meta-value */ |
| 9362 | 9390 | |
| 9363 | 9391 | /* |
| 9364 | 9392 | ** Values that may be OR'd together to form the second argument of an |
| 9365 | 9393 | ** sqlite3BtreeCursorHints() call. |
| 9394 | +** |
| 9395 | +** The BTREE_BULKLOAD flag is set on index cursors when the index is going |
| 9396 | +** to be filled with content that is already in sorted order. |
| 9397 | +** |
| 9398 | +** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or |
| 9399 | +** OP_SeekLE opcodes for a range search, but where the range of entries |
| 9400 | +** selected will all have the same key. In other words, the cursor will |
| 9401 | +** be used only for equality key searches. |
| 9402 | +** |
| 9366 | 9403 | */ |
| 9367 | | -#define BTREE_BULKLOAD 0x00000001 |
| 9404 | +#define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */ |
| 9405 | +#define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */ |
| 9368 | 9406 | |
| 9369 | 9407 | SQLITE_PRIVATE int sqlite3BtreeCursor( |
| 9370 | 9408 | Btree*, /* BTree containing table to open */ |
| 9371 | 9409 | int iTable, /* Index of root page */ |
| 9372 | 9410 | int wrFlag, /* 1 for writing. 0 for read-only */ |
| | @@ -9408,10 +9446,13 @@ |
| 9408 | 9446 | SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); |
| 9409 | 9447 | SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *); |
| 9410 | 9448 | SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *); |
| 9411 | 9449 | SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); |
| 9412 | 9450 | SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask); |
| 9451 | +#ifdef SQLITE_DEBUG |
| 9452 | +SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask); |
| 9453 | +#endif |
| 9413 | 9454 | SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt); |
| 9414 | 9455 | SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void); |
| 9415 | 9456 | |
| 9416 | 9457 | #ifndef NDEBUG |
| 9417 | 9458 | SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*); |
| | @@ -10908,10 +10949,11 @@ |
| 10908 | 10949 | } init; |
| 10909 | 10950 | int nVdbeActive; /* Number of VDBEs currently running */ |
| 10910 | 10951 | int nVdbeRead; /* Number of active VDBEs that read or write */ |
| 10911 | 10952 | int nVdbeWrite; /* Number of active VDBEs that read and write */ |
| 10912 | 10953 | int nVdbeExec; /* Number of nested calls to VdbeExec() */ |
| 10954 | + int nVDestroy; /* Number of active OP_VDestroy operations */ |
| 10913 | 10955 | int nExtension; /* Number of loaded extensions */ |
| 10914 | 10956 | void **aExtension; /* Array of shared library handles */ |
| 10915 | 10957 | void (*xTrace)(void*,const char*); /* Trace function */ |
| 10916 | 10958 | void *pTraceArg; /* Argument to the trace function */ |
| 10917 | 10959 | void (*xProfile)(void*,const char*,u64); /* Profiling function */ |
| | @@ -12502,11 +12544,12 @@ |
| 12502 | 12544 | #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ |
| 12503 | 12545 | #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ |
| 12504 | 12546 | #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ |
| 12505 | 12547 | #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ |
| 12506 | 12548 | #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ |
| 12507 | | -#define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */ |
| 12549 | +#define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */ |
| 12550 | +#define OPFLAG_P2ISREG 0x04 /* P2 to OP_Open** is a register number */ |
| 12508 | 12551 | #define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */ |
| 12509 | 12552 | |
| 12510 | 12553 | /* |
| 12511 | 12554 | * Each trigger present in the database schema is stored as an instance of |
| 12512 | 12555 | * struct Trigger. |
| | @@ -12906,14 +12949,19 @@ |
| 12906 | 12949 | SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int); |
| 12907 | 12950 | SQLITE_PRIVATE int sqlite3MutexInit(void); |
| 12908 | 12951 | SQLITE_PRIVATE int sqlite3MutexEnd(void); |
| 12909 | 12952 | #endif |
| 12910 | 12953 | |
| 12911 | | -SQLITE_PRIVATE int sqlite3StatusValue(int); |
| 12912 | | -SQLITE_PRIVATE void sqlite3StatusAdd(int, int); |
| 12954 | +SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int); |
| 12955 | +SQLITE_PRIVATE void sqlite3StatusUp(int, int); |
| 12956 | +SQLITE_PRIVATE void sqlite3StatusDown(int, int); |
| 12913 | 12957 | SQLITE_PRIVATE void sqlite3StatusSet(int, int); |
| 12914 | 12958 | |
| 12959 | +/* Access to mutexes used by sqlite3_status() */ |
| 12960 | +SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void); |
| 12961 | +SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void); |
| 12962 | + |
| 12915 | 12963 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 12916 | 12964 | SQLITE_PRIVATE int sqlite3IsNaN(double); |
| 12917 | 12965 | #else |
| 12918 | 12966 | # define sqlite3IsNaN(X) 0 |
| 12919 | 12967 | #endif |
| | @@ -13289,11 +13337,11 @@ |
| 13289 | 13337 | SQLITE_PRIVATE const char *sqlite3ErrStr(int); |
| 13290 | 13338 | SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse); |
| 13291 | 13339 | SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int); |
| 13292 | 13340 | SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName); |
| 13293 | 13341 | SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr); |
| 13294 | | -SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*); |
| 13342 | +SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int); |
| 13295 | 13343 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*); |
| 13296 | 13344 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*); |
| 13297 | 13345 | SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *); |
| 13298 | 13346 | SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *); |
| 13299 | 13347 | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int); |
| | @@ -13592,11 +13640,11 @@ |
| 13592 | 13640 | ** print I/O tracing messages. |
| 13593 | 13641 | */ |
| 13594 | 13642 | #ifdef SQLITE_ENABLE_IOTRACE |
| 13595 | 13643 | # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } |
| 13596 | 13644 | SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*); |
| 13597 | | -void (*sqlite3IoTrace)(const char*,...); |
| 13645 | +SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...); |
| 13598 | 13646 | #else |
| 13599 | 13647 | # define IOTRACE(A) |
| 13600 | 13648 | # define sqlite3VdbeIOTraceSql(X) |
| 13601 | 13649 | #endif |
| 13602 | 13650 | |
| | @@ -14305,11 +14353,11 @@ |
| 14305 | 14353 | ** was used and false if not. |
| 14306 | 14354 | ** |
| 14307 | 14355 | ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix |
| 14308 | 14356 | ** is not required for a match. |
| 14309 | 14357 | */ |
| 14310 | | -SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ |
| 14358 | +SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){ |
| 14311 | 14359 | int i, n; |
| 14312 | 14360 | |
| 14313 | 14361 | #if SQLITE_ENABLE_API_ARMOR |
| 14314 | 14362 | if( zOptName==0 ){ |
| 14315 | 14363 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -14333,11 +14381,11 @@ |
| 14333 | 14381 | |
| 14334 | 14382 | /* |
| 14335 | 14383 | ** Return the N-th compile-time option string. If N is out of range, |
| 14336 | 14384 | ** return a NULL pointer. |
| 14337 | 14385 | */ |
| 14338 | | -SQLITE_API const char *sqlite3_compileoption_get(int N){ |
| 14386 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){ |
| 14339 | 14387 | if( N>=0 && N<ArraySize(azCompileOpt) ){ |
| 14340 | 14388 | return azCompileOpt[N]; |
| 14341 | 14389 | } |
| 14342 | 14390 | return 0; |
| 14343 | 14391 | } |
| | @@ -14676,18 +14724,10 @@ |
| 14676 | 14724 | ** An instance of the virtual machine. This structure contains the complete |
| 14677 | 14725 | ** state of the virtual machine. |
| 14678 | 14726 | ** |
| 14679 | 14727 | ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() |
| 14680 | 14728 | ** is really a pointer to an instance of this structure. |
| 14681 | | -** |
| 14682 | | -** The Vdbe.inVtabMethod variable is set to non-zero for the duration of |
| 14683 | | -** any virtual table method invocations made by the vdbe program. It is |
| 14684 | | -** set to 2 for xDestroy method calls and 1 for all other methods. This |
| 14685 | | -** variable is used for two purposes: to allow xDestroy methods to execute |
| 14686 | | -** "DROP TABLE" statements and to prevent some nasty side effects of |
| 14687 | | -** malloc failure when SQLite is invoked recursively by a virtual table |
| 14688 | | -** method function. |
| 14689 | 14729 | */ |
| 14690 | 14730 | struct Vdbe { |
| 14691 | 14731 | sqlite3 *db; /* The database connection that owns this statement */ |
| 14692 | 14732 | Op *aOp; /* Space to hold the virtual machine's program */ |
| 14693 | 14733 | Mem *aMem; /* The memory locations */ |
| | @@ -14714,11 +14754,10 @@ |
| 14714 | 14754 | #endif |
| 14715 | 14755 | u16 nResColumn; /* Number of columns in one row of the result set */ |
| 14716 | 14756 | u8 errorAction; /* Recovery action to do in case of an error */ |
| 14717 | 14757 | u8 minWriteFileFormat; /* Minimum file format for writable database files */ |
| 14718 | 14758 | bft explain:2; /* True if EXPLAIN present on SQL command */ |
| 14719 | | - bft inVtabMethod:2; /* See comments above */ |
| 14720 | 14759 | bft changeCntOn:1; /* True to update the change-counter */ |
| 14721 | 14760 | bft expired:1; /* True if the VM needs to be recompiled */ |
| 14722 | 14761 | bft runOnlyOnce:1; /* Automatically expire on reset */ |
| 14723 | 14762 | bft usesStmtJournal:1; /* True if uses a statement journal */ |
| 14724 | 14763 | bft readOnly:1; /* True for statements that do not write */ |
| | @@ -14874,13 +14913,35 @@ |
| 14874 | 14913 | /* |
| 14875 | 14914 | ** Variables in which to record status information. |
| 14876 | 14915 | */ |
| 14877 | 14916 | typedef struct sqlite3StatType sqlite3StatType; |
| 14878 | 14917 | static SQLITE_WSD struct sqlite3StatType { |
| 14879 | | - int nowValue[10]; /* Current value */ |
| 14880 | | - int mxValue[10]; /* Maximum value */ |
| 14918 | +#if SQLITE_PTRSIZE>4 |
| 14919 | + sqlite3_int64 nowValue[10]; /* Current value */ |
| 14920 | + sqlite3_int64 mxValue[10]; /* Maximum value */ |
| 14921 | +#else |
| 14922 | + u32 nowValue[10]; /* Current value */ |
| 14923 | + u32 mxValue[10]; /* Maximum value */ |
| 14924 | +#endif |
| 14881 | 14925 | } sqlite3Stat = { {0,}, {0,} }; |
| 14926 | + |
| 14927 | +/* |
| 14928 | +** Elements of sqlite3Stat[] are protected by either the memory allocator |
| 14929 | +** mutex, or by the pcache1 mutex. The following array determines which. |
| 14930 | +*/ |
| 14931 | +static const char statMutex[] = { |
| 14932 | + 0, /* SQLITE_STATUS_MEMORY_USED */ |
| 14933 | + 1, /* SQLITE_STATUS_PAGECACHE_USED */ |
| 14934 | + 1, /* SQLITE_STATUS_PAGECACHE_OVERFLOW */ |
| 14935 | + 0, /* SQLITE_STATUS_SCRATCH_USED */ |
| 14936 | + 0, /* SQLITE_STATUS_SCRATCH_OVERFLOW */ |
| 14937 | + 0, /* SQLITE_STATUS_MALLOC_SIZE */ |
| 14938 | + 0, /* SQLITE_STATUS_PARSER_STACK */ |
| 14939 | + 1, /* SQLITE_STATUS_PAGECACHE_SIZE */ |
| 14940 | + 0, /* SQLITE_STATUS_SCRATCH_SIZE */ |
| 14941 | + 0, /* SQLITE_STATUS_MALLOC_COUNT */ |
| 14942 | +}; |
| 14882 | 14943 | |
| 14883 | 14944 | |
| 14884 | 14945 | /* The "wsdStat" macro will resolve to the status information |
| 14885 | 14946 | ** state vector. If writable static data is unsupported on the target, |
| 14886 | 14947 | ** we have to locate the state vector at run-time. In the more common |
| | @@ -14894,70 +14955,116 @@ |
| 14894 | 14955 | # define wsdStatInit |
| 14895 | 14956 | # define wsdStat sqlite3Stat |
| 14896 | 14957 | #endif |
| 14897 | 14958 | |
| 14898 | 14959 | /* |
| 14899 | | -** Return the current value of a status parameter. |
| 14960 | +** Return the current value of a status parameter. The caller must |
| 14961 | +** be holding the appropriate mutex. |
| 14900 | 14962 | */ |
| 14901 | | -SQLITE_PRIVATE int sqlite3StatusValue(int op){ |
| 14963 | +SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){ |
| 14902 | 14964 | wsdStatInit; |
| 14903 | 14965 | assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); |
| 14966 | + assert( op>=0 && op<ArraySize(statMutex) ); |
| 14967 | + assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex() |
| 14968 | + : sqlite3MallocMutex()) ); |
| 14904 | 14969 | return wsdStat.nowValue[op]; |
| 14905 | 14970 | } |
| 14906 | 14971 | |
| 14907 | 14972 | /* |
| 14908 | | -** Add N to the value of a status record. It is assumed that the |
| 14909 | | -** caller holds appropriate locks. |
| 14973 | +** Add N to the value of a status record. The caller must hold the |
| 14974 | +** appropriate mutex. (Locking is checked by assert()). |
| 14975 | +** |
| 14976 | +** The StatusUp() routine can accept positive or negative values for N. |
| 14977 | +** The value of N is added to the current status value and the high-water |
| 14978 | +** mark is adjusted if necessary. |
| 14979 | +** |
| 14980 | +** The StatusDown() routine lowers the current value by N. The highwater |
| 14981 | +** mark is unchanged. N must be non-negative for StatusDown(). |
| 14910 | 14982 | */ |
| 14911 | | -SQLITE_PRIVATE void sqlite3StatusAdd(int op, int N){ |
| 14983 | +SQLITE_PRIVATE void sqlite3StatusUp(int op, int N){ |
| 14912 | 14984 | wsdStatInit; |
| 14913 | 14985 | assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); |
| 14986 | + assert( op>=0 && op<ArraySize(statMutex) ); |
| 14987 | + assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex() |
| 14988 | + : sqlite3MallocMutex()) ); |
| 14914 | 14989 | wsdStat.nowValue[op] += N; |
| 14915 | 14990 | if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){ |
| 14916 | 14991 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; |
| 14917 | 14992 | } |
| 14918 | 14993 | } |
| 14994 | +SQLITE_PRIVATE void sqlite3StatusDown(int op, int N){ |
| 14995 | + wsdStatInit; |
| 14996 | + assert( N>=0 ); |
| 14997 | + assert( op>=0 && op<ArraySize(statMutex) ); |
| 14998 | + assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex() |
| 14999 | + : sqlite3MallocMutex()) ); |
| 15000 | + assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); |
| 15001 | + wsdStat.nowValue[op] -= N; |
| 15002 | +} |
| 14919 | 15003 | |
| 14920 | 15004 | /* |
| 14921 | | -** Set the value of a status to X. |
| 15005 | +** Set the value of a status to X. The highwater mark is adjusted if |
| 15006 | +** necessary. The caller must hold the appropriate mutex. |
| 14922 | 15007 | */ |
| 14923 | 15008 | SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){ |
| 14924 | 15009 | wsdStatInit; |
| 14925 | 15010 | assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); |
| 15011 | + assert( op>=0 && op<ArraySize(statMutex) ); |
| 15012 | + assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex() |
| 15013 | + : sqlite3MallocMutex()) ); |
| 14926 | 15014 | wsdStat.nowValue[op] = X; |
| 14927 | 15015 | if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){ |
| 14928 | 15016 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; |
| 14929 | 15017 | } |
| 14930 | 15018 | } |
| 14931 | 15019 | |
| 14932 | 15020 | /* |
| 14933 | 15021 | ** Query status information. |
| 14934 | | -** |
| 14935 | | -** This implementation assumes that reading or writing an aligned |
| 14936 | | -** 32-bit integer is an atomic operation. If that assumption is not true, |
| 14937 | | -** then this routine is not threadsafe. |
| 14938 | 15022 | */ |
| 14939 | | -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ |
| 15023 | +SQLITE_API int SQLITE_STDCALL sqlite3_status64( |
| 15024 | + int op, |
| 15025 | + sqlite3_int64 *pCurrent, |
| 15026 | + sqlite3_int64 *pHighwater, |
| 15027 | + int resetFlag |
| 15028 | +){ |
| 15029 | + sqlite3_mutex *pMutex; |
| 14940 | 15030 | wsdStatInit; |
| 14941 | 15031 | if( op<0 || op>=ArraySize(wsdStat.nowValue) ){ |
| 14942 | 15032 | return SQLITE_MISUSE_BKPT; |
| 14943 | 15033 | } |
| 14944 | 15034 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 14945 | 15035 | if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT; |
| 14946 | 15036 | #endif |
| 15037 | + pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex(); |
| 15038 | + sqlite3_mutex_enter(pMutex); |
| 14947 | 15039 | *pCurrent = wsdStat.nowValue[op]; |
| 14948 | 15040 | *pHighwater = wsdStat.mxValue[op]; |
| 14949 | 15041 | if( resetFlag ){ |
| 14950 | 15042 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; |
| 14951 | 15043 | } |
| 15044 | + sqlite3_mutex_leave(pMutex); |
| 15045 | + (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */ |
| 14952 | 15046 | return SQLITE_OK; |
| 15047 | +} |
| 15048 | +SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ |
| 15049 | + sqlite3_int64 iCur, iHwtr; |
| 15050 | + int rc; |
| 15051 | +#ifdef SQLITE_ENABLE_API_ARMOR |
| 15052 | + if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT; |
| 15053 | +#endif |
| 15054 | + rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag); |
| 15055 | + if( rc==0 ){ |
| 15056 | + *pCurrent = (int)iCur; |
| 15057 | + *pHighwater = (int)iHwtr; |
| 15058 | + } |
| 15059 | + return rc; |
| 14953 | 15060 | } |
| 14954 | 15061 | |
| 14955 | 15062 | /* |
| 14956 | 15063 | ** Query status information for a single database connection |
| 14957 | 15064 | */ |
| 14958 | | -SQLITE_API int sqlite3_db_status( |
| 15065 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_status( |
| 14959 | 15066 | sqlite3 *db, /* The database connection whose status is desired */ |
| 14960 | 15067 | int op, /* Status verb */ |
| 14961 | 15068 | int *pCurrent, /* Write current value here */ |
| 14962 | 15069 | int *pHighwater, /* Write high-water mark here */ |
| 14963 | 15070 | int resetFlag /* Reset high-water mark if true */ |
| | @@ -16577,11 +16684,11 @@ |
| 16577 | 16684 | |
| 16578 | 16685 | /* |
| 16579 | 16686 | ** Locate a VFS by name. If no name is given, simply return the |
| 16580 | 16687 | ** first VFS on the list. |
| 16581 | 16688 | */ |
| 16582 | | -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){ |
| 16689 | +SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){ |
| 16583 | 16690 | sqlite3_vfs *pVfs = 0; |
| 16584 | 16691 | #if SQLITE_THREADSAFE |
| 16585 | 16692 | sqlite3_mutex *mutex; |
| 16586 | 16693 | #endif |
| 16587 | 16694 | #ifndef SQLITE_OMIT_AUTOINIT |
| | @@ -16623,11 +16730,11 @@ |
| 16623 | 16730 | /* |
| 16624 | 16731 | ** Register a VFS with the system. It is harmless to register the same |
| 16625 | 16732 | ** VFS multiple times. The new VFS becomes the default if makeDflt is |
| 16626 | 16733 | ** true. |
| 16627 | 16734 | */ |
| 16628 | | -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ |
| 16735 | +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ |
| 16629 | 16736 | MUTEX_LOGIC(sqlite3_mutex *mutex;) |
| 16630 | 16737 | #ifndef SQLITE_OMIT_AUTOINIT |
| 16631 | 16738 | int rc = sqlite3_initialize(); |
| 16632 | 16739 | if( rc ) return rc; |
| 16633 | 16740 | #endif |
| | @@ -16651,11 +16758,11 @@ |
| 16651 | 16758 | } |
| 16652 | 16759 | |
| 16653 | 16760 | /* |
| 16654 | 16761 | ** Unregister a VFS so that it is no longer accessible. |
| 16655 | 16762 | */ |
| 16656 | | -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){ |
| 16763 | +SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){ |
| 16657 | 16764 | #if SQLITE_THREADSAFE |
| 16658 | 16765 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); |
| 16659 | 16766 | #endif |
| 16660 | 16767 | sqlite3_mutex_enter(mutex); |
| 16661 | 16768 | vfsUnlink(pVfs); |
| | @@ -18987,11 +19094,11 @@ |
| 18987 | 19094 | } |
| 18988 | 19095 | |
| 18989 | 19096 | /* |
| 18990 | 19097 | ** Retrieve a pointer to a static mutex or allocate a new dynamic one. |
| 18991 | 19098 | */ |
| 18992 | | -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){ |
| 19099 | +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){ |
| 18993 | 19100 | #ifndef SQLITE_OMIT_AUTOINIT |
| 18994 | 19101 | if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0; |
| 18995 | 19102 | if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0; |
| 18996 | 19103 | #endif |
| 18997 | 19104 | return sqlite3GlobalConfig.mutex.xMutexAlloc(id); |
| | @@ -19006,31 +19113,31 @@ |
| 19006 | 19113 | } |
| 19007 | 19114 | |
| 19008 | 19115 | /* |
| 19009 | 19116 | ** Free a dynamic mutex. |
| 19010 | 19117 | */ |
| 19011 | | -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){ |
| 19118 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){ |
| 19012 | 19119 | if( p ){ |
| 19013 | 19120 | sqlite3GlobalConfig.mutex.xMutexFree(p); |
| 19014 | 19121 | } |
| 19015 | 19122 | } |
| 19016 | 19123 | |
| 19017 | 19124 | /* |
| 19018 | 19125 | ** Obtain the mutex p. If some other thread already has the mutex, block |
| 19019 | 19126 | ** until it can be obtained. |
| 19020 | 19127 | */ |
| 19021 | | -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){ |
| 19128 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){ |
| 19022 | 19129 | if( p ){ |
| 19023 | 19130 | sqlite3GlobalConfig.mutex.xMutexEnter(p); |
| 19024 | 19131 | } |
| 19025 | 19132 | } |
| 19026 | 19133 | |
| 19027 | 19134 | /* |
| 19028 | 19135 | ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another |
| 19029 | 19136 | ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. |
| 19030 | 19137 | */ |
| 19031 | | -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){ |
| 19138 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){ |
| 19032 | 19139 | int rc = SQLITE_OK; |
| 19033 | 19140 | if( p ){ |
| 19034 | 19141 | return sqlite3GlobalConfig.mutex.xMutexTry(p); |
| 19035 | 19142 | } |
| 19036 | 19143 | return rc; |
| | @@ -19040,11 +19147,11 @@ |
| 19040 | 19147 | ** The sqlite3_mutex_leave() routine exits a mutex that was previously |
| 19041 | 19148 | ** entered by the same thread. The behavior is undefined if the mutex |
| 19042 | 19149 | ** is not currently entered. If a NULL pointer is passed as an argument |
| 19043 | 19150 | ** this function is a no-op. |
| 19044 | 19151 | */ |
| 19045 | | -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){ |
| 19152 | +SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){ |
| 19046 | 19153 | if( p ){ |
| 19047 | 19154 | sqlite3GlobalConfig.mutex.xMutexLeave(p); |
| 19048 | 19155 | } |
| 19049 | 19156 | } |
| 19050 | 19157 | |
| | @@ -19051,14 +19158,14 @@ |
| 19051 | 19158 | #ifndef NDEBUG |
| 19052 | 19159 | /* |
| 19053 | 19160 | ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are |
| 19054 | 19161 | ** intended for use inside assert() statements. |
| 19055 | 19162 | */ |
| 19056 | | -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){ |
| 19163 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){ |
| 19057 | 19164 | return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p); |
| 19058 | 19165 | } |
| 19059 | | -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){ |
| 19166 | +SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){ |
| 19060 | 19167 | return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p); |
| 19061 | 19168 | } |
| 19062 | 19169 | #endif |
| 19063 | 19170 | |
| 19064 | 19171 | #endif /* !defined(SQLITE_MUTEX_OMIT) */ |
| | @@ -20050,12 +20157,12 @@ |
| 20050 | 20157 | ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the |
| 20051 | 20158 | ** "interlocked" magic used here is probably not strictly necessary. |
| 20052 | 20159 | */ |
| 20053 | 20160 | static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0; |
| 20054 | 20161 | |
| 20055 | | -SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */ |
| 20056 | | -SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ |
| 20162 | +SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */ |
| 20163 | +SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ |
| 20057 | 20164 | |
| 20058 | 20165 | static int winMutexInit(void){ |
| 20059 | 20166 | /* The first to increment to 1 does actual initialization */ |
| 20060 | 20167 | if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){ |
| 20061 | 20168 | int i; |
| | @@ -20347,11 +20454,11 @@ |
| 20347 | 20454 | /* |
| 20348 | 20455 | ** Attempt to release up to n bytes of non-essential memory currently |
| 20349 | 20456 | ** held by SQLite. An example of non-essential memory is memory used to |
| 20350 | 20457 | ** cache database pages that are not currently in use. |
| 20351 | 20458 | */ |
| 20352 | | -SQLITE_API int sqlite3_release_memory(int n){ |
| 20459 | +SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){ |
| 20353 | 20460 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 20354 | 20461 | return sqlite3PcacheReleaseMemory(n); |
| 20355 | 20462 | #else |
| 20356 | 20463 | /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine |
| 20357 | 20464 | ** is a no-op returning zero if SQLite is not compiled with |
| | @@ -20401,10 +20508,17 @@ |
| 20401 | 20508 | */ |
| 20402 | 20509 | int nearlyFull; |
| 20403 | 20510 | } mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 20404 | 20511 | |
| 20405 | 20512 | #define mem0 GLOBAL(struct Mem0Global, mem0) |
| 20513 | + |
| 20514 | +/* |
| 20515 | +** Return the memory allocator mutex. sqlite3_status() needs it. |
| 20516 | +*/ |
| 20517 | +SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){ |
| 20518 | + return mem0.mutex; |
| 20519 | +} |
| 20406 | 20520 | |
| 20407 | 20521 | /* |
| 20408 | 20522 | ** This routine runs when the memory allocator sees that the |
| 20409 | 20523 | ** total memory allocation is about to exceed the soft heap |
| 20410 | 20524 | ** limit. |
| | @@ -20424,11 +20538,11 @@ |
| 20424 | 20538 | static int sqlite3MemoryAlarm( |
| 20425 | 20539 | void(*xCallback)(void *pArg, sqlite3_int64 used,int N), |
| 20426 | 20540 | void *pArg, |
| 20427 | 20541 | sqlite3_int64 iThreshold |
| 20428 | 20542 | ){ |
| 20429 | | - int nUsed; |
| 20543 | + sqlite3_int64 nUsed; |
| 20430 | 20544 | sqlite3_mutex_enter(mem0.mutex); |
| 20431 | 20545 | mem0.alarmCallback = xCallback; |
| 20432 | 20546 | mem0.alarmArg = pArg; |
| 20433 | 20547 | mem0.alarmThreshold = iThreshold; |
| 20434 | 20548 | nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| | @@ -20440,11 +20554,11 @@ |
| 20440 | 20554 | #ifndef SQLITE_OMIT_DEPRECATED |
| 20441 | 20555 | /* |
| 20442 | 20556 | ** Deprecated external interface. Internal/core SQLite code |
| 20443 | 20557 | ** should call sqlite3MemoryAlarm. |
| 20444 | 20558 | */ |
| 20445 | | -SQLITE_API int sqlite3_memory_alarm( |
| 20559 | +SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm( |
| 20446 | 20560 | void(*xCallback)(void *pArg, sqlite3_int64 used,int N), |
| 20447 | 20561 | void *pArg, |
| 20448 | 20562 | sqlite3_int64 iThreshold |
| 20449 | 20563 | ){ |
| 20450 | 20564 | return sqlite3MemoryAlarm(xCallback, pArg, iThreshold); |
| | @@ -20453,11 +20567,11 @@ |
| 20453 | 20567 | |
| 20454 | 20568 | /* |
| 20455 | 20569 | ** Set the soft heap-size limit for the library. Passing a zero or |
| 20456 | 20570 | ** negative value indicates no limit. |
| 20457 | 20571 | */ |
| 20458 | | -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ |
| 20572 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){ |
| 20459 | 20573 | sqlite3_int64 priorLimit; |
| 20460 | 20574 | sqlite3_int64 excess; |
| 20461 | 20575 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20462 | 20576 | int rc = sqlite3_initialize(); |
| 20463 | 20577 | if( rc ) return -1; |
| | @@ -20473,19 +20587,20 @@ |
| 20473 | 20587 | } |
| 20474 | 20588 | excess = sqlite3_memory_used() - n; |
| 20475 | 20589 | if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff)); |
| 20476 | 20590 | return priorLimit; |
| 20477 | 20591 | } |
| 20478 | | -SQLITE_API void sqlite3_soft_heap_limit(int n){ |
| 20592 | +SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){ |
| 20479 | 20593 | if( n<0 ) n = 0; |
| 20480 | 20594 | sqlite3_soft_heap_limit64(n); |
| 20481 | 20595 | } |
| 20482 | 20596 | |
| 20483 | 20597 | /* |
| 20484 | 20598 | ** Initialize the memory allocation subsystem. |
| 20485 | 20599 | */ |
| 20486 | 20600 | SQLITE_PRIVATE int sqlite3MallocInit(void){ |
| 20601 | + int rc; |
| 20487 | 20602 | if( sqlite3GlobalConfig.m.xMalloc==0 ){ |
| 20488 | 20603 | sqlite3MemSetDefault(); |
| 20489 | 20604 | } |
| 20490 | 20605 | memset(&mem0, 0, sizeof(mem0)); |
| 20491 | 20606 | if( sqlite3GlobalConfig.bCoreMutex ){ |
| | @@ -20517,11 +20632,13 @@ |
| 20517 | 20632 | || sqlite3GlobalConfig.nPage<1 ){ |
| 20518 | 20633 | sqlite3GlobalConfig.pPage = 0; |
| 20519 | 20634 | sqlite3GlobalConfig.szPage = 0; |
| 20520 | 20635 | sqlite3GlobalConfig.nPage = 0; |
| 20521 | 20636 | } |
| 20522 | | - return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); |
| 20637 | + rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); |
| 20638 | + if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0)); |
| 20639 | + return rc; |
| 20523 | 20640 | } |
| 20524 | 20641 | |
| 20525 | 20642 | /* |
| 20526 | 20643 | ** Return true if the heap is currently under memory pressure - in other |
| 20527 | 20644 | ** words if the amount of heap used is close to the limit set by |
| | @@ -20542,11 +20659,11 @@ |
| 20542 | 20659 | } |
| 20543 | 20660 | |
| 20544 | 20661 | /* |
| 20545 | 20662 | ** Return the amount of memory currently checked out. |
| 20546 | 20663 | */ |
| 20547 | | -SQLITE_API sqlite3_int64 sqlite3_memory_used(void){ |
| 20664 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){ |
| 20548 | 20665 | int n, mx; |
| 20549 | 20666 | sqlite3_int64 res; |
| 20550 | 20667 | sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0); |
| 20551 | 20668 | res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */ |
| 20552 | 20669 | return res; |
| | @@ -20555,11 +20672,11 @@ |
| 20555 | 20672 | /* |
| 20556 | 20673 | ** Return the maximum amount of memory that has ever been |
| 20557 | 20674 | ** checked out since either the beginning of this process |
| 20558 | 20675 | ** or since the most recent reset. |
| 20559 | 20676 | */ |
| 20560 | | -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){ |
| 20677 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){ |
| 20561 | 20678 | int n, mx; |
| 20562 | 20679 | sqlite3_int64 res; |
| 20563 | 20680 | sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag); |
| 20564 | 20681 | res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */ |
| 20565 | 20682 | return res; |
| | @@ -20593,11 +20710,11 @@ |
| 20593 | 20710 | void *p; |
| 20594 | 20711 | assert( sqlite3_mutex_held(mem0.mutex) ); |
| 20595 | 20712 | nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 20596 | 20713 | sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); |
| 20597 | 20714 | if( mem0.alarmCallback!=0 ){ |
| 20598 | | - int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20715 | + sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20599 | 20716 | if( nUsed >= mem0.alarmThreshold - nFull ){ |
| 20600 | 20717 | mem0.nearlyFull = 1; |
| 20601 | 20718 | sqlite3MallocAlarm(nFull); |
| 20602 | 20719 | }else{ |
| 20603 | 20720 | mem0.nearlyFull = 0; |
| | @@ -20610,12 +20727,12 @@ |
| 20610 | 20727 | p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| 20611 | 20728 | } |
| 20612 | 20729 | #endif |
| 20613 | 20730 | if( p ){ |
| 20614 | 20731 | nFull = sqlite3MallocSize(p); |
| 20615 | | - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull); |
| 20616 | | - sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 20732 | + sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull); |
| 20733 | + sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 20617 | 20734 | } |
| 20618 | 20735 | *pp = p; |
| 20619 | 20736 | return nFull; |
| 20620 | 20737 | } |
| 20621 | 20738 | |
| | @@ -20646,17 +20763,17 @@ |
| 20646 | 20763 | /* |
| 20647 | 20764 | ** This version of the memory allocation is for use by the application. |
| 20648 | 20765 | ** First make sure the memory subsystem is initialized, then do the |
| 20649 | 20766 | ** allocation. |
| 20650 | 20767 | */ |
| 20651 | | -SQLITE_API void *sqlite3_malloc(int n){ |
| 20768 | +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){ |
| 20652 | 20769 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20653 | 20770 | if( sqlite3_initialize() ) return 0; |
| 20654 | 20771 | #endif |
| 20655 | 20772 | return n<=0 ? 0 : sqlite3Malloc(n); |
| 20656 | 20773 | } |
| 20657 | | -SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){ |
| 20774 | +SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){ |
| 20658 | 20775 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20659 | 20776 | if( sqlite3_initialize() ) return 0; |
| 20660 | 20777 | #endif |
| 20661 | 20778 | return sqlite3Malloc(n); |
| 20662 | 20779 | } |
| | @@ -20688,18 +20805,18 @@ |
| 20688 | 20805 | sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n); |
| 20689 | 20806 | if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){ |
| 20690 | 20807 | p = mem0.pScratchFree; |
| 20691 | 20808 | mem0.pScratchFree = mem0.pScratchFree->pNext; |
| 20692 | 20809 | mem0.nScratchFree--; |
| 20693 | | - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1); |
| 20810 | + sqlite3StatusUp(SQLITE_STATUS_SCRATCH_USED, 1); |
| 20694 | 20811 | sqlite3_mutex_leave(mem0.mutex); |
| 20695 | 20812 | }else{ |
| 20696 | 20813 | sqlite3_mutex_leave(mem0.mutex); |
| 20697 | 20814 | p = sqlite3Malloc(n); |
| 20698 | 20815 | if( sqlite3GlobalConfig.bMemstat && p ){ |
| 20699 | 20816 | sqlite3_mutex_enter(mem0.mutex); |
| 20700 | | - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p)); |
| 20817 | + sqlite3StatusUp(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p)); |
| 20701 | 20818 | sqlite3_mutex_leave(mem0.mutex); |
| 20702 | 20819 | } |
| 20703 | 20820 | sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH); |
| 20704 | 20821 | } |
| 20705 | 20822 | assert( sqlite3_mutex_notheld(mem0.mutex) ); |
| | @@ -20736,23 +20853,23 @@ |
| 20736 | 20853 | sqlite3_mutex_enter(mem0.mutex); |
| 20737 | 20854 | pSlot->pNext = mem0.pScratchFree; |
| 20738 | 20855 | mem0.pScratchFree = pSlot; |
| 20739 | 20856 | mem0.nScratchFree++; |
| 20740 | 20857 | assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch ); |
| 20741 | | - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1); |
| 20858 | + sqlite3StatusDown(SQLITE_STATUS_SCRATCH_USED, 1); |
| 20742 | 20859 | sqlite3_mutex_leave(mem0.mutex); |
| 20743 | 20860 | }else{ |
| 20744 | 20861 | /* Release memory back to the heap */ |
| 20745 | 20862 | assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) ); |
| 20746 | | - assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) ); |
| 20863 | + assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) ); |
| 20747 | 20864 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 20748 | 20865 | if( sqlite3GlobalConfig.bMemstat ){ |
| 20749 | 20866 | int iSize = sqlite3MallocSize(p); |
| 20750 | 20867 | sqlite3_mutex_enter(mem0.mutex); |
| 20751 | | - sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize); |
| 20752 | | - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize); |
| 20753 | | - sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); |
| 20868 | + sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize); |
| 20869 | + sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize); |
| 20870 | + sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 20754 | 20871 | sqlite3GlobalConfig.m.xFree(p); |
| 20755 | 20872 | sqlite3_mutex_leave(mem0.mutex); |
| 20756 | 20873 | }else{ |
| 20757 | 20874 | sqlite3GlobalConfig.m.xFree(p); |
| 20758 | 20875 | } |
| | @@ -20779,41 +20896,41 @@ |
| 20779 | 20896 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 20780 | 20897 | return sqlite3GlobalConfig.m.xSize(p); |
| 20781 | 20898 | } |
| 20782 | 20899 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ |
| 20783 | 20900 | if( db==0 ){ |
| 20784 | | - assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) ); |
| 20901 | + assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 20785 | 20902 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 20786 | 20903 | return sqlite3MallocSize(p); |
| 20787 | 20904 | }else{ |
| 20788 | 20905 | assert( sqlite3_mutex_held(db->mutex) ); |
| 20789 | 20906 | if( isLookaside(db, p) ){ |
| 20790 | 20907 | return db->lookaside.sz; |
| 20791 | 20908 | }else{ |
| 20792 | 20909 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20793 | | - assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20910 | + assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20794 | 20911 | return sqlite3GlobalConfig.m.xSize(p); |
| 20795 | 20912 | } |
| 20796 | 20913 | } |
| 20797 | 20914 | } |
| 20798 | | -SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){ |
| 20799 | | - assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) ); |
| 20915 | +SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){ |
| 20916 | + assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 20800 | 20917 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 20801 | 20918 | return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p); |
| 20802 | 20919 | } |
| 20803 | 20920 | |
| 20804 | 20921 | /* |
| 20805 | 20922 | ** Free memory previously obtained from sqlite3Malloc(). |
| 20806 | 20923 | */ |
| 20807 | | -SQLITE_API void sqlite3_free(void *p){ |
| 20924 | +SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){ |
| 20808 | 20925 | if( p==0 ) return; /* IMP: R-49053-54554 */ |
| 20809 | 20926 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 20810 | | - assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) ); |
| 20927 | + assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 20811 | 20928 | if( sqlite3GlobalConfig.bMemstat ){ |
| 20812 | 20929 | sqlite3_mutex_enter(mem0.mutex); |
| 20813 | | - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p)); |
| 20814 | | - sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1); |
| 20930 | + sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p)); |
| 20931 | + sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1); |
| 20815 | 20932 | sqlite3GlobalConfig.m.xFree(p); |
| 20816 | 20933 | sqlite3_mutex_leave(mem0.mutex); |
| 20817 | 20934 | }else{ |
| 20818 | 20935 | sqlite3GlobalConfig.m.xFree(p); |
| 20819 | 20936 | } |
| | @@ -20850,11 +20967,11 @@ |
| 20850 | 20967 | db->lookaside.nOut--; |
| 20851 | 20968 | return; |
| 20852 | 20969 | } |
| 20853 | 20970 | } |
| 20854 | 20971 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20855 | | - assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20972 | + assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 20856 | 20973 | assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); |
| 20857 | 20974 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 20858 | 20975 | sqlite3_free(p); |
| 20859 | 20976 | } |
| 20860 | 20977 | |
| | @@ -20863,11 +20980,11 @@ |
| 20863 | 20980 | */ |
| 20864 | 20981 | SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){ |
| 20865 | 20982 | int nOld, nNew, nDiff; |
| 20866 | 20983 | void *pNew; |
| 20867 | 20984 | assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) ); |
| 20868 | | - assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) ); |
| 20985 | + assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) ); |
| 20869 | 20986 | if( pOld==0 ){ |
| 20870 | 20987 | return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */ |
| 20871 | 20988 | } |
| 20872 | 20989 | if( nBytes==0 ){ |
| 20873 | 20990 | sqlite3_free(pOld); /* IMP: R-26507-47431 */ |
| | @@ -20897,11 +21014,11 @@ |
| 20897 | 21014 | sqlite3MallocAlarm((int)nBytes); |
| 20898 | 21015 | pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); |
| 20899 | 21016 | } |
| 20900 | 21017 | if( pNew ){ |
| 20901 | 21018 | nNew = sqlite3MallocSize(pNew); |
| 20902 | | - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld); |
| 21019 | + sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld); |
| 20903 | 21020 | } |
| 20904 | 21021 | sqlite3_mutex_leave(mem0.mutex); |
| 20905 | 21022 | }else{ |
| 20906 | 21023 | pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); |
| 20907 | 21024 | } |
| | @@ -20911,18 +21028,18 @@ |
| 20911 | 21028 | |
| 20912 | 21029 | /* |
| 20913 | 21030 | ** The public interface to sqlite3Realloc. Make sure that the memory |
| 20914 | 21031 | ** subsystem is initialized prior to invoking sqliteRealloc. |
| 20915 | 21032 | */ |
| 20916 | | -SQLITE_API void *sqlite3_realloc(void *pOld, int n){ |
| 21033 | +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){ |
| 20917 | 21034 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20918 | 21035 | if( sqlite3_initialize() ) return 0; |
| 20919 | 21036 | #endif |
| 20920 | 21037 | if( n<0 ) n = 0; /* IMP: R-26507-47431 */ |
| 20921 | 21038 | return sqlite3Realloc(pOld, n); |
| 20922 | 21039 | } |
| 20923 | | -SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){ |
| 21040 | +SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){ |
| 20924 | 21041 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20925 | 21042 | if( sqlite3_initialize() ) return 0; |
| 20926 | 21043 | #endif |
| 20927 | 21044 | return sqlite3Realloc(pOld, n); |
| 20928 | 21045 | } |
| | @@ -21030,11 +21147,11 @@ |
| 21030 | 21147 | memcpy(pNew, p, db->lookaside.sz); |
| 21031 | 21148 | sqlite3DbFree(db, p); |
| 21032 | 21149 | } |
| 21033 | 21150 | }else{ |
| 21034 | 21151 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 21035 | | - assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 21152 | + assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 21036 | 21153 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 21037 | 21154 | pNew = sqlite3_realloc64(p, n); |
| 21038 | 21155 | if( !pNew ){ |
| 21039 | 21156 | db->mallocFailed = 1; |
| 21040 | 21157 | } |
| | @@ -22084,11 +22201,11 @@ |
| 22084 | 22201 | |
| 22085 | 22202 | /* |
| 22086 | 22203 | ** Print into memory obtained from sqlite3_malloc(). Omit the internal |
| 22087 | 22204 | ** %-conversion extensions. |
| 22088 | 22205 | */ |
| 22089 | | -SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){ |
| 22206 | +SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){ |
| 22090 | 22207 | char *z; |
| 22091 | 22208 | char zBase[SQLITE_PRINT_BUF_SIZE]; |
| 22092 | 22209 | StrAccum acc; |
| 22093 | 22210 | |
| 22094 | 22211 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -22109,11 +22226,11 @@ |
| 22109 | 22226 | |
| 22110 | 22227 | /* |
| 22111 | 22228 | ** Print into memory obtained from sqlite3_malloc()(). Omit the internal |
| 22112 | 22229 | ** %-conversion extensions. |
| 22113 | 22230 | */ |
| 22114 | | -SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){ |
| 22231 | +SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){ |
| 22115 | 22232 | va_list ap; |
| 22116 | 22233 | char *z; |
| 22117 | 22234 | #ifndef SQLITE_OMIT_AUTOINIT |
| 22118 | 22235 | if( sqlite3_initialize() ) return 0; |
| 22119 | 22236 | #endif |
| | @@ -22134,11 +22251,11 @@ |
| 22134 | 22251 | ** this without breaking compatibility, so we just have to live with the |
| 22135 | 22252 | ** mistake. |
| 22136 | 22253 | ** |
| 22137 | 22254 | ** sqlite3_vsnprintf() is the varargs version. |
| 22138 | 22255 | */ |
| 22139 | | -SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){ |
| 22256 | +SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){ |
| 22140 | 22257 | StrAccum acc; |
| 22141 | 22258 | if( n<=0 ) return zBuf; |
| 22142 | 22259 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 22143 | 22260 | if( zBuf==0 || zFormat==0 ) { |
| 22144 | 22261 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -22149,11 +22266,11 @@ |
| 22149 | 22266 | sqlite3StrAccumInit(&acc, zBuf, n, 0); |
| 22150 | 22267 | acc.useMalloc = 0; |
| 22151 | 22268 | sqlite3VXPrintf(&acc, 0, zFormat, ap); |
| 22152 | 22269 | return sqlite3StrAccumFinish(&acc); |
| 22153 | 22270 | } |
| 22154 | | -SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ |
| 22271 | +SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ |
| 22155 | 22272 | char *z; |
| 22156 | 22273 | va_list ap; |
| 22157 | 22274 | va_start(ap,zFormat); |
| 22158 | 22275 | z = sqlite3_vsnprintf(n, zBuf, zFormat, ap); |
| 22159 | 22276 | va_end(ap); |
| | @@ -22181,11 +22298,11 @@ |
| 22181 | 22298 | } |
| 22182 | 22299 | |
| 22183 | 22300 | /* |
| 22184 | 22301 | ** Format and write a message to the log if logging is enabled. |
| 22185 | 22302 | */ |
| 22186 | | -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){ |
| 22303 | +SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){ |
| 22187 | 22304 | va_list ap; /* Vararg list */ |
| 22188 | 22305 | if( sqlite3GlobalConfig.xLog ){ |
| 22189 | 22306 | va_start(ap, zFormat); |
| 22190 | 22307 | renderLogMsg(iErrCode, zFormat, ap); |
| 22191 | 22308 | va_end(ap); |
| | @@ -22317,11 +22434,11 @@ |
| 22317 | 22434 | } sqlite3Prng; |
| 22318 | 22435 | |
| 22319 | 22436 | /* |
| 22320 | 22437 | ** Return N random bytes. |
| 22321 | 22438 | */ |
| 22322 | | -SQLITE_API void sqlite3_randomness(int N, void *pBuf){ |
| 22439 | +SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){ |
| 22323 | 22440 | unsigned char t; |
| 22324 | 22441 | unsigned char *zBuf = pBuf; |
| 22325 | 22442 | |
| 22326 | 22443 | /* The "wsdPrng" macro will resolve to the pseudo-random number generator |
| 22327 | 22444 | ** state vector. If writable static data is unsupported on the target, |
| | @@ -23469,11 +23586,11 @@ |
| 23469 | 23586 | ** sqlite3_strnicmp() APIs allow applications and extensions to compare |
| 23470 | 23587 | ** the contents of two buffers containing UTF-8 strings in a |
| 23471 | 23588 | ** case-independent fashion, using the same definition of "case |
| 23472 | 23589 | ** independence" that SQLite uses internally when comparing identifiers. |
| 23473 | 23590 | */ |
| 23474 | | -SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){ |
| 23591 | +SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){ |
| 23475 | 23592 | register unsigned char *a, *b; |
| 23476 | 23593 | if( zLeft==0 ){ |
| 23477 | 23594 | return zRight ? -1 : 0; |
| 23478 | 23595 | }else if( zRight==0 ){ |
| 23479 | 23596 | return 1; |
| | @@ -23481,11 +23598,11 @@ |
| 23481 | 23598 | a = (unsigned char *)zLeft; |
| 23482 | 23599 | b = (unsigned char *)zRight; |
| 23483 | 23600 | while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } |
| 23484 | 23601 | return UpperToLower[*a] - UpperToLower[*b]; |
| 23485 | 23602 | } |
| 23486 | | -SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){ |
| 23603 | +SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){ |
| 23487 | 23604 | register unsigned char *a, *b; |
| 23488 | 23605 | if( zLeft==0 ){ |
| 23489 | 23606 | return zRight ? -1 : 0; |
| 23490 | 23607 | }else if( zRight==0 ){ |
| 23491 | 23608 | return 1; |
| | @@ -25287,10 +25404,11 @@ |
| 25287 | 25404 | #define UNIXFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ |
| 25288 | 25405 | #define UNIXFILE_DELETE 0x20 /* Delete on close */ |
| 25289 | 25406 | #define UNIXFILE_URI 0x40 /* Filename might have query parameters */ |
| 25290 | 25407 | #define UNIXFILE_NOLOCK 0x80 /* Do no file locking */ |
| 25291 | 25408 | #define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */ |
| 25409 | +#define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */ |
| 25292 | 25410 | |
| 25293 | 25411 | /* |
| 25294 | 25412 | ** Include code that is common to all os_*.c files |
| 25295 | 25413 | */ |
| 25296 | 25414 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| | @@ -26782,11 +26900,11 @@ |
| 26782 | 26900 | |
| 26783 | 26901 | assert( pFile ); |
| 26784 | 26902 | OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h, |
| 26785 | 26903 | azFileLock(eFileLock), azFileLock(pFile->eFileLock), |
| 26786 | 26904 | azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared, |
| 26787 | | - osGetpid())); |
| 26905 | + osGetpid(0))); |
| 26788 | 26906 | |
| 26789 | 26907 | /* If there is already a lock of this type or more restrictive on the |
| 26790 | 26908 | ** unixFile, do nothing. Don't use the end_lock: exit path, as |
| 26791 | 26909 | ** unixEnterMutex() hasn't been called yet. |
| 26792 | 26910 | */ |
| | @@ -26990,11 +27108,11 @@ |
| 26990 | 27108 | int rc = SQLITE_OK; |
| 26991 | 27109 | |
| 26992 | 27110 | assert( pFile ); |
| 26993 | 27111 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock, |
| 26994 | 27112 | pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared, |
| 26995 | | - osGetpid())); |
| 27113 | + osGetpid(0))); |
| 26996 | 27114 | |
| 26997 | 27115 | assert( eFileLock<=SHARED_LOCK ); |
| 26998 | 27116 | if( pFile->eFileLock<=eFileLock ){ |
| 26999 | 27117 | return SQLITE_OK; |
| 27000 | 27118 | } |
| | @@ -27417,11 +27535,11 @@ |
| 27417 | 27535 | char *zLockFile = (char *)pFile->lockingContext; |
| 27418 | 27536 | int rc; |
| 27419 | 27537 | |
| 27420 | 27538 | assert( pFile ); |
| 27421 | 27539 | OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock, |
| 27422 | | - pFile->eFileLock, osGetpid())); |
| 27540 | + pFile->eFileLock, osGetpid(0))); |
| 27423 | 27541 | assert( eFileLock<=SHARED_LOCK ); |
| 27424 | 27542 | |
| 27425 | 27543 | /* no-op if possible */ |
| 27426 | 27544 | if( pFile->eFileLock==eFileLock ){ |
| 27427 | 27545 | return SQLITE_OK; |
| | @@ -27635,11 +27753,11 @@ |
| 27635 | 27753 | static int flockUnlock(sqlite3_file *id, int eFileLock) { |
| 27636 | 27754 | unixFile *pFile = (unixFile*)id; |
| 27637 | 27755 | |
| 27638 | 27756 | assert( pFile ); |
| 27639 | 27757 | OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock, |
| 27640 | | - pFile->eFileLock, osGetpid())); |
| 27758 | + pFile->eFileLock, osGetpid(0))); |
| 27641 | 27759 | assert( eFileLock<=SHARED_LOCK ); |
| 27642 | 27760 | |
| 27643 | 27761 | /* no-op if possible */ |
| 27644 | 27762 | if( pFile->eFileLock==eFileLock ){ |
| 27645 | 27763 | return SQLITE_OK; |
| | @@ -27803,11 +27921,11 @@ |
| 27803 | 27921 | sem_t *pSem = pFile->pInode->pSem; |
| 27804 | 27922 | |
| 27805 | 27923 | assert( pFile ); |
| 27806 | 27924 | assert( pSem ); |
| 27807 | 27925 | OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock, |
| 27808 | | - pFile->eFileLock, osGetpid())); |
| 27926 | + pFile->eFileLock, osGetpid(0))); |
| 27809 | 27927 | assert( eFileLock<=SHARED_LOCK ); |
| 27810 | 27928 | |
| 27811 | 27929 | /* no-op if possible */ |
| 27812 | 27930 | if( pFile->eFileLock==eFileLock ){ |
| 27813 | 27931 | return SQLITE_OK; |
| | @@ -28017,11 +28135,11 @@ |
| 28017 | 28135 | afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; |
| 28018 | 28136 | |
| 28019 | 28137 | assert( pFile ); |
| 28020 | 28138 | OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h, |
| 28021 | 28139 | azFileLock(eFileLock), azFileLock(pFile->eFileLock), |
| 28022 | | - azFileLock(pInode->eFileLock), pInode->nShared , osGetpid())); |
| 28140 | + azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0))); |
| 28023 | 28141 | |
| 28024 | 28142 | /* If there is already a lock of this type or more restrictive on the |
| 28025 | 28143 | ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as |
| 28026 | 28144 | ** unixEnterMutex() hasn't been called yet. |
| 28027 | 28145 | */ |
| | @@ -28203,11 +28321,11 @@ |
| 28203 | 28321 | #endif |
| 28204 | 28322 | |
| 28205 | 28323 | assert( pFile ); |
| 28206 | 28324 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, |
| 28207 | 28325 | pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared, |
| 28208 | | - osGetpid())); |
| 28326 | + osGetpid(0))); |
| 28209 | 28327 | |
| 28210 | 28328 | assert( eFileLock<=SHARED_LOCK ); |
| 28211 | 28329 | if( pFile->eFileLock<=eFileLock ){ |
| 28212 | 28330 | return SQLITE_OK; |
| 28213 | 28331 | } |
| | @@ -29028,10 +29146,14 @@ |
| 29028 | 29146 | ** Information and control of an open file handle. |
| 29029 | 29147 | */ |
| 29030 | 29148 | static int unixFileControl(sqlite3_file *id, int op, void *pArg){ |
| 29031 | 29149 | unixFile *pFile = (unixFile*)id; |
| 29032 | 29150 | switch( op ){ |
| 29151 | + case SQLITE_FCNTL_WAL_BLOCK: { |
| 29152 | + pFile->ctrlFlags |= UNIXFILE_BLOCK; |
| 29153 | + return SQLITE_OK; |
| 29154 | + } |
| 29033 | 29155 | case SQLITE_FCNTL_LOCKSTATE: { |
| 29034 | 29156 | *(int*)pArg = pFile->eFileLock; |
| 29035 | 29157 | return SQLITE_OK; |
| 29036 | 29158 | } |
| 29037 | 29159 | case SQLITE_FCNTL_LAST_ERRNO: { |
| | @@ -29337,37 +29459,42 @@ |
| 29337 | 29459 | ** |
| 29338 | 29460 | ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking |
| 29339 | 29461 | ** otherwise. |
| 29340 | 29462 | */ |
| 29341 | 29463 | static int unixShmSystemLock( |
| 29342 | | - unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */ |
| 29464 | + unixFile *pFile, /* Open connection to the WAL file */ |
| 29343 | 29465 | int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */ |
| 29344 | 29466 | int ofst, /* First byte of the locking range */ |
| 29345 | 29467 | int n /* Number of bytes to lock */ |
| 29346 | 29468 | ){ |
| 29347 | | - struct flock f; /* The posix advisory locking structure */ |
| 29348 | | - int rc = SQLITE_OK; /* Result code form fcntl() */ |
| 29469 | + unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */ |
| 29470 | + struct flock f; /* The posix advisory locking structure */ |
| 29471 | + int rc = SQLITE_OK; /* Result code form fcntl() */ |
| 29349 | 29472 | |
| 29350 | 29473 | /* Access to the unixShmNode object is serialized by the caller */ |
| 29474 | + pShmNode = pFile->pInode->pShmNode; |
| 29351 | 29475 | assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 ); |
| 29352 | 29476 | |
| 29353 | 29477 | /* Shared locks never span more than one byte */ |
| 29354 | 29478 | assert( n==1 || lockType!=F_RDLCK ); |
| 29355 | 29479 | |
| 29356 | 29480 | /* Locks are within range */ |
| 29357 | 29481 | assert( n>=1 && n<SQLITE_SHM_NLOCK ); |
| 29358 | 29482 | |
| 29359 | 29483 | if( pShmNode->h>=0 ){ |
| 29484 | + int lkType; |
| 29360 | 29485 | /* Initialize the locking parameters */ |
| 29361 | 29486 | memset(&f, 0, sizeof(f)); |
| 29362 | 29487 | f.l_type = lockType; |
| 29363 | 29488 | f.l_whence = SEEK_SET; |
| 29364 | 29489 | f.l_start = ofst; |
| 29365 | 29490 | f.l_len = n; |
| 29366 | 29491 | |
| 29367 | | - rc = osFcntl(pShmNode->h, F_SETLK, &f); |
| 29492 | + lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK; |
| 29493 | + rc = osFcntl(pShmNode->h, lkType, &f); |
| 29368 | 29494 | rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY; |
| 29495 | + pFile->ctrlFlags &= ~UNIXFILE_BLOCK; |
| 29369 | 29496 | } |
| 29370 | 29497 | |
| 29371 | 29498 | /* Update the global lock state and do debug tracing */ |
| 29372 | 29499 | #ifdef SQLITE_DEBUG |
| 29373 | 29500 | { u16 mask; |
| | @@ -29573,17 +29700,17 @@ |
| 29573 | 29700 | |
| 29574 | 29701 | /* Check to see if another process is holding the dead-man switch. |
| 29575 | 29702 | ** If not, truncate the file to zero length. |
| 29576 | 29703 | */ |
| 29577 | 29704 | rc = SQLITE_OK; |
| 29578 | | - if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){ |
| 29705 | + if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){ |
| 29579 | 29706 | if( robust_ftruncate(pShmNode->h, 0) ){ |
| 29580 | 29707 | rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename); |
| 29581 | 29708 | } |
| 29582 | 29709 | } |
| 29583 | 29710 | if( rc==SQLITE_OK ){ |
| 29584 | | - rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1); |
| 29711 | + rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1); |
| 29585 | 29712 | } |
| 29586 | 29713 | if( rc ) goto shm_open_err; |
| 29587 | 29714 | } |
| 29588 | 29715 | } |
| 29589 | 29716 | |
| | @@ -29811,11 +29938,11 @@ |
| 29811 | 29938 | allMask |= pX->sharedMask; |
| 29812 | 29939 | } |
| 29813 | 29940 | |
| 29814 | 29941 | /* Unlock the system-level locks */ |
| 29815 | 29942 | if( (mask & allMask)==0 ){ |
| 29816 | | - rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n); |
| 29943 | + rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n); |
| 29817 | 29944 | }else{ |
| 29818 | 29945 | rc = SQLITE_OK; |
| 29819 | 29946 | } |
| 29820 | 29947 | |
| 29821 | 29948 | /* Undo the local locks */ |
| | @@ -29839,11 +29966,11 @@ |
| 29839 | 29966 | } |
| 29840 | 29967 | |
| 29841 | 29968 | /* Get shared locks at the system level, if necessary */ |
| 29842 | 29969 | if( rc==SQLITE_OK ){ |
| 29843 | 29970 | if( (allShared & mask)==0 ){ |
| 29844 | | - rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n); |
| 29971 | + rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n); |
| 29845 | 29972 | }else{ |
| 29846 | 29973 | rc = SQLITE_OK; |
| 29847 | 29974 | } |
| 29848 | 29975 | } |
| 29849 | 29976 | |
| | @@ -29864,20 +29991,20 @@ |
| 29864 | 29991 | |
| 29865 | 29992 | /* Get the exclusive locks at the system level. Then if successful |
| 29866 | 29993 | ** also mark the local connection as being locked. |
| 29867 | 29994 | */ |
| 29868 | 29995 | if( rc==SQLITE_OK ){ |
| 29869 | | - rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n); |
| 29996 | + rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n); |
| 29870 | 29997 | if( rc==SQLITE_OK ){ |
| 29871 | 29998 | assert( (p->sharedMask & mask)==0 ); |
| 29872 | 29999 | p->exclMask |= mask; |
| 29873 | 30000 | } |
| 29874 | 30001 | } |
| 29875 | 30002 | } |
| 29876 | 30003 | sqlite3_mutex_leave(pShmNode->mutex); |
| 29877 | 30004 | OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n", |
| 29878 | | - p->id, osGetpid(), p->sharedMask, p->exclMask)); |
| 30005 | + p->id, osGetpid(0), p->sharedMask, p->exclMask)); |
| 29879 | 30006 | return rc; |
| 29880 | 30007 | } |
| 29881 | 30008 | |
| 29882 | 30009 | /* |
| 29883 | 30010 | ** Implement a memory barrier or memory fence on shared memory. |
| | @@ -30968,12 +31095,12 @@ |
| 30968 | 31095 | /* Detect a pid change and reset the PRNG. There is a race condition |
| 30969 | 31096 | ** here such that two or more threads all trying to open databases at |
| 30970 | 31097 | ** the same instant might all reset the PRNG. But multiple resets |
| 30971 | 31098 | ** are harmless. |
| 30972 | 31099 | */ |
| 30973 | | - if( randomnessPid!=osGetpid() ){ |
| 30974 | | - randomnessPid = osGetpid(); |
| 31100 | + if( randomnessPid!=osGetpid(0) ){ |
| 31101 | + randomnessPid = osGetpid(0); |
| 30975 | 31102 | sqlite3_randomness(0,0); |
| 30976 | 31103 | } |
| 30977 | 31104 | |
| 30978 | 31105 | memset(p, 0, sizeof(unixFile)); |
| 30979 | 31106 | |
| | @@ -31360,11 +31487,11 @@ |
| 31360 | 31487 | ** When testing, initializing zBuf[] to zero is all we do. That means |
| 31361 | 31488 | ** that we always use the same random number sequence. This makes the |
| 31362 | 31489 | ** tests repeatable. |
| 31363 | 31490 | */ |
| 31364 | 31491 | memset(zBuf, 0, nBuf); |
| 31365 | | - randomnessPid = osGetpid(); |
| 31492 | + randomnessPid = osGetpid(0); |
| 31366 | 31493 | #if !defined(SQLITE_TEST) |
| 31367 | 31494 | { |
| 31368 | 31495 | int fd, got; |
| 31369 | 31496 | fd = robust_open("/dev/urandom", O_RDONLY, 0); |
| 31370 | 31497 | if( fd<0 ){ |
| | @@ -31681,11 +31808,11 @@ |
| 31681 | 31808 | #else |
| 31682 | 31809 | # ifdef _CS_DARWIN_USER_TEMP_DIR |
| 31683 | 31810 | { |
| 31684 | 31811 | if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){ |
| 31685 | 31812 | OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n", |
| 31686 | | - lPath, errno, osGetpid())); |
| 31813 | + lPath, errno, osGetpid(0))); |
| 31687 | 31814 | return SQLITE_IOERR_LOCK; |
| 31688 | 31815 | } |
| 31689 | 31816 | len = strlcat(lPath, "sqliteplocks", maxLen); |
| 31690 | 31817 | } |
| 31691 | 31818 | # else |
| | @@ -31703,11 +31830,11 @@ |
| 31703 | 31830 | char c = dbPath[i]; |
| 31704 | 31831 | lPath[i+len] = (c=='/')?'_':c; |
| 31705 | 31832 | } |
| 31706 | 31833 | lPath[i+len]='\0'; |
| 31707 | 31834 | strlcat(lPath, ":auto:", maxLen); |
| 31708 | | - OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid())); |
| 31835 | + OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid(0))); |
| 31709 | 31836 | return SQLITE_OK; |
| 31710 | 31837 | } |
| 31711 | 31838 | |
| 31712 | 31839 | /* |
| 31713 | 31840 | ** Creates the lock file and any missing directories in lockPath |
| | @@ -31730,20 +31857,20 @@ |
| 31730 | 31857 | if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){ |
| 31731 | 31858 | int err=errno; |
| 31732 | 31859 | if( err!=EEXIST ) { |
| 31733 | 31860 | OSTRACE(("CREATELOCKPATH FAILED creating %s, " |
| 31734 | 31861 | "'%s' proxy lock path=%s pid=%d\n", |
| 31735 | | - buf, strerror(err), lockPath, osGetpid())); |
| 31862 | + buf, strerror(err), lockPath, osGetpid(0))); |
| 31736 | 31863 | return err; |
| 31737 | 31864 | } |
| 31738 | 31865 | } |
| 31739 | 31866 | } |
| 31740 | 31867 | start=i+1; |
| 31741 | 31868 | } |
| 31742 | 31869 | buf[i] = lockPath[i]; |
| 31743 | 31870 | } |
| 31744 | | - OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid())); |
| 31871 | + OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid(0))); |
| 31745 | 31872 | return 0; |
| 31746 | 31873 | } |
| 31747 | 31874 | |
| 31748 | 31875 | /* |
| 31749 | 31876 | ** Create a new VFS file descriptor (stored in memory obtained from |
| | @@ -32045,11 +32172,11 @@ |
| 32045 | 32172 | int tryOldLockPath = 0; |
| 32046 | 32173 | int forceNewLockPath = 0; |
| 32047 | 32174 | |
| 32048 | 32175 | OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h, |
| 32049 | 32176 | (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), |
| 32050 | | - osGetpid())); |
| 32177 | + osGetpid(0))); |
| 32051 | 32178 | |
| 32052 | 32179 | rc = proxyGetHostID(myHostID, &pError); |
| 32053 | 32180 | if( (rc&0xff)==SQLITE_IOERR ){ |
| 32054 | 32181 | storeLastErrno(pFile, pError); |
| 32055 | 32182 | goto end_takeconch; |
| | @@ -32255,11 +32382,11 @@ |
| 32255 | 32382 | |
| 32256 | 32383 | pCtx = (proxyLockingContext *)pFile->lockingContext; |
| 32257 | 32384 | conchFile = pCtx->conchFile; |
| 32258 | 32385 | OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h, |
| 32259 | 32386 | (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), |
| 32260 | | - osGetpid())); |
| 32387 | + osGetpid(0))); |
| 32261 | 32388 | if( pCtx->conchHeld>0 ){ |
| 32262 | 32389 | rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK); |
| 32263 | 32390 | } |
| 32264 | 32391 | pCtx->conchHeld = 0; |
| 32265 | 32392 | OSTRACE(("RELEASECONCH %d %s\n", conchFile->h, |
| | @@ -32397,11 +32524,11 @@ |
| 32397 | 32524 | }else{ |
| 32398 | 32525 | lockPath=(char *)path; |
| 32399 | 32526 | } |
| 32400 | 32527 | |
| 32401 | 32528 | OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h, |
| 32402 | | - (lockPath ? lockPath : ":auto:"), osGetpid())); |
| 32529 | + (lockPath ? lockPath : ":auto:"), osGetpid(0))); |
| 32403 | 32530 | |
| 32404 | 32531 | pCtx = sqlite3_malloc( sizeof(*pCtx) ); |
| 32405 | 32532 | if( pCtx==0 ){ |
| 32406 | 32533 | return SQLITE_NOMEM; |
| 32407 | 32534 | } |
| | @@ -32684,11 +32811,11 @@ |
| 32684 | 32811 | ** This routine is called once during SQLite initialization and by a |
| 32685 | 32812 | ** single thread. The memory allocation and mutex subsystems have not |
| 32686 | 32813 | ** necessarily been initialized when this routine is called, and so they |
| 32687 | 32814 | ** should not be used. |
| 32688 | 32815 | */ |
| 32689 | | -SQLITE_API int sqlite3_os_init(void){ |
| 32816 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){ |
| 32690 | 32817 | /* |
| 32691 | 32818 | ** The following macro defines an initializer for an sqlite3_vfs object. |
| 32692 | 32819 | ** The name of the VFS is NAME. The pAppData is a pointer to a pointer |
| 32693 | 32820 | ** to the "finder" function. (pAppData is a pointer to a pointer because |
| 32694 | 32821 | ** silly C90 rules prohibit a void* from being cast to a function pointer |
| | @@ -32783,11 +32910,11 @@ |
| 32783 | 32910 | ** |
| 32784 | 32911 | ** Some operating systems might need to do some cleanup in this routine, |
| 32785 | 32912 | ** to release dynamically allocated objects. But not on unix. |
| 32786 | 32913 | ** This routine is a no-op for unix. |
| 32787 | 32914 | */ |
| 32788 | | -SQLITE_API int sqlite3_os_end(void){ |
| 32915 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){ |
| 32789 | 32916 | return SQLITE_OK; |
| 32790 | 32917 | } |
| 32791 | 32918 | |
| 32792 | 32919 | #endif /* SQLITE_OS_UNIX */ |
| 32793 | 32920 | |
| | @@ -34175,11 +34302,11 @@ |
| 34175 | 34302 | ** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one |
| 34176 | 34303 | ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The |
| 34177 | 34304 | ** "pnLargest" argument, if non-zero, will be used to return the size of the |
| 34178 | 34305 | ** largest committed free block in the heap, in bytes. |
| 34179 | 34306 | */ |
| 34180 | | -SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){ |
| 34307 | +SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){ |
| 34181 | 34308 | int rc = SQLITE_OK; |
| 34182 | 34309 | UINT nLargest = 0; |
| 34183 | 34310 | HANDLE hHeap; |
| 34184 | 34311 | |
| 34185 | 34312 | winMemAssertMagic(); |
| | @@ -34215,11 +34342,11 @@ |
| 34215 | 34342 | ** If a Win32 native heap has been configured, this function will attempt to |
| 34216 | 34343 | ** destroy and recreate it. If the Win32 native heap is not isolated and/or |
| 34217 | 34344 | ** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will |
| 34218 | 34345 | ** be returned and no changes will be made to the Win32 native heap. |
| 34219 | 34346 | */ |
| 34220 | | -SQLITE_API int sqlite3_win32_reset_heap(){ |
| 34347 | +SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){ |
| 34221 | 34348 | int rc; |
| 34222 | 34349 | MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 34223 | 34350 | MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */ |
| 34224 | 34351 | MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); ) |
| 34225 | 34352 | MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); ) |
| | @@ -34260,11 +34387,11 @@ |
| 34260 | 34387 | /* |
| 34261 | 34388 | ** This function outputs the specified (ANSI) string to the Win32 debugger |
| 34262 | 34389 | ** (if available). |
| 34263 | 34390 | */ |
| 34264 | 34391 | |
| 34265 | | -SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){ |
| 34392 | +SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){ |
| 34266 | 34393 | char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE]; |
| 34267 | 34394 | int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */ |
| 34268 | 34395 | if( nMin<-1 ) nMin = -1; /* all negative values become -1. */ |
| 34269 | 34396 | assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE ); |
| 34270 | 34397 | #if defined(SQLITE_WIN32_HAS_ANSI) |
| | @@ -34300,11 +34427,11 @@ |
| 34300 | 34427 | */ |
| 34301 | 34428 | #if SQLITE_OS_WINRT |
| 34302 | 34429 | static HANDLE sleepObj = NULL; |
| 34303 | 34430 | #endif |
| 34304 | 34431 | |
| 34305 | | -SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){ |
| 34432 | +SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){ |
| 34306 | 34433 | #if SQLITE_OS_WINRT |
| 34307 | 34434 | if ( sleepObj==NULL ){ |
| 34308 | 34435 | sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET, |
| 34309 | 34436 | SYNCHRONIZE); |
| 34310 | 34437 | } |
| | @@ -34349,11 +34476,11 @@ |
| 34349 | 34476 | |
| 34350 | 34477 | /* |
| 34351 | 34478 | ** This function determines if the machine is running a version of Windows |
| 34352 | 34479 | ** based on the NT kernel. |
| 34353 | 34480 | */ |
| 34354 | | -SQLITE_API int sqlite3_win32_is_nt(void){ |
| 34481 | +SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){ |
| 34355 | 34482 | #if SQLITE_OS_WINRT |
| 34356 | 34483 | /* |
| 34357 | 34484 | ** NOTE: The WinRT sub-platform is always assumed to be based on the NT |
| 34358 | 34485 | ** kernel. |
| 34359 | 34486 | */ |
| | @@ -34703,11 +34830,11 @@ |
| 34703 | 34830 | |
| 34704 | 34831 | /* |
| 34705 | 34832 | ** Convert multibyte character string to UTF-8. Space to hold the |
| 34706 | 34833 | ** returned string is obtained from sqlite3_malloc(). |
| 34707 | 34834 | */ |
| 34708 | | -SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){ |
| 34835 | +SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){ |
| 34709 | 34836 | char *zFilenameUtf8; |
| 34710 | 34837 | LPWSTR zTmpWide; |
| 34711 | 34838 | |
| 34712 | 34839 | zTmpWide = winMbcsToUnicode(zFilename); |
| 34713 | 34840 | if( zTmpWide==0 ){ |
| | @@ -34720,11 +34847,11 @@ |
| 34720 | 34847 | |
| 34721 | 34848 | /* |
| 34722 | 34849 | ** Convert UTF-8 to multibyte character string. Space to hold the |
| 34723 | 34850 | ** returned string is obtained from sqlite3_malloc(). |
| 34724 | 34851 | */ |
| 34725 | | -SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){ |
| 34852 | +SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){ |
| 34726 | 34853 | char *zFilenameMbcs; |
| 34727 | 34854 | LPWSTR zTmpWide; |
| 34728 | 34855 | |
| 34729 | 34856 | zTmpWide = winUtf8ToUnicode(zFilename); |
| 34730 | 34857 | if( zTmpWide==0 ){ |
| | @@ -34740,11 +34867,11 @@ |
| 34740 | 34867 | ** the provided arguments. The type argument must be 1 in order to set the |
| 34741 | 34868 | ** data directory or 2 in order to set the temporary directory. The zValue |
| 34742 | 34869 | ** argument is the name of the directory to use. The return value will be |
| 34743 | 34870 | ** SQLITE_OK if successful. |
| 34744 | 34871 | */ |
| 34745 | | -SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){ |
| 34872 | +SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){ |
| 34746 | 34873 | char **ppDirectory = 0; |
| 34747 | 34874 | #ifndef SQLITE_OMIT_AUTOINIT |
| 34748 | 34875 | int rc = sqlite3_initialize(); |
| 34749 | 34876 | if( rc ) return rc; |
| 34750 | 34877 | #endif |
| | @@ -34965,15 +35092,15 @@ |
| 34965 | 35092 | } |
| 34966 | 35093 | |
| 34967 | 35094 | /* |
| 34968 | 35095 | ** Log a I/O error retry episode. |
| 34969 | 35096 | */ |
| 34970 | | -static void winLogIoerr(int nRetry){ |
| 35097 | +static void winLogIoerr(int nRetry, int lineno){ |
| 34971 | 35098 | if( nRetry ){ |
| 34972 | 35099 | sqlite3_log(SQLITE_IOERR, |
| 34973 | | - "delayed %dms for lock/sharing conflict", |
| 34974 | | - winIoerrRetryDelay*nRetry*(nRetry+1)/2 |
| 35100 | + "delayed %dms for lock/sharing conflict at line %d", |
| 35101 | + winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno |
| 34975 | 35102 | ); |
| 34976 | 35103 | } |
| 34977 | 35104 | } |
| 34978 | 35105 | |
| 34979 | 35106 | #if SQLITE_OS_WINCE |
| | @@ -35449,11 +35576,12 @@ |
| 35449 | 35576 | assert( id!=0 ); |
| 35450 | 35577 | #ifndef SQLITE_OMIT_WAL |
| 35451 | 35578 | assert( pFile->pShm==0 ); |
| 35452 | 35579 | #endif |
| 35453 | 35580 | assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE ); |
| 35454 | | - OSTRACE(("CLOSE file=%p\n", pFile->h)); |
| 35581 | + OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n", |
| 35582 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35455 | 35583 | |
| 35456 | 35584 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 35457 | 35585 | winUnmapfile(pFile); |
| 35458 | 35586 | #endif |
| 35459 | 35587 | |
| | @@ -35478,11 +35606,12 @@ |
| 35478 | 35606 | #endif |
| 35479 | 35607 | if( rc ){ |
| 35480 | 35608 | pFile->h = NULL; |
| 35481 | 35609 | } |
| 35482 | 35610 | OpenCounter(-1); |
| 35483 | | - OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed")); |
| 35611 | + OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n", |
| 35612 | + osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed")); |
| 35484 | 35613 | return rc ? SQLITE_OK |
| 35485 | 35614 | : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(), |
| 35486 | 35615 | "winClose", pFile->zPath); |
| 35487 | 35616 | } |
| 35488 | 35617 | |
| | @@ -35506,20 +35635,22 @@ |
| 35506 | 35635 | |
| 35507 | 35636 | assert( id!=0 ); |
| 35508 | 35637 | assert( amt>0 ); |
| 35509 | 35638 | assert( offset>=0 ); |
| 35510 | 35639 | SimulateIOError(return SQLITE_IOERR_READ); |
| 35511 | | - OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n", |
| 35640 | + OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, " |
| 35641 | + "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, |
| 35512 | 35642 | pFile->h, pBuf, amt, offset, pFile->locktype)); |
| 35513 | 35643 | |
| 35514 | 35644 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 35515 | 35645 | /* Deal with as much of this read request as possible by transfering |
| 35516 | 35646 | ** data from the memory mapping using memcpy(). */ |
| 35517 | 35647 | if( offset<pFile->mmapSize ){ |
| 35518 | 35648 | if( offset+amt <= pFile->mmapSize ){ |
| 35519 | 35649 | memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt); |
| 35520 | | - OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35650 | + OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35651 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35521 | 35652 | return SQLITE_OK; |
| 35522 | 35653 | }else{ |
| 35523 | 35654 | int nCopy = (int)(pFile->mmapSize - offset); |
| 35524 | 35655 | memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy); |
| 35525 | 35656 | pBuf = &((u8 *)pBuf)[nCopy]; |
| | @@ -35529,11 +35660,12 @@ |
| 35529 | 35660 | } |
| 35530 | 35661 | #endif |
| 35531 | 35662 | |
| 35532 | 35663 | #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED) |
| 35533 | 35664 | if( winSeekFile(pFile, offset) ){ |
| 35534 | | - OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h)); |
| 35665 | + OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n", |
| 35666 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35535 | 35667 | return SQLITE_FULL; |
| 35536 | 35668 | } |
| 35537 | 35669 | while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ |
| 35538 | 35670 | #else |
| 35539 | 35671 | memset(&overlapped, 0, sizeof(OVERLAPPED)); |
| | @@ -35543,23 +35675,26 @@ |
| 35543 | 35675 | osGetLastError()!=ERROR_HANDLE_EOF ){ |
| 35544 | 35676 | #endif |
| 35545 | 35677 | DWORD lastErrno; |
| 35546 | 35678 | if( winRetryIoerr(&nRetry, &lastErrno) ) continue; |
| 35547 | 35679 | pFile->lastErrno = lastErrno; |
| 35548 | | - OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h)); |
| 35680 | + OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n", |
| 35681 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35549 | 35682 | return winLogError(SQLITE_IOERR_READ, pFile->lastErrno, |
| 35550 | 35683 | "winRead", pFile->zPath); |
| 35551 | 35684 | } |
| 35552 | | - winLogIoerr(nRetry); |
| 35685 | + winLogIoerr(nRetry, __LINE__); |
| 35553 | 35686 | if( nRead<(DWORD)amt ){ |
| 35554 | 35687 | /* Unread parts of the buffer must be zero-filled */ |
| 35555 | 35688 | memset(&((char*)pBuf)[nRead], 0, amt-nRead); |
| 35556 | | - OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h)); |
| 35689 | + OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n", |
| 35690 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35557 | 35691 | return SQLITE_IOERR_SHORT_READ; |
| 35558 | 35692 | } |
| 35559 | 35693 | |
| 35560 | | - OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35694 | + OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35695 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35561 | 35696 | return SQLITE_OK; |
| 35562 | 35697 | } |
| 35563 | 35698 | |
| 35564 | 35699 | /* |
| 35565 | 35700 | ** Write data from a buffer into a file. Return SQLITE_OK on success |
| | @@ -35578,20 +35713,22 @@ |
| 35578 | 35713 | assert( amt>0 ); |
| 35579 | 35714 | assert( pFile ); |
| 35580 | 35715 | SimulateIOError(return SQLITE_IOERR_WRITE); |
| 35581 | 35716 | SimulateDiskfullError(return SQLITE_FULL); |
| 35582 | 35717 | |
| 35583 | | - OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n", |
| 35718 | + OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, " |
| 35719 | + "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile, |
| 35584 | 35720 | pFile->h, pBuf, amt, offset, pFile->locktype)); |
| 35585 | 35721 | |
| 35586 | 35722 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 35587 | 35723 | /* Deal with as much of this write request as possible by transfering |
| 35588 | 35724 | ** data from the memory mapping using memcpy(). */ |
| 35589 | 35725 | if( offset<pFile->mmapSize ){ |
| 35590 | 35726 | if( offset+amt <= pFile->mmapSize ){ |
| 35591 | 35727 | memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt); |
| 35592 | | - OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35728 | + OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35729 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35593 | 35730 | return SQLITE_OK; |
| 35594 | 35731 | }else{ |
| 35595 | 35732 | int nCopy = (int)(pFile->mmapSize - offset); |
| 35596 | 35733 | memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy); |
| 35597 | 35734 | pBuf = &((u8 *)pBuf)[nCopy]; |
| | @@ -35650,21 +35787,24 @@ |
| 35650 | 35787 | } |
| 35651 | 35788 | |
| 35652 | 35789 | if( rc ){ |
| 35653 | 35790 | if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ) |
| 35654 | 35791 | || ( pFile->lastErrno==ERROR_DISK_FULL )){ |
| 35655 | | - OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h)); |
| 35792 | + OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n", |
| 35793 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35656 | 35794 | return winLogError(SQLITE_FULL, pFile->lastErrno, |
| 35657 | 35795 | "winWrite1", pFile->zPath); |
| 35658 | 35796 | } |
| 35659 | | - OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h)); |
| 35797 | + OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n", |
| 35798 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35660 | 35799 | return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno, |
| 35661 | 35800 | "winWrite2", pFile->zPath); |
| 35662 | 35801 | }else{ |
| 35663 | | - winLogIoerr(nRetry); |
| 35802 | + winLogIoerr(nRetry, __LINE__); |
| 35664 | 35803 | } |
| 35665 | | - OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35804 | + OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35805 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35666 | 35806 | return SQLITE_OK; |
| 35667 | 35807 | } |
| 35668 | 35808 | |
| 35669 | 35809 | /* |
| 35670 | 35810 | ** Truncate an open file to a specified size |
| | @@ -35674,12 +35814,12 @@ |
| 35674 | 35814 | int rc = SQLITE_OK; /* Return code for this function */ |
| 35675 | 35815 | DWORD lastErrno; |
| 35676 | 35816 | |
| 35677 | 35817 | assert( pFile ); |
| 35678 | 35818 | SimulateIOError(return SQLITE_IOERR_TRUNCATE); |
| 35679 | | - OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n", |
| 35680 | | - pFile->h, nByte, pFile->locktype)); |
| 35819 | + OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n", |
| 35820 | + osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype)); |
| 35681 | 35821 | |
| 35682 | 35822 | /* If the user has configured a chunk-size for this file, truncate the |
| 35683 | 35823 | ** file so that it consists of an integer number of chunks (i.e. the |
| 35684 | 35824 | ** actual file size after the operation may be larger than the requested |
| 35685 | 35825 | ** size). |
| | @@ -35707,11 +35847,12 @@ |
| 35707 | 35847 | if( pFile->pMapRegion && nByte<pFile->mmapSize ){ |
| 35708 | 35848 | pFile->mmapSize = nByte; |
| 35709 | 35849 | } |
| 35710 | 35850 | #endif |
| 35711 | 35851 | |
| 35712 | | - OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc))); |
| 35852 | + OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n", |
| 35853 | + osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc))); |
| 35713 | 35854 | return rc; |
| 35714 | 35855 | } |
| 35715 | 35856 | |
| 35716 | 35857 | #ifdef SQLITE_TEST |
| 35717 | 35858 | /* |
| | @@ -35752,12 +35893,13 @@ |
| 35752 | 35893 | /* Unix cannot, but some systems may return SQLITE_FULL from here. This |
| 35753 | 35894 | ** line is to test that doing so does not cause any problems. |
| 35754 | 35895 | */ |
| 35755 | 35896 | SimulateDiskfullError( return SQLITE_FULL ); |
| 35756 | 35897 | |
| 35757 | | - OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n", |
| 35758 | | - pFile->h, flags, pFile->locktype)); |
| 35898 | + OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n", |
| 35899 | + osGetCurrentProcessId(), pFile, pFile->h, flags, |
| 35900 | + pFile->locktype)); |
| 35759 | 35901 | |
| 35760 | 35902 | #ifndef SQLITE_TEST |
| 35761 | 35903 | UNUSED_PARAMETER(flags); |
| 35762 | 35904 | #else |
| 35763 | 35905 | if( (flags&0x0F)==SQLITE_SYNC_FULL ){ |
| | @@ -35768,21 +35910,24 @@ |
| 35768 | 35910 | |
| 35769 | 35911 | /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a |
| 35770 | 35912 | ** no-op |
| 35771 | 35913 | */ |
| 35772 | 35914 | #ifdef SQLITE_NO_SYNC |
| 35773 | | - OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35915 | + OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35916 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35774 | 35917 | return SQLITE_OK; |
| 35775 | 35918 | #else |
| 35776 | 35919 | rc = osFlushFileBuffers(pFile->h); |
| 35777 | 35920 | SimulateIOError( rc=FALSE ); |
| 35778 | 35921 | if( rc ){ |
| 35779 | | - OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h)); |
| 35922 | + OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n", |
| 35923 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35780 | 35924 | return SQLITE_OK; |
| 35781 | 35925 | }else{ |
| 35782 | 35926 | pFile->lastErrno = osGetLastError(); |
| 35783 | | - OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h)); |
| 35927 | + OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n", |
| 35928 | + osGetCurrentProcessId(), pFile, pFile->h)); |
| 35784 | 35929 | return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, |
| 35785 | 35930 | "winSync", pFile->zPath); |
| 35786 | 35931 | } |
| 35787 | 35932 | #endif |
| 35788 | 35933 | } |
| | @@ -37751,11 +37896,11 @@ |
| 37751 | 37896 | winRetryIoerr(&cnt, &lastErrno) ){ |
| 37752 | 37897 | /* Noop */ |
| 37753 | 37898 | } |
| 37754 | 37899 | } |
| 37755 | 37900 | #endif |
| 37756 | | - winLogIoerr(cnt); |
| 37901 | + winLogIoerr(cnt, __LINE__); |
| 37757 | 37902 | |
| 37758 | 37903 | OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name, |
| 37759 | 37904 | dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok")); |
| 37760 | 37905 | |
| 37761 | 37906 | if( h==INVALID_HANDLE_VALUE ){ |
| | @@ -37935,11 +38080,11 @@ |
| 37935 | 38080 | } |
| 37936 | 38081 | #endif |
| 37937 | 38082 | if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){ |
| 37938 | 38083 | rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename); |
| 37939 | 38084 | }else{ |
| 37940 | | - winLogIoerr(cnt); |
| 38085 | + winLogIoerr(cnt, __LINE__); |
| 37941 | 38086 | } |
| 37942 | 38087 | sqlite3_free(zConverted); |
| 37943 | 38088 | OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc))); |
| 37944 | 38089 | return rc; |
| 37945 | 38090 | } |
| | @@ -37985,11 +38130,11 @@ |
| 37985 | 38130 | attr = INVALID_FILE_ATTRIBUTES; |
| 37986 | 38131 | }else{ |
| 37987 | 38132 | attr = sAttrData.dwFileAttributes; |
| 37988 | 38133 | } |
| 37989 | 38134 | }else{ |
| 37990 | | - winLogIoerr(cnt); |
| 38135 | + winLogIoerr(cnt, __LINE__); |
| 37991 | 38136 | if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){ |
| 37992 | 38137 | sqlite3_free(zConverted); |
| 37993 | 38138 | return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", |
| 37994 | 38139 | zFilename); |
| 37995 | 38140 | }else{ |
| | @@ -38500,11 +38645,11 @@ |
| 38500 | 38645 | } |
| 38501 | 38646 | |
| 38502 | 38647 | /* |
| 38503 | 38648 | ** Initialize and deinitialize the operating system interface. |
| 38504 | 38649 | */ |
| 38505 | | -SQLITE_API int sqlite3_os_init(void){ |
| 38650 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){ |
| 38506 | 38651 | static sqlite3_vfs winVfs = { |
| 38507 | 38652 | 3, /* iVersion */ |
| 38508 | 38653 | sizeof(winFile), /* szOsFile */ |
| 38509 | 38654 | SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ |
| 38510 | 38655 | 0, /* pNext */ |
| | @@ -38575,11 +38720,11 @@ |
| 38575 | 38720 | #endif |
| 38576 | 38721 | |
| 38577 | 38722 | return SQLITE_OK; |
| 38578 | 38723 | } |
| 38579 | 38724 | |
| 38580 | | -SQLITE_API int sqlite3_os_end(void){ |
| 38725 | +SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){ |
| 38581 | 38726 | #if SQLITE_OS_WINRT |
| 38582 | 38727 | if( sleepObj!=NULL ){ |
| 38583 | 38728 | osCloseHandle(sleepObj); |
| 38584 | 38729 | sleepObj = NULL; |
| 38585 | 38730 | } |
| | @@ -39866,20 +40011,20 @@ |
| 39866 | 40011 | ** in pcache1 need to be protected via mutex. |
| 39867 | 40012 | */ |
| 39868 | 40013 | static void *pcache1Alloc(int nByte){ |
| 39869 | 40014 | void *p = 0; |
| 39870 | 40015 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 39871 | | - sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); |
| 39872 | 40016 | if( nByte<=pcache1.szSlot ){ |
| 39873 | 40017 | sqlite3_mutex_enter(pcache1.mutex); |
| 39874 | 40018 | p = (PgHdr1 *)pcache1.pFree; |
| 39875 | 40019 | if( p ){ |
| 39876 | 40020 | pcache1.pFree = pcache1.pFree->pNext; |
| 39877 | 40021 | pcache1.nFreeSlot--; |
| 39878 | 40022 | pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve; |
| 39879 | 40023 | assert( pcache1.nFreeSlot>=0 ); |
| 39880 | | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1); |
| 40024 | + sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); |
| 40025 | + sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1); |
| 39881 | 40026 | } |
| 39882 | 40027 | sqlite3_mutex_leave(pcache1.mutex); |
| 39883 | 40028 | } |
| 39884 | 40029 | if( p==0 ){ |
| 39885 | 40030 | /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool. Get |
| | @@ -39888,11 +40033,12 @@ |
| 39888 | 40033 | p = sqlite3Malloc(nByte); |
| 39889 | 40034 | #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS |
| 39890 | 40035 | if( p ){ |
| 39891 | 40036 | int sz = sqlite3MallocSize(p); |
| 39892 | 40037 | sqlite3_mutex_enter(pcache1.mutex); |
| 39893 | | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); |
| 40038 | + sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte); |
| 40039 | + sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); |
| 39894 | 40040 | sqlite3_mutex_leave(pcache1.mutex); |
| 39895 | 40041 | } |
| 39896 | 40042 | #endif |
| 39897 | 40043 | sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); |
| 39898 | 40044 | } |
| | @@ -39906,11 +40052,11 @@ |
| 39906 | 40052 | int nFreed = 0; |
| 39907 | 40053 | if( p==0 ) return 0; |
| 39908 | 40054 | if( p>=pcache1.pStart && p<pcache1.pEnd ){ |
| 39909 | 40055 | PgFreeslot *pSlot; |
| 39910 | 40056 | sqlite3_mutex_enter(pcache1.mutex); |
| 39911 | | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1); |
| 40057 | + sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1); |
| 39912 | 40058 | pSlot = (PgFreeslot*)p; |
| 39913 | 40059 | pSlot->pNext = pcache1.pFree; |
| 39914 | 40060 | pcache1.pFree = pSlot; |
| 39915 | 40061 | pcache1.nFreeSlot++; |
| 39916 | 40062 | pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve; |
| | @@ -39920,11 +40066,11 @@ |
| 39920 | 40066 | assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) ); |
| 39921 | 40067 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 39922 | 40068 | nFreed = sqlite3MallocSize(p); |
| 39923 | 40069 | #ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS |
| 39924 | 40070 | sqlite3_mutex_enter(pcache1.mutex); |
| 39925 | | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed); |
| 40071 | + sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed); |
| 39926 | 40072 | sqlite3_mutex_leave(pcache1.mutex); |
| 39927 | 40073 | #endif |
| 39928 | 40074 | sqlite3_free(p); |
| 39929 | 40075 | } |
| 39930 | 40076 | return nFreed; |
| | @@ -40656,10 +40802,18 @@ |
| 40656 | 40802 | |
| 40657 | 40803 | /* |
| 40658 | 40804 | ** Return the size of the header on each page of this PCACHE implementation. |
| 40659 | 40805 | */ |
| 40660 | 40806 | SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); } |
| 40807 | + |
| 40808 | +/* |
| 40809 | +** Return the global mutex used by this PCACHE implementation. The |
| 40810 | +** sqlite3_status() routine needs access to this mutex. |
| 40811 | +*/ |
| 40812 | +SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){ |
| 40813 | + return pcache1.mutex; |
| 40814 | +} |
| 40661 | 40815 | |
| 40662 | 40816 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 40663 | 40817 | /* |
| 40664 | 40818 | ** This function is called to free superfluous dynamically allocated memory |
| 40665 | 40819 | ** held by the pager system. Memory in use by any SQLite pager allocated |
| | @@ -49429,13 +49583,14 @@ |
| 49429 | 49583 | if( pWal->exclusiveMode ) return; |
| 49430 | 49584 | (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1, |
| 49431 | 49585 | SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED); |
| 49432 | 49586 | WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx))); |
| 49433 | 49587 | } |
| 49434 | | -static int walLockExclusive(Wal *pWal, int lockIdx, int n){ |
| 49588 | +static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){ |
| 49435 | 49589 | int rc; |
| 49436 | 49590 | if( pWal->exclusiveMode ) return SQLITE_OK; |
| 49591 | + if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0); |
| 49437 | 49592 | rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n, |
| 49438 | 49593 | SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE); |
| 49439 | 49594 | WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal, |
| 49440 | 49595 | walLockName(lockIdx), n, rc ? "failed" : "ok")); |
| 49441 | 49596 | VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); ) |
| | @@ -49717,11 +49872,11 @@ |
| 49717 | 49872 | assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 ); |
| 49718 | 49873 | assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE ); |
| 49719 | 49874 | assert( pWal->writeLock ); |
| 49720 | 49875 | iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock; |
| 49721 | 49876 | nLock = SQLITE_SHM_NLOCK - iLock; |
| 49722 | | - rc = walLockExclusive(pWal, iLock, nLock); |
| 49877 | + rc = walLockExclusive(pWal, iLock, nLock, 0); |
| 49723 | 49878 | if( rc ){ |
| 49724 | 49879 | return rc; |
| 49725 | 49880 | } |
| 49726 | 49881 | WALTRACE(("WAL%p: recovery begin...\n", pWal)); |
| 49727 | 49882 | |
| | @@ -50251,11 +50406,11 @@ |
| 50251 | 50406 | int lockIdx, /* Offset of first byte to lock */ |
| 50252 | 50407 | int n /* Number of bytes to lock */ |
| 50253 | 50408 | ){ |
| 50254 | 50409 | int rc; |
| 50255 | 50410 | do { |
| 50256 | | - rc = walLockExclusive(pWal, lockIdx, n); |
| 50411 | + rc = walLockExclusive(pWal, lockIdx, n, 0); |
| 50257 | 50412 | }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) ); |
| 50258 | 50413 | return rc; |
| 50259 | 50414 | } |
| 50260 | 50415 | |
| 50261 | 50416 | /* |
| | @@ -50684,11 +50839,11 @@ |
| 50684 | 50839 | if( pWal->readOnly & WAL_SHM_RDONLY ){ |
| 50685 | 50840 | if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){ |
| 50686 | 50841 | walUnlockShared(pWal, WAL_WRITE_LOCK); |
| 50687 | 50842 | rc = SQLITE_READONLY_RECOVERY; |
| 50688 | 50843 | } |
| 50689 | | - }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){ |
| 50844 | + }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){ |
| 50690 | 50845 | pWal->writeLock = 1; |
| 50691 | 50846 | if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){ |
| 50692 | 50847 | badHdr = walIndexTryHdr(pWal, pChanged); |
| 50693 | 50848 | if( badHdr ){ |
| 50694 | 50849 | /* If the wal-index header is still malformed even while holding |
| | @@ -50890,11 +51045,11 @@ |
| 50890 | 51045 | { |
| 50891 | 51046 | if( (pWal->readOnly & WAL_SHM_RDONLY)==0 |
| 50892 | 51047 | && (mxReadMark<pWal->hdr.mxFrame || mxI==0) |
| 50893 | 51048 | ){ |
| 50894 | 51049 | for(i=1; i<WAL_NREADER; i++){ |
| 50895 | | - rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 51050 | + rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1, 0); |
| 50896 | 51051 | if( rc==SQLITE_OK ){ |
| 50897 | 51052 | mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame; |
| 50898 | 51053 | mxI = i; |
| 50899 | 51054 | walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| 50900 | 51055 | break; |
| | @@ -51146,11 +51301,11 @@ |
| 51146 | 51301 | } |
| 51147 | 51302 | |
| 51148 | 51303 | /* Only one writer allowed at a time. Get the write lock. Return |
| 51149 | 51304 | ** SQLITE_BUSY if unable. |
| 51150 | 51305 | */ |
| 51151 | | - rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1); |
| 51306 | + rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0); |
| 51152 | 51307 | if( rc ){ |
| 51153 | 51308 | return rc; |
| 51154 | 51309 | } |
| 51155 | 51310 | pWal->writeLock = 1; |
| 51156 | 51311 | |
| | @@ -51291,11 +51446,11 @@ |
| 51291 | 51446 | volatile WalCkptInfo *pInfo = walCkptInfo(pWal); |
| 51292 | 51447 | assert( pInfo->nBackfill==pWal->hdr.mxFrame ); |
| 51293 | 51448 | if( pInfo->nBackfill>0 ){ |
| 51294 | 51449 | u32 salt1; |
| 51295 | 51450 | sqlite3_randomness(4, &salt1); |
| 51296 | | - rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); |
| 51451 | + rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0); |
| 51297 | 51452 | if( rc==SQLITE_OK ){ |
| 51298 | 51453 | /* If all readers are using WAL_READ_LOCK(0) (in other words if no |
| 51299 | 51454 | ** readers are currently using the WAL), then the transactions |
| 51300 | 51455 | ** frames will overwrite the start of the existing log. Update the |
| 51301 | 51456 | ** wal-index header to reflect this. |
| | @@ -51616,11 +51771,11 @@ |
| 51616 | 51771 | if( pWal->readOnly ) return SQLITE_READONLY; |
| 51617 | 51772 | WALTRACE(("WAL%p: checkpoint begins\n", pWal)); |
| 51618 | 51773 | |
| 51619 | 51774 | /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive |
| 51620 | 51775 | ** "checkpoint" lock on the database file. */ |
| 51621 | | - rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1); |
| 51776 | + rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0); |
| 51622 | 51777 | if( rc ){ |
| 51623 | 51778 | /* EVIDENCE-OF: R-10421-19736 If any other process is running a |
| 51624 | 51779 | ** checkpoint operation at the same time, the lock cannot be obtained and |
| 51625 | 51780 | ** SQLITE_BUSY is returned. |
| 51626 | 51781 | ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured, |
| | @@ -52618,10 +52773,11 @@ |
| 52618 | 52773 | |
| 52619 | 52774 | /* |
| 52620 | 52775 | ** Exit the recursive mutex on a Btree. |
| 52621 | 52776 | */ |
| 52622 | 52777 | SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){ |
| 52778 | + assert( sqlite3_mutex_held(p->db->mutex) ); |
| 52623 | 52779 | if( p->sharable ){ |
| 52624 | 52780 | assert( p->wantToLock>0 ); |
| 52625 | 52781 | p->wantToLock--; |
| 52626 | 52782 | if( p->wantToLock==0 ){ |
| 52627 | 52783 | unlockBtreeMutex(p); |
| | @@ -52865,11 +53021,11 @@ |
| 52865 | 53021 | ** |
| 52866 | 53022 | ** This routine has no effect on existing database connections. |
| 52867 | 53023 | ** The shared cache setting effects only future calls to |
| 52868 | 53024 | ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(). |
| 52869 | 53025 | */ |
| 52870 | | -SQLITE_API int sqlite3_enable_shared_cache(int enable){ |
| 53026 | +SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){ |
| 52871 | 53027 | sqlite3GlobalConfig.sharedCacheEnabled = enable; |
| 52872 | 53028 | return SQLITE_OK; |
| 52873 | 53029 | } |
| 52874 | 53030 | #endif |
| 52875 | 53031 | |
| | @@ -53379,14 +53535,19 @@ |
| 53379 | 53535 | ** prior to calling this routine. |
| 53380 | 53536 | */ |
| 53381 | 53537 | static int saveCursorPosition(BtCursor *pCur){ |
| 53382 | 53538 | int rc; |
| 53383 | 53539 | |
| 53384 | | - assert( CURSOR_VALID==pCur->eState ); |
| 53540 | + assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState ); |
| 53385 | 53541 | assert( 0==pCur->pKey ); |
| 53386 | 53542 | assert( cursorHoldsMutex(pCur) ); |
| 53387 | 53543 | |
| 53544 | + if( pCur->eState==CURSOR_SKIPNEXT ){ |
| 53545 | + pCur->eState = CURSOR_VALID; |
| 53546 | + }else{ |
| 53547 | + pCur->skipNext = 0; |
| 53548 | + } |
| 53388 | 53549 | rc = sqlite3BtreeKeySize(pCur, &pCur->nKey); |
| 53389 | 53550 | assert( rc==SQLITE_OK ); /* KeySize() cannot fail */ |
| 53390 | 53551 | |
| 53391 | 53552 | /* If this is an intKey table, then the above call to BtreeKeySize() |
| 53392 | 53553 | ** stores the integer key in pCur->nKey. In this case this value is |
| | @@ -53453,11 +53614,11 @@ |
| 53453 | 53614 | Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */ |
| 53454 | 53615 | BtCursor *pExcept /* Do not save this cursor */ |
| 53455 | 53616 | ){ |
| 53456 | 53617 | do{ |
| 53457 | 53618 | if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){ |
| 53458 | | - if( p->eState==CURSOR_VALID ){ |
| 53619 | + if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){ |
| 53459 | 53620 | int rc = saveCursorPosition(p); |
| 53460 | 53621 | if( SQLITE_OK!=rc ){ |
| 53461 | 53622 | return rc; |
| 53462 | 53623 | } |
| 53463 | 53624 | }else{ |
| | @@ -53525,21 +53686,23 @@ |
| 53525 | 53686 | ** at most one effective restoreCursorPosition() call after each |
| 53526 | 53687 | ** saveCursorPosition(). |
| 53527 | 53688 | */ |
| 53528 | 53689 | static int btreeRestoreCursorPosition(BtCursor *pCur){ |
| 53529 | 53690 | int rc; |
| 53691 | + int skipNext; |
| 53530 | 53692 | assert( cursorHoldsMutex(pCur) ); |
| 53531 | 53693 | assert( pCur->eState>=CURSOR_REQUIRESEEK ); |
| 53532 | 53694 | if( pCur->eState==CURSOR_FAULT ){ |
| 53533 | 53695 | return pCur->skipNext; |
| 53534 | 53696 | } |
| 53535 | 53697 | pCur->eState = CURSOR_INVALID; |
| 53536 | | - rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext); |
| 53698 | + rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext); |
| 53537 | 53699 | if( rc==SQLITE_OK ){ |
| 53538 | 53700 | sqlite3_free(pCur->pKey); |
| 53539 | 53701 | pCur->pKey = 0; |
| 53540 | 53702 | assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID ); |
| 53703 | + pCur->skipNext |= skipNext; |
| 53541 | 53704 | if( pCur->skipNext && pCur->eState==CURSOR_VALID ){ |
| 53542 | 53705 | pCur->eState = CURSOR_SKIPNEXT; |
| 53543 | 53706 | } |
| 53544 | 53707 | } |
| 53545 | 53708 | return rc; |
| | @@ -53587,13 +53750,14 @@ |
| 53587 | 53750 | rc = restoreCursorPosition(pCur); |
| 53588 | 53751 | if( rc ){ |
| 53589 | 53752 | *pDifferentRow = 1; |
| 53590 | 53753 | return rc; |
| 53591 | 53754 | } |
| 53592 | | - if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){ |
| 53755 | + if( pCur->eState!=CURSOR_VALID ){ |
| 53593 | 53756 | *pDifferentRow = 1; |
| 53594 | 53757 | }else{ |
| 53758 | + assert( pCur->skipNext==0 ); |
| 53595 | 53759 | *pDifferentRow = 0; |
| 53596 | 53760 | } |
| 53597 | 53761 | return SQLITE_OK; |
| 53598 | 53762 | } |
| 53599 | 53763 | |
| | @@ -54796,12 +54960,12 @@ |
| 54796 | 54960 | /* |
| 54797 | 54961 | ** The following asserts make sure that structures used by the btree are |
| 54798 | 54962 | ** the right size. This is to guard against size changes that result |
| 54799 | 54963 | ** when compiling on a different architecture. |
| 54800 | 54964 | */ |
| 54801 | | - assert( sizeof(i64)==8 || sizeof(i64)==4 ); |
| 54802 | | - assert( sizeof(u64)==8 || sizeof(u64)==4 ); |
| 54965 | + assert( sizeof(i64)==8 ); |
| 54966 | + assert( sizeof(u64)==8 ); |
| 54803 | 54967 | assert( sizeof(u32)==4 ); |
| 54804 | 54968 | assert( sizeof(u16)==2 ); |
| 54805 | 54969 | assert( sizeof(Pgno)==4 ); |
| 54806 | 54970 | |
| 54807 | 54971 | pBt = sqlite3MallocZero( sizeof(*pBt) ); |
| | @@ -56404,11 +56568,11 @@ |
| 56404 | 56568 | if( pBtree ){ |
| 56405 | 56569 | sqlite3BtreeEnter(pBtree); |
| 56406 | 56570 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 56407 | 56571 | int i; |
| 56408 | 56572 | if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){ |
| 56409 | | - if( p->eState==CURSOR_VALID ){ |
| 56573 | + if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){ |
| 56410 | 56574 | rc = saveCursorPosition(p); |
| 56411 | 56575 | if( rc!=SQLITE_OK ){ |
| 56412 | 56576 | (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0); |
| 56413 | 56577 | break; |
| 56414 | 56578 | } |
| | @@ -56810,10 +56974,12 @@ |
| 56810 | 56974 | ** to return an integer result code for historical reasons. |
| 56811 | 56975 | */ |
| 56812 | 56976 | SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){ |
| 56813 | 56977 | assert( cursorHoldsMutex(pCur) ); |
| 56814 | 56978 | assert( pCur->eState==CURSOR_VALID ); |
| 56979 | + assert( pCur->iPage>=0 ); |
| 56980 | + assert( pCur->iPage<BTCURSOR_MAX_DEPTH ); |
| 56815 | 56981 | assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 ); |
| 56816 | 56982 | getCellInfo(pCur); |
| 56817 | 56983 | *pSize = pCur->info.nPayload; |
| 56818 | 56984 | return SQLITE_OK; |
| 56819 | 56985 | } |
| | @@ -57288,19 +57454,21 @@ |
| 57288 | 57454 | return SQLITE_CORRUPT_BKPT; |
| 57289 | 57455 | } |
| 57290 | 57456 | return SQLITE_OK; |
| 57291 | 57457 | } |
| 57292 | 57458 | |
| 57293 | | -#if 0 |
| 57459 | +#if SQLITE_DEBUG |
| 57294 | 57460 | /* |
| 57295 | 57461 | ** Page pParent is an internal (non-leaf) tree page. This function |
| 57296 | 57462 | ** asserts that page number iChild is the left-child if the iIdx'th |
| 57297 | 57463 | ** cell in page pParent. Or, if iIdx is equal to the total number of |
| 57298 | 57464 | ** cells in pParent, that page number iChild is the right-child of |
| 57299 | 57465 | ** the page. |
| 57300 | 57466 | */ |
| 57301 | 57467 | static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){ |
| 57468 | + if( CORRUPT_DB ) return; /* The conditions tested below might not be true |
| 57469 | + ** in a corrupt database */ |
| 57302 | 57470 | assert( iIdx<=pParent->nCell ); |
| 57303 | 57471 | if( iIdx==pParent->nCell ){ |
| 57304 | 57472 | assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild ); |
| 57305 | 57473 | }else{ |
| 57306 | 57474 | assert( get4byte(findCell(pParent, iIdx))==iChild ); |
| | @@ -57321,23 +57489,15 @@ |
| 57321 | 57489 | static void moveToParent(BtCursor *pCur){ |
| 57322 | 57490 | assert( cursorHoldsMutex(pCur) ); |
| 57323 | 57491 | assert( pCur->eState==CURSOR_VALID ); |
| 57324 | 57492 | assert( pCur->iPage>0 ); |
| 57325 | 57493 | assert( pCur->apPage[pCur->iPage] ); |
| 57326 | | - |
| 57327 | | - /* UPDATE: It is actually possible for the condition tested by the assert |
| 57328 | | - ** below to be untrue if the database file is corrupt. This can occur if |
| 57329 | | - ** one cursor has modified page pParent while a reference to it is held |
| 57330 | | - ** by a second cursor. Which can only happen if a single page is linked |
| 57331 | | - ** into more than one b-tree structure in a corrupt database. */ |
| 57332 | | -#if 0 |
| 57333 | 57494 | assertParentIndex( |
| 57334 | 57495 | pCur->apPage[pCur->iPage-1], |
| 57335 | 57496 | pCur->aiIdx[pCur->iPage-1], |
| 57336 | 57497 | pCur->apPage[pCur->iPage]->pgno |
| 57337 | 57498 | ); |
| 57338 | | -#endif |
| 57339 | 57499 | testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell ); |
| 57340 | 57500 | |
| 57341 | 57501 | releasePage(pCur->apPage[pCur->iPage]); |
| 57342 | 57502 | pCur->iPage--; |
| 57343 | 57503 | pCur->info.nSize = 0; |
| | @@ -60259,11 +60419,12 @@ |
| 60259 | 60419 | ** the previous call, as the overflow cell data will have been |
| 60260 | 60420 | ** copied either into the body of a database page or into the new |
| 60261 | 60421 | ** pSpace buffer passed to the latter call to balance_nonroot(). |
| 60262 | 60422 | */ |
| 60263 | 60423 | u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize); |
| 60264 | | - rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints); |
| 60424 | + rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, |
| 60425 | + pCur->hints&BTREE_BULKLOAD); |
| 60265 | 60426 | if( pFree ){ |
| 60266 | 60427 | /* If pFree is not NULL, it points to the pSpace buffer used |
| 60267 | 60428 | ** by a previous call to balance_nonroot(). Its contents are |
| 60268 | 60429 | ** now stored either on real database pages or within the |
| 60269 | 60430 | ** new pSpace buffer, so it may be safely freed here. */ |
| | @@ -60280,10 +60441,11 @@ |
| 60280 | 60441 | pPage->nOverflow = 0; |
| 60281 | 60442 | |
| 60282 | 60443 | /* The next iteration of the do-loop balances the parent page. */ |
| 60283 | 60444 | releasePage(pPage); |
| 60284 | 60445 | pCur->iPage--; |
| 60446 | + assert( pCur->iPage>=0 ); |
| 60285 | 60447 | } |
| 60286 | 60448 | }while( rc==SQLITE_OK ); |
| 60287 | 60449 | |
| 60288 | 60450 | if( pFree ){ |
| 60289 | 60451 | sqlite3PageFree(pFree); |
| | @@ -60751,29 +60913,32 @@ |
| 60751 | 60913 | int rc; |
| 60752 | 60914 | unsigned char *pCell; |
| 60753 | 60915 | int i; |
| 60754 | 60916 | int hdr; |
| 60755 | 60917 | u16 szCell; |
| 60918 | + u8 hasChildren; |
| 60756 | 60919 | |
| 60757 | 60920 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 60758 | 60921 | if( pgno>btreePagecount(pBt) ){ |
| 60759 | 60922 | return SQLITE_CORRUPT_BKPT; |
| 60760 | 60923 | } |
| 60761 | 60924 | |
| 60762 | 60925 | rc = getAndInitPage(pBt, pgno, &pPage, 0); |
| 60763 | 60926 | if( rc ) return rc; |
| 60927 | + hasChildren = !pPage->leaf; |
| 60928 | + pPage->leaf = 1; /* Block looping if the database is corrupt */ |
| 60764 | 60929 | hdr = pPage->hdrOffset; |
| 60765 | 60930 | for(i=0; i<pPage->nCell; i++){ |
| 60766 | 60931 | pCell = findCell(pPage, i); |
| 60767 | | - if( !pPage->leaf ){ |
| 60932 | + if( hasChildren ){ |
| 60768 | 60933 | rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange); |
| 60769 | 60934 | if( rc ) goto cleardatabasepage_out; |
| 60770 | 60935 | } |
| 60771 | 60936 | rc = clearCell(pPage, pCell, &szCell); |
| 60772 | 60937 | if( rc ) goto cleardatabasepage_out; |
| 60773 | 60938 | } |
| 60774 | | - if( !pPage->leaf ){ |
| 60939 | + if( hasChildren ){ |
| 60775 | 60940 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 60776 | 60941 | if( rc ) goto cleardatabasepage_out; |
| 60777 | 60942 | }else if( pnChange ){ |
| 60778 | 60943 | assert( pPage->intKey ); |
| 60779 | 60944 | *pnChange += pPage->nCell; |
| | @@ -61922,17 +62087,26 @@ |
| 61922 | 62087 | pBt->btsFlags &= ~BTS_NO_WAL; |
| 61923 | 62088 | return rc; |
| 61924 | 62089 | } |
| 61925 | 62090 | |
| 61926 | 62091 | /* |
| 61927 | | -** set the mask of hint flags for cursor pCsr. Currently the only valid |
| 61928 | | -** values are 0 and BTREE_BULKLOAD. |
| 62092 | +** set the mask of hint flags for cursor pCsr. |
| 61929 | 62093 | */ |
| 61930 | 62094 | SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){ |
| 61931 | | - assert( mask==BTREE_BULKLOAD || mask==0 ); |
| 62095 | + assert( mask==BTREE_BULKLOAD || mask==BTREE_SEEK_EQ || mask==0 ); |
| 61932 | 62096 | pCsr->hints = mask; |
| 61933 | 62097 | } |
| 62098 | + |
| 62099 | +#ifdef SQLITE_DEBUG |
| 62100 | +/* |
| 62101 | +** Return true if the cursor has a hint specified. This routine is |
| 62102 | +** only used from within assert() statements |
| 62103 | +*/ |
| 62104 | +SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){ |
| 62105 | + return (pCsr->hints & mask)!=0; |
| 62106 | +} |
| 62107 | +#endif |
| 61934 | 62108 | |
| 61935 | 62109 | /* |
| 61936 | 62110 | ** Return true if the given Btree is read-only. |
| 61937 | 62111 | */ |
| 61938 | 62112 | SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){ |
| | @@ -62088,11 +62262,11 @@ |
| 62088 | 62262 | ** a pointer to the new sqlite3_backup object. |
| 62089 | 62263 | ** |
| 62090 | 62264 | ** If an error occurs, NULL is returned and an error code and error message |
| 62091 | 62265 | ** stored in database handle pDestDb. |
| 62092 | 62266 | */ |
| 62093 | | -SQLITE_API sqlite3_backup *sqlite3_backup_init( |
| 62267 | +SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init( |
| 62094 | 62268 | sqlite3* pDestDb, /* Database to write to */ |
| 62095 | 62269 | const char *zDestDb, /* Name of database within pDestDb */ |
| 62096 | 62270 | sqlite3* pSrcDb, /* Database connection to read from */ |
| 62097 | 62271 | const char *zSrcDb /* Name of database within pSrcDb */ |
| 62098 | 62272 | ){ |
| | @@ -62296,11 +62470,11 @@ |
| 62296 | 62470 | } |
| 62297 | 62471 | |
| 62298 | 62472 | /* |
| 62299 | 62473 | ** Copy nPage pages from the source b-tree to the destination. |
| 62300 | 62474 | */ |
| 62301 | | -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){ |
| 62475 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){ |
| 62302 | 62476 | int rc; |
| 62303 | 62477 | int destMode; /* Destination journal mode */ |
| 62304 | 62478 | int pgszSrc = 0; /* Source page size */ |
| 62305 | 62479 | int pgszDest = 0; /* Destination page size */ |
| 62306 | 62480 | |
| | @@ -62541,11 +62715,11 @@ |
| 62541 | 62715 | } |
| 62542 | 62716 | |
| 62543 | 62717 | /* |
| 62544 | 62718 | ** Release all resources associated with an sqlite3_backup* handle. |
| 62545 | 62719 | */ |
| 62546 | | -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){ |
| 62720 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){ |
| 62547 | 62721 | sqlite3_backup **pp; /* Ptr to head of pagers backup list */ |
| 62548 | 62722 | sqlite3 *pSrcDb; /* Source database connection */ |
| 62549 | 62723 | int rc; /* Value to return */ |
| 62550 | 62724 | |
| 62551 | 62725 | /* Enter the mutexes */ |
| | @@ -62593,11 +62767,11 @@ |
| 62593 | 62767 | |
| 62594 | 62768 | /* |
| 62595 | 62769 | ** Return the number of pages still to be backed up as of the most recent |
| 62596 | 62770 | ** call to sqlite3_backup_step(). |
| 62597 | 62771 | */ |
| 62598 | | -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){ |
| 62772 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){ |
| 62599 | 62773 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 62600 | 62774 | if( p==0 ){ |
| 62601 | 62775 | (void)SQLITE_MISUSE_BKPT; |
| 62602 | 62776 | return 0; |
| 62603 | 62777 | } |
| | @@ -62607,11 +62781,11 @@ |
| 62607 | 62781 | |
| 62608 | 62782 | /* |
| 62609 | 62783 | ** Return the total number of pages in the source database as of the most |
| 62610 | 62784 | ** recent call to sqlite3_backup_step(). |
| 62611 | 62785 | */ |
| 62612 | | -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){ |
| 62786 | +SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){ |
| 62613 | 62787 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 62614 | 62788 | if( p==0 ){ |
| 62615 | 62789 | (void)SQLITE_MISUSE_BKPT; |
| 62616 | 62790 | return 0; |
| 62617 | 62791 | } |
| | @@ -63822,11 +63996,11 @@ |
| 63822 | 63996 | ** by calling sqlite3ValueNew(). |
| 63823 | 63997 | ** |
| 63824 | 63998 | ** Otherwise, if the second argument is non-zero, then this function is |
| 63825 | 63999 | ** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not |
| 63826 | 64000 | ** already been allocated, allocate the UnpackedRecord structure that |
| 63827 | | -** that function will return to its caller here. Then return a pointer |
| 64001 | +** that function will return to its caller here. Then return a pointer to |
| 63828 | 64002 | ** an sqlite3_value within the UnpackedRecord.a[] array. |
| 63829 | 64003 | */ |
| 63830 | 64004 | static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ |
| 63831 | 64005 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 63832 | 64006 | if( p ){ |
| | @@ -63866,10 +64040,117 @@ |
| 63866 | 64040 | UNUSED_PARAMETER(p); |
| 63867 | 64041 | #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */ |
| 63868 | 64042 | return sqlite3ValueNew(db); |
| 63869 | 64043 | } |
| 63870 | 64044 | |
| 64045 | +/* |
| 64046 | +** The expression object indicated by the second argument is guaranteed |
| 64047 | +** to be a scalar SQL function. If |
| 64048 | +** |
| 64049 | +** * all function arguments are SQL literals, |
| 64050 | +** * the SQLITE_FUNC_CONSTANT function flag is set, and |
| 64051 | +** * the SQLITE_FUNC_NEEDCOLL function flag is not set, |
| 64052 | +** |
| 64053 | +** then this routine attempts to invoke the SQL function. Assuming no |
| 64054 | +** error occurs, output parameter (*ppVal) is set to point to a value |
| 64055 | +** object containing the result before returning SQLITE_OK. |
| 64056 | +** |
| 64057 | +** Affinity aff is applied to the result of the function before returning. |
| 64058 | +** If the result is a text value, the sqlite3_value object uses encoding |
| 64059 | +** enc. |
| 64060 | +** |
| 64061 | +** If the conditions above are not met, this function returns SQLITE_OK |
| 64062 | +** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to |
| 64063 | +** NULL and an SQLite error code returned. |
| 64064 | +*/ |
| 64065 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 64066 | +static int valueFromFunction( |
| 64067 | + sqlite3 *db, /* The database connection */ |
| 64068 | + Expr *p, /* The expression to evaluate */ |
| 64069 | + u8 enc, /* Encoding to use */ |
| 64070 | + u8 aff, /* Affinity to use */ |
| 64071 | + sqlite3_value **ppVal, /* Write the new value here */ |
| 64072 | + struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */ |
| 64073 | +){ |
| 64074 | + sqlite3_context ctx; /* Context object for function invocation */ |
| 64075 | + sqlite3_value **apVal = 0; /* Function arguments */ |
| 64076 | + int nVal = 0; /* Size of apVal[] array */ |
| 64077 | + FuncDef *pFunc = 0; /* Function definition */ |
| 64078 | + sqlite3_value *pVal = 0; /* New value */ |
| 64079 | + int rc = SQLITE_OK; /* Return code */ |
| 64080 | + int nName; /* Size of function name in bytes */ |
| 64081 | + ExprList *pList = 0; /* Function arguments */ |
| 64082 | + int i; /* Iterator variable */ |
| 64083 | + |
| 64084 | + assert( pCtx!=0 ); |
| 64085 | + assert( (p->flags & EP_TokenOnly)==0 ); |
| 64086 | + pList = p->x.pList; |
| 64087 | + if( pList ) nVal = pList->nExpr; |
| 64088 | + nName = sqlite3Strlen30(p->u.zToken); |
| 64089 | + pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0); |
| 64090 | + assert( pFunc ); |
| 64091 | + if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0 |
| 64092 | + || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) |
| 64093 | + ){ |
| 64094 | + return SQLITE_OK; |
| 64095 | + } |
| 64096 | + |
| 64097 | + if( pList ){ |
| 64098 | + apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal); |
| 64099 | + if( apVal==0 ){ |
| 64100 | + rc = SQLITE_NOMEM; |
| 64101 | + goto value_from_function_out; |
| 64102 | + } |
| 64103 | + for(i=0; i<nVal; i++){ |
| 64104 | + rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]); |
| 64105 | + if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out; |
| 64106 | + } |
| 64107 | + } |
| 64108 | + |
| 64109 | + pVal = valueNew(db, pCtx); |
| 64110 | + if( pVal==0 ){ |
| 64111 | + rc = SQLITE_NOMEM; |
| 64112 | + goto value_from_function_out; |
| 64113 | + } |
| 64114 | + |
| 64115 | + assert( pCtx->pParse->rc==SQLITE_OK ); |
| 64116 | + memset(&ctx, 0, sizeof(ctx)); |
| 64117 | + ctx.pOut = pVal; |
| 64118 | + ctx.pFunc = pFunc; |
| 64119 | + pFunc->xFunc(&ctx, nVal, apVal); |
| 64120 | + if( ctx.isError ){ |
| 64121 | + rc = ctx.isError; |
| 64122 | + sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal)); |
| 64123 | + }else{ |
| 64124 | + sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8); |
| 64125 | + assert( rc==SQLITE_OK ); |
| 64126 | + rc = sqlite3VdbeChangeEncoding(pVal, enc); |
| 64127 | + if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){ |
| 64128 | + rc = SQLITE_TOOBIG; |
| 64129 | + pCtx->pParse->nErr++; |
| 64130 | + } |
| 64131 | + } |
| 64132 | + pCtx->pParse->rc = rc; |
| 64133 | + |
| 64134 | + value_from_function_out: |
| 64135 | + if( rc!=SQLITE_OK ){ |
| 64136 | + pVal = 0; |
| 64137 | + } |
| 64138 | + if( apVal ){ |
| 64139 | + for(i=0; i<nVal; i++){ |
| 64140 | + sqlite3ValueFree(apVal[i]); |
| 64141 | + } |
| 64142 | + sqlite3DbFree(db, apVal); |
| 64143 | + } |
| 64144 | + |
| 64145 | + *ppVal = pVal; |
| 64146 | + return rc; |
| 64147 | +} |
| 64148 | +#else |
| 64149 | +# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK |
| 64150 | +#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */ |
| 64151 | + |
| 63871 | 64152 | /* |
| 63872 | 64153 | ** Extract a value from the supplied expression in the manner described |
| 63873 | 64154 | ** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object |
| 63874 | 64155 | ** using valueNew(). |
| 63875 | 64156 | ** |
| | @@ -63897,10 +64178,16 @@ |
| 63897 | 64178 | *ppVal = 0; |
| 63898 | 64179 | return SQLITE_OK; |
| 63899 | 64180 | } |
| 63900 | 64181 | while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft; |
| 63901 | 64182 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 64183 | + |
| 64184 | + /* Compressed expressions only appear when parsing the DEFAULT clause |
| 64185 | + ** on a table column definition, and hence only when pCtx==0. This |
| 64186 | + ** check ensures that an EP_TokenOnly expression is never passed down |
| 64187 | + ** into valueFromFunction(). */ |
| 64188 | + assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 ); |
| 63902 | 64189 | |
| 63903 | 64190 | if( op==TK_CAST ){ |
| 63904 | 64191 | u8 aff = sqlite3AffinityType(pExpr->u.zToken,0); |
| 63905 | 64192 | rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx); |
| 63906 | 64193 | testcase( rc!=SQLITE_OK ); |
| | @@ -63973,10 +64260,16 @@ |
| 63973 | 64260 | assert( zVal[nVal]=='\'' ); |
| 63974 | 64261 | sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2, |
| 63975 | 64262 | 0, SQLITE_DYNAMIC); |
| 63976 | 64263 | } |
| 63977 | 64264 | #endif |
| 64265 | + |
| 64266 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 64267 | + else if( op==TK_FUNCTION && pCtx!=0 ){ |
| 64268 | + rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx); |
| 64269 | + } |
| 64270 | +#endif |
| 63978 | 64271 | |
| 63979 | 64272 | *ppVal = pVal; |
| 63980 | 64273 | return rc; |
| 63981 | 64274 | |
| 63982 | 64275 | no_mem: |
| | @@ -64363,11 +64656,11 @@ |
| 64363 | 64656 | } |
| 64364 | 64657 | |
| 64365 | 64658 | /* |
| 64366 | 64659 | ** Return the SQL associated with a prepared statement |
| 64367 | 64660 | */ |
| 64368 | | -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){ |
| 64661 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){ |
| 64369 | 64662 | Vdbe *p = (Vdbe *)pStmt; |
| 64370 | 64663 | return (p && p->isPrepareV2) ? p->zSql : 0; |
| 64371 | 64664 | } |
| 64372 | 64665 | |
| 64373 | 64666 | /* |
| | @@ -65426,11 +65719,11 @@ |
| 65426 | 65719 | break; |
| 65427 | 65720 | } |
| 65428 | 65721 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 65429 | 65722 | case P4_VTAB: { |
| 65430 | 65723 | sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab; |
| 65431 | | - sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab->pModule); |
| 65724 | + sqlite3_snprintf(nTemp, zTemp, "vtab:%p", pVtab); |
| 65432 | 65725 | break; |
| 65433 | 65726 | } |
| 65434 | 65727 | #endif |
| 65435 | 65728 | case P4_INTARRAY: { |
| 65436 | 65729 | sqlite3_snprintf(nTemp, zTemp, "intarray"); |
| | @@ -66090,13 +66383,13 @@ |
| 66090 | 66383 | } |
| 66091 | 66384 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 66092 | 66385 | else if( pCx->pVtabCursor ){ |
| 66093 | 66386 | sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor; |
| 66094 | 66387 | const sqlite3_module *pModule = pVtabCursor->pVtab->pModule; |
| 66095 | | - p->inVtabMethod = 1; |
| 66388 | + assert( pVtabCursor->pVtab->nRef>0 ); |
| 66389 | + pVtabCursor->pVtab->nRef--; |
| 66096 | 66390 | pModule->xClose(pVtabCursor); |
| 66097 | | - p->inVtabMethod = 0; |
| 66098 | 66391 | } |
| 66099 | 66392 | #endif |
| 66100 | 66393 | } |
| 66101 | 66394 | |
| 66102 | 66395 | /* |
| | @@ -66451,11 +66744,11 @@ |
| 66451 | 66744 | |
| 66452 | 66745 | /* Delete the master journal file. This commits the transaction. After |
| 66453 | 66746 | ** doing this the directory is synced again before any individual |
| 66454 | 66747 | ** transaction files are deleted. |
| 66455 | 66748 | */ |
| 66456 | | - rc = sqlite3OsDelete(pVfs, zMaster, 1); |
| 66749 | + rc = sqlite3OsDelete(pVfs, zMaster, needSync); |
| 66457 | 66750 | sqlite3DbFree(db, zMaster); |
| 66458 | 66751 | zMaster = 0; |
| 66459 | 66752 | if( rc ){ |
| 66460 | 66753 | return rc; |
| 66461 | 66754 | } |
| | @@ -68519,11 +68812,11 @@ |
| 68519 | 68812 | ** execution environment changes in a way that would alter the program |
| 68520 | 68813 | ** that sqlite3_prepare() generates. For example, if new functions or |
| 68521 | 68814 | ** collating sequences are registered or if an authorizer function is |
| 68522 | 68815 | ** added or changed. |
| 68523 | 68816 | */ |
| 68524 | | -SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){ |
| 68817 | +SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){ |
| 68525 | 68818 | Vdbe *p = (Vdbe*)pStmt; |
| 68526 | 68819 | return p==0 || p->expired; |
| 68527 | 68820 | } |
| 68528 | 68821 | #endif |
| 68529 | 68822 | |
| | @@ -68556,11 +68849,11 @@ |
| 68556 | 68849 | ** machine. |
| 68557 | 68850 | ** |
| 68558 | 68851 | ** This routine sets the error code and string returned by |
| 68559 | 68852 | ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). |
| 68560 | 68853 | */ |
| 68561 | | -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){ |
| 68854 | +SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){ |
| 68562 | 68855 | int rc; |
| 68563 | 68856 | if( pStmt==0 ){ |
| 68564 | 68857 | /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL |
| 68565 | 68858 | ** pointer is a harmless no-op. */ |
| 68566 | 68859 | rc = SQLITE_OK; |
| | @@ -68582,11 +68875,11 @@ |
| 68582 | 68875 | ** the prior execution is returned. |
| 68583 | 68876 | ** |
| 68584 | 68877 | ** This routine sets the error code and string returned by |
| 68585 | 68878 | ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). |
| 68586 | 68879 | */ |
| 68587 | | -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){ |
| 68880 | +SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){ |
| 68588 | 68881 | int rc; |
| 68589 | 68882 | if( pStmt==0 ){ |
| 68590 | 68883 | rc = SQLITE_OK; |
| 68591 | 68884 | }else{ |
| 68592 | 68885 | Vdbe *v = (Vdbe*)pStmt; |
| | @@ -68601,11 +68894,11 @@ |
| 68601 | 68894 | } |
| 68602 | 68895 | |
| 68603 | 68896 | /* |
| 68604 | 68897 | ** Set all the parameters in the compiled SQL statement to NULL. |
| 68605 | 68898 | */ |
| 68606 | | -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){ |
| 68899 | +SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){ |
| 68607 | 68900 | int i; |
| 68608 | 68901 | int rc = SQLITE_OK; |
| 68609 | 68902 | Vdbe *p = (Vdbe*)pStmt; |
| 68610 | 68903 | #if SQLITE_THREADSAFE |
| 68611 | 68904 | sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex; |
| | @@ -68625,54 +68918,54 @@ |
| 68625 | 68918 | |
| 68626 | 68919 | /**************************** sqlite3_value_ ******************************* |
| 68627 | 68920 | ** The following routines extract information from a Mem or sqlite3_value |
| 68628 | 68921 | ** structure. |
| 68629 | 68922 | */ |
| 68630 | | -SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){ |
| 68923 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){ |
| 68631 | 68924 | Mem *p = (Mem*)pVal; |
| 68632 | 68925 | if( p->flags & (MEM_Blob|MEM_Str) ){ |
| 68633 | 68926 | sqlite3VdbeMemExpandBlob(p); |
| 68634 | 68927 | p->flags |= MEM_Blob; |
| 68635 | 68928 | return p->n ? p->z : 0; |
| 68636 | 68929 | }else{ |
| 68637 | 68930 | return sqlite3_value_text(pVal); |
| 68638 | 68931 | } |
| 68639 | 68932 | } |
| 68640 | | -SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){ |
| 68933 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){ |
| 68641 | 68934 | return sqlite3ValueBytes(pVal, SQLITE_UTF8); |
| 68642 | 68935 | } |
| 68643 | | -SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){ |
| 68936 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){ |
| 68644 | 68937 | return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE); |
| 68645 | 68938 | } |
| 68646 | | -SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){ |
| 68939 | +SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){ |
| 68647 | 68940 | return sqlite3VdbeRealValue((Mem*)pVal); |
| 68648 | 68941 | } |
| 68649 | | -SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){ |
| 68942 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){ |
| 68650 | 68943 | return (int)sqlite3VdbeIntValue((Mem*)pVal); |
| 68651 | 68944 | } |
| 68652 | | -SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){ |
| 68945 | +SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){ |
| 68653 | 68946 | return sqlite3VdbeIntValue((Mem*)pVal); |
| 68654 | 68947 | } |
| 68655 | | -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ |
| 68948 | +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){ |
| 68656 | 68949 | return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8); |
| 68657 | 68950 | } |
| 68658 | 68951 | #ifndef SQLITE_OMIT_UTF16 |
| 68659 | | -SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){ |
| 68952 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){ |
| 68660 | 68953 | return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); |
| 68661 | 68954 | } |
| 68662 | | -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){ |
| 68955 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){ |
| 68663 | 68956 | return sqlite3ValueText(pVal, SQLITE_UTF16BE); |
| 68664 | 68957 | } |
| 68665 | | -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){ |
| 68958 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){ |
| 68666 | 68959 | return sqlite3ValueText(pVal, SQLITE_UTF16LE); |
| 68667 | 68960 | } |
| 68668 | 68961 | #endif /* SQLITE_OMIT_UTF16 */ |
| 68669 | 68962 | /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five |
| 68670 | 68963 | ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating |
| 68671 | 68964 | ** point number string BLOB NULL |
| 68672 | 68965 | */ |
| 68673 | | -SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){ |
| 68966 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){ |
| 68674 | 68967 | static const u8 aType[] = { |
| 68675 | 68968 | SQLITE_BLOB, /* 0x00 */ |
| 68676 | 68969 | SQLITE_NULL, /* 0x01 */ |
| 68677 | 68970 | SQLITE_TEXT, /* 0x02 */ |
| 68678 | 68971 | SQLITE_NULL, /* 0x03 */ |
| | @@ -68744,21 +69037,21 @@ |
| 68744 | 69037 | xDel((void*)p); |
| 68745 | 69038 | } |
| 68746 | 69039 | if( pCtx ) sqlite3_result_error_toobig(pCtx); |
| 68747 | 69040 | return SQLITE_TOOBIG; |
| 68748 | 69041 | } |
| 68749 | | -SQLITE_API void sqlite3_result_blob( |
| 69042 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob( |
| 68750 | 69043 | sqlite3_context *pCtx, |
| 68751 | 69044 | const void *z, |
| 68752 | 69045 | int n, |
| 68753 | 69046 | void (*xDel)(void *) |
| 68754 | 69047 | ){ |
| 68755 | 69048 | assert( n>=0 ); |
| 68756 | 69049 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68757 | 69050 | setResultStrOrError(pCtx, z, n, 0, xDel); |
| 68758 | 69051 | } |
| 68759 | | -SQLITE_API void sqlite3_result_blob64( |
| 69052 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64( |
| 68760 | 69053 | sqlite3_context *pCtx, |
| 68761 | 69054 | const void *z, |
| 68762 | 69055 | sqlite3_uint64 n, |
| 68763 | 69056 | void (*xDel)(void *) |
| 68764 | 69057 | ){ |
| | @@ -68768,50 +69061,50 @@ |
| 68768 | 69061 | (void)invokeValueDestructor(z, xDel, pCtx); |
| 68769 | 69062 | }else{ |
| 68770 | 69063 | setResultStrOrError(pCtx, z, (int)n, 0, xDel); |
| 68771 | 69064 | } |
| 68772 | 69065 | } |
| 68773 | | -SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 69066 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){ |
| 68774 | 69067 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68775 | 69068 | sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); |
| 68776 | 69069 | } |
| 68777 | | -SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 69070 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ |
| 68778 | 69071 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68779 | 69072 | pCtx->isError = SQLITE_ERROR; |
| 68780 | 69073 | pCtx->fErrorOrAux = 1; |
| 68781 | 69074 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); |
| 68782 | 69075 | } |
| 68783 | 69076 | #ifndef SQLITE_OMIT_UTF16 |
| 68784 | | -SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 69077 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ |
| 68785 | 69078 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68786 | 69079 | pCtx->isError = SQLITE_ERROR; |
| 68787 | 69080 | pCtx->fErrorOrAux = 1; |
| 68788 | 69081 | sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); |
| 68789 | 69082 | } |
| 68790 | 69083 | #endif |
| 68791 | | -SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 69084 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){ |
| 68792 | 69085 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68793 | 69086 | sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); |
| 68794 | 69087 | } |
| 68795 | | -SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 69088 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ |
| 68796 | 69089 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68797 | 69090 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 68798 | 69091 | } |
| 68799 | | -SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ |
| 69092 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){ |
| 68800 | 69093 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68801 | 69094 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 68802 | 69095 | } |
| 68803 | | -SQLITE_API void sqlite3_result_text( |
| 69096 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text( |
| 68804 | 69097 | sqlite3_context *pCtx, |
| 68805 | 69098 | const char *z, |
| 68806 | 69099 | int n, |
| 68807 | 69100 | void (*xDel)(void *) |
| 68808 | 69101 | ){ |
| 68809 | 69102 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68810 | 69103 | setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); |
| 68811 | 69104 | } |
| 68812 | | -SQLITE_API void sqlite3_result_text64( |
| 69105 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text64( |
| 68813 | 69106 | sqlite3_context *pCtx, |
| 68814 | 69107 | const char *z, |
| 68815 | 69108 | sqlite3_uint64 n, |
| 68816 | 69109 | void (*xDel)(void *), |
| 68817 | 69110 | unsigned char enc |
| | @@ -68824,69 +69117,69 @@ |
| 68824 | 69117 | }else{ |
| 68825 | 69118 | setResultStrOrError(pCtx, z, (int)n, enc, xDel); |
| 68826 | 69119 | } |
| 68827 | 69120 | } |
| 68828 | 69121 | #ifndef SQLITE_OMIT_UTF16 |
| 68829 | | -SQLITE_API void sqlite3_result_text16( |
| 69122 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16( |
| 68830 | 69123 | sqlite3_context *pCtx, |
| 68831 | 69124 | const void *z, |
| 68832 | 69125 | int n, |
| 68833 | 69126 | void (*xDel)(void *) |
| 68834 | 69127 | ){ |
| 68835 | 69128 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68836 | 69129 | setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel); |
| 68837 | 69130 | } |
| 68838 | | -SQLITE_API void sqlite3_result_text16be( |
| 69131 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be( |
| 68839 | 69132 | sqlite3_context *pCtx, |
| 68840 | 69133 | const void *z, |
| 68841 | 69134 | int n, |
| 68842 | 69135 | void (*xDel)(void *) |
| 68843 | 69136 | ){ |
| 68844 | 69137 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68845 | 69138 | setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel); |
| 68846 | 69139 | } |
| 68847 | | -SQLITE_API void sqlite3_result_text16le( |
| 69140 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le( |
| 68848 | 69141 | sqlite3_context *pCtx, |
| 68849 | 69142 | const void *z, |
| 68850 | 69143 | int n, |
| 68851 | 69144 | void (*xDel)(void *) |
| 68852 | 69145 | ){ |
| 68853 | 69146 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68854 | 69147 | setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel); |
| 68855 | 69148 | } |
| 68856 | 69149 | #endif /* SQLITE_OMIT_UTF16 */ |
| 68857 | | -SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 69150 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ |
| 68858 | 69151 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68859 | 69152 | sqlite3VdbeMemCopy(pCtx->pOut, pValue); |
| 68860 | 69153 | } |
| 68861 | | -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ |
| 69154 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ |
| 68862 | 69155 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68863 | 69156 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n); |
| 68864 | 69157 | } |
| 68865 | | -SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 69158 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 68866 | 69159 | pCtx->isError = errCode; |
| 68867 | 69160 | pCtx->fErrorOrAux = 1; |
| 68868 | 69161 | #ifdef SQLITE_DEBUG |
| 68869 | | - pCtx->pVdbe->rcApp = errCode; |
| 69162 | + if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; |
| 68870 | 69163 | #endif |
| 68871 | 69164 | if( pCtx->pOut->flags & MEM_Null ){ |
| 68872 | 69165 | sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1, |
| 68873 | 69166 | SQLITE_UTF8, SQLITE_STATIC); |
| 68874 | 69167 | } |
| 68875 | 69168 | } |
| 68876 | 69169 | |
| 68877 | 69170 | /* Force an SQLITE_TOOBIG error. */ |
| 68878 | | -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 69171 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){ |
| 68879 | 69172 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68880 | 69173 | pCtx->isError = SQLITE_TOOBIG; |
| 68881 | 69174 | pCtx->fErrorOrAux = 1; |
| 68882 | 69175 | sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, |
| 68883 | 69176 | SQLITE_UTF8, SQLITE_STATIC); |
| 68884 | 69177 | } |
| 68885 | 69178 | |
| 68886 | 69179 | /* An SQLITE_NOMEM error. */ |
| 68887 | | -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 69180 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){ |
| 68888 | 69181 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 68889 | 69182 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 68890 | 69183 | pCtx->isError = SQLITE_NOMEM; |
| 68891 | 69184 | pCtx->fErrorOrAux = 1; |
| 68892 | 69185 | pCtx->pOut->db->mallocFailed = 1; |
| | @@ -69055,11 +69348,11 @@ |
| 69055 | 69348 | /* |
| 69056 | 69349 | ** This is the top-level implementation of sqlite3_step(). Call |
| 69057 | 69350 | ** sqlite3Step() to do most of the work. If a schema error occurs, |
| 69058 | 69351 | ** call sqlite3Reprepare() and try again. |
| 69059 | 69352 | */ |
| 69060 | | -SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){ |
| 69353 | +SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){ |
| 69061 | 69354 | int rc = SQLITE_OK; /* Result from sqlite3Step() */ |
| 69062 | 69355 | int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */ |
| 69063 | 69356 | Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */ |
| 69064 | 69357 | int cnt = 0; /* Counter to prevent infinite loop of reprepares */ |
| 69065 | 69358 | sqlite3 *db; /* The database connection */ |
| | @@ -69106,11 +69399,11 @@ |
| 69106 | 69399 | |
| 69107 | 69400 | /* |
| 69108 | 69401 | ** Extract the user data from a sqlite3_context structure and return a |
| 69109 | 69402 | ** pointer to it. |
| 69110 | 69403 | */ |
| 69111 | | -SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ |
| 69404 | +SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){ |
| 69112 | 69405 | assert( p && p->pFunc ); |
| 69113 | 69406 | return p->pFunc->pUserData; |
| 69114 | 69407 | } |
| 69115 | 69408 | |
| 69116 | 69409 | /* |
| | @@ -69121,26 +69414,36 @@ |
| 69121 | 69414 | ** returns a copy of the pointer to the database connection (the 1st |
| 69122 | 69415 | ** parameter) of the sqlite3_create_function() and |
| 69123 | 69416 | ** sqlite3_create_function16() routines that originally registered the |
| 69124 | 69417 | ** application defined function. |
| 69125 | 69418 | */ |
| 69126 | | -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ |
| 69419 | +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){ |
| 69127 | 69420 | assert( p && p->pFunc ); |
| 69128 | 69421 | return p->pOut->db; |
| 69129 | 69422 | } |
| 69130 | 69423 | |
| 69131 | 69424 | /* |
| 69132 | | -** Return the current time for a statement |
| 69425 | +** Return the current time for a statement. If the current time |
| 69426 | +** is requested more than once within the same run of a single prepared |
| 69427 | +** statement, the exact same time is returned for each invocation regardless |
| 69428 | +** of the amount of time that elapses between invocations. In other words, |
| 69429 | +** the time returned is always the time of the first call. |
| 69133 | 69430 | */ |
| 69134 | 69431 | SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){ |
| 69135 | | - Vdbe *v = p->pVdbe; |
| 69136 | 69432 | int rc; |
| 69137 | | - if( v->iCurrentTime==0 ){ |
| 69138 | | - rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &v->iCurrentTime); |
| 69139 | | - if( rc ) v->iCurrentTime = 0; |
| 69433 | +#ifndef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 69434 | + sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime; |
| 69435 | + assert( p->pVdbe!=0 ); |
| 69436 | +#else |
| 69437 | + sqlite3_int64 iTime = 0; |
| 69438 | + sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime; |
| 69439 | +#endif |
| 69440 | + if( *piTime==0 ){ |
| 69441 | + rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime); |
| 69442 | + if( rc ) *piTime = 0; |
| 69140 | 69443 | } |
| 69141 | | - return v->iCurrentTime; |
| 69444 | + return *piTime; |
| 69142 | 69445 | } |
| 69143 | 69446 | |
| 69144 | 69447 | /* |
| 69145 | 69448 | ** The following is the implementation of an SQL function that always |
| 69146 | 69449 | ** fails with an error message stating that the function is used in the |
| | @@ -69187,11 +69490,11 @@ |
| 69187 | 69490 | /* |
| 69188 | 69491 | ** Allocate or return the aggregate context for a user function. A new |
| 69189 | 69492 | ** context is allocated on the first call. Subsequent calls return the |
| 69190 | 69493 | ** same context that was returned on prior calls. |
| 69191 | 69494 | */ |
| 69192 | | -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ |
| 69495 | +SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){ |
| 69193 | 69496 | assert( p && p->pFunc && p->pFunc->xStep ); |
| 69194 | 69497 | assert( sqlite3_mutex_held(p->pOut->db->mutex) ); |
| 69195 | 69498 | testcase( nByte<0 ); |
| 69196 | 69499 | if( (p->pMem->flags & MEM_Agg)==0 ){ |
| 69197 | 69500 | return createAggContext(p, nByte); |
| | @@ -69202,14 +69505,19 @@ |
| 69202 | 69505 | |
| 69203 | 69506 | /* |
| 69204 | 69507 | ** Return the auxiliary data pointer, if any, for the iArg'th argument to |
| 69205 | 69508 | ** the user-function defined by pCtx. |
| 69206 | 69509 | */ |
| 69207 | | -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 69510 | +SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 69208 | 69511 | AuxData *pAuxData; |
| 69209 | 69512 | |
| 69210 | 69513 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 69514 | +#if SQLITE_ENABLE_STAT3_OR_STAT4 |
| 69515 | + if( pCtx->pVdbe==0 ) return 0; |
| 69516 | +#else |
| 69517 | + assert( pCtx->pVdbe!=0 ); |
| 69518 | +#endif |
| 69211 | 69519 | for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 69212 | 69520 | if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 69213 | 69521 | } |
| 69214 | 69522 | |
| 69215 | 69523 | return (pAuxData ? pAuxData->pAux : 0); |
| | @@ -69218,11 +69526,11 @@ |
| 69218 | 69526 | /* |
| 69219 | 69527 | ** Set the auxiliary data pointer and delete function, for the iArg'th |
| 69220 | 69528 | ** argument to the user-function defined by pCtx. Any previous value is |
| 69221 | 69529 | ** deleted by calling the delete function specified when it was set. |
| 69222 | 69530 | */ |
| 69223 | | -SQLITE_API void sqlite3_set_auxdata( |
| 69531 | +SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata( |
| 69224 | 69532 | sqlite3_context *pCtx, |
| 69225 | 69533 | int iArg, |
| 69226 | 69534 | void *pAux, |
| 69227 | 69535 | void (*xDelete)(void*) |
| 69228 | 69536 | ){ |
| | @@ -69229,10 +69537,15 @@ |
| 69229 | 69537 | AuxData *pAuxData; |
| 69230 | 69538 | Vdbe *pVdbe = pCtx->pVdbe; |
| 69231 | 69539 | |
| 69232 | 69540 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 69233 | 69541 | if( iArg<0 ) goto failed; |
| 69542 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 69543 | + if( pVdbe==0 ) goto failed; |
| 69544 | +#else |
| 69545 | + assert( pVdbe!=0 ); |
| 69546 | +#endif |
| 69234 | 69547 | |
| 69235 | 69548 | for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 69236 | 69549 | if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 69237 | 69550 | } |
| 69238 | 69551 | if( pAuxData==0 ){ |
| | @@ -69268,29 +69581,29 @@ |
| 69268 | 69581 | ** This function is deprecated. Do not use it for new code. It is |
| 69269 | 69582 | ** provide only to avoid breaking legacy code. New aggregate function |
| 69270 | 69583 | ** implementations should keep their own counts within their aggregate |
| 69271 | 69584 | ** context. |
| 69272 | 69585 | */ |
| 69273 | | -SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){ |
| 69586 | +SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){ |
| 69274 | 69587 | assert( p && p->pMem && p->pFunc && p->pFunc->xStep ); |
| 69275 | 69588 | return p->pMem->n; |
| 69276 | 69589 | } |
| 69277 | 69590 | #endif |
| 69278 | 69591 | |
| 69279 | 69592 | /* |
| 69280 | 69593 | ** Return the number of columns in the result set for the statement pStmt. |
| 69281 | 69594 | */ |
| 69282 | | -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){ |
| 69595 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){ |
| 69283 | 69596 | Vdbe *pVm = (Vdbe *)pStmt; |
| 69284 | 69597 | return pVm ? pVm->nResColumn : 0; |
| 69285 | 69598 | } |
| 69286 | 69599 | |
| 69287 | 69600 | /* |
| 69288 | 69601 | ** Return the number of values available from the current row of the |
| 69289 | 69602 | ** currently executing statement pStmt. |
| 69290 | 69603 | */ |
| 69291 | | -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){ |
| 69604 | +SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){ |
| 69292 | 69605 | Vdbe *pVm = (Vdbe *)pStmt; |
| 69293 | 69606 | if( pVm==0 || pVm->pResultSet==0 ) return 0; |
| 69294 | 69607 | return pVm->nResColumn; |
| 69295 | 69608 | } |
| 69296 | 69609 | |
| | @@ -69388,67 +69701,67 @@ |
| 69388 | 69701 | |
| 69389 | 69702 | /**************************** sqlite3_column_ ******************************* |
| 69390 | 69703 | ** The following routines are used to access elements of the current row |
| 69391 | 69704 | ** in the result set. |
| 69392 | 69705 | */ |
| 69393 | | -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){ |
| 69706 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){ |
| 69394 | 69707 | const void *val; |
| 69395 | 69708 | val = sqlite3_value_blob( columnMem(pStmt,i) ); |
| 69396 | 69709 | /* Even though there is no encoding conversion, value_blob() might |
| 69397 | 69710 | ** need to call malloc() to expand the result of a zeroblob() |
| 69398 | 69711 | ** expression. |
| 69399 | 69712 | */ |
| 69400 | 69713 | columnMallocFailure(pStmt); |
| 69401 | 69714 | return val; |
| 69402 | 69715 | } |
| 69403 | | -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ |
| 69716 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){ |
| 69404 | 69717 | int val = sqlite3_value_bytes( columnMem(pStmt,i) ); |
| 69405 | 69718 | columnMallocFailure(pStmt); |
| 69406 | 69719 | return val; |
| 69407 | 69720 | } |
| 69408 | | -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ |
| 69721 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){ |
| 69409 | 69722 | int val = sqlite3_value_bytes16( columnMem(pStmt,i) ); |
| 69410 | 69723 | columnMallocFailure(pStmt); |
| 69411 | 69724 | return val; |
| 69412 | 69725 | } |
| 69413 | | -SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){ |
| 69726 | +SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){ |
| 69414 | 69727 | double val = sqlite3_value_double( columnMem(pStmt,i) ); |
| 69415 | 69728 | columnMallocFailure(pStmt); |
| 69416 | 69729 | return val; |
| 69417 | 69730 | } |
| 69418 | | -SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){ |
| 69731 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){ |
| 69419 | 69732 | int val = sqlite3_value_int( columnMem(pStmt,i) ); |
| 69420 | 69733 | columnMallocFailure(pStmt); |
| 69421 | 69734 | return val; |
| 69422 | 69735 | } |
| 69423 | | -SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){ |
| 69736 | +SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){ |
| 69424 | 69737 | sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) ); |
| 69425 | 69738 | columnMallocFailure(pStmt); |
| 69426 | 69739 | return val; |
| 69427 | 69740 | } |
| 69428 | | -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){ |
| 69741 | +SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){ |
| 69429 | 69742 | const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) ); |
| 69430 | 69743 | columnMallocFailure(pStmt); |
| 69431 | 69744 | return val; |
| 69432 | 69745 | } |
| 69433 | | -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){ |
| 69746 | +SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){ |
| 69434 | 69747 | Mem *pOut = columnMem(pStmt, i); |
| 69435 | 69748 | if( pOut->flags&MEM_Static ){ |
| 69436 | 69749 | pOut->flags &= ~MEM_Static; |
| 69437 | 69750 | pOut->flags |= MEM_Ephem; |
| 69438 | 69751 | } |
| 69439 | 69752 | columnMallocFailure(pStmt); |
| 69440 | 69753 | return (sqlite3_value *)pOut; |
| 69441 | 69754 | } |
| 69442 | 69755 | #ifndef SQLITE_OMIT_UTF16 |
| 69443 | | -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){ |
| 69756 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){ |
| 69444 | 69757 | const void *val = sqlite3_value_text16( columnMem(pStmt,i) ); |
| 69445 | 69758 | columnMallocFailure(pStmt); |
| 69446 | 69759 | return val; |
| 69447 | 69760 | } |
| 69448 | 69761 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69449 | | -SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){ |
| 69762 | +SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){ |
| 69450 | 69763 | int iType = sqlite3_value_type( columnMem(pStmt,i) ); |
| 69451 | 69764 | columnMallocFailure(pStmt); |
| 69452 | 69765 | return iType; |
| 69453 | 69766 | } |
| 69454 | 69767 | |
| | @@ -69508,16 +69821,16 @@ |
| 69508 | 69821 | |
| 69509 | 69822 | /* |
| 69510 | 69823 | ** Return the name of the Nth column of the result set returned by SQL |
| 69511 | 69824 | ** statement pStmt. |
| 69512 | 69825 | */ |
| 69513 | | -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){ |
| 69826 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){ |
| 69514 | 69827 | return columnName( |
| 69515 | 69828 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME); |
| 69516 | 69829 | } |
| 69517 | 69830 | #ifndef SQLITE_OMIT_UTF16 |
| 69518 | | -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){ |
| 69831 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){ |
| 69519 | 69832 | return columnName( |
| 69520 | 69833 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME); |
| 69521 | 69834 | } |
| 69522 | 69835 | #endif |
| 69523 | 69836 | |
| | @@ -69533,16 +69846,16 @@ |
| 69533 | 69846 | #ifndef SQLITE_OMIT_DECLTYPE |
| 69534 | 69847 | /* |
| 69535 | 69848 | ** Return the column declaration type (if applicable) of the 'i'th column |
| 69536 | 69849 | ** of the result set of SQL statement pStmt. |
| 69537 | 69850 | */ |
| 69538 | | -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){ |
| 69851 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){ |
| 69539 | 69852 | return columnName( |
| 69540 | 69853 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE); |
| 69541 | 69854 | } |
| 69542 | 69855 | #ifndef SQLITE_OMIT_UTF16 |
| 69543 | | -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){ |
| 69856 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){ |
| 69544 | 69857 | return columnName( |
| 69545 | 69858 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE); |
| 69546 | 69859 | } |
| 69547 | 69860 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69548 | 69861 | #endif /* SQLITE_OMIT_DECLTYPE */ |
| | @@ -69551,16 +69864,16 @@ |
| 69551 | 69864 | /* |
| 69552 | 69865 | ** Return the name of the database from which a result column derives. |
| 69553 | 69866 | ** NULL is returned if the result column is an expression or constant or |
| 69554 | 69867 | ** anything else which is not an unambiguous reference to a database column. |
| 69555 | 69868 | */ |
| 69556 | | -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){ |
| 69869 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){ |
| 69557 | 69870 | return columnName( |
| 69558 | 69871 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE); |
| 69559 | 69872 | } |
| 69560 | 69873 | #ifndef SQLITE_OMIT_UTF16 |
| 69561 | | -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){ |
| 69874 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){ |
| 69562 | 69875 | return columnName( |
| 69563 | 69876 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE); |
| 69564 | 69877 | } |
| 69565 | 69878 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69566 | 69879 | |
| | @@ -69567,16 +69880,16 @@ |
| 69567 | 69880 | /* |
| 69568 | 69881 | ** Return the name of the table from which a result column derives. |
| 69569 | 69882 | ** NULL is returned if the result column is an expression or constant or |
| 69570 | 69883 | ** anything else which is not an unambiguous reference to a database column. |
| 69571 | 69884 | */ |
| 69572 | | -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){ |
| 69885 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){ |
| 69573 | 69886 | return columnName( |
| 69574 | 69887 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE); |
| 69575 | 69888 | } |
| 69576 | 69889 | #ifndef SQLITE_OMIT_UTF16 |
| 69577 | | -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){ |
| 69890 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){ |
| 69578 | 69891 | return columnName( |
| 69579 | 69892 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE); |
| 69580 | 69893 | } |
| 69581 | 69894 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69582 | 69895 | |
| | @@ -69583,16 +69896,16 @@ |
| 69583 | 69896 | /* |
| 69584 | 69897 | ** Return the name of the table column from which a result column derives. |
| 69585 | 69898 | ** NULL is returned if the result column is an expression or constant or |
| 69586 | 69899 | ** anything else which is not an unambiguous reference to a database column. |
| 69587 | 69900 | */ |
| 69588 | | -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){ |
| 69901 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){ |
| 69589 | 69902 | return columnName( |
| 69590 | 69903 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN); |
| 69591 | 69904 | } |
| 69592 | 69905 | #ifndef SQLITE_OMIT_UTF16 |
| 69593 | | -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){ |
| 69906 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){ |
| 69594 | 69907 | return columnName( |
| 69595 | 69908 | pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN); |
| 69596 | 69909 | } |
| 69597 | 69910 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69598 | 69911 | #endif /* SQLITE_ENABLE_COLUMN_METADATA */ |
| | @@ -69689,20 +70002,20 @@ |
| 69689 | 70002 | |
| 69690 | 70003 | |
| 69691 | 70004 | /* |
| 69692 | 70005 | ** Bind a blob value to an SQL statement variable. |
| 69693 | 70006 | */ |
| 69694 | | -SQLITE_API int sqlite3_bind_blob( |
| 70007 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob( |
| 69695 | 70008 | sqlite3_stmt *pStmt, |
| 69696 | 70009 | int i, |
| 69697 | 70010 | const void *zData, |
| 69698 | 70011 | int nData, |
| 69699 | 70012 | void (*xDel)(void*) |
| 69700 | 70013 | ){ |
| 69701 | 70014 | return bindText(pStmt, i, zData, nData, xDel, 0); |
| 69702 | 70015 | } |
| 69703 | | -SQLITE_API int sqlite3_bind_blob64( |
| 70016 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64( |
| 69704 | 70017 | sqlite3_stmt *pStmt, |
| 69705 | 70018 | int i, |
| 69706 | 70019 | const void *zData, |
| 69707 | 70020 | sqlite3_uint64 nData, |
| 69708 | 70021 | void (*xDel)(void*) |
| | @@ -69712,52 +70025,52 @@ |
| 69712 | 70025 | return invokeValueDestructor(zData, xDel, 0); |
| 69713 | 70026 | }else{ |
| 69714 | 70027 | return bindText(pStmt, i, zData, (int)nData, xDel, 0); |
| 69715 | 70028 | } |
| 69716 | 70029 | } |
| 69717 | | -SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ |
| 70030 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){ |
| 69718 | 70031 | int rc; |
| 69719 | 70032 | Vdbe *p = (Vdbe *)pStmt; |
| 69720 | 70033 | rc = vdbeUnbind(p, i); |
| 69721 | 70034 | if( rc==SQLITE_OK ){ |
| 69722 | 70035 | sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue); |
| 69723 | 70036 | sqlite3_mutex_leave(p->db->mutex); |
| 69724 | 70037 | } |
| 69725 | 70038 | return rc; |
| 69726 | 70039 | } |
| 69727 | | -SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){ |
| 70040 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){ |
| 69728 | 70041 | return sqlite3_bind_int64(p, i, (i64)iValue); |
| 69729 | 70042 | } |
| 69730 | | -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){ |
| 70043 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){ |
| 69731 | 70044 | int rc; |
| 69732 | 70045 | Vdbe *p = (Vdbe *)pStmt; |
| 69733 | 70046 | rc = vdbeUnbind(p, i); |
| 69734 | 70047 | if( rc==SQLITE_OK ){ |
| 69735 | 70048 | sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue); |
| 69736 | 70049 | sqlite3_mutex_leave(p->db->mutex); |
| 69737 | 70050 | } |
| 69738 | 70051 | return rc; |
| 69739 | 70052 | } |
| 69740 | | -SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){ |
| 70053 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){ |
| 69741 | 70054 | int rc; |
| 69742 | 70055 | Vdbe *p = (Vdbe*)pStmt; |
| 69743 | 70056 | rc = vdbeUnbind(p, i); |
| 69744 | 70057 | if( rc==SQLITE_OK ){ |
| 69745 | 70058 | sqlite3_mutex_leave(p->db->mutex); |
| 69746 | 70059 | } |
| 69747 | 70060 | return rc; |
| 69748 | 70061 | } |
| 69749 | | -SQLITE_API int sqlite3_bind_text( |
| 70062 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text( |
| 69750 | 70063 | sqlite3_stmt *pStmt, |
| 69751 | 70064 | int i, |
| 69752 | 70065 | const char *zData, |
| 69753 | 70066 | int nData, |
| 69754 | 70067 | void (*xDel)(void*) |
| 69755 | 70068 | ){ |
| 69756 | 70069 | return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8); |
| 69757 | 70070 | } |
| 69758 | | -SQLITE_API int sqlite3_bind_text64( |
| 70071 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64( |
| 69759 | 70072 | sqlite3_stmt *pStmt, |
| 69760 | 70073 | int i, |
| 69761 | 70074 | const char *zData, |
| 69762 | 70075 | sqlite3_uint64 nData, |
| 69763 | 70076 | void (*xDel)(void*), |
| | @@ -69770,21 +70083,21 @@ |
| 69770 | 70083 | if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE; |
| 69771 | 70084 | return bindText(pStmt, i, zData, (int)nData, xDel, enc); |
| 69772 | 70085 | } |
| 69773 | 70086 | } |
| 69774 | 70087 | #ifndef SQLITE_OMIT_UTF16 |
| 69775 | | -SQLITE_API int sqlite3_bind_text16( |
| 70088 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16( |
| 69776 | 70089 | sqlite3_stmt *pStmt, |
| 69777 | 70090 | int i, |
| 69778 | 70091 | const void *zData, |
| 69779 | 70092 | int nData, |
| 69780 | 70093 | void (*xDel)(void*) |
| 69781 | 70094 | ){ |
| 69782 | 70095 | return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE); |
| 69783 | 70096 | } |
| 69784 | 70097 | #endif /* SQLITE_OMIT_UTF16 */ |
| 69785 | | -SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){ |
| 70098 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){ |
| 69786 | 70099 | int rc; |
| 69787 | 70100 | switch( sqlite3_value_type((sqlite3_value*)pValue) ){ |
| 69788 | 70101 | case SQLITE_INTEGER: { |
| 69789 | 70102 | rc = sqlite3_bind_int64(pStmt, i, pValue->u.i); |
| 69790 | 70103 | break; |
| | @@ -69811,11 +70124,11 @@ |
| 69811 | 70124 | break; |
| 69812 | 70125 | } |
| 69813 | 70126 | } |
| 69814 | 70127 | return rc; |
| 69815 | 70128 | } |
| 69816 | | -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 70129 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 69817 | 70130 | int rc; |
| 69818 | 70131 | Vdbe *p = (Vdbe *)pStmt; |
| 69819 | 70132 | rc = vdbeUnbind(p, i); |
| 69820 | 70133 | if( rc==SQLITE_OK ){ |
| 69821 | 70134 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| | @@ -69826,11 +70139,11 @@ |
| 69826 | 70139 | |
| 69827 | 70140 | /* |
| 69828 | 70141 | ** Return the number of wildcards that can be potentially bound to. |
| 69829 | 70142 | ** This routine is added to support DBD::SQLite. |
| 69830 | 70143 | */ |
| 69831 | | -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){ |
| 70144 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){ |
| 69832 | 70145 | Vdbe *p = (Vdbe*)pStmt; |
| 69833 | 70146 | return p ? p->nVar : 0; |
| 69834 | 70147 | } |
| 69835 | 70148 | |
| 69836 | 70149 | /* |
| | @@ -69837,11 +70150,11 @@ |
| 69837 | 70150 | ** Return the name of a wildcard parameter. Return NULL if the index |
| 69838 | 70151 | ** is out of range or if the wildcard is unnamed. |
| 69839 | 70152 | ** |
| 69840 | 70153 | ** The result is always UTF-8. |
| 69841 | 70154 | */ |
| 69842 | | -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){ |
| 70155 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){ |
| 69843 | 70156 | Vdbe *p = (Vdbe*)pStmt; |
| 69844 | 70157 | if( p==0 || i<1 || i>p->nzVar ){ |
| 69845 | 70158 | return 0; |
| 69846 | 70159 | } |
| 69847 | 70160 | return p->azVar[i-1]; |
| | @@ -69865,11 +70178,11 @@ |
| 69865 | 70178 | } |
| 69866 | 70179 | } |
| 69867 | 70180 | } |
| 69868 | 70181 | return 0; |
| 69869 | 70182 | } |
| 69870 | | -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){ |
| 70183 | +SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){ |
| 69871 | 70184 | return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName)); |
| 69872 | 70185 | } |
| 69873 | 70186 | |
| 69874 | 70187 | /* |
| 69875 | 70188 | ** Transfer all bindings from the first statement over to the second. |
| | @@ -69899,11 +70212,11 @@ |
| 69899 | 70212 | ** |
| 69900 | 70213 | ** If the two statements contain a different number of bindings, then |
| 69901 | 70214 | ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise |
| 69902 | 70215 | ** SQLITE_OK is returned. |
| 69903 | 70216 | */ |
| 69904 | | -SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){ |
| 70217 | +SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){ |
| 69905 | 70218 | Vdbe *pFrom = (Vdbe*)pFromStmt; |
| 69906 | 70219 | Vdbe *pTo = (Vdbe*)pToStmt; |
| 69907 | 70220 | if( pFrom->nVar!=pTo->nVar ){ |
| 69908 | 70221 | return SQLITE_ERROR; |
| 69909 | 70222 | } |
| | @@ -69921,26 +70234,26 @@ |
| 69921 | 70234 | ** Return the sqlite3* database handle to which the prepared statement given |
| 69922 | 70235 | ** in the argument belongs. This is the same database handle that was |
| 69923 | 70236 | ** the first argument to the sqlite3_prepare() that was used to create |
| 69924 | 70237 | ** the statement in the first place. |
| 69925 | 70238 | */ |
| 69926 | | -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){ |
| 70239 | +SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){ |
| 69927 | 70240 | return pStmt ? ((Vdbe*)pStmt)->db : 0; |
| 69928 | 70241 | } |
| 69929 | 70242 | |
| 69930 | 70243 | /* |
| 69931 | 70244 | ** Return true if the prepared statement is guaranteed to not modify the |
| 69932 | 70245 | ** database. |
| 69933 | 70246 | */ |
| 69934 | | -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){ |
| 70247 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){ |
| 69935 | 70248 | return pStmt ? ((Vdbe*)pStmt)->readOnly : 1; |
| 69936 | 70249 | } |
| 69937 | 70250 | |
| 69938 | 70251 | /* |
| 69939 | 70252 | ** Return true if the prepared statement is in need of being reset. |
| 69940 | 70253 | */ |
| 69941 | | -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){ |
| 70254 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){ |
| 69942 | 70255 | Vdbe *v = (Vdbe*)pStmt; |
| 69943 | 70256 | return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN; |
| 69944 | 70257 | } |
| 69945 | 70258 | |
| 69946 | 70259 | /* |
| | @@ -69947,11 +70260,11 @@ |
| 69947 | 70260 | ** Return a pointer to the next prepared statement after pStmt associated |
| 69948 | 70261 | ** with database connection pDb. If pStmt is NULL, return the first |
| 69949 | 70262 | ** prepared statement for the database connection. Return NULL if there |
| 69950 | 70263 | ** are no more. |
| 69951 | 70264 | */ |
| 69952 | | -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){ |
| 70265 | +SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){ |
| 69953 | 70266 | sqlite3_stmt *pNext; |
| 69954 | 70267 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 69955 | 70268 | if( !sqlite3SafetyCheckOk(pDb) ){ |
| 69956 | 70269 | (void)SQLITE_MISUSE_BKPT; |
| 69957 | 70270 | return 0; |
| | @@ -69968,11 +70281,11 @@ |
| 69968 | 70281 | } |
| 69969 | 70282 | |
| 69970 | 70283 | /* |
| 69971 | 70284 | ** Return the value of a status counter for a prepared statement |
| 69972 | 70285 | */ |
| 69973 | | -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ |
| 70286 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ |
| 69974 | 70287 | Vdbe *pVdbe = (Vdbe*)pStmt; |
| 69975 | 70288 | u32 v; |
| 69976 | 70289 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 69977 | 70290 | if( !pStmt ){ |
| 69978 | 70291 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -69986,11 +70299,11 @@ |
| 69986 | 70299 | |
| 69987 | 70300 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 69988 | 70301 | /* |
| 69989 | 70302 | ** Return status data for a single loop within query pStmt. |
| 69990 | 70303 | */ |
| 69991 | | -SQLITE_API int sqlite3_stmt_scanstatus( |
| 70304 | +SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus( |
| 69992 | 70305 | sqlite3_stmt *pStmt, /* Prepared statement being queried */ |
| 69993 | 70306 | int idx, /* Index of loop to report on */ |
| 69994 | 70307 | int iScanStatusOp, /* Which metric to return */ |
| 69995 | 70308 | void *pOut /* OUT: Write the answer here */ |
| 69996 | 70309 | ){ |
| | @@ -70045,11 +70358,11 @@ |
| 70045 | 70358 | } |
| 70046 | 70359 | |
| 70047 | 70360 | /* |
| 70048 | 70361 | ** Zero all counters associated with the sqlite3_stmt_scanstatus() data. |
| 70049 | 70362 | */ |
| 70050 | | -SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 70363 | +SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ |
| 70051 | 70364 | Vdbe *p = (Vdbe*)pStmt; |
| 70052 | 70365 | memset(p->anExec, 0, p->nOp * sizeof(i64)); |
| 70053 | 70366 | } |
| 70054 | 70367 | #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */ |
| 70055 | 70368 | |
| | @@ -70544,11 +70857,11 @@ |
| 70544 | 70857 | ** Try to convert the type of a function argument or a result column |
| 70545 | 70858 | ** into a numeric representation. Use either INTEGER or REAL whichever |
| 70546 | 70859 | ** is appropriate. But only do the conversion if it is possible without |
| 70547 | 70860 | ** loss of information and return the revised type of the argument. |
| 70548 | 70861 | */ |
| 70549 | | -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){ |
| 70862 | +SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){ |
| 70550 | 70863 | int eType = sqlite3_value_type(pVal); |
| 70551 | 70864 | if( eType==SQLITE_TEXT ){ |
| 70552 | 70865 | Mem *pMem = (Mem*)pVal; |
| 70553 | 70866 | applyNumericAffinity(pMem, 0); |
| 70554 | 70867 | eType = sqlite3_value_type(pVal); |
| | @@ -71845,11 +72158,11 @@ |
| 71845 | 72158 | ** max() aggregate will set to 1 if the current row is not the minimum or |
| 71846 | 72159 | ** maximum. The P1 register is initialized to 0 by this instruction. |
| 71847 | 72160 | ** |
| 71848 | 72161 | ** The interface used by the implementation of the aforementioned functions |
| 71849 | 72162 | ** to retrieve the collation sequence set by this opcode is not available |
| 71850 | | -** publicly, only to user functions defined in func.c. |
| 72163 | +** publicly. Only built-in functions have access to this feature. |
| 71851 | 72164 | */ |
| 71852 | 72165 | case OP_CollSeq: { |
| 71853 | 72166 | assert( pOp->p4type==P4_COLLSEQ ); |
| 71854 | 72167 | if( pOp->p1 ){ |
| 71855 | 72168 | sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0); |
| | @@ -73563,35 +73876,33 @@ |
| 73563 | 73876 | ** cursors or a single read/write cursor but not both. |
| 73564 | 73877 | ** |
| 73565 | 73878 | ** See also OpenRead. |
| 73566 | 73879 | */ |
| 73567 | 73880 | case OP_ReopenIdx: { |
| 73568 | | - VdbeCursor *pCur; |
| 73569 | | - |
| 73570 | | - assert( pOp->p5==0 ); |
| 73571 | | - assert( pOp->p4type==P4_KEYINFO ); |
| 73572 | | - pCur = p->apCsr[pOp->p1]; |
| 73573 | | - if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){ |
| 73574 | | - assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ |
| 73575 | | - break; |
| 73576 | | - } |
| 73577 | | - /* If the cursor is not currently open or is open on a different |
| 73578 | | - ** index, then fall through into OP_OpenRead to force a reopen */ |
| 73579 | | -} |
| 73580 | | -case OP_OpenRead: |
| 73581 | | -case OP_OpenWrite: { |
| 73582 | 73881 | int nField; |
| 73583 | 73882 | KeyInfo *pKeyInfo; |
| 73584 | 73883 | int p2; |
| 73585 | 73884 | int iDb; |
| 73586 | 73885 | int wrFlag; |
| 73587 | 73886 | Btree *pX; |
| 73588 | 73887 | VdbeCursor *pCur; |
| 73589 | 73888 | Db *pDb; |
| 73590 | 73889 | |
| 73591 | | - assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 ); |
| 73592 | | - assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 ); |
| 73890 | + assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ ); |
| 73891 | + assert( pOp->p4type==P4_KEYINFO ); |
| 73892 | + pCur = p->apCsr[pOp->p1]; |
| 73893 | + if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){ |
| 73894 | + assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ |
| 73895 | + goto open_cursor_set_hints; |
| 73896 | + } |
| 73897 | + /* If the cursor is not currently open or is open on a different |
| 73898 | + ** index, then fall through into OP_OpenRead to force a reopen */ |
| 73899 | +case OP_OpenRead: |
| 73900 | +case OP_OpenWrite: |
| 73901 | + |
| 73902 | + assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR|OPFLAG_SEEKEQ))==pOp->p5 ); |
| 73903 | + assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ ); |
| 73593 | 73904 | assert( p->bIsReader ); |
| 73594 | 73905 | assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx |
| 73595 | 73906 | || p->readOnly==0 ); |
| 73596 | 73907 | |
| 73597 | 73908 | if( p->expired ){ |
| | @@ -73650,18 +73961,21 @@ |
| 73650 | 73961 | pCur->nullRow = 1; |
| 73651 | 73962 | pCur->isOrdered = 1; |
| 73652 | 73963 | pCur->pgnoRoot = p2; |
| 73653 | 73964 | rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor); |
| 73654 | 73965 | pCur->pKeyInfo = pKeyInfo; |
| 73655 | | - assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); |
| 73656 | | - sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); |
| 73657 | | - |
| 73658 | 73966 | /* Set the VdbeCursor.isTable variable. Previous versions of |
| 73659 | 73967 | ** SQLite used to check if the root-page flags were sane at this point |
| 73660 | 73968 | ** and report database corruption if they were not, but this check has |
| 73661 | 73969 | ** since moved into the btree layer. */ |
| 73662 | 73970 | pCur->isTable = pOp->p4type!=P4_KEYINFO; |
| 73971 | + |
| 73972 | +open_cursor_set_hints: |
| 73973 | + assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); |
| 73974 | + assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ ); |
| 73975 | + sqlite3BtreeCursorHints(pCur->pCursor, |
| 73976 | + (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ))); |
| 73663 | 73977 | break; |
| 73664 | 73978 | } |
| 73665 | 73979 | |
| 73666 | 73980 | /* Opcode: OpenEphemeral P1 P2 * P4 P5 |
| 73667 | 73981 | ** Synopsis: nColumn=P2 |
| | @@ -73918,10 +74232,26 @@ |
| 73918 | 74232 | oc = pOp->opcode; |
| 73919 | 74233 | pC->nullRow = 0; |
| 73920 | 74234 | #ifdef SQLITE_DEBUG |
| 73921 | 74235 | pC->seekOp = pOp->opcode; |
| 73922 | 74236 | #endif |
| 74237 | + |
| 74238 | + /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and |
| 74239 | + ** OP_SeekLE opcodes are allowed, and these must be immediately followed |
| 74240 | + ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key. |
| 74241 | + */ |
| 74242 | +#ifdef SQLITE_DEBUG |
| 74243 | + if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){ |
| 74244 | + assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE ); |
| 74245 | + assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT ); |
| 74246 | + assert( pOp[1].p1==pOp[0].p1 ); |
| 74247 | + assert( pOp[1].p2==pOp[0].p2 ); |
| 74248 | + assert( pOp[1].p3==pOp[0].p3 ); |
| 74249 | + assert( pOp[1].p4.i==pOp[0].p4.i ); |
| 74250 | + } |
| 74251 | +#endif |
| 74252 | + |
| 73923 | 74253 | if( pC->isTable ){ |
| 73924 | 74254 | /* The input value in P3 might be of any type: integer, real, string, |
| 73925 | 74255 | ** blob, or NULL. But it needs to be an integer before we can do |
| 73926 | 74256 | ** the seek, so convert it. */ |
| 73927 | 74257 | pIn3 = &aMem[pOp->p3]; |
| | @@ -75257,34 +75587,19 @@ |
| 75257 | 75587 | ** |
| 75258 | 75588 | ** See also: Clear |
| 75259 | 75589 | */ |
| 75260 | 75590 | case OP_Destroy: { /* out2-prerelease */ |
| 75261 | 75591 | int iMoved; |
| 75262 | | - int iCnt; |
| 75263 | | - Vdbe *pVdbe; |
| 75264 | 75592 | int iDb; |
| 75265 | 75593 | |
| 75266 | 75594 | assert( p->readOnly==0 ); |
| 75267 | | -#ifndef SQLITE_OMIT_VIRTUALTABLE |
| 75268 | | - iCnt = 0; |
| 75269 | | - for(pVdbe=db->pVdbe; pVdbe; pVdbe = pVdbe->pNext){ |
| 75270 | | - if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->bIsReader |
| 75271 | | - && pVdbe->inVtabMethod<2 && pVdbe->pc>=0 |
| 75272 | | - ){ |
| 75273 | | - iCnt++; |
| 75274 | | - } |
| 75275 | | - } |
| 75276 | | -#else |
| 75277 | | - iCnt = db->nVdbeRead; |
| 75278 | | -#endif |
| 75279 | 75595 | pOut->flags = MEM_Null; |
| 75280 | | - if( iCnt>1 ){ |
| 75596 | + if( db->nVdbeRead > db->nVDestroy+1 ){ |
| 75281 | 75597 | rc = SQLITE_LOCKED; |
| 75282 | 75598 | p->errorAction = OE_Abort; |
| 75283 | 75599 | }else{ |
| 75284 | 75600 | iDb = pOp->p3; |
| 75285 | | - assert( iCnt==1 ); |
| 75286 | 75601 | assert( DbMaskTest(p->btreeMask, iDb) ); |
| 75287 | 75602 | iMoved = 0; /* Not needed. Only to silence a warning. */ |
| 75288 | 75603 | rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved); |
| 75289 | 75604 | pOut->flags = MEM_Int; |
| 75290 | 75605 | pOut->u.i = iMoved; |
| | @@ -76337,17 +76652,33 @@ |
| 76337 | 76652 | break; |
| 76338 | 76653 | } |
| 76339 | 76654 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 76340 | 76655 | |
| 76341 | 76656 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 76342 | | -/* Opcode: VCreate P1 * * P4 * |
| 76657 | +/* Opcode: VCreate P1 P2 * * * |
| 76343 | 76658 | ** |
| 76344 | | -** P4 is the name of a virtual table in database P1. Call the xCreate method |
| 76345 | | -** for that table. |
| 76659 | +** P2 is a register that holds the name of a virtual table in database |
| 76660 | +** P1. Call the xCreate method for that table. |
| 76346 | 76661 | */ |
| 76347 | 76662 | case OP_VCreate: { |
| 76348 | | - rc = sqlite3VtabCallCreate(db, pOp->p1, pOp->p4.z, &p->zErrMsg); |
| 76663 | + Mem sMem; /* For storing the record being decoded */ |
| 76664 | + const char *zTab; /* Name of the virtual table */ |
| 76665 | + |
| 76666 | + memset(&sMem, 0, sizeof(sMem)); |
| 76667 | + sMem.db = db; |
| 76668 | + /* Because P2 is always a static string, it is impossible for the |
| 76669 | + ** sqlite3VdbeMemCopy() to fail */ |
| 76670 | + assert( (aMem[pOp->p2].flags & MEM_Str)!=0 ); |
| 76671 | + assert( (aMem[pOp->p2].flags & MEM_Static)!=0 ); |
| 76672 | + rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]); |
| 76673 | + assert( rc==SQLITE_OK ); |
| 76674 | + zTab = (const char*)sqlite3_value_text(&sMem); |
| 76675 | + assert( zTab || db->mallocFailed ); |
| 76676 | + if( zTab ){ |
| 76677 | + rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg); |
| 76678 | + } |
| 76679 | + sqlite3VdbeMemRelease(&sMem); |
| 76349 | 76680 | break; |
| 76350 | 76681 | } |
| 76351 | 76682 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 76352 | 76683 | |
| 76353 | 76684 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| | @@ -76355,13 +76686,13 @@ |
| 76355 | 76686 | ** |
| 76356 | 76687 | ** P4 is the name of a virtual table in database P1. Call the xDestroy method |
| 76357 | 76688 | ** of that table. |
| 76358 | 76689 | */ |
| 76359 | 76690 | case OP_VDestroy: { |
| 76360 | | - p->inVtabMethod = 2; |
| 76691 | + db->nVDestroy++; |
| 76361 | 76692 | rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z); |
| 76362 | | - p->inVtabMethod = 0; |
| 76693 | + db->nVDestroy--; |
| 76363 | 76694 | break; |
| 76364 | 76695 | } |
| 76365 | 76696 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 76366 | 76697 | |
| 76367 | 76698 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| | @@ -76373,18 +76704,21 @@ |
| 76373 | 76704 | */ |
| 76374 | 76705 | case OP_VOpen: { |
| 76375 | 76706 | VdbeCursor *pCur; |
| 76376 | 76707 | sqlite3_vtab_cursor *pVtabCursor; |
| 76377 | 76708 | sqlite3_vtab *pVtab; |
| 76378 | | - sqlite3_module *pModule; |
| 76709 | + const sqlite3_module *pModule; |
| 76379 | 76710 | |
| 76380 | 76711 | assert( p->bIsReader ); |
| 76381 | 76712 | pCur = 0; |
| 76382 | 76713 | pVtabCursor = 0; |
| 76383 | 76714 | pVtab = pOp->p4.pVtab->pVtab; |
| 76384 | | - pModule = (sqlite3_module *)pVtab->pModule; |
| 76385 | | - assert(pVtab && pModule); |
| 76715 | + if( pVtab==0 || NEVER(pVtab->pModule==0) ){ |
| 76716 | + rc = SQLITE_LOCKED; |
| 76717 | + break; |
| 76718 | + } |
| 76719 | + pModule = pVtab->pModule; |
| 76386 | 76720 | rc = pModule->xOpen(pVtab, &pVtabCursor); |
| 76387 | 76721 | sqlite3VtabImportErrmsg(p, pVtab); |
| 76388 | 76722 | if( SQLITE_OK==rc ){ |
| 76389 | 76723 | /* Initialize sqlite3_vtab_cursor base class */ |
| 76390 | 76724 | pVtabCursor->pVtab = pVtab; |
| | @@ -76391,10 +76725,11 @@ |
| 76391 | 76725 | |
| 76392 | 76726 | /* Initialize vdbe cursor object */ |
| 76393 | 76727 | pCur = allocateCursor(p, pOp->p1, 0, -1, 0); |
| 76394 | 76728 | if( pCur ){ |
| 76395 | 76729 | pCur->pVtabCursor = pVtabCursor; |
| 76730 | + pVtab->nRef++; |
| 76396 | 76731 | }else{ |
| 76397 | 76732 | db->mallocFailed = 1; |
| 76398 | 76733 | pModule->xClose(pVtabCursor); |
| 76399 | 76734 | } |
| 76400 | 76735 | } |
| | @@ -76456,13 +76791,11 @@ |
| 76456 | 76791 | apArg = p->apArg; |
| 76457 | 76792 | for(i = 0; i<nArg; i++){ |
| 76458 | 76793 | apArg[i] = &pArgc[i+1]; |
| 76459 | 76794 | } |
| 76460 | 76795 | |
| 76461 | | - p->inVtabMethod = 1; |
| 76462 | 76796 | rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); |
| 76463 | | - p->inVtabMethod = 0; |
| 76464 | 76797 | sqlite3VtabImportErrmsg(p, pVtab); |
| 76465 | 76798 | if( rc==SQLITE_OK ){ |
| 76466 | 76799 | res = pModule->xEof(pVtabCursor); |
| 76467 | 76800 | } |
| 76468 | 76801 | VdbeBranchTaken(res!=0,2); |
| | @@ -76548,13 +76881,11 @@ |
| 76548 | 76881 | ** underlying implementation to return an error if one occurs during |
| 76549 | 76882 | ** xNext(). Instead, if an error occurs, true is returned (indicating that |
| 76550 | 76883 | ** data is available) and the error code returned when xColumn or |
| 76551 | 76884 | ** some other method is next invoked on the save virtual table cursor. |
| 76552 | 76885 | */ |
| 76553 | | - p->inVtabMethod = 1; |
| 76554 | 76886 | rc = pModule->xNext(pCur->pVtabCursor); |
| 76555 | | - p->inVtabMethod = 0; |
| 76556 | 76887 | sqlite3VtabImportErrmsg(p, pVtab); |
| 76557 | 76888 | if( rc==SQLITE_OK ){ |
| 76558 | 76889 | res = pModule->xEof(pCur->pVtabCursor); |
| 76559 | 76890 | } |
| 76560 | 76891 | VdbeBranchTaken(!res,2); |
| | @@ -76625,11 +76956,11 @@ |
| 76625 | 76956 | ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to |
| 76626 | 76957 | ** apply in the case of a constraint failure on an insert or update. |
| 76627 | 76958 | */ |
| 76628 | 76959 | case OP_VUpdate: { |
| 76629 | 76960 | sqlite3_vtab *pVtab; |
| 76630 | | - sqlite3_module *pModule; |
| 76961 | + const sqlite3_module *pModule; |
| 76631 | 76962 | int nArg; |
| 76632 | 76963 | int i; |
| 76633 | 76964 | sqlite_int64 rowid; |
| 76634 | 76965 | Mem **apArg; |
| 76635 | 76966 | Mem *pX; |
| | @@ -76637,11 +76968,15 @@ |
| 76637 | 76968 | assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback |
| 76638 | 76969 | || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace |
| 76639 | 76970 | ); |
| 76640 | 76971 | assert( p->readOnly==0 ); |
| 76641 | 76972 | pVtab = pOp->p4.pVtab->pVtab; |
| 76642 | | - pModule = (sqlite3_module *)pVtab->pModule; |
| 76973 | + if( pVtab==0 || NEVER(pVtab->pModule==0) ){ |
| 76974 | + rc = SQLITE_LOCKED; |
| 76975 | + break; |
| 76976 | + } |
| 76977 | + pModule = pVtab->pModule; |
| 76643 | 76978 | nArg = pOp->p2; |
| 76644 | 76979 | assert( pOp->p4type==P4_VTAB ); |
| 76645 | 76980 | if( ALWAYS(pModule->xUpdate) ){ |
| 76646 | 76981 | u8 vtabOnConflict = db->vtabOnConflict; |
| 76647 | 76982 | apArg = p->apArg; |
| | @@ -76984,11 +77319,11 @@ |
| 76984 | 77319 | } |
| 76985 | 77320 | |
| 76986 | 77321 | /* |
| 76987 | 77322 | ** Open a blob handle. |
| 76988 | 77323 | */ |
| 76989 | | -SQLITE_API int sqlite3_blob_open( |
| 77324 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_open( |
| 76990 | 77325 | sqlite3* db, /* The database connection */ |
| 76991 | 77326 | const char *zDb, /* The attached database containing the blob */ |
| 76992 | 77327 | const char *zTable, /* The table containing the blob */ |
| 76993 | 77328 | const char *zColumn, /* The column containing the blob */ |
| 76994 | 77329 | sqlite_int64 iRow, /* The row containing the glob */ |
| | @@ -77221,11 +77556,11 @@ |
| 77221 | 77556 | |
| 77222 | 77557 | /* |
| 77223 | 77558 | ** Close a blob handle that was previously created using |
| 77224 | 77559 | ** sqlite3_blob_open(). |
| 77225 | 77560 | */ |
| 77226 | | -SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){ |
| 77561 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){ |
| 77227 | 77562 | Incrblob *p = (Incrblob *)pBlob; |
| 77228 | 77563 | int rc; |
| 77229 | 77564 | sqlite3 *db; |
| 77230 | 77565 | |
| 77231 | 77566 | if( p ){ |
| | @@ -77290,28 +77625,28 @@ |
| 77290 | 77625 | } |
| 77291 | 77626 | |
| 77292 | 77627 | /* |
| 77293 | 77628 | ** Read data from a blob handle. |
| 77294 | 77629 | */ |
| 77295 | | -SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){ |
| 77630 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){ |
| 77296 | 77631 | return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData); |
| 77297 | 77632 | } |
| 77298 | 77633 | |
| 77299 | 77634 | /* |
| 77300 | 77635 | ** Write data to a blob handle. |
| 77301 | 77636 | */ |
| 77302 | | -SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){ |
| 77637 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){ |
| 77303 | 77638 | return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData); |
| 77304 | 77639 | } |
| 77305 | 77640 | |
| 77306 | 77641 | /* |
| 77307 | 77642 | ** Query a blob handle for the size of the data. |
| 77308 | 77643 | ** |
| 77309 | 77644 | ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob |
| 77310 | 77645 | ** so no mutex is required for access. |
| 77311 | 77646 | */ |
| 77312 | | -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){ |
| 77647 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){ |
| 77313 | 77648 | Incrblob *p = (Incrblob *)pBlob; |
| 77314 | 77649 | return (p && p->pStmt) ? p->nByte : 0; |
| 77315 | 77650 | } |
| 77316 | 77651 | |
| 77317 | 77652 | /* |
| | @@ -77322,11 +77657,11 @@ |
| 77322 | 77657 | ** contain a blob or text value, then an error code is returned and the |
| 77323 | 77658 | ** database handle error code and message set. If this happens, then all |
| 77324 | 77659 | ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) |
| 77325 | 77660 | ** immediately return SQLITE_ABORT. |
| 77326 | 77661 | */ |
| 77327 | | -SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){ |
| 77662 | +SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){ |
| 77328 | 77663 | int rc; |
| 77329 | 77664 | Incrblob *p = (Incrblob *)pBlob; |
| 77330 | 77665 | sqlite3 *db; |
| 77331 | 77666 | |
| 77332 | 77667 | if( p==0 ) return SQLITE_MISUSE_BKPT; |
| | @@ -78507,10 +78842,11 @@ |
| 78507 | 78842 | sqlite3 *db, /* Database handle doing sort */ |
| 78508 | 78843 | i64 nExtend, /* Attempt to extend file to this size */ |
| 78509 | 78844 | sqlite3_file **ppFd |
| 78510 | 78845 | ){ |
| 78511 | 78846 | int rc; |
| 78847 | + if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS; |
| 78512 | 78848 | rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd, |
| 78513 | 78849 | SQLITE_OPEN_TEMP_JOURNAL | |
| 78514 | 78850 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | |
| 78515 | 78851 | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE, &rc |
| 78516 | 78852 | ); |
| | @@ -82098,14 +82434,15 @@ |
| 82098 | 82434 | ** and the pExpr parameter is returned unchanged. |
| 82099 | 82435 | */ |
| 82100 | 82436 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( |
| 82101 | 82437 | Parse *pParse, /* Parsing context */ |
| 82102 | 82438 | Expr *pExpr, /* Add the "COLLATE" clause to this expression */ |
| 82103 | | - const Token *pCollName /* Name of collating sequence */ |
| 82439 | + const Token *pCollName, /* Name of collating sequence */ |
| 82440 | + int dequote /* True to dequote pCollName */ |
| 82104 | 82441 | ){ |
| 82105 | 82442 | if( pCollName->n>0 ){ |
| 82106 | | - Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1); |
| 82443 | + Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); |
| 82107 | 82444 | if( pNew ){ |
| 82108 | 82445 | pNew->pLeft = pExpr; |
| 82109 | 82446 | pNew->flags |= EP_Collate|EP_Skip; |
| 82110 | 82447 | pExpr = pNew; |
| 82111 | 82448 | } |
| | @@ -82115,11 +82452,11 @@ |
| 82115 | 82452 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){ |
| 82116 | 82453 | Token s; |
| 82117 | 82454 | assert( zC!=0 ); |
| 82118 | 82455 | s.z = zC; |
| 82119 | 82456 | s.n = sqlite3Strlen30(s.z); |
| 82120 | | - return sqlite3ExprAddCollateToken(pParse, pExpr, &s); |
| 82457 | + return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0); |
| 82121 | 82458 | } |
| 82122 | 82459 | |
| 82123 | 82460 | /* |
| 82124 | 82461 | ** Skip over any TK_COLLATE or TK_AS operators and any unlikely() |
| 82125 | 82462 | ** or likelihood() function at the root of an expression. |
| | @@ -82425,10 +82762,11 @@ |
| 82425 | 82762 | ** |
| 82426 | 82763 | ** Also propagate all EP_Propagate flags from the Expr.x.pList into |
| 82427 | 82764 | ** Expr.flags. |
| 82428 | 82765 | */ |
| 82429 | 82766 | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ |
| 82767 | + if( pParse->nErr ) return; |
| 82430 | 82768 | exprSetHeight(p); |
| 82431 | 82769 | sqlite3ExprCheckHeight(pParse, p->nHeight); |
| 82432 | 82770 | } |
| 82433 | 82771 | |
| 82434 | 82772 | /* |
| | @@ -87139,11 +87477,14 @@ |
| 87139 | 87477 | /* Ensure the default expression is something that sqlite3ValueFromExpr() |
| 87140 | 87478 | ** can handle (i.e. not CURRENT_TIME etc.) |
| 87141 | 87479 | */ |
| 87142 | 87480 | if( pDflt ){ |
| 87143 | 87481 | sqlite3_value *pVal = 0; |
| 87144 | | - if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){ |
| 87482 | + int rc; |
| 87483 | + rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal); |
| 87484 | + assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); |
| 87485 | + if( rc!=SQLITE_OK ){ |
| 87145 | 87486 | db->mallocFailed = 1; |
| 87146 | 87487 | return; |
| 87147 | 87488 | } |
| 87148 | 87489 | if( !pVal ){ |
| 87149 | 87490 | sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default"); |
| | @@ -89824,11 +90165,11 @@ |
| 89824 | 90165 | ** and attempts to write the column will be ignored. |
| 89825 | 90166 | ** |
| 89826 | 90167 | ** Setting the auth function to NULL disables this hook. The default |
| 89827 | 90168 | ** setting of the auth function is NULL. |
| 89828 | 90169 | */ |
| 89829 | | -SQLITE_API int sqlite3_set_authorizer( |
| 90170 | +SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer( |
| 89830 | 90171 | sqlite3 *db, |
| 89831 | 90172 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
| 89832 | 90173 | void *pArg |
| 89833 | 90174 | ){ |
| 89834 | 90175 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -93202,10 +93543,11 @@ |
| 93202 | 93543 | } |
| 93203 | 93544 | if( pIdx->onError==OE_Default ){ |
| 93204 | 93545 | pIdx->onError = pIndex->onError; |
| 93205 | 93546 | } |
| 93206 | 93547 | } |
| 93548 | + pRet = pIdx; |
| 93207 | 93549 | goto exit_create_index; |
| 93208 | 93550 | } |
| 93209 | 93551 | } |
| 93210 | 93552 | } |
| 93211 | 93553 | |
| | @@ -95661,11 +96003,13 @@ |
| 95661 | 96003 | |
| 95662 | 96004 | /* |
| 95663 | 96005 | ** Return the collating function associated with a function. |
| 95664 | 96006 | */ |
| 95665 | 96007 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| 95666 | | - VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1]; |
| 96008 | + VdbeOp *pOp; |
| 96009 | + assert( context->pVdbe!=0 ); |
| 96010 | + pOp = &context->pVdbe->aOp[context->iOp-1]; |
| 95667 | 96011 | assert( pOp->opcode==OP_CollSeq ); |
| 95668 | 96012 | assert( pOp->p4type==P4_COLLSEQ ); |
| 95669 | 96013 | return pOp->p4.pColl; |
| 95670 | 96014 | } |
| 95671 | 96015 | |
| | @@ -96399,11 +96743,11 @@ |
| 96399 | 96743 | } |
| 96400 | 96744 | |
| 96401 | 96745 | /* |
| 96402 | 96746 | ** The sqlite3_strglob() interface. |
| 96403 | 96747 | */ |
| 96404 | | -SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){ |
| 96748 | +SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){ |
| 96405 | 96749 | return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0; |
| 96406 | 96750 | } |
| 96407 | 96751 | |
| 96408 | 96752 | /* |
| 96409 | 96753 | ** Count the number of times that the LIKE operator (or GLOB which is |
| | @@ -100894,11 +101238,11 @@ |
| 100894 | 101238 | ** If the SQL is a query, then for each row in the query result |
| 100895 | 101239 | ** the xCallback() function is called. pArg becomes the first |
| 100896 | 101240 | ** argument to xCallback(). If xCallback=NULL then no callback |
| 100897 | 101241 | ** is invoked, even for queries. |
| 100898 | 101242 | */ |
| 100899 | | -SQLITE_API int sqlite3_exec( |
| 101243 | +SQLITE_API int SQLITE_STDCALL sqlite3_exec( |
| 100900 | 101244 | sqlite3 *db, /* The database on which the SQL executes */ |
| 100901 | 101245 | const char *zSql, /* The SQL to be executed */ |
| 100902 | 101246 | sqlite3_callback xCallback, /* Invoke this callback routine */ |
| 100903 | 101247 | void *pArg, /* First argument to xCallback() */ |
| 100904 | 101248 | char **pzErrMsg /* Write error messages here */ |
| | @@ -102089,11 +102433,11 @@ |
| 102089 | 102433 | db->aExtension = aHandle; |
| 102090 | 102434 | |
| 102091 | 102435 | db->aExtension[db->nExtension++] = handle; |
| 102092 | 102436 | return SQLITE_OK; |
| 102093 | 102437 | } |
| 102094 | | -SQLITE_API int sqlite3_load_extension( |
| 102438 | +SQLITE_API int SQLITE_STDCALL sqlite3_load_extension( |
| 102095 | 102439 | sqlite3 *db, /* Load the extension into this database connection */ |
| 102096 | 102440 | const char *zFile, /* Name of the shared library containing extension */ |
| 102097 | 102441 | const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ |
| 102098 | 102442 | char **pzErrMsg /* Put error message here if not 0 */ |
| 102099 | 102443 | ){ |
| | @@ -102120,11 +102464,11 @@ |
| 102120 | 102464 | |
| 102121 | 102465 | /* |
| 102122 | 102466 | ** Enable or disable extension loading. Extension loading is disabled by |
| 102123 | 102467 | ** default so as not to open security holes in older applications. |
| 102124 | 102468 | */ |
| 102125 | | -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 102469 | +SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){ |
| 102126 | 102470 | sqlite3_mutex_enter(db->mutex); |
| 102127 | 102471 | if( onoff ){ |
| 102128 | 102472 | db->flags |= SQLITE_LoadExtension; |
| 102129 | 102473 | }else{ |
| 102130 | 102474 | db->flags &= ~SQLITE_LoadExtension; |
| | @@ -102177,11 +102521,11 @@ |
| 102177 | 102521 | |
| 102178 | 102522 | /* |
| 102179 | 102523 | ** Register a statically linked extension that is automatically |
| 102180 | 102524 | ** loaded by every new database connection. |
| 102181 | 102525 | */ |
| 102182 | | -SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){ |
| 102526 | +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){ |
| 102183 | 102527 | int rc = SQLITE_OK; |
| 102184 | 102528 | #ifndef SQLITE_OMIT_AUTOINIT |
| 102185 | 102529 | rc = sqlite3_initialize(); |
| 102186 | 102530 | if( rc ){ |
| 102187 | 102531 | return rc; |
| | @@ -102222,11 +102566,11 @@ |
| 102222 | 102566 | ** routine is a no-op. |
| 102223 | 102567 | ** |
| 102224 | 102568 | ** Return 1 if xInit was found on the list and removed. Return 0 if xInit |
| 102225 | 102569 | ** was not on the list. |
| 102226 | 102570 | */ |
| 102227 | | -SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){ |
| 102571 | +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){ |
| 102228 | 102572 | #if SQLITE_THREADSAFE |
| 102229 | 102573 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); |
| 102230 | 102574 | #endif |
| 102231 | 102575 | int i; |
| 102232 | 102576 | int n = 0; |
| | @@ -102245,11 +102589,11 @@ |
| 102245 | 102589 | } |
| 102246 | 102590 | |
| 102247 | 102591 | /* |
| 102248 | 102592 | ** Reset the automatic extension loading mechanism. |
| 102249 | 102593 | */ |
| 102250 | | -SQLITE_API void sqlite3_reset_auto_extension(void){ |
| 102594 | +SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){ |
| 102251 | 102595 | #ifndef SQLITE_OMIT_AUTOINIT |
| 102252 | 102596 | if( sqlite3_initialize()==SQLITE_OK ) |
| 102253 | 102597 | #endif |
| 102254 | 102598 | { |
| 102255 | 102599 | #if SQLITE_THREADSAFE |
| | @@ -105525,11 +105869,11 @@ |
| 105525 | 105869 | ** and so if a schema change occurs, SQLITE_SCHEMA is returned by |
| 105526 | 105870 | ** sqlite3_step(). In the new version, the original SQL text is retained |
| 105527 | 105871 | ** and the statement is automatically recompiled if an schema change |
| 105528 | 105872 | ** occurs. |
| 105529 | 105873 | */ |
| 105530 | | -SQLITE_API int sqlite3_prepare( |
| 105874 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare( |
| 105531 | 105875 | sqlite3 *db, /* Database handle. */ |
| 105532 | 105876 | const char *zSql, /* UTF-8 encoded SQL statement. */ |
| 105533 | 105877 | int nBytes, /* Length of zSql in bytes. */ |
| 105534 | 105878 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 105535 | 105879 | const char **pzTail /* OUT: End of parsed string */ |
| | @@ -105537,11 +105881,11 @@ |
| 105537 | 105881 | int rc; |
| 105538 | 105882 | rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail); |
| 105539 | 105883 | assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ |
| 105540 | 105884 | return rc; |
| 105541 | 105885 | } |
| 105542 | | -SQLITE_API int sqlite3_prepare_v2( |
| 105886 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2( |
| 105543 | 105887 | sqlite3 *db, /* Database handle. */ |
| 105544 | 105888 | const char *zSql, /* UTF-8 encoded SQL statement. */ |
| 105545 | 105889 | int nBytes, /* Length of zSql in bytes. */ |
| 105546 | 105890 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 105547 | 105891 | const char **pzTail /* OUT: End of parsed string */ |
| | @@ -105613,11 +105957,11 @@ |
| 105613 | 105957 | ** and so if a schema change occurs, SQLITE_SCHEMA is returned by |
| 105614 | 105958 | ** sqlite3_step(). In the new version, the original SQL text is retained |
| 105615 | 105959 | ** and the statement is automatically recompiled if an schema change |
| 105616 | 105960 | ** occurs. |
| 105617 | 105961 | */ |
| 105618 | | -SQLITE_API int sqlite3_prepare16( |
| 105962 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16( |
| 105619 | 105963 | sqlite3 *db, /* Database handle. */ |
| 105620 | 105964 | const void *zSql, /* UTF-16 encoded SQL statement. */ |
| 105621 | 105965 | int nBytes, /* Length of zSql in bytes. */ |
| 105622 | 105966 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 105623 | 105967 | const void **pzTail /* OUT: End of parsed string */ |
| | @@ -105625,11 +105969,11 @@ |
| 105625 | 105969 | int rc; |
| 105626 | 105970 | rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail); |
| 105627 | 105971 | assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ |
| 105628 | 105972 | return rc; |
| 105629 | 105973 | } |
| 105630 | | -SQLITE_API int sqlite3_prepare16_v2( |
| 105974 | +SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2( |
| 105631 | 105975 | sqlite3 *db, /* Database handle. */ |
| 105632 | 105976 | const void *zSql, /* UTF-16 encoded SQL statement. */ |
| 105633 | 105977 | int nBytes, /* Length of zSql in bytes. */ |
| 105634 | 105978 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 105635 | 105979 | const void **pzTail /* OUT: End of parsed string */ |
| | @@ -109678,11 +110022,11 @@ |
| 109678 | 110022 | sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel); |
| 109679 | 110023 | |
| 109680 | 110024 | for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior); |
| 109681 | 110025 | pEList = pLeft->pEList; |
| 109682 | 110026 | if( pCte->pCols ){ |
| 109683 | | - if( pEList->nExpr!=pCte->pCols->nExpr ){ |
| 110027 | + if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){ |
| 109684 | 110028 | sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns", |
| 109685 | 110029 | pCte->zName, pEList->nExpr, pCte->pCols->nExpr |
| 109686 | 110030 | ); |
| 109687 | 110031 | pParse->pWith = pSavedWith; |
| 109688 | 110032 | return SQLITE_ERROR; |
| | @@ -111361,11 +111705,11 @@ |
| 111361 | 111705 | ** The result that is written to ***pazResult is held in memory obtained |
| 111362 | 111706 | ** from malloc(). But the caller cannot free this memory directly. |
| 111363 | 111707 | ** Instead, the entire table should be passed to sqlite3_free_table() when |
| 111364 | 111708 | ** the calling procedure is finished using it. |
| 111365 | 111709 | */ |
| 111366 | | -SQLITE_API int sqlite3_get_table( |
| 111710 | +SQLITE_API int SQLITE_STDCALL sqlite3_get_table( |
| 111367 | 111711 | sqlite3 *db, /* The database on which the SQL executes */ |
| 111368 | 111712 | const char *zSql, /* The SQL to be executed */ |
| 111369 | 111713 | char ***pazResult, /* Write the result table here */ |
| 111370 | 111714 | int *pnRow, /* Write the number of rows in the result here */ |
| 111371 | 111715 | int *pnColumn, /* Write the number of columns of result here */ |
| | @@ -111430,11 +111774,11 @@ |
| 111430 | 111774 | } |
| 111431 | 111775 | |
| 111432 | 111776 | /* |
| 111433 | 111777 | ** This routine frees the space the sqlite3_get_table() malloced. |
| 111434 | 111778 | */ |
| 111435 | | -SQLITE_API void sqlite3_free_table( |
| 111779 | +SQLITE_API void SQLITE_STDCALL sqlite3_free_table( |
| 111436 | 111780 | char **azResult /* Result returned from sqlite3_get_table() */ |
| 111437 | 111781 | ){ |
| 111438 | 111782 | if( azResult ){ |
| 111439 | 111783 | int i, n; |
| 111440 | 111784 | azResult--; |
| | @@ -113790,11 +114134,11 @@ |
| 113790 | 114134 | |
| 113791 | 114135 | |
| 113792 | 114136 | /* |
| 113793 | 114137 | ** External API function used to create a new virtual-table module. |
| 113794 | 114138 | */ |
| 113795 | | -SQLITE_API int sqlite3_create_module( |
| 114139 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_module( |
| 113796 | 114140 | sqlite3 *db, /* Database in which module is registered */ |
| 113797 | 114141 | const char *zName, /* Name assigned to this module */ |
| 113798 | 114142 | const sqlite3_module *pModule, /* The definition of the module */ |
| 113799 | 114143 | void *pAux /* Context pointer for xCreate/xConnect */ |
| 113800 | 114144 | ){ |
| | @@ -113805,11 +114149,11 @@ |
| 113805 | 114149 | } |
| 113806 | 114150 | |
| 113807 | 114151 | /* |
| 113808 | 114152 | ** External API function used to create a new virtual-table module. |
| 113809 | 114153 | */ |
| 113810 | | -SQLITE_API int sqlite3_create_module_v2( |
| 114154 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2( |
| 113811 | 114155 | sqlite3 *db, /* Database in which module is registered */ |
| 113812 | 114156 | const char *zName, /* Name assigned to this module */ |
| 113813 | 114157 | const sqlite3_module *pModule, /* The definition of the module */ |
| 113814 | 114158 | void *pAux, /* Context pointer for xCreate/xConnect */ |
| 113815 | 114159 | void (*xDestroy)(void *) /* Module destructor function */ |
| | @@ -114104,10 +114448,11 @@ |
| 114104 | 114448 | */ |
| 114105 | 114449 | if( !db->init.busy ){ |
| 114106 | 114450 | char *zStmt; |
| 114107 | 114451 | char *zWhere; |
| 114108 | 114452 | int iDb; |
| 114453 | + int iReg; |
| 114109 | 114454 | Vdbe *v; |
| 114110 | 114455 | |
| 114111 | 114456 | /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ |
| 114112 | 114457 | if( pEnd ){ |
| 114113 | 114458 | pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n; |
| | @@ -114138,12 +114483,14 @@ |
| 114138 | 114483 | sqlite3ChangeCookie(pParse, iDb); |
| 114139 | 114484 | |
| 114140 | 114485 | sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); |
| 114141 | 114486 | zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); |
| 114142 | 114487 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
| 114143 | | - sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, |
| 114144 | | - pTab->zName, sqlite3Strlen30(pTab->zName) + 1); |
| 114488 | + |
| 114489 | + iReg = ++pParse->nMem; |
| 114490 | + sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0); |
| 114491 | + sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); |
| 114145 | 114492 | } |
| 114146 | 114493 | |
| 114147 | 114494 | /* If we are rereading the sqlite_master table create the in-memory |
| 114148 | 114495 | ** record of the table. The xConnect() method is not called until |
| 114149 | 114496 | ** the first time the virtual table is used in an SQL statement. This |
| | @@ -114417,11 +114764,11 @@ |
| 114417 | 114764 | /* |
| 114418 | 114765 | ** This function is used to set the schema of a virtual table. It is only |
| 114419 | 114766 | ** valid to call this function from within the xCreate() or xConnect() of a |
| 114420 | 114767 | ** virtual table module. |
| 114421 | 114768 | */ |
| 114422 | | -SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ |
| 114769 | +SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ |
| 114423 | 114770 | Parse *pParse; |
| 114424 | 114771 | |
| 114425 | 114772 | int rc = SQLITE_OK; |
| 114426 | 114773 | Table *pTab; |
| 114427 | 114774 | char *zErr = 0; |
| | @@ -114492,15 +114839,19 @@ |
| 114492 | 114839 | int rc = SQLITE_OK; |
| 114493 | 114840 | Table *pTab; |
| 114494 | 114841 | |
| 114495 | 114842 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName); |
| 114496 | 114843 | if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){ |
| 114497 | | - VTable *p = vtabDisconnectAll(db, pTab); |
| 114498 | | - |
| 114499 | | - assert( rc==SQLITE_OK ); |
| 114844 | + VTable *p; |
| 114845 | + for(p=pTab->pVTable; p; p=p->pNext){ |
| 114846 | + assert( p->pVtab ); |
| 114847 | + if( p->pVtab->nRef>0 ){ |
| 114848 | + return SQLITE_LOCKED; |
| 114849 | + } |
| 114850 | + } |
| 114851 | + p = vtabDisconnectAll(db, pTab); |
| 114500 | 114852 | rc = p->pMod->pModule->xDestroy(p->pVtab); |
| 114501 | | - |
| 114502 | 114853 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ |
| 114503 | 114854 | if( rc==SQLITE_OK ){ |
| 114504 | 114855 | assert( pTab->pVTable==p && p->pNext==0 ); |
| 114505 | 114856 | p->pVtab = 0; |
| 114506 | 114857 | pTab->pVTable = 0; |
| | @@ -114781,11 +115132,11 @@ |
| 114781 | 115132 | ** table update operation currently in progress. |
| 114782 | 115133 | ** |
| 114783 | 115134 | ** The results of this routine are undefined unless it is called from |
| 114784 | 115135 | ** within an xUpdate method. |
| 114785 | 115136 | */ |
| 114786 | | -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){ |
| 115137 | +SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){ |
| 114787 | 115138 | static const unsigned char aMap[] = { |
| 114788 | 115139 | SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE |
| 114789 | 115140 | }; |
| 114790 | 115141 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 114791 | 115142 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| | @@ -114799,11 +115150,11 @@ |
| 114799 | 115150 | /* |
| 114800 | 115151 | ** Call from within the xCreate() or xConnect() methods to provide |
| 114801 | 115152 | ** the SQLite core with additional information about the behavior |
| 114802 | 115153 | ** of the virtual table being implemented. |
| 114803 | 115154 | */ |
| 114804 | | -SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){ |
| 115155 | +SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){ |
| 114805 | 115156 | va_list ap; |
| 114806 | 115157 | int rc = SQLITE_OK; |
| 114807 | 115158 | |
| 114808 | 115159 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 114809 | 115160 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| | @@ -116078,10 +116429,83 @@ |
| 116078 | 116429 | static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){ |
| 116079 | 116430 | pWC->a[iChild].iParent = iParent; |
| 116080 | 116431 | pWC->a[iChild].truthProb = pWC->a[iParent].truthProb; |
| 116081 | 116432 | pWC->a[iParent].nChild++; |
| 116082 | 116433 | } |
| 116434 | + |
| 116435 | +/* |
| 116436 | +** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not |
| 116437 | +** a conjunction, then return just pTerm when N==0. If N is exceeds |
| 116438 | +** the number of available subterms, return NULL. |
| 116439 | +*/ |
| 116440 | +static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){ |
| 116441 | + if( pTerm->eOperator!=WO_AND ){ |
| 116442 | + return N==0 ? pTerm : 0; |
| 116443 | + } |
| 116444 | + if( N<pTerm->u.pAndInfo->wc.nTerm ){ |
| 116445 | + return &pTerm->u.pAndInfo->wc.a[N]; |
| 116446 | + } |
| 116447 | + return 0; |
| 116448 | +} |
| 116449 | + |
| 116450 | +/* |
| 116451 | +** Subterms pOne and pTwo are contained within WHERE clause pWC. The |
| 116452 | +** two subterms are in disjunction - they are OR-ed together. |
| 116453 | +** |
| 116454 | +** If these two terms are both of the form: "A op B" with the same |
| 116455 | +** A and B values but different operators and if the operators are |
| 116456 | +** compatible (if one is = and the other is <, for example) then |
| 116457 | +** add a new virtual AND term to pWC that is the combination of the |
| 116458 | +** two. |
| 116459 | +** |
| 116460 | +** Some examples: |
| 116461 | +** |
| 116462 | +** x<y OR x=y --> x<=y |
| 116463 | +** x=y OR x=y --> x=y |
| 116464 | +** x<=y OR x<y --> x<=y |
| 116465 | +** |
| 116466 | +** The following is NOT generated: |
| 116467 | +** |
| 116468 | +** x<y OR x>y --> x!=y |
| 116469 | +*/ |
| 116470 | +static void whereCombineDisjuncts( |
| 116471 | + SrcList *pSrc, /* the FROM clause */ |
| 116472 | + WhereClause *pWC, /* The complete WHERE clause */ |
| 116473 | + WhereTerm *pOne, /* First disjunct */ |
| 116474 | + WhereTerm *pTwo /* Second disjunct */ |
| 116475 | +){ |
| 116476 | + u16 eOp = pOne->eOperator | pTwo->eOperator; |
| 116477 | + sqlite3 *db; /* Database connection (for malloc) */ |
| 116478 | + Expr *pNew; /* New virtual expression */ |
| 116479 | + int op; /* Operator for the combined expression */ |
| 116480 | + int idxNew; /* Index in pWC of the next virtual term */ |
| 116481 | + |
| 116482 | + if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 116483 | + if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 116484 | + if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp |
| 116485 | + && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return; |
| 116486 | + assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 ); |
| 116487 | + assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 ); |
| 116488 | + if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return; |
| 116489 | + if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return; |
| 116490 | + /* If we reach this point, it means the two subterms can be combined */ |
| 116491 | + if( (eOp & (eOp-1))!=0 ){ |
| 116492 | + if( eOp & (WO_LT|WO_LE) ){ |
| 116493 | + eOp = WO_LE; |
| 116494 | + }else{ |
| 116495 | + assert( eOp & (WO_GT|WO_GE) ); |
| 116496 | + eOp = WO_GE; |
| 116497 | + } |
| 116498 | + } |
| 116499 | + db = pWC->pWInfo->pParse->db; |
| 116500 | + pNew = sqlite3ExprDup(db, pOne->pExpr, 0); |
| 116501 | + if( pNew==0 ) return; |
| 116502 | + for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); } |
| 116503 | + pNew->op = op; |
| 116504 | + idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); |
| 116505 | + exprAnalyze(pSrc, pWC, idxNew); |
| 116506 | +} |
| 116083 | 116507 | |
| 116084 | 116508 | #if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY) |
| 116085 | 116509 | /* |
| 116086 | 116510 | ** Analyze a term that consists of two or more OR-connected |
| 116087 | 116511 | ** subterms. So in: |
| | @@ -116103,10 +116527,11 @@ |
| 116103 | 116527 | ** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5 |
| 116104 | 116528 | ** (B) x=expr1 OR expr2=x OR x=expr3 |
| 116105 | 116529 | ** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15) |
| 116106 | 116530 | ** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*') |
| 116107 | 116531 | ** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6) |
| 116532 | +** (F) x>A OR (x=A AND y>=B) |
| 116108 | 116533 | ** |
| 116109 | 116534 | ** CASE 1: |
| 116110 | 116535 | ** |
| 116111 | 116536 | ** If all subterms are of the form T.C=expr for some single column of C and |
| 116112 | 116537 | ** a single table T (as shown in example B above) then create a new virtual |
| | @@ -116118,10 +116543,20 @@ |
| 116118 | 116543 | ** then create a new virtual term like this: |
| 116119 | 116544 | ** |
| 116120 | 116545 | ** x IN (expr1,expr2,expr3) |
| 116121 | 116546 | ** |
| 116122 | 116547 | ** CASE 2: |
| 116548 | +** |
| 116549 | +** If there are exactly two disjuncts one side has x>A and the other side |
| 116550 | +** has x=A (for the same x and A) then add a new virtual conjunct term to the |
| 116551 | +** WHERE clause of the form "x>=A". Example: |
| 116552 | +** |
| 116553 | +** x>A OR (x=A AND y>B) adds: x>=A |
| 116554 | +** |
| 116555 | +** The added conjunct can sometimes be helpful in query planning. |
| 116556 | +** |
| 116557 | +** CASE 3: |
| 116123 | 116558 | ** |
| 116124 | 116559 | ** If all subterms are indexable by a single table T, then set |
| 116125 | 116560 | ** |
| 116126 | 116561 | ** WhereTerm.eOperator = WO_OR |
| 116127 | 116562 | ** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T |
| | @@ -116245,15 +116680,29 @@ |
| 116245 | 116680 | } |
| 116246 | 116681 | } |
| 116247 | 116682 | } |
| 116248 | 116683 | |
| 116249 | 116684 | /* |
| 116250 | | - ** Record the set of tables that satisfy case 2. The set might be |
| 116685 | + ** Record the set of tables that satisfy case 3. The set might be |
| 116251 | 116686 | ** empty. |
| 116252 | 116687 | */ |
| 116253 | 116688 | pOrInfo->indexable = indexable; |
| 116254 | 116689 | pTerm->eOperator = indexable==0 ? 0 : WO_OR; |
| 116690 | + |
| 116691 | + /* For a two-way OR, attempt to implementation case 2. |
| 116692 | + */ |
| 116693 | + if( indexable && pOrWc->nTerm==2 ){ |
| 116694 | + int iOne = 0; |
| 116695 | + WhereTerm *pOne; |
| 116696 | + while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){ |
| 116697 | + int iTwo = 0; |
| 116698 | + WhereTerm *pTwo; |
| 116699 | + while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){ |
| 116700 | + whereCombineDisjuncts(pSrc, pWC, pOne, pTwo); |
| 116701 | + } |
| 116702 | + } |
| 116703 | + } |
| 116255 | 116704 | |
| 116256 | 116705 | /* |
| 116257 | 116706 | ** chngToIN holds a set of tables that *might* satisfy case 1. But |
| 116258 | 116707 | ** we have to do some additional checking to see if case 1 really |
| 116259 | 116708 | ** is satisfied. |
| | @@ -116380,11 +116829,11 @@ |
| 116380 | 116829 | pTerm = &pWC->a[idxTerm]; |
| 116381 | 116830 | markTermAsChild(pWC, idxNew, idxTerm); |
| 116382 | 116831 | }else{ |
| 116383 | 116832 | sqlite3ExprListDelete(db, pList); |
| 116384 | 116833 | } |
| 116385 | | - pTerm->eOperator = WO_NOOP; /* case 1 trumps case 2 */ |
| 116834 | + pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */ |
| 116386 | 116835 | } |
| 116387 | 116836 | } |
| 116388 | 116837 | } |
| 116389 | 116838 | #endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */ |
| 116390 | 116839 | |
| | @@ -116575,11 +117024,11 @@ |
| 116575 | 117024 | Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */ |
| 116576 | 117025 | Expr *pNewExpr1; |
| 116577 | 117026 | Expr *pNewExpr2; |
| 116578 | 117027 | int idxNew1; |
| 116579 | 117028 | int idxNew2; |
| 116580 | | - Token sCollSeqName; /* Name of collating sequence */ |
| 117029 | + const char *zCollSeqName; /* Name of collating sequence */ |
| 116581 | 117030 | const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC; |
| 116582 | 117031 | |
| 116583 | 117032 | pLeft = pExpr->x.pList->a[1].pExpr; |
| 116584 | 117033 | pStr2 = sqlite3ExprDup(db, pStr1, 0); |
| 116585 | 117034 | |
| | @@ -116611,23 +117060,22 @@ |
| 116611 | 117060 | if( c=='A'-1 ) isComplete = 0; |
| 116612 | 117061 | c = sqlite3UpperToLower[c]; |
| 116613 | 117062 | } |
| 116614 | 117063 | *pC = c + 1; |
| 116615 | 117064 | } |
| 116616 | | - sCollSeqName.z = noCase ? "NOCASE" : "BINARY"; |
| 116617 | | - sCollSeqName.n = 6; |
| 117065 | + zCollSeqName = noCase ? "NOCASE" : "BINARY"; |
| 116618 | 117066 | pNewExpr1 = sqlite3ExprDup(db, pLeft, 0); |
| 116619 | 117067 | pNewExpr1 = sqlite3PExpr(pParse, TK_GE, |
| 116620 | | - sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName), |
| 117068 | + sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName), |
| 116621 | 117069 | pStr1, 0); |
| 116622 | 117070 | transferJoinMarkings(pNewExpr1, pExpr); |
| 116623 | 117071 | idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags); |
| 116624 | 117072 | testcase( idxNew1==0 ); |
| 116625 | 117073 | exprAnalyze(pSrc, pWC, idxNew1); |
| 116626 | 117074 | pNewExpr2 = sqlite3ExprDup(db, pLeft, 0); |
| 116627 | 117075 | pNewExpr2 = sqlite3PExpr(pParse, TK_LT, |
| 116628 | | - sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName), |
| 117076 | + sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName), |
| 116629 | 117077 | pStr2, 0); |
| 116630 | 117078 | transferJoinMarkings(pNewExpr2, pExpr); |
| 116631 | 117079 | idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags); |
| 116632 | 117080 | testcase( idxNew2==0 ); |
| 116633 | 117081 | exprAnalyze(pSrc, pWC, idxNew2); |
| | @@ -117240,15 +117688,18 @@ |
| 117240 | 117688 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 117241 | 117689 | /* |
| 117242 | 117690 | ** Estimate the location of a particular key among all keys in an |
| 117243 | 117691 | ** index. Store the results in aStat as follows: |
| 117244 | 117692 | ** |
| 117245 | | -** aStat[0] Est. number of rows less than pVal |
| 117246 | | -** aStat[1] Est. number of rows equal to pVal |
| 117693 | +** aStat[0] Est. number of rows less than pRec |
| 117694 | +** aStat[1] Est. number of rows equal to pRec |
| 117247 | 117695 | ** |
| 117248 | 117696 | ** Return the index of the sample that is the smallest sample that |
| 117249 | | -** is greater than or equal to pRec. |
| 117697 | +** is greater than or equal to pRec. Note that this index is not an index |
| 117698 | +** into the aSample[] array - it is an index into a virtual set of samples |
| 117699 | +** based on the contents of aSample[] and the number of fields in record |
| 117700 | +** pRec. |
| 117250 | 117701 | */ |
| 117251 | 117702 | static int whereKeyStats( |
| 117252 | 117703 | Parse *pParse, /* Database connection */ |
| 117253 | 117704 | Index *pIdx, /* Index to consider domain of */ |
| 117254 | 117705 | UnpackedRecord *pRec, /* Vector of values to consider */ |
| | @@ -117255,71 +117706,162 @@ |
| 117255 | 117706 | int roundUp, /* Round up if true. Round down if false */ |
| 117256 | 117707 | tRowcnt *aStat /* OUT: stats written here */ |
| 117257 | 117708 | ){ |
| 117258 | 117709 | IndexSample *aSample = pIdx->aSample; |
| 117259 | 117710 | int iCol; /* Index of required stats in anEq[] etc. */ |
| 117711 | + int i; /* Index of first sample >= pRec */ |
| 117712 | + int iSample; /* Smallest sample larger than or equal to pRec */ |
| 117260 | 117713 | int iMin = 0; /* Smallest sample not yet tested */ |
| 117261 | | - int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */ |
| 117262 | 117714 | int iTest; /* Next sample to test */ |
| 117263 | 117715 | int res; /* Result of comparison operation */ |
| 117716 | + int nField; /* Number of fields in pRec */ |
| 117717 | + tRowcnt iLower = 0; /* anLt[] + anEq[] of largest sample pRec is > */ |
| 117264 | 117718 | |
| 117265 | 117719 | #ifndef SQLITE_DEBUG |
| 117266 | 117720 | UNUSED_PARAMETER( pParse ); |
| 117267 | 117721 | #endif |
| 117268 | 117722 | assert( pRec!=0 ); |
| 117269 | | - iCol = pRec->nField - 1; |
| 117270 | 117723 | assert( pIdx->nSample>0 ); |
| 117271 | | - assert( pRec->nField>0 && iCol<pIdx->nSampleCol ); |
| 117724 | + assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol ); |
| 117725 | + |
| 117726 | + /* Do a binary search to find the first sample greater than or equal |
| 117727 | + ** to pRec. If pRec contains a single field, the set of samples to search |
| 117728 | + ** is simply the aSample[] array. If the samples in aSample[] contain more |
| 117729 | + ** than one fields, all fields following the first are ignored. |
| 117730 | + ** |
| 117731 | + ** If pRec contains N fields, where N is more than one, then as well as the |
| 117732 | + ** samples in aSample[] (truncated to N fields), the search also has to |
| 117733 | + ** consider prefixes of those samples. For example, if the set of samples |
| 117734 | + ** in aSample is: |
| 117735 | + ** |
| 117736 | + ** aSample[0] = (a, 5) |
| 117737 | + ** aSample[1] = (a, 10) |
| 117738 | + ** aSample[2] = (b, 5) |
| 117739 | + ** aSample[3] = (c, 100) |
| 117740 | + ** aSample[4] = (c, 105) |
| 117741 | + ** |
| 117742 | + ** Then the search space should ideally be the samples above and the |
| 117743 | + ** unique prefixes [a], [b] and [c]. But since that is hard to organize, |
| 117744 | + ** the code actually searches this set: |
| 117745 | + ** |
| 117746 | + ** 0: (a) |
| 117747 | + ** 1: (a, 5) |
| 117748 | + ** 2: (a, 10) |
| 117749 | + ** 3: (a, 10) |
| 117750 | + ** 4: (b) |
| 117751 | + ** 5: (b, 5) |
| 117752 | + ** 6: (c) |
| 117753 | + ** 7: (c, 100) |
| 117754 | + ** 8: (c, 105) |
| 117755 | + ** 9: (c, 105) |
| 117756 | + ** |
| 117757 | + ** For each sample in the aSample[] array, N samples are present in the |
| 117758 | + ** effective sample array. In the above, samples 0 and 1 are based on |
| 117759 | + ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc. |
| 117760 | + ** |
| 117761 | + ** Often, sample i of each block of N effective samples has (i+1) fields. |
| 117762 | + ** Except, each sample may be extended to ensure that it is greater than or |
| 117763 | + ** equal to the previous sample in the array. For example, in the above, |
| 117764 | + ** sample 2 is the first sample of a block of N samples, so at first it |
| 117765 | + ** appears that it should be 1 field in size. However, that would make it |
| 117766 | + ** smaller than sample 1, so the binary search would not work. As a result, |
| 117767 | + ** it is extended to two fields. The duplicates that this creates do not |
| 117768 | + ** cause any problems. |
| 117769 | + */ |
| 117770 | + nField = pRec->nField; |
| 117771 | + iCol = 0; |
| 117772 | + iSample = pIdx->nSample * nField; |
| 117272 | 117773 | do{ |
| 117273 | | - iTest = (iMin+i)/2; |
| 117274 | | - res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec); |
| 117774 | + int iSamp; /* Index in aSample[] of test sample */ |
| 117775 | + int n; /* Number of fields in test sample */ |
| 117776 | + |
| 117777 | + iTest = (iMin+iSample)/2; |
| 117778 | + iSamp = iTest / nField; |
| 117779 | + if( iSamp>0 ){ |
| 117780 | + /* The proposed effective sample is a prefix of sample aSample[iSamp]. |
| 117781 | + ** Specifically, the shortest prefix of at least (1 + iTest%nField) |
| 117782 | + ** fields that is greater than the previous effective sample. */ |
| 117783 | + for(n=(iTest % nField) + 1; n<nField; n++){ |
| 117784 | + if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break; |
| 117785 | + } |
| 117786 | + }else{ |
| 117787 | + n = iTest + 1; |
| 117788 | + } |
| 117789 | + |
| 117790 | + pRec->nField = n; |
| 117791 | + res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec); |
| 117275 | 117792 | if( res<0 ){ |
| 117793 | + iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1]; |
| 117794 | + iMin = iTest+1; |
| 117795 | + }else if( res==0 && n<nField ){ |
| 117796 | + iLower = aSample[iSamp].anLt[n-1]; |
| 117276 | 117797 | iMin = iTest+1; |
| 117798 | + res = -1; |
| 117277 | 117799 | }else{ |
| 117278 | | - i = iTest; |
| 117800 | + iSample = iTest; |
| 117801 | + iCol = n-1; |
| 117279 | 117802 | } |
| 117280 | | - }while( res && iMin<i ); |
| 117803 | + }while( res && iMin<iSample ); |
| 117804 | + i = iSample / nField; |
| 117281 | 117805 | |
| 117282 | 117806 | #ifdef SQLITE_DEBUG |
| 117283 | 117807 | /* The following assert statements check that the binary search code |
| 117284 | 117808 | ** above found the right answer. This block serves no purpose other |
| 117285 | 117809 | ** than to invoke the asserts. */ |
| 117286 | | - if( res==0 ){ |
| 117287 | | - /* If (res==0) is true, then sample $i must be equal to pRec */ |
| 117288 | | - assert( i<pIdx->nSample ); |
| 117289 | | - assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec) |
| 117290 | | - || pParse->db->mallocFailed ); |
| 117291 | | - }else{ |
| 117292 | | - /* Otherwise, pRec must be smaller than sample $i and larger than |
| 117293 | | - ** sample ($i-1). */ |
| 117294 | | - assert( i==pIdx->nSample |
| 117295 | | - || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0 |
| 117296 | | - || pParse->db->mallocFailed ); |
| 117297 | | - assert( i==0 |
| 117298 | | - || sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0 |
| 117299 | | - || pParse->db->mallocFailed ); |
| 117810 | + if( pParse->db->mallocFailed==0 ){ |
| 117811 | + if( res==0 ){ |
| 117812 | + /* If (res==0) is true, then pRec must be equal to sample i. */ |
| 117813 | + assert( i<pIdx->nSample ); |
| 117814 | + assert( iCol==nField-1 ); |
| 117815 | + pRec->nField = nField; |
| 117816 | + assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec) |
| 117817 | + || pParse->db->mallocFailed |
| 117818 | + ); |
| 117819 | + }else{ |
| 117820 | + /* Unless i==pIdx->nSample, indicating that pRec is larger than |
| 117821 | + ** all samples in the aSample[] array, pRec must be smaller than the |
| 117822 | + ** (iCol+1) field prefix of sample i. */ |
| 117823 | + assert( i<=pIdx->nSample && i>=0 ); |
| 117824 | + pRec->nField = iCol+1; |
| 117825 | + assert( i==pIdx->nSample |
| 117826 | + || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0 |
| 117827 | + || pParse->db->mallocFailed ); |
| 117828 | + |
| 117829 | + /* if i==0 and iCol==0, then record pRec is smaller than all samples |
| 117830 | + ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must |
| 117831 | + ** be greater than or equal to the (iCol) field prefix of sample i. |
| 117832 | + ** If (i>0), then pRec must also be greater than sample (i-1). */ |
| 117833 | + if( iCol>0 ){ |
| 117834 | + pRec->nField = iCol; |
| 117835 | + assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0 |
| 117836 | + || pParse->db->mallocFailed ); |
| 117837 | + } |
| 117838 | + if( i>0 ){ |
| 117839 | + pRec->nField = nField; |
| 117840 | + assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0 |
| 117841 | + || pParse->db->mallocFailed ); |
| 117842 | + } |
| 117843 | + } |
| 117300 | 117844 | } |
| 117301 | 117845 | #endif /* ifdef SQLITE_DEBUG */ |
| 117302 | 117846 | |
| 117303 | | - /* At this point, aSample[i] is the first sample that is greater than |
| 117304 | | - ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less |
| 117305 | | - ** than pVal. If aSample[i]==pVal, then res==0. |
| 117306 | | - */ |
| 117307 | 117847 | if( res==0 ){ |
| 117848 | + /* Record pRec is equal to sample i */ |
| 117849 | + assert( iCol==nField-1 ); |
| 117308 | 117850 | aStat[0] = aSample[i].anLt[iCol]; |
| 117309 | 117851 | aStat[1] = aSample[i].anEq[iCol]; |
| 117310 | 117852 | }else{ |
| 117311 | | - tRowcnt iLower, iUpper, iGap; |
| 117312 | | - if( i==0 ){ |
| 117313 | | - iLower = 0; |
| 117314 | | - iUpper = aSample[0].anLt[iCol]; |
| 117853 | + /* At this point, the (iCol+1) field prefix of aSample[i] is the first |
| 117854 | + ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec |
| 117855 | + ** is larger than all samples in the array. */ |
| 117856 | + tRowcnt iUpper, iGap; |
| 117857 | + if( i>=pIdx->nSample ){ |
| 117858 | + iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]); |
| 117315 | 117859 | }else{ |
| 117316 | | - i64 nRow0 = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]); |
| 117317 | | - iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol]; |
| 117318 | | - iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol]; |
| 117860 | + iUpper = aSample[i].anLt[iCol]; |
| 117319 | 117861 | } |
| 117320 | | - aStat[1] = pIdx->aAvgEq[iCol]; |
| 117862 | + |
| 117321 | 117863 | if( iLower>=iUpper ){ |
| 117322 | 117864 | iGap = 0; |
| 117323 | 117865 | }else{ |
| 117324 | 117866 | iGap = iUpper - iLower; |
| 117325 | 117867 | } |
| | @@ -117327,11 +117869,15 @@ |
| 117327 | 117869 | iGap = (iGap*2)/3; |
| 117328 | 117870 | }else{ |
| 117329 | 117871 | iGap = iGap/3; |
| 117330 | 117872 | } |
| 117331 | 117873 | aStat[0] = iLower + iGap; |
| 117874 | + aStat[1] = pIdx->aAvgEq[iCol]; |
| 117332 | 117875 | } |
| 117876 | + |
| 117877 | + /* Restore the pRec->nField value before returning. */ |
| 117878 | + pRec->nField = nField; |
| 117333 | 117879 | return i; |
| 117334 | 117880 | } |
| 117335 | 117881 | #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ |
| 117336 | 117882 | |
| 117337 | 117883 | /* |
| | @@ -118322,25 +118868,33 @@ |
| 118322 | 118868 | #else |
| 118323 | 118869 | # define addScanStatus(a, b, c, d) ((void)d) |
| 118324 | 118870 | #endif |
| 118325 | 118871 | |
| 118326 | 118872 | /* |
| 118327 | | -** Look at the last instruction coded. If that instruction is OP_String8 |
| 118328 | | -** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be |
| 118873 | +** If the most recently coded instruction is a constant range contraint |
| 118874 | +** that originated from the LIKE optimization, then change the P3 to be |
| 118329 | 118875 | ** pLoop->iLikeRepCntr and set P5. |
| 118330 | 118876 | ** |
| 118331 | 118877 | ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range |
| 118332 | 118878 | ** expression: "x>='ABC' AND x<'abd'". But this requires that the range |
| 118333 | 118879 | ** scan loop run twice, once for strings and a second time for BLOBs. |
| 118334 | 118880 | ** The OP_String opcodes on the second pass convert the upper and lower |
| 118335 | 118881 | ** bound string contants to blobs. This routine makes the necessary changes |
| 118336 | 118882 | ** to the OP_String opcodes for that to happen. |
| 118337 | 118883 | */ |
| 118338 | | -static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){ |
| 118339 | | - VdbeOp *pOp; |
| 118340 | | - pOp = sqlite3VdbeGetOp(v, -1); |
| 118341 | | - if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){ |
| 118884 | +static void whereLikeOptimizationStringFixup( |
| 118885 | + Vdbe *v, /* prepared statement under construction */ |
| 118886 | + WhereLevel *pLevel, /* The loop that contains the LIKE operator */ |
| 118887 | + WhereTerm *pTerm /* The upper or lower bound just coded */ |
| 118888 | +){ |
| 118889 | + if( pTerm->wtFlags & TERM_LIKEOPT ){ |
| 118890 | + VdbeOp *pOp; |
| 118891 | + assert( pLevel->iLikeRepCntr>0 ); |
| 118892 | + pOp = sqlite3VdbeGetOp(v, -1); |
| 118893 | + assert( pOp!=0 ); |
| 118894 | + assert( pOp->opcode==OP_String8 |
| 118895 | + || pTerm->pWC->pWInfo->pParse->db->mallocFailed ); |
| 118342 | 118896 | pOp->p3 = pLevel->iLikeRepCntr; |
| 118343 | 118897 | pOp->p5 = 1; |
| 118344 | 118898 | } |
| 118345 | 118899 | } |
| 118346 | 118900 | |
| | @@ -118670,18 +119224,20 @@ |
| 118670 | 119224 | */ |
| 118671 | 119225 | j = nEq; |
| 118672 | 119226 | if( pLoop->wsFlags & WHERE_BTM_LIMIT ){ |
| 118673 | 119227 | pRangeStart = pLoop->aLTerm[j++]; |
| 118674 | 119228 | nExtraReg = 1; |
| 119229 | + /* Like optimization range constraints always occur in pairs */ |
| 119230 | + assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 || |
| 119231 | + (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 ); |
| 118675 | 119232 | } |
| 118676 | 119233 | if( pLoop->wsFlags & WHERE_TOP_LIMIT ){ |
| 118677 | 119234 | pRangeEnd = pLoop->aLTerm[j++]; |
| 118678 | 119235 | nExtraReg = 1; |
| 118679 | | - if( pRangeStart |
| 118680 | | - && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0 |
| 118681 | | - && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 |
| 118682 | | - ){ |
| 119236 | + if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){ |
| 119237 | + assert( pRangeStart!=0 ); /* LIKE opt constraints */ |
| 119238 | + assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */ |
| 118683 | 119239 | pLevel->iLikeRepCntr = ++pParse->nMem; |
| 118684 | 119240 | testcase( bRev ); |
| 118685 | 119241 | testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC ); |
| 118686 | 119242 | sqlite3VdbeAddOp2(v, OP_Integer, |
| 118687 | 119243 | bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC), |
| | @@ -118729,11 +119285,11 @@ |
| 118729 | 119285 | /* Seek the index cursor to the start of the range. */ |
| 118730 | 119286 | nConstraint = nEq; |
| 118731 | 119287 | if( pRangeStart ){ |
| 118732 | 119288 | Expr *pRight = pRangeStart->pExpr->pRight; |
| 118733 | 119289 | sqlite3ExprCode(pParse, pRight, regBase+nEq); |
| 118734 | | - whereLikeOptimizationStringFixup(v, pLevel); |
| 119290 | + whereLikeOptimizationStringFixup(v, pLevel, pRangeStart); |
| 118735 | 119291 | if( (pRangeStart->wtFlags & TERM_VNULL)==0 |
| 118736 | 119292 | && sqlite3ExprCanBeNull(pRight) |
| 118737 | 119293 | ){ |
| 118738 | 119294 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); |
| 118739 | 119295 | VdbeCoverage(v); |
| | @@ -118775,11 +119331,11 @@ |
| 118775 | 119331 | nConstraint = nEq; |
| 118776 | 119332 | if( pRangeEnd ){ |
| 118777 | 119333 | Expr *pRight = pRangeEnd->pExpr->pRight; |
| 118778 | 119334 | sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); |
| 118779 | 119335 | sqlite3ExprCode(pParse, pRight, regBase+nEq); |
| 118780 | | - whereLikeOptimizationStringFixup(v, pLevel); |
| 119336 | + whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); |
| 118781 | 119337 | if( (pRangeEnd->wtFlags & TERM_VNULL)==0 |
| 118782 | 119338 | && sqlite3ExprCanBeNull(pRight) |
| 118783 | 119339 | ){ |
| 118784 | 119340 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); |
| 118785 | 119341 | VdbeCoverage(v); |
| | @@ -119852,10 +120408,14 @@ |
| 119852 | 120408 | ){ |
| 119853 | 120409 | continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */ |
| 119854 | 120410 | } |
| 119855 | 120411 | if( pTerm->prereqRight & pNew->maskSelf ) continue; |
| 119856 | 120412 | |
| 120413 | + /* Do not allow the upper bound of a LIKE optimization range constraint |
| 120414 | + ** to mix with a lower range bound from some other source */ |
| 120415 | + if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; |
| 120416 | + |
| 119857 | 120417 | pNew->wsFlags = saved_wsFlags; |
| 119858 | 120418 | pNew->u.btree.nEq = saved_nEq; |
| 119859 | 120419 | pNew->nLTerm = saved_nLTerm; |
| 119860 | 120420 | if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */ |
| 119861 | 120421 | pNew->aLTerm[pNew->nLTerm++] = pTerm; |
| | @@ -119895,10 +120455,21 @@ |
| 119895 | 120455 | testcase( eOp & WO_GT ); |
| 119896 | 120456 | testcase( eOp & WO_GE ); |
| 119897 | 120457 | pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT; |
| 119898 | 120458 | pBtm = pTerm; |
| 119899 | 120459 | pTop = 0; |
| 120460 | + if( pTerm->wtFlags & TERM_LIKEOPT ){ |
| 120461 | + /* Range contraints that come from the LIKE optimization are |
| 120462 | + ** always used in pairs. */ |
| 120463 | + pTop = &pTerm[1]; |
| 120464 | + assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm ); |
| 120465 | + assert( pTop->wtFlags & TERM_LIKEOPT ); |
| 120466 | + assert( pTop->eOperator==WO_LT ); |
| 120467 | + if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */ |
| 120468 | + pNew->aLTerm[pNew->nLTerm++] = pTop; |
| 120469 | + pNew->wsFlags |= WHERE_TOP_LIMIT; |
| 120470 | + } |
| 119900 | 120471 | }else{ |
| 119901 | 120472 | assert( eOp & (WO_LT|WO_LE) ); |
| 119902 | 120473 | testcase( eOp & WO_LT ); |
| 119903 | 120474 | testcase( eOp & WO_LE ); |
| 119904 | 120475 | pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT; |
| | @@ -121089,14 +121660,14 @@ |
| 121089 | 121660 | assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] ); |
| 121090 | 121661 | assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX ); |
| 121091 | 121662 | |
| 121092 | 121663 | /* Seed the search with a single WherePath containing zero WhereLoops. |
| 121093 | 121664 | ** |
| 121094 | | - ** TUNING: Do not let the number of iterations go above 25. If the cost |
| 121095 | | - ** of computing an automatic index is not paid back within the first 25 |
| 121665 | + ** TUNING: Do not let the number of iterations go above 28. If the cost |
| 121666 | + ** of computing an automatic index is not paid back within the first 28 |
| 121096 | 121667 | ** rows, then do not use the automatic index. */ |
| 121097 | | - aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) ); |
| 121668 | + aFrom[0].nRow = MIN(pParse->nQueryLoop, 48); assert( 48==sqlite3LogEst(28) ); |
| 121098 | 121669 | nFrom = 1; |
| 121099 | 121670 | assert( aFrom[0].isOrdered==0 ); |
| 121100 | 121671 | if( nOrderBy ){ |
| 121101 | 121672 | /* If nLoop is zero, then there are no FROM terms in the query. Since |
| 121102 | 121673 | ** in this case the query may return a maximum of one row, the results |
| | @@ -121890,10 +122461,16 @@ |
| 121890 | 122461 | assert( pIx->pSchema==pTab->pSchema ); |
| 121891 | 122462 | assert( iIndexCur>=0 ); |
| 121892 | 122463 | if( op ){ |
| 121893 | 122464 | sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb); |
| 121894 | 122465 | sqlite3VdbeSetP4KeyInfo(pParse, pIx); |
| 122466 | + if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 |
| 122467 | + && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0 |
| 122468 | + && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 |
| 122469 | + ){ |
| 122470 | + sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */ |
| 122471 | + } |
| 121895 | 122472 | VdbeComment((v, "%s", pIx->zName)); |
| 121896 | 122473 | } |
| 121897 | 122474 | } |
| 121898 | 122475 | if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb); |
| 121899 | 122476 | notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor); |
| | @@ -124891,11 +125468,11 @@ |
| 124891 | 125468 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 124892 | 125469 | } |
| 124893 | 125470 | break; |
| 124894 | 125471 | case 193: /* expr ::= expr COLLATE ID|STRING */ |
| 124895 | 125472 | { |
| 124896 | | - yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0); |
| 125473 | + yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0, 1); |
| 124897 | 125474 | yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart; |
| 124898 | 125475 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 124899 | 125476 | } |
| 124900 | 125477 | break; |
| 124901 | 125478 | case 194: /* expr ::= CAST LP expr AS typetoken RP */ |
| | @@ -125171,20 +125748,20 @@ |
| 125171 | 125748 | case 241: /* uniqueflag ::= */ |
| 125172 | 125749 | {yygotominor.yy328 = OE_None;} |
| 125173 | 125750 | break; |
| 125174 | 125751 | case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 125175 | 125752 | { |
| 125176 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 125753 | + Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1); |
| 125177 | 125754 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p); |
| 125178 | 125755 | sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1); |
| 125179 | 125756 | sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 125180 | 125757 | if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 125181 | 125758 | } |
| 125182 | 125759 | break; |
| 125183 | 125760 | case 245: /* idxlist ::= nm collate sortorder */ |
| 125184 | 125761 | { |
| 125185 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 125762 | + Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1); |
| 125186 | 125763 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p); |
| 125187 | 125764 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 125188 | 125765 | sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 125189 | 125766 | if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 125190 | 125767 | } |
| | @@ -126439,13 +127016,15 @@ |
| 126439 | 127016 | pParse->zTail = &zSql[i]; |
| 126440 | 127017 | } |
| 126441 | 127018 | sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); |
| 126442 | 127019 | } |
| 126443 | 127020 | #ifdef YYTRACKMAXSTACKDEPTH |
| 127021 | + sqlite3_mutex_enter(sqlite3MallocMutex()); |
| 126444 | 127022 | sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK, |
| 126445 | 127023 | sqlite3ParserStackPeak(pEngine) |
| 126446 | 127024 | ); |
| 127025 | + sqlite3_mutex_leave(sqlite3MallocMutex()); |
| 126447 | 127026 | #endif /* YYDEBUG */ |
| 126448 | 127027 | sqlite3ParserFree(pEngine, sqlite3_free); |
| 126449 | 127028 | db->lookaside.bEnabled = enableLookaside; |
| 126450 | 127029 | if( db->mallocFailed ){ |
| 126451 | 127030 | pParse->rc = SQLITE_NOMEM; |
| | @@ -126605,11 +127184,11 @@ |
| 126605 | 127184 | ** |
| 126606 | 127185 | ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed |
| 126607 | 127186 | ** to recognize the end of a trigger can be omitted. All we have to do |
| 126608 | 127187 | ** is look for a semicolon that is not part of an string or comment. |
| 126609 | 127188 | */ |
| 126610 | | -SQLITE_API int sqlite3_complete(const char *zSql){ |
| 127189 | +SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){ |
| 126611 | 127190 | u8 state = 0; /* Current state, using numbers defined in header comment */ |
| 126612 | 127191 | u8 token; /* Value of the next token */ |
| 126613 | 127192 | |
| 126614 | 127193 | #ifndef SQLITE_OMIT_TRIGGER |
| 126615 | 127194 | /* A complex statement machine used to detect the end of a CREATE TRIGGER |
| | @@ -126770,11 +127349,11 @@ |
| 126770 | 127349 | /* |
| 126771 | 127350 | ** This routine is the same as the sqlite3_complete() routine described |
| 126772 | 127351 | ** above, except that the parameter is required to be UTF-16 encoded, not |
| 126773 | 127352 | ** UTF-8. |
| 126774 | 127353 | */ |
| 126775 | | -SQLITE_API int sqlite3_complete16(const void *zSql){ |
| 127354 | +SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){ |
| 126776 | 127355 | sqlite3_value *pVal; |
| 126777 | 127356 | char const *zSql8; |
| 126778 | 127357 | int rc = SQLITE_NOMEM; |
| 126779 | 127358 | |
| 126780 | 127359 | #ifndef SQLITE_OMIT_AUTOINIT |
| | @@ -126920,37 +127499,37 @@ |
| 126920 | 127499 | #endif |
| 126921 | 127500 | |
| 126922 | 127501 | /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns |
| 126923 | 127502 | ** a pointer to the to the sqlite3_version[] string constant. |
| 126924 | 127503 | */ |
| 126925 | | -SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; } |
| 127504 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; } |
| 126926 | 127505 | |
| 126927 | 127506 | /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a |
| 126928 | 127507 | ** pointer to a string constant whose value is the same as the |
| 126929 | 127508 | ** SQLITE_SOURCE_ID C preprocessor macro. |
| 126930 | 127509 | */ |
| 126931 | | -SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 127510 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 126932 | 127511 | |
| 126933 | 127512 | /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function |
| 126934 | 127513 | ** returns an integer equal to SQLITE_VERSION_NUMBER. |
| 126935 | 127514 | */ |
| 126936 | | -SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } |
| 127515 | +SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } |
| 126937 | 127516 | |
| 126938 | 127517 | /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns |
| 126939 | 127518 | ** zero if and only if SQLite was compiled with mutexing code omitted due to |
| 126940 | 127519 | ** the SQLITE_THREADSAFE compile-time option being set to 0. |
| 126941 | 127520 | */ |
| 126942 | | -SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } |
| 127521 | +SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } |
| 126943 | 127522 | |
| 126944 | 127523 | #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) |
| 126945 | 127524 | /* |
| 126946 | 127525 | ** If the following function pointer is not NULL and if |
| 126947 | 127526 | ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing |
| 126948 | 127527 | ** I/O active are written using this function. These messages |
| 126949 | 127528 | ** are intended for debugging activity only. |
| 126950 | 127529 | */ |
| 126951 | | -/* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0; |
| 127530 | +SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0; |
| 126952 | 127531 | #endif |
| 126953 | 127532 | |
| 126954 | 127533 | /* |
| 126955 | 127534 | ** If the following global variable points to a string which is the |
| 126956 | 127535 | ** name of a directory, then that directory will be used to store |
| | @@ -126998,11 +127577,11 @@ |
| 126998 | 127577 | ** call by X completes. |
| 126999 | 127578 | ** |
| 127000 | 127579 | ** * Recursive calls to this routine from thread X return immediately |
| 127001 | 127580 | ** without blocking. |
| 127002 | 127581 | */ |
| 127003 | | -SQLITE_API int sqlite3_initialize(void){ |
| 127582 | +SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){ |
| 127004 | 127583 | MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 127005 | 127584 | int rc; /* Result code */ |
| 127006 | 127585 | #ifdef SQLITE_EXTRA_INIT |
| 127007 | 127586 | int bRunExtraInit = 0; /* Extra initialization needed */ |
| 127008 | 127587 | #endif |
| | @@ -127011,10 +127590,15 @@ |
| 127011 | 127590 | rc = sqlite3_wsd_init(4096, 24); |
| 127012 | 127591 | if( rc!=SQLITE_OK ){ |
| 127013 | 127592 | return rc; |
| 127014 | 127593 | } |
| 127015 | 127594 | #endif |
| 127595 | + |
| 127596 | + /* If the following assert() fails on some obscure processor/compiler |
| 127597 | + ** combination, the work-around is to set the correct pointer |
| 127598 | + ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */ |
| 127599 | + assert( SQLITE_PTRSIZE==sizeof(char*) ); |
| 127016 | 127600 | |
| 127017 | 127601 | /* If SQLite is already completely initialized, then this call |
| 127018 | 127602 | ** to sqlite3_initialize() should be a no-op. But the initialization |
| 127019 | 127603 | ** must be complete. So isInit must not be set until the very end |
| 127020 | 127604 | ** of this routine. |
| | @@ -127154,11 +127738,11 @@ |
| 127154 | 127738 | ** while any part of SQLite is otherwise in use in any thread. This |
| 127155 | 127739 | ** routine is not threadsafe. But it is safe to invoke this routine |
| 127156 | 127740 | ** on when SQLite is already shut down. If SQLite is already shut down |
| 127157 | 127741 | ** when this routine is invoked, then this routine is a harmless no-op. |
| 127158 | 127742 | */ |
| 127159 | | -SQLITE_API int sqlite3_shutdown(void){ |
| 127743 | +SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){ |
| 127160 | 127744 | #ifdef SQLITE_OMIT_WSD |
| 127161 | 127745 | int rc = sqlite3_wsd_init(4096, 24); |
| 127162 | 127746 | if( rc!=SQLITE_OK ){ |
| 127163 | 127747 | return rc; |
| 127164 | 127748 | } |
| | @@ -127208,11 +127792,11 @@ |
| 127208 | 127792 | ** This routine should only be called when there are no outstanding |
| 127209 | 127793 | ** database connections or memory allocations. This routine is not |
| 127210 | 127794 | ** threadsafe. Failure to heed these warnings can lead to unpredictable |
| 127211 | 127795 | ** behavior. |
| 127212 | 127796 | */ |
| 127213 | | -SQLITE_API int sqlite3_config(int op, ...){ |
| 127797 | +SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){ |
| 127214 | 127798 | va_list ap; |
| 127215 | 127799 | int rc = SQLITE_OK; |
| 127216 | 127800 | |
| 127217 | 127801 | /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while |
| 127218 | 127802 | ** the SQLite library is in use. */ |
| | @@ -127565,11 +128149,11 @@ |
| 127565 | 128149 | } |
| 127566 | 128150 | |
| 127567 | 128151 | /* |
| 127568 | 128152 | ** Return the mutex associated with a database connection. |
| 127569 | 128153 | */ |
| 127570 | | -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){ |
| 128154 | +SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){ |
| 127571 | 128155 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 127572 | 128156 | if( !sqlite3SafetyCheckOk(db) ){ |
| 127573 | 128157 | (void)SQLITE_MISUSE_BKPT; |
| 127574 | 128158 | return 0; |
| 127575 | 128159 | } |
| | @@ -127579,11 +128163,11 @@ |
| 127579 | 128163 | |
| 127580 | 128164 | /* |
| 127581 | 128165 | ** Free up as much memory as we can from the given database |
| 127582 | 128166 | ** connection. |
| 127583 | 128167 | */ |
| 127584 | | -SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){ |
| 128168 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){ |
| 127585 | 128169 | int i; |
| 127586 | 128170 | |
| 127587 | 128171 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 127588 | 128172 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 127589 | 128173 | #endif |
| | @@ -127602,11 +128186,11 @@ |
| 127602 | 128186 | } |
| 127603 | 128187 | |
| 127604 | 128188 | /* |
| 127605 | 128189 | ** Configuration settings for an individual database connection |
| 127606 | 128190 | */ |
| 127607 | | -SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 128191 | +SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){ |
| 127608 | 128192 | va_list ap; |
| 127609 | 128193 | int rc; |
| 127610 | 128194 | va_start(ap, op); |
| 127611 | 128195 | switch( op ){ |
| 127612 | 128196 | case SQLITE_DBCONFIG_LOOKASIDE: { |
| | @@ -127721,11 +128305,11 @@ |
| 127721 | 128305 | } |
| 127722 | 128306 | |
| 127723 | 128307 | /* |
| 127724 | 128308 | ** Return the ROWID of the most recent insert |
| 127725 | 128309 | */ |
| 127726 | | -SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){ |
| 128310 | +SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){ |
| 127727 | 128311 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 127728 | 128312 | if( !sqlite3SafetyCheckOk(db) ){ |
| 127729 | 128313 | (void)SQLITE_MISUSE_BKPT; |
| 127730 | 128314 | return 0; |
| 127731 | 128315 | } |
| | @@ -127734,11 +128318,11 @@ |
| 127734 | 128318 | } |
| 127735 | 128319 | |
| 127736 | 128320 | /* |
| 127737 | 128321 | ** Return the number of changes in the most recent call to sqlite3_exec(). |
| 127738 | 128322 | */ |
| 127739 | | -SQLITE_API int sqlite3_changes(sqlite3 *db){ |
| 128323 | +SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){ |
| 127740 | 128324 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 127741 | 128325 | if( !sqlite3SafetyCheckOk(db) ){ |
| 127742 | 128326 | (void)SQLITE_MISUSE_BKPT; |
| 127743 | 128327 | return 0; |
| 127744 | 128328 | } |
| | @@ -127747,11 +128331,11 @@ |
| 127747 | 128331 | } |
| 127748 | 128332 | |
| 127749 | 128333 | /* |
| 127750 | 128334 | ** Return the number of changes since the database handle was opened. |
| 127751 | 128335 | */ |
| 127752 | | -SQLITE_API int sqlite3_total_changes(sqlite3 *db){ |
| 128336 | +SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){ |
| 127753 | 128337 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 127754 | 128338 | if( !sqlite3SafetyCheckOk(db) ){ |
| 127755 | 128339 | (void)SQLITE_MISUSE_BKPT; |
| 127756 | 128340 | return 0; |
| 127757 | 128341 | } |
| | @@ -127889,12 +128473,12 @@ |
| 127889 | 128473 | ** statements or unfinished sqlite3_backups. The sqlite3_close_v2() |
| 127890 | 128474 | ** version forces the connection to become a zombie if there are |
| 127891 | 128475 | ** unclosed resources, and arranges for deallocation when the last |
| 127892 | 128476 | ** prepare statement or sqlite3_backup closes. |
| 127893 | 128477 | */ |
| 127894 | | -SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); } |
| 127895 | | -SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); } |
| 128478 | +SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); } |
| 128479 | +SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); } |
| 127896 | 128480 | |
| 127897 | 128481 | |
| 127898 | 128482 | /* |
| 127899 | 128483 | ** Close the mutex on database connection db. |
| 127900 | 128484 | ** |
| | @@ -128297,11 +128881,11 @@ |
| 128297 | 128881 | |
| 128298 | 128882 | /* |
| 128299 | 128883 | ** This routine sets the busy callback for an Sqlite database to the |
| 128300 | 128884 | ** given callback function with the given argument. |
| 128301 | 128885 | */ |
| 128302 | | -SQLITE_API int sqlite3_busy_handler( |
| 128886 | +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler( |
| 128303 | 128887 | sqlite3 *db, |
| 128304 | 128888 | int (*xBusy)(void*,int), |
| 128305 | 128889 | void *pArg |
| 128306 | 128890 | ){ |
| 128307 | 128891 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -128320,11 +128904,11 @@ |
| 128320 | 128904 | /* |
| 128321 | 128905 | ** This routine sets the progress callback for an Sqlite database to the |
| 128322 | 128906 | ** given callback function with the given argument. The progress callback will |
| 128323 | 128907 | ** be invoked every nOps opcodes. |
| 128324 | 128908 | */ |
| 128325 | | -SQLITE_API void sqlite3_progress_handler( |
| 128909 | +SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler( |
| 128326 | 128910 | sqlite3 *db, |
| 128327 | 128911 | int nOps, |
| 128328 | 128912 | int (*xProgress)(void*), |
| 128329 | 128913 | void *pArg |
| 128330 | 128914 | ){ |
| | @@ -128351,11 +128935,11 @@ |
| 128351 | 128935 | |
| 128352 | 128936 | /* |
| 128353 | 128937 | ** This routine installs a default busy handler that waits for the |
| 128354 | 128938 | ** specified number of milliseconds before returning 0. |
| 128355 | 128939 | */ |
| 128356 | | -SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){ |
| 128940 | +SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){ |
| 128357 | 128941 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 128358 | 128942 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 128359 | 128943 | #endif |
| 128360 | 128944 | if( ms>0 ){ |
| 128361 | 128945 | sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db); |
| | @@ -128367,11 +128951,11 @@ |
| 128367 | 128951 | } |
| 128368 | 128952 | |
| 128369 | 128953 | /* |
| 128370 | 128954 | ** Cause any pending operation to stop at its earliest opportunity. |
| 128371 | 128955 | */ |
| 128372 | | -SQLITE_API void sqlite3_interrupt(sqlite3 *db){ |
| 128956 | +SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){ |
| 128373 | 128957 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 128374 | 128958 | if( !sqlite3SafetyCheckOk(db) ){ |
| 128375 | 128959 | (void)SQLITE_MISUSE_BKPT; |
| 128376 | 128960 | return; |
| 128377 | 128961 | } |
| | @@ -128484,11 +129068,11 @@ |
| 128484 | 129068 | } |
| 128485 | 129069 | |
| 128486 | 129070 | /* |
| 128487 | 129071 | ** Create new user functions. |
| 128488 | 129072 | */ |
| 128489 | | -SQLITE_API int sqlite3_create_function( |
| 129073 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function( |
| 128490 | 129074 | sqlite3 *db, |
| 128491 | 129075 | const char *zFunc, |
| 128492 | 129076 | int nArg, |
| 128493 | 129077 | int enc, |
| 128494 | 129078 | void *p, |
| | @@ -128498,11 +129082,11 @@ |
| 128498 | 129082 | ){ |
| 128499 | 129083 | return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep, |
| 128500 | 129084 | xFinal, 0); |
| 128501 | 129085 | } |
| 128502 | 129086 | |
| 128503 | | -SQLITE_API int sqlite3_create_function_v2( |
| 129087 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2( |
| 128504 | 129088 | sqlite3 *db, |
| 128505 | 129089 | const char *zFunc, |
| 128506 | 129090 | int nArg, |
| 128507 | 129091 | int enc, |
| 128508 | 129092 | void *p, |
| | @@ -128541,11 +129125,11 @@ |
| 128541 | 129125 | sqlite3_mutex_leave(db->mutex); |
| 128542 | 129126 | return rc; |
| 128543 | 129127 | } |
| 128544 | 129128 | |
| 128545 | 129129 | #ifndef SQLITE_OMIT_UTF16 |
| 128546 | | -SQLITE_API int sqlite3_create_function16( |
| 129130 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_function16( |
| 128547 | 129131 | sqlite3 *db, |
| 128548 | 129132 | const void *zFunctionName, |
| 128549 | 129133 | int nArg, |
| 128550 | 129134 | int eTextRep, |
| 128551 | 129135 | void *p, |
| | @@ -128581,11 +129165,11 @@ |
| 128581 | 129165 | ** When virtual tables intend to provide an overloaded function, they |
| 128582 | 129166 | ** should call this routine to make sure the global function exists. |
| 128583 | 129167 | ** A global function must exist in order for name resolution to work |
| 128584 | 129168 | ** properly. |
| 128585 | 129169 | */ |
| 128586 | | -SQLITE_API int sqlite3_overload_function( |
| 129170 | +SQLITE_API int SQLITE_STDCALL sqlite3_overload_function( |
| 128587 | 129171 | sqlite3 *db, |
| 128588 | 129172 | const char *zName, |
| 128589 | 129173 | int nArg |
| 128590 | 129174 | ){ |
| 128591 | 129175 | int nName = sqlite3Strlen30(zName); |
| | @@ -128613,11 +129197,11 @@ |
| 128613 | 129197 | ** |
| 128614 | 129198 | ** A NULL trace function means that no tracing is executes. A non-NULL |
| 128615 | 129199 | ** trace is a pointer to a function that is invoked at the start of each |
| 128616 | 129200 | ** SQL statement. |
| 128617 | 129201 | */ |
| 128618 | | -SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ |
| 129202 | +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ |
| 128619 | 129203 | void *pOld; |
| 128620 | 129204 | |
| 128621 | 129205 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 128622 | 129206 | if( !sqlite3SafetyCheckOk(db) ){ |
| 128623 | 129207 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -128637,11 +129221,11 @@ |
| 128637 | 129221 | ** |
| 128638 | 129222 | ** A NULL profile function means that no profiling is executes. A non-NULL |
| 128639 | 129223 | ** profile is a pointer to a function that is invoked at the conclusion of |
| 128640 | 129224 | ** each SQL statement that is run. |
| 128641 | 129225 | */ |
| 128642 | | -SQLITE_API void *sqlite3_profile( |
| 129226 | +SQLITE_API void *SQLITE_STDCALL sqlite3_profile( |
| 128643 | 129227 | sqlite3 *db, |
| 128644 | 129228 | void (*xProfile)(void*,const char*,sqlite_uint64), |
| 128645 | 129229 | void *pArg |
| 128646 | 129230 | ){ |
| 128647 | 129231 | void *pOld; |
| | @@ -128664,11 +129248,11 @@ |
| 128664 | 129248 | /* |
| 128665 | 129249 | ** Register a function to be invoked when a transaction commits. |
| 128666 | 129250 | ** If the invoked function returns non-zero, then the commit becomes a |
| 128667 | 129251 | ** rollback. |
| 128668 | 129252 | */ |
| 128669 | | -SQLITE_API void *sqlite3_commit_hook( |
| 129253 | +SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook( |
| 128670 | 129254 | sqlite3 *db, /* Attach the hook to this database */ |
| 128671 | 129255 | int (*xCallback)(void*), /* Function to invoke on each commit */ |
| 128672 | 129256 | void *pArg /* Argument to the function */ |
| 128673 | 129257 | ){ |
| 128674 | 129258 | void *pOld; |
| | @@ -128689,11 +129273,11 @@ |
| 128689 | 129273 | |
| 128690 | 129274 | /* |
| 128691 | 129275 | ** Register a callback to be invoked each time a row is updated, |
| 128692 | 129276 | ** inserted or deleted using this database connection. |
| 128693 | 129277 | */ |
| 128694 | | -SQLITE_API void *sqlite3_update_hook( |
| 129278 | +SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook( |
| 128695 | 129279 | sqlite3 *db, /* Attach the hook to this database */ |
| 128696 | 129280 | void (*xCallback)(void*,int,char const *,char const *,sqlite_int64), |
| 128697 | 129281 | void *pArg /* Argument to the function */ |
| 128698 | 129282 | ){ |
| 128699 | 129283 | void *pRet; |
| | @@ -128714,11 +129298,11 @@ |
| 128714 | 129298 | |
| 128715 | 129299 | /* |
| 128716 | 129300 | ** Register a callback to be invoked each time a transaction is rolled |
| 128717 | 129301 | ** back by this database connection. |
| 128718 | 129302 | */ |
| 128719 | | -SQLITE_API void *sqlite3_rollback_hook( |
| 129303 | +SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook( |
| 128720 | 129304 | sqlite3 *db, /* Attach the hook to this database */ |
| 128721 | 129305 | void (*xCallback)(void*), /* Callback function */ |
| 128722 | 129306 | void *pArg /* Argument to the function */ |
| 128723 | 129307 | ){ |
| 128724 | 129308 | void *pRet; |
| | @@ -128768,11 +129352,11 @@ |
| 128768 | 129352 | ** The callback registered by this function replaces any existing callback |
| 128769 | 129353 | ** registered using sqlite3_wal_hook(). Likewise, registering a callback |
| 128770 | 129354 | ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism |
| 128771 | 129355 | ** configured by this function. |
| 128772 | 129356 | */ |
| 128773 | | -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){ |
| 129357 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){ |
| 128774 | 129358 | #ifdef SQLITE_OMIT_WAL |
| 128775 | 129359 | UNUSED_PARAMETER(db); |
| 128776 | 129360 | UNUSED_PARAMETER(nFrame); |
| 128777 | 129361 | #else |
| 128778 | 129362 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -128789,11 +129373,11 @@ |
| 128789 | 129373 | |
| 128790 | 129374 | /* |
| 128791 | 129375 | ** Register a callback to be invoked each time a transaction is written |
| 128792 | 129376 | ** into the write-ahead-log by this database connection. |
| 128793 | 129377 | */ |
| 128794 | | -SQLITE_API void *sqlite3_wal_hook( |
| 129378 | +SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook( |
| 128795 | 129379 | sqlite3 *db, /* Attach the hook to this db handle */ |
| 128796 | 129380 | int(*xCallback)(void *, sqlite3*, const char*, int), |
| 128797 | 129381 | void *pArg /* First argument passed to xCallback() */ |
| 128798 | 129382 | ){ |
| 128799 | 129383 | #ifndef SQLITE_OMIT_WAL |
| | @@ -128816,11 +129400,11 @@ |
| 128816 | 129400 | } |
| 128817 | 129401 | |
| 128818 | 129402 | /* |
| 128819 | 129403 | ** Checkpoint database zDb. |
| 128820 | 129404 | */ |
| 128821 | | -SQLITE_API int sqlite3_wal_checkpoint_v2( |
| 129405 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2( |
| 128822 | 129406 | sqlite3 *db, /* Database handle */ |
| 128823 | 129407 | const char *zDb, /* Name of attached database (or NULL) */ |
| 128824 | 129408 | int eMode, /* SQLITE_CHECKPOINT_* value */ |
| 128825 | 129409 | int *pnLog, /* OUT: Size of WAL log in frames */ |
| 128826 | 129410 | int *pnCkpt /* OUT: Total number of frames checkpointed */ |
| | @@ -128871,11 +129455,11 @@ |
| 128871 | 129455 | /* |
| 128872 | 129456 | ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points |
| 128873 | 129457 | ** to contains a zero-length string, all attached databases are |
| 128874 | 129458 | ** checkpointed. |
| 128875 | 129459 | */ |
| 128876 | | -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ |
| 129460 | +SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ |
| 128877 | 129461 | /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to |
| 128878 | 129462 | ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */ |
| 128879 | 129463 | return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0); |
| 128880 | 129464 | } |
| 128881 | 129465 | |
| | @@ -128960,11 +129544,11 @@ |
| 128960 | 129544 | |
| 128961 | 129545 | /* |
| 128962 | 129546 | ** Return UTF-8 encoded English language explanation of the most recent |
| 128963 | 129547 | ** error. |
| 128964 | 129548 | */ |
| 128965 | | -SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){ |
| 129549 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){ |
| 128966 | 129550 | const char *z; |
| 128967 | 129551 | if( !db ){ |
| 128968 | 129552 | return sqlite3ErrStr(SQLITE_NOMEM); |
| 128969 | 129553 | } |
| 128970 | 129554 | if( !sqlite3SafetyCheckSickOrOk(db) ){ |
| | @@ -128988,11 +129572,11 @@ |
| 128988 | 129572 | #ifndef SQLITE_OMIT_UTF16 |
| 128989 | 129573 | /* |
| 128990 | 129574 | ** Return UTF-16 encoded English language explanation of the most recent |
| 128991 | 129575 | ** error. |
| 128992 | 129576 | */ |
| 128993 | | -SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){ |
| 129577 | +SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){ |
| 128994 | 129578 | static const u16 outOfMem[] = { |
| 128995 | 129579 | 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0 |
| 128996 | 129580 | }; |
| 128997 | 129581 | static const u16 misuse[] = { |
| 128998 | 129582 | 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ', |
| | @@ -129033,20 +129617,20 @@ |
| 129033 | 129617 | |
| 129034 | 129618 | /* |
| 129035 | 129619 | ** Return the most recent error code generated by an SQLite routine. If NULL is |
| 129036 | 129620 | ** passed to this function, we assume a malloc() failed during sqlite3_open(). |
| 129037 | 129621 | */ |
| 129038 | | -SQLITE_API int sqlite3_errcode(sqlite3 *db){ |
| 129622 | +SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){ |
| 129039 | 129623 | if( db && !sqlite3SafetyCheckSickOrOk(db) ){ |
| 129040 | 129624 | return SQLITE_MISUSE_BKPT; |
| 129041 | 129625 | } |
| 129042 | 129626 | if( !db || db->mallocFailed ){ |
| 129043 | 129627 | return SQLITE_NOMEM; |
| 129044 | 129628 | } |
| 129045 | 129629 | return db->errCode & db->errMask; |
| 129046 | 129630 | } |
| 129047 | | -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){ |
| 129631 | +SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){ |
| 129048 | 129632 | if( db && !sqlite3SafetyCheckSickOrOk(db) ){ |
| 129049 | 129633 | return SQLITE_MISUSE_BKPT; |
| 129050 | 129634 | } |
| 129051 | 129635 | if( !db || db->mallocFailed ){ |
| 129052 | 129636 | return SQLITE_NOMEM; |
| | @@ -129057,11 +129641,11 @@ |
| 129057 | 129641 | /* |
| 129058 | 129642 | ** Return a string that describes the kind of error specified in the |
| 129059 | 129643 | ** argument. For now, this simply calls the internal sqlite3ErrStr() |
| 129060 | 129644 | ** function. |
| 129061 | 129645 | */ |
| 129062 | | -SQLITE_API const char *sqlite3_errstr(int rc){ |
| 129646 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){ |
| 129063 | 129647 | return sqlite3ErrStr(rc); |
| 129064 | 129648 | } |
| 129065 | 129649 | |
| 129066 | 129650 | /* |
| 129067 | 129651 | ** Create a new collating function for database "db". The name is zName |
| | @@ -129205,11 +129789,11 @@ |
| 129205 | 129789 | ** |
| 129206 | 129790 | ** A new lower limit does not shrink existing constructs. |
| 129207 | 129791 | ** It merely prevents new constructs that exceed the limit |
| 129208 | 129792 | ** from forming. |
| 129209 | 129793 | */ |
| 129210 | | -SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ |
| 129794 | +SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ |
| 129211 | 129795 | int oldLimit; |
| 129212 | 129796 | |
| 129213 | 129797 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 129214 | 129798 | if( !sqlite3SafetyCheckOk(db) ){ |
| 129215 | 129799 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -129790,18 +130374,18 @@ |
| 129790 | 130374 | } |
| 129791 | 130375 | |
| 129792 | 130376 | /* |
| 129793 | 130377 | ** Open a new database handle. |
| 129794 | 130378 | */ |
| 129795 | | -SQLITE_API int sqlite3_open( |
| 130379 | +SQLITE_API int SQLITE_STDCALL sqlite3_open( |
| 129796 | 130380 | const char *zFilename, |
| 129797 | 130381 | sqlite3 **ppDb |
| 129798 | 130382 | ){ |
| 129799 | 130383 | return openDatabase(zFilename, ppDb, |
| 129800 | 130384 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0); |
| 129801 | 130385 | } |
| 129802 | | -SQLITE_API int sqlite3_open_v2( |
| 130386 | +SQLITE_API int SQLITE_STDCALL sqlite3_open_v2( |
| 129803 | 130387 | const char *filename, /* Database filename (UTF-8) */ |
| 129804 | 130388 | sqlite3 **ppDb, /* OUT: SQLite db handle */ |
| 129805 | 130389 | int flags, /* Flags */ |
| 129806 | 130390 | const char *zVfs /* Name of VFS module to use */ |
| 129807 | 130391 | ){ |
| | @@ -129810,11 +130394,11 @@ |
| 129810 | 130394 | |
| 129811 | 130395 | #ifndef SQLITE_OMIT_UTF16 |
| 129812 | 130396 | /* |
| 129813 | 130397 | ** Open a new database handle. |
| 129814 | 130398 | */ |
| 129815 | | -SQLITE_API int sqlite3_open16( |
| 130399 | +SQLITE_API int SQLITE_STDCALL sqlite3_open16( |
| 129816 | 130400 | const void *zFilename, |
| 129817 | 130401 | sqlite3 **ppDb |
| 129818 | 130402 | ){ |
| 129819 | 130403 | char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */ |
| 129820 | 130404 | sqlite3_value *pVal; |
| | @@ -129849,11 +130433,11 @@ |
| 129849 | 130433 | #endif /* SQLITE_OMIT_UTF16 */ |
| 129850 | 130434 | |
| 129851 | 130435 | /* |
| 129852 | 130436 | ** Register a new collation sequence with the database handle db. |
| 129853 | 130437 | */ |
| 129854 | | -SQLITE_API int sqlite3_create_collation( |
| 130438 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation( |
| 129855 | 130439 | sqlite3* db, |
| 129856 | 130440 | const char *zName, |
| 129857 | 130441 | int enc, |
| 129858 | 130442 | void* pCtx, |
| 129859 | 130443 | int(*xCompare)(void*,int,const void*,int,const void*) |
| | @@ -129862,11 +130446,11 @@ |
| 129862 | 130446 | } |
| 129863 | 130447 | |
| 129864 | 130448 | /* |
| 129865 | 130449 | ** Register a new collation sequence with the database handle db. |
| 129866 | 130450 | */ |
| 129867 | | -SQLITE_API int sqlite3_create_collation_v2( |
| 130451 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2( |
| 129868 | 130452 | sqlite3* db, |
| 129869 | 130453 | const char *zName, |
| 129870 | 130454 | int enc, |
| 129871 | 130455 | void* pCtx, |
| 129872 | 130456 | int(*xCompare)(void*,int,const void*,int,const void*), |
| | @@ -129887,11 +130471,11 @@ |
| 129887 | 130471 | |
| 129888 | 130472 | #ifndef SQLITE_OMIT_UTF16 |
| 129889 | 130473 | /* |
| 129890 | 130474 | ** Register a new collation sequence with the database handle db. |
| 129891 | 130475 | */ |
| 129892 | | -SQLITE_API int sqlite3_create_collation16( |
| 130476 | +SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16( |
| 129893 | 130477 | sqlite3* db, |
| 129894 | 130478 | const void *zName, |
| 129895 | 130479 | int enc, |
| 129896 | 130480 | void* pCtx, |
| 129897 | 130481 | int(*xCompare)(void*,int,const void*,int,const void*) |
| | @@ -129917,11 +130501,11 @@ |
| 129917 | 130501 | |
| 129918 | 130502 | /* |
| 129919 | 130503 | ** Register a collation sequence factory callback with the database handle |
| 129920 | 130504 | ** db. Replace any previously installed collation sequence factory. |
| 129921 | 130505 | */ |
| 129922 | | -SQLITE_API int sqlite3_collation_needed( |
| 130506 | +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed( |
| 129923 | 130507 | sqlite3 *db, |
| 129924 | 130508 | void *pCollNeededArg, |
| 129925 | 130509 | void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*) |
| 129926 | 130510 | ){ |
| 129927 | 130511 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -129938,11 +130522,11 @@ |
| 129938 | 130522 | #ifndef SQLITE_OMIT_UTF16 |
| 129939 | 130523 | /* |
| 129940 | 130524 | ** Register a collation sequence factory callback with the database handle |
| 129941 | 130525 | ** db. Replace any previously installed collation sequence factory. |
| 129942 | 130526 | */ |
| 129943 | | -SQLITE_API int sqlite3_collation_needed16( |
| 130527 | +SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16( |
| 129944 | 130528 | sqlite3 *db, |
| 129945 | 130529 | void *pCollNeededArg, |
| 129946 | 130530 | void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*) |
| 129947 | 130531 | ){ |
| 129948 | 130532 | #ifdef SQLITE_ENABLE_API_ARMOR |
| | @@ -129960,11 +130544,11 @@ |
| 129960 | 130544 | #ifndef SQLITE_OMIT_DEPRECATED |
| 129961 | 130545 | /* |
| 129962 | 130546 | ** This function is now an anachronism. It used to be used to recover from a |
| 129963 | 130547 | ** malloc() failure, but SQLite now does this automatically. |
| 129964 | 130548 | */ |
| 129965 | | -SQLITE_API int sqlite3_global_recover(void){ |
| 130549 | +SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){ |
| 129966 | 130550 | return SQLITE_OK; |
| 129967 | 130551 | } |
| 129968 | 130552 | #endif |
| 129969 | 130553 | |
| 129970 | 130554 | /* |
| | @@ -129971,11 +130555,11 @@ |
| 129971 | 130555 | ** Test to see whether or not the database connection is in autocommit |
| 129972 | 130556 | ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on |
| 129973 | 130557 | ** by default. Autocommit is disabled by a BEGIN statement and reenabled |
| 129974 | 130558 | ** by the next COMMIT or ROLLBACK. |
| 129975 | 130559 | */ |
| 129976 | | -SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){ |
| 130560 | +SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){ |
| 129977 | 130561 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 129978 | 130562 | if( !sqlite3SafetyCheckOk(db) ){ |
| 129979 | 130563 | (void)SQLITE_MISUSE_BKPT; |
| 129980 | 130564 | return 0; |
| 129981 | 130565 | } |
| | @@ -130023,19 +130607,19 @@ |
| 130023 | 130607 | ** data for this thread has been deallocated. |
| 130024 | 130608 | ** |
| 130025 | 130609 | ** SQLite no longer uses thread-specific data so this routine is now a |
| 130026 | 130610 | ** no-op. It is retained for historical compatibility. |
| 130027 | 130611 | */ |
| 130028 | | -SQLITE_API void sqlite3_thread_cleanup(void){ |
| 130612 | +SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){ |
| 130029 | 130613 | } |
| 130030 | 130614 | #endif |
| 130031 | 130615 | |
| 130032 | 130616 | /* |
| 130033 | 130617 | ** Return meta information about a specific column of a database table. |
| 130034 | 130618 | ** See comment in sqlite3.h (sqlite.h.in) for details. |
| 130035 | 130619 | */ |
| 130036 | | -SQLITE_API int sqlite3_table_column_metadata( |
| 130620 | +SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata( |
| 130037 | 130621 | sqlite3 *db, /* Connection handle */ |
| 130038 | 130622 | const char *zDbName, /* Database name or NULL */ |
| 130039 | 130623 | const char *zTableName, /* Table name */ |
| 130040 | 130624 | const char *zColumnName, /* Column name */ |
| 130041 | 130625 | char const **pzDataType, /* OUTPUT: Declared data type */ |
| | @@ -130149,11 +130733,11 @@ |
| 130149 | 130733 | } |
| 130150 | 130734 | |
| 130151 | 130735 | /* |
| 130152 | 130736 | ** Sleep for a little while. Return the amount of time slept. |
| 130153 | 130737 | */ |
| 130154 | | -SQLITE_API int sqlite3_sleep(int ms){ |
| 130738 | +SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){ |
| 130155 | 130739 | sqlite3_vfs *pVfs; |
| 130156 | 130740 | int rc; |
| 130157 | 130741 | pVfs = sqlite3_vfs_find(0); |
| 130158 | 130742 | if( pVfs==0 ) return 0; |
| 130159 | 130743 | |
| | @@ -130165,11 +130749,11 @@ |
| 130165 | 130749 | } |
| 130166 | 130750 | |
| 130167 | 130751 | /* |
| 130168 | 130752 | ** Enable or disable the extended result codes. |
| 130169 | 130753 | */ |
| 130170 | | -SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){ |
| 130754 | +SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){ |
| 130171 | 130755 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 130172 | 130756 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| 130173 | 130757 | #endif |
| 130174 | 130758 | sqlite3_mutex_enter(db->mutex); |
| 130175 | 130759 | db->errMask = onoff ? 0xffffffff : 0xff; |
| | @@ -130178,11 +130762,11 @@ |
| 130178 | 130762 | } |
| 130179 | 130763 | |
| 130180 | 130764 | /* |
| 130181 | 130765 | ** Invoke the xFileControl method on a particular database. |
| 130182 | 130766 | */ |
| 130183 | | -SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ |
| 130767 | +SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){ |
| 130184 | 130768 | int rc = SQLITE_ERROR; |
| 130185 | 130769 | Btree *pBtree; |
| 130186 | 130770 | |
| 130187 | 130771 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 130188 | 130772 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| | @@ -130212,11 +130796,11 @@ |
| 130212 | 130796 | } |
| 130213 | 130797 | |
| 130214 | 130798 | /* |
| 130215 | 130799 | ** Interface to the testing logic. |
| 130216 | 130800 | */ |
| 130217 | | -SQLITE_API int sqlite3_test_control(int op, ...){ |
| 130801 | +SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){ |
| 130218 | 130802 | int rc = 0; |
| 130219 | 130803 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 130220 | 130804 | va_list ap; |
| 130221 | 130805 | va_start(ap, op); |
| 130222 | 130806 | switch( op ){ |
| | @@ -130555,11 +131139,11 @@ |
| 130555 | 131139 | ** method of a VFS implementation. The zParam argument is the name of the |
| 130556 | 131140 | ** query parameter we seek. This routine returns the value of the zParam |
| 130557 | 131141 | ** parameter if it exists. If the parameter does not exist, this routine |
| 130558 | 131142 | ** returns a NULL pointer. |
| 130559 | 131143 | */ |
| 130560 | | -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){ |
| 131144 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){ |
| 130561 | 131145 | if( zFilename==0 || zParam==0 ) return 0; |
| 130562 | 131146 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 130563 | 131147 | while( zFilename[0] ){ |
| 130564 | 131148 | int x = strcmp(zFilename, zParam); |
| 130565 | 131149 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| | @@ -130570,20 +131154,20 @@ |
| 130570 | 131154 | } |
| 130571 | 131155 | |
| 130572 | 131156 | /* |
| 130573 | 131157 | ** Return a boolean value for a query parameter. |
| 130574 | 131158 | */ |
| 130575 | | -SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){ |
| 131159 | +SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){ |
| 130576 | 131160 | const char *z = sqlite3_uri_parameter(zFilename, zParam); |
| 130577 | 131161 | bDflt = bDflt!=0; |
| 130578 | 131162 | return z ? sqlite3GetBoolean(z, bDflt) : bDflt; |
| 130579 | 131163 | } |
| 130580 | 131164 | |
| 130581 | 131165 | /* |
| 130582 | 131166 | ** Return a 64-bit integer value for a query parameter. |
| 130583 | 131167 | */ |
| 130584 | | -SQLITE_API sqlite3_int64 sqlite3_uri_int64( |
| 131168 | +SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64( |
| 130585 | 131169 | const char *zFilename, /* Filename as passed to xOpen */ |
| 130586 | 131170 | const char *zParam, /* URI parameter sought */ |
| 130587 | 131171 | sqlite3_int64 bDflt /* return if parameter is missing */ |
| 130588 | 131172 | ){ |
| 130589 | 131173 | const char *z = sqlite3_uri_parameter(zFilename, zParam); |
| | @@ -130611,11 +131195,11 @@ |
| 130611 | 131195 | |
| 130612 | 131196 | /* |
| 130613 | 131197 | ** Return the filename of the database associated with a database |
| 130614 | 131198 | ** connection. |
| 130615 | 131199 | */ |
| 130616 | | -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ |
| 131200 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){ |
| 130617 | 131201 | Btree *pBt; |
| 130618 | 131202 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 130619 | 131203 | if( !sqlite3SafetyCheckOk(db) ){ |
| 130620 | 131204 | (void)SQLITE_MISUSE_BKPT; |
| 130621 | 131205 | return 0; |
| | @@ -130627,11 +131211,11 @@ |
| 130627 | 131211 | |
| 130628 | 131212 | /* |
| 130629 | 131213 | ** Return 1 if database is read-only or 0 if read/write. Return -1 if |
| 130630 | 131214 | ** no such database exists. |
| 130631 | 131215 | */ |
| 130632 | | -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ |
| 131216 | +SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ |
| 130633 | 131217 | Btree *pBt; |
| 130634 | 131218 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 130635 | 131219 | if( !sqlite3SafetyCheckOk(db) ){ |
| 130636 | 131220 | (void)SQLITE_MISUSE_BKPT; |
| 130637 | 131221 | return -1; |
| | @@ -130786,11 +131370,11 @@ |
| 130786 | 131370 | ** |
| 130787 | 131371 | ** Each call to this routine overrides any prior callbacks registered |
| 130788 | 131372 | ** on the same "db". If xNotify==0 then any prior callbacks are immediately |
| 130789 | 131373 | ** cancelled. |
| 130790 | 131374 | */ |
| 130791 | | -SQLITE_API int sqlite3_unlock_notify( |
| 131375 | +SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify( |
| 130792 | 131376 | sqlite3 *db, |
| 130793 | 131377 | void (*xNotify)(void **, int), |
| 130794 | 131378 | void *pArg |
| 130795 | 131379 | ){ |
| 130796 | 131380 | int rc = SQLITE_OK; |
| | @@ -132766,15 +133350,20 @@ |
| 132766 | 133350 | ** the output value undefined. Otherwise SQLITE_OK is returned. |
| 132767 | 133351 | ** |
| 132768 | 133352 | ** This function is used when parsing the "prefix=" FTS4 parameter. |
| 132769 | 133353 | */ |
| 132770 | 133354 | static int fts3GobbleInt(const char **pp, int *pnOut){ |
| 133355 | + const int MAX_NPREFIX = 10000000; |
| 132771 | 133356 | const char *p; /* Iterator pointer */ |
| 132772 | 133357 | int nInt = 0; /* Output value */ |
| 132773 | 133358 | |
| 132774 | 133359 | for(p=*pp; p[0]>='0' && p[0]<='9'; p++){ |
| 132775 | 133360 | nInt = nInt * 10 + (p[0] - '0'); |
| 133361 | + if( nInt>MAX_NPREFIX ){ |
| 133362 | + nInt = 0; |
| 133363 | + break; |
| 133364 | + } |
| 132776 | 133365 | } |
| 132777 | 133366 | if( p==*pp ) return SQLITE_ERROR; |
| 132778 | 133367 | *pnOut = nInt; |
| 132779 | 133368 | *pp = p; |
| 132780 | 133369 | return SQLITE_OK; |
| | @@ -132813,27 +133402,33 @@ |
| 132813 | 133402 | } |
| 132814 | 133403 | } |
| 132815 | 133404 | |
| 132816 | 133405 | aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex); |
| 132817 | 133406 | *apIndex = aIndex; |
| 132818 | | - *pnIndex = nIndex; |
| 132819 | 133407 | if( !aIndex ){ |
| 132820 | 133408 | return SQLITE_NOMEM; |
| 132821 | 133409 | } |
| 132822 | 133410 | |
| 132823 | 133411 | memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex); |
| 132824 | 133412 | if( zParam ){ |
| 132825 | 133413 | const char *p = zParam; |
| 132826 | 133414 | int i; |
| 132827 | 133415 | for(i=1; i<nIndex; i++){ |
| 132828 | | - int nPrefix; |
| 133416 | + int nPrefix = 0; |
| 132829 | 133417 | if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR; |
| 132830 | | - aIndex[i].nPrefix = nPrefix; |
| 133418 | + assert( nPrefix>=0 ); |
| 133419 | + if( nPrefix==0 ){ |
| 133420 | + nIndex--; |
| 133421 | + i--; |
| 133422 | + }else{ |
| 133423 | + aIndex[i].nPrefix = nPrefix; |
| 133424 | + } |
| 132831 | 133425 | p++; |
| 132832 | 133426 | } |
| 132833 | 133427 | } |
| 132834 | 133428 | |
| 133429 | + *pnIndex = nIndex; |
| 132835 | 133430 | return SQLITE_OK; |
| 132836 | 133431 | } |
| 132837 | 133432 | |
| 132838 | 133433 | /* |
| 132839 | 133434 | ** This function is called when initializing an FTS4 table that uses the |
| | @@ -132953,11 +133548,11 @@ |
| 132953 | 133548 | int nName; /* Bytes required to hold table name */ |
| 132954 | 133549 | int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */ |
| 132955 | 133550 | const char **aCol; /* Array of column names */ |
| 132956 | 133551 | sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */ |
| 132957 | 133552 | |
| 132958 | | - int nIndex; /* Size of aIndex[] array */ |
| 133553 | + int nIndex = 0; /* Size of aIndex[] array */ |
| 132959 | 133554 | struct Fts3Index *aIndex = 0; /* Array of indexes for this table */ |
| 132960 | 133555 | |
| 132961 | 133556 | /* The results of parsing supported FTS4 key=value options: */ |
| 132962 | 133557 | int bNoDocsize = 0; /* True to omit %_docsize table */ |
| 132963 | 133558 | int bDescIdx = 0; /* True to store descending indexes */ |
| | @@ -137641,11 +138236,11 @@ |
| 137641 | 138236 | ** Initialize API pointer table, if required. |
| 137642 | 138237 | */ |
| 137643 | 138238 | #ifdef _WIN32 |
| 137644 | 138239 | __declspec(dllexport) |
| 137645 | 138240 | #endif |
| 137646 | | -SQLITE_API int sqlite3_fts3_init( |
| 138241 | +SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init( |
| 137647 | 138242 | sqlite3 *db, |
| 137648 | 138243 | char **pzErrMsg, |
| 137649 | 138244 | const sqlite3_api_routines *pApi |
| 137650 | 138245 | ){ |
| 137651 | 138246 | SQLITE_EXTENSION_INIT2(pApi) |
| | @@ -140609,11 +141204,11 @@ |
| 140609 | 141204 | nName = sqlite3_value_bytes(argv[0])+1; |
| 140610 | 141205 | |
| 140611 | 141206 | if( argc==2 ){ |
| 140612 | 141207 | void *pOld; |
| 140613 | 141208 | int n = sqlite3_value_bytes(argv[1]); |
| 140614 | | - if( n!=sizeof(pPtr) ){ |
| 141209 | + if( zName==0 || n!=sizeof(pPtr) ){ |
| 140615 | 141210 | sqlite3_result_error(context, "argument type mismatch", -1); |
| 140616 | 141211 | return; |
| 140617 | 141212 | } |
| 140618 | 141213 | pPtr = *(void **)sqlite3_value_blob(argv[1]); |
| 140619 | 141214 | pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr); |
| | @@ -140620,11 +141215,13 @@ |
| 140620 | 141215 | if( pOld==pPtr ){ |
| 140621 | 141216 | sqlite3_result_error(context, "out of memory", -1); |
| 140622 | 141217 | return; |
| 140623 | 141218 | } |
| 140624 | 141219 | }else{ |
| 140625 | | - pPtr = sqlite3Fts3HashFind(pHash, zName, nName); |
| 141220 | + if( zName ){ |
| 141221 | + pPtr = sqlite3Fts3HashFind(pHash, zName, nName); |
| 141222 | + } |
| 140626 | 141223 | if( !pPtr ){ |
| 140627 | 141224 | char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName); |
| 140628 | 141225 | sqlite3_result_error(context, zErr, -1); |
| 140629 | 141226 | sqlite3_free(zErr); |
| 140630 | 141227 | return; |
| | @@ -140701,10 +141298,14 @@ |
| 140701 | 141298 | zCopy = sqlite3_mprintf("%s", zArg); |
| 140702 | 141299 | if( !zCopy ) return SQLITE_NOMEM; |
| 140703 | 141300 | zEnd = &zCopy[strlen(zCopy)]; |
| 140704 | 141301 | |
| 140705 | 141302 | z = (char *)sqlite3Fts3NextToken(zCopy, &n); |
| 141303 | + if( z==0 ){ |
| 141304 | + assert( n==0 ); |
| 141305 | + z = zCopy; |
| 141306 | + } |
| 140706 | 141307 | z[n] = '\0'; |
| 140707 | 141308 | sqlite3Fts3Dequote(z); |
| 140708 | 141309 | |
| 140709 | 141310 | m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1); |
| 140710 | 141311 | if( !m ){ |
| | @@ -143346,11 +143947,14 @@ |
| 143346 | 143947 | /* |
| 143347 | 143948 | ** This is a comparison function used as a qsort() callback when sorting |
| 143348 | 143949 | ** an array of pending terms by term. This occurs as part of flushing |
| 143349 | 143950 | ** the contents of the pending-terms hash table to the database. |
| 143350 | 143951 | */ |
| 143351 | | -static int fts3CompareElemByTerm(const void *lhs, const void *rhs){ |
| 143952 | +static int SQLITE_CDECL fts3CompareElemByTerm( |
| 143953 | + const void *lhs, |
| 143954 | + const void *rhs |
| 143955 | +){ |
| 143352 | 143956 | char *z1 = fts3HashKey(*(Fts3HashElem **)lhs); |
| 143353 | 143957 | char *z2 = fts3HashKey(*(Fts3HashElem **)rhs); |
| 143354 | 143958 | int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs); |
| 143355 | 143959 | int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs); |
| 143356 | 143960 | |
| | @@ -153079,11 +153683,11 @@ |
| 153079 | 153683 | } |
| 153080 | 153684 | |
| 153081 | 153685 | /* |
| 153082 | 153686 | ** Register a new geometry function for use with the r-tree MATCH operator. |
| 153083 | 153687 | */ |
| 153084 | | -SQLITE_API int sqlite3_rtree_geometry_callback( |
| 153688 | +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback( |
| 153085 | 153689 | sqlite3 *db, /* Register SQL function on this connection */ |
| 153086 | 153690 | const char *zGeom, /* Name of the new SQL function */ |
| 153087 | 153691 | int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */ |
| 153088 | 153692 | void *pContext /* Extra data associated with the callback */ |
| 153089 | 153693 | ){ |
| | @@ -153103,11 +153707,11 @@ |
| 153103 | 153707 | |
| 153104 | 153708 | /* |
| 153105 | 153709 | ** Register a new 2nd-generation geometry function for use with the |
| 153106 | 153710 | ** r-tree MATCH operator. |
| 153107 | 153711 | */ |
| 153108 | | -SQLITE_API int sqlite3_rtree_query_callback( |
| 153712 | +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback( |
| 153109 | 153713 | sqlite3 *db, /* Register SQL function on this connection */ |
| 153110 | 153714 | const char *zQueryFunc, /* Name of new SQL function */ |
| 153111 | 153715 | int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */ |
| 153112 | 153716 | void *pContext, /* Extra data passed into the callback */ |
| 153113 | 153717 | void (*xDestructor)(void*) /* Destructor for the extra data */ |
| | @@ -153128,11 +153732,11 @@ |
| 153128 | 153732 | |
| 153129 | 153733 | #if !SQLITE_CORE |
| 153130 | 153734 | #ifdef _WIN32 |
| 153131 | 153735 | __declspec(dllexport) |
| 153132 | 153736 | #endif |
| 153133 | | -SQLITE_API int sqlite3_rtree_init( |
| 153737 | +SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init( |
| 153134 | 153738 | sqlite3 *db, |
| 153135 | 153739 | char **pzErrMsg, |
| 153136 | 153740 | const sqlite3_api_routines *pApi |
| 153137 | 153741 | ){ |
| 153138 | 153742 | SQLITE_EXTENSION_INIT2(pApi) |
| | @@ -153633,11 +154237,11 @@ |
| 153633 | 154237 | |
| 153634 | 154238 | #if !SQLITE_CORE |
| 153635 | 154239 | #ifdef _WIN32 |
| 153636 | 154240 | __declspec(dllexport) |
| 153637 | 154241 | #endif |
| 153638 | | -SQLITE_API int sqlite3_icu_init( |
| 154242 | +SQLITE_API int SQLITE_STDCALL sqlite3_icu_init( |
| 153639 | 154243 | sqlite3 *db, |
| 153640 | 154244 | char **pzErrMsg, |
| 153641 | 154245 | const sqlite3_api_routines *pApi |
| 153642 | 154246 | ){ |
| 153643 | 154247 | SQLITE_EXTENSION_INIT2(pApi) |
| 153644 | 154248 | |