bump sqlite3 3.24.0 and add TestUpsert.
This commit is contained in:
parent
ecf0c3a828
commit
a06d1c9512
8147
sqlite3-binding.c
8147
sqlite3-binding.c
File diff suppressed because it is too large
Load Diff
|
@ -124,9 +124,9 @@ extern "C" {
|
||||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||||
** [sqlite_version()] and [sqlite_source_id()].
|
** [sqlite_version()] and [sqlite_source_id()].
|
||||||
*/
|
*/
|
||||||
#define SQLITE_VERSION "3.23.1"
|
#define SQLITE_VERSION "3.24.0"
|
||||||
#define SQLITE_VERSION_NUMBER 3023001
|
#define SQLITE_VERSION_NUMBER 3024000
|
||||||
#define SQLITE_SOURCE_ID "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"
|
#define SQLITE_SOURCE_ID "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Run-Time Library Version Numbers
|
** CAPI3REF: Run-Time Library Version Numbers
|
||||||
|
@ -505,6 +505,7 @@ SQLITE_API int sqlite3_exec(
|
||||||
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
|
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
|
||||||
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
|
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
|
||||||
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
|
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
|
||||||
|
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
|
||||||
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
|
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
|
||||||
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
|
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
|
||||||
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
|
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
|
||||||
|
@ -512,6 +513,7 @@ SQLITE_API int sqlite3_exec(
|
||||||
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
|
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
|
||||||
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
|
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
|
||||||
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
|
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
|
||||||
|
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
|
||||||
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
|
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
|
||||||
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
|
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
|
||||||
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
|
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
|
||||||
|
@ -1931,6 +1933,22 @@ struct sqlite3_mem_methods {
|
||||||
** I/O required to support statement rollback.
|
** I/O required to support statement rollback.
|
||||||
** The default value for this setting is controlled by the
|
** The default value for this setting is controlled by the
|
||||||
** [SQLITE_STMTJRNL_SPILL] compile-time option.
|
** [SQLITE_STMTJRNL_SPILL] compile-time option.
|
||||||
|
**
|
||||||
|
** [[SQLITE_CONFIG_SORTERREF_SIZE]]
|
||||||
|
** <dt>SQLITE_CONFIG_SORTERREF_SIZE
|
||||||
|
** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
|
||||||
|
** of type (int) - the new value of the sorter-reference size threshold.
|
||||||
|
** Usually, when SQLite uses an external sort to order records according
|
||||||
|
** to an ORDER BY clause, all fields required by the caller are present in the
|
||||||
|
** sorted records. However, if SQLite determines based on the declared type
|
||||||
|
** of a table column that its values are likely to be very large - larger
|
||||||
|
** than the configured sorter-reference size threshold - then a reference
|
||||||
|
** is stored in each sorted record and the required column values loaded
|
||||||
|
** from the database as records are returned in sorted order. The default
|
||||||
|
** value for this option is to never use this optimization. Specifying a
|
||||||
|
** negative value for this option restores the default behaviour.
|
||||||
|
** This option is only available if SQLite is compiled with the
|
||||||
|
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
|
||||||
** </dl>
|
** </dl>
|
||||||
*/
|
*/
|
||||||
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
|
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
|
||||||
|
@ -1960,6 +1978,7 @@ struct sqlite3_mem_methods {
|
||||||
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
|
#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
|
||||||
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
|
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
|
||||||
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
|
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
|
||||||
|
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Database Connection Configuration Options
|
** CAPI3REF: Database Connection Configuration Options
|
||||||
|
@ -2096,6 +2115,21 @@ struct sqlite3_mem_methods {
|
||||||
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
|
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
|
||||||
** it is not disabled, 1 if it is.
|
** it is not disabled, 1 if it is.
|
||||||
** </dd>
|
** </dd>
|
||||||
|
**
|
||||||
|
** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
|
||||||
|
** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
|
||||||
|
** [VACUUM] in order to reset a database back to an empty database
|
||||||
|
** with no schema and no content. The following process works even for
|
||||||
|
** a badly corrupted database file:
|
||||||
|
** <ol>
|
||||||
|
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
|
||||||
|
** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
|
||||||
|
** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
|
||||||
|
** </ol>
|
||||||
|
** Because resetting a database is destructive and irreversible, the
|
||||||
|
** process requires the use of this obscure API and multiple steps to help
|
||||||
|
** ensure that it does not happen by accident.
|
||||||
|
** </dd>
|
||||||
** </dl>
|
** </dl>
|
||||||
*/
|
*/
|
||||||
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
|
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
|
||||||
|
@ -2107,7 +2141,8 @@ struct sqlite3_mem_methods {
|
||||||
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
|
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
|
||||||
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
|
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
|
||||||
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
|
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
|
||||||
#define SQLITE_DBCONFIG_MAX 1008 /* Largest DBCONFIG */
|
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
|
||||||
|
#define SQLITE_DBCONFIG_MAX 1009 /* Largest DBCONFIG */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Enable Or Disable Extended Result Codes
|
** CAPI3REF: Enable Or Disable Extended Result Codes
|
||||||
|
@ -5493,6 +5528,41 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
|
||||||
*/
|
*/
|
||||||
SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
|
SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Win32 Specific Interface
|
||||||
|
**
|
||||||
|
** These interfaces are available only on Windows. The
|
||||||
|
** [sqlite3_win32_set_directory] interface is used to set the value associated
|
||||||
|
** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to
|
||||||
|
** zValue, depending on the value of the type parameter. The zValue parameter
|
||||||
|
** should be NULL to cause the previous value to be freed via [sqlite3_free];
|
||||||
|
** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]
|
||||||
|
** prior to being used. The [sqlite3_win32_set_directory] interface returns
|
||||||
|
** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,
|
||||||
|
** or [SQLITE_NOMEM] if memory could not be allocated. The value of the
|
||||||
|
** [sqlite3_data_directory] variable is intended to act as a replacement for
|
||||||
|
** the current directory on the sub-platforms of Win32 where that concept is
|
||||||
|
** not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and
|
||||||
|
** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the
|
||||||
|
** sqlite3_win32_set_directory interface except the string parameter must be
|
||||||
|
** UTF-8 or UTF-16, respectively.
|
||||||
|
*/
|
||||||
|
SQLITE_API int sqlite3_win32_set_directory(
|
||||||
|
unsigned long type, /* Identifier for directory being set or reset */
|
||||||
|
void *zValue /* New value for directory being set or reset */
|
||||||
|
);
|
||||||
|
SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);
|
||||||
|
SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Win32 Directory Types
|
||||||
|
**
|
||||||
|
** These macros are only available on Windows. They define the allowed values
|
||||||
|
** for the type argument to the [sqlite3_win32_set_directory] interface.
|
||||||
|
*/
|
||||||
|
#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1
|
||||||
|
#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Test For Auto-Commit Mode
|
** CAPI3REF: Test For Auto-Commit Mode
|
||||||
** KEYWORDS: {autocommit mode}
|
** KEYWORDS: {autocommit mode}
|
||||||
|
@ -6225,6 +6295,10 @@ struct sqlite3_index_info {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Virtual Table Scan Flags
|
** CAPI3REF: Virtual Table Scan Flags
|
||||||
|
**
|
||||||
|
** Virtual table implementations are allowed to set the
|
||||||
|
** [sqlite3_index_info].idxFlags field to some combination of
|
||||||
|
** these bits.
|
||||||
*/
|
*/
|
||||||
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
|
#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
|
||||||
|
|
||||||
|
@ -7000,7 +7074,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
|
||||||
#define SQLITE_TESTCTRL_ALWAYS 13
|
#define SQLITE_TESTCTRL_ALWAYS 13
|
||||||
#define SQLITE_TESTCTRL_RESERVE 14
|
#define SQLITE_TESTCTRL_RESERVE 14
|
||||||
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
|
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
|
||||||
#define SQLITE_TESTCTRL_ISKEYWORD 16
|
#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
|
||||||
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
|
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
|
||||||
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
|
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
|
||||||
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
|
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
|
||||||
|
@ -7014,6 +7088,189 @@ SQLITE_API int sqlite3_test_control(int op, ...);
|
||||||
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
|
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
|
||||||
#define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */
|
#define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: SQL Keyword Checking
|
||||||
|
**
|
||||||
|
** These routines provide access to the set of SQL language keywords
|
||||||
|
** recognized by SQLite. Applications can uses these routines to determine
|
||||||
|
** whether or not a specific identifier needs to be escaped (for example,
|
||||||
|
** by enclosing in double-quotes) so as not to confuse the parser.
|
||||||
|
**
|
||||||
|
** The sqlite3_keyword_count() interface returns the number of distinct
|
||||||
|
** keywords understood by SQLite.
|
||||||
|
**
|
||||||
|
** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and
|
||||||
|
** makes *Z point to that keyword expressed as UTF8 and writes the number
|
||||||
|
** of bytes in the keyword into *L. The string that *Z points to is not
|
||||||
|
** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns
|
||||||
|
** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z
|
||||||
|
** or L are NULL or invalid pointers then calls to
|
||||||
|
** sqlite3_keyword_name(N,Z,L) result in undefined behavior.
|
||||||
|
**
|
||||||
|
** The sqlite3_keyword_check(Z,L) interface checks to see whether or not
|
||||||
|
** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero
|
||||||
|
** if it is and zero if not.
|
||||||
|
**
|
||||||
|
** The parser used by SQLite is forgiving. It is often possible to use
|
||||||
|
** a keyword as an identifier as long as such use does not result in a
|
||||||
|
** parsing ambiguity. For example, the statement
|
||||||
|
** "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and
|
||||||
|
** creates a new table named "BEGIN" with three columns named
|
||||||
|
** "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid
|
||||||
|
** using keywords as identifiers. Common techniques used to avoid keyword
|
||||||
|
** name collisions include:
|
||||||
|
** <ul>
|
||||||
|
** <li> Put all identifier names inside double-quotes. This is the official
|
||||||
|
** SQL way to escape identifier names.
|
||||||
|
** <li> Put identifier names inside [...]. This is not standard SQL,
|
||||||
|
** but it is what SQL Server does and so lots of programmers use this
|
||||||
|
** technique.
|
||||||
|
** <li> Begin every identifier with the letter "Z" as no SQL keywords start
|
||||||
|
** with "Z".
|
||||||
|
** <li> Include a digit somewhere in every identifier name.
|
||||||
|
** </ul>
|
||||||
|
**
|
||||||
|
** Note that the number of keywords understood by SQLite can depend on
|
||||||
|
** compile-time options. For example, "VACUUM" is not a keyword if
|
||||||
|
** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also,
|
||||||
|
** new keywords may be added to future releases of SQLite.
|
||||||
|
*/
|
||||||
|
SQLITE_API int sqlite3_keyword_count(void);
|
||||||
|
SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
|
||||||
|
SQLITE_API int sqlite3_keyword_check(const char*,int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Dynamic String Object
|
||||||
|
** KEYWORDS: {dynamic string}
|
||||||
|
**
|
||||||
|
** An instance of the sqlite3_str object contains a dynamically-sized
|
||||||
|
** string under construction.
|
||||||
|
**
|
||||||
|
** The lifecycle of an sqlite3_str object is as follows:
|
||||||
|
** <ol>
|
||||||
|
** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
|
||||||
|
** <li> ^Text is appended to the sqlite3_str object using various
|
||||||
|
** methods, such as [sqlite3_str_appendf()].
|
||||||
|
** <li> ^The sqlite3_str object is destroyed and the string it created
|
||||||
|
** is returned using the [sqlite3_str_finish()] interface.
|
||||||
|
** </ol>
|
||||||
|
*/
|
||||||
|
typedef struct sqlite3_str sqlite3_str;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Create A New Dynamic String Object
|
||||||
|
** CONSTRUCTOR: sqlite3_str
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_new(D)] interface allocates and initializes
|
||||||
|
** a new [sqlite3_str] object. To avoid memory leaks, the object returned by
|
||||||
|
** [sqlite3_str_new()] must be freed by a subsequent call to
|
||||||
|
** [sqlite3_str_finish(X)].
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_new(D)] interface always returns a pointer to a
|
||||||
|
** valid [sqlite3_str] object, though in the event of an out-of-memory
|
||||||
|
** error the returned object might be a special singleton that will
|
||||||
|
** silently reject new text, always return SQLITE_NOMEM from
|
||||||
|
** [sqlite3_str_errcode()], always return 0 for
|
||||||
|
** [sqlite3_str_length()], and always return NULL from
|
||||||
|
** [sqlite3_str_finish(X)]. It is always safe to use the value
|
||||||
|
** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter
|
||||||
|
** to any of the other [sqlite3_str] methods.
|
||||||
|
**
|
||||||
|
** The D parameter to [sqlite3_str_new(D)] may be NULL. If the
|
||||||
|
** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum
|
||||||
|
** length of the string contained in the [sqlite3_str] object will be
|
||||||
|
** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead
|
||||||
|
** of [SQLITE_MAX_LENGTH].
|
||||||
|
*/
|
||||||
|
SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Finalize A Dynamic String
|
||||||
|
** DESTRUCTOR: sqlite3_str
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X
|
||||||
|
** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]
|
||||||
|
** that contains the constructed string. The calling application should
|
||||||
|
** pass the returned value to [sqlite3_free()] to avoid a memory leak.
|
||||||
|
** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
|
||||||
|
** errors were encountered during construction of the string. ^The
|
||||||
|
** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
|
||||||
|
** string in [sqlite3_str] object X is zero bytes long.
|
||||||
|
*/
|
||||||
|
SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Add Content To A Dynamic String
|
||||||
|
** METHOD: sqlite3_str
|
||||||
|
**
|
||||||
|
** These interfaces add content to an sqlite3_str object previously obtained
|
||||||
|
** from [sqlite3_str_new()].
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_appendf(X,F,...)] and
|
||||||
|
** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
|
||||||
|
** functionality of SQLite to append formatted text onto the end of
|
||||||
|
** [sqlite3_str] object X.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S
|
||||||
|
** onto the end of the [sqlite3_str] object X. N must be non-negative.
|
||||||
|
** S must contain at least N non-zero bytes of content. To append a
|
||||||
|
** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]
|
||||||
|
** method instead.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of
|
||||||
|
** zero-terminated string S onto the end of [sqlite3_str] object X.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the
|
||||||
|
** single-byte character C onto the end of [sqlite3_str] object X.
|
||||||
|
** ^This method can be used, for example, to add whitespace indentation.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_reset(X)] method resets the string under construction
|
||||||
|
** inside [sqlite3_str] object X back to zero bytes in length.
|
||||||
|
**
|
||||||
|
** These methods do not return a result code. ^If an error occurs, that fact
|
||||||
|
** is recorded in the [sqlite3_str] object and can be recovered by a
|
||||||
|
** subsequent call to [sqlite3_str_errcode(X)].
|
||||||
|
*/
|
||||||
|
SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);
|
||||||
|
SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);
|
||||||
|
SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
|
||||||
|
SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
|
||||||
|
SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
|
||||||
|
SQLITE_API void sqlite3_str_reset(sqlite3_str*);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Status Of A Dynamic String
|
||||||
|
** METHOD: sqlite3_str
|
||||||
|
**
|
||||||
|
** These interfaces return the current status of an [sqlite3_str] object.
|
||||||
|
**
|
||||||
|
** ^If any prior errors have occurred while constructing the dynamic string
|
||||||
|
** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return
|
||||||
|
** an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns
|
||||||
|
** [SQLITE_NOMEM] following any out-of-memory error, or
|
||||||
|
** [SQLITE_TOOBIG] if the size of the dynamic string exceeds
|
||||||
|
** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,
|
||||||
|
** of the dynamic string under construction in [sqlite3_str] object X.
|
||||||
|
** ^The length returned by [sqlite3_str_length(X)] does not include the
|
||||||
|
** zero-termination byte.
|
||||||
|
**
|
||||||
|
** ^The [sqlite3_str_value(X)] method returns a pointer to the current
|
||||||
|
** content of the dynamic string under construction in X. The value
|
||||||
|
** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X
|
||||||
|
** and might be freed or altered by any subsequent method on the same
|
||||||
|
** [sqlite3_str] object. Applications must not used the pointer returned
|
||||||
|
** [sqlite3_str_value(X)] after any subsequent method call on the same
|
||||||
|
** object. ^Applications may change the content of the string returned
|
||||||
|
** by [sqlite3_str_value(X)] as long as they do not write into any bytes
|
||||||
|
** outside the range of 0 to [sqlite3_str_length(X)] and do not read or
|
||||||
|
** write any byte after any subsequent sqlite3_str method call.
|
||||||
|
*/
|
||||||
|
SQLITE_API int sqlite3_str_errcode(sqlite3_str*);
|
||||||
|
SQLITE_API int sqlite3_str_length(sqlite3_str*);
|
||||||
|
SQLITE_API char *sqlite3_str_value(sqlite3_str*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: SQLite Runtime Status
|
** CAPI3REF: SQLite Runtime Status
|
||||||
**
|
**
|
||||||
|
@ -8283,11 +8540,11 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
|
||||||
** method of a [virtual table], then it returns true if and only if the
|
** method of a [virtual table], then it returns true if and only if the
|
||||||
** column is being fetched as part of an UPDATE operation during which the
|
** column is being fetched as part of an UPDATE operation during which the
|
||||||
** column value will not change. Applications might use this to substitute
|
** column value will not change. Applications might use this to substitute
|
||||||
** a lighter-weight value to return that the corresponding [xUpdate] method
|
** a return value that is less expensive to compute and that the corresponding
|
||||||
** understands as a "no-change" value.
|
** [xUpdate] method understands as a "no-change" value.
|
||||||
**
|
**
|
||||||
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
|
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
|
||||||
** the column is not changed by the UPDATE statement, they the xColumn
|
** the column is not changed by the UPDATE statement, then the xColumn
|
||||||
** method can optionally return without setting a result, without calling
|
** method can optionally return without setting a result, without calling
|
||||||
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
|
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
|
||||||
** In that case, [sqlite3_value_nochange(X)] will return true for the
|
** In that case, [sqlite3_value_nochange(X)] will return true for the
|
||||||
|
@ -8782,7 +9039,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
|
||||||
** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
|
** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
|
||||||
** values of D and S.
|
** values of D and S.
|
||||||
** The size of the database is written into *P even if the
|
** The size of the database is written into *P even if the
|
||||||
** SQLITE_SERIALIZE_NOCOPY bit is set but no contigious copy
|
** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
|
||||||
** of the database exists.
|
** of the database exists.
|
||||||
**
|
**
|
||||||
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
|
** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
|
||||||
|
|
|
@ -231,6 +231,56 @@ func TestInsert(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpsert(t *testing.T) {
|
||||||
|
_, n, _ := Version()
|
||||||
|
if !(n >= 3024000) {
|
||||||
|
t.Log("your version of sqlite3 doesn't support UPSERT featue. Version >= '3.24.0' needed. Skipping test...")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tempFilename := TempFilename(t)
|
||||||
|
defer os.Remove(tempFilename)
|
||||||
|
db, err := sql.Open("sqlite3", tempFilename)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to open database:", err)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
_, err = db.Exec("drop table foo")
|
||||||
|
_, err = db.Exec("create table foo (name string primary key, counter integer)")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to create table:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
res, err := db.Exec("insert into foo(name, counter) values('key', 1) on conflict (name) do update set counter=counter+1")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to upsert record:", err)
|
||||||
|
}
|
||||||
|
affected, _ := res.RowsAffected()
|
||||||
|
if affected != 1 {
|
||||||
|
t.Fatalf("Expected %d for affected rows, but %d:", 1, affected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows, err := db.Query("select name, counter from foo")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Failed to select records:", err)
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
rows.Next()
|
||||||
|
|
||||||
|
var resultName string
|
||||||
|
var resultCounter int
|
||||||
|
rows.Scan(&resultName, &resultCounter)
|
||||||
|
if resultName != "key" {
|
||||||
|
t.Errorf("Expected %s for fetched result, but %s:", "key", resultName)
|
||||||
|
}
|
||||||
|
if resultCounter != 10 {
|
||||||
|
t.Errorf("Expected %d for fetched result, but %d:", 10, resultCounter)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdate(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
tempFilename := TempFilename(t)
|
tempFilename := TempFilename(t)
|
||||||
defer os.Remove(tempFilename)
|
defer os.Remove(tempFilename)
|
||||||
|
|
30
sqlite3ext.h
30
sqlite3ext.h
|
@ -296,6 +296,21 @@ struct sqlite3_api_routines {
|
||||||
int (*vtab_nochange)(sqlite3_context*);
|
int (*vtab_nochange)(sqlite3_context*);
|
||||||
int (*value_nochange)(sqlite3_value*);
|
int (*value_nochange)(sqlite3_value*);
|
||||||
const char *(*vtab_collation)(sqlite3_index_info*,int);
|
const char *(*vtab_collation)(sqlite3_index_info*,int);
|
||||||
|
/* Version 3.24.0 and later */
|
||||||
|
int (*keyword_count)(void);
|
||||||
|
int (*keyword_name)(int,const char**,int*);
|
||||||
|
int (*keyword_check)(const char*,int);
|
||||||
|
sqlite3_str *(*str_new)(sqlite3*);
|
||||||
|
char *(*str_finish)(sqlite3_str*);
|
||||||
|
void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
|
||||||
|
void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
|
||||||
|
void (*str_append)(sqlite3_str*, const char *zIn, int N);
|
||||||
|
void (*str_appendall)(sqlite3_str*, const char *zIn);
|
||||||
|
void (*str_appendchar)(sqlite3_str*, int N, char C);
|
||||||
|
void (*str_reset)(sqlite3_str*);
|
||||||
|
int (*str_errcode)(sqlite3_str*);
|
||||||
|
int (*str_length)(sqlite3_str*);
|
||||||
|
char *(*str_value)(sqlite3_str*);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -566,6 +581,21 @@ typedef int (*sqlite3_loadext_entry)(
|
||||||
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
#define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
|
||||||
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
#define sqlite3_value_nochange sqlite3_api->value_nochange
|
||||||
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
#define sqlite3_vtab_collation sqlite3_api->vtab_collation
|
||||||
|
/* Version 3.24.0 and later */
|
||||||
|
#define sqlite3_keyword_count sqlite3_api->keyword_count
|
||||||
|
#define sqlite3_keyword_name sqlite3_api->keyword_name
|
||||||
|
#define sqlite3_keyword_check sqlite3_api->keyword_check
|
||||||
|
#define sqlite3_str_new sqlite3_api->str_new
|
||||||
|
#define sqlite3_str_finish sqlite3_api->str_finish
|
||||||
|
#define sqlite3_str_appendf sqlite3_api->str_appendf
|
||||||
|
#define sqlite3_str_vappendf sqlite3_api->str_vappendf
|
||||||
|
#define sqlite3_str_append sqlite3_api->str_append
|
||||||
|
#define sqlite3_str_appendall sqlite3_api->str_appendall
|
||||||
|
#define sqlite3_str_appendchar sqlite3_api->str_appendchar
|
||||||
|
#define sqlite3_str_reset sqlite3_api->str_reset
|
||||||
|
#define sqlite3_str_errcode sqlite3_api->str_errcode
|
||||||
|
#define sqlite3_str_length sqlite3_api->str_length
|
||||||
|
#define sqlite3_str_value sqlite3_api->str_value
|
||||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||||
|
|
||||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||||
|
|
Loading…
Reference in New Issue