Sq3StmtC - Result Values From A Query … More...
Functions | |
static SQ3_VAL | Sq3StmtColumnValue (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_BINN | Sq3StmtColumnBlobHide (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_I32 | Sq3StmtColumnBytes (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_I32 | Sq3StmtColumnCount (SQ3_STMT pStmt) |
Number Of Columns In A Result Set … | |
static MK_DBL | Sq3StmtColumnDouble (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_I32 | Sq3StmtColumnInt (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_I64 | Sq3StmtColumnInt64 (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MK_STRN | Sq3StmtColumnName (SQ3_STMT sq3stmt, MK_I32 N) |
Column Names In A Result Set … | |
static MK_STRN | Sq3StmtColumnTextHide (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static enum Sq3TypeE | Sq3StmtColumnType (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result Values From A Query … | |
static MkBinaryR | Sq3StmtColumnBlob (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result a MkBinaryR Value From A Query. | |
static MkStringR | Sq3StmtColumnText (SQ3_STMT sq3stmt, MK_I32 iCol) |
Result a MkStringR Value From A Query. | |
Sq3StmtC - Result Values From A Query …
Result a MkBinaryR Value From A Query.
This is an enhanced version of Sq3StmtColumnBlobHide using the Programming-Language-Micro-Kernel (PLMK) definition of a blob called MkBinaryR as return-value.
[in] | sq3stmt | the Sq3StmtC instance to work on a statement |
[in] | iCol | Is the index of the column for which information should be returned. The leftmost column of the result set has the index 0. |
sqlite3_column_blob → BLOB result sqlite3_column_double → REAL result sqlite3_column_int → 32-bit INTEGER result sqlite3_column_int64 → 64-bit INTEGER result sqlite3_column_text → UTF-8 TEXT result sqlite3_column_text16 → UTF-16 TEXT result sqlite3_column_value → The result as an Sq3ValueC object. sqlite3_column_bytes → Size of a BLOB or a UTF-8 TEXT result in bytes sqlite3_column_bytes16 → Size of UTF-16 TEXT in bytes sqlite3_column_type → Default datatype of the result
Internal
TypeRequested
TypeConversion
NULL INTEGER Result is 0 NULL FLOAT Result is 0.0 NULL TEXT Result is a NULL pointer NULL BLOB Result is a NULL pointer INTEGER FLOAT Convert from integer to float INTEGER TEXT ASCII rendering of the integer INTEGER BLOB Same as INTEGER->TEXT FLOAT INTEGER CAST to INTEGER FLOAT TEXT ASCII rendering of the float FLOAT BLOB CAST to BLOB TEXT INTEGER CAST to INTEGER TEXT FLOAT CAST to REAL TEXT BLOB No change BLOB INTEGER CAST to INTEGER BLOB FLOAT CAST to REAL BLOB TEXT CAST to TEXT, ensure zero terminator
Definition at line 669 of file Sq3StmtC_sq3.h.
Result Values From A Query …
Summary:
sqlite3_column_blob → BLOB result sqlite3_column_double → REAL result sqlite3_column_int → 32-bit INTEGER result sqlite3_column_int64 → 64-bit INTEGER result sqlite3_column_text → UTF-8 TEXT result sqlite3_column_text16 → UTF-16 TEXT result sqlite3_column_value → The result as an Sq3ValueC object. sqlite3_column_bytes → Size of a BLOB or a UTF-8 TEXT result in bytes sqlite3_column_bytes16 → Size of UTF-16 TEXT in bytes sqlite3_column_type → Default datatype of the result
Details:
These routines return information about a single column of the current result row of a query. In every case the first argument is a pointer to the prepared statement that is being evaluated (the Sq3StmtC* that was returned from Sq3StmtPrepareV2 () or one of its variants) and the second argument is the index of the column for which information should be returned. The leftmost column of the result set has the index 0. The number of columns in the result can be determined using Sq3StmtColumnCount ().
If the SQL statement does not currently point to a valid row, or if the column index is out of range, the result is undefined. These routines may only be called when the most recent call to Sq3StmtStep () has returned SQ3_RESULT_ROW and neither Sq3StmtReset () nor Sq3StmtFinalize () have been called subsequently. If any of these routines are called after Sq3StmtReset () or Sq3StmtFinalize () or after Sq3StmtStep () has returned something other than SQ3_RESULT_ROW, the results are undefined. If Sq3StmtStep () or Sq3StmtReset () or Sq3StmtFinalize () are called from a different thread while any of these routines are pending, then the results are undefined.
The first six interfaces (_blob, _double, _int, _int64, _text, and _text16) each return the value of a result column in a specific data format. If the result column is not initially in the requested format (for example, if the query returns an integer but the Sq3StmtColumnText() interface is used to extract the value) then an automatic type conversion is performed.
The Sq3StmtColumnType() routine returns the datatype code for the initial data type of the result column. The returned value is one of SQ3_TYPE_INTEGER, SQ3_TYPE_FLOAT, SQ3_TYPE_TEXT, SQ3_TYPE_BLOB, or SQ3_TYPE_NULL. The return value of Sq3StmtColumnType() can be used to decide which of the first six interface should be used to extract the column value. The value returned by Sq3StmtColumnType() is only meaningful if no automatic type conversions have occurred for the value in question. After a type conversion, the result of calling Sq3StmtColumnType() is undefined, though harmless. Future versions of SQLite may change the behavior of Sq3StmtColumnType() following a type conversion.
If the result is a BLOB or a TEXT string, then the Sq3StmtColumnBytes() or sqlite3_column_bytes16() interfaces can be used to determine the size of that BLOB or string.
If the result is a BLOB or UTF-8 string then the Sq3StmtColumnBytes() routine returns the number of bytes in that BLOB or string. If the result is a UTF-16 string, then Sq3StmtColumnBytes() converts the string to UTF-8 and then returns the number of bytes. If the result is a numeric value then Sq3StmtColumnBytes() uses sqlite3_snprintf () to convert that value to a UTF-8 string and returns the number of bytes in that string. If the result is NULL, then Sq3StmtColumnBytes() returns zero.
If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() routine returns the number of bytes in that BLOB or string. If the result is a UTF-8 string, then sqlite3_column_bytes16() converts the string to UTF-16 and then returns the number of bytes. If the result is a numeric value then sqlite3_column_bytes16() uses sqlite3_snprintf () to convert that value to a UTF-16 string and returns the number of bytes in that string. If the result is NULL, then sqlite3_column_bytes16() returns zero.
The values returned by Sq3StmtColumnBytes () and sqlite3_column_bytes16 () do not include the zero terminators at the end of the string. For clarity: the values returned by Sq3StmtColumnBytes () and sqlite3_column_bytes16 () are the number of bytes in the string, not the number of characters.
Strings returned by Sq3StmtColumnText() and sqlite3_column_text16(), even empty strings, are always zero-terminated. The return value from Sq3StmtColumnBlob() for a zero-length BLOB is a NULL pointer.
Strings returned by sqlite3_column_text16() always have the endianness which is native to the platform, regardless of the text encoding set for the database.
Warning: The object returned by Sq3StmtColumnValue () is an unprotected Sq3ValueC object. In a multithreaded environment, an unprotected Sq3ValueC object may only be used safely with Sq3StmtBindValue () and sqlite3_result_value (). If the unprotected Sq3ValueC object returned by Sq3StmtColumnValue () is used in any other way, including calls to routines like Sq3ValueInt (), Sq3ValueText (), or Sq3ValueBytes (), the behavior is not threadsafe. Hence, the Sq3StmtColumnValue() interface is normally only useful within the implementation of application-defined SQL functions or virtual tables, not within top-level application code.
These routines may attempt to convert the datatype of the result. For example, if the internal representation is FLOAT and a text result is requested, sqlite3_snprintf () is used internally to perform the conversion automatically. The following table details the conversions that are applied:
Internal
TypeRequested
TypeConversion
NULL INTEGER Result is 0 NULL FLOAT Result is 0.0 NULL TEXT Result is a NULL pointer NULL BLOB Result is a NULL pointer INTEGER FLOAT Convert from integer to float INTEGER TEXT ASCII rendering of the integer INTEGER BLOB Same as INTEGER->TEXT FLOAT INTEGER CAST to INTEGER FLOAT TEXT ASCII rendering of the float FLOAT BLOB CAST to BLOB TEXT INTEGER CAST to INTEGER TEXT FLOAT CAST to REAL TEXT BLOB No change BLOB INTEGER CAST to INTEGER BLOB FLOAT CAST to REAL BLOB TEXT CAST to TEXT, ensure zero terminator
Note that when type conversions occur, pointers returned by prior calls to Sq3StmtColumnBlob(), Sq3StmtColumnText(), and/or sqlite3_column_text16() may be invalidated. Type conversions and pointer invalidations might occur in the following cases:
Conversions between UTF-16be and UTF-16le are always done in place and do not invalidate a prior pointer, though of course the content of the buffer that the prior pointer references will have been modified. Other kinds of conversion are done in place when it is possible, but sometimes they are not possible and in those cases prior pointers are invalidated.
The safest policy is to invoke these routines in one of the following ways:
In other words, you should call Sq3StmtColumnText(), Sq3StmtColumnBlob(), or sqlite3_column_text16() first to force the result into the desired format, then invoke Sq3StmtColumnBytes() or sqlite3_column_bytes16() to find the size of the result. Do not mix calls to Sq3StmtColumnText() or Sq3StmtColumnBlob() with calls to sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() with calls to Sq3StmtColumnBytes().
The pointers returned are valid until a type conversion occurs as described above, or until Sq3StmtStep () or Sq3StmtReset () or Sq3StmtFinalize () is called. The memory space used to hold strings and BLOBs is freed automatically. Do not pass the pointers returned from Sq3StmtColumnBlob (), Sq3StmtColumnText (), etc. into Sq3Free ().
As long as the input parameters are correct, these routines will only fail if an out-of-memory error occurs during a format conversion. Only the following subset of interfaces are subject to out-of-memory errors:
If an out-of-memory error occurs, then the return value from these routines is the same as if the column had contained an SQL NULL value. Valid SQL NULL returns can be distinguished from out-of-memory errors by invoking the Sq3LiteErrCode () immediately after the suspect return value is obtained and before any other SQLite interface is called on the same database connection.
Reference code from sqlite3:
Definition at line 237 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnBlobHide …
Non-inline replacement for Sq3StmtColumnBlob …
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 243 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnBytes …
Number Of Columns In A Result Set …
Return the number of columns in the result set returned by the prepared statement. If this routine returns 0, that means the prepared statement returns no data (for example an UPDATE). However, just because this routine returns a positive number does not mean that one or more rows of data will be returned. A SELECT statement will always have a positive Sq3StmtColumnCount() but depending on the WHERE clause constraints and the table content, it might return no rows.
See also: Sq3StmtDataCount ()
Reference code from sqlite3:
Definition at line 249 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnCount …
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 255 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnDouble …
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 261 of file Sq3StmtC_sq3.h.
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 267 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnInt64 …
Non-inline replacement for Sq3StmtColumnInt …
Column Names In A Result Set …
These routines return the name assigned to a particular column in the result set of a SELECT statement. The Sq3StmtColumnName() interface returns a pointer to a zero-terminated UTF-8 string and sqlite3_column_name16() returns a pointer to a zero-terminated UTF-16 string. The first parameter is the prepared statement that implements the SELECT statement. The second parameter is the column number. The leftmost column is number 0.
The returned string pointer is valid until either the prepared statement is destroyed by Sq3StmtFinalize () or until the statement is automatically reprepared by the first call to Sq3StmtStep () for a particular run or until the next call to Sq3StmtColumnName() or sqlite3_column_name16() on the same column.
If Sq3Malloc() fails during the processing of either routine (for example during a conversion from UTF-8 to UTF-16) then a NULL pointer is returned.
The name of a result column is the value of the "AS" clause for that column, if there is an AS clause. If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next.
Reference code from sqlite3:
Definition at line 273 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnName …
Result a MkStringR Value From A Query.
This is an enhanced version of Sq3StmtColumnTextHide using the Programming-Language-Micro-Kernel (PLMK) definition of a text called MkStringR as return-value.
[in] | sq3stmt | the Sq3StmtC instance to work on a statement |
[in] | iCol | Is the index of the column for which information should be returned. The leftmost column of the result set has the index 0. |
Definition at line 688 of file Sq3StmtC_sq3.h.
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 280 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnTextHide …
Non-inline replacement for Sq3StmtColumnText …
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 287 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnType …
Result Values From A Query …
read more at 'Sq3StmtColumnBlob'
Definition at line 229 of file Sq3StmtC_sq3.h.
Non-inline replacement for Sq3StmtColumnValue …