Classes | Namespaces | Macros | Typedefs | Enumerations
BeSQLite.h File Reference
#include <Bentley/Bentley.h>
#include <Bentley/bset.h>
#include <list>
#include <type_traits>
#include <Logging/bentleylogging.h>
#include <Bentley/BeFile.h>
#include <Bentley/BeThread.h>
#include <Bentley/WString.h>
#include <Bentley/NonCopyableClass.h>
#include <Bentley/bvector.h>
#include <Bentley/bmap.h>
#include <Bentley/RefCounted.h>
#include <Bentley/DateTime.h>
#include <Bentley/BeVersion.h>

Go to the source code of this file.

Classes

struct  BeGuid
 A 16-byte Globally Unique Id. A value of all zeros means "Invalid Id". More...
 
struct  BeBriefcaseId
 A unique Id for a BeBriefcase (a particular copy of a BeSQLite::Db is referred to as a BeBriefcase.) Whenever more than one BeBriefcase of a the same Db exists, each of them must have a unique identifier to facilitate change merging via BeBriefcaseBasedId's. More...
 
struct  ProfileVersion
 A 4-digit number that specifies the version of the "profile" (schema) of a Db. More...
 
struct  BeSQLiteLib
 
struct  BeSQLiteLib::ILanguageSupport
 This is an interface class that allows applications to provide custom language processing for SQL case and collation operations. More...
 
struct  BeSQLiteLib::ILanguageSupport::CollationEntry
 Describes a custom collator to register. More...
 
struct  Statement
 A wrapper for a SQLite Prepared Statement. More...
 
struct  StatementDiagnostics
 Class to turn on/off diagnostics for BeSQLite::Statement. More...
 
struct  BlobIO
 A Blob handle for incremental I/O. See sqlite3_blob_open for details. More...
 
struct  DbValue
 A "value" from a BeSQLite function. More...
 
struct  DbDupValue
 A duplicated "value" from a BeSQLite function. More...
 
struct  DbFunction
 A user-defined function that can be added to a Db connection and then used in SQL. More...
 
struct  DbFunction::Context
 The "context" supplied to DbFunctions that can be used to set result values. More...
 
struct  ScalarFunction
 A user-defined scalar function. More...
 
struct  AggregateFunction
 A user-defined aggregate function. More...
 
struct  RTreeMatchFunction
 A user-defined implementation of the SQLite sqlite3_rtree_query_callback function for using the MATCH keyword for RTree queries. More...
 
struct  RTreeMatchFunction::QueryInfo
 This is a copy of sqlite3_rtree_query_info. More...
 
struct  VirtualSet
 This interface should be implemented to supply the first argument to the BeSQLite function "InVirtualSet". More...
 
struct  SqlPrintfString
 Wraps sqlite3_mprintf. Adds convenience that destructor frees memory. More...
 
struct  BeDbMutex
 Holds a mutex to synchronize multi-thread access to data. More...
 
struct  BeDbMutexHolder
 A convenience class for acquiring and releasing a mutex lock. Lock is acquired on construction and released on destruction. More...
 
struct  CachedStatement
 A reference-counted Statement. Statement is freed when last reference is Released. More...
 
struct  StatementCache
 A cache of SharedStatements that can be reused without re-Preparing. More...
 
struct  NamedParams
 Values that can be bound to named parameters of an SQL statement. More...
 
struct  NamedParams::SqlParameter
 
struct  DbTableIterator
 Base class for an Iterator of a BeSQLite::Db table. More...
 
struct  DbTableIterator::Entry
 
struct  ICompressProgressTracker
 Defines a callback for providing information on the progress of a compress or decompress operation. More...
 
struct  Savepoint
 Savepoint encapsulates SQLite transactions against a BeSQLite::Db. More...
 
struct  PropertySpec
 Every BeSQLite::Db has a table for storing "Properties". More...
 
