Qore FreetdsSqlUtil Module Reference  1.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 - 2016 Qore Technologies, sro
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 
147 namespace FreetdsSqlUtil {
150  FreetdsTable get_table(AbstractDatasource nds, string nname, *hash opts);
151 
152 
154  FreetdsDatabase get_database(AbstractDatasource nds, *hash opts);
155 
156 
157  parse_schema_name(string nname, reference schema, reference name);
158 
159 
162 
163 public:
164  public :
166  *string filegroup;
167 
168 public:
169 
171  constructor(string n_name, bool n_unique, hash n_cols, *string n_filegroup) ;
172 
173 
175  string getCreateSql(string table_name, *hash opt);
176 
177 
179  private bool equalImpl(AbstractIndex ix);
180 
181 
183  string getRenameSql(string table_name, string new_name);
184 
185  };
186 
189 
190 public:
192  constructor(string n, Columns c, ForeignConstraintTarget t) ;
193 
194 
196  string getCreateSql(string table_name, *hash opt);
197 
198 
199  softlist getRenameSql(string table_name, string new_name);
200 
201 
203  string getCreateSql(string name, string table_name, *hash opt);
204 
205  };
206 
209 
210 public:
212  constructor(string n, string n_src) ;
213 
214 
216  string getCreateSql(string table_name, *hash opt);
217 
218 
219  list getRenameSql(string table_name, string new_name);
220 
221 
223  string getCreateSql(string name, string table_name, *hash opt);
224 
225  };
226 
229 
230 public:
231  public :
234 
235 public:
236 
238  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
239 
240 
242  string getNativeTypeString();
243 
244 
246 
253  softlist getAddColumnSql(AbstractTable t);
254 
255 
257 
269  list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
270 
271 
273 
283  string getRenameSql(AbstractTable t, string new_name);
284 
285 
287  private bool equalImpl(AbstractColumn c);
288 
289  };
290 
293 
294 public:
296  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale) ;
297 
298 
300  string getNativeTypeString();
301 
302  };
303 
306 
307 public:
308  private :
310  *string filegroup;
311 
312 public:
313 
315  constructor(*string ts);
316 
317 
319  *string getTablespace();
320 
321 
323  setTablespace(*string ts);
324 
325 
327  bool setIndexBase(string ix);
328 
329 
331  clearIndex();
332 
333 
335  getIndexSql(reference sql, string name, *hash opts);
336 
337 
339  abstract AbstractIterator keyIterator();
340  };
341 
344 
345 public:
346  private :
348  bool enabled;
349 
350 public:
351 
353 
358  constructor(string n, hash n_cols, bool e = True, *string ts) ;
359 
360 
362 
377  FreetdsColumn memberGate(string k);
378 
379 
381  string getCreateSql(string table_name, *hash opts);
382 
383 
384  list getRenameSql(string table_name, string new_name);
385 
386 
388  string getCreateSql(string name, string table_name, *hash opts);
389 
390 
392  bool isEnabled();
393 
394  };
395 
398 
399 public:
401  constructor();
402 
403 
405 
409  constructor(string n, *hash c, *string ts) ;
410 
411 
413 
428  FreetdsColumn memberGate(string k);
429 
430 
432  string getCreateSql(string table_name, *hash opts);
433 
434 
436  softlist getRenameSql(string table_name, string new_name);
437 
438  };
439 
442 
443 public:
445  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
446 
447 
449  string getCreateSql(*hash opt);
450 
451 
453  string getRenameSql(string new_name);
454 
455  };
456 
459 
460 public:
462  constructor(string n_name, string n_src, *string n_schemaname) ;
463 
464 
466  string getCreateSql(*hash opt);
467 
468 
470  softlist getRenameSql(string new_name);
471 
472  };
473 
476 
477 public:
479  constructor(string n, string n_src) ;
480 
481 
483  softlist getCreateSql(string table_name, *hash opt);
484 
485 
487  softlist getDropSql(string table_name);
488 
489 
491  private bool equalImpl(AbstractFunctionBase t);
492 
493 
495  softlist getRenameSql(string table_name, string new_name);
496 
497  };
498 
501 
502 public:
503  public :
504  *string args;
505 
506 public:
507 
508  constructor(string n, string n_src, *string a) ;
509 
510 
512  softlist getCreateSql(*hash opt);
513 
514 
516  string getDropSql();
517 
518 
520  private bool equalImpl(AbstractFunctionBase t);
521 
522 
524  softlist getRenameSql(string new_name);
525 
526 
528  setName(string new_name);
529 
530  };
531 
534 
535 public:
536  public :
538  bool is_sybase;
539 
541  const FreetdsSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions;
542 
543  const FreeTDS_TempSavepoint = "qore_freetds_tmp_savepoint";
544 
547 
548 public:
549 
550  constructor(AbstractDatasource nds, *hash opts) ;
551 
552 
553  private list featuresImpl();
554 
555 
556  private FreetdsSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
557 
558 
559  private *AbstractSequence getSequenceImpl(string name);
560 
561 
562  private *AbstractView getViewImpl(string name);
563 
564 
565  private FreetdsFunction makeFunctionImpl(string name, string src, *hash opts);
566 
567 
568  private FreetdsFunction makeProcedureImpl(string name, string src, *hash opts);
569 
570 
571  private *AbstractFunction getFunctionImpl(string name);
572 
573 
574  private AbstractFunction getProcedureImpl(string name);
575 
576 
577  private list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
578 
579 
580  private list getAlignSqlImpl(hash schema_hash, *hash opt);
581 
582 
584  private softlist listTablesImpl();
585 
586 
588 
592  private list listFunctionsImpl();
593 
594 
596 
598  private list listProceduresImpl();
599 
600 
601  private list listSequencesImpl();
602 
603 
604  private list listViewsImpl();
605 
606 
608  private string getCreateSqlImpl(list l);
609 
610 
612  static bool isSybase(AbstractDatasource ds);
613 
615  static string getCreateSql(list l);
616 
619 
620 
622  private hash getReclaimSpaceOptions();
623 
624 
626  private softint getNextSequenceValueImpl(string name);
627 
628 
630  private softint getCurrentSequenceValueImpl(string name);
631 
632 
634  private bool supportsSequencesImpl();
635 
636 
638  private bool supportsTypesImpl();
639 
640 
642  private bool supportsPackagesImpl();
643 
644 
646  private bool rebuildIndexImpl(string name, *hash options);
647 
648 
650  private computeStatisticsImpl(*hash options);
651 
652 
654  private reclaimSpaceImpl(*hash options);
655 
656 
658  private any tryExecArgsImpl(string sql, *softlist args);
659 
660 
662  private any tryExecRawImpl(string sql, *softlist args);
663 
664 
666  static any tryExecArgs(AbstractDatasource ds, string sql, *softlist args);
667 
669  static any tryExecRaw(AbstractDatasource ds, string sql);
670  };
671 
674 
675 public:
676  public :
678  bool is_sybase;
679 
682 
684  const FreetdsTypeMap = (
685  "numeric": ("qore": Type::Number, "size": SZ_NUM,),
686  "decimal": ("qore": Type::Number, "size": SZ_NUM,),
687  "tinyint": ("qore": Type::Int,),
688  "smallint": ("qore": Type::Int,),
689  "int": ("qore": Type::Int,),
690  "bigint": ("qore": Type::Int,),
691  "double": ("qore": Type::Float,),
692  "float": ("qore": Type::Float,), // NOTE: optional precision
693  "real": ("qore": Type::Float,),
694  "money": ("qore": Type::Number,),
695  "smallmoney": ("qore": Type::Number,),
696 
697  "datetime": ("qore": Type::Date,),
698  "smalldatetime": ("qore": Type::Date,),
699  "date": ("qore": Type::Date,),
700  "time": ("qore": Type::Date,),
701 
702  // NOTE: "size_range" is different between MS SQL Server and Sybase SQL Anywhere Server
703  // MS SQL: range is (1, 8000) or special keyword "max" for varchar types
704  // Sybase: range is (1, 32767) and size is mandatory for character-length semantics
705  "char": ("qore": Type::String, "size": SZ_OPT),
706  "char varying": ("qore": Type::String, "size": SZ_OPT),
707  "character varying": ("qore": Type::String, "size": SZ_OPT),
708  "varchar": ("qore": Type::String, "size": SZ_OPT),
709 
710  // The following uni* types are used in Sybase Adaptive Server
711  "unichar": ("qore": Type::String, "size": SZ_MAND,),
712  "univarchar": ("qore": Type::String, "size": SZ_MAND,),
713  "unitext": ("qore": Type::String,),
714 
715  // NOTE: "size_range" is different between MS SQL Server and Sybase SQL Anywhere Server
716  // MS SQL: range is (1, 8000) or special keyword "max" for varbinary types
717  // Sybase: range is (1, 32767)
718  "binary": ("qore": Type::Binary, "size": SZ_OPT),
719  "binary varying": ("qore": Type::Binary, "size": SZ_OPT),
720  "varbinary": ("qore": Type::Binary, "size": SZ_OPT),
721 
722  // The following are used in Sybase, supported & deprecated in MS SQL
723  "text": ("qore": Type::String,), // domain, implemented as "long varchar"
724  "image": ("qore": Type::Binary,), // domain, implemented as "long binary"
725  // The following are Sybase specific
726  "long binary": ("qore": Type::Binary,),
727  "long varchar": ("qore": Type::String,),
728  );
729 
731  const QoreTypeMap = (
732  "integer": "bigint",
733  "float": "float",
734  "number": "numeric",
735  "string": "varchar",
736  "date": "datetime",
737  "binary": "varbinary",
738  "bool": "tinyint",
739  SqlUtil::CHAR: "char",
740  SqlUtil::CLOB: "text",
741  SqlUtil::BLOB: "varbinary",
742  );
743 
745  const FreetdsTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions;
746 
747  const FreetdsColumnDescOptions = AbstractTable::ColumnDescOptions;
748 
749  const FreetdsIndexOptions = AbstractTable::IndexOptions;
750 
751  const FreetdsConstraintOptions = AbstractTable::ConstraintOptions + FreetdsIndexOptions;
752 
753  const FreetdsTableCreationOptions = AbstractTable::TableCreationOptions + FreetdsConstraintOptions;
754 
755  const FreetdsAlignTableOptions = AbstractTable::AlignTableOptions + FreetdsTableCreationOptions;
756 
758  const FreetdsSelectOptions = AbstractTable::SelectOptions + (
759  "tablehint": "softstringlist",
760  );
761 
764  "fastfirstrow": True,
765  "holdlock": True,
766  "nolock": True,
767  "paglock": True,
768  "readcommitted": True,
769  "readpast": True,
770  "readuncommitted": True,
771  "repeatableread": True,
772  "rowlock": True,
773  "serializable": True,
774  "tablock": True,
775  "tablockx": True,
776  "updlock": True,
777  "xlock": True,
778  );
779 
782  OP_SUBSTR: (
783  "code": string (object t, string cn, any arg, reference args, *hash jch, bool join = False, *hash ch, *hash psch) {
784  args += arg[0]; // start
785  if (!exists arg[1]);
786 
787  args += arg[1]; // count
788  args += arg[2]; // text
789  return sprintf("substring(%s,%v,%v) = %v", cn);
790  },
791  ),
792  );
793 
796  COP_CAST: (
797  "code": string (string cve, list args) {
798  string name = QoreTypeMap{args[0]} ?? args[0];
799  hash desc = FreetdsTypeMap{name};
800  string sql = sprintf ("cast (%s as %s", cve, name);
801  switch (name);
802 
803  sql += ")";
804  return sql;
805  },
806  ),
807  COP_PREPEND: (
808  "arg": Type::String,
809  "sqlvalue": True,
810  "code": string (string cve, string arg) {
811  return sprintf("%s + %s", arg, cve);
812  },
813  ),
814  COP_APPEND: (
815  "arg": Type::String,
816  "sqlvalue": True,
817  "code": string (string cve, string arg) {
818  return sprintf("%s + %s", cve, arg);
819  },
820  ),
821  COP_SUBSTR: (
822  "code": string (string cve, list args) {
823  if (!exists args[1])
824  return sprintf("substring(%s,%d,32767)", cve, args[0]); // NOTE: length arg is required
825  return sprintf("substring(%s,%d,%d)", cve, args[0], args[1]);
826  },
827  ),
828  COP_OVER: (
829  "argcolumn": True,
830  "argoptional": True,
831  "code": string (*string cve, *string arg) {
832  string sql = cve + " over (";
833  if (arg)
834  sql += sprintf("partition by %s", arg);
835  sql += ")";
836  return sql;
837  },
838  ),
839  COP_YEAR: (
840  "code": string (string arg1, any arg) {
841  return sprintf("substring(convert(varchar, dt, 120), 1, 4)", arg1);
842  }
843  ),
844  COP_YEAR_MONTH: (
845  "code": string (string arg1, any arg) {
846  return sprintf("substring(convert(varchar, dt, 120), 1, 7)", arg1);
847  }
848  ),
849  COP_YEAR_DAY: (
850  "code": string (string arg1, any arg) {
851  return sprintf("substring(convert(varchar, dt, 120), 1, 10)", arg1);
852  }
853  ),
854  COP_YEAR_HOUR: (
855  "code": string (string arg1, any arg) {
856  return sprintf("substring(convert(varchar, dt, 120), 1, 13)", arg1);
857  }
858  ),
859  COP_SEQ: (
860  "nocolumn": True,
861  "withalias": True,
862  "code": string (*string cve, hash arg, reference psch) {
863  string sql = sprintf("next value for %s", arg.seq);
864  if (arg.as);
865 
866  return sql;
867  }
868  ),
869  COP_SEQ_CURRVAL: (
870  "nocolumn": True,
871  "code": string (*string cve, hash arg) {
872  throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this database does not support this operation", arg.seq);
873  }
874  ),
875  );
876 
879  IOP_SEQ: (
880  "arg": Type::String,
881  "placeholder": "next value for %v",
882  ),
883  );
884 
887  COP_SEQ: (
888  "nocolumn": True,
889  "withalias": True,
890  "code": string (*string cve, string arg) {
891  return sprintf("next value for %s", arg);
892  }
893  ),
894  COP_SEQ_CURRVAL: (
895  "nocolumn": True,
896  "code": string (*string cve, string arg) {
897  throw "SEQUENCE-ERROR", sprintf("cannot select the current value of sequence %y because this database does not support this operation", arg);
898  }
899  ),
900  );
901 
902 public:
903 
904  private :
906  *string filegroup;
907 
909  string schema;
910 
912  Functions triggerFunctions;
913 
914 public:
915 
916  constructor(AbstractDatasource nds, string nname, *hash opts) ;
917 
918 
920  string getSchemaName();
921 
922 
924  *string getTablespaceName();
925 
926 
928  code getUpsertClosure(hash row, int upsert_strategy = UpsertAuto, *hash opt);
929 
930 
932  bool hasArrayBind();
933 
934 
936  string getSqlName();
937 
938 
939  private string getFromIntern(string from, *hash qh);
940 
941 
942  private hash getTableCreationOptions();
943 
944 
945  private hash getTableDescriptionHashOptions();
946 
947 
948  private hash getColumnDescOptions();
949 
950 
951  private hash getIndexOptions();
952 
953 
954  private hash getConstraintOptions();
955 
956 
957  private hash getAlignTableOptions();
958 
959 
961  private hash getWhereOperatorMap();
962 
963 
965  private hash getColumnOperatorMap();
966 
967 
969  private hash getInsertOperatorMap();
970 
971 
973  private hash getRawUpdateOperatorMap();
974 
975 
977  private hash getSelectOptions();
978 
979 
980  private bool checkExistenceImpl();
981 
982 
983  private Columns describeImpl();
984 
985 
986  private Columns describeSybaseImpl();
987 
988 
989  private Columns describeMssqlImpl();
990 
991 
992  private FreetdsPrimaryKey getPrimaryKeyImpl();
993 
994 
995  private FreetdsPrimaryKey getPrimaryKeySybaseImpl();
996 
997 
998  private FreetdsPrimaryKey getPrimaryKeyMssqlImpl();
999 
1000 
1001  private Indexes getIndexesImpl();
1002 
1003 
1004  private Indexes getIndexesSybaseImpl();
1005 
1006 
1007  private Indexes getIndexesMssqlImpl();
1008 
1009 
1010  private ForeignConstraints getForeignConstraintsImpl(*hash opts);
1011 
1012 
1013  private ForeignConstraints getForeignConstraintsSybaseImpl();
1014 
1015 
1016  private ForeignConstraints getForeignConstraintsMssqlImpl();
1017 
1018 
1019  private Constraints getConstraintsImpl();
1020 
1021 
1022  private Constraints getConstraintsSybaseImpl();
1023 
1024 
1025  private Constraints getConstraintsMssqlImpl();
1026 
1027 
1028  private Triggers getTriggersImpl();
1029 
1030 
1032  private string getCreateTableSqlImpl(*hash opt);
1033 
1034 
1035  private *list getCreateMiscSqlImpl(*hash opt, bool cache);
1036 
1037 
1038  private *list getAlignSqlImpl(AbstractTable table, *hash opt);
1039 
1040 
1042  private string getCreateSqlImpl(list l);
1043 
1044 
1045  private string getRenameSqlImpl(string new_name);
1046 
1047 
1048  private AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1049 
1050 
1051  private AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1052 
1053 
1054  private AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1055 
1056 
1057  private AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1058 
1059 
1060  private AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1061 
1062 
1063  private AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1064 
1065 
1066  private AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1067 
1068 
1069  private bool tryInsertImpl(string sql, hash row);
1070 
1071 
1072  private hash getQoreTypeMapImpl();
1073 
1074 
1075  private hash getTypeMapImpl();
1076 
1077 
1079  private *string getSqlValueImpl(any v);
1080 
1081 
1082  private bool emptyImpl();
1083 
1084 
1086  private clearImpl();
1087 
1088 
1089  private setupTableImpl(hash desc, *hash opt);
1090 
1091 
1093  private bool constraintsLinkedToIndexesImpl();
1094 
1095 
1097  private bool uniqueIndexCreatesConstraintImpl();
1098 
1099 
1101  private bool supportsTablespacesImpl();
1102 
1103 
1105  private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh);
1106 
1107 
1109  private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1110 
1111 
1113  private any tryExecArgsImpl(string sql, *softlist args);
1114 
1115 
1117  private any tryExecRawImpl(string sql, *softlist args);
1118 
1119 
1121  private copyImpl(AbstractTable old);
1122 
1123 
1124  private *hash doReturningImpl(hash opt, reference sql, list args);
1125 
1126 
1127  private softbool tryUpdate(string sql, hash row, Columns cols, list updc);
1128 
1129  };
1130 };
softlist getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
const Date
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
private bool supportsSequencesImpl()
returns True if the database supports sequences
const COP_SEQ
constructor(string n, Columns c, ForeignConstraintTarget t)
creates the constraint from the supplied arguments
static any tryExecArgs(AbstractDatasource ds, string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
const String
const DefaultIopMap
constructor(string n_name, string n_src, *string n_schemaname)
creates the object from the arguments
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:678
string sprintf(string fmt,...)
private bool supportsPackagesImpl()
returns True if the database supports packages
bool ss_has_merge
"has merge" flag for SQL server
Definition: FreetdsSqlUtil.qm.dox.h:681
private bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
constructor()
creates an empty primary key object
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
const DefaultCopMap
private hash getColumnOperatorMap()
returns the column operator map for this object
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale)
creates the column from the supplied arguments
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
const FreetdsOpMap
where operator specializations for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:781
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs)
creates the column from the supplied arguments
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
represents a FreeTDS-specific numeric column
Definition: FreetdsSqlUtil.qm.dox.h:292
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
class for FreeTDS sequences
Definition: FreetdsSqlUtil.qm.dox.h:441
FreetdsColumn memberGate(string k)
returns the FreetdsColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception...
static bool isSybase(AbstractDatasource ds)
returns True if the DB is a Sybase database
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
const COP_OVER
string schema
schema name for the table
Definition: FreetdsSqlUtil.qm.dox.h:909
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
string getSchemaName()
returns the schema name
represents a FreeTDS-specific column
Definition: FreetdsSqlUtil.qm.dox.h:228
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
constructor(string n, string n_src)
creates the constraint from the supplied arguments
represents a FreeTDS-specific primary key constraint
Definition: FreetdsSqlUtil.qm.dox.h:397
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
const FreetdsTypeMap
maps postgresql type names to type configurations
Definition: FreetdsSqlUtil.qm.dox.h:684
list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
const FreetdsTableDescriptionHashOptions
equal to SqlUtil::AbstractTable::TableDescriptionHashOptions
Definition: FreetdsSqlUtil.qm.dox.h:745
const COP_SEQ_CURRVAL
bool hasArrayBind()
returns False because the freetds driver does not support array binds / bulk DML operations ...
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
const True
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
private hash getWhereOperatorMap()
returns the "where" operator map for this object
const SZ_MAND
const CHAR
private hash getInsertOperatorMap()
returns the insert operator map for this object
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:538
common base class for unique constraints
Definition: FreetdsSqlUtil.qm.dox.h:305
number number(softnumber n)
const COP_YEAR_HOUR
static any tryExecRaw(AbstractDatasource ds, string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
int byte_size
byte size of the column
Definition: FreetdsSqlUtil.qm.dox.h:233
string getNativeTypeString()
returns a string giving the native type of the column
class modeling a unique constraint
Definition: FreetdsSqlUtil.qm.dox.h:343
*string filegroup
the tablespace (filegroup) name of the index
Definition: FreetdsSqlUtil.qm.dox.h:166
constructor(*string ts)
creates the constraint with an optional filegroup name
represents a FreeTDS-specific foreign constraint
Definition: FreetdsSqlUtil.qm.dox.h:188
const False
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
private string getCreateTableSqlImpl(*hash opt)
returns a string that can be used to create the table in the database
list list(...)
const Float
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
private any tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
the FreetdsSqlUtil namespace contains all the objects in the FreetdsSqlUtil module ...
Definition: FreetdsSqlUtil.qm.dox.h:148
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
private softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
const FreetdsReclaimSpaceOptions
Options for reclaimSpace()
Definition: FreetdsSqlUtil.qm.dox.h:546
constructor(string n_name, bool n_unique, hash n_cols, *string n_filegroup)
creates the object from the arguments
private string getCreateSqlImpl(list l)
returns a string that can be used to create the table in the database
const SZ_NUM
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: FreetdsSqlUtil.qm.dox.h:912
const Binary
setTablespace(*string ts)
sets or clears the filegroup name
private bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
const FreetdsCopMap
column operator specializations for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:795
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
*string getTablespace()
returns the filegroup name used for this constraint, if known
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
bool exists(...)
provides the FreeTDS-specific implementation of the AbstractDatabase interface
Definition: FreetdsSqlUtil.qm.dox.h:533
const MsSqlServerTableHints
query hints
Definition: FreetdsSqlUtil.qm.dox.h:763
const COP_YEAR_MONTH
clearIndex()
clears any index base for the constraint
represents a FreeTDS-specific index
Definition: FreetdsSqlUtil.qm.dox.h:161
private hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
FreetdsColumn memberGate(string k)
returns the FreetdsColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception...
private softlist listTablesImpl()
returns a list of string table names in the database
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
const BLOB
private bool supportsTypesImpl()
returns True if the database supports named types
const CLOB
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch, *hash psch, list coll)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument...
represents a FreeTDS view
Definition: FreetdsSqlUtil.qm.dox.h:458
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh)
processes a string for use in SQL select statements when there is a "limit" argument, but no "orderby" or "offset" arguments
const FreetdsSelectOptions
select options supported by FreetdsSqlUtil
Definition: FreetdsSqlUtil.qm.dox.h:758
provides the FreeTDS-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: FreetdsSqlUtil.qm.dox.h:673
represents a FreeTDS-specific check constraint
Definition: FreetdsSqlUtil.qm.dox.h:208
static string getCreateSql(list l)
returns a string that can be used to create the schema in the database
private computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
private list listProceduresImpl()
since FreeTDS only supports functions, this method is identical to listFunctionsImpl() ...
code getUpsertClosure(hash row, int upsert_strategy=UpsertAuto, *hash opt)
returns a closure for performing upserts; if the underlying dataserver supports an optimized MERGE st...
const COP_PREPEND
bool enabled
True if the constraint is enabled, False if not
Definition: FreetdsSqlUtil.qm.dox.h:348
FreetdsDatabase get_database(AbstractDatasource nds, *hash opts)
returns a FreetdsDatabase object corresponding to the arguments
getIndexSql(reference sql, string name, *hash opts)
adds index options onto the sql creation string
constructor(string n, hash n_cols, bool e=True, *string ts)
creates the object with the given attributes
*string filegroup
any filegroup for the unique key index
Definition: FreetdsSqlUtil.qm.dox.h:310
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the constraint
const Int
const QoreTypeMap
maps qore type names to postgresql type names
Definition: FreetdsSqlUtil.qm.dox.h:731
const COP_YEAR
string string(softstring str, *string enc)
string getDropSql()
returns a string that can be used to drop the function from the database
bool setIndexBase(string ix)
sets the supporting index name
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
represents a FreeTDS-specific trigger
Definition: FreetdsSqlUtil.qm.dox.h:475
string getNativeTypeString()
returns a string giving the native type of the column
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
const COP_CAST
private string getCreateSqlImpl(list l)
returns a string that can be used to create the schema in the database
const FreetdsUopMap
a hash of default update operator definitions for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:886
const DefaultUopMap
represents a FreeTDS-specific function
Definition: FreetdsSqlUtil.qm.dox.h:500
const COP_YEAR_DAY
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
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
private any tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
private hash getSelectOptions()
returns the select options for this driver
private clearImpl()
clears FreeTDS-specific table information
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
hash hash(object obj)
private list listFunctionsImpl()
returns a list of string function names in the database
const COP_SUBSTR
setName(string new_name)
sets the new name of the function
const OP_SUBSTR
const SZ_OPT
const FreetdsSchemaDescriptionOptions
FreeTDS-specific schema description keys.
Definition: FreetdsSqlUtil.qm.dox.h:541
const IOP_SEQ
abstract AbstractIterator keyIterator()
returns an iterator for keys iterating a list of string key names
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
bool isEnabled()
returns True if the constraint is enabled, False if not
string join(string str,...)
private copyImpl(AbstractTable old)
db-specific copy actions
const Number
*string filegroup
filegroup name for the table, if known
Definition: FreetdsSqlUtil.qm.dox.h:906
softlist getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
private hash getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
const DefaultOpMap
const FreetdsIopMap
a hash of default value operator descriptions for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:878
private reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
const COP_APPEND
*string getTablespaceName()
returns the data filegroup name for the table or NOTHING if none is known