Qore MysqlSqlUtil Module Reference 1.5
Loading...
Searching...
No Matches
MysqlSqlUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* MysqlSqlUtil.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:
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
184namespace MysqlSqlUtil {
186 MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
187
188
190 MysqlDatabase get_database(AbstractDatasource nds, *hash opts);
191
192
193 parse_schema_name(string nname, reference<*string> schema, reference<string> name);
194
195
197class MysqlSavepointHelper : public AbstractSavepointHelper {
198
199public:
201 constructor(AbstractDatasource ds, *string savepoint) ;
202
203
205protected:
207public:
208
209
211protected:
213public:
214
215
217protected:
219public:
220
221 };
222
225
226public:
228 constructor(string native_type, bool nullable, *hash<auto> options) ;
229
230 };
231
234
235public:
236 string type;
237
239 constructor(string n_name, bool n_unique, hash n_cols, string n_type = 'BTREE') ;
240
241
243 string getCreateSql(string table_name, *hash opt);
244
245
247protected:
248 bool equalImpl(AbstractIndex ix);
249public:
250
251
253 string getRenameSql(string table_name, string new_name);
254
255
257 string getDropSql(string table_name);
258
259 };
260
263
264public:
265 constructor(string n, Columns c, ForeignConstraintTarget t) ;
266
267
268 string getCreateSql(string table_name, *hash opt);
269
270
272 softlist getRenameSql(string table_name, string new_name);
273
274
275 string getCreateSql(string name, string table_name, *hash opt);
276
277
278 string getAddSql(string name, string table_name, *hash opt);
279
280
282 string getDropSql(string table_name);
283
284 };
285
288
289public:
292
294protected:
296public:
297
298
299 constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, *softint bs, *int scale) ;
300
301
303
310 softlist<string> getAddColumnSql(AbstractTable t);
311
312
314 string getCreateSql(AbstractTable t);
315
316
318
334 softlist<string> getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
335
336
338
348 string getRenameSql(AbstractTable t, string new_name);
349
350
352
354 string getDdlName(string name);
355
356
358protected:
359 bool equalImpl(AbstractColumn c);
360public:
361
362 };
363
366
367public:
368 bool unsigned;
369 bool auto_increment;
370 // auto-incrememnt columns must be either "unique" or "primary key" in mysql
371 bool pk = False;
372
373protected:
374 // AUTO_INCREMENT applies only to integer and floating-point types
375 const AUTO_INCREMENT_VALID_TYPES = {
376 // int types
377 "tinyint": True,
378 "smallint": True,
379 "mediumint": True,
380 "int": True,
381 "bigint": True,
382 # float types
383 "float": True,
384 "real": True,
385 "double precision": True,
386 };
387
388public:
389
390 constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint scale, bool n_unsigned = False, bool n_auto_increment = False, bool n_pk = False)
391 ;
392
393
395private:
396 deserializeMembers(hash<auto> members);
397public:
398
399
400protected:
401 validateConstructor();
402public:
403
404
405 string getNativeTypeString();
406
407
409protected:
410 bool equalImpl(AbstractColumn c);
411public:
412
413 };
414
415class MysqlUniqueConstraintCommon : public SqlUtil::AbstractUniqueConstraint {
416
417public:
418 constructor();
419
420
421 bool setIndexBase(string ix);
422
423
425 clearIndex();
426
427
429 getIndexSql(reference<string> sql, string name, *hash opts);
430
431 };
432
433class MysqlUniqueConstraint : public SqlUtil::AbstractUniqueConstraint, public MysqlUniqueConstraintCommon {
434
435public:
436 constructor(string n, hash n_cols) ;
437
438
440
455 MysqlColumn memberGate(string k);
456
457
458 string getCreateSql(string table_name, *hash opts);
459
460
461 list getRenameSql(string table_name, string new_name);
462
463
464 string getCreateSql(string name, string table_name, *hash opts);
465
466
468 string getDropSql(string table_name);
469
470 };
471
473class MysqlPrimaryKey : public SqlUtil::AbstractPrimaryKey, public MysqlUniqueConstraintCommon {
474
475public:
476 constructor();
477
478
479 constructor(*hash c) ;
480
481
483
499
500
501 string getCreateSql(string table_name, *hash opts);
502
503
505 softlist getRenameSql(string table_name, string new_name);
506
507
509 string getDropSql(string table_name);
510
511
514
515 };
516
519
520public:
522 constructor(string n, string n_src) ;
523
524
526 softlist getCreateSql(string table_name, *hash opt);
527
528
530 softlist getDropSql(string table_name);
531
532
534protected:
535 bool equalImpl(AbstractFunctionBase t);
536public:
537
538
540 softlist getRenameSql(string table_name, string new_name);
541
542 };
543
546
547public:
548 constructor(string n, string n_src) ;
549
550
552 softlist getCreateSql(*hash opt);
553
554
556
558 string getDropSql(*hash opt);
559
560
562protected:
563 bool equalImpl(AbstractFunctionBase t);
564public:
565
566
568
571 softlist getRenameSql(string new_name, *hash opt);
572
573 };
574
577
578public:
579protected:
580 string table_name;
581
582public:
583
585 constructor(string n_table_name, string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
586
587
589 string getCreateSql(*hash opt);
590
591
593
596 softlist getRenameSql(string new_name, *hash opt);
597
598
600
602 string getDropSql(*hash opt);
603
604 };
605
608
609public:
613 *string checkoption;
615 *string definer;
618
620 constructor(string n_name, string n_src, *string n_tablecatalog, *string n_schema, *string n_checkoption, *string n_definer, *string n_securitytype, bool n_updatable)
621 ;
622
623
625 string getCreateSql(*hash opt);
626
627
629
632 softlist getRenameSql(string new_name, *hash opt);
633
634 };
635
638
639public:
641 const MysqlOptions = ...;
642
643
645 const MysqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + MysqlOptions;
646
648 const MysqlDatabaseOptions = AbstractDatabase::DatabaseOptions + MysqlOptions;
649
652
653
655 const MysqlSequenceFunction = "%s(seq_name varchar(40)) returns decimal(14) begin update %s set id = last_insert_id(id + 1) where name = seq_name;
656 return last_insert_id();
657end";
658
661
662
665
666
669
670
673
674protected:
675 string schema;
676
678 Datasource seqds;
679
680 string sequence_table = "sqlutil_sequences";
681 string sequence_function = "sqlutil_nextval";
682
683public:
684
685 constructor(AbstractDatasource nds, *hash opts) ;
686
687
689
694
695
697
702
703
704protected:
705 list<string> featuresImpl();
706public:
707
708
709 string getSchemaName();
710
711
712protected:
713 AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
714public:
715
716
717protected:
718 *AbstractSequence getSequenceImpl(string name);
719public:
720
721
722protected:
723 *AbstractView getViewImpl(string name);
724public:
725
726
727protected:
728 MysqlFunction makeFunctionImpl(string name, string src, *hash opts);
729public:
730
731
732protected:
733 MysqlFunction makeProcedureImpl(string name, string src, *hash opts);
734public:
735
736
737protected:
738 *AbstractFunction getFunctionImpl(string name);
739public:
740
741
742protected:
743 static string makeParameter(hash<auto> row);
744public:
745
746
747protected:
748 AbstractFunction getProcedureImpl(string name);
749public:
750
751
752protected:
753 list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
754public:
755
756
757protected:
758 list getAlignSqlImpl(hash schema_hash, *hash opt);
759public:
760
761
763protected:
764 list<string> listTablesImpl();
765public:
766
767
769
773protected:
774 list<string> listFunctionsImpl();
775public:
776
777
779
783protected:
784 list<string> listProceduresImpl();
785public:
786
787
788protected:
789 list<string> listSequencesImpl();
790public:
791
792
793protected:
794 list<string> listViewsImpl();
795public:
796
797
798protected:
799 string getCreateSqlImpl(list l);
800public:
801
802
803 static string getCreateSql(list l);
804
806protected:
808public:
809
810
812protected:
814public:
815
816
818protected:
820public:
821
822
824protected:
826public:
827
828
830protected:
831 softint getNextSequenceValueImpl(string name);
832public:
833
834
836protected:
837 softint getCurrentSequenceValueImpl(string name);
838public:
839
840
842protected:
844public:
845
846
848protected:
850public:
851
852
854protected:
856public:
857
858
860protected:
861 bool rebuildIndexImpl(string name, *hash options);
862public:
863
864
866protected:
867 computeStatisticsImpl(*hash options);
868public:
869
870
872protected:
873 reclaimSpaceImpl(*hash options);
874public:
875
876
878protected:
880public:
881
882 };
883
886
887public:
889 const MysqlTypeMap = {
890 "decimal": {
891 "qore": Type::Number,
892 "size": SZ_NUM,
893 },
894 "tinyint": ("qore": Type::Int, "ai": True,),
895 "smallint": ("qore": Type::Int, "ai": True,),
896 "mediumint": ("qore": Type::Int, "ai": True,),
897 "int": ("qore": Type::Int, "ai": True,),
898 "bigint": ("qore": Type::Int, "ai": True,),
899 "float": ("qore": Type::Float, "ai": True,),
900 "double": ("qore": Type::Float, "ai": True,),
901
902 "date": ("qore": Type::Date,),
903 "datetime": ("qore": Type::Date,),
904 "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
905 "time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
906 "year": ("qore": Type::Int,),
907
908 "char": {
909 "qore": Type::String,
910 "size": SZ_OPT,
911 "size_range": (0, 255),
912 },
913 "varchar": {
914 "qore": Type::String,
915 "size": SZ_MAND,
916 "size_range": (0, 65535),
917 "default_size": AbstractColumn::DefaultVarcharSize,
918 },
919
920 "binary": ("qore": Type::Binary, "size": SZ_OPT, "size_range": (0, 255)),
921 "varbinary": {
922 "qore": Type::Binary,
923 "size": SZ_MAND,
924 "size_range": (0, 65535),
925 "default_size": 80,
926 },
927
928 "tinytext": ("qore": Type::String,),
929 "text": ("qore": Type::String,),
930 "mediumtext": ("qore": Type::String,),
931 "longtext": ("qore": Type::String,),
932
933 "tinyblob": ("qore": Type::Binary,),
934 "blob": ("qore": Type::Binary,),
935 "mediumblob": ("qore": Type::Binary,),
936 "longblob": ("qore": Type::Binary,),
937
938 "bit": ("qore": Type::Int,),
939 };
940
942 const QoreTypeMap = ...;
943
944
946
954
955
957
963
964
965 const MysqlIndexOptions = AbstractTable::IndexOptions;
966
967 const MysqlConstraintOptions = ...;
968
969
970 const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
971
972 const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
973
975 const MysqlCopMap = ...;
976
977
979 const MysqlExpressionMap = DefaultExpressionMap + {
980 COP_CAST: {
981 "exp": <DataProviderExpressionInfo>{
982 "type": DET_Operator,
983 "label": COP_CAST,
984 "name": "cast",
985 "desc": "cast operator",
986 "symbol": "cast",
987 "args": (
988 DataProviderSignatureAnyType,
989 DataProviderSignatureStringValueType,
990 DataProviderSignatureOptionalIntValueType,
991 DataProviderSignatureOptionalIntValueType),
992 "varargs": True,
993 "return_type": AbstractDataProviderTypeMap."any",
994 },
995 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
996 string exp0 = info.table.getExpressionArg(\info, role, args[0],
997 AbstractDataProviderTypeMap."any");
998 string name = QoreTypeMap{args[1]} ?? args[1];
999 *hash<auto> desc = MysqlTypeMap{name};
1000 string sql = sprintf ("cast (%s as %s", exp0, name);
1001 if (desc.size == SZ_MAND) {
1002 if (!exists args[1] && !exists desc.size_range)
1003 throw "OPERATOR-ERROR", sprintf ("cast operator missing size for type %s",
1004 name);
1005 sql += sprintf("(%d)", args[1] ?? desc.size_range[1]);
1006 } else if (desc.size == SZ_NUM && exists args[1]) {
1007 sql += sprintf("(%d", args[1]);
1008 sql += exists args[2] ? sprintf(",%d)", args[2]) : ")";
1009 } else if (desc.size == SZ_OPT && exists args[1]) {
1010 sql += sprintf("(%d)", args[1]);
1011 }
1012 sql += ")";
1013 return sql;
1014 },
1015 },
1016 COP_PREPEND: DefaultExpressionMap{COP_PREPEND} + {
1017 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1018 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1019 AbstractDataProviderTypeMap."string");
1020 string exp1 = info.table.getExpressionArg(\info, role, args[1],
1021 AbstractDataProviderTypeMap."string");
1022 return sprintf("concat(%s, %s)", exp1, exp0);
1023 },
1024 },
1025 COP_APPEND: DefaultExpressionMap{COP_APPEND} + {
1026 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1027 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1028 AbstractDataProviderTypeMap."string");
1029 string exp1 = info.table.getExpressionArg(\info, role, args[1],
1030 AbstractDataProviderTypeMap."string");
1031 return sprintf("concat(%s, %s)", exp0, exp1);
1032 },
1033 },
1034 COP_YEAR: {
1035 "exp": <DataProviderExpressionInfo>{
1036 "type": DET_Operator,
1037 "label": COP_YEAR,
1038 "name": COP_YEAR,
1039 "desc": "returns the year component of a date as a string (ex: `2022`)",
1040 "symbol": COP_YEAR,
1041 "args": (
1042 DataProviderSignatureDateType,
1043 ),
1044 "return_type": AbstractDataProviderTypeMap."string",
1045 },
1046 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1047 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1048 AbstractDataProviderTypeMap."date");
1049 return sprintf("date_format(%s, '%%Y')", exp0);
1050 }
1051 },
1052 COP_YEAR_MONTH: {
1053 "exp": <DataProviderExpressionInfo>{
1054 "type": DET_Operator,
1055 "label": COP_YEAR_MONTH,
1056 "name": COP_YEAR_MONTH,
1057 "desc": "returns the year and month components of a date as a string (ex: `2022-06`)",
1058 "symbol": COP_YEAR_MONTH,
1059 "args": (
1060 DataProviderSignatureDateType,
1061 ),
1062 "return_type": AbstractDataProviderTypeMap."string",
1063 },
1064 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1065 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1066 AbstractDataProviderTypeMap."date");
1067 return sprintf("date_format(%s, '%%Y-%%m')", exp0);
1068 }
1069 },
1070 COP_YEAR_DAY: {
1071 "exp": <DataProviderExpressionInfo>{
1072 "type": DET_Operator,
1073 "label": COP_YEAR_DAY,
1074 "name": COP_YEAR_DAY,
1075 "desc": "returns the year, month, and day components of a date as a string (ex: `2022-06-29`)",
1076 "symbol": COP_YEAR_DAY,
1077 "args": (
1078 DataProviderSignatureDateType,
1079 ),
1080 "return_type": AbstractDataProviderTypeMap."string",
1081 },
1082 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1083 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1084 AbstractDataProviderTypeMap."date");
1085 return sprintf("date_format(%s, '%%Y-%%m-%%e')", exp0);
1086 }
1087 },
1088 COP_YEAR_HOUR: {
1089 "exp": <DataProviderExpressionInfo>{
1090 "type": DET_Operator,
1091 "label": COP_YEAR_HOUR,
1092 "name": COP_YEAR_HOUR,
1093 "desc": "returns the year, month, day, and hour components of a date as a string "
1094 "(ex: `2022-06-29 15`)",
1095 "symbol": COP_YEAR_HOUR,
1096 "args": (
1097 DataProviderSignatureDateType,
1098 ),
1099 "return_type": AbstractDataProviderTypeMap."string",
1100 },
1101 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1102 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1103 AbstractDataProviderTypeMap."date");
1104 return sprintf("date_format(%s, '%%Y-%%m-%%e %%k')", exp0);
1105 }
1106 },
1107 COP_TRUNC_DATE: {
1108 "exp": <DataProviderExpressionInfo>{
1109 "type": DET_Operator,
1110 "label": COP_TRUNC_DATE,
1111 "name": COP_TRUNC_DATE,
1112 "desc": "truncates the given date to the given resolution; args: date, string code: Y: year, "
1113 "M: month, D: day, H: hour, m: minute, S: second",
1114 "symbol": COP_TRUNC_DATE,
1115 "args": (
1116 DataProviderSignatureDateType,
1117 DataProviderSignatureStringValueType,
1118 ),
1119 "return_type": AbstractDataProviderTypeMap."date",
1120 },
1121 "code": string sub(reference<hash<QueryInfo>> info, int role, list<auto> args) {
1122 *string str = MysqlTruncDate{args[1]};
1123 if (!str) {
1124 throw "COP-TRUNC-DATE-ERROR", sprintf("unknown date truncation format argument %y; "
1125 "supported date format arguments: %y", args[1], keys MysqlTruncDate);
1126 }
1127 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1128 AbstractDataProviderTypeMap."date");
1129 return sprintf("cast(date_format(%s, %s) as datetime)", exp0, str);
1130 },
1131 },
1132 };
1133
1135 const MysqlOpMap = DefaultOpMap + {
1136 COP_PREPEND: {
1137 "arg": Type::String,
1138 "sqlvalue": True,
1139 "code": string sub (string cve, string arg) {
1140 return sprintf("concat(%s, %s)", arg, cve);
1141 },
1142 },
1143 COP_APPEND: {
1144 "arg": Type::String,
1145 "sqlvalue": True,
1146 "code": string sub (string cve, string arg) {
1147 return sprintf("concat(%s, %s)", cve, arg);
1148 },
1149 },
1150 };
1151
1154 DT_YEAR : "'%Y-01-01 00:00:00'",
1155 DT_MONTH : "'%Y-%m-01 00:00:00'",
1156 DT_DAY : "'%Y-%m-%d 00:00:00'",
1157 DT_HOUR : "'%Y-%m-%d %H:00:00'",
1158 DT_MINUTE: "'%Y-%m-%d %H:%i:00'",
1159 DT_SECOND: "'%Y-%m-%d %H:%i:%s'",
1160 };
1161
1162protected:
1163 string schema;
1164 string engine = "innodb";
1165 string collation;
1166 string table_encoding;
1167
1168public:
1169
1170 constructor(AbstractDatasource nds, string nname, *hash opts) ;
1171
1172
1174 string getSqlName();
1175
1176
1178 hash<auto> getExpressionMap();
1179
1180
1183
1184
1185protected:
1186 hash getTableCreationOptions();
1187public:
1188
1189
1190protected:
1191 hash getTableDescriptionHashOptions();
1192public:
1193
1194
1195protected:
1196 hash getColumnDescOptions();
1197public:
1198
1199
1200protected:
1201 hash getIndexOptions();
1202public:
1203
1204
1205protected:
1206 hash getConstraintOptions();
1207public:
1208
1209
1210protected:
1211 hash getAlignTableOptions();
1212public:
1213
1214
1216protected:
1218public:
1219
1220
1221protected:
1222 bool checkExistenceImpl();
1223public:
1224
1225
1226protected:
1227 Columns describeImpl();
1228public:
1229
1230
1231protected:
1232 *string getCreatePrimaryKeySqlUnlocked(*hash opt, bool cache = True);
1233public:
1234
1235
1236protected:
1237 MysqlPrimaryKey getPrimaryKeyImpl();
1238public:
1239
1240
1241protected:
1242 Indexes getIndexesImpl();
1243public:
1244
1245
1246protected:
1247 ForeignConstraints getForeignConstraintsImpl(*hash opts);
1248public:
1249
1250
1251protected:
1252 Constraints getConstraintsImpl();
1253public:
1254
1255
1256protected:
1257 Triggers getTriggersImpl();
1258public:
1259
1260
1261 string getCreateTableSqlImpl(*hash opt);
1262
1263
1266
1267
1268protected:
1269 *list getCreateMiscSqlImpl(*hash opt, bool cache);
1270public:
1271
1272
1273protected:
1274 *list getAlignSqlImpl(AbstractTable table, *hash opt);
1275public:
1276
1277
1278protected:
1279 string getCreateSqlImpl(list l);
1280public:
1281
1282
1283protected:
1284 string getRenameSqlImpl(string new_name);
1285public:
1286
1287
1288protected:
1289 AbstractColumn addColumnImpl(string cname, hash<auto> opt, bool nullable = True);
1290public:
1291
1292
1293protected:
1294 setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
1295public:
1296
1297
1298protected:
1299 addColumnToTableUnlocked(AbstractColumn c);
1300public:
1301
1302
1303protected:
1304 AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1305public:
1306
1307
1308protected:
1309 AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1310public:
1311
1312
1313protected:
1314 AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1315public:
1316
1317
1318protected:
1319 AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1320public:
1321
1322
1323protected:
1324 AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1325public:
1326
1327
1328protected:
1329 AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1330public:
1331
1332
1333protected:
1334 bool tryInsertImpl(string sql, hash<auto> row);
1335public:
1336
1337
1339
1341protected:
1342 bool isDuplicateRowErrorImpl(hash<ExceptionInfo> ex);
1343public:
1344
1345
1346protected:
1347 hash getQoreTypeMapImpl();
1348public:
1349
1350
1351protected:
1352 hash getTypeMapImpl();
1353public:
1354
1355
1357protected:
1358 *string getSqlValueImpl(auto v);
1359public:
1360
1361
1363protected:
1364 static *string getSqlValueIntern(auto v);
1365public:
1366
1367
1369
1371 string getColumnSqlName(string col);
1372
1373
1375 list getColumnSqlNames(softlist cols);
1376
1377
1379
1390 static *string getSqlValue(auto v);
1391
1392protected:
1393 bool emptyImpl();
1394public:
1395
1396
1397protected:
1398 preSetupTableImpl(reference<hash> desc, *hash opt);
1399public:
1400
1401
1402protected:
1403 setupTableImpl(hash desc, *hash opt);
1404public:
1405
1406
1408protected:
1410public:
1411
1412
1414protected:
1416public:
1417
1418
1420protected:
1422public:
1423
1424
1426protected:
1427 doSelectLimitOnlyUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql);
1428public:
1429
1430
1432protected:
1433 doSelectOrderByWithOffsetSqlUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql, list<auto> coll);
1434public:
1435
1436
1438protected:
1440public:
1441
1442
1443protected:
1444 *hash<auto> doReturningImpl(hash<auto> opt, reference<string> sql, list<auto> args);
1445public:
1446
1447
1448protected:
1449 list<auto> getGroupOrderByListUnlocked(hash<QueryInfo> info, string key, list<auto> coll);
1450public:
1451
1452
1455
1456
1458protected:
1459 copyImpl(AbstractTable old);
1460public:
1461
1462
1464protected:
1465 AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash<auto> options);
1466public:
1467
1468
1470
1474protected:
1475 AbstractSavepointHelper getSavepointHelperImpl(*string savepoint);
1476public:
1477
1478 };
1479};
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:287
softlist< string > getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table
softlist< string > getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
constructor()
empty constructor for subclasses
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:291
string getDdlName(string name)
returns the column name with quoting in case the column name is a reserved word
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:637
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:651
const MysqlComputeStatisticsOptions
Options for computeStatistics()
Definition: MysqlSqlUtil.qm.dox.h:660
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:645
bool requiresScale()
Returns True if the driver requires a scale to support decimal values in numeric or decimal columns.
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:678
list< string > listProceduresImpl()
returns a list of string procedure names in the database
int getMaximumPrecision()
Returns the maximum precision for numeric or decimal columns.
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
const MysqlMaxPrecision
Maximum precision.
Definition: MysqlSqlUtil.qm.dox.h:672
bool supportsPackagesImpl()
returns True if the database supports packages
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
int getPhysicalSizeImpl()
SqlUtil::AbstractDatabase::getPhysicalSize()
const MysqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: MysqlSqlUtil.qm.dox.h:664
const MysqlReservedWords
hash of reserved words
Definition: MysqlSqlUtil.qm.dox.h:668
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics()
hash getDatabaseOptions()
returns driver-specific options to the base abstract class
const MysqlSequenceFunction
MySQL sequence function.
Definition: MysqlSqlUtil.qm.dox.h:655
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
list< string > listFunctionsImpl()
returns a list of string function names in the database
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
bool supportsTypesImpl()
returns True if the database supports named types
list< string > listTablesImpl()
returns a list of string table names in the database
hash getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in MySQL
const MysqlOptions
MySQL-specific options.
Definition: MysqlSqlUtil.qm.dox.h:641
const MysqlDatabaseOptions
MySQL-specific database options.
Definition: MysqlSqlUtil.qm.dox.h:648
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:262
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 MySQL does not support renaming cons...
represents a MySQL-specific function
Definition: MysqlSqlUtil.qm.dox.h:545
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:233
constructor(string n_name, bool n_unique, hash n_cols, string n_type='BTREE')
creates the object from the arguments
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database; hwoever mysql does not support...
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
the data type for DECIMAL columns
Definition: MysqlSqlUtil.qm.dox.h:224
constructor(string native_type, bool nullable, *hash< auto > options)
creates the object
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:365
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
deserializeMembers(hash< auto > members)
deserializes the hash to a replica of the original object
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:473
MysqlColumn memberGate(string k)
returns the MysqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
bool supportsName()
returns False since primary key constraints in MySQL have no name
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
MySQL savepoint helper.
Definition: MysqlSqlUtil.qm.dox.h:197
deleteSavepointImpl()
Deletes the savepoint.
createSavepointImpl()
Creates the savepoint.
constructor(AbstractDatasource ds, *string savepoint)
Creates the object.
rollbackImpl()
Rolls back to the savepoint.
class for MySQL sequences based on a sequence table and autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:576
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
string getDropSql(*hash opt)
returns a string that can be used to drop the sequence from the database
constructor(string n_table_name, string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:885
hash< auto > getExpressionMap()
Returns the expression map for MySQL.
bool isDuplicateRowErrorImpl(hash< ExceptionInfo > ex)
Returns True if the exception was raised because of a duplicate row / key error.
hash< auto > getWhereOperatorMap()
returns the "where" operator map for MySQL
bool hasReturningImpl()
returns True if the current driver supports the "returning" clause in insert statements
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
const QoreTypeMap
maps qore type names to MySQL type names
Definition: MysqlSqlUtil.qm.dox.h:942
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
doSelectLimitOnlyUnlockedImpl(reference< hash< QueryInfo > > info, reference< string > sql)
processes a string for use in SQL select statements when there is a "limit" argument,...
const MysqlTypeMap
maps mysql type names to type configurations
Definition: MysqlSqlUtil.qm.dox.h:889
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...
hash getColumnOperatorMapImpl()
returns the column operator map for this object
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,...
static *string getSqlValue(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument
bool hasArrayBind()
returns False because the mysql driver does not support array binds / bulk DML operations
const MysqlOpMap
where operator specializations for MySQL
Definition: MysqlSqlUtil.qm.dox.h:1135
const MysqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions
Definition: MysqlSqlUtil.qm.dox.h:953
const MysqlExpressionMap
MySQL Expression map.
Definition: MysqlSqlUtil.qm.dox.h:979
const MysqlTruncDate
Map SqlUtil::cop_trunc_date() constants for internal masks.
Definition: MysqlSqlUtil.qm.dox.h:1153
const MysqlCopMap
column operator specializations for MySQL
Definition: MysqlSqlUtil.qm.dox.h:975
const MysqlColumnDescOptions
extends SqlUtil::AbstractTable::ColumnDescOptions with MySQL-specific values
Definition: MysqlSqlUtil.qm.dox.h:962
static *string getSqlValueIntern(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
copyImpl(AbstractTable old)
db-specific copy actions
AbstractSavepointHelper getSavepointHelperImpl(*string savepoint)
get DB-specific savepoint helper
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
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
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:518
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
softlist getCreateSql(string table_name, *hash 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
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
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:607
constructor(string n_name, string n_src, *string n_tablecatalog, *string n_schema, *string n_checkoption, *string n_definer, *string n_securitytype, bool n_updatable)
creates the object from the arguments
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:611
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:615
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:613
*string securitytype
security type value
Definition: MysqlSqlUtil.qm.dox.h:617
cache(*hash< auto > opts)
the MysqlSqlUtil namespace contains all the objects in the MysqlSqlUtil module
Definition: MysqlSqlUtil.qm.dox.h:184
MysqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a MysqlDatabase object corresponding to the arguments
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a MysqlTable object corresponding to the arguments