sqlite3ext.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. #ifndef USE_LIBSQLITE3
  2. /*
  3. ** 2006 June 7
  4. **
  5. ** The author disclaims copyright to this source code. In place of
  6. ** a legal notice, here is a blessing:
  7. **
  8. ** May you do good and not evil.
  9. ** May you find forgiveness for yourself and forgive others.
  10. ** May you share freely, never taking more than you give.
  11. **
  12. *************************************************************************
  13. ** This header file defines the SQLite interface for use by
  14. ** shared libraries that want to be imported as extensions into
  15. ** an SQLite instance. Shared libraries that intend to be loaded
  16. ** as extensions by SQLite should #include this file instead of
  17. ** sqlite3.h.
  18. */
  19. #ifndef SQLITE3EXT_H
  20. #define SQLITE3EXT_H
  21. #include "sqlite3-binding.h"
  22. #ifdef __clang__
  23. #define assert(condition) ((void)0)
  24. #endif
  25. /*
  26. ** The following structure holds pointers to all of the SQLite API
  27. ** routines.
  28. **
  29. ** WARNING: In order to maintain backwards compatibility, add new
  30. ** interfaces to the end of this structure only. If you insert new
  31. ** interfaces in the middle of this structure, then older different
  32. ** versions of SQLite will not be able to load each other's shared
  33. ** libraries!
  34. */
  35. struct sqlite3_api_routines {
  36. void * (*aggregate_context)(sqlite3_context*,int nBytes);
  37. int (*aggregate_count)(sqlite3_context*);
  38. int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
  39. int (*bind_double)(sqlite3_stmt*,int,double);
  40. int (*bind_int)(sqlite3_stmt*,int,int);
  41. int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
  42. int (*bind_null)(sqlite3_stmt*,int);
  43. int (*bind_parameter_count)(sqlite3_stmt*);
  44. int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
  45. const char * (*bind_parameter_name)(sqlite3_stmt*,int);
  46. int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
  47. int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
  48. int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
  49. int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
  50. int (*busy_timeout)(sqlite3*,int ms);
  51. int (*changes)(sqlite3*);
  52. int (*close)(sqlite3*);
  53. int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
  54. int eTextRep,const char*));
  55. int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
  56. int eTextRep,const void*));
  57. const void * (*column_blob)(sqlite3_stmt*,int iCol);
  58. int (*column_bytes)(sqlite3_stmt*,int iCol);
  59. int (*column_bytes16)(sqlite3_stmt*,int iCol);
  60. int (*column_count)(sqlite3_stmt*pStmt);
  61. const char * (*column_database_name)(sqlite3_stmt*,int);
  62. const void * (*column_database_name16)(sqlite3_stmt*,int);
  63. const char * (*column_decltype)(sqlite3_stmt*,int i);
  64. const void * (*column_decltype16)(sqlite3_stmt*,int);
  65. double (*column_double)(sqlite3_stmt*,int iCol);
  66. int (*column_int)(sqlite3_stmt*,int iCol);
  67. sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
  68. const char * (*column_name)(sqlite3_stmt*,int);
  69. const void * (*column_name16)(sqlite3_stmt*,int);
  70. const char * (*column_origin_name)(sqlite3_stmt*,int);
  71. const void * (*column_origin_name16)(sqlite3_stmt*,int);
  72. const char * (*column_table_name)(sqlite3_stmt*,int);
  73. const void * (*column_table_name16)(sqlite3_stmt*,int);
  74. const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
  75. const void * (*column_text16)(sqlite3_stmt*,int iCol);
  76. int (*column_type)(sqlite3_stmt*,int iCol);
  77. sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
  78. void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
  79. int (*complete)(const char*sql);
  80. int (*complete16)(const void*sql);
  81. int (*create_collation)(sqlite3*,const char*,int,void*,
  82. int(*)(void*,int,const void*,int,const void*));
  83. int (*create_collation16)(sqlite3*,const void*,int,void*,
  84. int(*)(void*,int,const void*,int,const void*));
  85. int (*create_function)(sqlite3*,const char*,int,int,void*,
  86. void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  87. void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  88. void (*xFinal)(sqlite3_context*));
  89. int (*create_function16)(sqlite3*,const void*,int,int,void*,
  90. void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  91. void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  92. void (*xFinal)(sqlite3_context*));
  93. int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
  94. int (*data_count)(sqlite3_stmt*pStmt);
  95. sqlite3 * (*db_handle)(sqlite3_stmt*);
  96. int (*declare_vtab)(sqlite3*,const char*);
  97. int (*enable_shared_cache)(int);
  98. int (*errcode)(sqlite3*db);
  99. const char * (*errmsg)(sqlite3*);
  100. const void * (*errmsg16)(sqlite3*);
  101. int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
  102. int (*expired)(sqlite3_stmt*);
  103. int (*finalize)(sqlite3_stmt*pStmt);
  104. void (*free)(void*);
  105. void (*free_table)(char**result);
  106. int (*get_autocommit)(sqlite3*);
  107. void * (*get_auxdata)(sqlite3_context*,int);
  108. int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
  109. int (*global_recover)(void);
  110. void (*interruptx)(sqlite3*);
  111. sqlite_int64 (*last_insert_rowid)(sqlite3*);
  112. const char * (*libversion)(void);
  113. int (*libversion_number)(void);
  114. void *(*malloc)(int);
  115. char * (*mprintf)(const char*,...);
  116. int (*open)(const char*,sqlite3**);
  117. int (*open16)(const void*,sqlite3**);
  118. int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
  119. int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
  120. void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
  121. void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
  122. void *(*realloc)(void*,int);
  123. int (*reset)(sqlite3_stmt*pStmt);
  124. void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
  125. void (*result_double)(sqlite3_context*,double);
  126. void (*result_error)(sqlite3_context*,const char*,int);
  127. void (*result_error16)(sqlite3_context*,const void*,int);
  128. void (*result_int)(sqlite3_context*,int);
  129. void (*result_int64)(sqlite3_context*,sqlite_int64);
  130. void (*result_null)(sqlite3_context*);
  131. void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
  132. void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
  133. void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
  134. void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
  135. void (*result_value)(sqlite3_context*,sqlite3_value*);
  136. void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
  137. int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
  138. const char*,const char*),void*);
  139. void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
  140. char * (*xsnprintf)(int,char*,const char*,...);
  141. int (*step)(sqlite3_stmt*);
  142. int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
  143. char const**,char const**,int*,int*,int*);
  144. void (*thread_cleanup)(void);
  145. int (*total_changes)(sqlite3*);
  146. void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
  147. int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
  148. void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
  149. sqlite_int64),void*);
  150. void * (*user_data)(sqlite3_context*);
  151. const void * (*value_blob)(sqlite3_value*);
  152. int (*value_bytes)(sqlite3_value*);
  153. int (*value_bytes16)(sqlite3_value*);
  154. double (*value_double)(sqlite3_value*);
  155. int (*value_int)(sqlite3_value*);
  156. sqlite_int64 (*value_int64)(sqlite3_value*);
  157. int (*value_numeric_type)(sqlite3_value*);
  158. const unsigned char * (*value_text)(sqlite3_value*);
  159. const void * (*value_text16)(sqlite3_value*);
  160. const void * (*value_text16be)(sqlite3_value*);
  161. const void * (*value_text16le)(sqlite3_value*);
  162. int (*value_type)(sqlite3_value*);
  163. char *(*vmprintf)(const char*,va_list);
  164. /* Added ??? */
  165. int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
  166. /* Added by 3.3.13 */
  167. int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
  168. int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
  169. int (*clear_bindings)(sqlite3_stmt*);
  170. /* Added by 3.4.1 */
  171. int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
  172. void (*xDestroy)(void *));
  173. /* Added by 3.5.0 */
  174. int (*bind_zeroblob)(sqlite3_stmt*,int,int);
  175. int (*blob_bytes)(sqlite3_blob*);
  176. int (*blob_close)(sqlite3_blob*);
  177. int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
  178. int,sqlite3_blob**);
  179. int (*blob_read)(sqlite3_blob*,void*,int,int);
  180. int (*blob_write)(sqlite3_blob*,const void*,int,int);
  181. int (*create_collation_v2)(sqlite3*,const char*,int,void*,
  182. int(*)(void*,int,const void*,int,const void*),
  183. void(*)(void*));
  184. int (*file_control)(sqlite3*,const char*,int,void*);
  185. sqlite3_int64 (*memory_highwater)(int);
  186. sqlite3_int64 (*memory_used)(void);
  187. sqlite3_mutex *(*mutex_alloc)(int);
  188. void (*mutex_enter)(sqlite3_mutex*);
  189. void (*mutex_free)(sqlite3_mutex*);
  190. void (*mutex_leave)(sqlite3_mutex*);
  191. int (*mutex_try)(sqlite3_mutex*);
  192. int (*open_v2)(const char*,sqlite3**,int,const char*);
  193. int (*release_memory)(int);
  194. void (*result_error_nomem)(sqlite3_context*);
  195. void (*result_error_toobig)(sqlite3_context*);
  196. int (*sleep)(int);
  197. void (*soft_heap_limit)(int);
  198. sqlite3_vfs *(*vfs_find)(const char*);
  199. int (*vfs_register)(sqlite3_vfs*,int);
  200. int (*vfs_unregister)(sqlite3_vfs*);
  201. int (*xthreadsafe)(void);
  202. void (*result_zeroblob)(sqlite3_context*,int);
  203. void (*result_error_code)(sqlite3_context*,int);
  204. int (*test_control)(int, ...);
  205. void (*randomness)(int,void*);
  206. sqlite3 *(*context_db_handle)(sqlite3_context*);
  207. int (*extended_result_codes)(sqlite3*,int);
  208. int (*limit)(sqlite3*,int,int);
  209. sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
  210. const char *(*sql)(sqlite3_stmt*);
  211. int (*status)(int,int*,int*,int);
  212. int (*backup_finish)(sqlite3_backup*);
  213. sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
  214. int (*backup_pagecount)(sqlite3_backup*);
  215. int (*backup_remaining)(sqlite3_backup*);
  216. int (*backup_step)(sqlite3_backup*,int);
  217. const char *(*compileoption_get)(int);
  218. int (*compileoption_used)(const char*);
  219. int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
  220. void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  221. void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  222. void (*xFinal)(sqlite3_context*),
  223. void(*xDestroy)(void*));
  224. int (*db_config)(sqlite3*,int,...);
  225. sqlite3_mutex *(*db_mutex)(sqlite3*);
  226. int (*db_status)(sqlite3*,int,int*,int*,int);
  227. int (*extended_errcode)(sqlite3*);
  228. void (*log)(int,const char*,...);
  229. sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
  230. const char *(*sourceid)(void);
  231. int (*stmt_status)(sqlite3_stmt*,int,int);
  232. int (*strnicmp)(const char*,const char*,int);
  233. int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
  234. int (*wal_autocheckpoint)(sqlite3*,int);
  235. int (*wal_checkpoint)(sqlite3*,const char*);
  236. void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
  237. int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
  238. int (*vtab_config)(sqlite3*,int op,...);
  239. int (*vtab_on_conflict)(sqlite3*);
  240. /* Version 3.7.16 and later */
  241. int (*close_v2)(sqlite3*);
  242. const char *(*db_filename)(sqlite3*,const char*);
  243. int (*db_readonly)(sqlite3*,const char*);
  244. int (*db_release_memory)(sqlite3*);
  245. const char *(*errstr)(int);
  246. int (*stmt_busy)(sqlite3_stmt*);
  247. int (*stmt_readonly)(sqlite3_stmt*);
  248. int (*stricmp)(const char*,const char*);
  249. int (*uri_boolean)(const char*,const char*,int);
  250. sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
  251. const char *(*uri_parameter)(const char*,const char*);
  252. char *(*xvsnprintf)(int,char*,const char*,va_list);
  253. int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
  254. /* Version 3.8.7 and later */
  255. int (*auto_extension)(void(*)(void));
  256. int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
  257. void(*)(void*));
  258. int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
  259. void(*)(void*),unsigned char);
  260. int (*cancel_auto_extension)(void(*)(void));
  261. int (*load_extension)(sqlite3*,const char*,const char*,char**);
  262. void *(*malloc64)(sqlite3_uint64);
  263. sqlite3_uint64 (*msize)(void*);
  264. void *(*realloc64)(void*,sqlite3_uint64);
  265. void (*reset_auto_extension)(void);
  266. void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
  267. void(*)(void*));
  268. void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
  269. void(*)(void*), unsigned char);
  270. int (*strglob)(const char*,const char*);
  271. /* Version 3.8.11 and later */
  272. sqlite3_value *(*value_dup)(const sqlite3_value*);
  273. void (*value_free)(sqlite3_value*);
  274. int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
  275. int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
  276. /* Version 3.9.0 and later */
  277. unsigned int (*value_subtype)(sqlite3_value*);
  278. void (*result_subtype)(sqlite3_context*,unsigned int);
  279. /* Version 3.10.0 and later */
  280. int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
  281. int (*strlike)(const char*,const char*,unsigned int);
  282. int (*db_cacheflush)(sqlite3*);
  283. /* Version 3.12.0 and later */
  284. int (*system_errno)(sqlite3*);
  285. /* Version 3.14.0 and later */
  286. int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
  287. char *(*expanded_sql)(sqlite3_stmt*);
  288. /* Version 3.18.0 and later */
  289. void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
  290. /* Version 3.20.0 and later */
  291. int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
  292. sqlite3_stmt**,const char**);
  293. int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
  294. sqlite3_stmt**,const void**);
  295. int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));
  296. void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));
  297. void *(*value_pointer)(sqlite3_value*,const char*);
  298. int (*vtab_nochange)(sqlite3_context*);
  299. int (*value_nochange)(sqlite3_value*);
  300. const char *(*vtab_collation)(sqlite3_index_info*,int);
  301. /* Version 3.24.0 and later */
  302. int (*keyword_count)(void);
  303. int (*keyword_name)(int,const char**,int*);
  304. int (*keyword_check)(const char*,int);
  305. sqlite3_str *(*str_new)(sqlite3*);
  306. char *(*str_finish)(sqlite3_str*);
  307. void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);
  308. void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);
  309. void (*str_append)(sqlite3_str*, const char *zIn, int N);
  310. void (*str_appendall)(sqlite3_str*, const char *zIn);
  311. void (*str_appendchar)(sqlite3_str*, int N, char C);
  312. void (*str_reset)(sqlite3_str*);
  313. int (*str_errcode)(sqlite3_str*);
  314. int (*str_length)(sqlite3_str*);
  315. char *(*str_value)(sqlite3_str*);
  316. /* Version 3.25.0 and later */
  317. int (*create_window_function)(sqlite3*,const char*,int,int,void*,
  318. void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  319. void (*xFinal)(sqlite3_context*),
  320. void (*xValue)(sqlite3_context*),
  321. void (*xInv)(sqlite3_context*,int,sqlite3_value**),
  322. void(*xDestroy)(void*));
  323. /* Version 3.26.0 and later */
  324. const char *(*normalized_sql)(sqlite3_stmt*);
  325. /* Version 3.28.0 and later */
  326. int (*stmt_isexplain)(sqlite3_stmt*);
  327. int (*value_frombind)(sqlite3_value*);
  328. /* Version 3.30.0 and later */
  329. int (*drop_modules)(sqlite3*,const char**);
  330. /* Version 3.31.0 and later */
  331. sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
  332. const char *(*uri_key)(const char*,int);
  333. const char *(*filename_database)(const char*);
  334. const char *(*filename_journal)(const char*);
  335. const char *(*filename_wal)(const char*);
  336. /* Version 3.32.0 and later */
  337. const char *(*create_filename)(const char*,const char*,const char*,
  338. int,const char**);
  339. void (*free_filename)(const char*);
  340. sqlite3_file *(*database_file_object)(const char*);
  341. /* Version 3.34.0 and later */
  342. int (*txn_state)(sqlite3*,const char*);
  343. /* Version 3.36.1 and later */
  344. sqlite3_int64 (*changes64)(sqlite3*);
  345. sqlite3_int64 (*total_changes64)(sqlite3*);
  346. /* Version 3.37.0 and later */
  347. int (*autovacuum_pages)(sqlite3*,
  348. unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
  349. void*, void(*)(void*));
  350. /* Version 3.38.0 and later */
  351. int (*error_offset)(sqlite3*);
  352. int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**);
  353. int (*vtab_distinct)(sqlite3_index_info*);
  354. int (*vtab_in)(sqlite3_index_info*,int,int);
  355. int (*vtab_in_first)(sqlite3_value*,sqlite3_value**);
  356. int (*vtab_in_next)(sqlite3_value*,sqlite3_value**);
  357. /* Version 3.39.0 and later */
  358. int (*deserialize)(sqlite3*,const char*,unsigned char*,
  359. sqlite3_int64,sqlite3_int64,unsigned);
  360. unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*,
  361. unsigned int);
  362. const char *(*db_name)(sqlite3*,int);
  363. /* Version 3.40.0 and later */
  364. int (*value_encoding)(sqlite3_value*);
  365. /* Version 3.41.0 and later */
  366. int (*is_interrupted)(sqlite3*);
  367. /* Version 3.43.0 and later */
  368. int (*stmt_explain)(sqlite3_stmt*,int);
  369. /* Version 3.44.0 and later */
  370. void *(*get_clientdata)(sqlite3*,const char*);
  371. int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
  372. };
  373. /*
  374. ** This is the function signature used for all extension entry points. It
  375. ** is also defined in the file "loadext.c".
  376. */
  377. typedef int (*sqlite3_loadext_entry)(
  378. sqlite3 *db, /* Handle to the database. */
  379. char **pzErrMsg, /* Used to set error string on failure. */
  380. const sqlite3_api_routines *pThunk /* Extension API function pointers. */
  381. );
  382. /*
  383. ** The following macros redefine the API routines so that they are
  384. ** redirected through the global sqlite3_api structure.
  385. **
  386. ** This header file is also used by the loadext.c source file
  387. ** (part of the main SQLite library - not an extension) so that
  388. ** it can get access to the sqlite3_api_routines structure
  389. ** definition. But the main library does not want to redefine
  390. ** the API. So the redefinition macros are only valid if the
  391. ** SQLITE_CORE macros is undefined.
  392. */
  393. #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
  394. #define sqlite3_aggregate_context sqlite3_api->aggregate_context
  395. #ifndef SQLITE_OMIT_DEPRECATED
  396. #define sqlite3_aggregate_count sqlite3_api->aggregate_count
  397. #endif
  398. #define sqlite3_bind_blob sqlite3_api->bind_blob
  399. #define sqlite3_bind_double sqlite3_api->bind_double
  400. #define sqlite3_bind_int sqlite3_api->bind_int
  401. #define sqlite3_bind_int64 sqlite3_api->bind_int64
  402. #define sqlite3_bind_null sqlite3_api->bind_null
  403. #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
  404. #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
  405. #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
  406. #define sqlite3_bind_text sqlite3_api->bind_text
  407. #define sqlite3_bind_text16 sqlite3_api->bind_text16
  408. #define sqlite3_bind_value sqlite3_api->bind_value
  409. #define sqlite3_busy_handler sqlite3_api->busy_handler
  410. #define sqlite3_busy_timeout sqlite3_api->busy_timeout
  411. #define sqlite3_changes sqlite3_api->changes
  412. #define sqlite3_close sqlite3_api->close
  413. #define sqlite3_collation_needed sqlite3_api->collation_needed
  414. #define sqlite3_collation_needed16 sqlite3_api->collation_needed16
  415. #define sqlite3_column_blob sqlite3_api->column_blob
  416. #define sqlite3_column_bytes sqlite3_api->column_bytes
  417. #define sqlite3_column_bytes16 sqlite3_api->column_bytes16
  418. #define sqlite3_column_count sqlite3_api->column_count
  419. #define sqlite3_column_database_name sqlite3_api->column_database_name
  420. #define sqlite3_column_database_name16 sqlite3_api->column_database_name16
  421. #define sqlite3_column_decltype sqlite3_api->column_decltype
  422. #define sqlite3_column_decltype16 sqlite3_api->column_decltype16
  423. #define sqlite3_column_double sqlite3_api->column_double
  424. #define sqlite3_column_int sqlite3_api->column_int
  425. #define sqlite3_column_int64 sqlite3_api->column_int64
  426. #define sqlite3_column_name sqlite3_api->column_name
  427. #define sqlite3_column_name16 sqlite3_api->column_name16
  428. #define sqlite3_column_origin_name sqlite3_api->column_origin_name
  429. #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
  430. #define sqlite3_column_table_name sqlite3_api->column_table_name
  431. #define sqlite3_column_table_name16 sqlite3_api->column_table_name16
  432. #define sqlite3_column_text sqlite3_api->column_text
  433. #define sqlite3_column_text16 sqlite3_api->column_text16
  434. #define sqlite3_column_type sqlite3_api->column_type
  435. #define sqlite3_column_value sqlite3_api->column_value
  436. #define sqlite3_commit_hook sqlite3_api->commit_hook
  437. #define sqlite3_complete sqlite3_api->complete
  438. #define sqlite3_complete16 sqlite3_api->complete16
  439. #define sqlite3_create_collation sqlite3_api->create_collation
  440. #define sqlite3_create_collation16 sqlite3_api->create_collation16
  441. #define sqlite3_create_function sqlite3_api->create_function
  442. #define sqlite3_create_function16 sqlite3_api->create_function16
  443. #define sqlite3_create_module sqlite3_api->create_module
  444. #define sqlite3_create_module_v2 sqlite3_api->create_module_v2
  445. #define sqlite3_data_count sqlite3_api->data_count
  446. #define sqlite3_db_handle sqlite3_api->db_handle
  447. #define sqlite3_declare_vtab sqlite3_api->declare_vtab
  448. #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
  449. #define sqlite3_errcode sqlite3_api->errcode
  450. #define sqlite3_errmsg sqlite3_api->errmsg
  451. #define sqlite3_errmsg16 sqlite3_api->errmsg16
  452. #define sqlite3_exec sqlite3_api->exec
  453. #ifndef SQLITE_OMIT_DEPRECATED
  454. #define sqlite3_expired sqlite3_api->expired
  455. #endif
  456. #define sqlite3_finalize sqlite3_api->finalize
  457. #define sqlite3_free sqlite3_api->free
  458. #define sqlite3_free_table sqlite3_api->free_table
  459. #define sqlite3_get_autocommit sqlite3_api->get_autocommit
  460. #define sqlite3_get_auxdata sqlite3_api->get_auxdata
  461. #define sqlite3_get_table sqlite3_api->get_table
  462. #ifndef SQLITE_OMIT_DEPRECATED
  463. #define sqlite3_global_recover sqlite3_api->global_recover
  464. #endif
  465. #define sqlite3_interrupt sqlite3_api->interruptx
  466. #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
  467. #define sqlite3_libversion sqlite3_api->libversion
  468. #define sqlite3_libversion_number sqlite3_api->libversion_number
  469. #define sqlite3_malloc sqlite3_api->malloc
  470. #define sqlite3_mprintf sqlite3_api->mprintf
  471. #define sqlite3_open sqlite3_api->open
  472. #define sqlite3_open16 sqlite3_api->open16
  473. #define sqlite3_prepare sqlite3_api->prepare
  474. #define sqlite3_prepare16 sqlite3_api->prepare16
  475. #define sqlite3_prepare_v2 sqlite3_api->prepare_v2
  476. #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
  477. #define sqlite3_profile sqlite3_api->profile
  478. #define sqlite3_progress_handler sqlite3_api->progress_handler
  479. #define sqlite3_realloc sqlite3_api->realloc
  480. #define sqlite3_reset sqlite3_api->reset
  481. #define sqlite3_result_blob sqlite3_api->result_blob
  482. #define sqlite3_result_double sqlite3_api->result_double
  483. #define sqlite3_result_error sqlite3_api->result_error
  484. #define sqlite3_result_error16 sqlite3_api->result_error16
  485. #define sqlite3_result_int sqlite3_api->result_int
  486. #define sqlite3_result_int64 sqlite3_api->result_int64
  487. #define sqlite3_result_null sqlite3_api->result_null
  488. #define sqlite3_result_text sqlite3_api->result_text
  489. #define sqlite3_result_text16 sqlite3_api->result_text16
  490. #define sqlite3_result_text16be sqlite3_api->result_text16be
  491. #define sqlite3_result_text16le sqlite3_api->result_text16le
  492. #define sqlite3_result_value sqlite3_api->result_value
  493. #define sqlite3_rollback_hook sqlite3_api->rollback_hook
  494. #define sqlite3_set_authorizer sqlite3_api->set_authorizer
  495. #define sqlite3_set_auxdata sqlite3_api->set_auxdata
  496. #define sqlite3_snprintf sqlite3_api->xsnprintf
  497. #define sqlite3_step sqlite3_api->step
  498. #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
  499. #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
  500. #define sqlite3_total_changes sqlite3_api->total_changes
  501. #define sqlite3_trace sqlite3_api->trace
  502. #ifndef SQLITE_OMIT_DEPRECATED
  503. #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
  504. #endif
  505. #define sqlite3_update_hook sqlite3_api->update_hook
  506. #define sqlite3_user_data sqlite3_api->user_data
  507. #define sqlite3_value_blob sqlite3_api->value_blob
  508. #define sqlite3_value_bytes sqlite3_api->value_bytes
  509. #define sqlite3_value_bytes16 sqlite3_api->value_bytes16
  510. #define sqlite3_value_double sqlite3_api->value_double
  511. #define sqlite3_value_int sqlite3_api->value_int
  512. #define sqlite3_value_int64 sqlite3_api->value_int64
  513. #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
  514. #define sqlite3_value_text sqlite3_api->value_text
  515. #define sqlite3_value_text16 sqlite3_api->value_text16
  516. #define sqlite3_value_text16be sqlite3_api->value_text16be
  517. #define sqlite3_value_text16le sqlite3_api->value_text16le
  518. #define sqlite3_value_type sqlite3_api->value_type
  519. #define sqlite3_vmprintf sqlite3_api->vmprintf
  520. #define sqlite3_vsnprintf sqlite3_api->xvsnprintf
  521. #define sqlite3_overload_function sqlite3_api->overload_function
  522. #define sqlite3_prepare_v2 sqlite3_api->prepare_v2
  523. #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
  524. #define sqlite3_clear_bindings sqlite3_api->clear_bindings
  525. #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
  526. #define sqlite3_blob_bytes sqlite3_api->blob_bytes
  527. #define sqlite3_blob_close sqlite3_api->blob_close
  528. #define sqlite3_blob_open sqlite3_api->blob_open
  529. #define sqlite3_blob_read sqlite3_api->blob_read
  530. #define sqlite3_blob_write sqlite3_api->blob_write
  531. #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
  532. #define sqlite3_file_control sqlite3_api->file_control
  533. #define sqlite3_memory_highwater sqlite3_api->memory_highwater
  534. #define sqlite3_memory_used sqlite3_api->memory_used
  535. #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
  536. #define sqlite3_mutex_enter sqlite3_api->mutex_enter
  537. #define sqlite3_mutex_free sqlite3_api->mutex_free
  538. #define sqlite3_mutex_leave sqlite3_api->mutex_leave
  539. #define sqlite3_mutex_try sqlite3_api->mutex_try
  540. #define sqlite3_open_v2 sqlite3_api->open_v2
  541. #define sqlite3_release_memory sqlite3_api->release_memory
  542. #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
  543. #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
  544. #define sqlite3_sleep sqlite3_api->sleep
  545. #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
  546. #define sqlite3_vfs_find sqlite3_api->vfs_find
  547. #define sqlite3_vfs_register sqlite3_api->vfs_register
  548. #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
  549. #define sqlite3_threadsafe sqlite3_api->xthreadsafe
  550. #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
  551. #define sqlite3_result_error_code sqlite3_api->result_error_code
  552. #define sqlite3_test_control sqlite3_api->test_control
  553. #define sqlite3_randomness sqlite3_api->randomness
  554. #define sqlite3_context_db_handle sqlite3_api->context_db_handle
  555. #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
  556. #define sqlite3_limit sqlite3_api->limit
  557. #define sqlite3_next_stmt sqlite3_api->next_stmt
  558. #define sqlite3_sql sqlite3_api->sql
  559. #define sqlite3_status sqlite3_api->status
  560. #define sqlite3_backup_finish sqlite3_api->backup_finish
  561. #define sqlite3_backup_init sqlite3_api->backup_init
  562. #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
  563. #define sqlite3_backup_remaining sqlite3_api->backup_remaining
  564. #define sqlite3_backup_step sqlite3_api->backup_step
  565. #define sqlite3_compileoption_get sqlite3_api->compileoption_get
  566. #define sqlite3_compileoption_used sqlite3_api->compileoption_used
  567. #define sqlite3_create_function_v2 sqlite3_api->create_function_v2
  568. #define sqlite3_db_config sqlite3_api->db_config
  569. #define sqlite3_db_mutex sqlite3_api->db_mutex
  570. #define sqlite3_db_status sqlite3_api->db_status
  571. #define sqlite3_extended_errcode sqlite3_api->extended_errcode
  572. #define sqlite3_log sqlite3_api->log
  573. #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
  574. #define sqlite3_sourceid sqlite3_api->sourceid
  575. #define sqlite3_stmt_status sqlite3_api->stmt_status
  576. #define sqlite3_strnicmp sqlite3_api->strnicmp
  577. #define sqlite3_unlock_notify sqlite3_api->unlock_notify
  578. #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
  579. #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
  580. #define sqlite3_wal_hook sqlite3_api->wal_hook
  581. #define sqlite3_blob_reopen sqlite3_api->blob_reopen
  582. #define sqlite3_vtab_config sqlite3_api->vtab_config
  583. #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
  584. /* Version 3.7.16 and later */
  585. #define sqlite3_close_v2 sqlite3_api->close_v2
  586. #define sqlite3_db_filename sqlite3_api->db_filename
  587. #define sqlite3_db_readonly sqlite3_api->db_readonly
  588. #define sqlite3_db_release_memory sqlite3_api->db_release_memory
  589. #define sqlite3_errstr sqlite3_api->errstr
  590. #define sqlite3_stmt_busy sqlite3_api->stmt_busy
  591. #define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
  592. #define sqlite3_stricmp sqlite3_api->stricmp
  593. #define sqlite3_uri_boolean sqlite3_api->uri_boolean
  594. #define sqlite3_uri_int64 sqlite3_api->uri_int64
  595. #define sqlite3_uri_parameter sqlite3_api->uri_parameter
  596. #define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf
  597. #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
  598. /* Version 3.8.7 and later */
  599. #define sqlite3_auto_extension sqlite3_api->auto_extension
  600. #define sqlite3_bind_blob64 sqlite3_api->bind_blob64
  601. #define sqlite3_bind_text64 sqlite3_api->bind_text64
  602. #define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
  603. #define sqlite3_load_extension sqlite3_api->load_extension
  604. #define sqlite3_malloc64 sqlite3_api->malloc64
  605. #define sqlite3_msize sqlite3_api->msize
  606. #define sqlite3_realloc64 sqlite3_api->realloc64
  607. #define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
  608. #define sqlite3_result_blob64 sqlite3_api->result_blob64
  609. #define sqlite3_result_text64 sqlite3_api->result_text64
  610. #define sqlite3_strglob sqlite3_api->strglob
  611. /* Version 3.8.11 and later */
  612. #define sqlite3_value_dup sqlite3_api->value_dup
  613. #define sqlite3_value_free sqlite3_api->value_free
  614. #define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
  615. #define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
  616. /* Version 3.9.0 and later */
  617. #define sqlite3_value_subtype sqlite3_api->value_subtype
  618. #define sqlite3_result_subtype sqlite3_api->result_subtype
  619. /* Version 3.10.0 and later */
  620. #define sqlite3_status64 sqlite3_api->status64
  621. #define sqlite3_strlike sqlite3_api->strlike
  622. #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
  623. /* Version 3.12.0 and later */
  624. #define sqlite3_system_errno sqlite3_api->system_errno
  625. /* Version 3.14.0 and later */
  626. #define sqlite3_trace_v2 sqlite3_api->trace_v2
  627. #define sqlite3_expanded_sql sqlite3_api->expanded_sql
  628. /* Version 3.18.0 and later */
  629. #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid
  630. /* Version 3.20.0 and later */
  631. #define sqlite3_prepare_v3 sqlite3_api->prepare_v3
  632. #define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3
  633. #define sqlite3_bind_pointer sqlite3_api->bind_pointer
  634. #define sqlite3_result_pointer sqlite3_api->result_pointer
  635. #define sqlite3_value_pointer sqlite3_api->value_pointer
  636. /* Version 3.22.0 and later */
  637. #define sqlite3_vtab_nochange sqlite3_api->vtab_nochange
  638. #define sqlite3_value_nochange sqlite3_api->value_nochange
  639. #define sqlite3_vtab_collation sqlite3_api->vtab_collation
  640. /* Version 3.24.0 and later */
  641. #define sqlite3_keyword_count sqlite3_api->keyword_count
  642. #define sqlite3_keyword_name sqlite3_api->keyword_name
  643. #define sqlite3_keyword_check sqlite3_api->keyword_check
  644. #define sqlite3_str_new sqlite3_api->str_new
  645. #define sqlite3_str_finish sqlite3_api->str_finish
  646. #define sqlite3_str_appendf sqlite3_api->str_appendf
  647. #define sqlite3_str_vappendf sqlite3_api->str_vappendf
  648. #define sqlite3_str_append sqlite3_api->str_append
  649. #define sqlite3_str_appendall sqlite3_api->str_appendall
  650. #define sqlite3_str_appendchar sqlite3_api->str_appendchar
  651. #define sqlite3_str_reset sqlite3_api->str_reset
  652. #define sqlite3_str_errcode sqlite3_api->str_errcode
  653. #define sqlite3_str_length sqlite3_api->str_length
  654. #define sqlite3_str_value sqlite3_api->str_value
  655. /* Version 3.25.0 and later */
  656. #define sqlite3_create_window_function sqlite3_api->create_window_function
  657. /* Version 3.26.0 and later */
  658. #define sqlite3_normalized_sql sqlite3_api->normalized_sql
  659. /* Version 3.28.0 and later */
  660. #define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
  661. #define sqlite3_value_frombind sqlite3_api->value_frombind
  662. /* Version 3.30.0 and later */
  663. #define sqlite3_drop_modules sqlite3_api->drop_modules
  664. /* Version 3.31.0 and later */
  665. #define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
  666. #define sqlite3_uri_key sqlite3_api->uri_key
  667. #define sqlite3_filename_database sqlite3_api->filename_database
  668. #define sqlite3_filename_journal sqlite3_api->filename_journal
  669. #define sqlite3_filename_wal sqlite3_api->filename_wal
  670. /* Version 3.32.0 and later */
  671. #define sqlite3_create_filename sqlite3_api->create_filename
  672. #define sqlite3_free_filename sqlite3_api->free_filename
  673. #define sqlite3_database_file_object sqlite3_api->database_file_object
  674. /* Version 3.34.0 and later */
  675. #define sqlite3_txn_state sqlite3_api->txn_state
  676. /* Version 3.36.1 and later */
  677. #define sqlite3_changes64 sqlite3_api->changes64
  678. #define sqlite3_total_changes64 sqlite3_api->total_changes64
  679. /* Version 3.37.0 and later */
  680. #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages
  681. /* Version 3.38.0 and later */
  682. #define sqlite3_error_offset sqlite3_api->error_offset
  683. #define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value
  684. #define sqlite3_vtab_distinct sqlite3_api->vtab_distinct
  685. #define sqlite3_vtab_in sqlite3_api->vtab_in
  686. #define sqlite3_vtab_in_first sqlite3_api->vtab_in_first
  687. #define sqlite3_vtab_in_next sqlite3_api->vtab_in_next
  688. /* Version 3.39.0 and later */
  689. #ifndef SQLITE_OMIT_DESERIALIZE
  690. #define sqlite3_deserialize sqlite3_api->deserialize
  691. #define sqlite3_serialize sqlite3_api->serialize
  692. #endif
  693. #define sqlite3_db_name sqlite3_api->db_name
  694. /* Version 3.40.0 and later */
  695. #define sqlite3_value_encoding sqlite3_api->value_encoding
  696. /* Version 3.41.0 and later */
  697. #define sqlite3_is_interrupted sqlite3_api->is_interrupted
  698. /* Version 3.43.0 and later */
  699. #define sqlite3_stmt_explain sqlite3_api->stmt_explain
  700. /* Version 3.44.0 and later */
  701. #define sqlite3_get_clientdata sqlite3_api->get_clientdata
  702. #define sqlite3_set_clientdata sqlite3_api->set_clientdata
  703. #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
  704. #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
  705. /* This case when the file really is being compiled as a loadable
  706. ** extension */
  707. # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
  708. # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
  709. # define SQLITE_EXTENSION_INIT3 \
  710. extern const sqlite3_api_routines *sqlite3_api;
  711. #else
  712. /* This case when the file is being statically linked into the
  713. ** application */
  714. # define SQLITE_EXTENSION_INIT1 /*no-op*/
  715. # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
  716. # define SQLITE_EXTENSION_INIT3 /*no-op*/
  717. #endif
  718. #endif /* SQLITE3EXT_H */
  719. #else // USE_LIBSQLITE3
  720. // If users really want to link against the system sqlite3 we
  721. // need to make this file a noop.
  722. #endif