Qore FreetdsSqlUtil Module Reference  1.2
FreetdsSqlUtil.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file FreetdsSqlUtil.qm Qore user module for working with PostgreSQL SQL data
3 
4 /* FreetdsSqlUtil.qm Copyright (C) 2015 - 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 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 
36 // version history is included below in the docs
37 
157 namespace FreetdsSqlUtil {
160  FreetdsTable get_table(AbstractDatasource nds, string nname, *hash opts);
161 
162 
164  FreetdsDatabase get_database(AbstractDatasource nds, *hash opts);
165 
166 
167  parse_schema_name(string nname, reference<string> schema, reference<string> name);
168 
169 
172 
173 public:
174  public :
176  *string filegroup;
177 
178 public:
179 
181  constructor(string n_name, bool n_unique, hash n_cols, *string n_filegroup) ;
182 
183 
185  string getCreateSql(string table_name, *hash opt);
186 
187 
189 
190 private:
191  bool equalImpl(AbstractIndex ix);
192 public:
193 
194 
196  string getRenameSql(string table_name, string new_name);
197 
198  };
199 
202 
203 public:
205  constructor(string n, Columns c, ForeignConstraintTarget t) ;
206 
207 
209  string getCreateSql(string table_name, *hash opt);
210 
211 
212  softlist getRenameSql(string table_name, string new_name);
213 
214 
216  string getCreateSql(string name, string table_name, *hash opt);
217 
218  };
219 
222 
223 public:
225  constructor(string n, string n_src) ;
226 
227 
229  string getCreateSql(string table_name, *hash opt);
230 
231 
232  list getRenameSql(string table_name, string new_name);
233 
234 
236  string getCreateSql(string name, string table_name, *hash opt);
237 
238  };
239 
242 
243 public:
244  public :
247 
248 public:
249 
251  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
252 
253 
255  string getNativeTypeString();
256 
257 
259 
266  softlist getAddColumnSql(AbstractTable t);
267 
268 
270 
283  list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
284 
285 
287 
297  string getRenameSql(AbstractTable t, string new_name);
298 
299 
301 
302 private:
303  bool equalImpl(AbstractColumn c);
304 public:
305 
306  };
307 
310 
311 public:
313  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale) ;
314 
315 
317  string getNativeTypeString();
318 
319  };
320 
323 
324 public:
325  private :
327  *string filegroup;
328 
329 public:
330 
332  constructor(*string ts);
333 
334 
336  *string getTablespace();
337 
338 
340  setTablespace(*string ts);
341 
342 
344  bool setIndexBase(string ix);
345 
346 
348  clearIndex();
349 
350 
352  getIndexSql(reference<string> sql, string name, *hash opts);
353 
354 
356  abstract AbstractIterator keyIterator();
357  };
358 
361 
362 public:
363  private :
365  bool enabled;
366 
367 public:
368 
370 
375  constructor(string n, hash n_cols, bool e = True, *string ts) ;
376 
377 
379 
394  FreetdsColumn memberGate(string k);
395 
396 
398  string getCreateSql(string table_name, *hash opts);
399 
400 
401  list getRenameSql(string table_name, string new_name);
402 
403 
405  string getCreateSql(string name, string table_name, *hash opts);
406 
407 
409  bool isEnabled();
410 
411  };
412 
415 
416 public:
418  constructor();
419 
420 
422 
426  constructor(string n, *hash c, *string ts) ;
427 
428 
430 
445  FreetdsColumn memberGate(string k);
446 
447 
449  string getCreateSql(string table_name, *hash opts);
450 
451 
453  softlist getRenameSql(string table_name, string new_name);
454 
455  };
456 
459 
460 public:
462  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
463 
464 
466  string getCreateSql(*hash opt);
467 
468 
470 
474  softlist getRenameSql(string new_name, *hash opt);
475 
476  };
477 
480 
481 public:
483  constructor(string n_name, string n_src, *string n_schemaname) ;
484 
485 
487  string getCreateSql(*hash opt);
488 
489 
491 
495  softlist getRenameSql(string new_name, *hash opt);
496 
497  };
498 
501 
502 public:
504  constructor(string n, string n_src) ;
505 
506 
508  softlist getCreateSql(string table_name, *hash opt);
509 
510 
512  softlist getDropSql(string table_name);
513 
514 
516 
517 private:
518  bool equalImpl(AbstractFunctionBase t);
519 public:
520 
521 
523  softlist getRenameSql(string table_name, string new_name);
524 
525  };
526 
529 
530 public:
531  public :
532  *string args;
533 
534 public:
535 
536  constructor(string n, string n_src, *string a) ;
537 
538 
540  softlist getCreateSql(*hash opt);
541 
542 
544 
546  string getDropSql(*hash opt);
547 
548 
550 
551 private:
552  bool equalImpl(AbstractFunctionBase t);
553 public:
554 
555 
557 
560  softlist getRenameSql(string new_name, *hash opt);
561 
562 
564  setName(string new_name);
565 
566  };
567 
570 
571 public:
572  public :
574  bool is_sybase;
575 
577  const FreetdsSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions;
578 
579  const FreeTDS_TempSavepoint = "qore_freetds_tmp_savepoint";
580 
582  const FreetdsReclaimSpaceOptions = ReclaimSpaceOptions;
583 
585  const FreetdsReservedWords = (
586  "add": True,
587  "all": True,
588  "alter": True,
589  "and": True,
590  "any": True,
591  "as": True,
592  "asc": True,
593  "authorization": True,
594  "backup": True,
595  "begin": True,
596  "between": True,
597  "break": True,
598  "browse": True,
599  "bulk": True,
600  "by": True,
601  "cascade": True,
602  "case": True,
603  "check": True,
604  "checkpoint": True,
605  "close": True,
606  "clustered": True,
607  "coalesce": True,
608  "collate": True,
609  "column": True,
610  "commit": True,
611  "compute": True,
612  "constraint": True,
613  "contains": True,
614  "containstable": True,
615  "continue": True,
616  "convert": True,
617  "create": True,
618  "cross": True,
619  "current": True,
620  "current_date": True,
621  "current_time": True,
622  "current_timestamp": True,
623  "current_user": True,
624  "cursor": True,
625  "database": True,
626  "dbcc": True,
627  "deallocate": True,
628  "declare": True,
629  "default": True,
630  "delete": True,
631  "deny": True,
632  "desc": True,
633  "disk": True,
634  "distinct": True,
635  "distributed": True,
636  "double": True,
637  "drop": True,
638  "dump": True,
639  "else": True,
640  "end": True,
641  "errlvl": True,
642  "escape": True,
643  "except": True,
644  "exec": True,
645  "execute": True,
646  "exists": True,
647  "exit": True,
648  "external": True,
649  "fetch": True,
650  "file": True,
651  "fillfactor": True,
652  "for": True,
653  "foreign": True,
654  "freetext": True,
655  "freetexttable": True,
656  "from": True,
657  "full": True,
658  "function": True,
659  "goto": True,
660  "grant": True,
661  "group": True,
662  "having": True,
663  "holdlock": True,
664  "identity": True,
665  "identity_insert": True,
666  "identitycol": True,
667  "if": True,
668  "in": True,
669  "index": True,
670  "inner": True,
671  "insert": True,
672  "intersect": True,
673  "into": True,
674  "is": True,
675  "join": True,
676  "key": True,
677  "kill": True,
678  "left": True,
679  "like": True,
680  "lineno": True,
681  "load": True,
682  "merge": True,
683  "national": True,
684  "nocheck": True,
685  "nonclustered": True,
686  "not": True,
687  "null": True,
688  "nullif": True,
689  "of": True,
690  "off": True,
691  "offsets": True,
692  "on": True,
693  "open": True,
694  "opendatasource": True,
695  "openquery": True,
696  "openrowset": True,
697  "openxml": True,
698  "option": True,
699  "or": True,
700  "order": True,
701  "outer": True,
702  "over": True,
703  "percent": True,
704  "pivot": True,
705  "plan": True,
706  "precision": True,
707  "primary": True,
708  "print": True,
709  "proc": True,
710  "procedure": True,
711  "public": True,
712  "raiserror": True,
713  "read": True,
714  "readtext": True,
715  "reconfigure": True,
716  "references": True,
717  "replication": True,
718  "restore": True,
719  "restrict": True,
720  "return": True,
721  "revert": True,
722  "revoke": True,
723  "right": True,
724  "rollback": True,
725  "rowcount": True,
726  "rowguidcol": True,
727  "rule": True,
728  "save": True,
729  "schema": True,
730  "securityaudit": True,
731  "select": True,
732  "semantickeyphrasetable": True,
733  "semanticsimilaritydetailstable": True,
734  "semanticsimilaritytable": True,
735  "session_user": True,
736  "set": True,
737  "setuser": True,
738  "shutdown": True,
739  "some": True,
740  "statistics": True,
741  "system_user": True,
742  "table": True,
743  "tablesample": True,
744  "textsize": True,
745  "then": True,
746  "to": True,
747  "top": True,
748  "tran": True,
749  "transaction": True,
750  "trigger": True,
751  "truncate": True,
752  "try_convert": True,
753  "tsequal": True,
754  "union": True,
755  "unique": True,
756  "unpivot": True,
757  "update": True,
758  "updatetext": True,
759  "use": True,
760  "user": True,
761  "values": True,
762  "varying": True,
763  "view": True,
764  "waitfor": True,
765  "when": True,
766  "where": True,
767  "while": True,
768  "with": True,
769  "within group": True,
770  "writetext": True,
771  );
772 
773 public:
774 
775  constructor(AbstractDatasource nds, *hash opts) ;
776 
777 
778 
779 private:
780  list featuresImpl();
781 public:
782 
783 
784 
785 private:
786  FreetdsSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
787 public:
788 
789 
790 
791 private:
792  *AbstractSequence getSequenceImpl(string name);
793 public:
794 
795 
796 
797 private:
798  *AbstractView getViewImpl(string name);
799 public:
800 
801 
802 
803 private:
804  FreetdsFunction makeFunctionImpl(string name, string src, *hash opts);
805 public:
806 
807 
808 
809 private:
810  FreetdsFunction makeProcedureImpl(string name, string src, *hash opts);
811 public:
812 
813 
814 
815 private:
816  *AbstractFunction getFunctionImpl(string name);
817 public:
818 
819 
820 
821 private:
822  AbstractFunction getProcedureImpl(string name);
823 public:
824 
825 
826 
827 private:
828  list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
829 public:
830 
831 
832 
833 private:
834  list getAlignSqlImpl(hash schema_hash, *hash opt);
835 public:
836 
837 
839 
840 private:
841  softlist listTablesImpl();
842 public:
843 
844 
846 
851 private:
852  list listFunctionsImpl();
853 public:
854 
855 
857 
860 private:
861  list listProceduresImpl();
862 public:
863 
864 
865 
866 private:
867  list listSequencesImpl();
868 public:
869 
870 
871 
872 private:
873  list listViewsImpl();
874 public:
875 
876 
878 
879 private:
880  string getCreateSqlImpl(list l);
881 public:
882 
883 
885  static bool isSybase(AbstractDatasource ds);
886 
888  static string getCreateSql(list l);
889 
891 
892 private:
893  hash getSchemaDescriptionOptions();
894 public:
895 
896 
898 
899 private:
900  hash getReclaimSpaceOptions();
901 public:
902 
903 
905 
906 private:
907  softint getNextSequenceValueImpl(string name);
908 public:
909 
910 
912 
913 private:
914  softint getCurrentSequenceValueImpl(string name);
915 public:
916 
917 
919 
920 private:
921  bool supportsSequencesImpl();
922 public:
923 
924 
926 
927 private:
928  bool supportsTypesImpl();
929 public:
930 
931 
933 
934 private:
935  bool supportsPackagesImpl();
936 public:
937 
938 
940 
941 private:
942  bool rebuildIndexImpl(string name, *hash options);
943 public:
944 
945 
947 
948 private:
949  computeStatisticsImpl(*hash options);
950 public:
951 
952 
954 
955 private:
956  reclaimSpaceImpl(*hash options);
957 public:
958 
959 
961 
962 private:
963  auto tryExecArgsImpl(string sql, *softlist args);
964 public:
965 
966 
968 
969 private:
970  auto tryExecRawImpl(string sql, *softlist args);
971 public:
972 
973 
975  static auto tryExecArgs(AbstractDatasource ds, string sql, *softlist args);
976 
978  static auto tryExecRaw(AbstractDatasource ds, string sql);
979  };
980 
983 
984 public:
985  public :
987  bool is_sybase;
988 
990  bool ss_has_merge = False;
991 
993  const FreetdsTypeMap = (
994  "numeric": ("qore": Type::Number, "size": SZ_NUM,),
995  "decimal": ("qore": Type::Number, "size": SZ_NUM,),
996  "tinyint": ("qore": Type::Int,),
997  "smallint": ("qore": Type::Int,),
998  "int": ("qore": Type::Int,),
999  "bigint": ("qore": Type::Int,),
1000  "double": ("qore": Type::Float,),
1001  "float": ("qore": Type::Float,), // NOTE: optional precision
1002  "real": ("qore": Type::Float,),
1003  "money": ("qore": Type::Number,),
1004  "smallmoney": ("qore": Type::Number,),
1005 
1006  "datetime": ("qore": Type::Date,),
1007  "smalldatetime": ("qore": Type::Date,),
1008  "date": ("qore": Type::Date,),
1009  "time": ("qore": Type::Date,),
1010 
1011  // NOTE: "size_range" is different between MS SQL Server and Sybase SQL Anywhere Server
1012  // MS SQL: range is (1, 8000) or special keyword "max" for varchar types
1013  // Sybase: range is (1, 32767) and size is mandatory for character-length semantics
1014  "char": ("qore": Type::String, "size": SZ_OPT),
1015  "char varying": ("qore": Type::String, "size": SZ_OPT),
1016  "character varying": ("qore": Type::String, "size": SZ_OPT),
1017  "varchar": ("qore": Type::String, "size": SZ_OPT),
1018 
1019  // The following uni* types are used in Sybase Adaptive Server
1020  "unichar": ("qore": Type::String, "size": SZ_MAND,),
1021  "univarchar": ("qore": Type::String, "size": SZ_MAND,),
1022  "unitext": ("qore": Type::String,),
1023 
1024  // NOTE: "size_range" is different between MS SQL Server and Sybase SQL Anywhere Server
1025  // MS SQL: range is (1, 8000) or special keyword "max" for varbinary types
1026  // Sybase: range is (1, 32767)
1027  "binary": ("qore": Type::Binary, "size": SZ_OPT),
1028  "binary varying": ("qore": Type::Binary, "size": SZ_OPT),
1029  "varbinary": ("qore": Type::Binary, "size": SZ_OPT),
1030  "varbinary(max)": ("qore": Type::Binary,),
1031 
1032  // The following are used in Sybase, supported & deprecated in MS SQL
1033  "text": ("qore": Type::String,), // domain, implemented as "long varchar"
1034  "image": ("qore": Type::Binary,), // domain, implemented as "long binary"
1035  // The following are Sybase specific
1036  "long binary": ("qore": Type::Binary,),
1037  "long varchar": ("qore": Type::String,),
1038  );
1039 
1041  const QoreTypeMap = (
1042  "integer": "bigint",
1043  "float": "float",
1044  "number": "numeric",
1045  "string": "varchar",
1046  "date": "datetime",
1047  "binary": "varbinary",
1048  "bool": "tinyint",
1049  SqlUtil::CHAR: "char",
1050  SqlUtil::CLOB: "text",
1051  );
1052 
1054  const MsQoreTypeMap = QoreTypeMap + (
1055  SqlUtil::BLOB: "varbinary(max)",
1056  );
1057 
1059  const SybaseQoreTypeMap = QoreTypeMap;
1060 
1062  const FreetdsTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions;
1063 
1064  const FreetdsColumnDescOptions = AbstractTable::ColumnDescOptions;
1065 
1066  const FreetdsIndexOptions = AbstractTable::IndexOptions;
1067 
1068  const FreetdsConstraintOptions = AbstractTable::ConstraintOptions + FreetdsIndexOptions;
1069 
1070  const FreetdsTableCreationOptions = AbstractTable::TableCreationOptions + FreetdsConstraintOptions;
1071 
1072  const FreetdsAlignTableOptions = AbstractTable::AlignTableOptions + FreetdsTableCreationOptions;
1073 
1075  const FreetdsSelectOptions = AbstractTable::SelectOptions + (
1076  "tablehint": "softstringlist",
1077  );
1078 
1080  const MsSqlServerTableHints = (
1081  "fastfirstrow": True,
1082  "holdlock": True,
1083  "nolock": True,
1084  "paglock": True,
1085  "readcommitted": True,
1086  "readpast": True,
1087  "readuncommitted": True,
1088  "repeatableread": True,
1089  "rowlock": True,
1090  "serializable": True,
1091  "tablock": True,
1092  "tablockx": True,
1093  "updlock": True,
1094  "xlock": True,
1095  );
1096 
1098  const FreetdsOpMap = DefaultOpMap + (
1099  OP_SUBSTR: (
1100  "code": string (object t, string cn, softlist arg, reference<list> args, *hash jch, bool join = False, *hash ch, *hash psch) {
1101  args += arg[0]; // start
1102  if (!exists arg[1]);
1103 
1104  args += arg[1]; // count
1105  args += arg[2]; // text
1106  return sprintf("substring(%s,%v,%v) = %v", cn);
1107  },
1108  ),
1109  );
1110 
1112  const FreetdsCopMap = DefaultCopMap + (
1113  COP_CAST: (
1114  "code": string (string cve, list args) {
1115  string name = QoreTypeMap{args[0]} ?? args[0];
1116  hash desc = FreetdsTypeMap{name};
1117  string sql = sprintf ("cast (%s as %s", cve, name);
1118  switch (name);
1119 
1120  sql += ")";
1121  return sql;
1122  },
1123  ),
1124  COP_PREPEND: (
1125  "arg": Type::String,
1126  "sqlvalue": True,
1127  "code": string (string cve, string arg) {
1128  return sprintf("%s + %s", arg, cve);
1129  },
1130  ),
1131  COP_APPEND: (
1132  "arg": Type::String,
1133  "sqlvalue": True,
1134  "code": string (string cve, string arg) {
1135  return sprintf("%s + %s", cve, arg);
1136  },
1137  ),
1138  COP_SUBSTR: (
1139  "code": string (string cve, list args) {
1140  if (!exists args[1])
1141  return sprintf("substring(%s,%d,32767)", cve, args[0]); // NOTE: length arg is required
1142  return sprintf("substring(%s,%d,%d)", cve, args[0], args[1]);
1143  },
1144  ),
1145  COP_YEAR: (
1146  "code": string (string arg1, auto arg) {
1147  return sprintf("substring(convert(varchar, dt, 120), 1, 4)", arg1);
1148  }
1149  ),
1150  COP_YEAR_MONTH: (
1151  "code": string (string arg1, auto arg) {
1152  return sprintf("substring(convert(varchar, dt, 120), 1, 7)", arg1);
1153  }
1154  ),
1155  COP_YEAR_DAY: (
1156  "code": string (string arg1, auto arg) {
1157  return sprintf("substring(convert(varchar, dt, 120), 1, 10)", arg1);
1158  }
1159  ),
1160  COP_YEAR_HOUR: (
1161  "code": string (string arg1, auto arg) {
1162  return sprintf("substring(convert(varchar, dt, 120), 1, 13)", arg1);
1163  }
1164  ),
1165  COP_SEQ: (
1166  "nocolumn": True,
1167  "withalias": True,
1168  "code": string (*string cve, hash arg, reference<hash> psch) {
1169  string sql = sprintf("next value for %s", arg.seq);
1170  if (arg.as);
1171 
1172  return sql;
1173  }
1174  ),
1175  COP_SEQ_CURRVAL: (
1176  "nocolumn": True,
1177  "code": string (*string cve, hash arg) {
1178  throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this database does not support this operation", arg.seq);
1179  }
1180  ),
1181  COP_LENGTH: (
1182  "code": string (string cve, auto arg) {
1183  return sprintf("len(%s)", cve);
1184  },
1185  ),
1186  COP_TRUNC_DATE: (
1187  "code": string sub(string arg1, auto arg) {
1188  if (!FreetdsTruncDate.hasKey(arg));
1189 
1190  string cmd = FreetdsTruncDate{arg};
1191  return replace(cmd, "%s", arg1);
1192  }
1193  )
1194  );
1195 
1197  /* Impl. note here. There is shorter workaround for this, but it does not work with seconds
1198  and with dates older than 1.1.1970. (minutes will overflow later too etc.).
1199  So no usage for: dateadd(ss, datediff(ss, 0, %s), 0) for example
1200  */
1201  const FreetdsTruncDate = (
1202  DT_YEAR : "datetimefromparts(datepart(year, %s), 1, 1, 0, 0, 0, 0)",
1203  DT_MONTH : "datetimefromparts(datepart(year, %s), datepart(month, %s), 1, 0, 0, 0, 0)",
1204  DT_DAY : "datetimefromparts(datepart(year, %s), datepart(month, %s), datepart(day, %s), 0, 0, 0, 0)",
1205  DT_HOUR : "datetimefromparts(datepart(year, %s), datepart(month, %s), datepart(day, %s), datepart(hour, %s), 0, 0, 0)",
1206  DT_MINUTE : "datetimefromparts(datepart(year, %s), datepart(month, %s), datepart(day, %s), datepart(hour, %s), datepart(minute, %s), 0, 0)",
1207  DT_SECOND : "datetimefromparts(datepart(year, %s), datepart(month, %s), datepart(day, %s), datepart(hour, %s), datepart(minute, %s), datepart(second, %s), 0)",
1208  );
1209 
1211  const FreetdsIopMap = DefaultIopMap + (
1212  IOP_SEQ: (
1213  "arg": Type::String,
1214  "placeholder": "next value for %v",
1215  ),
1216  );
1217 
1219  const FreetdsUopMap = DefaultUopMap + (
1220  COP_SEQ: (
1221  "nocolumn": True,
1222  "withalias": True,
1223  "code": string (*string cve, string arg) {
1224  return sprintf("next value for %s", arg);
1225  }
1226  ),
1227  COP_SEQ_CURRVAL: (
1228  "nocolumn": True,
1229  "code": string (*string cve, string arg) {
1230  throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this database does not support this operation", arg);
1231  }
1232  ),
1233  );
1234 
1235 public:
1236 
1237  private :
1239  *string filegroup;
1240 
1242  string schema;
1243 
1245  Functions triggerFunctions;
1246 
1247 public:
1248 
1249  constructor(AbstractDatasource nds, string nname, *hash opts) ;
1250 
1251 
1253  string getSchemaName();
1254 
1255 
1257  *string getTablespaceName();
1258 
1259 
1261  code getUpsertClosure(hash row, int upsert_strategy = UpsertAuto, *hash opt);
1262 
1263 
1265  bool hasArrayBind();
1266 
1267 
1269  string getSqlName();
1270 
1271 
1272 
1273 private:
1274  string getFromIntern(string from, *hash qh);
1275 public:
1276 
1277 
1278 
1279 private:
1280  hash getTableCreationOptions();
1281 public:
1282 
1283 
1284 
1285 private:
1286  hash getTableDescriptionHashOptions();
1287 public:
1288 
1289 
1290 
1291 private:
1292  hash getColumnDescOptions();
1293 public:
1294 
1295 
1296 
1297 private:
1298  hash getIndexOptions();
1299 public:
1300 
1301 
1302 
1303 private:
1304  hash getConstraintOptions();
1305 public:
1306 
1307 
1308 
1309 private:
1310  hash getAlignTableOptions();
1311 public:
1312 
1313 
1315 
1316 private:
1317  hash getWhereOperatorMap();
1318 public:
1319 
1320 
1322 
1323 private:
1324  hash getColumnOperatorMap();
1325 public:
1326 
1327 
1329 
1330 private:
1331  hash getInsertOperatorMap();
1332 public:
1333 
1334 
1336 
1337 private:
1338  hash getRawUpdateOperatorMap();
1339 public:
1340 
1341 
1343 
1344 private:
1345  hash getSelectOptions();
1346 public:
1347 
1348 
1349 
1350 private:
1351  bool checkExistenceImpl();
1352 public:
1353 
1354 
1355 
1356 private:
1357  Columns describeImpl();
1358 public:
1359 
1360 
1361 
1362 private:
1363  Columns describeSybaseImpl();
1364 public:
1365 
1366 
1367 
1368 private:
1369  Columns describeMssqlImpl();
1370 public:
1371 
1372 
1373 
1374 private:
1375  FreetdsPrimaryKey getPrimaryKeyImpl();
1376 public:
1377 
1378 
1379 
1380 private:
1381  FreetdsPrimaryKey getPrimaryKeySybaseImpl();
1382 public:
1383 
1384 
1385 
1386 private:
1387  FreetdsPrimaryKey getPrimaryKeyMssqlImpl();
1388 public:
1389 
1390 
1391 
1392 private:
1393  Indexes getIndexesImpl();
1394 public:
1395 
1396 
1397 
1398 private:
1399  Indexes getIndexesSybaseImpl();
1400 public:
1401 
1402 
1403 
1404 private:
1405  Indexes getIndexesMssqlImpl();
1406 public:
1407 
1408 
1409 
1410 private:
1411  ForeignConstraints getForeignConstraintsImpl(*hash opts);
1412 public:
1413 
1414 
1415 
1416 private:
1417  ForeignConstraints getForeignConstraintsSybaseImpl();
1418 public:
1419 
1420 
1421 
1422 private:
1423  ForeignConstraints getForeignConstraintsMssqlImpl();
1424 public:
1425 
1426 
1427 
1428 private:
1429  Constraints getConstraintsImpl();
1430 public:
1431 
1432 
1433 
1434 private:
1435  Constraints getConstraintsSybaseImpl();
1436 public:
1437 
1438 
1439 
1440 private:
1441  Constraints getConstraintsMssqlImpl();
1442 public:
1443 
1444 
1445 
1446 private:
1447  Triggers getTriggersImpl();
1448 public:
1449 
1450 
1452 
1453 private:
1454  string getCreateTableSqlImpl(*hash opt);
1455 public:
1456 
1457 
1458 
1459 private:
1460  *list getCreateMiscSqlImpl(*hash opt, bool cache);
1461 public:
1462 
1463 
1464 
1465 private:
1466  *list getAlignSqlImpl(AbstractTable table, *hash opt);
1467 public:
1468 
1469 
1471 
1472 private:
1473  string getCreateSqlImpl(list l);
1474 public:
1475 
1476 
1477 
1478 private:
1479  string getRenameSqlImpl(string new_name);
1480 public:
1481 
1482 
1483 
1484 private:
1485  AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1486 public:
1487 
1488 
1489 
1490 private:
1491  AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1492 public:
1493 
1494 
1495 
1496 private:
1497  AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1498 public:
1499 
1500 
1501 
1502 private:
1503  AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1504 public:
1505 
1506 
1507 
1508 private:
1509  AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1510 public:
1511 
1512 
1513 
1514 private:
1515  AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1516 public:
1517 
1518 
1519 
1520 private:
1521  AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1522 public:
1523 
1524 
1525 
1526 private:
1527  bool tryInsertImpl(string sql, hash row);
1528 public:
1529 
1530 
1531 
1532 private:
1533  hash getQoreTypeMapImpl();
1534 public:
1535 
1536 
1537 
1538 private:
1539  hash getTypeMapImpl();
1540 public:
1541 
1542 
1544 
1545 private:
1546  *string getSqlValueImpl(auto v);
1547 public:
1548 
1549 
1551  string getColumnSqlName(string col);
1552 
1553 
1555  list getColumnSqlNames(softlist cols);
1556 
1557 
1558 
1559 private:
1560  bool emptyImpl();
1561 public:
1562 
1563 
1565 
1566 private:
1567  clearImpl();
1568 public:
1569 
1570 
1571 
1572 private:
1573  setupTableImpl(hash desc, *hash opt);
1574 public:
1575 
1576 
1578 
1579 private:
1580  bool constraintsLinkedToIndexesImpl();
1581 public:
1582 
1583 
1585 
1586 private:
1587  bool uniqueIndexCreatesConstraintImpl();
1588 public:
1589 
1590 
1592 
1593 private:
1594  bool supportsTablespacesImpl();
1595 public:
1596 
1597 
1599 
1600 private:
1601  doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *hash qh);
1602 public:
1603 
1604 
1606 
1607 private:
1608  doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1609 public:
1610 
1611 
1613 
1614 private:
1615  auto tryExecArgsImpl(string sql, *softlist args);
1616 public:
1617 
1618 
1620 
1621 private:
1622  auto tryExecRawImpl(string sql, *softlist args);
1623 public:
1624 
1625 
1627 
1628 private:
1629  copyImpl(AbstractTable old);
1630 public:
1631 
1632 
1633 
1634 private:
1635  *hash doReturningImpl(hash opt, reference<string> sql, list args);
1636 public:
1637 
1638 
1639 
1640 private:
1641  softbool tryUpdate(string sql, hash row, Columns cols, list updc);
1642 public:
1643 
1644  };
1645 };
const Date
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
const COP_SEQ
const UpsertAuto
const String
const DefaultIopMap
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:987
string sprintf(string fmt,...)
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
const DefaultCopMap
represents a FreeTDS-specific numeric column
Definition: FreetdsSqlUtil.qm.dox.h:309
class for FreeTDS sequences
Definition: FreetdsSqlUtil.qm.dox.h:458
string schema
schema name for the table
Definition: FreetdsSqlUtil.qm.dox.h:1242
represents a FreeTDS-specific column
Definition: FreetdsSqlUtil.qm.dox.h:241
represents a FreeTDS-specific primary key constraint
Definition: FreetdsSqlUtil.qm.dox.h:414
const COP_SEQ_CURRVAL
const True
const SZ_MAND
const CHAR
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:574
common base class for unique constraints
Definition: FreetdsSqlUtil.qm.dox.h:322
number number(softnumber n)
const COP_YEAR_HOUR
int byte_size
byte size of the column
Definition: FreetdsSqlUtil.qm.dox.h:246
class modeling a unique constraint
Definition: FreetdsSqlUtil.qm.dox.h:360
*string filegroup
the tablespace (filegroup) name of the index
Definition: FreetdsSqlUtil.qm.dox.h:176
represents a FreeTDS-specific foreign constraint
Definition: FreetdsSqlUtil.qm.dox.h:201
const False
string replace(string str, string source, string target, int start=0, int end=-1)
list list(...)
const Float
const DT_DAY
the FreetdsSqlUtil namespace contains all the objects in the FreetdsSqlUtil module ...
Definition: FreetdsSqlUtil.qm.dox.h:158
constructor(string n_name, bool n_unique, hash n_cols, *string n_filegroup)
creates the object from the arguments
const SZ_NUM
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: FreetdsSqlUtil.qm.dox.h:1245
const Binary
bool exists(...)
provides the FreeTDS-specific implementation of the AbstractDatabase interface
Definition: FreetdsSqlUtil.qm.dox.h:569
const COP_YEAR_MONTH
const COP_LENGTH
represents a FreeTDS-specific index
Definition: FreetdsSqlUtil.qm.dox.h:171
const BLOB
const CLOB
represents a FreeTDS view
Definition: FreetdsSqlUtil.qm.dox.h:479
provides the FreeTDS-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: FreetdsSqlUtil.qm.dox.h:982
represents a FreeTDS-specific check constraint
Definition: FreetdsSqlUtil.qm.dox.h:221
const COP_PREPEND
bool enabled
True if the constraint is enabled, False if not
Definition: FreetdsSqlUtil.qm.dox.h:365
const COP_TRUNC_DATE
FreetdsDatabase get_database(AbstractDatasource nds, *hash opts)
returns a FreetdsDatabase object corresponding to the arguments
*string filegroup
any filegroup for the unique key index
Definition: FreetdsSqlUtil.qm.dox.h:327
const Int
const COP_YEAR
string string(softstring str, *string enc)
represents a FreeTDS-specific trigger
Definition: FreetdsSqlUtil.qm.dox.h:500
const COP_CAST
const DT_MINUTE
const DT_HOUR
const DefaultUopMap
represents a FreeTDS-specific function
Definition: FreetdsSqlUtil.qm.dox.h:528
const COP_YEAR_DAY
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
FreetdsTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a FreetdsTable object corresponding to the arguments
const DT_MONTH
hash hash(object obj)
const COP_SUBSTR
const OP_SUBSTR
const SZ_OPT
const IOP_SEQ
const DT_YEAR
string getDropSql(string table_name)
string join(string str,...)
const Number
*string filegroup
filegroup name for the table, if known
Definition: FreetdsSqlUtil.qm.dox.h:1239
const DefaultOpMap
const DT_SECOND
const COP_APPEND