Qore PgsqlSqlUtil Module Reference  1.1
 All Classes Namespaces Functions Variables Groups Pages
PgsqlSqlUtil.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file PgsqlSqlUtil.qm Qore user module for working with PostgreSQL SQL data
3 
4 /* PgsqlSqlUtil.qm Copyright (C) 2013 - 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 
201 namespace PgsqlSqlUtil {
204  PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
205 
206 
208  PgsqlDatabase get_database(AbstractDatasource nds, *hash opts);
209 
210 
211  parse_schema_name(string nname, reference schema, reference name);
212 
213 
215  class PgsqlType {
216 
217 public:
218  public :
220  string name;
221 
223  string src;
224 
225 public:
226 
228  constructor(string n_name, string n_src);
229 
230 
231  list getTypeList();
232 
233 
234  list getModifySql(PgsqlType old, *hash opt);
235 
236 
238  string getCreateSql(*hash opt);
239 
240 
242  string getDropSql(*hash opt);
243 
244 
246  string getDropSqlForce();
247 
248 
250  string getRenameSql(string new_name);
251 
252 
254  bool equal(PgsqlType type);
255 
256  };
257 
260 
261 public:
262  public :
264  *string tablespace;
265 
266 public:
267 
269  constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace) ;
270 
271 
273  string getCreateSql(string table_name, *hash opt);
274 
275 
277  private bool equalImpl(AbstractIndex ix);
278 
279 
281  string getRenameSql(string table_name, string new_name);
282 
283 
284  };
285 
288 
289 public:
291  constructor(string n, Columns c, ForeignConstraintTarget t) ;
292 
293 
295  string getCreateSql(string table_name, *hash opt);
296 
297 
298  softlist getRenameSql(string table_name, string new_name);
299 
300 
302  string getCreateSql(string name, string table_name, *hash opt);
303 
304  };
305 
308 
309 public:
311  constructor(string n, string n_src) ;
312 
313 
315  string getCreateSql(string table_name, *hash opt);
316 
317 
318  list getRenameSql(string table_name, string new_name);
319 
320 
322  string getCreateSql(string name, string table_name, *hash opt);
323 
324  };
325 
328 
329 public:
330  public :
333 
334 public:
335 
337  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
338 
339 
341  string getNativeTypeString();
342 
343 
345 
352  list getAddColumnSql(AbstractTable t);
353 
354 
356 
368  list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
369 
370 
372 
382  string getRenameSql(AbstractTable t, string new_name);
383 
384 
386  private bool equalImpl(AbstractColumn c);
387 
388  };
389 
392 
393 public:
395  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale) ;
396 
397 
399  string getNativeTypeString();
400 
401  };
402 
405 
406 public:
407  private :
409  *string tablespace;
410 
411 public:
412 
414  constructor(*string ts);
415 
416 
418  *string getTablespace();
419 
420 
422  setTablespace(*string ts);
423 
424 
426  bool setIndexBase(string ix);
427 
428 
430  clearIndex();
431 
432 
434  abstract AbstractIterator keyIterator();
435 
437  getIndexSql(reference sql, string name, *hash opts);
438 
439  };
440 
443 
444 public:
445  private :
447  bool enabled;
448 
449 public:
450 
452 
457  constructor(string n, hash n_cols, bool e = True, *string ts) ;
458 
459 
461 
476  PgsqlColumn memberGate(string k);
477 
478 
480  string getCreateSql(string table_name, *hash opts);
481 
482 
483  list getRenameSql(string table_name, string new_name);
484 
485 
487  string getCreateSql(string name, string table_name, *hash opts);
488 
489 
491  bool isEnabled();
492 
493  };
494 
497 
498 public:
500  constructor();
501 
502 
504 
508  constructor(string n, *hash c, *string ts) ;
509 
510 
512 
527  PgsqlColumn memberGate(string k);
528 
529 
531  string getCreateSql(string table_name, *hash opts);
532 
533 
535  softlist getRenameSql(string table_name, string new_name);
536 
537  };
538 
541 
542 public:
544  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
545 
546 
548  string getCreateSql(*hash opt);
549 
550 
552  string getRenameSql(string new_name);
553 
554  };
555 
558 
559 public:
560 
561  public :
563  *string viewowner;
564 
565 public:
566 
568  constructor(string n_name, string n_src, *string n_schemaname,
569  *string n_viewowner)
570  ;
571 
572 
574  string getCreateSql(*hash opt);
575 
576 
578  softlist getRenameSql(string new_name);
579 
580  };
581 
584 
585 public:
587  constructor(string n, string n_src) ;
588 
589 
591  softlist getCreateSql(string table_name, *hash opt);
592 
593 
595  softlist getDropSql(string table_name);
596 
597 
599  private bool equalImpl(AbstractFunctionBase t);
600 
601 
603  softlist getRenameSql(string table_name, string new_name);
604 
605  };
606 
609 
610 public:
611  public :
612  *string args;
613 
614 public:
615 
616  constructor(string n, string n_src, *string a) ;
617 
618 
620  softlist getCreateSql(*hash opt);
621 
622 
624  string getDropSql();
625 
626 
628  private bool equalImpl(AbstractFunctionBase t);
629 
630 
632  softlist getRenameSql(string new_name);
633 
634 
636  setName(string new_name);
637 
638  };
639 
642 
643 public:
644  public :
646  string trigger;
647 
648 public:
649 
650  constructor(string n, string n_src, string n_trigger) ;
651 
652  };
653 
656 
657 public:
658  public :
660  const PgsqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + (
661  "types": Type::Hash,
662  "type_map": Type::Hash,
663  );
664 
665  const PGSQL_TempSavepoint = "qore_pgsql_tmp_savepoint";
666 
669  "full" : Type::Boolean,
670  "analyze" : Type::Boolean,
671  );
672 
673 public:
674 
675  constructor(AbstractDatasource nds, *hash opts) ;
676 
677 
678  private list featuresImpl();
679 
680 
681  PgsqlType makeType(string name, string src, *hash opts);
682 
683 
684  *PgsqlType getType(string name);
685 
686 
687  private PgsqlSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
688 
689 
690  private *AbstractSequence getSequenceImpl(string name);
691 
692 
693  private *AbstractView getViewImpl(string name);
694 
695 
696  private PgsqlFunction makeFunctionImpl(string name, string src, *hash opts);
697 
698 
699  private PgsqlFunction makeProcedureImpl(string name, string src, *hash opts);
700 
701 
702  private *AbstractFunction getFunctionImpl(string name);
703 
704 
705  private AbstractFunction getProcedureImpl(string name);
706 
707 
708  static *string getFunctionArgs(string err, reference src);
709 
710  static PgsqlFunction processFunction(hash row, bool native_case);
711 
712  private list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
713 
714 
715  private list getAlignSqlImpl(hash schema_hash, *hash opt);
716 
717 
719  private list listTablesImpl();
720 
721 
723 
727  private list listFunctionsImpl();
728 
729 
731 
733  private list listProceduresImpl();
734 
735 
736  private list listSequencesImpl();
737 
738 
739  private list listViewsImpl();
740 
741 
744 
745 
747  ListIterator materializedViewIterator();
748 
749 
751  list listTypes();
752 
753 
755  ListIterator typeIterator();
756 
757 
759  private string getCreateSqlImpl(list l);
760 
761 
763  static string getCreateSql(list l);
764 
767 
768 
770  private hash getReclaimSpaceOptions();
771 
772 
774  private softint getNextSequenceValueImpl(string name);
775 
776 
778  private softint getCurrentSequenceValueImpl(string name);
779 
780 
782  private bool supportsSequencesImpl();
783 
784 
786  private bool supportsTypesImpl();
787 
788 
790  private bool supportsPackagesImpl();
791 
792 
794  private bool rebuildIndexImpl(string name, *hash options);
795 
796 
798  private computeStatisticsImpl(*hash options);
799 
800 
802  private reclaimSpaceImpl(*hash options);
803 
804 
806  private any tryExecArgsImpl(string sql, *softlist args);
807 
808 
810  private any tryExecRawImpl(string sql, *softlist args);
811 
812 
814  static any tryExecArgs(AbstractDatasource ds, string sql, *softlist args);
815 
817  static any tryExecRaw(AbstractDatasource ds, string sql);
818  };
819 
822 
823 public:
824  public :
826  const PgsqlTypeMap = (
827  "abstime": ("qore": Type::Date,),
828  "bigint": ("qore": Type::Int,),
829  "bigserial": ("qore": Type::Int,),
830  "bit": ("qore": Type::Binary, "size": SZ_OPT,),
831  "bit varying": ("qore": Type::Binary, "size": SZ_OPT,),
832  "bool": ("qore": Type::Boolean,),
833  "boolean": ("qore": Type::Boolean,),
834  "bytea": ("qore": Type::Binary,),
835  "char": ("qore": Type::String, "size": SZ_OPT,),
836  "character": ("qore": Type::String, "size": SZ_OPT,),
837  "character varying": ("qore": Type::String, "size": SZ_OPT,),
838  "cidr": ("qore": Type::String,),
839  "date": ("qore": Type::Date,),
840  "decimal": ("qore": Type::Number, "size": SZ_NUM,),
841  "double precision": ("qore": Type::Float,),
842  "float": ("qore": Type::Float,),
843  "inet": ("qore": Type::String,),
844  "int": ("qore": Type::Int,),
845  "integer": ("qore": Type::Int,),
846  "interval": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
847  "macaddr": ("qore": Type::String,),
848  "money": ("qore": Type::Number,),
849  "numeric": ("qore": Type::Number, "size": SZ_NUM,),
850  "oid": ("qore": Type::Int,),
851  "real": ("qore": Type::Float,),
852  "reltime": ("qore": Type::Date,),
853  "serial": ("qore": Type::Int,),
854  "smallint": ("qore": Type::Int,),
855  "smallserial": ("qore": Type::Int,),
856  "text": ("qore": Type::String,),
857  "time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
858  "time with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
859  "time without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
860  "timetz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
861  "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
862  "timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
863  "timestamp without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
864  "timestamptz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
865  "varbit": ("qore": Type::Binary, "size": SZ_OPT,),
866  "varchar": ("qore": Type::String, "size": SZ_OPT,),
867  );
868 
870  const PgsqlNameMap = (
871  "bit varying": "varbit",
872  "character": "char",
873  "character varying": "varchar",
874  "char varying": "varchar",
875  "double precision": "float",
876  "time with time zone": "timetz",
877  "time without time zone": "time",
878  "timestamp with time zone": "timestamptz",
879  "timestamp without time zone": "timestamp",
880  );
881 
883  const QoreTypeMap = (
884  "integer": "bigint",
885  "float": "double precision",
886  "number": "numeric",
887  "string": "varchar",
888  "date": "timestamp",
889  "binary": "bytea",
890  "bool": "boolean",
891  SqlUtil::CHAR: "char",
892  SqlUtil::CLOB: "text",
893  SqlUtil::BLOB: "bytea",
894  );
895 
897  const PgsqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
898  "functions": Type::Hash,
899  );
900 
901  const PgsqlColumnDescOptions = AbstractTable::ColumnDescOptions;
902 
903  const PgsqlIndexOptions = AbstractTable::IndexOptions;
904 
905  const PgsqlConstraintOptions = AbstractTable::ConstraintOptions + PgsqlIndexOptions + (
906  "index": Type::String,
907  );
908 
909  const PgsqlTableCreationOptions = AbstractTable::TableCreationOptions + PgsqlConstraintOptions + (
910  "omit_trigger_functions": Type::Boolean,
911  );
912 
913  const PgsqlAlignTableOptions = AbstractTable::AlignTableOptions + PgsqlTableCreationOptions;
914 
917  COP_CAST: (
918  "code": string (string cve, list args) {
919  string name = QoreTypeMap{args[0]} ?? args[0];
920  hash desc = PgsqlTypeMap{name};
921  string sql = sprintf ("cast (%s as %s", cve, name);
922  switch (name);
923 
924  sql += ")";
925  return sql;
926  },
927  ),
928  COP_OVER: (
929  "argcolumn": True,
930  "argoptional": True,
931  "code": string (*string cve, *string arg) {
932  string sql = cve + " over (";
933  if (arg)
934  sql += sprintf("partition by %s", arg);
935  sql += ")";
936  return sql;
937  },
938  ),
939  COP_YEAR: (
940  "code": string (string arg1, any arg) {
941  return sprintf("to_char(%s, 'YYYY')", arg1);
942  }
943  ),
944  COP_YEAR_MONTH: (
945  "code": string (string arg1, any arg) {
946  return sprintf("to_char(%s, 'YYYY-MM')", arg1);
947  }
948  ),
949  COP_YEAR_DAY: (
950  "code": string (string arg1, any arg) {
951  return sprintf("to_char(%s, 'YYYY-MM-DD')", arg1);
952  }
953  ),
954  COP_YEAR_HOUR: (
955  "code": string (string arg1, any arg) {
956  return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", arg1);
957  }
958  ),
959  COP_SEQ: (
960  "nocolumn": True,
961  "withalias": True,
962  "code": string (*string cve, hash arg, reference psch) {
963  string sql = sprintf("nextval('%s')", arg.seq);
964  if (arg.as);
965 
966  return sql;
967  }
968  ),
969  COP_SEQ_CURRVAL: (
970  "nocolumn": True,
971  "withalias": True,
972  "code": string (*string cve, hash arg, reference psch) {
973  string sql = sprintf("currval('%s')", arg.seq);
974  if (arg.as);
975 
976  return sql;
977  }
978  ),
979  );
980 
983  IOP_SEQ: (
984  "arg": Type::String,
985  "placeholder": "nextval(%v)",
986  ),
987  IOP_SEQ_CURRVAL: (
988  "arg": Type::String,
989  "placeholder": "currval(%v)",
990  ),
991  );
992 
995  COP_SEQ: (
996  "nocolumn": True,
997  "code": string (*string cve, string arg) {
998  return sprintf("nextval('%s')", arg);
999  }
1000  ),
1001  COP_SEQ_CURRVAL: (
1002  "nocolumn": True,
1003  "withalias": True,
1004  "code": string (*string cve, string arg) {
1005  return sprintf("currval('%s')", arg);
1006  }
1007  ),
1008  );
1009 
1010 public:
1011 
1012  private :
1014  *string tablespace;
1015 
1017  string schema;
1018 
1020  Functions triggerFunctions;
1021 
1022 public:
1023 
1024  constructor(AbstractDatasource nds, string nname, *hash opts) ;
1025 
1026 
1028  string getSchemaName();
1029 
1030 
1032  *string getTablespaceName();
1033 
1034 
1035  PgsqlFunction addTriggerFunction(string tfname, string src, string trigger);
1036 
1037 
1039  bool hasArrayBind();
1040 
1041 
1042  private PgsqlFunction addTriggerFunctionUnlocked(string tfname, string src, string trigger);
1043 
1044 
1046  string getSqlName();
1047 
1048 
1049  private hash getTableCreationOptions();
1050 
1051 
1052  private hash getTableDescriptionHashOptions();
1053 
1054 
1055  private hash getColumnDescOptions();
1056 
1057 
1058  private hash getIndexOptions();
1059 
1060 
1061  private hash getConstraintOptions();
1062 
1063 
1064  private hash getAlignTableOptions();
1065 
1066 
1068  private hash getColumnOperatorMap();
1069 
1070 
1072  private hash getInsertOperatorMap();
1073 
1074 
1076  private hash getRawUpdateOperatorMap();
1077 
1078 
1079  private bool checkExistenceImpl();
1080 
1081 
1082  private Columns describeImpl();
1083 
1084 
1085  private PgsqlPrimaryKey getPrimaryKeyImpl();
1086 
1087 
1088  private Indexes getIndexesImpl();
1089 
1090 
1091  private ForeignConstraints getForeignConstraintsImpl(*hash opts);
1092 
1093 
1094  private Constraints getConstraintsImpl();
1095 
1096 
1097  private Triggers getTriggersImpl();
1098 
1099 
1101  private string getCreateTableSqlImpl(*hash opt);
1102 
1103 
1104  private *list getCreateMiscSqlImpl(*hash opt, bool cache);
1105 
1106 
1107  private *list getAlignSqlImpl(AbstractTable table, *hash opt);
1108 
1109 
1111  private string getCreateSqlImpl(list l);
1112 
1113 
1114  private string getRenameSqlImpl(string new_name);
1115 
1116 
1117  private AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1118 
1119 
1120  private AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1121 
1122 
1123  private AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1124 
1125 
1126  private AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1127 
1128 
1129  private AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1130 
1131 
1132  private AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1133 
1134 
1135  private AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1136 
1137 
1138  private bool tryInsertImpl(string sql, hash row);
1139 
1140 
1141  private hash getQoreTypeMapImpl();
1142 
1143 
1144  private hash getTypeMapImpl();
1145 
1146 
1148  private *string getSqlValueImpl(any v);
1149 
1150 
1151  private bool emptyImpl();
1152 
1153 
1155  private clearImpl();
1156 
1157 
1158  private softlist getDropSqlImpl();
1159 
1160 
1161  private setupTableImpl(hash desc, *hash opt);
1162 
1163 
1165  private bool constraintsLinkedToIndexesImpl();
1166 
1167 
1169  private bool uniqueIndexCreatesConstraintImpl();
1170 
1171 
1173  private bool supportsTablespacesImpl();
1174 
1175 
1177  private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh);
1178 
1179 
1181  private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1182 
1183 
1185  private any tryExecArgsImpl(string sql, *softlist args);
1186 
1187 
1189  private any tryExecRawImpl(string sql, *softlist args);
1190 
1191 
1193  private copyImpl(AbstractTable old);
1194 
1195 
1196  private *hash doReturningImpl(hash opt, reference sql, list args);
1197 
1198 
1199  private list getGroupOrderByListUnlocked(string key, hash qh, *hash jch, *hash ch, *hash psch, list coll);
1200 
1201  };
1202 };
const PgsqlIopMap
a hash of default value operator descriptions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:982
const PgsqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: PgsqlSqlUtil.qm.dox.h:668
*string viewowner
Owner of the view.
Definition: PgsqlSqlUtil.qm.dox.h:563
class modeling a unique constraint
Definition: PgsqlSqlUtil.qm.dox.h:442
const Date
bool isEnabled()
returns True if the constraint is enabled, False if not
private bool supportsPackagesImpl()
returns True if the database supports packages
const COP_SEQ
*string getTablespaceName()
returns the data tablespace name for the table or NOTHING if none is known
const Hash
represents a PostgreSQL view
Definition: PgsqlSqlUtil.qm.dox.h:557
const String
const DefaultIopMap
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 ...
represents a PostgreSQL-specific check constraint
Definition: PgsqlSqlUtil.qm.dox.h:307
string sprintf(string fmt,...)
list listTypes()
returns a list of string type names in the database
const DefaultCopMap
bool hasArrayBind()
returns False because the pgsql driver does not support array binds / bulk DML operations ...
private list listProceduresImpl()
since PostgreSQL only supports functions, this method is identical to listFunctionsImpl() ...
provides the PostgreSQL-specific implementation of the AbstractDatabase interface ...
Definition: PgsqlSqlUtil.qm.dox.h:655
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
constructor(string n, string n_src)
creates the constraint from the supplied arguments
PgsqlColumn memberGate(string k)
returns the PgsqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
private hash getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
represents a PostgreSQL-specific column
Definition: PgsqlSqlUtil.qm.dox.h:327
const PgsqlNameMap
maps from verbose type names to simple type names
Definition: PgsqlSqlUtil.qm.dox.h:870
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
const COP_OVER
ListIterator materializedViewIterator()
returns an iterator listing the string materialized view names in the database
setTablespace(*string ts)
sets or clears the tablespace name
string getDropSqlForce()
returns a string that can be used to drop a type and all dependencies
bool setIndexBase(string ix)
sets the supporting index name
represents a PostgreSQL-specific trigger
Definition: PgsqlSqlUtil.qm.dox.h:583
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
setName(string new_name)
sets the new name of the function
represents a PostgreSQL type
Definition: PgsqlSqlUtil.qm.dox.h:215
private clearImpl()
clears PostgreSQL-specific table information
private string getCreateSqlImpl(list l)
returns a string that can be used to create the table in the database
const COP_SEQ_CURRVAL
const True
private hash getColumnOperatorMap()
returns the column operator map for this object
PgsqlColumn memberGate(string k)
returns the PgsqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
const CHAR
string trigger
trigger name
Definition: PgsqlSqlUtil.qm.dox.h:646
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
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 ...
represents a PostgreSQL-specific index
Definition: PgsqlSqlUtil.qm.dox.h:259
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the constraint
const PgsqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with "functions" for table functions requ...
Definition: PgsqlSqlUtil.qm.dox.h:897
string getRenameSql(string new_name)
returns a string that can be used to rename a type
number number(softnumber n)
const COP_YEAR_HOUR
represents a PostgreSQL-specific trigger function
Definition: PgsqlSqlUtil.qm.dox.h:641
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 ...
const IOP_SEQ_CURRVAL
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(*hash opt)
returns a string that can be used to create the type in the database
int byte_size
byte size of the column
Definition: PgsqlSqlUtil.qm.dox.h:332
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
*string tablespace
the tablespace name of the index
Definition: PgsqlSqlUtil.qm.dox.h:264
represents a PostgreSQL-specific numeric column
Definition: PgsqlSqlUtil.qm.dox.h:391
list list(...)
getIndexSql(reference sql, string name, *hash opts)
adds index options onto the sql creation string
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
const Float
private hash getInsertOperatorMap()
returns the insert operator map for this object
const QoreTypeMap
maps qore type names to PostgreSQL type names
Definition: PgsqlSqlUtil.qm.dox.h:883
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...
private computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
string getNativeTypeString()
returns a string giving the native type of the column
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 ...
constructor(*string ts)
creates the constraint with an optional tablespace name
string getSchemaName()
returns the schema name
const Boolean
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
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 ...
const SZ_NUM
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
string name
the name of the type
Definition: PgsqlSqlUtil.qm.dox.h:220
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
const Binary
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
static string getCreateSql(list l)
returns a string that can be used to create the schema in the database
private bool supportsSequencesImpl()
returns True if the database supports sequences
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
bool enabled
True if the constraint is enabled, False if not
Definition: PgsqlSqlUtil.qm.dox.h:447
const PgsqlTypeMap
maps PostgreSQL type names to type configurations
Definition: PgsqlSqlUtil.qm.dox.h:826
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
constructor()
creates an empty primary key object
const COP_YEAR_MONTH
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 string getCreateSqlImpl(list l)
returns a string that can be used to create the schema in the database
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: PgsqlSqlUtil.qm.dox.h:1020
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
common base class for unique constraints
Definition: PgsqlSqlUtil.qm.dox.h:404
const PgsqlSchemaDescriptionOptions
PostgreSQL-specific schema description keys.
Definition: PgsqlSqlUtil.qm.dox.h:660
const BLOB
private bool supportsTypesImpl()
returns True if the database supports named types
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
string type(any arg)
const CLOB
ListIterator typeIterator()
returns an iterator listing the string type names in the database
string src
the source of the type
Definition: PgsqlSqlUtil.qm.dox.h:223
represents a PostgreSQL-specific primary key constraint
Definition: PgsqlSqlUtil.qm.dox.h:496
constructor(string n_name, string n_src)
creates the type 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
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
private bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
const Int
private list listTablesImpl()
returns a list of string table names in the database
const COP_YEAR
string string(softstring str, *string enc)
const PgsqlUopMap
a hash of default update operator definitions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:994
*string tablespace
tablespace name for the table, if known
Definition: PgsqlSqlUtil.qm.dox.h:1014
list listMaterializedViews()
returns a list of string materialized view names in the database
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
represents a PostgreSQL-specific foreign constraint
Definition: PgsqlSqlUtil.qm.dox.h:287
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
const COP_CAST
const DefaultUopMap
const COP_YEAR_DAY
list getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
*string getTablespace()
returns the tablespace name used for this constraint, if known
constructor(string n_name, string n_src, *string n_schemaname, *string n_viewowner)
creates the object from the arguments
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
string getDropSql()
returns a string that can be used to drop the function from the database
string getDropSql(*hash opt)
returns a string that can be used to drop a type
constructor(string n, hash n_cols, bool e=True, *string ts)
creates the object with the given attributes
private string getCreateTableSqlImpl(*hash opt)
returns a string that can be used to create the table in the database
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace)
creates the object from the arguments
string schema
schema name for the table
Definition: PgsqlSqlUtil.qm.dox.h:1017
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
hash hash(object obj)
const PgsqlCopMap
column operator specializations for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:916
constructor(string n, Columns c, ForeignConstraintTarget t)
creates the constraint from the supplied arguments
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 SZ_OPT
*string tablespace
any tablespace for the unique key index
Definition: PgsqlSqlUtil.qm.dox.h:409
private bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
class for PostgreSQL sequences
Definition: PgsqlSqlUtil.qm.dox.h:540
abstract AbstractIterator keyIterator()
returns an iterator for keys iterating a list of string key names
const IOP_SEQ
PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a PgsqlTable object corresponding to the arguments
provides the PostgreSQL-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: PgsqlSqlUtil.qm.dox.h:821
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
softlist getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
private reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
const Number
PgsqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a PgsqlDatabase object corresponding to the arguments
represents a PostgreSQL-specific function
Definition: PgsqlSqlUtil.qm.dox.h:608
private copyImpl(AbstractTable old)
db-specific copy actions
bool equal(PgsqlType type)
returns True if the types are equal
private hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
clearIndex()
clears any index base for the constraint
string getNativeTypeString()
returns a string giving the native type of the column
private list listFunctionsImpl()
returns a list of string function names in the database