forked from jonasfj/trilite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trilite.c
61 lines (50 loc) · 1.7 KB
/
trilite.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "vtable.h"
#include "trilite.h"
#include "cursor.h"
#include "config.h"
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1
/** Trigram module */
static const sqlite3_module triliteModule = {
/* iVersion */ 1,
/* xCreate */ triliteCreate,
/* xConnect */ triliteConnect,
/* xBestIndex */ triliteBestIndex,
/* xDisconnect */ triliteDisconnect,
/* xDestroy */ triliteDestroy,
/* xOpen */ triliteOpen,
/* xClose */ triliteClose,
/* xFilter */ triliteFilter,
/* xNext */ triliteNext,
/* xEof */ triliteEof,
/* xColumn */ triliteColumn,
/* xRowid */ triliteRowid,
/* xUpdate */ triliteUpdate,
/* xBegin */ triliteBegin,
/* xSync */ triliteSync,
/* xCommit */ triliteCommit,
/* xRollback */ 0,
/* xFindFunction */ triliteFindFunction,
/* xRename */ triliteRename,
/* Change iVersion before using these fields */
/* xSavepoint */ 0,
/* xRelease */ 0,
/* xRollbackTo */ 0
};
/** Initialize extension, called this from sqlite
* See http://www.sqlite.org/lang_corefunc.html#load_extension */
int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi){
int rc = SQLITE_OK;
/* Initialize the extension API */
SQLITE_EXTENSION_INIT2(pApi);
/* Register place holder for the extents function */
sqlite3_overload_function(db, "extents", 1);
/* Create module */
rc = sqlite3_create_module(db, "trilite", &triliteModule, 0);
return rc;
}
/* Entry point for applications loading this module,
* This will load the module */
void load_trilite_extension(){
sqlite3_auto_extension((void(*)(void))sqlite3_extension_init);
}