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 - 2024 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
416
417 constructor(AbstractDatasource ds, *hash<auto> opts) ;
418
419
421
426
427
429
434
435
436protected:
437 list<string> featuresImpl();
438public:
439
440
441 string getSchemaName();
442
443
444protected:
445 AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash<auto> opts);
446public:
447
448
449protected:
450 *AbstractSequence getSequenceImpl(string name);
451public:
452
453
454protected:
455 *AbstractView getViewImpl(string name);
456public:
457
458
459protected:
460 AbstractFunction makeFunctionImpl(string name, string src, *hash<auto> opts);
461public:
462
463
464protected:
465 AbstractFunction makeProcedureImpl(string name, string src, *hash<auto> opts);
466public:
467
468
469protected:
470 *AbstractFunction getFunctionImpl(string name);
471public:
472
473
474protected:
475 *AbstractFunction getProcedureImpl(string name);
476public:
477
478
479protected:
480 list<string> getDropSchemaSqlImpl(hash<auto> schema_hash, *hash<auto> opt);
481public:
482
483
484protected:
485 list<string> getAlignSqlImpl(hash schema_hash, *hash<auto> opt);
486public:
487
488
490protected:
491 list<string> listTablesImpl();
492public:
493
494
496
500protected:
501 list<string> listFunctionsImpl();
502public:
503
504
506
510protected:
511 list<string> listProceduresImpl();
512public:
513
514
515protected:
516 list<string> listSequencesImpl();
517public:
518
519
520protected:
521 list<string> listViewsImpl();
522public:
523
524
525protected:
526 string getCreateSqlImpl(list<auto> l);
527public:
528
529
530 static string getCreateSql(list<auto> l);
531
533protected:
534 softint getNextSequenceValueImpl(string name);
535public:
536
537
539protected:
540 softint getCurrentSequenceValueImpl(string name);
541public:
542
543
545protected:
547public:
548
549
551protected:
553public:
554
555
557protected:
559public:
560
561
563protected:
564 bool rebuildIndexImpl(string name, *hash<auto> options);
565public:
566
567
569protected:
570 computeStatisticsImpl(*hash<auto> options);
571public:
572
573
575protected:
576 reclaimSpaceImpl(*hash<auto> options);
577public:
578
579
581protected:
583public:
584
585 };
586
589
590public:
592 const Sqlite3TypeMap = ...;
593
594
596 const QoreTypeMap = ...;
597
598
600 const Sqlite3CopMap = ...;
601
602
603 constructor(AbstractDatasource ds, string name, *hash<auto> opts) ;
604
605
607 string getSqlName();
608
609
611protected:
613public:
614
615
616protected:
617 bool checkExistenceImpl();
618public:
619
620
621protected:
622 Columns describeImpl();
623public:
624
625
626protected:
627 *string getCreatePrimaryKeySqlUnlocked(*hash<auto> opt, bool cache = True);
628public:
629
630
631protected:
632 Sqlite3PrimaryKey getPrimaryKeyImpl();
633public:
634
635
636protected:
637 Indexes getIndexesImpl();
638public:
639
640
641protected:
642 ForeignConstraints getForeignConstraintsImpl(*hash<auto> opts);
643public:
644
645
646protected:
647 Constraints getConstraintsImpl();
648public:
649
650
651protected:
652 Triggers getTriggersImpl();
653public:
654
655
656 string getCreateTableSqlImpl(*hash<auto> opt);
657
658
661
662
663protected:
664 *list getCreateMiscSqlImpl(*hash<auto> opt, bool cache);
665public:
666
667
668protected:
669 *list getAlignSqlImpl(AbstractTable table, *hash<auto> opt);
670public:
671
672
673protected:
674 string getCreateSqlImpl(list l);
675public:
676
677
678protected:
679 string getRenameSqlImpl(string new_name);
680public:
681
682
683protected:
684 AbstractColumn addColumnImpl(string cname, hash<auto> opt, bool nullable = True);
685public:
686
687
688protected:
689 setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
690public:
691
692
693protected:
694 addColumnToTableUnlocked(AbstractColumn c);
695public:
696
697
698protected:
699 AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash<auto> ch, *hash<auto> opt);
700public:
701
702
703protected:
704 AbstractIndex addIndexImpl(string iname, bool enabled, hash<auto> ch, *hash<auto> opt);
705public:
706
707
708protected:
709 AbstractForeignConstraint addForeignConstraintImpl(string cname, hash<auto> ch, string table, hash<auto> tch, *hash<auto> opt);
710public:
711
712
713protected:
714 AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash<auto> opt);
715public:
716
717
718protected:
719 AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash<auto> ch, *hash<auto> opt);
720public:
721
722
723protected:
724 AbstractTrigger addTriggerImpl(string tname, string src, *hash<auto> opt);
725public:
726
727
728protected:
729 bool tryInsertImpl(string sql, hash<auto> row);
730public:
731
732
734
736protected:
737 bool isDuplicateRowErrorImpl(hash<ExceptionInfo> ex);
738public:
739
740
741protected:
742 hash<auto> getQoreTypeMapImpl();
743public:
744
745
746protected:
747 hash<auto> getTypeMapImpl();
748public:
749
750
752protected:
753 *string getSqlValueImpl(auto v);
754public:
755
756
758protected:
759 static *string getSqlValueIntern(auto v);
760public:
761
762
764
766 string getColumnSqlName(string col);
767
768
770 list<string> getColumnSqlNames(softlist<auto> cols);
771
772
774
785 static *string getSqlValue(auto v);
786
787protected:
788 bool emptyImpl();
789public:
790
791
792protected:
793 preSetupTableImpl(reference<hash> desc, *hash<auto> opt);
794public:
795
796
797protected:
798 setupTableImpl(hash<auto> desc, *hash<auto> opt);
799public:
800
801
803protected:
805public:
806
807
809protected:
811public:
812
813
815protected:
817public:
818
819
821protected:
822 doSelectLimitOnlyInternImpl(reference<hash<QueryInfo>> info, reference<string> sql);
823public:
824
825
827protected:
828 doSelectOrderByWithOffsetSqlInternImpl(reference<hash<QueryInfo>> info, reference<string> sql, list<auto> coll);
829public:
830
831
833protected:
835public:
836
837
838protected:
839 *hash<auto> doReturningImpl(hash<auto> opt, reference<string> sql, list<auto> args);
840public:
841
842
843protected:
844 list<auto> getGroupOrderByListUnlocked(hash<QueryInfo> info, string key, list<auto> coll);
845public:
846
847
850
851
853protected:
854 copyImpl(AbstractTable old);
855public:
856
857
859protected:
860 AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash<auto> options);
861public:
862
863
865
869protected:
870 AbstractSavepointHelper getSavepointHelperImpl(*string savepoint);
871public:
872
873 };
874};
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:588
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...
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:596
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:600
doSelectLimitOnlyInternImpl(reference< hash< QueryInfo > > info, reference< string > sql)
processes a string for use in SQL select statements when there is a "limit" argument,...
const Sqlite3TypeMap
maps sqlite3 type names to type configurations
Definition Sqlite3SqlUtil.qm.dox.h:592
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...
doSelectOrderByWithOffsetSqlInternImpl(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
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