$darkmode
Qore SqlUtil Module Reference 1.9.1
AbstractDatabase.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
26 namespace SqlUtil {
29 
30 public:
32 
35  const DatabaseOptions = ...;
36 
37 
39 
42  const CacheOptions = ...;
43 
44 
46 
51  const CallbackOptions = ...;
52 
53 
63  const AC_Unchanged = 0;
64 
66  const AC_Create = 1;
67 
69  const AC_Drop = 2;
70 
72  const AC_Rename = 3;
73 
75  const AC_Modify = 4;
76 
78  const AC_Truncate = 5;
79 
81  const AC_Add = 6;
82 
84  const AC_Recreate = 7;
85 
87  const AC_Insert = 8;
88 
90  const AC_Update = 9;
91 
93  const AC_Delete = 10;
94 
96  const AC_NotFound = 11;
98 
100  const ActionMap = ...;
101 
102 
104  const ActionDescMap = ...;
105 
106 
108  const ActionLetterMap = ...;
109 
110 
112 
118  const CreationOptions = ...;
119 
120 
122 
125  const AlignSchemaOptions = ...;
126 
127 
129 
132  const DropSchemaOptions = ...;
133 
134 
136 
149 
150 
152 
158 
159 
162 
163 
165  const ReclaimSpaceOptions = ...;
166 
167 
168 protected:
171 
172  // AbstractDatabase::getPhysicalSize() return in a case of no data
173  const GET_PHYSICAL_DB_SIZE_NOVAL = -1;
174 
175 public:
176 
178 
183 protected:
184  constructor(AbstractDatasource nds, *hash nopts) ;
185 public:
186 
187 
190 
191 
192  static doOkCallback(*hash<auto> opt, int ac, string type, string name, *string table, *string info);
193 
194 protected:
195  static runInfoCallback(code info_callback, int ac, string type, string name, *string table, *string new_name, *string info);
196 public:
197 
198 
199  static *string doCallback(*hash<auto> opt, *string sql, int ac, string type, string name, *string table, *string new_name, *string info);
200 
201  static list doCallback(*hash<auto> opt, list sql, int ac, string type, string name, *string table, *string new_name, *string info);
202 
204 
215  auto tryExec(string sql);
216 
217 
219 
229  auto tryExecArgs(string sql, *softlist<auto> args);
230 
231 
233 
244  auto tryExecRaw(string sql);
245 
246 
248 
262  list<auto> getAlignSql(hash schema_hash, *hash<auto> opt, *Tables table_cache);
263 
264 
266 
279  list<auto> getDropSchemaSql(hash schema_hash, *hash<auto> opt);
280 
281 
282 protected:
283  list dropSqlUnlocked(string type, hash schema_hash, code get, code make, *hash<auto> opt, string make_arg_type);
284 public:
285 
286 
287 protected:
288  list alignCodeUnlocked(string type, hash schema_hash, code get, code make, *hash<auto> opt, string make_arg_type);
289 public:
290 
291 
293 
309  AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
310 
311 
312  AbstractSequence makeSequenceFromDescription(string name, *hash<auto> sh, *hash<auto> opts);
313 
314 
316 
331  AbstractTable makeTable(string name, hash<auto> desc, *hash<auto> opts);
332 
333 
335 
350  AbstractFunction makeFunction(string name, string src, *hash<auto> opts);
351 
352 
354 
369  AbstractFunction makeProcedure(string name, string src, *hash<auto> opt);
370 
371 
373 
385  bool dropFunctionIfExists(string name, *hash<auto> opt);
386 
387 
389 
401  bool dropProcedureIfExists(string name, *hash<auto> opt);
402 
403 
405 
417  bool dropSequenceIfExists(string name, *hash<auto> opt);
418 
419 
421 
433  bool dropViewIfExists(string name, *hash<auto> opt);
434 
435 
437 
449  bool dropTableIfExists(string name, *hash<auto> opt);
450 
451 
453 
465  *string getDropFunctionSqlIfExists(string name, *hash<auto> opt);
466 
467 
469 
481  *string getDropProcedureSqlIfExists(string name, *hash<auto> opt);
482 
483 
485 
497  *string getDropSequenceSqlIfExists(string name, *hash<auto> opt);
498 
499 
501 
513  *list<auto> getDropTableSqlIfExists(string name, *hash<auto> opt);
514 
515 
516  doDropSql(*softlist l, string type, string name, *hash<auto> opt);
517 
518 
519  bool doDrop(*softlist l, string type, string name, *hash<auto> opt);
520 
521 
523 
535  list<auto> getAlignFunctionSql(AbstractFunction f, *hash<auto> opt);
536 
537 
539 
551  list<auto> getAlignProcedureSql(AbstractFunction f, *hash<auto> opt);
552 
553 
555 
564  *AbstractTable getTable(string name);
565 
566 
568 
578 
579 
581 
593 
594 
596 
608 
609 
611 
620  *AbstractView getView(string name);
621 
622 
624 
633  int getNextSequenceValue(string name);
634 
635 
637 
646  int getCurrentSequenceValue(string name);
647 
648 
650 
660 
661 
664 
665 
668 
669 
672 
673 
675  list<string> listTables();
676 
677 
680 
681 
683  list<string> listFunctions();
684 
685 
688 
689 
691  list<string> listProcedures();
692 
693 
696 
697 
699  list<string> listSequences();
700 
701 
704 
705 
707  list<string> listViews();
708 
709 
712 
713 
715 
725  bool rebuildIndex(string name, *hash<auto> options);
726 
727 
729 
737  bool rebuildIndex(AbstractIndex index, *hash<auto> options);
738 
739 
741 
748  computeStatistics(*hash<auto> options);
749 
750 
752 
759  reclaimSpace(*hash<auto> options);
760 
761 
763 
773 
774 
776 
781 
782 
784 
789 
790 
791 protected:
792  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt);
793 public:
794 
795 
796 protected:
797  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt, string tag);
798 public:
799 
800 
801  static AbstractDatabase getDatabase(AbstractDatasource nds, *hash<auto> opts);
802 
803  static string loadModule(AbstractDatasource nds, *reference<string> drv);
804 
805  static AbstractDatabase getDatabase(string dsstr, *hash<auto> opts);
806 
807  static AbstractDatabase getDatabase(hash<auto> dsh, *hash<auto> opts);
808 
809  static checkDriverOptions(reference<hash<auto>> h, string drv);
810 
812 protected:
813  hash<auto> getDatabaseOptions();
814 public:
815 
816 
818 protected:
819  hash<auto> getCallbackOptions();
820 public:
821 
822 
824 protected:
825  hash<auto> getCreationOptions();
826 public:
827 
828 
830 protected:
831  hash<auto> getCacheOptions();
832 public:
833 
834 
836 protected:
837  hash<auto> getAlignSchemaOptions();
838 public:
839 
840 
842 protected:
843  hash<auto> getDropSchemaOptions();
844 public:
845 
846 
848 protected:
850 public:
851 
852 
854 protected:
856 public:
857 
858 
860 protected:
862 public:
863 
864 
866 protected:
868 public:
869 
870 
872 protected:
874 public:
875 
876 
878 protected:
879  auto tryExecArgsImpl(string sql, *softlist<auto> args);
880 public:
881 
882 
884 protected:
885  auto tryExecRawImpl(string sql);
886 public:
887 
888 
889 protected:
890  abstract string getCreateSqlImpl(list l);
891 public:
892 protected:
893  abstract list<auto> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
894 public:
895 protected:
896  abstract list<auto> getDropSchemaSqlImpl(hash schema_hash, *hash<auto> opt);
897 public:
898 
899 protected:
900  abstract *AbstractSequence getSequenceImpl(string name);
901 public:
902 protected:
903  abstract *AbstractFunction getFunctionImpl(string name);
904 public:
905 protected:
906  abstract *AbstractFunction getProcedureImpl(string name);
907 public:
908 protected:
909  abstract *AbstractView getViewImpl(string name);
910 public:
911 
912 protected:
913  abstract AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
914 public:
915 protected:
916  abstract AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
917 public:
918 protected:
919  abstract AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
920 public:
921 
922 protected:
923  abstract list<string> featuresImpl();
924 public:
925 protected:
926  abstract list<string> listTablesImpl();
927 public:
928 protected:
929  abstract list<string> listFunctionsImpl();
930 public:
931 protected:
932  abstract list<string> listProceduresImpl();
933 public:
934 protected:
935  abstract list<string> listSequencesImpl();
936 public:
937 protected:
938  abstract list<string> listViewsImpl();
939 public:
940 
942 protected:
943  abstract int getNextSequenceValueImpl(string name);
944 public:
946 protected:
947  abstract int getCurrentSequenceValueImpl(string name);
948 public:
949 
951 protected:
952  abstract bool supportsSequencesImpl();
953 public:
954 protected:
955  abstract bool supportsPackagesImpl();
956 public:
957 protected:
958  abstract bool supportsTypesImpl();
959 public:
960 
961 protected:
962  abstract bool rebuildIndexImpl(string name, *hash<auto> options);
963 public:
964 protected:
965  abstract computeStatisticsImpl(*hash<auto> options);
966 public:
967 protected:
968  abstract reclaimSpaceImpl(*hash<auto> options);
969 public:
970 protected:
971  abstract int getPhysicalSizeImpl();
972 public:
973 };
974 };
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
bool dropProcedureIfExists(string name, *hash< auto > opt)
drops the given procedure if it exists; returns True if the procedure was dropped,...
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...
list< string > listTables()
returns a list of string table names in the database
hash< auto > getAlignSchemaOptions()
override in subclasses to return driver-specific options
const CacheOptions
generic cache options
Definition: AbstractDatabase.qc.dox.h:42
hash< auto > getCacheOptions()
override in subclasses to return driver-specific options
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
hash< auto > getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
bool rebuildIndex(AbstractIndex index, *hash< auto > options)
Rebuild an index in the DB.
*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...
list features()
See DB Features Constants.
*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.
hash< auto > getCreationOptions()
override in subclasses to return driver-specific options
hash< auto > getSequenceDescriptionOptions()
override in subclasses to return driver-specific options
list< string > listProcedures()
returns a list of string procedure names in the database
list< string > listFunctions()
returns a list of string function names in the database
const ActionMap
maps from action codes to action descriptions
Definition: AbstractDatabase.qc.dox.h:100
list< string > listViews()
returns a list of string view names in the database
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
int getPhysicalSize()
Get the current database physical size in bytes.
list< string > listSequences()
returns a list of string sequence names in the database
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
bool supportsPackages()
returns True if the database supports packages
const ActionDescMap
maps from action descriptions to action codes
Definition: AbstractDatabase.qc.dox.h:104
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...
const ComputeStatisticsOptions
Options for computeStatistics()
Definition: AbstractDatabase.qc.dox.h:161
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...
reclaimSpace(*hash< auto > options)
Reclaim taken but unused space in the DB.
bool rebuildIndex(string name, *hash< auto > options)
Rebuild an index in the DB.
hash< auto > getRebuildIndexOptions()
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...
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
abstract bool supportsSequencesImpl()
returns True if the database supports sequences
hash< auto > getReclaimSpaceOptions()
override in subclasses to return driver-specific options
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
hash< auto > getCallbackOptions()
override in subclasses to return driver-specific options
hash< auto > getComputeStatisticsOptions()
override in subclasses to return driver-specific options
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 > getDatabaseOptions()
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
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
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...
hash< auto > getDropSchemaOptions()
override in subclasses to return driver-specific options
constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
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...
*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
const SequenceDescriptionOptions
default generic sequence description keys
Definition: AbstractDatabase.qc.dox.h:157
base class for functions
Definition: SqlUtil.qm.dox.h:7085
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:6546
base class for sequences
Definition: SqlUtil.qm.dox.h:6968
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
the base abstract class for the table implementation
Definition: AbstractTable.qc.dox.h:30
base class for views
Definition: SqlUtil.qm.dox.h:7004
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:6098
const False
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
int index(softstring str, softstring substr, softint pos=0)
hash< auto > hash(object obj)
string type(auto arg)
list< auto > list(...)
number number(softnumber n)
Qore AbstractDatabase class definition.
Definition: AbstractDatabase.qc.dox.h:26