Rename the wrapper functions to not pollute the sqlite3_* namespace

This commit is contained in:
Mura Li 2018-10-20 23:02:18 +08:00
parent eb08795f52
commit 68e53de11e
2 changed files with 18 additions and 18 deletions

View File

@ -79,37 +79,37 @@ _sqlite3_exec(sqlite3* db, const char* pcmd, long long* rowid, long long* change
} }
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
extern int sqlite3_step_blocking(sqlite3_stmt *stmt); extern int _sqlite3_step_blocking(sqlite3_stmt *stmt);
extern int _sqlite3_step_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes); extern int _sqlite3_step_row_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes);
extern int sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail); extern int _sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail);
static int static int
sqlite3_step_internal(sqlite3_stmt *stmt) _sqlite3_step_internal(sqlite3_stmt *stmt)
{ {
return sqlite3_step_blocking(stmt); return _sqlite3_step_blocking(stmt);
} }
static int static int
_sqlite3_step_internal(sqlite3_stmt* stmt, long long* rowid, long long* changes) _sqlite3_step_row_internal(sqlite3_stmt* stmt, long long* rowid, long long* changes)
{ {
return _sqlite3_step_blocking(stmt, rowid, changes); return _sqlite3_step_row_blocking(stmt, rowid, changes);
} }
static int static int
sqlite3_prepare_v2_internal(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail) _sqlite3_prepare_v2_internal(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail)
{ {
return sqlite3_prepare_v2_blocking(db, zSql, nBytes, ppStmt, pzTail); return _sqlite3_prepare_v2_blocking(db, zSql, nBytes, ppStmt, pzTail);
} }
#else #else
static int static int
sqlite3_step_internal(sqlite3_stmt *stmt) _sqlite3_step_internal(sqlite3_stmt *stmt)
{ {
return sqlite3_step(stmt); return sqlite3_step(stmt);
} }
static int static int
_sqlite3_step_internal(sqlite3_stmt* stmt, long long* rowid, long long* changes) _sqlite3_step_row_internal(sqlite3_stmt* stmt, long long* rowid, long long* changes)
{ {
int rv = sqlite3_step(stmt); int rv = sqlite3_step(stmt);
sqlite3* db = sqlite3_db_handle(stmt); sqlite3* db = sqlite3_db_handle(stmt);
@ -119,7 +119,7 @@ _sqlite3_step_internal(sqlite3_stmt* stmt, long long* rowid, long long* changes)
} }
static int static int
sqlite3_prepare_v2_internal(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail) _sqlite3_prepare_v2_internal(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail)
{ {
return sqlite3_prepare_v2(db, zSql, nBytes, ppStmt, pzTail); return sqlite3_prepare_v2(db, zSql, nBytes, ppStmt, pzTail);
} }
@ -1674,7 +1674,7 @@ func (c *SQLiteConn) prepare(ctx context.Context, query string) (driver.Stmt, er
defer C.free(unsafe.Pointer(pquery)) defer C.free(unsafe.Pointer(pquery))
var s *C.sqlite3_stmt var s *C.sqlite3_stmt
var tail *C.char var tail *C.char
rv := C.sqlite3_prepare_v2_internal(c.db, pquery, -1, &s, &tail) rv := C._sqlite3_prepare_v2_internal(c.db, pquery, -1, &s, &tail)
if rv != C.SQLITE_OK { if rv != C.SQLITE_OK {
return nil, c.lastError() return nil, c.lastError()
} }
@ -1908,7 +1908,7 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
} }
var rowid, changes C.longlong var rowid, changes C.longlong
rv := C._sqlite3_step_internal(s.s, &rowid, &changes) rv := C._sqlite3_step_row_internal(s.s, &rowid, &changes)
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE { if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
err := s.c.lastError() err := s.c.lastError()
C.sqlite3_reset(s.s) C.sqlite3_reset(s.s)
@ -1980,7 +1980,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
if rc.s.closed { if rc.s.closed {
return io.EOF return io.EOF
} }
rv := C.sqlite3_step_internal(rc.s.s) rv := C._sqlite3_step_internal(rc.s.s)
if rv == C.SQLITE_DONE { if rv == C.SQLITE_DONE {
return io.EOF return io.EOF
} }

View File

@ -10,7 +10,7 @@
extern int unlock_notify_wait(sqlite3 *db); extern int unlock_notify_wait(sqlite3 *db);
int int
sqlite3_step_blocking(sqlite3_stmt *stmt) _sqlite3_step_blocking(sqlite3_stmt *stmt)
{ {
int rv; int rv;
sqlite3* db; sqlite3* db;
@ -35,7 +35,7 @@ sqlite3_step_blocking(sqlite3_stmt *stmt)
} }
int int
_sqlite3_step_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes) _sqlite3_step_row_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes)
{ {
int rv; int rv;
sqlite3* db; sqlite3* db;
@ -62,7 +62,7 @@ _sqlite3_step_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes)
} }
int int
sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail) _sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail)
{ {
int rv; int rv;