aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorTetsuya Morimoto <tetsuya.morimoto@gmail.com>2017-07-17 21:29:07 +0900
committerTetsuya Morimoto <tetsuya.morimoto@gmail.com>2017-11-05 08:19:06 +0900
commitd785b8f8121cfc3d44df753b0c8c2c1cc26d0af1 (patch)
treed90d0309b7dcf7a90f58403f0f866c295bda10eb /sqlite3.go
parentMerge pull request #471 from msoap/patch-1 (diff)
downloadgolite-d785b8f8121cfc3d44df753b0c8c2c1cc26d0af1.tar.gz
golite-d785b8f8121cfc3d44df753b0c8c2c1cc26d0af1.tar.xz
support sqlite3_limit to get/set run time limit
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 1ff58c3..bcb6da0 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -827,6 +827,36 @@ func (c *SQLiteConn) prepare(ctx context.Context, query string) (driver.Stmt, er
return ss, nil
}
+// Run-Time Limit Categories.
+// See: http://www.sqlite.org/c3ref/c_limit_attached.html
+const (
+ SQLITE_LIMIT_LENGTH = C.SQLITE_LIMIT_LENGTH
+ SQLITE_LIMIT_SQL_LENGTH = C.SQLITE_LIMIT_SQL_LENGTH
+ SQLITE_LIMIT_COLUMN = C.SQLITE_LIMIT_COLUMN
+ SQLITE_LIMIT_EXPR_DEPTH = C.SQLITE_LIMIT_EXPR_DEPTH
+ SQLITE_LIMIT_COMPOUND_SELECT = C.SQLITE_LIMIT_COMPOUND_SELECT
+ SQLITE_LIMIT_VDBE_OP = C.SQLITE_LIMIT_VDBE_OP
+ SQLITE_LIMIT_FUNCTION_ARG = C.SQLITE_LIMIT_FUNCTION_ARG
+ SQLITE_LIMIT_ATTACHED = C.SQLITE_LIMIT_ATTACHED
+ SQLITE_LIMIT_LIKE_PATTERN_LENGTH = C.SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+ SQLITE_LIMIT_VARIABLE_NUMBER = C.SQLITE_LIMIT_VARIABLE_NUMBER
+ SQLITE_LIMIT_TRIGGER_DEPTH = C.SQLITE_LIMIT_TRIGGER_DEPTH
+ SQLITE_LIMIT_WORKER_THREADS = C.SQLITE_LIMIT_WORKER_THREADS
+)
+
+// GetLimit returns the current value of a run-time limit.
+// See: sqlite3_limit, http://www.sqlite.org/c3ref/limit.html
+func (c *SQLiteConn) GetLimit(id int) int {
+ return int(C.sqlite3_limit(c.db, C.int(id), -1))
+}
+
+// SetLimit changes the value of a run-time limits.
+// Then this method returns the prior value of the limit.
+// See: sqlite3_limit, http://www.sqlite.org/c3ref/limit.html
+func (c *SQLiteConn) SetLimit(id int, newVal int) int {
+ return int(C.sqlite3_limit(c.db, C.int(id), C.int(newVal)))
+}
+
// Close the statement.
func (s *SQLiteStmt) Close() error {
s.mu.Lock()