diff options
author | Tetsuya Morimoto <tetsuya.morimoto@gmail.com> | 2017-07-17 21:29:07 +0900 |
---|---|---|
committer | Tetsuya Morimoto <tetsuya.morimoto@gmail.com> | 2017-11-05 08:19:06 +0900 |
commit | d785b8f8121cfc3d44df753b0c8c2c1cc26d0af1 (patch) | |
tree | d90d0309b7dcf7a90f58403f0f866c295bda10eb /sqlite3.go | |
parent | Merge pull request #471 from msoap/patch-1 (diff) | |
download | golite-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.go | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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() |