Qore SqlUtil Module Reference  1.7.4
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 
307  AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
308 
309 
310  AbstractSequence makeSequenceFromDescription(string name, *hash<auto> sh, *hash<auto> opts);
311 
312 
314 
327  AbstractTable makeTable(string name, hash<auto> desc, *hash<auto> opts);
328 
329 
331 
342  AbstractFunction makeFunction(string name, string src, *hash<auto> opts);
343 
344 
346 
357  AbstractFunction makeProcedure(string name, string src, *hash<auto> opt);
358 
359 
361 
373  bool dropFunctionIfExists(string name, *hash<auto> opt);
374 
375 
377 
389  bool dropProcedureIfExists(string name, *hash<auto> opt);
390 
391 
393 
405  bool dropSequenceIfExists(string name, *hash<auto> opt);
406 
407 
409 
421  bool dropViewIfExists(string name, *hash<auto> opt);
422 
423 
425 
437  bool dropTableIfExists(string name, *hash<auto> opt);
438 
439 
441 
453  *string getDropFunctionSqlIfExists(string name, *hash<auto> opt);
454 
455 
457 
469  *string getDropProcedureSqlIfExists(string name, *hash<auto> opt);
470 
471 
473 
485  *string getDropSequenceSqlIfExists(string name, *hash<auto> opt);
486 
487 
489 
501  *list<auto> getDropTableSqlIfExists(string name, *hash<auto> opt);
502 
503 
504  doDropSql(*softlist l, string type, string name, *hash<auto> opt);
505 
506 
507  bool doDrop(*softlist l, string type, string name, *hash<auto> opt);
508 
509 
511 
523  list<auto> getAlignFunctionSql(AbstractFunction f, *hash<auto> opt);
524 
525 
527 
539  list<auto> getAlignProcedureSql(AbstractFunction f, *hash<auto> opt);
540 
541 
543 
552  *AbstractTable getTable(string name);
553 
554 
556 
566 
567 
569 
581 
582 
584 
596 
597 
599 
608  *AbstractView getView(string name);
609 
610 
612 
621  int getNextSequenceValue(string name);
622 
623 
625 
634  int getCurrentSequenceValue(string name);
635 
636 
638 
648 
649 
652 
653 
656 
657 
660 
661 
663  list<string> listTables();
664 
665 
668 
669 
671  list<string> listFunctions();
672 
673 
676 
677 
679  list<string> listProcedures();
680 
681 
684 
685 
687  list<string> listSequences();
688 
689 
692 
693 
695  list<string> listViews();
696 
697 
700 
701 
703 
713  bool rebuildIndex(string name, *hash<auto> options);
714 
715 
717 
725  bool rebuildIndex(AbstractIndex index, *hash<auto> options);
726 
727 
729 
736  computeStatistics(*hash<auto> options);
737 
738 
740 
747  reclaimSpace(*hash<auto> options);
748 
749 
751 
761 
762 
763 protected:
764  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt);
765 public:
766 
767 
768 protected:
769  validateOptionsIntern(string err, hash<auto> ropt, reference<hash> opt, string tag);
770 public:
771 
772 
773  static AbstractDatabase getDatabase(AbstractDatasource nds, *hash<auto> opts);
774 
775  static AbstractDatabase getDatabase(string dsstr, *hash<auto> opts);
776 
777  static AbstractDatabase getDatabase(hash<auto> dsh, *hash<auto> opts);
778 
779  static checkDriverOptions(reference<hash> h, string drv);
780 
782 protected:
783  hash<auto> getDatabaseOptions();
784 public:
785 
786 
788 protected:
789  hash<auto> getCallbackOptions();
790 public:
791 
792 
794 protected:
795  hash<auto> getCreationOptions();
796 public:
797 
798 
800 protected:
801  hash<auto> getCacheOptions();
802 public:
803 
804 
806 protected:
807  hash<auto> getAlignSchemaOptions();
808 public:
809 
810 
812 protected:
813  hash<auto> getDropSchemaOptions();
814 public:
815 
816 
818 protected:
820 public:
821 
822 
824 protected:
826 public:
827 
828 
830 protected:
832 public:
833 
834 
836 protected:
838 public:
839 
840 
842 protected:
844 public:
845 
846 
848 protected:
849  auto tryExecArgsImpl(string sql, *softlist<auto> args);
850 public:
851 
852 
854 protected:
855  auto tryExecRawImpl(string sql);
856 public:
857 
858 
859 protected:
860  abstract string getCreateSqlImpl(list l);
861 public:
862 protected:
863  abstract list<auto> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
864 public:
865 protected:
866  abstract list<auto> getDropSchemaSqlImpl(hash schema_hash, *hash<auto> opt);
867 public:
868 
869 protected:
870  abstract *AbstractSequence getSequenceImpl(string name);
871 public:
872 protected:
873  abstract *AbstractFunction getFunctionImpl(string name);
874 public:
875 protected:
876  abstract *AbstractFunction getProcedureImpl(string name);
877 public:
878 protected:
879  abstract *AbstractView getViewImpl(string name);
880 public:
881 
882 protected:
883  abstract AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
884 public:
885 protected:
886  abstract AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
887 public:
888 protected:
889  abstract AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
890 public:
891 
892 protected:
893  abstract list<string> featuresImpl();
894 public:
895 protected:
896  abstract list<string> listTablesImpl();
897 public:
898 protected:
899  abstract list<string> listFunctionsImpl();
900 public:
901 protected:
902  abstract list<string> listProceduresImpl();
903 public:
904 protected:
905  abstract list<string> listSequencesImpl();
906 public:
907 protected:
908  abstract list<string> listViewsImpl();
909 public:
910 
912 protected:
913  abstract int getNextSequenceValueImpl(string name);
914 public:
916 protected:
917  abstract int getCurrentSequenceValueImpl(string name);
918 public:
919 
921 protected:
922  abstract bool supportsSequencesImpl();
923 public:
924 protected:
925  abstract bool supportsPackagesImpl();
926 public:
927 protected:
928  abstract bool supportsTypesImpl();
929 public:
930 
931 protected:
932  abstract bool rebuildIndexImpl(string name, *hash<auto> options);
933 public:
934 protected:
935  abstract computeStatisticsImpl(*hash<auto> options);
936 public:
937 protected:
938  abstract reclaimSpaceImpl(*hash<auto> options);
939 public:
940 protected:
941  abstract int getPhysicalSizeImpl();
942 public:
943 };
944 };
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
const AC_NotFound
used when dropping object but the object is not present
Definition: AbstractDatabase.qc.dox.h:96
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
const AC_Modify
used when an object is modified in place
Definition: AbstractDatabase.qc.dox.h:75
hash< auto > getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
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
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
hash< auto > getCreationOptions()
override in subclasses to return driver-specific options
hash< auto > getSequenceDescriptionOptions()
override in subclasses to return driver-specific options
const AC_Update
used when data is updated in a table
Definition: AbstractDatabase.qc.dox.h:90
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
const AC_Drop
used when an object is dropped
Definition: AbstractDatabase.qc.dox.h:69
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
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 AC_Create
used when a new object is created
Definition: AbstractDatabase.qc.dox.h:66
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.
const AC_Delete
used when data is deleted in a table
Definition: AbstractDatabase.qc.dox.h:93
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
const AC_Truncate
used when a table is truncated
Definition: AbstractDatabase.qc.dox.h:78
*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
const AC_Unchanged
used when an existing object matches the template and no changes are made
Definition: AbstractDatabase.qc.dox.h:63
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
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 AC_Insert
used when data is inserted in a table
Definition: AbstractDatabase.qc.dox.h:87
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
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
const AC_Rename
used when an object is renamed
Definition: AbstractDatabase.qc.dox.h:72
base class for functions
Definition: SqlUtil.qm.dox.h:6000
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:5461
base class for sequences
Definition: SqlUtil.qm.dox.h:5883
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:5919
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:5016
const False
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