All Classes Namespaces Functions Variables Groups Pages
PgsqlSqlUtil.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file PgsqlSqlUtil.qm Qore user module for working with PostgreSQL SQL data
/* PgsqlSqlUtil.qm Copyright (C) 2013 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum qore version
// requires the SqlUtil module
// don't use "$" signs for variables and class members, assume local variable scope
// require type definitions everywhere
// enable all warnings
// version history is included below in the docs
namespace PgsqlSqlUtil {
PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
PgsqlDatabase get_database(AbstractDatasource nds, *hash opts);
parse_schema_name(string nname, reference<string> schema, reference<string> name);
class PgsqlType {
public:
public :
string name;
string src;
public:
constructor(string n_name, string n_src);
list getTypeList();
list getModifySql(PgsqlType old, *hash opt);
string getCreateSql(*hash opt);
string getDropSql(*hash opt);
string getRenameSql(string new_name, *hash opt);
bool equal(PgsqlType type);
};
class PgsqlIndex : public SqlUtil::AbstractIndex {
public:
public :
*string tablespace;
public:
constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace) ;
string getCreateSql(string table_name, *hash opt);
private:
bool equalImpl(AbstractIndex ix);
public:
string getRenameSql(string table_name, string new_name);
};
class PgsqlForeignConstraint : public SqlUtil::AbstractForeignConstraint {
public:
constructor(string n, Columns c, ForeignConstraintTarget t) ;
string getCreateSql(string table_name, *hash opt);
softlist getRenameSql(string table_name, string new_name);
string getCreateSql(string name, string table_name, *hash opt);
};
class PgsqlCheckConstraint : public SqlUtil::AbstractCheckConstraint {
public:
constructor(string n, string n_src) ;
string getCreateSql(string table_name, *hash opt);
list getRenameSql(string table_name, string new_name);
string getCreateSql(string name, string table_name, *hash opt);
};
class PgsqlColumn : public SqlUtil::AbstractColumn {
public:
public :
int byte_size;
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs) ;
string getNativeTypeString();
list getAddColumnSql(AbstractTable t);
list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
string getRenameSql(AbstractTable t, string new_name);
private:
bool equalImpl(AbstractColumn c);
public:
};
class PgsqlNumericColumn : public PgsqlColumn,public SqlUtil::NumericColumnInfo {
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale) ;
string getNativeTypeString();
};
class PgsqlUniqueConstraintCommon : public SqlUtil::AbstractUniqueConstraint {
public:
private :
*string tablespace;
public:
constructor(*string ts);
*string getTablespace();
setTablespace(*string ts);
bool setIndexBase(string ix);
clearIndex();
abstract AbstractIterator keyIterator();
getIndexSql(reference<string> sql, string name, *hash opts);
};
class PgsqlUniqueConstraint : public SqlUtil::AbstractUniqueConstraint,public PgsqlUniqueConstraintCommon {
public:
private :
bool enabled;
public:
constructor(string n, hash n_cols, bool e = True, *string ts) ;
PgsqlColumn memberGate(string k);
string getCreateSql(string table_name, *hash opts);
list getRenameSql(string table_name, string new_name);
string getCreateSql(string name, string table_name, *hash opts);
bool isEnabled();
};
class PgsqlPrimaryKey : public SqlUtil::AbstractPrimaryKey,public PgsqlUniqueConstraintCommon {
public:
constructor();
constructor(string n, *hash c, *string ts) ;
PgsqlColumn memberGate(string k);
string getCreateSql(string table_name, *hash opts);
softlist getRenameSql(string table_name, string new_name);
};
class PgsqlSequence : public SqlUtil::AbstractSequence {
public:
constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
string getCreateSql(*hash opt);
softlist getRenameSql(string new_name, *hash opt);
};
class PgsqlView : public SqlUtil::AbstractView {
public:
public :
*string viewowner;
public:
constructor(string n_name, string n_src, *string n_schemaname,
*string n_viewowner)
;
string getCreateSql(*hash opt);
softlist getRenameSql(string new_name, *hash opt);
};
class PgsqlTrigger : public SqlUtil::AbstractTrigger {
public:
constructor(string n, string n_src) ;
softlist getCreateSql(string table_name, *hash opt);
softlist getDropSql(string table_name);
private:
bool equalImpl(AbstractFunctionBase t);
public:
softlist getRenameSql(string table_name, string new_name);
};
class PgsqlFunction : public SqlUtil::AbstractFunction {
public:
public :
*string args;
public:
constructor(string n, string n_src, *string a) ;
softlist getCreateSql(*hash opt);
string getDropSql(*hash opt);
private:
bool equalImpl(AbstractFunctionBase t);
public:
softlist getRenameSql(string new_name, *hash opt);
setName(string new_name);
};
class PgsqlTriggerFunction : public PgsqlFunction {
public:
public :
string trigger;
public:
constructor(string n, string n_src, string n_trigger) ;
};
class PgsqlDatabase : public SqlUtil::AbstractDatabase {
public:
public :
const PgsqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + (
"types": Type::Hash,
"type_map": Type::Hash,
);
const PGSQL_TempSavepoint = "qore_pgsql_tmp_savepoint";
const PgsqlReclaimSpaceOptions = ReclaimSpaceOptions + (
"full" : Type::Boolean,
"analyze" : Type::Boolean,
);
public:
constructor(AbstractDatasource nds, *hash opts) ;
private:
list featuresImpl();
public:
PgsqlType makeType(string name, string src, *hash opts);
*PgsqlType getType(string name);
private:
PgsqlSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
public:
private:
*AbstractSequence getSequenceImpl(string name);
public:
private:
*AbstractView getViewImpl(string name);
public:
private:
PgsqlFunction makeFunctionImpl(string name, string src, *hash opts);
public:
private:
PgsqlFunction makeProcedureImpl(string name, string src, *hash opts);
public:
private:
*AbstractFunction getFunctionImpl(string name);
public:
private:
AbstractFunction getProcedureImpl(string name);
public:
static *string getFunctionArgs(string err, reference<string> src);
static PgsqlFunction processFunction(hash row, bool native_case);
private:
list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
public:
private:
list getAlignSqlImpl(hash schema_hash, *hash opt);
public:
private:
list listTablesImpl();
public:
private:
list listFunctionsImpl();
public:
private:
list listProceduresImpl();
public:
private:
list listSequencesImpl();
public:
private:
list listViewsImpl();
public:
list listMaterializedViews();
ListIterator materializedViewIterator();
list listTypes();
ListIterator typeIterator();
private:
string getCreateSqlImpl(list l);
public:
static string getCreateSql(list l);
private:
hash getSchemaDescriptionOptions();
public:
private:
hash getReclaimSpaceOptions();
public:
private:
softint getNextSequenceValueImpl(string name);
public:
private:
softint getCurrentSequenceValueImpl(string name);
public:
private:
bool supportsSequencesImpl();
public:
private:
bool supportsTypesImpl();
public:
private:
bool supportsPackagesImpl();
public:
private:
bool rebuildIndexImpl(string name, *hash options);
public:
private:
computeStatisticsImpl(*hash options);
public:
private:
reclaimSpaceImpl(*hash options);
public:
private:
auto tryExecArgsImpl(string sql, *softlist args);
public:
private:
auto tryExecRawImpl(string sql, *softlist args);
public:
static auto tryExecArgs(AbstractDatasource ds, string sql, *softlist args);
static auto tryExecRaw(AbstractDatasource ds, string sql);
};
class PgsqlTable : public SqlUtil::AbstractTable {
public:
public :
const PgsqlTypeMap = (
"abstime": ("qore": Type::Date,),
"bigint": ("qore": Type::Int,),
"bigserial": ("qore": Type::Int,),
"bit": ("qore": Type::Binary, "size": SZ_OPT,),
"bit varying": ("qore": Type::Binary, "size": SZ_OPT,),
"bool": ("qore": Type::Boolean,),
"boolean": ("qore": Type::Boolean,),
"bytea": ("qore": Type::Binary,),
"char": ("qore": Type::String, "size": SZ_OPT,),
"character": ("qore": Type::String, "size": SZ_OPT,),
"character varying": ("qore": Type::String, "size": SZ_OPT,),
"cidr": ("qore": Type::String,),
"date": ("qore": Type::Date,),
"decimal": ("qore": Type::Number, "size": SZ_NUM,),
"double precision": ("qore": Type::Float,),
"float": ("qore": Type::Float,),
"inet": ("qore": Type::String,),
"int": ("qore": Type::Int,),
"integer": ("qore": Type::Int,),
"interval": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"macaddr": ("qore": Type::String,),
"money": ("qore": Type::Number,),
"numeric": ("qore": Type::Number, "size": SZ_NUM,),
"oid": ("qore": Type::Int,),
"real": ("qore": Type::Float,),
"reltime": ("qore": Type::Date,),
"serial": ("qore": Type::Int,),
"smallint": ("qore": Type::Int,),
"smallserial": ("qore": Type::Int,),
"text": ("qore": Type::String,),
"time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"time with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"time without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"timetz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"timestamp without time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"timestamptz": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6), "default_size": 6,),
"varbit": ("qore": Type::Binary, "size": SZ_OPT,),
"varchar": ("qore": Type::String, "size": SZ_OPT,),
);
const PgsqlNameMap = (
"bit varying": "varbit",
"character": "char",
"character varying": "varchar",
"char varying": "varchar",
"double precision": "float",
"time with time zone": "timetz",
"time without time zone": "time",
"timestamp with time zone": "timestamptz",
"timestamp without time zone": "timestamp",
);
const QoreTypeMap = (
"integer": "bigint",
"float": "double precision",
"number": "numeric",
"string": "varchar",
"date": "timestamp",
"binary": "bytea",
"bool": "boolean",
SqlUtil::CHAR: "char",
SqlUtil::CLOB: "text",
SqlUtil::BLOB: "bytea",
);
const PgsqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
"functions": Type::Hash,
);
const PgsqlColumnDescOptions = AbstractTable::ColumnDescOptions;
const PgsqlIndexOptions = AbstractTable::IndexOptions;
const PgsqlConstraintOptions = AbstractTable::ConstraintOptions + PgsqlIndexOptions + (
"index": Type::String,
);
const PgsqlTableCreationOptions = AbstractTable::TableCreationOptions + PgsqlConstraintOptions + (
"omit_trigger_functions": Type::Boolean,
);
const PgsqlAlignTableOptions = AbstractTable::AlignTableOptions + PgsqlTableCreationOptions;
const PgsqlCopMap = (
COP_CAST: (
"code": string (string cve, list args) {
string name = QoreTypeMap{args[0]} ?? args[0];
hash desc = PgsqlTypeMap{name};
string sql = sprintf ("cast (%s as %s", cve, name);
switch (name);
sql += ")";
return sql;
},
),
COP_YEAR: (
"code": string (string arg1, auto arg) {
return sprintf("to_char(%s, 'YYYY')", arg1);
}
),
COP_YEAR_MONTH: (
"code": string (string arg1, auto arg) {
return sprintf("to_char(%s, 'YYYY-MM')", arg1);
}
),
COP_YEAR_DAY: (
"code": string (string arg1, auto arg) {
return sprintf("to_char(%s, 'YYYY-MM-DD')", arg1);
}
),
COP_YEAR_HOUR: (
"code": string (string arg1, auto arg) {
return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", arg1);
}
),
COP_SEQ: (
"nocolumn": True,
"withalias": True,
"code": string (*string cve, hash arg, reference<hash> psch) {
string sql = sprintf("nextval('%s')", arg.seq);
if (arg.as);
return sql;
}
),
COP_SEQ_CURRVAL: (
"nocolumn": True,
"withalias": True,
"code": string (*string cve, hash arg, reference<hash> psch) {
string sql = sprintf("currval('%s')", arg.seq);
if (arg.as);
return sql;
}
),
COP_TRUNC_DATE: (
"code": string sub(string arg1, auto arg) {
if (!PgsqlTruncDate.hasKey(arg));
return sprintf("date_trunc(%s, %s)", PgsqlTruncDate{arg}, arg1);
}
)
);
const PgsqlTruncDate = (
DT_YEAR : "'year'",
DT_MONTH : "'month'",
DT_DAY : "'day'",
DT_HOUR : "'hour'",
DT_MINUTE : "'minute'",
DT_SECOND : "'second'",
);
const PgsqlIopMap = DefaultIopMap + (
IOP_SEQ: (
"arg": Type::String,
"placeholder": "nextval(%v)",
),
IOP_SEQ_CURRVAL: (
"arg": Type::String,
"placeholder": "currval(%v)",
),
);
const PgsqlUopMap = DefaultUopMap + (
COP_SEQ: (
"nocolumn": True,
"code": string (*string cve, string arg) {
return sprintf("nextval('%s')", arg);
}
),
COP_SEQ_CURRVAL: (
"nocolumn": True,
"withalias": True,
"code": string (*string cve, string arg) {
return sprintf("currval('%s')", arg);
}
),
);
public:
private :
*string tablespace;
string schema;
Functions triggerFunctions;
public:
constructor(AbstractDatasource nds, string nname, *hash opts) ;
string getSchemaName();
*string getTablespaceName();
PgsqlFunction addTriggerFunction(string tfname, string src, string trigger);
bool hasArrayBind();
private:
PgsqlFunction addTriggerFunctionUnlocked(string tfname, string src, string trigger);
public:
string getSqlName();
private:
hash getTableCreationOptions();
public:
private:
hash getTableDescriptionHashOptions();
public:
private:
hash getColumnDescOptions();
public:
private:
hash getIndexOptions();
public:
private:
hash getConstraintOptions();
public:
private:
hash getAlignTableOptions();
public:
private:
hash getColumnOperatorMapImpl();
public:
private:
hash getInsertOperatorMap();
public:
private:
hash getRawUpdateOperatorMap();
public:
private:
bool checkExistenceImpl();
public:
private:
Columns describeImpl();
public:
private:
PgsqlPrimaryKey getPrimaryKeyImpl();
public:
private:
Indexes getIndexesImpl();
public:
private:
ForeignConstraints getForeignConstraintsImpl(*hash opts);
public:
private:
Constraints getConstraintsImpl();
public:
private:
Triggers getTriggersImpl();
public:
private:
string getCreateTableSqlImpl(*hash opt);
public:
private:
*list getCreateMiscSqlImpl(*hash opt, bool cache);
public:
private:
*list getAlignSqlImpl(AbstractTable table, *hash opt);
public:
private:
string getCreateSqlImpl(list l);
public:
private:
string getRenameSqlImpl(string new_name);
public:
private:
AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
public:
private:
AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
public:
private:
AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
public:
private:
AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
public:
private:
AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
public:
private:
AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
public:
private:
AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
public:
private:
bool tryInsertImpl(string sql, hash row);
public:
private:
hash getQoreTypeMapImpl();
public:
private:
hash getTypeMapImpl();
public:
private:
*string getSqlValueImpl(auto v);
public:
private:
bool emptyImpl();
public:
private:
clearImpl();
public:
private:
softlist getDropSqlImpl();
public:
private:
setupTableImpl(hash desc, *hash opt);
public:
private:
bool constraintsLinkedToIndexesImpl();
public:
private:
bool uniqueIndexCreatesConstraintImpl();
public:
private:
bool supportsTablespacesImpl();
public:
private:
doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *hash qh);
public:
private:
doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
public:
private:
auto tryExecArgsImpl(string sql, *softlist args);
public:
private:
auto tryExecRawImpl(string sql, *softlist args);
public:
private:
copyImpl(AbstractTable old);
public:
private:
*hash doReturningImpl(hash opt, reference<string> sql, list args);
public:
private:
list getGroupOrderByListUnlocked(string key, hash qh, *hash jch, *hash ch, *hash psch, list coll);
public:
};
};
SqlUtil::AbstractConstraint::name
string name
PgsqlSqlUtil::PgsqlTable::PgsqlIopMap
const PgsqlIopMap
a hash of default value operator descriptions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1113
PgsqlSqlUtil::PgsqlDatabase::computeStatisticsImpl
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
PgsqlSqlUtil::PgsqlDatabase::PgsqlReclaimSpaceOptions
const PgsqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: PgsqlSqlUtil.qm.dox.h:709
PgsqlSqlUtil::PgsqlView::viewowner
*string viewowner
Owner of the view.
Definition: PgsqlSqlUtil.qm.dox.h:589
PgsqlSqlUtil::PgsqlUniqueConstraint
class modeling a unique constraint
Definition: PgsqlSqlUtil.qm.dox.h:464
Date
const Date
PgsqlSqlUtil::PgsqlUniqueConstraint::isEnabled
bool isEnabled()
returns True if the constraint is enabled, False if not
PgsqlSqlUtil::PgsqlDatabase::rebuildIndexImpl
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
COP_SEQ
const COP_SEQ
PgsqlSqlUtil::PgsqlTable::getTablespaceName
*string getTablespaceName()
returns the data tablespace name for the table or NOTHING if none is known
Hash
const Hash
PgsqlSqlUtil::PgsqlView
represents a PostgreSQL view
Definition: PgsqlSqlUtil.qm.dox.h:583
String
const String
DefaultIopMap
const DefaultIopMap
PgsqlSqlUtil::PgsqlTable::getColumnOperatorMapImpl
hash getColumnOperatorMapImpl()
returns the column operator map for this object
PgsqlSqlUtil::PgsqlCheckConstraint
represents a PostgreSQL-specific check constraint
Definition: PgsqlSqlUtil.qm.dox.h:325
sprintf
string sprintf(string fmt,...)
PgsqlSqlUtil::PgsqlDatabase::listTypes
list listTypes()
returns a list of string type names in the database
PgsqlSqlUtil::PgsqlTable::getCreateSqlImpl
string getCreateSqlImpl(list l)
returns a string that can be used to create the table in the database
SqlUtil::AbstractTable
PgsqlSqlUtil::PgsqlTable::hasArrayBind
bool hasArrayBind()
returns False because the pgsql driver does not support array binds / bulk DML operations ...
PgsqlSqlUtil::PgsqlDatabase::supportsSequencesImpl
bool supportsSequencesImpl()
returns True if the database supports sequences
PgsqlSqlUtil::PgsqlDatabase::getSchemaDescriptionOptions
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
PgsqlSqlUtil::PgsqlDatabase
provides the PostgreSQL-specific implementation of the AbstractDatabase interface ...
Definition: PgsqlSqlUtil.qm.dox.h:696
SqlUtil::AbstractTable::cache
cache(*hash opts)
PgsqlSqlUtil::PgsqlSequence::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
PgsqlSqlUtil::PgsqlCheckConstraint::constructor
constructor(string n, string n_src)
creates the constraint from the supplied arguments
PgsqlSqlUtil::PgsqlUniqueConstraint::memberGate
PgsqlColumn memberGate(string k)
returns the PgsqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
PgsqlSqlUtil::PgsqlDatabase::listProceduresImpl
list listProceduresImpl()
since PostgreSQL only supports functions, this method is identical to listFunctionsImpl() ...
PgsqlSqlUtil::PgsqlDatabase::tryExecRaw
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 ...
PgsqlSqlUtil::PgsqlIndex::getCreateSql
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
SqlUtil::AbstractIndex
PgsqlSqlUtil::PgsqlColumn
represents a PostgreSQL-specific column
Definition: PgsqlSqlUtil.qm.dox.h:345
PgsqlSqlUtil::PgsqlTable::PgsqlNameMap
const PgsqlNameMap
maps from verbose type names to simple type names
Definition: PgsqlSqlUtil.qm.dox.h:995
PgsqlSqlUtil::PgsqlDatabase::materializedViewIterator
ListIterator materializedViewIterator()
returns an iterator listing the string materialized view names in the database
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::setTablespace
setTablespace(*string ts)
sets or clears the tablespace name
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::setIndexBase
bool setIndexBase(string ix)
sets the supporting index name
PgsqlSqlUtil::PgsqlTable::doSelectOrderByWithOffsetSqlUnlockedImpl
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...
PgsqlSqlUtil::PgsqlTrigger
represents a PostgreSQL-specific trigger
Definition: PgsqlSqlUtil.qm.dox.h:613
PgsqlSqlUtil::PgsqlFunction::getCreateSql
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
PgsqlSqlUtil::PgsqlFunction::setName
setName(string new_name)
sets the new name of the function
PgsqlSqlUtil::PgsqlType
represents a PostgreSQL type
Definition: PgsqlSqlUtil.qm.dox.h:229
PgsqlSqlUtil::PgsqlTable::uniqueIndexCreatesConstraintImpl
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
PgsqlSqlUtil::PgsqlTable::doSelectLimitOnlyUnlockedImpl
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
COP_SEQ_CURRVAL
const COP_SEQ_CURRVAL
SqlUtil::NumericColumnInfo
PgsqlSqlUtil::PgsqlTrigger::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
True
const True
PgsqlSqlUtil::PgsqlDatabase::listTablesImpl
list listTablesImpl()
returns a list of string table names in the database
PgsqlSqlUtil::PgsqlPrimaryKey::memberGate
PgsqlColumn memberGate(string k)
returns the PgsqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
SqlUtil::CHAR
const CHAR
PgsqlSqlUtil::PgsqlTriggerFunction::trigger
string trigger
trigger name
Definition: PgsqlSqlUtil.qm.dox.h:687
SqlUtil::AbstractSequence
PgsqlSqlUtil::PgsqlIndex
represents a PostgreSQL-specific index
Definition: PgsqlSqlUtil.qm.dox.h:274
PgsqlSqlUtil::PgsqlIndex::equalImpl
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
PgsqlSqlUtil::PgsqlPrimaryKey::getRenameSql
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the constraint
PgsqlSqlUtil::PgsqlTable::PgsqlTableDescriptionHashOptions
const PgsqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with &quot;functions&quot; for table functions requ...
Definition: PgsqlSqlUtil.qm.dox.h:1022
number
number number(softnumber n)
COP_YEAR_HOUR
const COP_YEAR_HOUR
PgsqlSqlUtil::PgsqlTriggerFunction
represents a PostgreSQL-specific trigger function
Definition: PgsqlSqlUtil.qm.dox.h:682
IOP_SEQ_CURRVAL
const IOP_SEQ_CURRVAL
PgsqlSqlUtil::PgsqlColumn::constructor
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs)
creates the column from the supplied arguments
PgsqlSqlUtil::PgsqlType::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the type in the database
PgsqlSqlUtil::PgsqlColumn::byte_size
int byte_size
byte size of the column
Definition: PgsqlSqlUtil.qm.dox.h:350
PgsqlSqlUtil::PgsqlView::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
PgsqlSqlUtil::PgsqlIndex::tablespace
*string tablespace
the tablespace name of the index
Definition: PgsqlSqlUtil.qm.dox.h:279
SqlUtil::AbstractForeignConstraint
PgsqlSqlUtil::PgsqlNumericColumn
represents a PostgreSQL-specific numeric column
Definition: PgsqlSqlUtil.qm.dox.h:413
SqlUtil::AbstractSqlUtilBase::l
Mutex l()
SqlUtil::AbstractCheckConstraint
list
list list(...)
PgsqlSqlUtil::PgsqlPrimaryKey::getCreateSql
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
Float
const Float
PgsqlSqlUtil::PgsqlTable::QoreTypeMap
const QoreTypeMap
maps qore type names to PostgreSQL type names
Definition: PgsqlSqlUtil.qm.dox.h:1008
SqlUtil::AbstractTable::name
string name
PgsqlSqlUtil::PgsqlColumn::getNativeTypeString
string getNativeTypeString()
returns a string giving the native type of the column
DT_DAY
const DT_DAY
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::constructor
constructor(*string ts)
creates the constraint with an optional tablespace name
PgsqlSqlUtil::PgsqlTable::getSchemaName
string getSchemaName()
returns the schema name
Boolean
const Boolean
PgsqlSqlUtil::PgsqlTable::getSqlName
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
PgsqlSqlUtil::PgsqlTable::getRawUpdateOperatorMap
hash getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
PgsqlSqlUtil::PgsqlDatabase::tryExecRawImpl
auto tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
PgsqlSqlUtil::PgsqlType::getRenameSql
string getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename a type
SZ_NUM
const SZ_NUM
PgsqlSqlUtil::PgsqlSequence::constructor
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
PgsqlSqlUtil::PgsqlType::name
string name
the name of the type
Definition: PgsqlSqlUtil.qm.dox.h:234
PgsqlSqlUtil::PgsqlTrigger::getDropSql
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
PgsqlSqlUtil::PgsqlTrigger::getCreateSql
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
Binary
const Binary
PgsqlSqlUtil::PgsqlDatabase::tryExecArgs
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 ...
PgsqlSqlUtil::PgsqlView::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
PgsqlSqlUtil::PgsqlDatabase::supportsTypesImpl
bool supportsTypesImpl()
returns True if the database supports named types
PgsqlSqlUtil::PgsqlDatabase::getCreateSql
static string getCreateSql(list l)
returns a string that can be used to create the schema in the database
PgsqlSqlUtil::PgsqlDatabase::getReclaimSpaceOptions
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
PgsqlSqlUtil::PgsqlColumn::getRenameSql
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
PgsqlSqlUtil::PgsqlFunction::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
PgsqlSqlUtil::PgsqlUniqueConstraint::enabled
bool enabled
True if the constraint is enabled, False if not
Definition: PgsqlSqlUtil.qm.dox.h:469
PgsqlSqlUtil::PgsqlTable::clearImpl
clearImpl()
clears PostgreSQL-specific table information
PgsqlSqlUtil::PgsqlTable::PgsqlTypeMap
const PgsqlTypeMap
maps PostgreSQL type names to type configurations
Definition: PgsqlSqlUtil.qm.dox.h:951
PgsqlSqlUtil::PgsqlTable::tryExecRawImpl
auto tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
PgsqlSqlUtil::PgsqlIndex::getRenameSql
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
PgsqlSqlUtil::PgsqlPrimaryKey::constructor
constructor()
creates an empty primary key object
COP_YEAR_MONTH
const COP_YEAR_MONTH
PgsqlSqlUtil::PgsqlTable::triggerFunctions
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: PgsqlSqlUtil.qm.dox.h:1151
PgsqlSqlUtil::PgsqlUniqueConstraintCommon
common base class for unique constraints
Definition: PgsqlSqlUtil.qm.dox.h:426
PgsqlSqlUtil::PgsqlDatabase::PgsqlSchemaDescriptionOptions
const PgsqlSchemaDescriptionOptions
PostgreSQL-specific schema description keys.
Definition: PgsqlSqlUtil.qm.dox.h:701
SqlUtil::BLOB
const BLOB
PgsqlSqlUtil::PgsqlTrigger::getRenameSql
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
SqlUtil::CLOB
const CLOB
PgsqlSqlUtil::PgsqlDatabase::typeIterator
ListIterator typeIterator()
returns an iterator listing the string type names in the database
PgsqlSqlUtil::PgsqlType::src
string src
the source of the type
Definition: PgsqlSqlUtil.qm.dox.h:237
PgsqlSqlUtil::PgsqlPrimaryKey
represents a PostgreSQL-specific primary key constraint
Definition: PgsqlSqlUtil.qm.dox.h:518
SqlUtil::AbstractSqlUtilBase::ds
AbstractDatasource ds
PgsqlSqlUtil::PgsqlType::constructor
constructor(string n_name, string n_src)
creates the type from the supplied arguments
SqlUtil::AbstractFunction
PgsqlSqlUtil::PgsqlDatabase::reclaimSpaceImpl
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
PgsqlSqlUtil::PgsqlTable::getCreateTableSqlImpl
string getCreateTableSqlImpl(*hash opt)
returns a string that can be used to create the table in the database
PgsqlSqlUtil::PgsqlForeignConstraint::getCreateSql
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
PgsqlSqlUtil::PgsqlDatabase::tryExecArgsImpl
auto tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::getIndexSql
getIndexSql(reference< string > sql, string name, *hash opts)
adds index options onto the sql creation string
type
string type(auto arg)
COP_TRUNC_DATE
const COP_TRUNC_DATE
SqlUtil::AbstractView
SqlUtil::AbstractSqlUtilBase::opts
*hash opts
SqlUtil::AbstractDatabase::native_case
bool native_case
PgsqlSqlUtil::PgsqlDatabase::getNextSequenceValueImpl
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
Int
const Int
COP_YEAR
const COP_YEAR
string
string string(softstring str, *string enc)
PgsqlSqlUtil::PgsqlTable::tryExecArgsImpl
auto tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
PgsqlSqlUtil::PgsqlTable::PgsqlUopMap
const PgsqlUopMap
a hash of default update operator definitions for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1125
PgsqlSqlUtil::PgsqlTable::tablespace
*string tablespace
tablespace name for the table, if known
Definition: PgsqlSqlUtil.qm.dox.h:1145
PgsqlSqlUtil::PgsqlDatabase::listMaterializedViews
list listMaterializedViews()
returns a list of string materialized view names in the database
SqlUtil::AbstractTrigger
PgsqlSqlUtil::PgsqlDatabase::getCreateSqlImpl
string getCreateSqlImpl(list l)
returns a string that can be used to create the schema in the database
PgsqlSqlUtil::PgsqlDatabase::supportsPackagesImpl
bool supportsPackagesImpl()
returns True if the database supports packages
PgsqlSqlUtil::PgsqlForeignConstraint
represents a PostgreSQL-specific foreign constraint
Definition: PgsqlSqlUtil.qm.dox.h:305
PgsqlSqlUtil::PgsqlCheckConstraint::getCreateSql
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
SqlUtil::AbstractColumn
COP_CAST
const COP_CAST
DT_MINUTE
const DT_MINUTE
DT_HOUR
const DT_HOUR
DefaultUopMap
const DefaultUopMap
COP_YEAR_DAY
const COP_YEAR_DAY
PgsqlSqlUtil::PgsqlColumn::getAddColumnSql
list getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
PgsqlSqlUtil::PgsqlFunction::getDropSql
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::getTablespace
*string getTablespace()
returns the tablespace name used for this constraint, if known
PgsqlSqlUtil::PgsqlView::constructor
constructor(string n_name, string n_src, *string n_schemaname, *string n_viewowner)
creates the object from the arguments
DT_MONTH
const DT_MONTH
PgsqlSqlUtil::PgsqlNumericColumn::constructor
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
PgsqlSqlUtil::PgsqlTable::constraintsLinkedToIndexesImpl
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
PgsqlSqlUtil::PgsqlType::getDropSql
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
PgsqlSqlUtil::PgsqlUniqueConstraint::constructor
constructor(string n, hash n_cols, bool e=True, *string ts)
creates the object with the given attributes
PgsqlSqlUtil::PgsqlTrigger::constructor
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
PgsqlSqlUtil::PgsqlIndex::constructor
constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace)
creates the object from the arguments
PgsqlSqlUtil::PgsqlDatabase::getCurrentSequenceValueImpl
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
PgsqlSqlUtil::PgsqlTable::schema
string schema
schema name for the table
Definition: PgsqlSqlUtil.qm.dox.h:1148
PgsqlSqlUtil::PgsqlUniqueConstraint::getCreateSql
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
hash
hash hash(object obj)
PgsqlSqlUtil::PgsqlColumn::equalImpl
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
PgsqlSqlUtil::PgsqlTable::PgsqlCopMap
const PgsqlCopMap
column operator specializations for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:1041
PgsqlSqlUtil::PgsqlForeignConstraint::constructor
constructor(string n, Columns c, ForeignConstraintTarget t)
creates the constraint from the supplied arguments
PgsqlSqlUtil::PgsqlTable::getInsertOperatorMap
hash getInsertOperatorMap()
returns the insert operator map for this object
PgsqlSqlUtil::PgsqlColumn::getModifySqlImpl
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...
SZ_OPT
const SZ_OPT
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::tablespace
*string tablespace
any tablespace for the unique key index
Definition: PgsqlSqlUtil.qm.dox.h:431
PgsqlSqlUtil::PgsqlFunction::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
PgsqlSqlUtil::PgsqlSequence
class for PostgreSQL sequences
Definition: PgsqlSqlUtil.qm.dox.h:562
PgsqlSqlUtil::PgsqlDatabase::listFunctionsImpl
list listFunctionsImpl()
returns a list of string function names in the database
PgsqlSqlUtil::PgsqlTable::supportsTablespacesImpl
bool supportsTablespacesImpl()
returns True if the database support tablespaces
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::keyIterator
abstract AbstractIterator keyIterator()
returns an iterator for keys iterating a list of string key names
PgsqlSqlUtil::PgsqlTable::copyImpl
copyImpl(AbstractTable old)
db-specific copy actions
IOP_SEQ
const IOP_SEQ
SqlUtil::AbstractDatabase
PgsqlSqlUtil::get_table
PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a PgsqlTable object corresponding to the arguments
PgsqlSqlUtil::PgsqlTable::PgsqlTruncDate
const PgsqlTruncDate
Map SqlUtil::cop_trunc_date() constants to PostgreSQL internal masks.
Definition: PgsqlSqlUtil.qm.dox.h:1103
DT_YEAR
const DT_YEAR
PgsqlSqlUtil::PgsqlTable
provides the PostgreSQL-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: PgsqlSqlUtil.qm.dox.h:946
PgsqlSqlUtil::PgsqlSequence::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
SqlUtil::AbstractPrimaryKey
Number
const Number
PgsqlSqlUtil::get_database
PgsqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a PgsqlDatabase object corresponding to the arguments
PgsqlSqlUtil::PgsqlFunction
represents a PostgreSQL-specific function
Definition: PgsqlSqlUtil.qm.dox.h:641
PgsqlSqlUtil::PgsqlType::equal
bool equal(PgsqlType type)
returns True if the types are equal
SqlUtil::AbstractUniqueConstraint
PgsqlSqlUtil::PgsqlTable::getSqlValueImpl
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
SqlUtil::AbstractDatabase::ReclaimSpaceOptions
const ReclaimSpaceOptions
DT_SECOND
const DT_SECOND
PgsqlSqlUtil::PgsqlUniqueConstraintCommon::clearIndex
clearIndex()
clears any index base for the constraint
PgsqlSqlUtil::PgsqlNumericColumn::getNativeTypeString
string getNativeTypeString()
returns a string giving the native type of the column