Qore Sqlite3SqlUtil Module Reference 1.1
Loading...
Searching...
No Matches
Sqlite3SqlUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* Sqlite3SqlUtil.qm Copyright 2013 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:bool n_auto_increment = False, bool n_pk = False
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27// requires the SqlUtil module
28
29// don't use "$" signs for variables and class members, assume local variable scope
30
31// require type definitions everywhere
32
33// enable all warnings
34
35
129namespace Sqlite3SqlUtil {
131 Sqlite3Table get_table(AbstractDatasource nds, string nname, *hash<auto> opts);
132
133
135 Sqlite3Database get_database(AbstractDatasource nds, *hash<auto> opts);
136
137
139class Sqlite3SavepointHelper : public AbstractSavepointHelper {
140
141public:
143 constructor(AbstractDatasource ds, *string savepoint) ;
144
145
147protected:
149public:
150
151
153protected:
155public:
156
157
159protected:
161public:
162
163 };
164
167
168public:
169 hash<string, string> collations;
170
172 constructor(string name, bool unique, hash<auto> cols, *hash<string, string> collations)
173 ;
174
175
177 string getCreateSql(string table_name, *hash<auto> opt);
178
179
182
183
185protected:
186 bool equalImpl(AbstractIndex ix);
187public:
188
189
191
193 string getRenameSql(string table_name, string new_name);
194
195
197 string getDropSql(string table_name);
198
199 };
200
203
204public:
205 constructor(string n, Columns c, ForeignConstraintTarget t) ;
206
207
208 string getCreateSql(string table_name, *hash<auto> opt);
209
210
212 softlist getRenameSql(string table_name, string new_name);
213
214
215 string getCreateSql(string name, string table_name, *hash<auto> opt);
216
217
218 string getAddSql(string name, string table_name, *hash<auto> opt);
219
220
222 string getDropSql(string table_name);
223
224 };
225
228
229public:
230 bool auto_increment;
231 bool primary_key;
232
234protected:
236public:
237
238
240 constructor(string name, string native_type, *string qore_type, bool nullable, *string default_value,
241 bool auto_increment = False, bool primary_key = False)
242 ;
243
244
246
253 softlist<string> getAddColumnSql(AbstractTable t);
254
255
257
273 softlist<string> getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash<auto> opt);
274
275
277
287 string getRenameSql(AbstractTable t, string new_name);
288
289
291
293 string getDdlName(string name);
294
295
297protected:
298 bool equalImpl(AbstractColumn c);
299public:
300
301 };
302
303class Sqlite3UniqueConstraint : public SqlUtil::AbstractUniqueConstraint {
304
305public:
306 constructor(string name, hash<auto> cols) ;
307
308
310
326 Sqlite3Column memberGate(string k);
327
328
329 string getCreateSql(string table_name, *hash<auto> opts);
330
331
332 list<string> getRenameSql(string table_name, string new_name);
333
334
335 string getCreateSql(string name, string table_name, *hash<auto> opts);
336
337
339 string getDropSql(string table_name);
340
341 };
342
345
346public:
347 constructor();
348
349
350 constructor(hash<auto> c) ;
351
352
353 string getCreateSql(string table_name, *hash<auto> opts);
354
355
356 list<string> getRenameSql(string table_name, string new_name);
357
358
361
362 };
363
366
367public:
369 constructor(string n, string n_src) ;
370
371
373 softlist getCreateSql(string table_name, *hash<auto> opt);
374
375
377 softlist getDropSql(string table_name);
378
379
381protected:
382 bool equalImpl(AbstractFunctionBase t);
383public:
384
385
387 softlist getRenameSql(string table_name, string new_name);
388
389 };
390
393
394public:
396 constructor(string name, string src) ;
397
398
400 string getCreateSql(*hash<auto> opt);
401
402
404
407 softlist getRenameSql(string new_name, *hash<auto> opt);
408
409 };
410
413
414public:
417 "abort": True,
418 "action": True,
419 "add": True,
420 "after": True,
421 "all": True,
422 "alter": True,
423 "always": True,
424 "analyze": True,
425 "and": True,
426 "as": True,
427 "asc": True,
428 "attach": True,
429 "autoincrement": True,
430 "before": True,
431 "begin": True,
432 "between": True,
433 "by": True,
434 "cascade": True,
435 "case": True,
436 "cast": True,
437 "check": True,
438 "collate": True,
439 "column": True,
440 "commit": True,
441 "conflict": True,
442 "constraint": True,
443 "create": True,
444 "cross": True,
445 "current": True,
446 "current_date": True,
447 "current_time": True,
448 "current_timestamp": True,
449 "database": True,
450 "default": True,
451 "deferrable": True,
452 "deferred": True,
453 "delete": True,
454 "desc": True,
455 "detach": True,
456 "distinct": True,
457 "do": True,
458 "drop": True,
459 "each": True,
460 "else": True,
461 "end": True,
462 "escape": True,
463 "except": True,
464 "exclude": True,
465 "exclusive": True,
466 "exists": True,
467 "explain": True,
468 "fail": True,
469 "filter": True,
470 "first": True,
471 "following": True,
472 "for": True,
473 "foreign": True,
474 "from": True,
475 "full": True,
476 "generated": True,
477 "glob": True,
478 "group": True,
479 "groups": True,
480 "having": True,
481 "if": True,
482 "ignore": True,
483 "immediate": True,
484 "in": True,
485 "index": True,
486 "indexed": True,
487 "initially": True,
488 "inner": True,
489 "insert": True,
490 "instead": True,
491 "intersect": True,
492 "into": True,
493 "is": True,
494 "isnull": True,
495 "join": True,
496 "key": True,
497 "last": True,
498 "left": True,
499 "like": True,
500 "limit": True,
501 "match": True,
502 "materialized": True,
503 "natural": True,
504 "no": True,
505 "not": True,
506 "nothing": True,
507 "notnull": True,
508 "null": True,
509 "nulls": True,
510 "of": True,
511 "offset": True,
512 "on": True,
513 "or": True,
514 "order": True,
515 "others": True,
516 "outer": True,
517 "over": True,
518 "partition": True,
519 "plan": True,
520 "pragma": True,
521 "preceding": True,
522 "primary": True,
523 "query": True,
524 "raise": True,
525 "range": True,
526 "recursive": True,
527 "references": True,
528 "regexp": True,
529 "reindex": True,
530 "release": True,
531 "rename": True,
532 "replace": True,
533 "restrict": True,
534 "returning": True,
535 "right": True,
536 "rollback": True,
537 "row": True,
538 "rows": True,
539 "savepoint": True,
540 "select": True,
541 "set": True,
542 "table": True,
543 "temp": True,
544 "temporary": True,
545 "then": True,
546 "ties": True,
547 "to": True,
548 "transaction": True,
549 "trigger": True,
550 "unbounded": True,
551 "union": True,
552 "unique": True,
553 "update": True,
554 "using": True,
555 "vacuum": True,
556 "values": True,
557 "view": True,
558 "virtual": True,
559 "when": True,
560 "where": True,
561 "window": True,
562 "with": True,
563 "without": True,
564 };
565
566 constructor(AbstractDatasource ds, *hash<auto> opts) ;
567
568
570
575
576
578
583
584
585protected:
586 list<string> featuresImpl();
587public:
588
589
590 string getSchemaName();
591
592
593 private AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1,
594 *softnumber end, *hash<auto> opts) {
595 throw "UNSUPPORTED";
596 }
597
598protected:
599 *AbstractSequence getSequenceImpl(string name);
600public:
601
602
603protected:
604 *AbstractView getViewImpl(string name);
605public:
606
607
608protected:
609 AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
610public:
611
612
613protected:
614 AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
615public:
616
617
618protected:
619 *AbstractFunction getFunctionImpl(string name);
620public:
621
622
623protected:
624 *AbstractFunction getProcedureImpl(string name);
625public:
626
627
628protected:
629 list<string> getDropSchemaSqlImpl(hash<auto> schema_hash, *hash<auto> opt);
630public:
631
632
633protected:
634 list<string> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
635public:
636
637
639protected:
640 list<string> listTablesImpl();
641public:
642
643
645
649protected:
650 list<string> listFunctionsImpl();
651public:
652
653
655
659protected:
660 list<string> listProceduresImpl();
661public:
662
663
664protected:
665 list<string> listSequencesImpl();
666public:
667
668
669protected:
670 list<string> listViewsImpl();
671public:
672
673
674protected:
675 string getCreateSqlImpl(list<auto> l);
676public:
677
678
679 static string getCreateSql(list<auto> l);
680
682protected:
683 softint getNextSequenceValueImpl(string name);
684public:
685
686
688protected:
689 softint getCurrentSequenceValueImpl(string name);
690public:
691
692
694protected:
696public:
697
698
700protected:
702public:
703
704
706protected:
708public:
709
710
712protected:
713 bool rebuildIndexImpl(string name, *hash<auto> options);
714public:
715
716
718protected:
719 computeStatisticsImpl(*hash<auto> options);
720public:
721
722
724protected:
725 reclaimSpaceImpl(*hash<auto> options);
726public:
727
728
730protected:
732public:
733
734 };
735
738
739public:
742 "real": {
743 "qore": Type::Float,
744 "size": SZ_NUM,
745 },
746 "integer": {
747 "qore": Type::Int,
748 "ai": True,
749 },
750 "text": {
751 "qore": Type::String,
752 },
753 "varchar": {
754 "qore": Type::String,
755 },
756 "blob": {
757 "qore": Type::Binary,
758 },
759 };
760
762 const QoreTypeMap = ...;
763
764
766 const Sqlite3CopMap = ...;
767
768
769 constructor(AbstractDatasource ds, string name, *hash<auto> opts) ;
770
771
773 string getSqlName();
774
775
777protected:
779public:
780
781
782protected:
783 bool checkExistenceImpl();
784public:
785
786
787protected:
788 Columns describeImpl();
789public:
790
791
792protected:
793 *string getCreatePrimaryKeySqlUnlocked(*hash<auto> opt, bool cache = True);
794public:
795
796
797protected:
798 Sqlite3PrimaryKey getPrimaryKeyImpl();
799public:
800
801
802protected:
803 Indexes getIndexesImpl();
804public:
805
806
807protected:
808 ForeignConstraints getForeignConstraintsImpl(*hash<auto> opts);
809public:
810
811
812protected:
813 Constraints getConstraintsImpl();
814public:
815
816
817protected:
818 Triggers getTriggersImpl();
819public:
820
821
822 string getCreateTableSqlImpl(*hash<auto> opt);
823
824
827
828
829protected:
830 *list getCreateMiscSqlImpl(*hash<auto> opt, bool cache);
831public:
832
833
834protected:
835 *list getAlignSqlImpl(AbstractTable table, *hash<auto> opt);
836public:
837
838
839protected:
840 string getCreateSqlImpl(list l);
841public:
842
843
844protected:
845 string getRenameSqlImpl(string new_name);
846public:
847
848
849protected:
850 AbstractColumn addColumnImpl(string cname, hash<auto> opt, bool nullable = True);
851public:
852
853
854protected:
855 setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
856public:
857
858
859protected:
860 addColumnToTableUnlocked(AbstractColumn c);
861public:
862
863
864protected:
865 AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash<auto> ch, *hash<auto> opt);
866public:
867
868
869protected:
870 AbstractIndex addIndexImpl(string iname, bool enabled, hash<auto> ch, *hash<auto> opt);
871public:
872
873
874 private AbstractForeignConstraint addForeignConstraintImpl(string cname, hash<auto> ch, string table,
875 hash<auto> tch, *hash<auto> opt) {
876 ForeignConstraintTarget fct(table, new Columns(tch));
877 return new Sqlite3ForeignConstraint(cname, new Columns(ch), fct);
878 }
879
880protected:
881 AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash<auto> opt);
882public:
883
884
885protected:
886 AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash<auto> ch, *hash<auto> opt);
887public:
888
889
890protected:
891 AbstractTrigger addTriggerImpl(string tname, string src, *hash<auto> opt);
892public:
893
894
895protected:
896 bool tryInsertImpl(string sql, hash<auto> row);
897public:
898
899
901
903protected:
904 bool isDuplicateRowErrorImpl(hash<ExceptionInfo> ex);
905public:
906
907
908protected:
909 hash<auto> getQoreTypeMapImpl();
910public:
911
912
913protected:
914 hash<auto> getTypeMapImpl();
915public:
916
917
919protected:
920 *string getSqlValueImpl(auto v);
921public:
922
923
925protected:
926 static *string getSqlValueIntern(auto v);
927public:
928
929
931
933 string getColumnSqlName(string col);
934
935
937 list<string> getColumnSqlNames(softlist<auto> cols);
938
939
941
952 static *string getSqlValue(auto v);
953
954protected:
955 bool emptyImpl();
956public:
957
958
959protected:
960 preSetupTableImpl(reference<hash> desc, *hash<auto> opt);
961public:
962
963
964protected:
965 setupTableImpl(hash<auto> desc, *hash<auto> opt);
966public:
967
968
970protected:
972public:
973
974
976protected:
978public:
979
980
982protected:
984public:
985
986
988protected:
989 doSelectLimitOnlyUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql);
990public:
991
992
994 private doSelectOrderByWithOffsetSqlUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql,
995 list<auto> coll) {
996 doSelectOrderBySqlUnlocked(info, \sql, coll);
997 if (info.query_hash.limit);
998
999
1000 if (info.query_hash.offset);
1001
1002 }
1003
1005protected:
1007public:
1008
1009
1010protected:
1011 *hash<auto> doReturningImpl(hash<auto> opt, reference<string> sql, list<auto> args);
1012public:
1013
1014
1015protected:
1016 list<auto> getGroupOrderByListUnlocked(hash<QueryInfo> info, string key, list<auto> coll);
1017public:
1018
1019
1022
1023
1025protected:
1026 copyImpl(AbstractTable old);
1027public:
1028
1029
1031protected:
1032 AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash<auto> options);
1033public:
1034
1035
1037
1041protected:
1042 AbstractSavepointHelper getSavepointHelperImpl(*string savepoint);
1043public:
1044
1045 };
1046};
transient AbstractDatasource ds
cache(*hash< auto > opts)
represents a Sqlite3-specific column
Definition: Sqlite3SqlUtil.qm.dox.h:227
constructor()
empty constructor for subclasses
constructor(string name, string native_type, *string qore_type, bool nullable, *string default_value, bool auto_increment=False, bool primary_key=False)
Creates the column.
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
softlist< string > getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
softlist< string > getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash< auto > opt)
returns a list of sql strings that can be used to modify the column to the new definition
string getDdlName(string name)
returns the column name with quoting in case the column name is a reserved word
provides the Sqlite3-specific implementation of the AbstractDatabase interface
Definition: Sqlite3SqlUtil.qm.dox.h:412
list< string > listFunctionsImpl()
returns a list of string function names in the database
bool supportsTypesImpl()
returns True if the database supports named types
const Sqlite3ReservedWords
hash of reserved words
Definition: Sqlite3SqlUtil.qm.dox.h:416
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
list< string > listProceduresImpl()
returns a list of string procedure names in the database
bool rebuildIndexImpl(string name, *hash< auto > options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
bool supportsPackagesImpl()
returns True if the database supports packages
computeStatisticsImpl(*hash< auto > options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics()
bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in Sqlite3
int getPhysicalSizeImpl()
SqlUtil::AbstractDatabase::getPhysicalSize()
int getMaximumPrecision()
Returns the maximum precision for numeric or decimal columns.
list< string > listTablesImpl()
returns a list of string table names in the database
reclaimSpaceImpl(*hash< auto > options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
bool requiresScale()
Returns True if the driver requires a scale to support decimal values in numeric or decimal columns.
represents a Sqlite3-specific foreign constraint
Definition: Sqlite3SqlUtil.qm.dox.h:202
string getDropSql(string table_name)
returns a string that can be used to drop the foreign constraint from the database
softlist getRenameSql(string table_name, string new_name)
returns a string that drops the constraint and re-adds it, since Sqlite3 does not support renaming co...
represents a Sqlite3-specific index
Definition: Sqlite3SqlUtil.qm.dox.h:166
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
string getCreateSql(string table_name, *hash< auto > opt)
returns a string that can be used to create the index in the database
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
list< string > getColumnCollationList()
Returns a list of column name with COLLATE argument per column, if appropriate.
constructor(string name, bool unique, hash< auto > cols, *hash< string, string > collations)
creates the object from the arguments
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
represents a Sqlite3-specific primary key constraint
Definition: Sqlite3SqlUtil.qm.dox.h:344
bool supportsName()
returns False since primary key constraints in Sqlite3 have no name
Sqlite3 savepoint helper.
Definition: Sqlite3SqlUtil.qm.dox.h:139
createSavepointImpl()
Creates the savepoint.
rollbackImpl()
Rolls back to the savepoint.
deleteSavepointImpl()
Deletes the savepoint.
constructor(AbstractDatasource ds, *string savepoint)
Creates the object.
provides the Sqlite3-specific implementation of the AbstractTable interface
Definition: Sqlite3SqlUtil.qm.dox.h:737
bool isDuplicateRowErrorImpl(hash< ExceptionInfo > ex)
Returns True if the exception was raised because of a duplicate row / key error.
bool asteriskRequiresPrefix()
returns True if the database requires a wildcard "*" to be prefixed with the table name when it appea...
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema,...
bool hasArrayBind()
returns False because the sqlite3 driver does not support array binds / bulk DML operations
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference< hash< QueryInfo > > info, reference< string > sql, list< auto > coll)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument
Definition: Sqlite3SqlUtil.qm.dox.h:994
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
bool hasReturningImpl()
returns True if the current database driver supports the "returning" clause in insert statements,...
static *string getSqlValue(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument
list< string > getColumnSqlNames(softlist< auto > cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
const QoreTypeMap
maps qore type names to Sqlite3 type names
Definition: Sqlite3SqlUtil.qm.dox.h:762
copyImpl(AbstractTable old)
db-specific copy actions
static *string getSqlValueIntern(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
hash getColumnOperatorMapImpl()
returns the column operator map for this object
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
const Sqlite3CopMap
column operator specializations for Sqlite3
Definition: Sqlite3SqlUtil.qm.dox.h:766
const Sqlite3TypeMap
maps sqlite3 type names to type configurations
Definition: Sqlite3SqlUtil.qm.dox.h:741
doSelectLimitOnlyUnlockedImpl(reference< hash< QueryInfo > > info, reference< string > sql)
processes a string for use in SQL select statements when there is a "limit" argument,...
AbstractSavepointHelper getSavepointHelperImpl(*string savepoint)
get DB-specific savepoint helper
bool supportsTablespacesImpl()
returns True if the database support tablespaces
AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash< auto > options)
returns the type for number / numeric columns for the database so that data conversions can be handle...
represents a Sqlite3-specific trigger
Definition: Sqlite3SqlUtil.qm.dox.h:365
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
softlist getCreateSql(string table_name, *hash< auto > opt)
returns a string that can be used to create the trigger in the database
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
represents a Sqlite3 view
Definition: Sqlite3SqlUtil.qm.dox.h:392
constructor(string name, string src)
creates the object from the arguments
softlist getRenameSql(string new_name, *hash< auto > opt)
returns a string that can be used to rename the view in the database
string getCreateSql(*hash< auto > opt)
returns a string that can be used to create the view in the database
the Sqlite3SqlUtil namespace contains all the objects in the Sqlite3SqlUtil module
Definition: Sqlite3SqlUtil.qm.dox.h:129
Sqlite3Table get_table(AbstractDatasource nds, string nname, *hash< auto > opts)
returns a Sqlite3Table object corresponding to the arguments
Sqlite3Database get_database(AbstractDatasource nds, *hash< auto > opts)
returns a Sqlite3Database object corresponding to the arguments