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