Issue #69: transient text SQL binding

This commit is contained in:
Andrew Bettison 2013-10-03 23:16:02 +09:30
parent 41e18e587d
commit d18e48868d
2 changed files with 15 additions and 0 deletions

View File

@ -303,6 +303,8 @@ enum sqlbind_type {
INT64, // int64_t value INT64, // int64_t value
INT64_TOSTR, // int64_t value INT64_TOSTR, // int64_t value
UINT64_TOSTR, // uint64_t value UINT64_TOSTR, // uint64_t value
TEXT, // const char *text,
TEXT_LEN, // const char *text, int bytes
STATIC_TEXT, // const char *text, STATIC_TEXT, // const char *text,
STATIC_TEXT_LEN, // const char *text, int bytes STATIC_TEXT_LEN, // const char *text, int bytes
STATIC_BLOB, // const void *blob, int bytes STATIC_BLOB, // const void *blob, int bytes

View File

@ -565,6 +565,19 @@ int _sqlite_vbind(struct __sourceloc __whence, int log_level, sqlite_retry_state
BIND_RETRY(sqlite3_bind_text, str, -1, SQLITE_TRANSIENT); BIND_RETRY(sqlite3_bind_text, str, -1, SQLITE_TRANSIENT);
} }
break; break;
case TEXT: {
const char *text = va_arg(ap, const char *);
BIND_DEBUG(TEXT, sqlite3_bind_text, "%s,-1,SQLITE_TRANSIENT", alloca_str_toprint(text));
BIND_RETRY(sqlite3_bind_text, text, -1, SQLITE_TRANSIENT);
}
break;
case TEXT_LEN: {
const char *text = va_arg(ap, const char *);
int bytes = va_arg(ap, int);
BIND_DEBUG(TEXT_LEN, sqlite3_bind_text, "%s,%d,SQLITE_TRANSIENT", alloca_str_toprint(text), bytes);
BIND_RETRY(sqlite3_bind_text, text, bytes, SQLITE_TRANSIENT);
}
break;
case STATIC_TEXT: { case STATIC_TEXT: {
const char *text = va_arg(ap, const char *); const char *text = va_arg(ap, const char *);
BIND_DEBUG(STATIC_TEXT, sqlite3_bind_text, "%s,-1,SQLITE_STATIC", alloca_str_toprint(text)); BIND_DEBUG(STATIC_TEXT, sqlite3_bind_text, "%s,-1,SQLITE_STATIC", alloca_str_toprint(text));