struct  BusyRetry
 Supply a BusyRetry handler to BeSQLite (see https://www.sqlite.org/c3ref/busy_handler.html). More...
 
struct  DbFile
 A physical Db file. More...
 
struct  Db
 A BeSQLite database file. More...
 
struct  Db::OpenParams
 Parameters for controlling aspects of the opening of a Db. More...
 
struct  Db::CreateParams
 Parameters for controlling aspects of creating and then opening a Db. More...
 
struct  Db::AppData
 Applications subclass from this class to store in-memory data on a Db via AddAppData. More...
 
struct  Db::AppData::Key
 
struct  SnappyToBlob
 Utility to compress and write data to a blob using "Snappy" compression. More...
 
struct  SnappyReader
 
struct  SnappyFromMemory
 Utility to read Snappy-compressed data from memory, typically from an image of a blob. More...
 
struct  SnappyFromBlob
 Utility to read Snappy-compressed data from a blob in a database. More...
 
struct  PropSpec
 A property specification for the "be_Db" namespace. More...
 
struct  Properties
 The names of properties in the "be_Db" namespace. More...
 
struct  LzmaUtility
 Utility to compress/decompress Db-s. More...
 

Namespaces

 BentleyApi::BeSQLite
 Classes used to access a SQLite database.
 
 Bentley
 The Bentley namespace contains types defined by the Bentley Library.
 
 Bentley::BeSQLite
 

Macros

#define BE_SQLITE_EXPORT   IMPORT_ATTRIBUTE
 
#define TEMP_TABLE_Prefix   "temp."
 
#define TEMP_TABLE(name)   TEMP_TABLE_Prefix name
 
#define TEMP_TABLE_UniquePrefix   TEMP_TABLE_Prefix "t_"
 
#define TEMP_TABLE_UNIQUE(name)   TEMP_TABLE_UniquePrefix name
 
#define BEDB_TABLE_Local   "be_Local"
 
#define BEDB_TABLE_Property   "be_Prop"
 
#define BEDB_TABLE_EmbeddedFile   "be_EmbedFile"
 
#define BEDB_MemoryDb   ":memory:"
 
#define BEGIN_BENTLEY_SQLITE_NAMESPACE   BEGIN_BENTLEY_NAMESPACE namespace BeSQLite {
 
#define END_BENTLEY_SQLITE_NAMESPACE   } END_BENTLEY_NAMESPACE
 
#define USING_NAMESPACE_BENTLEY_SQLITE   using namespace Bentley::BeSQLite;
 
#define UNUSED_VARIABLE(x)   (void)(x)
 
#define BESQLITE_TYPEDEFS(_name_)   BEGIN_BENTLEY_SQLITE_NAMESPACE DEFINE_POINTER_SUFFIX_TYPEDEFS(_name_) END_BENTLEY_SQLITE_NAMESPACE
 
#define DIAGNOSTICS_PREPARE_LOGGER_NAME   L"Diagnostics.BeSQLite.Prepare"
 
#define DIAGNOSTICS_QUERYPLAN_LOGGER_NAME   L"Diagnostics.BeSQLite.QueryPlan"
 
#define DIAGNOSTICS_QUERYPLANWITHTABLESCANS_LOGGER_NAME   L"Diagnostics.BeSQLite.QueryPlanWithTableScans"
 
#define STATEMENT_DIAGNOSTICS_ON   StatementDiagnostics::SetIsEnabled(true);
 
#define STATEMENT_DIAGNOSTICS_OFF   StatementDiagnostics::SetIsEnabled(false);
 
#define STATEMENT_DIAGNOSTICS_LOGCOMMENT(comment)   StatementDiagnostics::LogComment(comment)
 
#define SQLITE_FORMAT_SIGNATURE   "SQLite format 3"
 
#define DOWNLOAD_FORMAT_SIGNATURE   "Download SQLite"
 
#define SQLZLIB_FORMAT_SIGNATURE   "ZV-zlib"
 
#define SQLSNAPPY_FORMAT_SIGNATURE   "ZV-snappy"
 
#define BEDB_PROPSPEC_NAMESPACE   "be_Db"
 
#define BEDB_PROPSPEC_EMBEDBLOB_NAME   "EmbdBlob"
 

Typedefs

typedef BeGuid * BeGuidP
 
typedef BeGuid & BeGuidR
 
typedef BeGuid const * BeGuidCP
 
typedef BeGuid const & BeGuidCR
 
typedef Db * DbP
 
typedef Db & DbR
 
typedef Db const * DbCP
 
typedef Db const & DbCR
 
typedef DbFile * DbFileP
 
typedef DbFile & DbFileR
 
typedef DbFile const * DbFileCP
 
typedef DbFile const & DbFileCR
 
typedef Statement * StatementP
 
typedef Statement & StatementR
 
typedef Statement const * StatementCP
 
typedef Statement const & StatementCR
 
typedef NamedParams * NamedParamsP
 
typedef NamedParams & NamedParamsR
 
typedef NamedParams const * NamedParamsCP
 
typedef NamedParams const & NamedParamsCR
 
typedef RefCountedPtr
< CachedStatement > 
CachedStatementPtr
 
typedef PropertySpec const & PropertySpecCR
 

Enumerations

enum  DbConstants {
  DbUserVersion = 10, NoCompressionLevel = 0, FastCompressionLevel = 1, DefaultCompressionLevel = 3,
  MaxCompressionLevel = 9
}
 
enum  DbProfileValues {
  BEDB_CURRENT_VERSION_Major = 3, BEDB_CURRENT_VERSION_Minor = 1, BEDB_CURRENT_VERSION_Sub1 = 0, BEDB_CURRENT_VERSION_Sub2 = 1,
  BEDB_SUPPORTED_VERSION_Major = BEDB_CURRENT_VERSION_Major, BEDB_SUPPORTED_VERSION_Minor = 0, BEDB_SUPPORTED_VERSION_Sub1 = 0, BEDB_SUPPORTED_VERSION_Sub2 = 0
}
 
enum  DbResult {
  BE_SQLITE_OK = 0, BE_SQLITE_ERROR = 1, BE_SQLITE_INTERNAL = 2, BE_SQLITE_PERM = 3,
  BE_SQLITE_ABORT = 4, BE_SQLITE_BUSY = 5, BE_SQLITE_LOCKED = 6, BE_SQLITE_NOMEM = 7,
  BE_SQLITE_READONLY = 8, BE_SQLITE_INTERRUPT = 9, BE_SQLITE_IOERR = 10, BE_SQLITE_CORRUPT = 11,
  BE_SQLITE_NOTFOUND = 12, BE_SQLITE_FULL = 13, BE_SQLITE_CANTOPEN = 14, BE_SQLITE_PROTOCOL = 15,
  BE_SQLITE_EMPTY = 16, BE_SQLITE_SCHEMA = 17, BE_SQLITE_TOOBIG = 18, BE_SQLITE_CONSTRAINT_BASE = 19,
  BE_SQLITE_MISMATCH = 20, BE_SQLITE_MISUSE = 21, BE_SQLITE_NOLFS = 22, BE_SQLITE_AUTH = 23,
  BE_SQLITE_FORMAT = 24, BE_SQLITE_RANGE = 25, BE_SQLITE_NOTADB = 26, BE_SQLITE_ROW = 100,
  BE_SQLITE_DONE = 101, BE_SQLITE_IOERR_READ = (BE_SQLITE_IOERR | (1<<8)), BE_SQLITE_IOERR_SHORT_READ = (BE_SQLITE_IOERR | (2<<8)), BE_SQLITE_IOERR_WRITE = (BE_SQLITE_IOERR | (3<<8)),
  BE_SQLITE_IOERR_FSYNC = (BE_SQLITE_IOERR | (4<<8)), BE_SQLITE_IOERR_DIR_FSYNC = (BE_SQLITE_IOERR | (5<<8)), BE_SQLITE_IOERR_TRUNCATE = (BE_SQLITE_IOERR | (6<<8)), BE_SQLITE_IOERR_FSTAT = (BE_SQLITE_IOERR | (7<<8)),
  BE_SQLITE_IOERR_UNLOCK = (BE_SQLITE_IOERR | (8<<8)), BE_SQLITE_IOERR_RDLOCK = (BE_SQLITE_IOERR | (9<<8)), BE_SQLITE_IOERR_DELETE = (BE_SQLITE_IOERR | (10<<8)), BE_SQLITE_IOERR_BLOCKED = (BE_SQLITE_IOERR | (11<<8)),
  BE_SQLITE_IOERR_NOMEM = (BE_SQLITE_IOERR | (12<<8)), BE_SQLITE_IOERR_ACCESS = (BE_SQLITE_IOERR | (13<<8)), BE_SQLITE_IOERR_CHECKRESERVEDLOCK = (BE_SQLITE_IOERR | (14<<8)), BE_SQLITE_IOERR_LOCK = (BE_SQLITE_IOERR | (15<<8)),
  BE_SQLITE_IOERR_CLOSE = (BE_SQLITE_IOERR | (16<<8)), BE_SQLITE_IOERR_DIR_CLOSE = (BE_SQLITE_IOERR | (17<<8)), BE_SQLITE_IOERR_SHMOPEN = (BE_SQLITE_IOERR | (18<<8)), BE_SQLITE_IOERR_SHMSIZE = (BE_SQLITE_IOERR | (19<<8)),
  BE_SQLITE_IOERR_SHMLOCK = (BE_SQLITE_IOERR | (20<<8)), BE_SQLITE_IOERR_SHMMAP = (BE_SQLITE_IOERR | (21<<8)), BE_SQLITE_IOERR_SEEK = (BE_SQLITE_IOERR | (22<<8)), BE_SQLITE_IOERR_DELETE_NOENT = (BE_SQLITE_IOERR | (23<<8)),
  BE_SQLITE_ERROR_FileExists = (BE_SQLITE_IOERR | (1<<24)), BE_SQLITE_ERROR_AlreadyOpen = (BE_SQLITE_IOERR | (2<<24)), BE_SQLITE_ERROR_NoPropertyTable = (BE_SQLITE_IOERR | (3<<24)), BE_SQLITE_ERROR_FileNotFound = (BE_SQLITE_IOERR | (4<<24)),
  BE_SQLITE_ERROR_NoTxnActive = (BE_SQLITE_IOERR | (5<<24)), BE_SQLITE_ERROR_BadDbProfile = (BE_SQLITE_IOERR | (6 << 24)), BE_SQLITE_ERROR_InvalidProfileVersion = (BE_SQLITE_IOERR | (7<<24)), BE_SQLITE_ERROR_ProfileUpgradeFailed = (BE_SQLITE_IOERR | (8<<24)),
  BE_SQLITE_ERROR_ProfileUpgradeFailedCannotOpenForWrite = (BE_SQLITE_IOERR | (9<<24)), BE_SQLITE_ERROR_ProfileTooOld = (BE_SQLITE_IOERR | (10<<24)), BE_SQLITE_ERROR_ProfileTooNewForReadWrite = (BE_SQLITE_IOERR | (11<<24)), BE_SQLITE_ERROR_ProfileTooNew = (BE_SQLITE_IOERR | (12<<24)),
  BE_SQLITE_ERROR_ChangeTrackError = (BE_SQLITE_IOERR | (13<<24)), BE_SQLITE_ERROR_InvalidRevisionVersion = (BE_SQLITE_IOERR | (14 << 24)), BE_SQLITE_ERROR_SchemaReadFailed = (BE_SQLITE_IOERR | 15 << 24), BE_SQLITE_ERROR_SchemaNotFound = (BE_SQLITE_ERROR | 16 << 24),
  BE_SQLITE_ERROR_SchemaTooNew = (BE_SQLITE_IOERR | 16 << 24), BE_SQLITE_ERROR_SchemaTooOld = (BE_SQLITE_IOERR | 17 << 24), BE_SQLITE_ERROR_SchemaImportRequired = (BE_SQLITE_IOERR | 18 << 24), BE_SQLITE_ERROR_SchemaLockFailed = (BE_SQLITE_IOERR | 19 << 24),
  BE_SQLITE_ERROR_SchemaImportFailed = (BE_SQLITE_IOERR | 20 << 24), BE_SQLITE_ERROR_SchemaDomainMismatch = (BE_SQLITE_IOERR | 21 << 24), BE_SQLITE_LOCKED_SHAREDCACHE = (BE_SQLITE_LOCKED | (1<<8)), BE_SQLITE_BUSY_RECOVERY = (BE_SQLITE_BUSY | (1<<8)),
  BE_SQLITE_CANTOPEN_NOTEMPDIR = (BE_SQLITE_CANTOPEN | (1<<8)), BE_SQLITE_CANTOPEN_ISDIR = (BE_SQLITE_CANTOPEN | (2<<8)), BE_SQLITE_CANTOPEN_FULLPATH = (BE_SQLITE_CANTOPEN | (3<<8)), BE_SQLITE_CORRUPT_VTAB = (BE_SQLITE_CORRUPT | (1<<8)),
  BE_SQLITE_READONLY_RECOVERY = (BE_SQLITE_READONLY | (1<<8)), BE_SQLITE_READONLY_CANTLOCK = (BE_SQLITE_READONLY | (2<<8)), BE_SQLITE_READONLY_ROLLBACK = (BE_SQLITE_READONLY | (3<<8)), BE_SQLITE_ABORT_ROLLBACK = (BE_SQLITE_ABORT | (2<<8)),
  BE_SQLITE_CONSTRAINT_CHECK = (BE_SQLITE_CONSTRAINT_BASE | (1<<8)), BE_SQLITE_CONSTRAINT_COMMITHOOK = (BE_SQLITE_CONSTRAINT_BASE | (2<<8)), BE_SQLITE_CONSTRAINT_FOREIGNKEY = (BE_SQLITE_CONSTRAINT_BASE | (3<<8)), BE_SQLITE_CONSTRAINT_FUNCTION = (BE_SQLITE_CONSTRAINT_BASE | (4<<8)),
  BE_SQLITE_CONSTRAINT_NOTNULL = (BE_SQLITE_CONSTRAINT_BASE | (5<<8)), BE_SQLITE_CONSTRAINT_PRIMARYKEY = (BE_SQLITE_CONSTRAINT_BASE | (6<<8)), BE_SQLITE_CONSTRAINT_TRIGGER = (BE_SQLITE_CONSTRAINT_BASE | (7<<8)), BE_SQLITE_CONSTRAINT_UNIQUE = (BE_SQLITE_CONSTRAINT_BASE | (8<<8)),
  BE_SQLITE_CONSTRAINT_VTAB = (BE_SQLITE_CONSTRAINT_BASE | (9<<8))
}
 
enum  DbOpcode : int { Delete = 9, Insert = 18, Update = 23 }
 
enum  DbValueType : int {
  IntegerVal = 1, FloatVal = 2, TextVal = 3, BlobVal = 4,
  NullVal = 5
}
 
enum  BeSQLiteTxnMode : int { None =0, Deferred =1, Immediate =2, Exclusive =3 }
 SQLite Transaction modes corresponding to https://www.sqlite.org/lang_transaction.html. More...
 
enum  DefaultTxn : int { No = (int) BeSQLiteTxnMode::None, Yes = (int) BeSQLiteTxnMode::Deferred, Immediate = (int) BeSQLiteTxnMode::Immediate, Exclusive = (int) BeSQLiteTxnMode::Exclusive }
 Determines whether and how the default transaction should be started when a Db is created or opened. More...
 
enum  ZipErrors {
  ZIP_SUCCESS = 0, ZIP_ERROR_BASE = 0x15000, ZIP_ERROR_WRITE_ERROR = ZIP_ERROR_BASE + 0x01, ZIP_ERROR_COMPRESSION_ERROR = ZIP_ERROR_BASE + 0x02,
  ZIP_ERROR_END_OF_DATA = ZIP_ERROR_BASE + 0x03, ZIP_ERROR_BUFFER_FULL = ZIP_ERROR_BASE + 0x04, ZIP_ERROR_BLOB_READ_ERROR = ZIP_ERROR_BASE + 0x05, ZIP_ERROR_FILE_DOES_NOT_EXIST = ZIP_ERROR_BASE + 0x06,
  ZIP_ERROR_CANNOT_OPEN_OUTPUT = ZIP_ERROR_BASE + 0x07, ZIP_ERROR_UNKNOWN = ZIP_ERROR_BASE + 0x08, ZIP_ERROR_BAD_DATA = ZIP_ERROR_BASE + 0x09, ZIP_ERROR_CANNOT_OPEN_INPUT = ZIP_ERROR_BASE + 0x0A,
  ZIP_ERROR_ABORTED = ZIP_ERROR_BASE + 0x0B, ZIP_ERROR_READ_ERROR = ZIP_ERROR_BASE + 0x0C
}
 Error values returned from the ZLib functions. See ZLib documentation for details. More...
 

Macro Definition Documentation

#define BE_SQLITE_EXPORT   IMPORT_ATTRIBUTE
#define BEDB_MemoryDb   ":memory:"
#define BEDB_PROPSPEC_EMBEDBLOB_NAME   "EmbdBlob"
#define BEDB_PROPSPEC_NAMESPACE   "be_Db"
#define BEDB_TABLE_EmbeddedFile   "be_EmbedFile"
#define BEDB_TABLE_Local   "be_Local"
#define BEDB_TABLE_Property   "be_Prop"
#define BEGIN_BENTLEY_SQLITE_NAMESPACE   BEGIN_BENTLEY_NAMESPACE namespace BeSQLite {
#define DIAGNOSTICS_PREPARE_LOGGER_NAME   L"Diagnostics.BeSQLite.Prepare"
#define DIAGNOSTICS_QUERYPLAN_LOGGER_NAME   L"Diagnostics.BeSQLite.QueryPlan"
#define DIAGNOSTICS_QUERYPLANWITHTABLESCANS_LOGGER_NAME   L"Diagnostics.BeSQLite.QueryPlanWithTableScans"
#define DOWNLOAD_FORMAT_SIGNATURE   "Download SQLite"
#define END_BENTLEY_SQLITE_NAMESPACE   } END_BENTLEY_NAMESPACE
#define SQLITE_FORMAT_SIGNATURE   "SQLite format 3"
#define SQLSNAPPY_FORMAT_SIGNATURE   "ZV-snappy"
#define SQLZLIB_FORMAT_SIGNATURE   "ZV-zlib"
#define STATEMENT_DIAGNOSTICS_LOGCOMMENT (   comment)    StatementDiagnostics::LogComment(comment)
#define STATEMENT_DIAGNOSTICS_OFF   StatementDiagnostics::SetIsEnabled(false);
#define STATEMENT_DIAGNOSTICS_ON   StatementDiagnostics::SetIsEnabled(true);
#define TEMP_TABLE (   name)    TEMP_TABLE_Prefix name
#define TEMP_TABLE_Prefix   "temp."
#define TEMP_TABLE_UNIQUE (   name)    TEMP_TABLE_UniquePrefix name
#define TEMP_TABLE_UniquePrefix   TEMP_TABLE_Prefix "t_"
#define UNUSED_VARIABLE (   x)    (void)(x)
#define USING_NAMESPACE_BENTLEY_SQLITE   using namespace Bentley::BeSQLite;

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.