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
176 string getCreateSql(string table_name, *hash<auto> opt);
177
178
181
182
184protected:
185 bool equalImpl(AbstractIndex ix);
186public:
187
188
190
192 string getRenameSql(string table_name, string new_name);
193
194
196 string getDropSql(string table_name);
197
198 };
199
202
203public:
204 constructor(string n, Columns c, ForeignConstraintTarget t) ;
205
206
207 string getCreateSql(string table_name, *hash<auto> opt);
208
209
211 softlist getRenameSql(string table_name, string new_name);
212
213
214 string getCreateSql(string name, string table_name, *hash<auto> opt);
215
216
217 string getAddSql(string name, string table_name, *hash<auto> opt);
218
219
221 string getDropSql(string table_name);
222
223 };
224
227
228public:
229 bool auto_increment;
230 bool primary_key;
231
233protected:
235public:
236
237
239 constructor(string name, string native_type, *string qore_type, bool nullable, *string default_value, bool auto_increment = False, bool primary_key = False)
240 ;
241
242
244
251 softlist<string> getAddColumnSql(AbstractTable t);
252
253
255
271 softlist<string> getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash<auto> opt);
272
273
275
285 string getRenameSql(AbstractTable t, string new_name);
286
287
289
291 string getDdlName(string name);
292
293
295protected:
296 bool equalImpl(AbstractColumn c);
297public:
298
299 };
300
301class Sqlite3UniqueConstraint : public SqlUtil::AbstractUniqueConstraint {
302
303public:
304 constructor(string name, hash<auto> cols) ;
305
306
308
324 Sqlite3Column memberGate(string k);
325
326
327 string getCreateSql(string table_name, *hash<auto> opts);
328
329
330 list<string> getRenameSql(string table_name, string new_name);
331
332
333 string getCreateSql(string name, string table_name, *hash<auto> opts);
334
335
337 string getDropSql(string table_name);
338
339 };
340
343
344public:
345 constructor();
346
347
348 constructor(hash<auto> c) ;
349
350
351 string getCreateSql(string table_name, *hash<auto> opts);
352
353
354 list<string> getRenameSql(string table_name, string new_name);
355
356
359
360 };
361
364
365public:
367 constructor(string n, string n_src) ;
368
369
371 softlist getCreateSql(string table_name, *hash<auto> opt);
372
373
375 softlist getDropSql(string table_name);
376
377
379protected:
380 bool equalImpl(AbstractFunctionBase t);
381public:
382
383
385 softlist getRenameSql(string table_name, string new_name);
386
387 };
388
391
392public:
394 constructor(string name, string src) ;
395
396
398 string getCreateSql(*hash<auto> opt);
399
400
402
405 softlist getRenameSql(string new_name, *hash<auto> opt);
406
407 };
408
411
412public:
415 "abort": True,
416 "action": True,
417 "add": True,
418 "after": True,
419 "all": True,
420 "alter": True,
421 "always": True,
422 "analyze": True,
423 "and": True,
424 "as": True,
425 "asc": True,
426 "attach": True,
427 "autoincrement": True,
428 "before": True,
429 "begin": True,
430 "between": True,
431 "by": True,
432 "cascade": True,
433 "case": True,
434 "cast": True,
435 "check": True,
436 "collate": True,
437 "column": True,
438 "commit": True,
439 "conflict": True,
440 "constraint": True,
441 "create": True,
442 "cross": True,
443 "current": True,
444 "current_date": True,
445 "current_time": True,
446 "current_timestamp": True,
447 "database": True,
448 "default": True,
449 "deferrable": True,
450 "deferred": True,
451 "delete": True,
452 "desc": True,
453 "detach": True,
454 "distinct": True,
455 "do": True,
456 "drop": True,
457 "each": True,
458 "else": True,
459 "end": True,
460 "escape": True,
461 "except": True,
462 "exclude": True,
463 "exclusive": True,
464 "exists": True,
465 "explain": True,
466 "fail": True,
467 "filter": True,
468 "first": True,
469 "following": True,
470 "for": True,
471 "foreign": True,
472 "from": True,
473 "full": True,
474 "generated": True,
475 "glob": True,
476 "group": True,
477 "groups": True,
478 "having": True,
479 "if": True,
480 "ignore": True,
481 "immediate": True,
482 "in": True,
483 "index": True,
484 "indexed": True,
485 "initially": True,
486 "inner": True,
487 "insert": True,
488 "instead": True,
489 "intersect": True,
490 "into": True,
491 "is": True,
492 "isnull": True,
493 "join": True,
494 "key": True,
495 "last": True,
496 "left": True,
497 "like": True,
498 "limit": True,
499 "match": True,
500 "materialized": True,
501 "natural": True,
502 "no": True,
503 "not": True,
504 "nothing": True,
505 "notnull": True,
506 "null": True,
507 "nulls": True,
508 "of": True,
509 "offset": True,
510 "on": True,
511 "or": True,
512 "order": True,
513 "others": True,
514 "outer": True,
515 "over": True,
516 "partition": True,
517 "plan": True,
518 "pragma": True,
519 "preceding": True,
520 "primary": True,
521 "query": True,
522 "raise": True,
523 "range": True,
524 "recursive": True,
525 "references": True,
526 "regexp": True,
527 "reindex": True,
528 "release": True,
529 "rename": True,
530 "replace": True,
531 "restrict": True,
532 "returning": True,
533 "right": True,
534 "rollback": True,
535 "row": True,
536 "rows": True,
537 "savepoint": True,
538 "select": True,
539 "set": True,
540 "table": True,
541 "temp": True,
542 "temporary": True,
543 "then": True,
544 "ties": True,
545 "to": True,
546 "transaction": True,
547 "trigger": True,
548 "unbounded": True,
549 "union": True,
550 "unique": True,
551 "update": True,
552 "using": True,
553 "vacuum": True,
554 "values": True,
555 "view": True,
556 "virtual": True,
557 "when": True,
558 "where": True,
559 "window": True,
560 "with": True,
561 "without": True,
562 };
563
564 constructor(AbstractDatasource ds, *hash<auto> opts) ;
565
566
568
573
574
576
581
582
583protected:
584 list<string> featuresImpl();
585public:
586
587
588 string getSchemaName();
589
590
591protected:
592 AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
593public:
594
595
596protected:
597 *AbstractSequence getSequenceImpl(string name);
598public:
599
600
601protected:
602 *AbstractView getViewImpl(string name);
603public:
604
605
606protected:
607 AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
608public:
609
610
611protected:
612 AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
613public:
614
615
616protected:
617 *AbstractFunction getFunctionImpl(string name);
618public:
619
620
621protected:
622 *AbstractFunction getProcedureImpl(string name);
623public:
624
625
626protected:
627 list<string> getDropSchemaSqlImpl(hash<auto> schema_hash, *hash<auto> opt);
628public:
629
630
631protected:
632 list<string> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
633public:
634
635
637protected:
638 list<string> listTablesImpl();
639public:
640
641
643
647protected:
648 list<string> listFunctionsImpl();
649public:
650
651
653
657protected:
658 list<string> listProceduresImpl();
659public:
660
661
662protected:
663 list<string> listSequencesImpl();
664public:
665
666
667protected:
668 list<string> listViewsImpl();
669public:
670
671
672protected:
673 string getCreateSqlImpl(list<auto> l);
674public:
675
676
677 static string getCreateSql(list<auto> l);
678
680protected:
681 softint getNextSequenceValueImpl(string name);
682public:
683
684
686protected:
687 softint getCurrentSequenceValueImpl(string name);
688public:
689
690
692protected:
694public:
695
696
698protected:
700public:
701
702
704protected:
706public:
707
708
710protected:
711 bool rebuildIndexImpl(string name, *hash<auto> options);
712public:
713
714
716protected:
717 computeStatisticsImpl(*hash<auto> options);
718public:
719
720
722protected:
723 reclaimSpaceImpl(*hash<auto> options);
724public:
725
726
728protected:
730public:
731
732 };
733
736
737public:
740 "real": {
741 "qore": Type::Float,
742 "size": SZ_NUM,
743 },
744 "integer": {
745 "qore": Type::Int,
746 "ai": True,
747 },
748 "text": {
749 "qore": Type::String,
750 },
751 "varchar": {
752 "qore": Type::String,
753 },
754 "blob": {
755 "qore": Type::Binary,
756 },
757 };
758
760 const QoreTypeMap = ...;
761
762
764 const Sqlite3CopMap = ...;
765
766
767 constructor(AbstractDatasource ds, string name, *hash<auto> opts) ;
768
769
771 string getSqlName();
772
773
775protected:
777public:
778
779
780protected:
781 bool checkExistenceImpl();
782public:
783
784
785protected:
786 Columns describeImpl();
787public:
788
789
790protected:
791 *string getCreatePrimaryKeySqlUnlocked(*hash<auto> opt, bool cache = True);
792public:
793
794
795protected:
796 Sqlite3PrimaryKey getPrimaryKeyImpl();
797public:
798
799
800protected:
801 Indexes getIndexesImpl();
802public:
803
804
805protected:
806 ForeignConstraints getForeignConstraintsImpl(*hash<auto> opts);
807public:
808
809
810protected:
811 Constraints getConstraintsImpl();
812public:
813
814
815protected:
816 Triggers getTriggersImpl();
817public:
818
819
820 string getCreateTableSqlImpl(*hash<auto> opt);
821
822
825
826
827protected:
828 *list getCreateMiscSqlImpl(*hash<auto> opt, bool cache);
829public:
830
831
832protected:
833 *list getAlignSqlImpl(AbstractTable table, *hash<auto> opt);
834public:
835
836
837protected:
838 string getCreateSqlImpl(list l);
839public:
840
841
842protected:
843 string getRenameSqlImpl(string new_name);
844public:
845
846
847protected:
848 AbstractColumn addColumnImpl(string cname, hash<auto> opt, bool nullable = True);
849public:
850
851
852protected:
853 setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
854public:
855
856
857protected:
858 addColumnToTableUnlocked(AbstractColumn c);
859public:
860
861
862protected:
863 AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash<auto> ch, *hash<auto> opt);
864public:
865
866
867protected:
868 AbstractIndex addIndexImpl(string iname, bool enabled, hash<auto> ch, *hash<auto> opt);
869public:
870
871
872protected:
873 AbstractForeignConstraint addForeignConstraintImpl(string cname, hash<auto> ch, string table, hash<auto> tch, *hash<auto> opt);
874public:
875
876
877protected:
878 AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash<auto> opt);
879public:
880
881
882protected:
883 AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash<auto> ch, *hash<auto> opt);
884public:
885
886
887protected:
888 AbstractTrigger addTriggerImpl(string tname, string src, *hash<auto> opt);
889public:
890
891
892protected:
893 bool tryInsertImpl(string sql, hash<auto> row);
894public:
895
896
898
900protected:
901 bool isDuplicateRowErrorImpl(hash<ExceptionInfo> ex);
902public:
903
904
905protected:
906 hash<auto> getQoreTypeMapImpl();
907public:
908
909
910protected:
911 hash<auto> getTypeMapImpl();
912public:
913
914
916protected:
917 *string getSqlValueImpl(auto v);
918public:
919
920
922protected:
923 static *string getSqlValueIntern(auto v);
924public:
925
926
928
930 string getColumnSqlName(string col);
931
932
934 list<string> getColumnSqlNames(softlist<auto> cols);
935
936
938
949 static *string getSqlValue(auto v);
950
951protected:
952 bool emptyImpl();
953public:
954
955
956protected:
957 preSetupTableImpl(reference<hash> desc, *hash<auto> opt);
958public:
959
960
961protected:
962 setupTableImpl(hash<auto> desc, *hash<auto> opt);
963public:
964
965
967protected:
969public:
970
971
973protected:
975public:
976
977
979protected:
981public:
982
983
985protected:
986 doSelectLimitOnlyUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql);
987public:
988
989
991protected:
992 doSelectOrderByWithOffsetSqlUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql, list<auto> coll);
993public:
994
995
997protected:
999public:
1000
1001
1002protected:
1003 *hash<auto> doReturningImpl(hash<auto> opt, reference<string> sql, list<auto> args);
1004public:
1005
1006
1007protected:
1008 list<auto> getGroupOrderByListUnlocked(hash<QueryInfo> info, string key, list<auto> coll);
1009public:
1010
1011
1014
1015
1017protected:
1018 copyImpl(AbstractTable old);
1019public:
1020
1021
1023protected:
1024 AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash<auto> options);
1025public:
1026
1027
1029
1033protected:
1034 AbstractSavepointHelper getSavepointHelperImpl(*string savepoint);
1035public:
1036
1037 };
1038};
transient AbstractDatasource ds
cache(*hash< auto > opts)
represents a Sqlite3-specific column
Definition: Sqlite3SqlUtil.qm.dox.h:226
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:410
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:414
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:201
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:342
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:735
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
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
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
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:760
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:764
const Sqlite3TypeMap
maps sqlite3 type names to type configurations
Definition: Sqlite3SqlUtil.qm.dox.h:739
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:363
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:390
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