New shell command ".load" and the sqlite3_load_extension() API allow
new SQL functions and collating sequences to be loaded at run-time from a DLL or shared library. (CVS 3207) FossilOrigin-Name: 4ca932d3ae9bb97b819b5baf6fd3e1cebda9e0e2
This commit is contained in:
+267
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file contains code used to dynamically load extensions into
|
||||
** the SQLite library.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||
|
||||
#define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */
|
||||
#include "sqlite3ext.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef SQLITE_ENABLE_COLUMN_METADATA
|
||||
# define sqlite3_column_database_name 0
|
||||
# define sqlite3_column_database_name16 0
|
||||
# define sqlite3_column_table_name 0
|
||||
# define sqlite3_column_table_name16 0
|
||||
# define sqlite3_column_origin_name 0
|
||||
# define sqlite3_column_origin_name16 0
|
||||
# define sqlite3_table_column_metadata 0
|
||||
#endif
|
||||
|
||||
const sqlite3_api_routines sqlite3_api = {
|
||||
sqlite3_aggregate_context,
|
||||
sqlite3_aggregate_count,
|
||||
sqlite3_bind_blob,
|
||||
sqlite3_bind_double,
|
||||
sqlite3_bind_int,
|
||||
sqlite3_bind_int64,
|
||||
sqlite3_bind_null,
|
||||
sqlite3_bind_parameter_count,
|
||||
sqlite3_bind_parameter_index,
|
||||
sqlite3_bind_parameter_name,
|
||||
sqlite3_bind_text,
|
||||
sqlite3_bind_text16,
|
||||
sqlite3_busy_handler,
|
||||
sqlite3_busy_timeout,
|
||||
sqlite3_changes,
|
||||
sqlite3_close,
|
||||
sqlite3_collation_needed,
|
||||
sqlite3_collation_needed16,
|
||||
sqlite3_column_blob,
|
||||
sqlite3_column_bytes,
|
||||
sqlite3_column_bytes16,
|
||||
sqlite3_column_count,
|
||||
sqlite3_column_database_name,
|
||||
sqlite3_column_database_name16,
|
||||
sqlite3_column_decltype,
|
||||
sqlite3_column_decltype16,
|
||||
sqlite3_column_double,
|
||||
sqlite3_column_int,
|
||||
sqlite3_column_int64,
|
||||
sqlite3_column_name,
|
||||
sqlite3_column_name16,
|
||||
sqlite3_column_origin_name,
|
||||
sqlite3_column_origin_name16,
|
||||
sqlite3_column_table_name,
|
||||
sqlite3_column_table_name16,
|
||||
sqlite3_column_text,
|
||||
sqlite3_column_text16,
|
||||
sqlite3_column_type,
|
||||
sqlite3_commit_hook,
|
||||
sqlite3_complete,
|
||||
sqlite3_complete16,
|
||||
sqlite3_create_collation,
|
||||
sqlite3_create_collation16,
|
||||
sqlite3_create_function,
|
||||
sqlite3_create_function16,
|
||||
sqlite3_data_count,
|
||||
sqlite3_db_handle,
|
||||
sqlite3_enable_shared_cache,
|
||||
sqlite3_errcode,
|
||||
sqlite3_errmsg,
|
||||
sqlite3_errmsg16,
|
||||
sqlite3_exec,
|
||||
sqlite3_expired,
|
||||
sqlite3_finalize,
|
||||
sqlite3_free,
|
||||
sqlite3_free_table,
|
||||
sqlite3_get_autocommit,
|
||||
sqlite3_get_auxdata,
|
||||
sqlite3_get_table,
|
||||
sqlite3_global_recover,
|
||||
sqlite3_interrupt,
|
||||
sqlite3_last_insert_rowid,
|
||||
sqlite3_libversion,
|
||||
sqlite3_libversion_number,
|
||||
sqlite3_mprintf,
|
||||
sqlite3_open,
|
||||
sqlite3_open16,
|
||||
sqlite3_prepare,
|
||||
sqlite3_prepare16,
|
||||
sqlite3_profile,
|
||||
sqlite3_progress_handler,
|
||||
sqlite3_reset,
|
||||
sqlite3_result_blob,
|
||||
sqlite3_result_double,
|
||||
sqlite3_result_error,
|
||||
sqlite3_result_error16,
|
||||
sqlite3_result_int,
|
||||
sqlite3_result_int64,
|
||||
sqlite3_result_null,
|
||||
sqlite3_result_text,
|
||||
sqlite3_result_text16,
|
||||
sqlite3_result_text16be,
|
||||
sqlite3_result_text16le,
|
||||
sqlite3_result_value,
|
||||
sqlite3_rollback_hook,
|
||||
sqlite3_set_authorizer,
|
||||
sqlite3_set_auxdata,
|
||||
sqlite3_snprintf,
|
||||
sqlite3_step,
|
||||
sqlite3_table_column_metadata,
|
||||
sqlite3_thread_cleanup,
|
||||
sqlite3_total_changes,
|
||||
sqlite3_trace,
|
||||
sqlite3_transfer_bindings,
|
||||
sqlite3_update_hook,
|
||||
sqlite3_user_data,
|
||||
sqlite3_value_blob,
|
||||
sqlite3_value_bytes,
|
||||
sqlite3_value_bytes16,
|
||||
sqlite3_value_double,
|
||||
sqlite3_value_int,
|
||||
sqlite3_value_int64,
|
||||
sqlite3_value_numeric_type,
|
||||
sqlite3_value_text,
|
||||
sqlite3_value_text16,
|
||||
sqlite3_value_text16be,
|
||||
sqlite3_value_text16le,
|
||||
sqlite3_value_type,
|
||||
sqlite3_vmprintf,
|
||||
};
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) || defined(__BORLANDC__)
|
||||
# include <windows.h>
|
||||
# define SQLITE_LIBRARY_TYPE HANDLE
|
||||
# define SQLITE_OPEN_LIBRARY(A) LoadLibrary(A)
|
||||
# define SQLITE_FIND_SYMBOL(A,B) GetProcAddress(A,B)
|
||||
# define SQLITE_LIBRARY_ERROR(A) FreeLibrary(A)
|
||||
# define SQLITE_CLOSE_LIBRARY(A)
|
||||
#endif /* windows */
|
||||
|
||||
/*
|
||||
** Non-windows implementation of shared-library loaders
|
||||
*/
|
||||
#if defined(HAVE_DLOPEN) && !defined(SQLITE_LIBRARY_TYPE)
|
||||
# include <dlfcn.h>
|
||||
# define SQLITE_LIBRARY_TYPE void*
|
||||
# define SQLITE_OPEN_LIBRARY(A) dlopen(A, RTLD_NOW | RTLD_GLOBAL)
|
||||
# define SQLITE_FIND_SYMBOL(A,B) dlsym(A,B)
|
||||
# define SQLITE_LIBRARY_ERROR(A) dlclose(A)
|
||||
# define SQLITE_CLOSE_LIBRARY(A)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Attempt to load an SQLite extension library contained in the file
|
||||
** zFile. The entry point is zProc. zProc may be 0 in which case the
|
||||
** name of the entry point is derived from the filename.
|
||||
**
|
||||
** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.
|
||||
**
|
||||
** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
|
||||
** error message text. The calling function should free this memory
|
||||
** by calling sqlite3_free().
|
||||
**
|
||||
** The entry point name is derived from the filename according to the
|
||||
** following steps:
|
||||
**
|
||||
** * Convert the name to lower case
|
||||
** * Remove the path prefix from the name
|
||||
** * Remove the first "." and all following characters from the name
|
||||
** * If the name begins with "lib" remove the first 3 characters
|
||||
** * Remove all characters that are not US-ASCII alphanumerics
|
||||
** or underscores
|
||||
** * Remove any leading digits and underscores from the name
|
||||
** * Append "_init" to the name
|
||||
**
|
||||
** So, for example, if the input filename is "/home/drh/libtest1.52.so"
|
||||
** then the entry point would be computed as "test1_init".
|
||||
**
|
||||
** The derived entry point name is limited to a reasonable number of
|
||||
** characters (currently 200).
|
||||
*/
|
||||
int sqlite3_load_extension(
|
||||
sqlite3 *db, /* Load the extension into this database connection */
|
||||
const char *zFile, /* Name of the shared library containing extension */
|
||||
const char *zProc, /* Entry point. Derived from zFile if 0 */
|
||||
char **pzErrMsg /* Put error message here if not 0 */
|
||||
){
|
||||
#ifdef SQLITE_LIBRARY_TYPE
|
||||
SQLITE_LIBRARY_TYPE handle;
|
||||
int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
|
||||
char *zErrmsg = 0;
|
||||
|
||||
if( zProc==0 ){
|
||||
int i, j, n;
|
||||
char *z;
|
||||
char zBuf[200];
|
||||
n = strlen(zFile);
|
||||
for(i=n-1; i>0 && zFile[i-1]!='/'; i--){}
|
||||
for(j=i; zFile[j] && zFile[j]!='.'; j++){}
|
||||
if( j-i > sizeof(zBuf)-10 ) j = i + sizeof(zBuf) - 10;
|
||||
memcpy(zBuf, &zFile[i], j - i);
|
||||
zBuf[j - i] = 0;
|
||||
z = zBuf;
|
||||
for(i=j=0; z[i]; i++){
|
||||
int c = z[i];
|
||||
if( (c & 0x80)!=0 || (!isalnum(c) && c!='_') ) continue;
|
||||
z[j++] = tolower(c);
|
||||
}
|
||||
z[j] = 0;
|
||||
if( strncmp(z, "lib", 3)==0 ){
|
||||
z += 3;
|
||||
}
|
||||
while( z[0] && !isalpha(z[0]) ){
|
||||
z++;
|
||||
}
|
||||
strcat(z, "_init");
|
||||
zProc = z;
|
||||
}
|
||||
|
||||
handle = SQLITE_OPEN_LIBRARY(zFile);
|
||||
if( handle==0 ){
|
||||
if( pzErrMsg ){
|
||||
*pzErrMsg = sqlite3_mprintf("unable to open shared library [%s]", zFile);
|
||||
}
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
|
||||
SQLITE_FIND_SYMBOL(handle, zProc);
|
||||
if( xInit==0 ){
|
||||
if( pzErrMsg ){
|
||||
*pzErrMsg = sqlite3_mprintf("no entry point [%s] in shared library [%s]",
|
||||
zProc, zFile);
|
||||
}
|
||||
SQLITE_LIBRARY_ERROR(handle);
|
||||
return SQLITE_ERROR;
|
||||
}else if( xInit(db, &zErrmsg, &sqlite3_api) ){
|
||||
if( pzErrMsg ){
|
||||
*pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
|
||||
}
|
||||
sqlite3_free(zErrmsg);
|
||||
SQLITE_LIBRARY_ERROR(handle);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
SQLITE_CLOSE_LIBRARY(handle);
|
||||
return SQLITE_OK;
|
||||
#else
|
||||
if( pzErrMsg ){
|
||||
*pzErrMsg = sqlite3_mprintf(
|
||||
"shared library loading not enabled for this build");
|
||||
}
|
||||
return SQLITE_ERROR;
|
||||
#endif
|
||||
}
|
||||
#endif /* SQLITE_OMIT_LOAD_EXTENSION */
|
||||
+16
-1
@@ -12,7 +12,7 @@
|
||||
** This file contains code to implement the "sqlite" command line
|
||||
** utility for accessing SQLite databases.
|
||||
**
|
||||
** $Id: shell.c,v 1.138 2006/06/06 12:32:21 drh Exp $
|
||||
** $Id: shell.c,v 1.139 2006/06/08 15:28:44 drh Exp $
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -759,6 +759,7 @@ static char zHelp[] =
|
||||
".help Show this message\n"
|
||||
".import FILE TABLE Import data from FILE into TABLE\n"
|
||||
".indices TABLE Show names of all indices on TABLE\n"
|
||||
".load FILE ?ENTRY? Load an extension library\n"
|
||||
".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
|
||||
" csv Comma-separated values\n"
|
||||
" column Left-aligned columns. (See .width)\n"
|
||||
@@ -1144,6 +1145,20 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||
}
|
||||
}else
|
||||
|
||||
if( c=='l' && strncmp(azArg[0], "load", n)==0 && nArg>=2 ){
|
||||
const char *zFile, *zProc;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
zFile = azArg[1];
|
||||
zProc = nArg>=3 ? azArg[2] : 0;
|
||||
open_db(p);
|
||||
rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);
|
||||
if( rc!=SQLITE_OK ){
|
||||
fprintf(stderr, "%s\n", zErrMsg);
|
||||
sqlite3_free(zErrMsg);
|
||||
}
|
||||
}else
|
||||
|
||||
if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){
|
||||
int n2 = strlen(azArg[1]);
|
||||
if( strncmp(azArg[1],"line",n2)==0
|
||||
|
||||
+41
-1
@@ -12,7 +12,7 @@
|
||||
** This header file defines the interface that the SQLite library
|
||||
** presents to client programs.
|
||||
**
|
||||
** @(#) $Id: sqlite.h.in,v 1.165 2006/04/04 01:54:55 drh Exp $
|
||||
** @(#) $Id: sqlite.h.in,v 1.166 2006/06/08 15:28:44 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITE3_H_
|
||||
#define _SQLITE3_H_
|
||||
@@ -1468,6 +1468,46 @@ int sqlite3_table_column_metadata(
|
||||
int *pAutoinc /* OUTPUT: True if colums is auto-increment */
|
||||
);
|
||||
|
||||
/*
|
||||
****** EXPERIMENTAL - subject to change without notice **************
|
||||
**
|
||||
** Attempt to load an SQLite extension library contained in the file
|
||||
** zFile. The entry point is zProc. zProc may be 0 in which case the
|
||||
** name of the entry point is derived from the filename.
|
||||
**
|
||||
** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.
|
||||
**
|
||||
** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
|
||||
** error message text. The calling function should free this memory
|
||||
** by calling sqlite3_free().
|
||||
**
|
||||
** The entry point name is derived from the filename according to the
|
||||
** following steps:
|
||||
**
|
||||
** * Convert the name to lower case
|
||||
** * Remove the path prefix from the name
|
||||
** * Remove the first "." and all following characters from the name
|
||||
** * If the name begins with "lib" remove the first 3 characters
|
||||
** * Remove all characters that are not US-ASCII alphanumerics
|
||||
** or underscores
|
||||
** * Remove any leading digits and underscores from the name
|
||||
** * Append "_init" to the name
|
||||
**
|
||||
** So, for example, if the input filename is "/home/drh/libtest1.52.so"
|
||||
** then the entry point would be computed as "test1_init".
|
||||
**
|
||||
** The derived entry point name is limited to a reasonable number of
|
||||
** characters (currently 200).
|
||||
**
|
||||
****** EXPERIMENTAL - subject to change without notice **************
|
||||
*/
|
||||
int sqlite3_load_extension(
|
||||
sqlite3 *db, /* Load the extension into this database connection */
|
||||
const char *zFile, /* Name of the shared library containing extension */
|
||||
const char *zProc, /* Entry point. Derived from zFile if 0 */
|
||||
char **pzErrMsg /* Put error message here if not 0 */
|
||||
);
|
||||
|
||||
/*
|
||||
** Undo the hack that converts floating point types to integer for
|
||||
** builds on processors without floating point support.
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This header file defines the SQLite interface for use by
|
||||
** shared libraries that want to be imported as extensions into
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
**
|
||||
** @(#) $Id: sqlite3ext.h,v 1.1 2006/06/08 15:28:44 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITE3EXT_H_
|
||||
#define _SQLITE3EXT_H_
|
||||
#include <sqlite3.h>
|
||||
|
||||
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
||||
|
||||
/*
|
||||
** The following structure hold pointers to all of the SQLite API
|
||||
** routines.
|
||||
*/
|
||||
struct sqlite3_api_routines {
|
||||
void * (*aggregate_context)(sqlite3_context*,int nBytes);
|
||||
int (*aggregate_count)(sqlite3_context*);
|
||||
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
|
||||
int (*bind_double)(sqlite3_stmt*,int,double);
|
||||
int (*bind_int)(sqlite3_stmt*,int,int);
|
||||
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
|
||||
int (*bind_null)(sqlite3_stmt*,int);
|
||||
int (*bind_parameter_count)(sqlite3_stmt*);
|
||||
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
|
||||
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
|
||||
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
|
||||
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
|
||||
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
|
||||
int (*busy_timeout)(sqlite3*,int ms);
|
||||
int (*changes)(sqlite3*);
|
||||
int (*close)(sqlite3*);
|
||||
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const char*));
|
||||
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,int eTextRep,const void*));
|
||||
const void * (*column_blob)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes)(sqlite3_stmt*,int iCol);
|
||||
int (*column_bytes16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_count)(sqlite3_stmt*pStmt);
|
||||
const char * (*column_database_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_database_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_decltype)(sqlite3_stmt*,int i);
|
||||
const void * (*column_decltype16)(sqlite3_stmt*,int);
|
||||
double (*column_double)(sqlite3_stmt*,int iCol);
|
||||
int (*column_int)(sqlite3_stmt*,int iCol);
|
||||
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
|
||||
const char * (*column_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_origin_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_origin_name16)(sqlite3_stmt*,int);
|
||||
const char * (*column_table_name)(sqlite3_stmt*,int);
|
||||
const void * (*column_table_name16)(sqlite3_stmt*,int);
|
||||
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
|
||||
const void * (*column_text16)(sqlite3_stmt*,int iCol);
|
||||
int (*column_type)(sqlite3_stmt*,int iCol);
|
||||
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
|
||||
int (*complete)(const char*sql);
|
||||
int (*complete16)(const void*sql);
|
||||
int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
|
||||
int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
|
||||
int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
|
||||
int (*data_count)(sqlite3_stmt*pStmt);
|
||||
sqlite3 * (*db_handle)(sqlite3_stmt*);
|
||||
int (*enable_shared_cache)(int);
|
||||
int (*errcode)(sqlite3*db);
|
||||
const char * (*errmsg)(sqlite3*);
|
||||
const void * (*errmsg16)(sqlite3*);
|
||||
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
|
||||
int (*expired)(sqlite3_stmt*);
|
||||
int (*finalize)(sqlite3_stmt*pStmt);
|
||||
void (*free)(char*z);
|
||||
void (*free_table)(char**result);
|
||||
int (*get_autocommit)(sqlite3*);
|
||||
void * (*get_auxdata)(sqlite3_context*,int);
|
||||
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
|
||||
int (*global_recover)(void);
|
||||
void (*interrupt)(sqlite3*);
|
||||
sqlite_int64 (*last_insert_rowid)(sqlite3*);
|
||||
const char * (*libversion)(void);
|
||||
int (*libversion_number)(void);
|
||||
char * (*mprintf)(const char*,...);
|
||||
int (*open)(const char*,sqlite3**);
|
||||
int (*open16)(const void*,sqlite3**);
|
||||
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
|
||||
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
|
||||
int (*reset)(sqlite3_stmt*pStmt);
|
||||
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_double)(sqlite3_context*,double);
|
||||
void (*result_error)(sqlite3_context*,const char*,int);
|
||||
void (*result_error16)(sqlite3_context*,const void*,int);
|
||||
void (*result_int)(sqlite3_context*,int);
|
||||
void (*result_int64)(sqlite3_context*,sqlite_int64);
|
||||
void (*result_null)(sqlite3_context*);
|
||||
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
|
||||
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||
void (*result_value)(sqlite3_context*,sqlite3_value*);
|
||||
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
|
||||
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,const char*,const char*),void*);
|
||||
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
||||
char * (*snprintf)(int,char*,const char*,...);
|
||||
int (*step)(sqlite3_stmt*);
|
||||
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
|
||||
void (*thread_cleanup)(void);
|
||||
int (*total_changes)(sqlite3*);
|
||||
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
|
||||
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
|
||||
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,sqlite_int64),void*);
|
||||
void * (*user_data)(sqlite3_context*);
|
||||
const void * (*value_blob)(sqlite3_value*);
|
||||
int (*value_bytes)(sqlite3_value*);
|
||||
int (*value_bytes16)(sqlite3_value*);
|
||||
double (*value_double)(sqlite3_value*);
|
||||
int (*value_int)(sqlite3_value*);
|
||||
sqlite_int64 (*value_int64)(sqlite3_value*);
|
||||
int (*value_numeric_type)(sqlite3_value*);
|
||||
const unsigned char * (*value_text)(sqlite3_value*);
|
||||
const void * (*value_text16)(sqlite3_value*);
|
||||
const void * (*value_text16be)(sqlite3_value*);
|
||||
const void * (*value_text16le)(sqlite3_value*);
|
||||
int (*value_type)(sqlite3_value*);
|
||||
char * (*vmprintf)(const char*,va_list);
|
||||
};
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected throught the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
** it can get access to the sqlite3_api_routines structure
|
||||
** definition. But the main library does not want to redefine
|
||||
** the API. So the redefinition macros are only valid if the
|
||||
** SQLITE_CORE macros is undefined.
|
||||
*/
|
||||
#ifndef SQLITE_CORE
|
||||
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||
#define sqlite3_changes sqlite3_api->changes
|
||||
#define sqlite3_close sqlite3_api->close
|
||||
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||
#define sqlite3_column_count sqlite3_api->column_count
|
||||
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||
#define sqlite3_column_double sqlite3_api->column_double
|
||||
#define sqlite3_column_int sqlite3_api->column_int
|
||||
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||
#define sqlite3_column_name sqlite3_api->column_name
|
||||
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||
#define sqlite3_column_text sqlite3_api->column_text
|
||||
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||
#define sqlite3_column_type sqlite3_api->column_type
|
||||
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||
#define sqlite3_complete sqlite3_api->complete
|
||||
#define sqlite3_complete16 sqlite3_api->complete16
|
||||
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||
#define sqlite3_create_function sqlite3_api->create_function
|
||||
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||
#define sqlite3_data_count sqlite3_api->data_count
|
||||
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||
#define sqlite3_errcode sqlite3_api->errcode
|
||||
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||
#define sqlite3_exec sqlite3_api->exec
|
||||
#define sqlite3_expired sqlite3_api->expired
|
||||
#define sqlite3_finalize sqlite3_api->finalize
|
||||
#define sqlite3_free sqlite3_api->free
|
||||
#define sqlite3_free_table sqlite3_api->free_table
|
||||
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||
#define sqlite3_get_table sqlite3_api->get_table
|
||||
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||
#define sqlite3_interrupt sqlite3_api->interrupt
|
||||
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||
#define sqlite3_libversion sqlite3_api->libversion
|
||||
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||
#define sqlite3_open sqlite3_api->open
|
||||
#define sqlite3_open16 sqlite3_api->open16
|
||||
#define sqlite3_prepare sqlite3_api->prepare
|
||||
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||
#define sqlite3_profile sqlite3_api->profile
|
||||
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||
#define sqlite3_reset sqlite3_api->reset
|
||||
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||
#define sqlite3_result_double sqlite3_api->result_double
|
||||
#define sqlite3_result_error sqlite3_api->result_error
|
||||
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||
#define sqlite3_result_int sqlite3_api->result_int
|
||||
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||
#define sqlite3_result_null sqlite3_api->result_null
|
||||
#define sqlite3_result_text sqlite3_api->result_text
|
||||
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||
#define sqlite3_result_value sqlite3_api->result_value
|
||||
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||
#define sqlite3_snprintf sqlite3_api->snprintf
|
||||
#define sqlite3_step sqlite3_api->step
|
||||
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||
#define sqlite3_trace sqlite3_api->trace
|
||||
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||
#define sqlite3_user_data sqlite3_api->user_data
|
||||
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||
#define sqlite3_value_double sqlite3_api->value_double
|
||||
#define sqlite3_value_int sqlite3_api->value_int
|
||||
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||
#define sqlite3_value_text sqlite3_api->value_text
|
||||
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||
#define sqlite3_value_type sqlite3_api->value_type
|
||||
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||
#endif /* SQLITE_CORE */
|
||||
|
||||
#define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api;
|
||||
#define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v;
|
||||
|
||||
#endif /* _SQLITE3EXT_H_ */
|
||||
Reference in New Issue
Block a user