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