Qore MysqlSqlUtil Module Reference  1.2.1
 All Classes Namespaces Functions Variables Groups Pages
MysqlSqlUtil.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file MysqlSqlUtil.qm Qore user module for working with MySQL SQL data
3 
4 /* MysqlSqlUtil.qm Copyright 2013 - 2017 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 
142 namespace MysqlSqlUtil {
145  MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
146 
147 
149  MysqlDatabase get_database(AbstractDatasource nds, *hash opts);
150 
151 
152  parse_schema_name(string nname, reference<*string> schema, reference<string> name);
153 
154 
157 
158 public:
159  public :
160  string type;
161 
162 public:
163 
165  constructor(string n_name, bool n_unique, hash n_cols, string n_type = "BTREE") ;
166 
167 
169  string getCreateSql(string table_name, *hash opt);
170 
171 
173 
174 private:
175  bool equalImpl(AbstractIndex ix);
176 public:
177 
178 
180  string getRenameSql(string table_name, string new_name);
181 
182 
184  string getDropSql(string table_name);
185 
186  };
187 
190 
191 public:
192  constructor(string n, Columns c, ForeignConstraintTarget t) ;
193 
194 
195  string getCreateSql(string table_name, *hash opt);
196 
197 
199  softlist getRenameSql(string table_name, string new_name);
200 
201 
202  string getCreateSql(string name, string table_name, *hash opt);
203 
204 
205  string getAddSql(string name, string table_name, *hash opt);
206 
207 
209  string getDropSql(string table_name);
210 
211  };
212 
215 
216 public:
217  public :
220 
221 public:
222 
223  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
224 
225 
227 
234  softlist getAddColumnSql(AbstractTable t);
235 
236 
238  string getCreateSql(AbstractTable t);
239 
240 
242 
255  softlist getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
256 
257 
259 
269  string getRenameSql(AbstractTable t, string new_name);
270 
271 
273 
274 private:
275  bool equalImpl(AbstractColumn c);
276 public:
277 
278  };
279 
282 
283 public:
284  public :
285  bool unsigned;
286  bool auto_increment;
287  // auto-incrememnt columns must be either "unique" or "primary key" in mysql
288  bool pk = False;
289 
290 public:
291 
292  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale, bool n_unsigned = False, bool n_auto_increment = False, bool n_pk = False) ;
293 
294 
295  string getNativeTypeString();
296 
297 
299 
300 private:
301  bool equalImpl(AbstractColumn c);
302 public:
303 
304  };
305 
306 class MysqlUniqueConstraintCommon : public SqlUtil::AbstractUniqueConstraint {
307 
308 public:
309  constructor();
310 
311 
312  bool setIndexBase(string ix);
313 
314 
316  clearIndex();
317 
318 
319  abstract AbstractIterator keyIterator();
320 
322  getIndexSql(reference<string> sql, string name, *hash opts);
323 
324  };
325 
326 class MysqlUniqueConstraint : public SqlUtil::AbstractUniqueConstraint,public MysqlUniqueConstraintCommon {
327 
328 public:
329  constructor(string n, hash n_cols) ;
330 
331 
333 
348  MysqlColumn memberGate(string k);
349 
350 
351  string getCreateSql(string table_name, *hash opts);
352 
353 
354  list getRenameSql(string table_name, string new_name);
355 
356 
357  string getCreateSql(string name, string table_name, *hash opts);
358 
359 
361  string getDropSql(string table_name);
362 
363  };
364 
366 class MysqlPrimaryKey : public SqlUtil::AbstractPrimaryKey,public MysqlUniqueConstraintCommon {
367 
368 public:
369  constructor();
370 
371 
372  constructor(*hash c) ;
373 
374 
376 
391  MysqlColumn memberGate(string k);
392 
393 
394  string getCreateSql(string table_name, *hash opts);
395 
396 
398  softlist getRenameSql(string table_name, string new_name);
399 
400 
402  string getDropSql(string table_name);
403 
404 
406  bool supportsName();
407 
408  };
409 
412 
413 public:
415  constructor(string n, string n_src) ;
416 
417 
419  softlist getCreateSql(string table_name, *hash opt);
420 
421 
423  softlist getDropSql(string table_name);
424 
425 
427 
428 private:
429  bool equalImpl(AbstractFunctionBase t);
430 public:
431 
432 
434  softlist getRenameSql(string table_name, string new_name);
435 
436  };
437 
440 
441 public:
442  constructor(string n, string n_src) ;
443 
444 
446  softlist getCreateSql(*hash opt);
447 
448 
450 
452  string getDropSql(*hash opt);
453 
454 
456 
457 private:
458  bool equalImpl(AbstractFunctionBase t);
459 public:
460 
461 
463 
466  softlist getRenameSql(string new_name, *hash opt);
467 
468  };
469 
472 
473 public:
474  private :
475  string table_name;
476 
477 public:
478 
480  constructor(string n_table_name, string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
481 
482 
484  string getCreateSql(*hash opt);
485 
486 
488 
491  softlist getRenameSql(string new_name, *hash opt);
492 
493 
495 
497  string getDropSql(*hash opt);
498 
499  };
500 
503 
504 public:
505  public :
507  *string tablecatalog;
509  *string checkoption;
511  *string definer;
513  *string securitytype;
514 
515 public:
516 
518  constructor(string n_name, string n_src, *string n_tablecatalog,
519  *string n_schema,
520  *string n_checkoption, *string n_definer,
521  *string n_securitytype, bool n_updatable)
522  ;
523 
524 
526  string getCreateSql(*hash opt);
527 
528 
530 
533  softlist getRenameSql(string new_name, *hash opt);
534 
535  };
536 
539 
540 public:
541  public :
543  const MysqlOptions = (
544  "sequence_table": Type::String,
545  "sequence_function": Type::String,
546  );
547 
549  const MysqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + MysqlOptions;
550 
552  const MysqlDatabaseOptions = AbstractDatabase::DatabaseOptions + MysqlOptions;
553 
556  "columns": (
557  "name": (
558  "qore_type": SqlUtil::VARCHAR,
559  "size": 40,
560  "notnull": True,
561  ),
562  "id": (
563  "qore_type": Type::Number,
564  "size": 14,
565  "notnull": True,
566  ),
567  ),
568  );
569 
571  const MyusqlCreationOptions = AbstractDatabase::CreationOptions;
572 
574  const MysqlSequenceFunction = "%s(seq_name varchar(40)) returns decimal(14)
575 begin
576  update %s set id = last_insert_id(id + 1) where name = seq_name;
577  return last_insert_id();
578 end";
579 
582  "no-binlog" : Type::Boolean,
583  );
584 
587  "no-binlog" : Type::Boolean,
588  );
589 
592  "accessible" : True,
593  "add" : True,
594  "all" : True,
595  "alter" : True,
596  "analyze" : True,
597  "and" : True,
598  "as" : True,
599  "asc" : True,
600  "asensitive" : True,
601  "before" : True,
602  "between" : True,
603  "bigint" : True,
604  "binary" : True,
605  "blob" : True,
606  "both" : True,
607  "by" : True,
608  "call" : True,
609  "cascade" : True,
610  "case" : True,
611  "change" : True,
612  "char" : True,
613  "character" : True,
614  "check" : True,
615  "collate" : True,
616  "column" : True,
617  "condition" : True,
618  "constraint" : True,
619  "continue" : True,
620  "convert" : True,
621  "create" : True,
622  "cross" : True,
623  "current_date" : True,
624  "current_time" : True,
625  "current_timestamp" : True,
626  "current_user" : True,
627  "cursor" : True,
628  "database" : True,
629  "databases" : True,
630  "day_hour" : True,
631  "day_microsecond" : True,
632  "day_minute" : True,
633  "day_second" : True,
634  "dec" : True,
635  "decimal" : True,
636  "declare" : True,
637  "default" : True,
638  "delayed" : True,
639  "delete" : True,
640  "desc" : True,
641  "describe" : True,
642  "deterministic" : True,
643  "distinct" : True,
644  "distinctrow" : True,
645  "div" : True,
646  "double" : True,
647  "drop" : True,
648  "dual" : True,
649  "each" : True,
650  "else" : True,
651  "elseif" : True,
652  "enclosed" : True,
653  "escaped" : True,
654  "exists" : True,
655  "exit" : True,
656  "explain" : True,
657  "false" : True,
658  "fetch" : True,
659  "float" : True,
660  "float4" : True,
661  "float8" : True,
662  "for" : True,
663  "force" : True,
664  "foreign" : True,
665  "from" : True,
666  "fulltext" : True,
667  "get" : True,
668  "grant" : True,
669  "group" : True,
670  "having" : True,
671  "high_priority" : True,
672  "hour_microsecond" : True,
673  "hour_minute" : True,
674  "hour_second" : True,
675  "if" : True,
676  "ignore" : True,
677  "in" : True,
678  "index" : True,
679  "infile" : True,
680  "inner" : True,
681  "inout" : True,
682  "insensitive" : True,
683  "insert" : True,
684  "int" : True,
685  "int1" : True,
686  "int2" : True,
687  "int3" : True,
688  "int4" : True,
689  "int8" : True,
690  "integer" : True,
691  "interval" : True,
692  "into" : True,
693  "io_after_gtids" : True,
694  "io_before_gtids" : True,
695  "is" : True,
696  "iterate" : True,
697  "join" : True,
698  "key" : True,
699  "keys" : True,
700  "kill" : True,
701  "leading" : True,
702  "leave" : True,
703  "left" : True,
704  "like" : True,
705  "limit" : True,
706  "linear" : True,
707  "lines" : True,
708  "load" : True,
709  "localtime" : True,
710  "localtimestamp" : True,
711  "lock" : True,
712  "long" : True,
713  "longblob" : True,
714  "longtext" : True,
715  "loop" : True,
716  "low_priority" : True,
717  "master_bind" : True,
718  "master_ssl_verify_server_cert" : True,
719  "match" : True,
720  "maxvalue" : True,
721  "mediumblob" : True,
722  "mediumint" : True,
723  "mediumtext" : True,
724  "middleint" : True,
725  "minute_microsecond" : True,
726  "minute_second" : True,
727  "mod" : True,
728  "modifies" : True,
729  "natural" : True,
730  "not" : True,
731  "no_write_to_binlog" : True,
732  "null" : True,
733  "numeric" : True,
734  "on" : True,
735  "optimize" : True,
736  "option" : True,
737  "optionally" : True,
738  "or" : True,
739  "order" : True,
740  "out" : True,
741  "outer" : True,
742  "outfile" : True,
743  "partition" : True,
744  "precision" : True,
745  "primary" : True,
746  "procedure" : True,
747  "purge" : True,
748  "range" : True,
749  "read" : True,
750  "reads" : True,
751  "read_write" : True,
752  "real" : True,
753  "references" : True,
754  "regexp" : True,
755  "release" : True,
756  "rename" : True,
757  "repeat" : True,
758  "replace" : True,
759  "require" : True,
760  "resignal" : True,
761  "restrict" : True,
762  "return" : True,
763  "revoke" : True,
764  "right" : True,
765  "rlike" : True,
766  "schema" : True,
767  "schemas" : True,
768  "second_microsecond" : True,
769  "select" : True,
770  "sensitive" : True,
771  "separator" : True,
772  "set" : True,
773  "show" : True,
774  "signal" : True,
775  "smallint" : True,
776  "spatial" : True,
777  "specific" : True,
778  "sql" : True,
779  "sqlexception" : True,
780  "sqlstate" : True,
781  "sqlwarning" : True,
782  "sql_big_result" : True,
783  "sql_calc_found_rows" : True,
784  "sql_small_result" : True,
785  "ssl" : True,
786  "starting" : True,
787  "straight_join" : True,
788  "table" : True,
789  "terminated" : True,
790  "then" : True,
791  "tinyblob" : True,
792  "tinyint" : True,
793  "tinytext" : True,
794  "to" : True,
795  "trailing" : True,
796  "trigger" : True,
797  "true" : True,
798  "undo" : True,
799  "union" : True,
800  "unique" : True,
801  "unlock" : True,
802  "unsigned" : True,
803  "update" : True,
804  "usage" : True,
805  "use" : True,
806  "using" : True,
807  "utc_date" : True,
808  "utc_time" : True,
809  "utc_timestamp" : True,
810  "values" : True,
811  "varbinary" : True,
812  "varchar" : True,
813  "varcharacter" : True,
814  "varying" : True,
815  "when" : True,
816  "where" : True,
817  "while" : True,
818  "with" : True,
819  "write" : True,
820  "xor" : True,
821  "year_month" : True,
822  "zerofill" : True,
823  );
824 
825 public:
826 
827  private :
828  string schema;
829 
831  Datasource seqds;
832 
833  string sequence_table = "sqlutil_sequences";
834  string sequence_function = "sqlutil_nextval";
835 
836 public:
837 
838  constructor(AbstractDatasource nds, *hash opts) ;
839 
840 
841 
842 private:
843  list featuresImpl();
844 public:
845 
846 
847  string getSchemaName();
848 
849 
850 
851 private:
852  AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
853 public:
854 
855 
856 
857 private:
858  *AbstractSequence getSequenceImpl(string name);
859 public:
860 
861 
862 
863 private:
864  *AbstractView getViewImpl(string name);
865 public:
866 
867 
868 
869 private:
870  MysqlFunction makeFunctionImpl(string name, string src, *hash opts);
871 public:
872 
873 
874 
875 private:
876  MysqlFunction makeProcedureImpl(string name, string src, *hash opts);
877 public:
878 
879 
880 
881 private:
882  *AbstractFunction getFunctionImpl(string name);
883 public:
884 
885 
886 
887 private:
888  static string makeParameter(hash row);
889 public:
890 
891 
892 
893 private:
894  AbstractFunction getProcedureImpl(string name);
895 public:
896 
897 
898 
899 private:
900  list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
901 public:
902 
903 
904 
905 private:
906  list getAlignSqlImpl(hash schema_hash, *hash opt);
907 public:
908 
909 
911 
912 private:
914 public:
915 
916 
918 
923 private:
925 public:
926 
927 
929 
934 private:
936 public:
937 
938 
939 
940 private:
941  list listSequencesImpl();
942 public:
943 
944 
945 
946 private:
947  list listViewsImpl();
948 public:
949 
950 
951 
952 private:
953  string getCreateSqlImpl(list l);
954 public:
955 
956 
957  static string getCreateSql(list l);
958 
960 
961 private:
963 public:
964 
965 
967 
968 private:
970 public:
971 
972 
974 
975 private:
977 public:
978 
979 
981 
982 private:
984 public:
985 
986 
988 
989 private:
990  softint getNextSequenceValueImpl(string name);
991 public:
992 
993 
995 
996 private:
997  softint getCurrentSequenceValueImpl(string name);
998 public:
999 
1000 
1002 
1003 private:
1004  bool supportsSequencesImpl();
1005 public:
1006 
1007 
1009 
1010 private:
1011  bool supportsTypesImpl();
1012 public:
1013 
1014 
1016 
1017 private:
1018  bool supportsPackagesImpl();
1019 public:
1020 
1021 
1023 
1024 private:
1025  bool rebuildIndexImpl(string name, *hash options);
1026 public:
1027 
1028 
1030 
1031 private:
1032  computeStatisticsImpl(*hash options);
1033 public:
1034 
1035 
1037 
1038 private:
1039  reclaimSpaceImpl(*hash options);
1040 public:
1041 
1042  };
1043 
1046 
1047 public:
1048  public :
1050  const MysqlTypeMap = (
1051  "decimal": ("qore": Type::Number, "size": SZ_NUM,),
1052  "tinyint": ("qore": Type::Int, "ai": True,),
1053  "smallint": ("qore": Type::Int, "ai": True,),
1054  "mediumint": ("qore": Type::Int, "ai": True,),
1055  "int": ("qore": Type::Int, "ai": True,),
1056  "bigint": ("qore": Type::Int, "ai": True,),
1057  "float": ("qore": Type::Float, "ai": True,),
1058  "double": ("qore": Type::Float, "ai": True,),
1059 
1060  "date": ("qore": Type::Date,),
1061  "datetime": ("qore": Type::Date,),
1062  "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6),"default_size": 6,),
1063  "time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6),"default_size": 6,),
1064  "year": ("qore": Type::Int,),
1065 
1066  "char": ("qore": Type::String, "size": SZ_OPT, "size_range": (0, 255)),
1067  "varchar": ("qore": Type::String, "size": SZ_MAND, "size_range": (0, 65535)),
1068 
1069  "binary": ("qore": Type::Binary, "size": SZ_OPT, "size_range": (0, 255)),
1070  "varbinary": ("qore": Type::Binary, "size": SZ_MAND, "size_range": (0, 65535)),
1071 
1072  "tinytext": ("qore": Type::String,),
1073  "text": ("qore": Type::String,),
1074  "mediumtext": ("qore": Type::String,),
1075  "longtext": ("qore": Type::String,),
1076 
1077  "tinyblob": ("qore": Type::Binary,),
1078  "blob": ("qore": Type::Binary,),
1079  "mediumblob": ("qore": Type::Binary,),
1080  "longblob": ("qore": Type::Binary,),
1081 
1082  "bit": ("qore": Type::Int,),
1083  );
1084 
1086  const QoreTypeMap = (
1087  "integer": "bigint",
1088  "float": "double",
1089  "number": "decimal",
1090  "string": "varchar",
1091  "date": "datetime",
1092  "binary": "varbinary",
1093  "bool": "tinyint",
1094  SqlUtil::CHAR: "char",
1095  SqlUtil::CLOB: "mediumtext",
1096  SqlUtil::BLOB: "mediumblob",
1097  );
1098 
1100  const MysqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
1101  "engine": Type::String,
1102  );
1103 
1105 
1110  const MysqlColumnDescOptions = AbstractTable::ColumnDescOptions + (
1111  "unsigned": Type::Boolean,
1112  "auto_increment": Type::Boolean,
1113  "pk": Type::Boolean,
1114  );
1115 
1116  const MysqlIndexOptions = AbstractTable::IndexOptions;
1117 
1118  const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
1119  "index": Type::String,
1120  );
1121 
1122  const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
1123 
1124  const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
1125 
1127  const MysqlCopMap = (
1128  COP_CAST: (
1129  "code": string (string cve, list args) {
1130  string name = QoreTypeMap{args[0]} ?? args[0];
1131  if (name == "varchar") name = "char"; // NOTE: due to current MariaSQL issue ("ERROR 1064 (42000)")
1132  hash desc = MysqlTypeMap{name};
1133  string sql = sprintf ("cast(%s as %s", cve, name);
1134  switch (name);
1135 
1136  sql += ")";
1137  return sql;
1138  },
1139  ),
1140  COP_PREPEND: (
1141  "arg": Type::String,
1142  "sqlvalue": True,
1143  "code": string (string cve, string arg) {
1144  return sprintf("concat(%s,%s)", arg, cve);
1145  },
1146  ),
1147  COP_APPEND: (
1148  "arg": Type::String,
1149  "sqlvalue": True,
1150  "code": string (string cve, string arg) {
1151  return sprintf("concat(%s,%s)", cve, arg);
1152  },
1153  ),
1154  COP_YEAR: (
1155  "code": string (string arg1, auto arg) {
1156  return sprintf("date_format(%s, '%%Y')", arg1);
1157  }
1158  ),
1159  COP_YEAR_MONTH: (
1160  "code": string (string arg1, auto arg) {
1161  return sprintf("date_format(%s, '%%Y-%%m')", arg1);
1162  }
1163  ),
1164  COP_YEAR_DAY: (
1165  "code": string (string arg1, auto arg) {
1166  return sprintf("date_format(%s, '%%Y-%%m-%%e')", arg1);
1167  }
1168  ),
1169  COP_YEAR_HOUR: (
1170  "code": string (string arg1, auto arg) {
1171  return sprintf("date_format(%s, '%%Y-%%m-%%e %%k')", arg1);
1172  }
1173  ),
1174  COP_TRUNC_DATE: (
1175  "code": string sub(string arg1, auto arg) {
1176  if (!MysqlTruncDate.hasKey(arg));
1177 
1178  return sprintf("cast(date_format(%s, %s) as datetime)", arg1, MysqlTruncDate{arg});
1179  }
1180  )
1181  );
1182 
1184  const MysqlTruncDate = (
1185  DT_YEAR : "'%Y-01-01 00:00:00'",
1186  DT_MONTH : "'%Y-%m-01 00:00:00'",
1187  DT_DAY : "'%Y-%m-%d 00:00:00'",
1188  DT_HOUR : "'%Y-%m-%d %H:00:00'",
1189  DT_MINUTE : "'%Y-%m-%d %H:%i:00'",
1190  DT_SECOND : "'%Y-%m-%d %H:%i:%s'",
1191  );
1192 
1193 public:
1194 
1195  private :
1196  string schema;
1197  string engine = "innodb";
1198 
1199 public:
1200 
1201  constructor(AbstractDatasource nds, string nname, *hash opts) ;
1202 
1203 
1205  string getSqlName();
1206 
1207 
1208 
1209 private:
1210  hash getTableCreationOptions();
1211 public:
1212 
1213 
1214 
1215 private:
1216  hash getTableDescriptionHashOptions();
1217 public:
1218 
1219 
1220 
1221 private:
1222  hash getColumnDescOptions();
1223 public:
1224 
1225 
1226 
1227 private:
1228  hash getIndexOptions();
1229 public:
1230 
1231 
1232 
1233 private:
1234  hash getConstraintOptions();
1235 public:
1236 
1237 
1238 
1239 private:
1240  hash getAlignTableOptions();
1241 public:
1242 
1243 
1245 
1246 private:
1248 public:
1249 
1250 
1251 
1252 private:
1253  bool checkExistenceImpl();
1254 public:
1255 
1256 
1257 
1258 private:
1259  Columns describeImpl();
1260 public:
1261 
1262 
1263 
1264 private:
1265  *string getCreatePrimaryKeySqlUnlocked(*hash opt, bool cache = True);
1266 public:
1267 
1268 
1269 
1270 private:
1271  MysqlPrimaryKey getPrimaryKeyImpl();
1272 public:
1273 
1274 
1275 
1276 private:
1277  Indexes getIndexesImpl();
1278 public:
1279 
1280 
1281 
1282 private:
1283  ForeignConstraints getForeignConstraintsImpl(*hash opts);
1284 public:
1285 
1286 
1287 
1288 private:
1289  Constraints getConstraintsImpl();
1290 public:
1291 
1292 
1293 
1294 private:
1295  Triggers getTriggersImpl();
1296 public:
1297 
1298 
1299  string getCreateTableSqlImpl(*hash opt);
1300 
1301 
1303  bool hasArrayBind();
1304 
1305 
1306 
1307 private:
1308  *list getCreateMiscSqlImpl(*hash opt, bool cache);
1309 public:
1310 
1311 
1312 
1313 private:
1314  *list getAlignSqlImpl(AbstractTable table, *hash opt);
1315 public:
1316 
1317 
1318 
1319 private:
1320  string getCreateSqlImpl(list l);
1321 public:
1322 
1323 
1324 
1325 private:
1326  string getRenameSqlImpl(string new_name);
1327 public:
1328 
1329 
1330 
1331 private:
1332  AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1333 public:
1334 
1335 
1336 
1337 private:
1338  setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
1339 public:
1340 
1341 
1342 
1343 private:
1344  addColumnToTableUnlocked(AbstractColumn c);
1345 public:
1346 
1347 
1348 
1349 private:
1350  AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1351 public:
1352 
1353 
1354 
1355 private:
1356  AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1357 public:
1358 
1359 
1360 
1361 private:
1362  AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1363 public:
1364 
1365 
1366 
1367 private:
1368  AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1369 public:
1370 
1371 
1372 
1373 private:
1374  AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1375 public:
1376 
1377 
1378 
1379 private:
1380  AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1381 public:
1382 
1383 
1384 
1385 private:
1386  bool tryInsertImpl(string sql, hash row);
1387 public:
1388 
1389 
1390 
1391 private:
1392  hash getQoreTypeMapImpl();
1393 public:
1394 
1395 
1396 
1397 private:
1398  hash getTypeMapImpl();
1399 public:
1400 
1401 
1403 
1404 private:
1405  *string getSqlValueImpl(auto v);
1406 public:
1407 
1408 
1410 
1411 private:
1412  static *string getSqlValueIntern(auto v);
1413 public:
1414 
1415 
1417  string getColumnSqlName(string col);
1418 
1419 
1421  list getColumnSqlNames(softlist cols);
1422 
1423 
1425 
1436  static *string getSqlValue(auto v);
1437 
1438 
1439 private:
1440  bool emptyImpl();
1441 public:
1442 
1443 
1444 
1445 private:
1446  preSetupTableImpl(reference<hash> desc, *hash opt);
1447 public:
1448 
1449 
1450 
1451 private:
1452  setupTableImpl(hash desc, *hash opt);
1453 public:
1454 
1455 
1457 
1458 private:
1460 public:
1461 
1462 
1464 
1465 private:
1467 public:
1468 
1469 
1471 
1472 private:
1473  bool supportsTablespacesImpl();
1474 public:
1475 
1476 
1478 
1479 private:
1480  doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *hash qh);
1481 public:
1482 
1483 
1485 
1486 private:
1487  doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1488 public:
1489 
1490 
1492 
1493 private:
1494  bool asteriskRequiresPrefix();
1495 public:
1496 
1497 
1498 
1499 private:
1500  *hash doReturningImpl(hash opt, reference<string> sql, list args);
1501 public:
1502 
1503 
1504 
1505 private:
1506  list getGroupOrderByListUnlocked(string key, hash qh, *hash jch, *hash ch, *hash psch, list coll);
1507 public:
1508 
1509 
1511  bool hasReturningImpl();
1512 
1513 
1515 
1516 private:
1517  copyImpl(AbstractTable old);
1518 public:
1519 
1520  };
1521 };
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
softlist getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
const MysqlColumnDescOptions
extends SqlUtil::AbstractTable::ColumnDescOptions with MySQL-specific values
Definition: MysqlSqlUtil.qm.dox.h:1110
const Date
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:219
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
const MysqlTypeMap
maps mysql type names to type configurations
Definition: MysqlSqlUtil.qm.dox.h:1050
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
const String
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:189
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string sprintf(string fmt,...)
const VARCHAR
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:538
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
bool hasArrayBind()
returns False because the mysql driver does not support array binds / bulk DML operations ...
string getDropSql(*hash opt)
returns a string that can be used to drop the sequence from the database
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a MysqlTable object corresponding to the arguments
const MysqlCopMap
column operator specializations for MySQL
Definition: MysqlSqlUtil.qm.dox.h:1127
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:502
bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in MySQL
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:555
bool hasReturningImpl()
returns True if the current database driver supports the &quot;returning&quot; clause in insert statements...
MysqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a MysqlDatabase object corresponding to the arguments
*string securitytype
security type value
Definition: MysqlSqlUtil.qm.dox.h:513
hash getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
const True
const SZ_MAND
const CHAR
softlist 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; if the col...
number number(softnumber n)
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
const COP_YEAR_HOUR
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
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...
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
hash getColumnOperatorMapImpl()
returns the column operator map for this object
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
const MysqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: MysqlSqlUtil.qm.dox.h:586
const False
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:509
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
const MysqlComputeStatisticsOptions
Options for computeStatistics()
Definition: MysqlSqlUtil.qm.dox.h:581
list list(...)
const Float
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
bool supportsPackagesImpl()
returns True if the database supports packages
list listFunctionsImpl()
returns a list of string function names in the database
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
const DT_DAY
string getDropSql(string table_name)
returns a string that can be used to drop the foreign constraint from the database ...
list listProceduresImpl()
returns a list of string procedure names in the database
const Boolean
const SZ_NUM
const MysqlSequenceFunction
MySQL sequence function.
Definition: MysqlSqlUtil.qm.dox.h:574
bool asteriskRequiresPrefix()
returns True if the database requires a wildcard &quot;*&quot; to be prefixed with the table name when it appea...
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
const Binary
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
MysqlColumn memberGate(string k)
returns the MysqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
doSelectOrderByWithOffsetSqlUnlockedImpl(reference< string > sql, reference< list > args, *hash qh, *hash jch, *hash ch, *hash psch, list coll)
processes a string for use in SQL select statements when there is an &quot;order by&quot; and &quot;offset&quot; argument...
const MysqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with &quot;engine&quot; for the DB engine behind th...
Definition: MysqlSqlUtil.qm.dox.h:1100
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
represents a MySQL-specific function
Definition: MysqlSqlUtil.qm.dox.h:439
list listTablesImpl()
returns a list of string table names in the database
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
hash getDatabaseOptions()
returns driver-specific options to the base abstract class
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:1045
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:366
const COP_YEAR_MONTH
const MyusqlCreationOptions
MySQL creation options.
Definition: MysqlSqlUtil.qm.dox.h:571
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:411
const BLOB
static *string getSqlValue(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
const CLOB
const MysqlTruncDate
Map SqlUtil::cop_trunc_date() constants to PostgreSQL internal masks.
Definition: MysqlSqlUtil.qm.dox.h:1184
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
bool supportsTablespacesImpl()
returns True if the database support tablespaces
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:511
const COP_PREPEND
const COP_TRUNC_DATE
static *string getSqlValueIntern(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
doSelectLimitOnlyUnlockedImpl(reference< string > sql, reference< list > args, *hash qh)
processes a string for use in SQL select statements when there is a &quot;limit&quot; argument, but no &quot;orderby&quot; or &quot;offset&quot; arguments
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions ...
Definition: MysqlSqlUtil.qm.dox.h:831
const Int
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
const COP_YEAR
string string(softstring str, *string enc)
bool supportsTypesImpl()
returns True if the database supports named types
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
copyImpl(AbstractTable old)
db-specific copy actions
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
class for MySQL sequences based on a sequence table and autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:471
const COP_CAST
const DT_MINUTE
const DT_HOUR
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:281
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:214
const COP_YEAR_DAY
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:549
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:507
const DT_MONTH
const MysqlReservedWords
hash of reserved words
Definition: MysqlSqlUtil.qm.dox.h:591
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:156
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
bool supportsName()
returns False since primary key constraints in MySQL have no name
hash hash(object obj)
const MysqlOptions
MySQL-specific options.
Definition: MysqlSqlUtil.qm.dox.h:543
const SZ_OPT
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 constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
const DT_YEAR
const MysqlDatabaseOptions
MySQL-specific database options.
Definition: MysqlSqlUtil.qm.dox.h:552
const Number
constructor(string n_name, bool n_unique, hash n_cols, string n_type="BTREE")
creates the object from the arguments
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
const DT_SECOND
const QoreTypeMap
maps qore type names to postgresql type names
Definition: MysqlSqlUtil.qm.dox.h:1086
const COP_APPEND