driver-sqlite.c revision 0ae010139a1bb3b29fbf117c5da1a6a6c6b7b5a0
/* Copyright (C) 2006 Jakob Hirsch */
#include "lib.h"
#include "str.h"
#include "sql-api-private.h"
#ifdef BUILD_SQLITE
#include <sqlite3.h>
/* retry time if db is busy (in ms) */
const int sqlite_busy_timeout = 1000;
struct sqlite_db {
const char *dbfile;
unsigned int connected:1;
int rc;
};
struct sqlite_result {
struct sql_result api;
unsigned int cols;
const char **row;
};
struct sqlite_transaction_context {
struct sql_transaction_context ctx;
unsigned int failed:1;
};
extern struct sql_db driver_sqlite_db;
extern struct sql_result driver_sqlite_result;
extern struct sql_result driver_sqlite_error_result;
{
return 1;
return 1;
} else {
return -1;
}
}
{
}
{
}
static enum sql_db_flags
{
return SQL_DB_FLAG_BLOCKING;
}
static const char *
const char *string)
{
const char *p;
/* find the first ' */
for (p = string; *p != '\''; p++) {
if (*p == '\0')
return t_strdup_noconst(string);
}
/* @UNSAFE: escape ' with '' */
for (; *p != '\0'; p++) {
*dest++ = *p;
if (*p == '\'')
*dest++ = *p;
}
*dest++ = '\0';
return destbegin;
}
{
i_error("sqlite: exec(%s) failed: %s (%d)",
}
}
{
struct sql_result *result;
}
static struct sql_result *
{
struct sqlite_result *result;
int rc;
} else {
}
}
{
int rc;
return;
i_warning("sqlite: finalize failed: %s (%d)",
}
}
}
{
case SQLITE_ROW:
return 1;
case SQLITE_DONE:
return 0;
default:
return -1;
}
}
static unsigned int
{
}
static const char *
unsigned int idx)
{
}
const char *field_name)
{
unsigned int i;
return i;
}
return -1;
}
static const char *
unsigned int idx)
{
}
static const unsigned char *
{
}
static const char *
const char *field_name)
{
int idx;
if (idx < 0)
return NULL;
}
static const char *const *
{
unsigned int i;
}
}
{
}
static struct sql_transaction_context *
{
struct sqlite_transaction_context *ctx;
}
static void
{
struct sqlite_transaction_context *ctx =
(struct sqlite_transaction_context *)_ctx;
}
static void
{
struct sqlite_transaction_context *ctx =
(struct sqlite_transaction_context *)_ctx;
const char *errmsg;
}
/* also does i_free(ctx) */
} else {
}
}
static int
const char **error_r)
{
struct sqlite_transaction_context *ctx =
(struct sqlite_transaction_context *)_ctx;
/* also does i_free(ctx) */
return -1;
}
return 0;
}
static void
{
struct sqlite_transaction_context *ctx =
(struct sqlite_transaction_context *)_ctx;
return;
}
struct sql_db driver_sqlite_db = {
"sqlite",
MEMBER(v) {
}
};
struct sql_result driver_sqlite_result = {
MEMBER(v) {
}
};
static int
{
return -1;
}
struct sql_result driver_sqlite_error_result = {
MEMBER(v) {
}
};
void driver_sqlite_init(void);
void driver_sqlite_deinit(void);
void driver_sqlite_init(void)
{
}
void driver_sqlite_deinit(void)
{
}
#endif