ksql_result_blob
,
ksql_result_blob_alloc
,
ksql_result_bytes
,
ksql_result_double
,
ksql_result_int
,
ksql_result_isnull
,
ksql_result_str
,
ksql_result_str_alloc
—
get the result columns of a statement
library “ksql”
#include
<sys/types.h>
#include
<stdint.h>
#include
<ksql.h>
enum ksqlc
ksql_result_blob
(
struct
ksqlstmt *stmt,
const void **p,
size_t *sz,
size_t
column);
enum ksqlc
ksql_result_blob_alloc
(
struct
ksqlstmt *stmt,
void **p,
size_t *sz,
size_t
column);
enum ksqlc
ksql_result_bytes
(
struct
ksqlstmt *stmt,
int *p,
size_t column);
enum ksqlc
ksql_result_double
(
struct
ksqlstmt *stmt,
double *p,
size_t column);
enum ksqlc
ksql_result_int
(
struct
ksqlstmt *stmt,
int64_t *p,
size_t column);
enum ksqlc
ksql_result_isnull
(
struct
ksqlstmt *stmt,
int *p,
size_t column);
enum ksqlc
ksql_result_str
(
struct
ksqlstmt *stmt,
const char **p,
size_t column);
enum ksqlc
ksql_result_str_alloc
(
struct
ksqlstmt *stmt,
char **p,
size_t column);
These functions return results following
ksql_stmt_step(3). They all accept
stmt, the statement allocated with
ksql_stmt_alloc(3); the
column to query, which starts at zero; and
p, which is set to the resulting data. The
ksql_result_blob
() function additionaly
accepts
sz, which is set to the length of
p.
The
ksql_result_str
() and
ksql_result_blob
() functions return memory
that must be copied prior to a subsequent
ksql_stmt_step(3),
ksql_stmt_reset(3), or
ksql_stmt_free(3). The
ksql_result_blob
() may fill in a
NULL
pointer in the event of an empty
buffer;
ksql_result_str
() will always
return a NUL-terminated string on success. For the caller to manage memory,
use the
ksql_result_blob_alloc
() and
ksql_result_str_alloc
() variants to pass
back memory that must be released with
free(3).
There are a number of error conditions returned by these functions.
KSQL_MEM
- Memory allocation failure.
KSQL_NORESULTS
- There is no result row available. This happens when the prior
ksql_stmt_step(3) did not return
KSQL_ROW
.
KSQL_NULL
- The column has no data. This is not returned by
ksql_result_isnull
().
KSQL_RESULTCOL
- The column exceeds the maximum number of available result columns.
KSQL_SYSTEM
- An internal system error occurred.
If any of these errors occur, the passed-in result pointers
p and
sz are
undefined.
On success,
KSQL_OK
is returned and the
result pointers are filled in.
sqlite3_column_blob(3)