215 namespace PgsqlSqlUtil {
218 PgsqlTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
225 parse_schema_name(
string nname, reference<string> schema, reference<string> name);
284 constructor(
string n_name,
bool n_unique,
hash n_cols, *
string n_tablespace) ;
299 string getRenameSql(
string table_name,
string new_name);
309 constructor(
string n, Columns c, ForeignConstraintTarget t) ;
316 softlist getRenameSql(
string table_name,
string new_name);
336 list getRenameSql(
string table_name,
string new_name);
355 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs) ;
417 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs, softint n_scale) ;
505 list getRenameSql(
string table_name,
string new_name);
557 softlist
getRenameSql(
string table_name,
string new_name);
594 constructor(
string n_name,
string n_src, *
string n_schemaname,
636 softlist
getRenameSql(
string table_name,
string new_name);
649 constructor(
string n,
string n_src, *
string a) ;
691 constructor(
string n,
string n_src,
string n_trigger) ;
706 const PGSQL_TempSavepoint =
"qore_pgsql_tmp_savepoint";
716 constructor(AbstractDatasource nds, *
hash opts) ;
739 *AbstractSequence getSequenceImpl(
string name);
745 *AbstractView getViewImpl(
string name);
763 *AbstractFunction getFunctionImpl(
string name);
769 AbstractFunction getProcedureImpl(
string name);
773 static *
string getFunctionArgs(
string err, reference<string> src);
818 list listSequencesImpl();
824 list listViewsImpl();
939 static auto tryExecArgs(AbstractDatasource
ds,
string sql, *softlist args);
942 static auto tryExecRaw(AbstractDatasource
ds,
string sql);
971 "interval": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
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,),
996 "bit varying":
"varbit",
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",
1009 "integer":
"bigint",
1010 "float":
"double precision",
1011 "number":
"numeric",
1012 "string":
"varchar",
1013 "date":
"timestamp",
1026 const PgsqlColumnDescOptions = AbstractTable::ColumnDescOptions;
1028 const PgsqlIndexOptions = AbstractTable::IndexOptions;
1030 const PgsqlConstraintOptions = AbstractTable::ConstraintOptions + PgsqlIndexOptions + (
1034 const PgsqlTableCreationOptions = AbstractTable::TableCreationOptions + PgsqlConstraintOptions + (
1038 const PgsqlAlignTableOptions = AbstractTable::AlignTableOptions + PgsqlTableCreationOptions;
1046 string sql =
sprintf (
"cast (%s as %s", cve, name);
1054 "code":
string (
string arg1,
auto arg) {
1055 return sprintf(
"to_char(%s, 'YYYY')", arg1);
1059 "code":
string (
string arg1,
auto arg) {
1060 return sprintf(
"to_char(%s, 'YYYY-MM')", arg1);
1064 "code":
string (
string arg1,
auto arg) {
1065 return sprintf(
"to_char(%s, 'YYYY-MM-DD')", arg1);
1069 "code":
string (
string arg1,
auto arg) {
1070 return sprintf(
"to_char(%s, 'YYYY-MM-DD HH24')", arg1);
1076 "code":
string (*
string cve,
hash arg, reference<hash> psch) {
1077 string sql =
sprintf(
"nextval('%s')", arg.seq);
1086 "code":
string (*
string cve,
hash arg, reference<hash> psch) {
1087 string sql =
sprintf(
"currval('%s')", arg.seq);
1094 "code":
string sub(
string arg1,
auto arg) {
1116 "placeholder":
"nextval(%v)",
1120 "placeholder":
"currval(%v)",
1128 "code":
string (*
string cve,
string arg) {
1129 return sprintf(
"nextval('%s')", arg);
1135 "code":
string (*
string cve,
string arg) {
1136 return sprintf(
"currval('%s')", arg);
1155 constructor(AbstractDatasource nds,
string nname, *
hash opts) ;
1166 PgsqlFunction addTriggerFunction(
string tfname,
string src,
string trigger);
1175 PgsqlFunction addTriggerFunctionUnlocked(
string tfname,
string src,
string trigger);
1185 hash getTableCreationOptions();
1191 hash getTableDescriptionHashOptions();
1197 hash getColumnDescOptions();
1203 hash getIndexOptions();
1209 hash getConstraintOptions();
1215 hash getAlignTableOptions();
1242 bool checkExistenceImpl();
1248 Columns describeImpl();
1260 Indexes getIndexesImpl();
1266 ForeignConstraints getForeignConstraintsImpl(*
hash opts);
1272 Constraints getConstraintsImpl();
1278 Triggers getTriggersImpl();
1297 *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
1310 string getRenameSqlImpl(
string new_name);
1316 AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
1322 AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
1328 AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
1334 AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
1340 AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
1346 AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
1352 AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
1358 bool tryInsertImpl(
string sql,
hash row);
1364 hash getQoreTypeMapImpl();
1370 hash getTypeMapImpl();
1396 softlist getDropSqlImpl();
1402 setupTableImpl(
hash desc, *
hash opt);
1464 *
hash doReturningImpl(
hash opt, reference<string> sql,
list args);
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
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()
*string getTablespaceName()
returns the data tablespace name for the table or NOTHING if none is known
represents a PostgreSQL view
Definition: PgsqlSqlUtil.qm.dox.h:583
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 "order by" and "offset" 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 "limit" argument, but no "orderby" or "offset" arguments
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
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 ...
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 "functions" for table functions requ...
Definition: PgsqlSqlUtil.qm.dox.h:1022
number number(softnumber n)
represents a PostgreSQL-specific trigger function
Definition: PgsqlSqlUtil.qm.dox.h:682
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
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
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
constructor(*string ts)
creates the constraint with an optional tablespace name
string getSchemaName()
returns the schema name
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
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
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
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
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
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
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
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
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
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
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...
*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
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
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
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 ReclaimSpaceOptions
clearIndex()
clears any index base for the constraint
string getNativeTypeString()
returns a string giving the native type of the column