![]() |
KaliVeda
Toolkit for HIC analysis
|
Modified copy of TSQLiteServer.
The Query(), Exec() and Statement() methods have been modified so that in case an error occurs, it can be retrieved after the call with GetErrorCode() (TSQLiteServer does not store the error codes internally).
The TSQLServer::GetTablesList() method is overridden so that if the database is locked by another process/thread, we try again a maximum of 4 times with a sleep of 50 ms between each attempt.
Definition at line 31 of file KVSQLiteServer.h.
#include <KVSQLiteServer.h>

Public Member Functions | |
| KVSQLiteServer (const char *db, const char *uid=nullptr, const char *pw=nullptr) | |
| ~KVSQLiteServer () | |
| Close SQLite DB. More... | |
| ClassDefOverride (KVSQLiteServer, 0) | |
| void | Close (Option_t *opt="") final |
| Close connection to SQLite DB. More... | |
| Bool_t | Commit () final |
| Int_t | CreateDataBase (const char *dbname) final |
| Int_t | DropDataBase (const char *dbname) final |
| Bool_t | Exec (const char *sql) final |
| TSQLResult * | GetColumns (const char *dbname, const char *table, const char *wild=nullptr) final |
| TSQLResult * | GetDataBases (const char *wild=nullptr) final |
| TSQLTableInfo * | GetTableInfo (const char *tablename) final |
| TSQLResult * | GetTables (const char *dbname, const char *wild=nullptr) final |
| TList * | GetTablesList (const char *wild=nullptr) final |
| Bool_t | HasStatement () const final |
| Bool_t | HasTransactionInFlight () final |
| returns kTRUE when transaction is running More... | |
| bool | IsLocked () const |
| bool | IsOK () const |
| TSQLResult * | Query (const char *sql) final |
| Int_t | Reload () final |
| Bool_t | Rollback () final |
| Int_t | SelectDataBase (const char *dbname) final |
| const char * | ServerInfo () final |
| Return server info, must be deleted by user. More... | |
| Int_t | Shutdown () final |
| Bool_t | StartTransaction () final |
| TSQLStatement * | Statement (const char *sql, Int_t=100) final |
| Produce TSQLiteStatement. More... | |
Public Member Functions inherited from TSQLServer | |
| virtual | ~TSQLServer () |
| virtual void | EnableErrorOutput (Bool_t on=kTRUE) |
| const char * | GetDB () const |
| const char * | GetDBMS () const |
| virtual Int_t | GetErrorCode () const |
| virtual const char * | GetErrorMsg () const |
| const char * | GetHost () const |
| virtual Int_t | GetMaxIdentifierLength () |
| Int_t | GetPort () const |
| virtual Bool_t | HasTable (const char *tablename) |
| TClass * | IsA () const override |
| virtual Bool_t | IsConnected () const |
| virtual Bool_t | IsError () const |
| virtual Int_t | Ping () |
| virtual Bool_t | PingVerify () |
| void | Streamer (TBuffer &) override |
| void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from TObject | |
| TObject () | |
| TObject (const TObject &object) | |
| virtual | ~TObject () |
| void | AbstractMethod (const char *method) const |
| virtual void | AppendPad (Option_t *option="") |
| virtual void | Browse (TBrowser *b) |
| ULong_t | CheckedHash () |
| virtual const char * | ClassName () const |
| virtual void | Clear (Option_t *="") |
| virtual TObject * | Clone (const char *newname="") const |
| virtual Int_t | Compare (const TObject *obj) const |
| virtual void | Copy (TObject &object) const |
| virtual void | Delete (Option_t *option="") |
| virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
| virtual void | Draw (Option_t *option="") |
| virtual void | DrawClass () const |
| virtual TObject * | DrawClone (Option_t *option="") const |
| virtual void | Dump () const |
| virtual void | Error (const char *method, const char *msgfmt,...) const |
| virtual void | Execute (const char *method, const char *params, Int_t *error=nullptr) |
| virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr) |
| virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
| virtual void | Fatal (const char *method, const char *msgfmt,...) const |
| virtual TObject * | FindObject (const char *name) const |
| virtual TObject * | FindObject (const TObject *obj) const |
| virtual Option_t * | GetDrawOption () const |
| virtual const char * | GetIconName () const |
| virtual const char * | GetName () const |
| virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
| virtual Option_t * | GetOption () const |
| virtual const char * | GetTitle () const |
| virtual UInt_t | GetUniqueID () const |
| virtual Bool_t | HandleTimer (TTimer *timer) |
| virtual ULong_t | Hash () const |
| Bool_t | HasInconsistentHash () const |
| virtual void | Info (const char *method, const char *msgfmt,...) const |
| virtual Bool_t | InheritsFrom (const char *classname) const |
| virtual Bool_t | InheritsFrom (const TClass *cl) const |
| virtual void | Inspect () const |
| void | InvertBit (UInt_t f) |
| Bool_t | IsDestructed () const |
| virtual Bool_t | IsEqual (const TObject *obj) const |
| virtual Bool_t | IsFolder () const |
| R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
| virtual Bool_t | IsSortable () const |
| R__ALWAYS_INLINE Bool_t | IsZombie () const |
| virtual void | ls (Option_t *option="") const |
| void | MayNotUse (const char *method) const |
| virtual Bool_t | Notify () |
| void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
| void | operator delete (void *ptr) |
| void | operator delete (void *ptr, void *vp) |
| void | operator delete[] (void *ptr) |
| void | operator delete[] (void *ptr, void *vp) |
| void * | operator new (size_t sz) |
| void * | operator new (size_t sz, void *vp) |
| void * | operator new[] (size_t sz) |
| void * | operator new[] (size_t sz, void *vp) |
| TObject & | operator= (const TObject &rhs) |
| virtual void | Paint (Option_t *option="") |
| virtual void | Pop () |
| virtual void | Print (Option_t *option="") const |
| virtual Int_t | Read (const char *name) |
| virtual void | RecursiveRemove (TObject *obj) |
| void | ResetBit (UInt_t f) |
| virtual void | SaveAs (const char *filename="", Option_t *option="") const |
| virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
| void | SetBit (UInt_t f) |
| void | SetBit (UInt_t f, Bool_t set) |
| virtual void | SetDrawOption (Option_t *option="") |
| virtual void | SetUniqueID (UInt_t uid) |
| void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
| virtual void | SysError (const char *method, const char *msgfmt,...) const |
| R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
| Int_t | TestBits (UInt_t f) const |
| virtual void | UseCurrentStyle () |
| virtual void | Warning (const char *method, const char *msgfmt,...) const |
| virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
| virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const |
Private Attributes | |
| sqlite3 * | fSQLite {nullptr} |
| TString | fSrvInfo |
| Server info string. More... | |
Additional Inherited Members | |
Public Types inherited from TSQLServer | |
| enum | ESQLDataTypes |
Public Types inherited from TObject | |
| enum | EDeprecatedStatusBits |
| enum | EStatusBits |
Static Public Member Functions inherited from TSQLServer | |
| static TClass * | Class () |
| static const char * | Class_Name () |
| static constexpr Version_t | Class_Version () |
| static TSQLServer * | Connect (const char *db, const char *uid, const char *pw) |
| static const char * | DeclFileName () |
| static const char * | GetFloatFormat () |
| static void | SetFloatFormat (const char *fmt="%e") |
Static Public Member Functions inherited from TObject | |
| static TClass * | Class () |
| static const char * | Class_Name () |
| static constexpr Version_t | Class_Version () |
| static const char * | DeclFileName () |
| static Longptr_t | GetDtorOnly () |
| static Bool_t | GetObjectStat () |
| static void | SetDtorOnly (void *obj) |
| static void | SetObjectStat (Bool_t stat) |
Public Attributes inherited from TSQLServer | |
| kSQL_BINARY | |
| kSQL_CHAR | |
| kSQL_DOUBLE | |
| kSQL_FLOAT | |
| kSQL_INTEGER | |
| kSQL_NONE | |
| kSQL_NUMERIC | |
| kSQL_TIMESTAMP | |
| kSQL_VARCHAR | |
Public Attributes inherited from TObject | |
| kBitMask | |
| kCanDelete | |
| kCannotPick | |
| kHasUUID | |
| kInconsistent | |
| kInvalidObject | |
| kIsOnHeap | |
| kIsReferenced | |
| kMustCleanup | |
| kNoContextMenu | |
| kNotDeleted | |
| kObjInCanvas | |
| kOverwrite | |
| kSingleKey | |
| kWriteDelete | |
| kZombie | |
Protected Member Functions inherited from TSQLServer | |
| TSQLServer () | |
| void | ClearError () |
| void | SetError (Int_t code, const char *msg, const char *method=nullptr) |
Protected Member Functions inherited from TObject | |
| virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
| void | MakeZombie () |
Protected Attributes inherited from TSQLServer | |
| TString | fDB |
| Int_t | fErrorCode |
| TString | fErrorMsg |
| Bool_t | fErrorOut |
| TString | fHost |
| Int_t | fPort |
| TString | fType |
Protected Attributes inherited from TObject | |
| kOnlyPrepStep | |
Static Protected Attributes inherited from TSQLServer | |
| static const char * | fgFloatFmt |
| KVSQLiteServer::KVSQLiteServer | ( | const char * | db, |
| const char * | uid = nullptr, |
||
| const char * | pw = nullptr |
||
| ) |
Open a connection to an SQLite DB server. The db arguments should be of the form "sqlite://<database>", e.g.: "sqlite://test.sqlite" or "sqlite://:memory:" for a temporary database in memory. Note that for SQLite versions >= 3.7.7 the full string behind "sqlite://" is handed to sqlite3_open_v2() with SQLITE_OPEN_URI activated, so all URI accepted by it can be used.
Definition at line 40 of file KVSQLiteServer.cxx.
| KVSQLiteServer::~KVSQLiteServer | ( | ) |
Close SQLite DB.
Definition at line 88 of file KVSQLiteServer.cxx.
| KVSQLiteServer::ClassDefOverride | ( | KVSQLiteServer | , |
| 0 | |||
| ) |
Close connection to SQLite DB.
Implements TSQLServer.
Definition at line 102 of file KVSQLiteServer.cxx.
|
finalvirtual |
submit "COMMIT TRANSACTION" query to database return kTRUE, if successful
Reimplemented from TSQLServer.
Definition at line 154 of file KVSQLiteServer.cxx.
|
finalvirtual |
Create a database. Always returns non-zero for SQLite, as it has only one DB per file.
Implements TSQLServer.
Definition at line 407 of file KVSQLiteServer.cxx.
|
finalvirtual |
Drop (i.e. delete) a database. Always returns non-zero for SQLite, as it has only one DB per file.
Implements TSQLServer.
Definition at line 421 of file KVSQLiteServer.cxx.
|
finalvirtual |
Execute SQL command which does not produce any result sets. Returns kTRUE if successful.
Reimplemented from TSQLServer.
Definition at line 216 of file KVSQLiteServer.cxx.
|
finalvirtual |
List all columns in specified table (database argument is ignored). Wild is for wildcarding "t%" list all columns starting with "t". Returns a pointer to a TSQLResult object if successful, 0 otherwise. The result object must be deleted by the user. For SQLite, this fails with wildcard, as the column names are not queryable! If no wildcard is used, the result of PRAGMA table_info(table) is returned, which contains the names in field 1.
Implements TSQLServer.
Definition at line 326 of file KVSQLiteServer.cxx.
|
finalvirtual |
List all available databases. Always returns 0 for SQLite, as only one DB exists per file.
Implements TSQLServer.
Definition at line 255 of file KVSQLiteServer.cxx.
|
finalvirtual |
Produces SQL table info. Object must be deleted by user.
Reimplemented from TSQLServer.
Definition at line 352 of file KVSQLiteServer.cxx.
|
finalvirtual |
List all tables in the specified database. Wild is for wildcarding "t%" list all tables starting with "t". Returns a pointer to a TSQLResult object if successful, 0 otherwise. The result object must be deleted by the user.
Implements TSQLServer.
Definition at line 271 of file KVSQLiteServer.cxx.
|
finalvirtual |
Reimplemented from TSQLServer.
Definition at line 289 of file KVSQLiteServer.cxx.
|
finalvirtual |
We assume prepared statements work for all SQLite-versions. As we actually use the recommended sqlite3_prepare(), or, if possible, sqlite3_prepare_v2(), this already introduces the "compile time check".
Reimplemented from TSQLServer.
Definition at line 475 of file KVSQLiteServer.cxx.
|
finalvirtual |
returns kTRUE when transaction is running
Reimplemented from TSQLServer.
Definition at line 137 of file KVSQLiteServer.cxx.
| bool KVSQLiteServer::IsLocked | ( | ) | const |
Definition at line 545 of file KVSQLiteServer.cxx.
| bool KVSQLiteServer::IsOK | ( | ) | const |
Definition at line 554 of file KVSQLiteServer.cxx.
|
finalvirtual |
Execute SQL command. Result object must be deleted by the user. Returns a pointer to a TSQLResult object if successful, 0 otherwise. The result object must be deleted by the user.
Implements TSQLServer.
Definition at line 181 of file KVSQLiteServer.cxx.
|
finalvirtual |
Reload permission tables. Returns 0 if successful, non-zero otherwise. User must have reload permissions.
Implements TSQLServer.
Definition at line 435 of file KVSQLiteServer.cxx.
|
finalvirtual |
submit "ROLLBACK TRANSACTION" query to database return kTRUE, if successful
Reimplemented from TSQLServer.
Definition at line 167 of file KVSQLiteServer.cxx.
|
finalvirtual |
Select a database. Always returns non-zero for SQLite, as only one DB exists per file.
Implements TSQLServer.
Definition at line 241 of file KVSQLiteServer.cxx.
|
finalvirtual |
Return server info, must be deleted by user.
Implements TSQLServer.
Definition at line 531 of file KVSQLiteServer.cxx.
|
finalvirtual |
Shutdown the database server. Returns 0 if successful, non-zero otherwise. Makes no sense for SQLite, always returns -1.
Implements TSQLServer.
Definition at line 454 of file KVSQLiteServer.cxx.
|
finalvirtual |
submit "BEGIN TRANSACTION" query to database return kTRUE, if successful
Reimplemented from TSQLServer.
Definition at line 124 of file KVSQLiteServer.cxx.
|
finalvirtual |
Produce TSQLiteStatement.
Reimplemented from TSQLServer.
Definition at line 487 of file KVSQLiteServer.cxx.
|
private |
Definition at line 35 of file KVSQLiteServer.h.
|
private |
Server info string.
Definition at line 34 of file KVSQLiteServer.h.