mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
The difficulty is that system <sqlite3.h> does not contain the expected declarations, even when SQLite is compiled with SQLITE_ENABLE_SNAPSHOT :-( Since snapshots are not exposed in any public API, we don't bother dealing with availability checks. We just add the missing declarations, and rely on the linker in order to spot eventual errors. This commit is likely to break Linux builds, though.
50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
#ifndef grdb_config_h
|
|
#define grdb_config_h
|
|
|
|
typedef void(*errorLogCallback)(void *pArg, int iErrCode, const char *zMsg);
|
|
|
|
/// Wrapper around sqlite3_config(SQLITE_CONFIG_LOG, ...) which is a variadic
|
|
/// function that can't be used from Swift.
|
|
static inline void registerErrorLogCallback(errorLogCallback callback) {
|
|
sqlite3_config(SQLITE_CONFIG_LOG, callback, 0);
|
|
}
|
|
|
|
#if SQLITE_VERSION_NUMBER >= 3029000
|
|
/// Wrapper around sqlite3_db_config() which is a variadic function that can't
|
|
/// be used from Swift.
|
|
static inline void disableDoubleQuotedStringLiterals(sqlite3 *db) {
|
|
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 0, (void *)0);
|
|
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 0, (void *)0);
|
|
}
|
|
|
|
/// Wrapper around sqlite3_db_config() which is a variadic function that can't
|
|
/// be used from Swift.
|
|
static inline void enableDoubleQuotedStringLiterals(sqlite3 *db) {
|
|
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 1, (void *)0);
|
|
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 1, (void *)0);
|
|
}
|
|
#else
|
|
static inline void disableDoubleQuotedStringLiterals(sqlite3 *db) { }
|
|
static inline void enableDoubleQuotedStringLiterals(sqlite3 *db) { }
|
|
#endif
|
|
|
|
/* Expose missing APIs for easier GRDB development*/
|
|
#ifndef SQLITE_ENABLE_SNAPSHOT
|
|
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
|
|
sqlite3 *db,
|
|
const char *zSchema,
|
|
sqlite3_snapshot **ppSnapshot)
|
|
{
|
|
return SQLITE_MISUSE;
|
|
}
|
|
SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot* ppSnapshot) { }
|
|
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
|
|
sqlite3_snapshot *p1,
|
|
sqlite3_snapshot *p2)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif /* SQLITE_ENABLE_SNAPSHOT */
|
|
|
|
#endif /* grdb_config_h */
|