Qore PgsqlSqlUtil Module Reference  1.2.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 - 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 
215 namespace PgsqlSqlUtil {
218  PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
219 
220 
222  PgsqlDatabase get_database(AbstractDatasource nds, *hash opts);
223 
224 
225  parse_schema_name(string nname, reference<string> schema, reference<string> name);
226 
227 
229  class PgsqlType {
230 
231 public:
232  public :
234  string name;
235 
237  string src;
238 
239 public:
240 
242  constructor(string n_name, string n_src);
243 
244 
245  list getTypeList();
246 
247 
248  list getModifySql(PgsqlType old, *hash opt);
249 
250 
252  string getCreateSql(*hash opt);
253 
254 
256 
258  string getDropSql(*hash opt);
259 
260 
262 
265  string getRenameSql(string new_name, *hash opt);
266 
267 
269  bool equal(PgsqlType type);
270 
271  };
272 
275 
276 public:
277  public :
279  *string tablespace;
280 
281 public:
282 
284  constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace) ;
285 
286 
288  string getCreateSql(string table_name, *hash opt);
289 
290 
292 
293 private:
294  bool equalImpl(AbstractIndex ix);
295 public:
296 
297 
299  string getRenameSql(string table_name, string new_name);
300 
301 
302  };
303 
306 
307 public:
309  constructor(string n, Columns c, ForeignConstraintTarget t) ;
310 
311 
313  string getCreateSql(string table_name, *hash opt);
314 
315 
316  softlist getRenameSql(string table_name, string new_name);
317 
318 
320  string getCreateSql(string name, string table_name, *hash opt);
321 
322  };
323 
326 
327 public:
329  constructor(string n, string n_src) ;
330 
331 
333  string getCreateSql(string table_name, *hash opt);
334 
335 
336  list getRenameSql(string table_name, string new_name);
337 
338 
340  string getCreateSql(string name, string table_name, *hash opt);
341 
342  };
343 
346 
347 public:
348  public :
351 
352 public:
353 
355  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
356 
357 
359  string getNativeTypeString();
360 
361 
363 
370  list getAddColumnSql(AbstractTable t);
371 
372 
374 
387  list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
388 
389 
391 
401  string getRenameSql(AbstractTable t, string new_name);
402 
403 
405 
406 private:
407  bool equalImpl(AbstractColumn c);
408 public:
409 
410  };
411 
414 
415 public:
417  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale) ;
418 
419 
421  string getNativeTypeString();
422 
423  };
424 
427 
428 public:
429  private :
431  *string tablespace;
432 
433 public:
434 
436  constructor(*string ts);
437 
438 
440  *string getTablespace();
441 
442 
444  setTablespace(*string ts);
445 
446 
448  bool setIndexBase(string ix);
449 
450 
452  clearIndex();
453 
454 
456  abstract AbstractIterator keyIterator();
457 
459  getIndexSql(reference<string> sql, string name, *hash opts);
460 
461  };
462 
465 
466 public:
467  private :
469  bool enabled;
470 
471 public:
472 
474 
479  constructor(string n, hash n_cols, bool e = True, *string ts) ;
480 
481 
483 
498  PgsqlColumn memberGate(string k);
499 
500 
502  string getCreateSql(string table_name, *hash opts);
503 
504 
505  list getRenameSql(string table_name, string new_name);
506 
507 
509  string getCreateSql(string name, string table_name, *hash opts);
510 
511 
513  bool isEnabled();
514 
515  };
516 
519 
520 public:
522  constructor();
523 
524 
526 
530  constructor(string n, *hash c, *string ts) ;
531 
532 
534 
549  PgsqlColumn memberGate(string k);
550 
551 
553  string getCreateSql(string table_name, *hash opts);
554 
555 
557  softlist getRenameSql(string table_name, string new_name);
558 
559  };
560 
563 
564 public:
566  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
567 
568 
570  string getCreateSql(*hash opt);
571 
572 
574 
578  softlist getRenameSql(string new_name, *hash opt);
579 
580  };
581 
584 
585 public:
586 
587  public :
589  *string viewowner;
590 
591 public:
592 
594  constructor(string n_name, string n_src, *string n_schemaname,
595  *string n_viewowner)
596  ;
597 
598 
600  string getCreateSql(*hash opt);
601 
602 
604 
608  softlist getRenameSql(string new_name, *hash opt);
609 
610  };
611 
614 
615 public:
617  constructor(string n, string n_src) ;
618 
619 
621  softlist getCreateSql(string table_name, *hash opt);
622 
623 
625  softlist getDropSql(string table_name);
626 
627 
629 
630 private:
631  bool equalImpl(AbstractFunctionBase t);
632 public:
633 
634 
636  softlist getRenameSql(string table_name, string new_name);
637 
638  };
639 
642 
643 public:
644  public :
645  *string args;
646 
647 public:
648 
649  constructor(string n, string n_src, *string a) ;
650 
651 
653  softlist getCreateSql(*hash opt);
654 
655 
657 
659  string getDropSql(*hash opt);
660 
661 
663 
664 private:
665  bool equalImpl(AbstractFunctionBase t);
666 public:
667 
668 
670 
673  softlist getRenameSql(string new_name, *hash opt);
674 
675 
677  setName(string new_name);
678 
679  };
680 
683 
684 public:
685  public :
687  string trigger;
688 
689 public:
690 
691  constructor(string n, string n_src, string n_trigger) ;
692 
693  };
694 
697 
698 public:
699  public :
701  const PgsqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + (
702  "types": Type::Hash,
703  "type_map": Type::Hash,
704  );
705 
706  const PGSQL_TempSavepoint = "qore_pgsql_tmp_savepoint";
707 
710  "full" : Type::Boolean,
711  "analyze" : Type::Boolean,
712  );
713 
714 public:
715 
716  constructor(AbstractDatasource nds, *hash opts) ;
717 
718 
719 
720 private:
721  list featuresImpl();
722 public:
723 
724 
725  PgsqlType makeType(string name, string src, *hash opts);
726 
727 
728  *PgsqlType getType(string name);
729 
730 
731 
732 private:
733  PgsqlSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
734 public:
735 
736 
737 
738 private:
739  *AbstractSequence getSequenceImpl(string name);
740 public:
741 
742 
743 
744 private:
745  *AbstractView getViewImpl(string name);
746 public:
747 
748 
749 
750 private:
751  PgsqlFunction makeFunctionImpl(string name, string src, *hash opts);
752 public:
753 
754 
755 
756 private:
757  PgsqlFunction makeProcedureImpl(string name, string src, *hash opts);
758 public:
759 
760 
761 
762 private:
763  *AbstractFunction getFunctionImpl(string name);
764 public:
765 
766 
767 
768 private:
769  AbstractFunction getProcedureImpl(string name);
770 public:
771 
772 
773  static *string getFunctionArgs(string err, reference<string> src);
774 
775  static PgsqlFunction processFunction(hash row, bool native_case);
776 
777 
778 private:
779  list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
780 public:
781 
782 
783 
784 private:
785  list getAlignSqlImpl(hash schema_hash, *hash opt);
786 public:
787 
788 
790 
791 private:
793 public:
794 
795 
797 
802 private:
804 public:
805 
806 
808 
811 private:
813 public:
814 
815 
816 
817 private:
818  list listSequencesImpl();
819 public:
820 
821 
822 
823 private:
824  list listViewsImpl();
825 public:
826 
827 
830 
831 
833  ListIterator materializedViewIterator();
834 
835 
837  list listTypes();
838 
839 
841  ListIterator typeIterator();
842 
843 
845 
846 private:
847  string getCreateSqlImpl(list l);
848 public:
849 
850 
852  static string getCreateSql(list l);
853 
855 
856 private:
858 public:
859 
860 
862 
863 private:
865 public:
866 
867 
869 
870 private:
871  softint getNextSequenceValueImpl(string name);
872 public:
873 
874 
876 
877 private:
878  softint getCurrentSequenceValueImpl(string name);
879 public:
880 
881 
883 
884 private:
885  bool supportsSequencesImpl();
886 public:
887 
888 
890 
891 private:
892  bool supportsTypesImpl();
893 public:
894 
895 
897 
898 private:
899  bool supportsPackagesImpl();
900 public:
901 
902 
904 
905 private:
906  bool rebuildIndexImpl(string name, *hash options);
907 public:
908 
909 
911 
912 private:
913  computeStatisticsImpl(*hash options);
914 public:
915 
916 
918 
919 private:
920  reclaimSpaceImpl(*hash options);
921 public:
922 
923 
925 
926 private:
927  auto tryExecArgsImpl(string sql, *softlist args);
928 public:
929 
930 
932 
933 private:
934  auto tryExecRawImpl(string sql, *softlist args);
935 public:
936 
937 
939  static auto tryExecArgs(AbstractDatasource ds, string sql, *softlist args);
940 
942  static auto tryExecRaw(AbstractDatasource ds, string sql);
943  };
944 
947 
948 public:
949  public :
951  const PgsqlTypeMap = (
952  "abstime": ("qore": Type::Date,),
953  "bigint": ("qore": Type::Int,),
954  "bigserial": ("qore": Type::Int,),
955  "bit": ("qore": Type::Binary, "size": SZ_OPT,),
956  "bit varying": ("qore": Type::Binary, "size": SZ_OPT,),
957  "bool": ("qore": Type::Boolean,),
958  "boolean": ("qore": Type::Boolean,),
959  "bytea": ("qore": Type::Binary,),
960  "char": ("qore": Type::String, "size": SZ_OPT,),
961  "character": ("qore": Type::String, "size": SZ_OPT,),
962  "character varying": ("qore": Type::String, "size": SZ_OPT,),
963  "cidr": ("qore": Type::String,),
964  "date": ("qore": Type::Date,),
965  "decimal": ("qore": Type::Number, "size": SZ_NUM,),
966  "double precision": ("qore": Type::Float,),
967  "float": ("qore": Type::Float,),
968  "inet": ("qore": Type::String,),
969  "int": ("qore": Type::Int,),
970  "integer": ("qore": Type::Int,),
971  "interval": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
972  "macaddr": ("qore": Type::String,),
973  "money": ("qore": Type::Number,),
974  "numeric": ("qore": Type::Number, "size": SZ_NUM,),
975  "oid": ("qore": Type::Int,),
976  "real": ("qore": Type::Float,),
977  "reltime": ("qore": Type::Date,),
978  "serial": ("qore": Type::Int,),
979  "smallint": ("qore": Type::Int,),
980  "smallserial": ("qore": Type::Int,),
981  "text": ("qore": Type::String,),
982  "time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
983  "time with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
984  "time without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
985  "timetz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
986  "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
987  "timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
988  "timestamp without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
989  "timestamptz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
990  "varbit": ("qore": Type::Binary, "size": SZ_OPT,),
991  "varchar": ("qore": Type::String, "size": SZ_OPT,),
992  );
993 
995  const PgsqlNameMap = (
996  "bit varying": "varbit",
997  "character": "char",
998  "character varying": "varchar",
999  "char varying": "varchar",
1000  "double precision": "float",
1001  "time with time zone": "timetz",
1002  "time without time zone": "time",
1003  "timestamp with time zone": "timestamptz",
1004  "timestamp without time zone": "timestamp",
1005  );
1006 
1008  const QoreTypeMap = (
1009  "integer": "bigint",
1010  "float": "double precision",
1011  "number": "numeric",
1012  "string": "varchar",
1013  "date": "timestamp",
1014  "binary": "bytea",
1015  "bool": "boolean",
1016  SqlUtil::CHAR: "char",
1017  SqlUtil::CLOB: "text",
1018  SqlUtil::BLOB: "bytea",
1019  );
1020 
1022  const PgsqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
1023  "functions": Type::Hash,
1024  );
1025 
1026  const PgsqlColumnDescOptions = AbstractTable::ColumnDescOptions;
1027 
1028  const PgsqlIndexOptions = AbstractTable::IndexOptions;
1029 
1030  const PgsqlConstraintOptions = AbstractTable::ConstraintOptions + PgsqlIndexOptions + (
1031  "index": Type::String,
1032  );
1033 
1034  const PgsqlTableCreationOptions = AbstractTable::TableCreationOptions + PgsqlConstraintOptions + (
1035  "omit_trigger_functions": Type::Boolean,
1036  );
1037 
1038  const PgsqlAlignTableOptions = AbstractTable::AlignTableOptions + PgsqlTableCreationOptions;
1039 
1041  const PgsqlCopMap = (
1042  COP_CAST: (
1043  "code": string (string cve, list args) {
1044  string name = QoreTypeMap{args[0]} ?? args[0];
1045  hash desc = PgsqlTypeMap{name};
1046  string sql = sprintf ("cast (%s as %s", cve, name);
1047  switch (name);
1048 
1049  sql += ")";
1050  return sql;
1051  },
1052  ),
1053  COP_YEAR: (
1054  "code": string (string arg1, auto arg) {
1055  return sprintf("to_char(%s, 'YYYY')", arg1);
1056  }
1057  ),
1058  COP_YEAR_MONTH: (
1059  "code": string (string arg1, auto arg) {
1060  return sprintf("to_char(%s, 'YYYY-MM')", arg1);
1061  }
1062  ),
1063  COP_YEAR_DAY: (
1064  "code": string (string arg1, auto arg) {
1065  return sprintf("to_char(%s, 'YYYY-MM-DD')", arg1);
1066  }
1067  ),
1068  COP_YEAR_HOUR: (
1069  "code": string (string arg1, auto arg) {
1070  return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", arg1);
1071  }
1072  ),
1073  COP_SEQ: (
1074  "nocolumn": True,
1075  "withalias": True,
1076  "code": string (*string cve, hash arg, reference<hash> psch) {
1077  string sql = sprintf("nextval('%s')", arg.seq);
1078  if (arg.as);
1079 
1080  return sql;
1081  }
1082  ),
1083  COP_SEQ_CURRVAL: (
1084  "nocolumn": True,
1085  "withalias": True,
1086  "code": string (*string cve, hash arg, reference<hash> psch) {
1087  string sql = sprintf("currval('%s')", arg.seq);
1088  if (arg.as);
1089 
1090  return sql;
1091  }
1092  ),
1093  COP_TRUNC_DATE: (
1094  "code": string sub(string arg1, auto arg) {
1095  if (!PgsqlTruncDate.hasKey(arg));
1096 
1097  return sprintf("date_trunc(%s, %s)", PgsqlTruncDate{arg}, arg1);
1098  }
1099  )
1100  );
1101 
1103  const PgsqlTruncDate = (
1104  DT_YEAR : "'year'",
1105  DT_MONTH : "'month'",
1106  DT_DAY : "'day'",
1107  DT_HOUR : "'hour'",
1108  DT_MINUTE : "'minute'",
1109  DT_SECOND : "'second'",
1110  );
1111 
1114  IOP_SEQ: (
1115  "arg": Type::String,
1116  "placeholder": "nextval(%v)",
1117  ),
1118  IOP_SEQ_CURRVAL: (
1119  "arg": Type::String,
1120  "placeholder": "currval(%v)",
1121  ),
1122  );
1123 
1126  COP_SEQ: (
1127  "nocolumn": True,
1128  "code": string (*string cve, string arg) {
1129  return sprintf("nextval('%s')", arg);
1130  }
1131  ),
1132  COP_SEQ_CURRVAL: (
1133  "nocolumn": True,
1134  "withalias": True,
1135  "code": string (*string cve, string arg) {
1136  return sprintf("currval('%s')", arg);
1137  }
1138  ),
1139  );
1140 
1141 public:
1142 
1143  private :
1145  *string tablespace;
1146 
1148  string schema;
1149 
1151  Functions triggerFunctions;
1152 
1153 public:
1154 
1155  constructor(AbstractDatasource nds, string nname, *hash opts) ;
1156 
1157 
1159  string getSchemaName();
1160 
1161 
1163  *string getTablespaceName();
1164 
1165 
1166  PgsqlFunction addTriggerFunction(string tfname, string src, string trigger);
1167 
1168 
1170  bool hasArrayBind();
1171 
1172 
1173 
1174 private:
1175  PgsqlFunction addTriggerFunctionUnlocked(string tfname, string src, string trigger);
1176 public:
1177 
1178 
1180  string getSqlName();
1181 
1182 
1183 
1184 private:
1185  hash getTableCreationOptions();
1186 public:
1187 
1188 
1189 
1190 private:
1191  hash getTableDescriptionHashOptions();
1192 public:
1193 
1194 
1195 
1196 private:
1197  hash getColumnDescOptions();
1198 public:
1199 
1200 
1201 
1202 private:
1203  hash getIndexOptions();
1204 public:
1205 
1206 
1207 
1208 private:
1209  hash getConstraintOptions();
1210 public:
1211 
1212 
1213 
1214 private:
1215  hash getAlignTableOptions();
1216 public:
1217 
1218 
1220 
1221 private:
1223 public:
1224 
1225 
1227 
1228 private:
1230 public:
1231 
1232 
1234 
1235 private:
1237 public:
1238 
1239 
1240 
1241 private:
1242  bool checkExistenceImpl();
1243 public:
1244 
1245 
1246 
1247 private:
1248  Columns describeImpl();
1249 public:
1250 
1251 
1252 
1253 private:
1254  PgsqlPrimaryKey getPrimaryKeyImpl();
1255 public:
1256 
1257 
1258 
1259 private:
1260  Indexes getIndexesImpl();
1261 public:
1262 
1263 
1264 
1265 private:
1266  ForeignConstraints getForeignConstraintsImpl(*hash opts);
1267 public:
1268 
1269 
1270 
1271 private:
1272  Constraints getConstraintsImpl();
1273 public:
1274 
1275 
1276 
1277 private:
1278  Triggers getTriggersImpl();
1279 public:
1280 
1281 
1283 
1284 private:
1285  string getCreateTableSqlImpl(*hash opt);
1286 public:
1287 
1288 
1289 
1290 private:
1291  *list getCreateMiscSqlImpl(*hash opt, bool cache);
1292 public:
1293 
1294 
1295 
1296 private:
1297  *list getAlignSqlImpl(AbstractTable table, *hash opt);
1298 public:
1299 
1300 
1302 
1303 private:
1304  string getCreateSqlImpl(list l);
1305 public:
1306 
1307 
1308 
1309 private:
1310  string getRenameSqlImpl(string new_name);
1311 public:
1312 
1313 
1314 
1315 private:
1316  AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1317 public:
1318 
1319 
1320 
1321 private:
1322  AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1323 public:
1324 
1325 
1326 
1327 private:
1328  AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
1329 public:
1330 
1331 
1332 
1333 private:
1334  AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
1335 public:
1336 
1337 
1338 
1339 private:
1340  AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
1341 public:
1342 
1343 
1344 
1345 private:
1346  AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
1347 public:
1348 
1349 
1350 
1351 private:
1352  AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
1353 public:
1354 
1355 
1356 
1357 private:
1358  bool tryInsertImpl(string sql, hash row);
1359 public:
1360 
1361 
1362 
1363 private:
1364  hash getQoreTypeMapImpl();
1365 public:
1366 
1367 
1368 
1369 private:
1370  hash getTypeMapImpl();
1371 public:
1372 
1373 
1375 
1376 private:
1377  *string getSqlValueImpl(auto v);
1378 public:
1379 
1380 
1381 
1382 private:
1383  bool emptyImpl();
1384 public:
1385 
1386 
1388 
1389 private:
1390  clearImpl();
1391 public:
1392 
1393 
1394 
1395 private:
1396  softlist getDropSqlImpl();
1397 public:
1398 
1399 
1400 
1401 private:
1402  setupTableImpl(hash desc, *hash opt);
1403 public:
1404 
1405 
1407 
1408 private:
1410 public:
1411 
1412 
1414 
1415 private:
1417 public:
1418 
1419 
1421 
1422 private:
1423  bool supportsTablespacesImpl();
1424 public:
1425 
1426 
1428 
1429 private:
1430  doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *hash qh);
1431 public:
1432 
1433 
1435 
1436 private:
1437  doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1438 public:
1439 
1440 
1442 
1443 private:
1444  auto tryExecArgsImpl(string sql, *softlist args);
1445 public:
1446 
1447 
1449 
1450 private:
1451  auto tryExecRawImpl(string sql, *softlist args);
1452 public:
1453 
1454 
1456 
1457 private:
1458  copyImpl(AbstractTable old);
1459 public:
1460 
1461 
1462 
1463 private:
1464  *hash doReturningImpl(hash opt, reference<string> sql, list args);
1465 public:
1466 
1467 
1468 
1469 private:
1470  list getGroupOrderByListUnlocked(string key, hash qh, *hash jch, *hash ch, *hash psch, list coll);
1471 public:
1472 
1473  };
1474 };
const PgsqlIopMap
a hash of default value operator descriptions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1113
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
const PgsqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: PgsqlSqlUtil.qm.dox.h:709
*string viewowner
Owner of the view.
Definition: PgsqlSqlUtil.qm.dox.h:589
class modeling a unique constraint
Definition: PgsqlSqlUtil.qm.dox.h:464
const Date
bool isEnabled()
returns True if the constraint is enabled, False if not
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
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:583
const String
const DefaultIopMap
hash getColumnOperatorMapImpl()
returns the column operator map for this object
represents a PostgreSQL-specific check constraint
Definition: PgsqlSqlUtil.qm.dox.h:325
string sprintf(string fmt,...)
list listTypes()
returns a list of string type names in the database
string getCreateSqlImpl(list l)
returns a string that can be used to create the table in the database
bool hasArrayBind()
returns False because the pgsql driver does not support array binds / bulk DML operations ...
bool supportsSequencesImpl()
returns True if the database supports sequences
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
provides the PostgreSQL-specific implementation of the AbstractDatabase interface ...
Definition: PgsqlSqlUtil.qm.dox.h:696
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 ...
list listProceduresImpl()
since PostgreSQL only supports functions, this method is identical to listFunctionsImpl() ...
static auto tryExecRaw(AbstractDatasource ds, string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
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:345
const PgsqlNameMap
maps from verbose type names to simple type names
Definition: PgsqlSqlUtil.qm.dox.h:995
ListIterator materializedViewIterator()
returns an iterator listing the string materialized view names in the database
setTablespace(*string ts)
sets or clears the tablespace name
bool setIndexBase(string ix)
sets the supporting index name
doSelectOrderByWithOffsetSqlUnlockedImpl(reference< string > sql, reference< list > args, *hash qh, *hash jch, *hash ch, *hash psch, list coll)
processes a string for use in SQL select statements when there is an &quot;order by&quot; and &quot;offset&quot; argument...
represents a PostgreSQL-specific trigger
Definition: PgsqlSqlUtil.qm.dox.h:613
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:229
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
doSelectLimitOnlyUnlockedImpl(reference< string > sql, reference< list > args, *hash qh)
processes a string for use in SQL select statements when there is a &quot;limit&quot; argument, but no &quot;orderby&quot; or &quot;offset&quot; arguments
const COP_SEQ_CURRVAL
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
const True
list listTablesImpl()
returns a list of string table names in the database
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:687
represents a PostgreSQL-specific index
Definition: PgsqlSqlUtil.qm.dox.h:274
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
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 &quot;functions&quot; for table functions requ...
Definition: PgsqlSqlUtil.qm.dox.h:1022
number number(softnumber n)
const COP_YEAR_HOUR
represents a PostgreSQL-specific trigger function
Definition: PgsqlSqlUtil.qm.dox.h:682
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:350
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:279
represents a PostgreSQL-specific numeric column
Definition: PgsqlSqlUtil.qm.dox.h:413
list list(...)
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
const Float
const QoreTypeMap
maps qore type names to PostgreSQL type names
Definition: PgsqlSqlUtil.qm.dox.h:1008
string getNativeTypeString()
returns a string giving the native type of the column
const DT_DAY
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)
hash getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
auto tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
string getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename a type
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:234
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
static auto 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 ...
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
bool supportsTypesImpl()
returns True if the database supports named types
static string getCreateSql(list l)
returns a string that can be used to create the schema in the database
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
bool enabled
True if the constraint is enabled, False if not
Definition: PgsqlSqlUtil.qm.dox.h:469
clearImpl()
clears PostgreSQL-specific table information
const PgsqlTypeMap
maps PostgreSQL type names to type configurations
Definition: PgsqlSqlUtil.qm.dox.h:951
auto tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
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
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: PgsqlSqlUtil.qm.dox.h:1151
common base class for unique constraints
Definition: PgsqlSqlUtil.qm.dox.h:426
const PgsqlSchemaDescriptionOptions
PostgreSQL-specific schema description keys.
Definition: PgsqlSqlUtil.qm.dox.h:701
const BLOB
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
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:237
represents a PostgreSQL-specific primary key constraint
Definition: PgsqlSqlUtil.qm.dox.h:518
constructor(string n_name, string n_src)
creates the type from the supplied arguments
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
string getCreateTableSqlImpl(*hash opt)
returns a string that can be used to create the table in the database
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
auto tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
getIndexSql(reference< string > sql, string name, *hash opts)
adds index options onto the sql creation string
string type(auto arg)
const COP_TRUNC_DATE
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
const Int
const COP_YEAR
string string(softstring str, *string enc)
auto tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
const PgsqlUopMap
a hash of default update operator definitions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1125
*string tablespace
tablespace name for the table, if known
Definition: PgsqlSqlUtil.qm.dox.h:1145
list listMaterializedViews()
returns a list of string materialized view names in the database
string getCreateSqlImpl(list l)
returns a string that can be used to create the schema in the database
bool supportsPackagesImpl()
returns True if the database supports packages
represents a PostgreSQL-specific foreign constraint
Definition: PgsqlSqlUtil.qm.dox.h:305
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 DT_MINUTE
const DT_HOUR
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 getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
*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
const DT_MONTH
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
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
constructor(string n, hash n_cols, bool e=True, *string ts)
creates the object with the given attributes
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
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
string schema
schema name for the table
Definition: PgsqlSqlUtil.qm.dox.h:1148
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
hash hash(object obj)
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
const PgsqlCopMap
column operator specializations for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1041
constructor(string n, Columns c, ForeignConstraintTarget t)
creates the constraint from the supplied arguments
hash getInsertOperatorMap()
returns the insert operator map for this object
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:431
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
class for PostgreSQL sequences
Definition: PgsqlSqlUtil.qm.dox.h:562
list listFunctionsImpl()
returns a list of string function names in the database
bool supportsTablespacesImpl()
returns True if the database support tablespaces
abstract AbstractIterator keyIterator()
returns an iterator for keys iterating a list of string key names
copyImpl(AbstractTable old)
db-specific copy actions
const IOP_SEQ
PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a PgsqlTable object corresponding to the arguments
const PgsqlTruncDate
Map SqlUtil::cop_trunc_date() constants to PostgreSQL internal masks.
Definition: PgsqlSqlUtil.qm.dox.h:1103
const DT_YEAR
provides the PostgreSQL-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: PgsqlSqlUtil.qm.dox.h:946
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
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:641
bool equal(PgsqlType type)
returns True if the types are equal
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
const DT_SECOND
clearIndex()
clears any index base for the constraint
string getNativeTypeString()
returns a string giving the native type of the column