aboutsummaryrefslogtreecommitdiff
path: root/doc.go
diff options
context:
space:
mode:
authorPhilip O'Toole <philip.otoole@yahoo.com>2016-02-23 01:18:14 -0500
committerPhilip O'Toole <philip.otoole@yahoo.com>2016-02-23 01:18:14 -0500
commit3e97a4ca68500045276a2ba7051740bd53e40d06 (patch)
treed984cc8023dffd95fd37fc6ed293ba80f973592a /doc.go
parentMerge pull request #134 from antoine-lizee/patch-1 (diff)
parentMerge pull request #267 from ianlancetaylor/go16 (diff)
downloadgolite-3e97a4ca68500045276a2ba7051740bd53e40d06.tar.gz
golite-3e97a4ca68500045276a2ba7051740bd53e40d06.tar.xz
Merge pull request #1 from mattn/master
Bring master up-to-date
Diffstat (limited to 'doc.go')
-rw-r--r--doc.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/doc.go b/doc.go
index 51364c3..a45d852 100644
--- a/doc.go
+++ b/doc.go
@@ -33,7 +33,7 @@ extension for Regexp matcher operation.
#include <string.h>
#include <stdio.h>
#include <sqlite3ext.h>
-
+
SQLITE_EXTENSION_INIT1
static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv) {
if (argc >= 2) {
@@ -44,7 +44,7 @@ extension for Regexp matcher operation.
int vec[500];
int n, rc;
pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL);
- rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500);
+ rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500);
if (rc <= 0) {
sqlite3_result_error(context, errstr, 0);
return;
@@ -52,7 +52,7 @@ extension for Regexp matcher operation.
sqlite3_result_int(context, 1);
}
}
-
+
#ifdef _WIN32
__declspec(dllexport)
#endif
@@ -91,5 +91,22 @@ you need to hook ConnectHook and get the SQLiteConn.
},
})
+Go SQlite3 Extensions
+
+If you want to register Go functions as SQLite extension functions,
+call RegisterFunction from ConnectHook.
+
+ regex = func(re, s string) (bool, error) {
+ return regexp.MatchString(re, s)
+ }
+ sql.Register("sqlite3_with_go_func",
+ &sqlite3.SQLiteDriver{
+ ConnectHook: func(conn *sqlite3.SQLiteConn) error {
+ return conn.RegisterFunc("regex", regex, true)
+ },
+ })
+
+See the documentation of RegisterFunc for more details.
+
*/
package sqlite3