173 const GET_PHYSICAL_DB_SIZE_NOVAL = -1;
192 static doOkCallback(*hash<auto> opt,
int ac,
string type,
string name, *
string table, *
string info);
194 static private runInfoCallback(code info_callback,
int ac,
string type,
string name, *
string table,
195 *
string new_name, *
string info) {
196 bool c = (type ==
"column");
198 name = sprintf(
"%s.%s", table, name);
199 string str = sprintf(
"%s %s %s",
ActionMap{ac}, type, name);
201 str += sprintf(
" %s %s", ac ==
AC_Drop ?
"from" :
"on", table);
203 str += sprintf(
" to %s", new_name);
205 str += sprintf(
" (%s)", info);
206 info_callback(str, ac, type, name, table, new_name, info);
209 static *
string doCallback(*hash<auto> opt, *
string sql,
int ac,
string type,
string name, *
string table,
210 *
string new_name, *
string info) {
213 if (opt.info_callback);
215 if (opt.sql_callback);
220 static list doCallback(*hash<auto> opt, list sql,
int ac,
string type,
string name, *
string table,
221 *
string new_name, *
string info) {
224 if (opt.info_callback);
226 if (opt.sql_callback);
310 private list dropSqlUnlocked(
string type, hash schema_hash, code get, code make, *hash<auto> opt,
311 string make_arg_type) {
317 reference<hash> fmap = \schema_hash{type +
"s"};
318 AbstractDatabase::checkDriverOptions(\fmap, drv);
319 foreach string name in (fmap.keyIterator());
325 private list alignCodeUnlocked(
string type, hash schema_hash, code get, code make, *hash<auto> opt,
326 string make_arg_type) {
334 reference<*hash> fmap = \schema_hash{type +
"_map"};
335 AbstractDatabase::checkDriverOptions(\fmap, drv);
336 HashIterator i(fmap);
341 reference<hash> fh = \schema_hash{
type +
"s"};
342 AbstractDatabase::checkDriverOptions(\fh, drv);
343 foreach string name in (fh.keyIterator());
371 if (!
opts.native_case);
373 return makeSequenceImpl(name, start, increment, end,
opts);
580 doDropSql(*softlist
l,
string type,
string name, *hash<auto> opt);
583 bool doDrop(*softlist
l,
string type,
string name, *hash<auto> opt);
856 validateOptionsIntern(
string err, hash<auto> ropt, reference<hash> opt);
861 validateOptionsIntern(
string err, hash<auto> ropt, reference<hash> opt,
string tag);
867 static string loadModule(AbstractDatasource nds, *reference<string> drv);
869 static string getOdbcDriverName(AbstractDatasource nds);
875 static checkDriverOptions(reference<hash<auto>> h,
string drv);
956 abstract
string getCreateSqlImpl(list
l);
959 abstract list<auto> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
962 abstract list<auto> getDropSchemaSqlImpl(hash schema_hash, *hash<auto> opt);
978 private abstract
AbstractSequence makeSequenceImpl(
string name, number start = 1, number increment = 1,
979 *softnumber end, *hash<auto>
opts);
988 abstract list<string> featuresImpl();
991 abstract list<string> listTablesImpl();
994 abstract list<string> listFunctionsImpl();
997 abstract list<string> listProceduresImpl();
1000 abstract list<string> listSequencesImpl();
1003 abstract list<string> listViewsImpl();
1020 abstract
bool supportsPackagesImpl();
1023 abstract
bool supportsTypesImpl();
1027 abstract
bool rebuildIndexImpl(
string name, *hash<auto> options);
1030 abstract computeStatisticsImpl(*hash<auto> options);
1033 abstract reclaimSpaceImpl(*hash<auto> options);
1036 abstract
int getPhysicalSizeImpl();
the base abstract class for the database implementation
Definition: AbstractDatabase.qc.dox.h:28
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
const CreationOptions
default generic creation options
Definition: AbstractDatabase.qc.dox.h:118
int getNextSequenceValue(string name)
returns the next value in the given sequence
const CallbackOptions
generic callback options
Definition: AbstractDatabase.qc.dox.h:51
hash< auto > getReclaimSpaceOptions()
override in subclasses to return driver-specific options
bool dropProcedureIfExists(string name, *hash< auto > opt)
drops the given procedure if it exists; returns True if the procedure was dropped,...
hash< auto > getRebuildIndexOptions()
override in subclasses to return driver-specific options
const DropSchemaOptions
default generic drop schema options
Definition: AbstractDatabase.qc.dox.h:132
*string getDropSequenceSqlIfExists(string name, *hash< auto > opt)
returns the SQL require to drop the given sequence if it exists or NOTHING if the named sequence does...
const CacheOptions
generic cache options
Definition: AbstractDatabase.qc.dox.h:42
bool supportsTypes()
returns True if the database supports named types
abstract int getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
const SchemaDescriptionOptions
default generic schema description keys
Definition: AbstractDatabase.qc.dox.h:148
list< auto > getAlignSql(hash schema_hash, *hash< auto > opt, *Tables table_cache)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
list< string > listProcedures()
returns a list of string procedure names in the database
hash< auto > getCallbackOptions()
override in subclasses to return driver-specific options
bool rebuildIndex(AbstractIndex index, *hash< auto > options)
Rebuild an index in the DB.
list features()
See DB Features Constants.
hash< auto > getCreationOptions()
override in subclasses to return driver-specific options
*string getDropFunctionSqlIfExists(string name, *hash< auto > opt)
returns the SQL require to drop the given function if it exists or NOTHING if the named function does...
AbstractFunction makeFunction(string name, string src, *hash< auto > opts)
creates a database-specific AbstractFunction object corresponding to the arguments
bool requiresScale()
Returns True if the driver requires a scale to support decimal values in numeric or decimal columns.
const ActionMap
maps from action codes to action descriptions
Definition: AbstractDatabase.qc.dox.h:100
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
list< auto > getAlignProcedureSql(AbstractFunction f, *hash< auto > opt)
returns a list of SQL strings that can be used to update a stored procedure in the database to the st...
int getPhysicalSize()
Get the current database physical size in bytes.
*list< auto > getDropTableSqlIfExists(string name, *hash< auto > opt)
returns the SQL require to drop the given table if it exists or NOTHING if the named table does not e...
AbstractSequence makeSequence(string name, number start=1, number increment=1, *softnumber end, *hash< auto > opts)
creates a database-specific AbstractSequence object corresponding to the arguments
Definition: AbstractDatabase.qc.dox.h:366
bool supportsPackages()
returns True if the database supports packages
const ActionDescMap
maps from action descriptions to action codes
Definition: AbstractDatabase.qc.dox.h:104
const ComputeStatisticsOptions
Options for computeStatistics()
Definition: AbstractDatabase.qc.dox.h:161
hash< auto > getDatabaseOptions()
override in subclasses to return driver-specific options
reclaimSpace(*hash< auto > options)
Reclaim taken but unused space in the DB.
hash< auto > getCacheOptions()
override in subclasses to return driver-specific options
bool rebuildIndex(string name, *hash< auto > options)
Rebuild an index in the DB.
hash< auto > getSequenceDescriptionOptions()
override in subclasses to return driver-specific options
auto tryExecArgs(string sql, *softlist< auto > args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
const AlignSchemaOptions
default generic schema description / alignment options
Definition: AbstractDatabase.qc.dox.h:125
bool native_case
native case option
Definition: AbstractDatabase.qc.dox.h:170
const DatabaseOptions
database options
Definition: AbstractDatabase.qc.dox.h:35
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view cannot be found
bool supportsSequences()
returns True if the database supports sequences
int getCurrentSequenceValue(string name)
returns the last value issued for the given sequence in the current session
computeStatistics(*hash< auto > options)
Compute database statistics.
bool dropTableIfExists(string name, *hash< auto > opt)
drops the given table if it exists; returns True if the table was dropped, False if not
auto tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost
auto tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
hash< auto > getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
abstract bool supportsSequencesImpl()
returns True if the database supports sequences
auto tryExecArgsImpl(string sql, *softlist< auto > args)
tries to execute a command so that if an error occurs the current transaction status is not lost
list< string > listViews()
returns a list of string view names in the database
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
const ReclaimSpaceOptions
Options for reclaimSpace()
Definition: AbstractDatabase.qc.dox.h:165
bool dropViewIfExists(string name, *hash< auto > opt)
drops the given view if it exists; returns True if the view was dropped, False if not
hash< auto > getComputeStatisticsOptions()
override in subclasses to return driver-specific options
int getMaximumPrecision()
Returns the maximum precision for numeric or decimal columns.
bool dropSequenceIfExists(string name, *hash< auto > opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not
AbstractTable makeTable(string name, hash< auto > desc, *hash< auto > opts)
creates a database-specific AbstractTable object corresponding to the arguments
hash< auto > getAlignSchemaOptions()
override in subclasses to return driver-specific options
const ActionLetterMap
maps from action codes to action letter codes
Definition: AbstractDatabase.qc.dox.h:108
abstract int getNextSequenceValueImpl(string name)
returns the next value in the given sequence
AbstractFunction makeProcedure(string name, string src, *hash< auto > opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
list< string > listSequences()
returns a list of string sequence names in the database
auto tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost
list< auto > getAlignFunctionSql(AbstractFunction f, *hash< auto > opt)
returns a list of SQL strings that can be used to update a function in the database to the function d...
*string getDropProcedureSqlIfExists(string name, *hash< auto > opt)
returns the SQL require to drop the given procedure if it exists or NOTHING if the named procedure do...
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
list< string > listFunctions()
returns a list of string function names in the database
constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
list< string > listTables()
returns a list of string table names in the database
list< auto > getDropSchemaSql(hash schema_hash, *hash< auto > opt)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
bool dropFunctionIfExists(string name, *hash< auto > opt)
drops the given function if it exists; returns True if the function was dropped, False if not
hash< auto > getDropSchemaOptions()
override in subclasses to return driver-specific options
const SequenceDescriptionOptions
default generic sequence description keys
Definition: AbstractDatabase.qc.dox.h:157
base class for functions
Definition: SqlUtil.qm.dox.h:7076
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:6537
base class for sequences
Definition: SqlUtil.qm.dox.h:6959
base class for abstract SqlUtil classes
Definition: AbstractSqlUtilBase.qc.dox.h:28
transient Mutex l()
mutex for atomic actions
*hash< auto > opts
option hash
Definition: AbstractSqlUtilBase.qc.dox.h:35
string getDriverName()
returns the database driver name
the base abstract class for the table implementation
Definition: AbstractTable.qc.dox.h:30
base class for views
Definition: SqlUtil.qm.dox.h:6995
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:6088
const AC_NotFound
used when dropping object but the object is not present
Definition: AbstractDatabase.qc.dox.h:96
const AC_Modify
used when an object is modified in place
Definition: AbstractDatabase.qc.dox.h:75
const AC_Add
used when an element is added to an existing object
Definition: AbstractDatabase.qc.dox.h:81
const AC_Recreate
used when an object is recreated (usually dropped and recreated in place)
Definition: AbstractDatabase.qc.dox.h:84
const AC_Update
used when data is updated in a table
Definition: AbstractDatabase.qc.dox.h:90
const AC_Drop
used when an object is dropped
Definition: AbstractDatabase.qc.dox.h:69
const AC_Create
used when a new object is created
Definition: AbstractDatabase.qc.dox.h:66
const AC_Delete
used when data is deleted in a table
Definition: AbstractDatabase.qc.dox.h:93
const AC_Truncate
used when a table is truncated
Definition: AbstractDatabase.qc.dox.h:78
const AC_Unchanged
Definition: AbstractDatabase.qc.dox.h:63
const AC_Insert
used when data is inserted in a table
Definition: AbstractDatabase.qc.dox.h:87
const AC_Rename
used when an object is renamed
Definition: AbstractDatabase.qc.dox.h:72
Qore AbstractDatabase class definition.
Definition: AbstractDatabase.qc.dox.h:26