-
-
Save OkobaPatino/76e4b8d55c71c25faa2542aa741255e9 to your computer and use it in GitHub Desktop.
New APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/src/db/mormot.db.raw.sqlite3.pas" "b/src/db/mormot.db.raw.sqlite3.pas" | |
index 1f11158..0b95489 100644 | |
--- "a/src/db/mormot.db.raw.sqlite3.pas" | |
+++ "b/src/db/mormot.db.raw.sqlite3.pas" | |
@@ -1273,7 +1273,24 @@ type | |
// API retain their values. Use sqlite3.clear_bindings() to reset the bindings. | |
reset: function(S: TSqlite3Statement): integer; cdecl; | |
- /// returns true (non-zero) if and only if the prepared statement X | |
+ /// Returns true (non-zero) if the prepared statement S has been stepped at least once | |
+ // using sqlite3.step(S) but has neither run to completion (returned SQLITE_DONE from | |
+ // sqlite3.step(S)) nor been reset using sqlite3.reset(S). | |
+ // - The sqlite3.stmt_busy(S) interface returns false if S is a NULL pointer. | |
+ // - If S is not a NULL pointer and is not a pointer to a valid prepared statement object, | |
+ // then the behavior is undefined and probably undesirable. | |
+ // - This interface can be used in combination sqlite3.next_stmt() to locate all prepared | |
+ // statements associated with a database connection that are in need of being reset. | |
+ // - This can be used, for example, in diagnostic routines to search for prepared statements | |
+ // that are holding a transaction open. | |
+ stmt_busy: function(S: TSqlite3Statement): integer; cdecl; | |
+ | |
+ /// Returns 1 if the prepared statement S is an EXPLAIN statement, | |
+ // or 2 if the statement S is an EXPLAIN QUERY PLAN, | |
+ // or 0 if S is an ordinary statement or a NULL pointer. | |
+ stmt_isexplain: function(S: TSqlite3Statement): integer; cdecl; | |
+ | |
+ /// Returns true (non-zero) if and only if the prepared statement X | |
// makes no direct changes to the content of the database file | |
// - Transaction control statements such as BEGIN, COMMIT, ROLLBACK, SAVEPOINT, | |
// and RELEASE cause sqlite3.stmt_readonly() to return true, since the statements | |
@@ -1284,6 +1301,24 @@ type | |
// do not make changes to the content of the database files on disk. | |
stmt_readonly: function(S: TSqlite3Statement): integer; cdecl; | |
+ /// Returns a pointer to a copy of the UTF-8 SQL text used to create prepared statement P. | |
+ // - The result is managed by SQLite and are automatically freed when the prepared statement is finalized. | |
+ sql: function(S: TSqlite3Statement): PUtf8Char; cdecl; | |
+ | |
+ /// Returns a pointer to a UTF-8 string containing the SQL text of prepared statement P | |
+ // with bound parameters expanded. | |
+ // - Returns NULL if insufficient memory is available to hold the result, or if the result | |
+ // would exceed the the maximum string length determined by the SQLITE_LIMIT_LENGTH. | |
+ // - The result is obtained from sqlite3.malloc() and must be free by the application by | |
+ // passing it to sqlite3.free_(). | |
+ expanded_sql: function(S: TSqlite3Statement): PUtf8Char; cdecl; | |
+ | |
+ /// Returns a pointer to a UTF-8 string containing the normalized SQL text of prepared statement P. | |
+ // - The semantics used to normalize a SQL statement are unspecified and subject to change. | |
+ // At a minimum, literal values will be replaced with suitable placeholders. | |
+ // - The result is managed by SQLite and are automatically freed when the prepared statement is finalized. | |
+ normalized_sql: function(S: TSqlite3Statement): PUtf8Char; cdecl; | |
+ | |
/// Evaluate An SQL Statement, returning a result status: | |
// - SQLITE_BUSY means that the database engine was unable to acquire the database | |
// locks it needs to do its job. If the statement is a COMMIT or occurs outside of | |
@@ -3714,7 +3749,7 @@ end; | |
{ TSqlite3LibraryDynamic } | |
const | |
- SQLITE3_ENTRIES: array[0..91] of PAnsiChar = ( | |
+ SQLITE3_ENTRIES: array[0..96] of PAnsiChar = ( | |
'sqlite3_initialize', | |
'sqlite3_shutdown', | |
'sqlite3_open', | |
@@ -3736,7 +3771,12 @@ const | |
'sqlite3_finalize', | |
'sqlite3_next_stmt', | |
'sqlite3_reset', | |
+ 'sqlite3_stmt_busy', | |
+ 'sqlite3_stmt_isexplain', | |
'sqlite3_stmt_readonly', | |
+ 'sqlite3_sql', | |
+ 'sqlite3_expanded_sql', | |
+ 'sqlite3_normalized_sql', | |
'sqlite3_step', | |
'sqlite3_column_count', | |
'sqlite3_column_type', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git "a/src/db/mormot.db.raw.sqlite3.static.pas" "b/src/db/mormot.db.raw.sqlite3.static.pas" | |
index 4df91e4..408e178 100644 | |
--- "a/src/db/mormot.db.raw.sqlite3.static.pas" | |
+++ "b/src/db/mormot.db.raw.sqlite3.static.pas" | |
@@ -1057,7 +1057,12 @@ function sqlite3_prepare_v2(DB: TSqlite3DB; SQL: PUtf8Char; SQL_bytes: integer; | |
function sqlite3_finalize(S: TSqlite3Statement): integer; cdecl; external; | |
function sqlite3_next_stmt(DB: TSqlite3DB; S: TSqlite3Statement): TSqlite3Statement; cdecl; external; | |
function sqlite3_reset(S: TSqlite3Statement): integer; cdecl; external; | |
+function sqlite3_stmt_busy(S: TSqlite3Statement): integer; cdecl; external; | |
+function sqlite3_stmt_isexplain(S: TSqlite3Statement): integer; cdecl; external; | |
function sqlite3_stmt_readonly(S: TSqlite3Statement): integer; cdecl; external; | |
+function sqlite3_sql(S: TSqlite3Statement): PUtf8Char; cdecl; external; | |
+function sqlite3_expanded_sql(S: TSqlite3Statement): PUtf8Char; cdecl; external; | |
+//function sqlite3_normalized_sql(S: TSqlite3Statement): PUtf8Char; cdecl; external; | |
function sqlite3_step(S: TSqlite3Statement): integer; cdecl; external; | |
function sqlite3_column_count(S: TSqlite3Statement): integer; cdecl; external; | |
function sqlite3_column_type(S: TSqlite3Statement; Col: integer): integer; cdecl; external; | |
@@ -1182,7 +1187,12 @@ begin | |
finalize := @sqlite3_finalize; | |
next_stmt := @sqlite3_next_stmt; | |
reset := @sqlite3_reset; | |
+ stmt_busy := @sqlite3_stmt_busy; | |
+ stmt_isexplain := @sqlite3_stmt_isexplain; | |
stmt_readonly := @sqlite3_stmt_readonly; | |
+ sql := @sqlite3_sql; | |
+ expanded_sql := @sqlite3_expanded_sql; | |
+ //normalized_sql := @sqlite3_normalized_sql; | |
step := @sqlite3_step; | |
column_count := @sqlite3_column_count; | |
column_type := @sqlite3_column_type; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment