Qore SqlUtil Module Reference  1.7.3
AbstractDatabase.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
25 // minimum required Qore version
26 // assume local scope for variables, do not use "$" signs
27 // require type definitions everywhere
29 // enable all warnings
30 
32 namespace SqlUtil {
35 
36 public:
38 
41  const DatabaseOptions = ...;
42 
43 
45 
48  const CacheOptions = ...;
49 
50 
52 
57  const CallbackOptions = ...;
58 
59 
68  const AC_Unchanged = 0;
70 
72  const AC_Create = 1;
73 
75  const AC_Drop = 2;
76 
78  const AC_Rename = 3;
79 
81  const AC_Modify = 4;
82 
84  const AC_Truncate = 5;
85 
87  const AC_Add = 6;
88 
90  const AC_Recreate = 7;
91 
93  const AC_Insert = 8;
94 
96  const AC_Update = 9;
97 
99  const AC_Delete = 10;
100 
102  const AC_NotFound = 11;
104 
106  const ActionMap = ...;
107 
108 
110  const ActionDescMap = ...;
111 
112 
114  const ActionLetterMap = ...;
115 
116 
118 
124  const CreationOptions = ...;
125 
126 
128 
131  const AlignSchemaOptions = ...;
132 
133 
135 
138  const DropSchemaOptions = ...;
139 
140 
142 
155 
156 
158 
164 
165 
168 
169 
171  const ReclaimSpaceOptions = ...;
172 
173 
174 protected:
177 
178  // AbstractDatabase::getPhysicalSize() return in a case of no data
179  const GET_PHYSICAL_DB_SIZE_NOVAL = -1;
180 
181 public:
182 
184 
189 protected:
190  constructor(AbstractDatasource nds, *hash nopts) ;
191 public:
192 
193 
195  list features();
196 
197 
198  static doOkCallback(*hash<auto> opt, int ac, string type, string name, *string table, *string info);
199 
200 protected:
201  static runInfoCallback(code info_callback, int ac, string type, string name, *string table, *string new_name, *string info);
202 public:
203 
204 
205  static *string doCallback(*hash<auto> opt, *string sql, int ac, string type, string name, *string table, *string new_name, *string info);
206 
207  static list doCallback(*hash<auto> opt, list sql, int ac, string type, string name, *string table, *string new_name, *string info);
208 
210 
221  auto tryExec(string sql);
222 
223 
225 
235  auto tryExecArgs(string sql, *softlist<auto> args);
236 
237 
239 
250  auto tryExecRaw(string sql);
251 
252 
254 
268  list<auto> getAlignSql(hash schema_hash, *hash<auto> opt, *Tables table_cache);
269 
270 
272 
285  list<auto> getDropSchemaSql(hash schema_hash, *hash<auto> opt);
286 
287 
288 protected:
289  list dropSqlUnlocked(string type, hash schema_hash, code get, code make, *hash<auto> opt, string make_arg_type);
290 public:
291 
292 
293 protected:
294  list alignCodeUnlocked(string type, hash schema_hash, code get, code make, *hash<auto> opt, string make_arg_type);
295 public:
296 
297 
299 
313  AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
314 
315 
316  AbstractSequence makeSequenceFromDescription(string name, *hash<auto> sh, *hash<auto> opts);
317 
318 
320 
333  AbstractTable makeTable(string name, hash<auto> desc, *hash<auto> opts);
334 
335 
337 
348  AbstractFunction makeFunction(string name, string src, *hash<auto> opts);
349 
350 
352 
363  AbstractFunction makeProcedure(string name, string src, *hash<auto> opt);
364 
365 
367 
379  bool dropFunctionIfExists(string name, *hash<auto> opt);
380 
381 
383 
395  bool dropProcedureIfExists(string name, *hash<auto> opt);
396 
397 
399 
411  bool dropSequenceIfExists(string name, *hash<auto> opt);
412 
413 
415 
427  bool dropViewIfExists(string name, *hash<auto> opt);
428 
429 
431 
443  bool dropTableIfExists(string name, *hash<auto> opt);
444 
445 
447 
459  *string getDropFunctionSqlIfExists(string name, *hash<auto> opt);
460 
461 
463 
475  *string getDropProcedureSqlIfExists(string name, *hash<auto> opt);
476 
477 
479 
491  *string getDropSequenceSqlIfExists(string name, *hash<auto> opt);
492 
493 
495 
507  *list<auto> getDropTableSqlIfExists(string name, *hash<auto> opt);
508 
509 
510  doDropSql(*softlist l, string type, string name, *hash<auto> opt);
511 
512 
513  bool doDrop(*softlist l, string type, string name, *hash<auto> opt);
514 
515 
517 
529  list<auto> getAlignFunctionSql(AbstractFunction f, *hash<auto> opt);
530 
531 
533 
545  list<auto> getAlignProcedureSql(AbstractFunction f, *hash<auto> opt);
546 
547 
549 
558  *AbstractTable getTable(string name);
559 
560 
562 
571  *AbstractSequence getSequence(string name);
572 
573 
575 
586  *AbstractFunction getFunction(string name);
587 
588 
590 
601  *AbstractFunction getProcedure(string name);
602 
603 
605 
614  *AbstractView getView(string name);
615 
616 
618 
627  int getNextSequenceValue(string name);
628 
629 
631 
640  int getCurrentSequenceValue(string name);
641 
642 
644 
653  string getSqlFromList(list l);
654 
655 
657  bool supportsSequences();
658 
659 
661  bool supportsTypes();
662 
663 
665  bool supportsPackages();
666 
667 
669  list<string> listTables();
670 
671 
674 
675 
677  list<string> listFunctions();
678 
679 
682 
683 
685  list<string> listProcedures();
686 
687 
690 
691 
693  list<string> listSequences();
694 
695 
698 
699 
701  list<string> listViews();
702 
703 
706 
707 
709 
719  bool rebuildIndex(string name, *hash<auto> options);
720 
721 
723 
731  bool rebuildIndex(AbstractIndex index, *hash<auto> options);
732 
733 
735 
742  computeStatistics(*hash<auto> options);
743 
744 
746 
753  reclaimSpace(*hash<auto> options);
754 
755 
757 
766  int getPhysicalSize();
767 
768 
769 protected:
770  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt);
771 public:
772 
773 
774 protected:
775  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt, string tag);
776 public:
777 
778 
779  static AbstractDatabase getDatabase(AbstractDatasource nds, *hash<auto> opts);
780 
781  static AbstractDatabase getDatabase(string dsstr, *hash<auto> opts);
782 
783  static AbstractDatabase getDatabase(hash<auto> dsh, *hash<auto> opts);
784 
785  static checkDriverOptions(reference<hash> h, string drv);
786 
788 protected:
789  hash<auto> getDatabaseOptions();
790 public:
791 
792 
794 protected:
795  hash<auto> getCallbackOptions();
796 public:
797 
798 
800 protected:
801  hash<auto> getCreationOptions();
802 public:
803 
804 
806 protected:
807  hash<auto> getCacheOptions();
808 public:
809 
810 
812 protected:
813  hash<auto> getAlignSchemaOptions();
814 public:
815 
816 
818 protected:
819  hash<auto> getDropSchemaOptions();
820 public:
821 
822 
824 protected:
825  hash<auto> getSchemaDescriptionOptions();
826 public:
827 
828 
830 protected:
831  hash<auto> getSequenceDescriptionOptions();
832 public:
833 
834 
836 protected:
837  hash<auto> getRebuildIndexOptions();
838 public:
839 
840 
842 protected:
843  hash<auto> getComputeStatisticsOptions();
844 public:
845 
846 
848 protected:
849  hash<auto> getReclaimSpaceOptions();
850 public:
851 
852 
854 protected:
855  auto tryExecArgsImpl(string sql, *softlist<auto> args);
856 public:
857 
858 
860 protected:
861  auto tryExecRawImpl(string sql);
862 public:
863 
864 
865 protected:
866  abstract string getCreateSqlImpl(list l);
867 public:
868 protected:
869  abstract list<auto> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
870 public:
871 protected:
872  abstract list<auto> getDropSchemaSqlImpl(hash schema_hash, *hash<auto> opt);
873 public:
874 
875 protected:
876  abstract *AbstractSequence getSequenceImpl(string name);
877 public:
878 protected:
879  abstract *AbstractFunction getFunctionImpl(string name);
880 public:
881 protected:
882  abstract *AbstractFunction getProcedureImpl(string name);
883 public:
884 protected:
885  abstract *AbstractView getViewImpl(string name);
886 public:
887 
888 protected:
889  abstract AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
890 public:
891 protected:
892  abstract AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
893 public:
894 protected:
895  abstract AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
896 public:
897 
898 protected:
899  abstract list<string> featuresImpl();
900 public:
901 protected:
902  abstract list<string> listTablesImpl();
903 public:
904 protected:
905  abstract list<string> listFunctionsImpl();
906 public:
907 protected:
908  abstract list<string> listProceduresImpl();
909 public:
910 protected:
911  abstract list<string> listSequencesImpl();
912 public:
913 protected:
914  abstract list<string> listViewsImpl();
915 public:
916 
918 protected:
919  abstract int getNextSequenceValueImpl(string name);
920 public:
922 protected:
923  abstract int getCurrentSequenceValueImpl(string name);
924 public:
925 
927 protected:
928  abstract bool supportsSequencesImpl();
929 public:
930 protected:
931  abstract bool supportsPackagesImpl();
932 public:
933 protected:
934  abstract bool supportsTypesImpl();
935 public:
936 
937 protected:
938  abstract bool rebuildIndexImpl(string name, *hash<auto> options);
939 public:
940 protected:
941  abstract computeStatisticsImpl(*hash<auto> options);
942 public:
943 protected:
944  abstract reclaimSpaceImpl(*hash<auto> options);
945 public:
946 protected:
947  abstract int getPhysicalSizeImpl();
948 public:
949 };
950 };
const ActionMap
maps from action codes to action descriptions
Definition: AbstractDatabase.qc.dox.h:106
AbstractFunction makeFunction(string name, string src, *hash< auto > opts)
creates a database-specific AbstractFunction object corresponding to the arguments ...
auto tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
hash< auto > getComputeStatisticsOptions()
override in subclasses to return driver-specific options
hash< auto > getDatabaseOptions()
override in subclasses to return driver-specific options
const AC_Unchanged
used when an existing object matches the template and no changes are made
Definition: AbstractDatabase.qc.dox.h:69
the base abstract class for the table implementation
Definition: AbstractTable.qc.dox.h:30
bool rebuildIndex(string name, *hash< auto > options)
Rebuild an index in the DB.
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:5009
hash< auto > getRebuildIndexOptions()
override in subclasses to return driver-specific options
*hash< auto > opts
option hash
Definition: AbstractSqlUtilBase.qc.dox.h:41
const DropSchemaOptions
default generic drop schema options
Definition: AbstractDatabase.qc.dox.h:138
reclaimSpace(*hash< auto > options)
Reclaim taken but unused space in the DB.
const SchemaDescriptionOptions
default generic schema description keys
Definition: AbstractDatabase.qc.dox.h:154
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view cannot be found ...
bool dropSequenceIfExists(string name, *hash< auto > opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not ...
const DatabaseOptions
database options
Definition: AbstractDatabase.qc.dox.h:41
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:5454
constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
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...
computeStatistics(*hash< auto > options)
Compute database statistics.
hash< auto > getCallbackOptions()
override in subclasses to return driver-specific options
const AC_Create
used when a new object is created
Definition: AbstractDatabase.qc.dox.h:72
base class for sequences
Definition: SqlUtil.qm.dox.h:5876
*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...
int getPhysicalSize()
Get the current database physical size in bytes.
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
number number(softnumber n)
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...
auto tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
base class for abstract SqlUtil classes
Definition: AbstractSqlUtilBase.qc.dox.h:34
const CacheOptions
generic cache options
Definition: AbstractDatabase.qc.dox.h:48
const AC_Modify
used when an object is modified in place
Definition: AbstractDatabase.qc.dox.h:81
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 ...
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
const False
const AC_Drop
used when an object is dropped
Definition: AbstractDatabase.qc.dox.h:75
Qore AbstractDatabase class definition.
Definition: AbstractDatabase.qc.dox.h:32
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
const ActionLetterMap
maps from action codes to action letter codes
Definition: AbstractDatabase.qc.dox.h:114
hash< auto > getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
bool supportsPackages()
returns True if the database supports packages
int index(softstring str, softstring substr, softint pos=0)
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
hash< auto > getCreationOptions()
override in subclasses to return driver-specific options
const AC_Rename
used when an object is renamed
Definition: AbstractDatabase.qc.dox.h:78
list< auto > list(...)
list< string > listTables()
returns a list of string table names in the database
bool dropViewIfExists(string name, *hash< auto > opt)
drops the given view if it exists; returns True if the view was dropped, False if not ...
const CreationOptions
default generic creation options
Definition: AbstractDatabase.qc.dox.h:124
const AC_Insert
used when data is inserted in a table
Definition: AbstractDatabase.qc.dox.h:93
hash< auto > getAlignSchemaOptions()
override in subclasses to return driver-specific options
hash< auto > getSequenceDescriptionOptions()
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
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
bool supportsTypes()
returns True if the database supports named types
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...
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
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...
auto tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
base class for functions
Definition: SqlUtil.qm.dox.h:5993
const AC_Recreate
used when an object is recreated (usually dropped and recreated in place)
Definition: AbstractDatabase.qc.dox.h:90
string type(auto arg)
base class for views
Definition: SqlUtil.qm.dox.h:5912
bool native_case
native case option
Definition: AbstractDatabase.qc.dox.h:176
hash< auto > hash(object obj)
AbstractTable makeTable(string name, hash< auto > desc, *hash< auto > opts)
creates a database-specific AbstractTable object corresponding to the arguments
hash< auto > getDropSchemaOptions()
override in subclasses to return driver-specific options
const SequenceDescriptionOptions
default generic sequence description keys
Definition: AbstractDatabase.qc.dox.h:163
hash< auto > getReclaimSpaceOptions()
override in subclasses to return driver-specific options
list< string > listSequences()
returns a list of string sequence names in the database
list< string > listProcedures()
returns a list of string procedure names in the database
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 AlignSchemaOptions
default generic schema description / alignment options
Definition: AbstractDatabase.qc.dox.h:131
int getNextSequenceValue(string name)
returns the next value in the given sequence
const AC_Truncate
used when a table is truncated
Definition: AbstractDatabase.qc.dox.h:84
transient Mutex l()
mutex for atomic actions
list< string > listViews()
returns a list of string view names in the database
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 ...
*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...
hash< auto > getCacheOptions()
override in subclasses to return driver-specific options
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...
list< string > listFunctions()
returns a list of string function names in the database
const CallbackOptions
generic callback options
Definition: AbstractDatabase.qc.dox.h:57
const ActionDescMap
maps from action descriptions to action codes
Definition: AbstractDatabase.qc.dox.h:110
*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...
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
int getCurrentSequenceValue(string name)
returns the last value issued for the given sequence in the current session
bool dropProcedureIfExists(string name, *hash< auto > opt)
drops the given procedure if it exists; returns True if the procedure was dropped, False if not
const AC_Delete
used when data is deleted in a table
Definition: AbstractDatabase.qc.dox.h:99
const ComputeStatisticsOptions
Options for computeStatistics()
Definition: AbstractDatabase.qc.dox.h:167
const AC_Update
used when data is updated in a table
Definition: AbstractDatabase.qc.dox.h:96
const AC_NotFound
used when dropping object but the object is not present
Definition: AbstractDatabase.qc.dox.h:102
abstract int getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
AbstractFunction makeProcedure(string name, string src, *hash< auto > opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
the base abstract class for the database implementation
Definition: AbstractDatabase.qc.dox.h:34
bool dropTableIfExists(string name, *hash< auto > opt)
drops the given table if it exists; returns True if the table was dropped, False if not ...
const AC_Add
used when an element is added to an existing object
Definition: AbstractDatabase.qc.dox.h:87
auto tryExecArgs(string sql, *softlist< auto > args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found ...
abstract int getNextSequenceValueImpl(string name)
returns the next value in the given sequence
bool supportsSequences()
returns True if the database supports sequences
const ReclaimSpaceOptions
Options for reclaimSpace()
Definition: AbstractDatabase.qc.dox.h:171