Documentation Source Text

Check-in [4110cb10fc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the "fts5ext.so" target for building an SQLite extension that enables the sqlite3 command-line shell to access the website search database.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4110cb10fc8acda72386876c71c28b33c4776f8699f1aeabccd041bf6e40814e
User & Date: drh 2017-06-30 00:47:08
Context
2017-07-01
23:23
Attempt to improve the INSERT documentation. check-in: 89ca937f0e user: drh tags: trunk
2017-06-30
00:47
Add the "fts5ext.so" target for building an SQLite extension that enables the sqlite3 command-line shell to access the website search database. check-in: 4110cb10fc user: drh tags: trunk
00:18
Update to the CLI documentation. check-in: e792c53939 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to main.mk.

161
162
163
164
165
166
167




168
169
170
171
	cp $(DOC)/document_header.tcl doc/document_header.tcl
	cp $(DOC)/document_header.tcl doc/search.d/document_header.tcl
	cp $(DOC)/search/search.tcl doc/search
	chmod +x doc/search
	cp $(DOC)/search/search.tcl doc/search.d/admin
	chmod +x doc/search.d/admin





always:	

clean:	
	rm -rf $(TCLSH) doc sqlite3.h







>
>
>
>




161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	cp $(DOC)/document_header.tcl doc/document_header.tcl
	cp $(DOC)/document_header.tcl doc/search.d/document_header.tcl
	cp $(DOC)/search/search.tcl doc/search
	chmod +x doc/search
	cp $(DOC)/search/search.tcl doc/search.d/admin
	chmod +x doc/search.d/admin

fts5ext.so:	$(DOC)/search/fts5ext.c
	gcc -shared -fPIC -I. -DSQLITE_EXT \
		$(DOC)/search/fts5ext.c -o fts5ext.so

always:	

clean:	
	rm -rf $(TCLSH) doc sqlite3.h

Changes to search/fts5ext.c.

4
5
6
7
8
9
10



11
12




13
14

15

16
17
18
19
20
21
22
...
241
242
243
244
245
246
247














248


249
250
251
252
253
254
255
256
257
258
** tokenizer implements the following special features:
**
**   * For all tokens that match the pattern "SQLITE_XXX" (case sensitive),
**     "XXX" is added as a synonym for SQLITE_XXX.
**
**   * For all tokens that match the pattern "sqlite3_xxx" (case sensitive),
**     "xxx" is added as a synonym for sqlite3_xxx.



*/





#include <sqlite3.h>
#include <tcl.h>

#include <string.h>



/*************************************************************************
** This is generic code copied from the FTS5 documentation.
**
** Return a pointer to the fts5_api pointer for database connection db.
** If an error occurs, return NULL and leave an error in the database 
................................................................................
  if( rc==SQLITE_OK ){
    rc = pApi->xCreateFunction(pApi, "srank", 0, srankFunc, 0);
  }

  return rc;
}


















int Fts5ext_Init(Tcl_Interp *interp){
#ifdef USE_TCL_STUBS
  if (Tcl_InitStubs(interp, "8.4", 0) == 0) {
    return TCL_ERROR;
  }
#endif
  sqlite3_auto_extension((void (*)(void))register_tokenizer);
  return TCL_OK;
}








>
>
>


>
>
>
>


>

>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>









|
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
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
** tokenizer implements the following special features:
**
**   * For all tokens that match the pattern "SQLITE_XXX" (case sensitive),
**     "XXX" is added as a synonym for SQLITE_XXX.
**
**   * For all tokens that match the pattern "sqlite3_xxx" (case sensitive),
**     "xxx" is added as a synonym for sqlite3_xxx.
**
** By default, this file builds a TCL extension.  But if the -DSQLITE_EXT
** compile-time option is used, then an SQLite extension is built instead.
*/

#ifdef SQLITE_EXT
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1
#else
#include <sqlite3.h>
#include <tcl.h>
#endif
#include <string.h>
#include <assert.h>


/*************************************************************************
** This is generic code copied from the FTS5 documentation.
**
** Return a pointer to the fts5_api pointer for database connection db.
** If an error occurs, return NULL and leave an error in the database 
................................................................................
  if( rc==SQLITE_OK ){
    rc = pApi->xCreateFunction(pApi, "srank", 0, srankFunc, 0);
  }

  return rc;
}

#ifdef SQLITE_EXT
#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_ftsext_init(
  sqlite3 *db, 
  char **pzErrMsg, 
  const sqlite3_api_routines *pApi
){
  int rc = SQLITE_OK;
  SQLITE_EXTENSION_INIT2(pApi);
  (void)pzErrMsg;  /* Unused parameter */
  rc = register_tokenizer(db, 0, 0);
  return rc;
}

#else
int Fts5ext_Init(Tcl_Interp *interp){
#ifdef USE_TCL_STUBS
  if (Tcl_InitStubs(interp, "8.4", 0) == 0) {
    return TCL_ERROR;
  }
#endif
  sqlite3_auto_extension((void (*)(void))register_tokenizer);
  return TCL_OK;
}
#endif