192 namespace PgsqlSqlUtil {
195 PgsqlTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
202 parse_schema_name(
string nname, reference schema, reference name);
218 constructor(
string n_name,
string n_src);
227 string getCreateSql(*
hash opt);
230 string getDropSql(*
hash opt);
233 string getRenameSql(
string new_name);
251 constructor(
string n_name,
bool n_unique,
hash n_cols, *
string n_tablespace);
259 private bool equalImpl(AbstractIndex ix);
263 string getRenameSql(
string table_name,
string new_name);
271 constructor(
string n, Columns c, ForeignConstraintTarget t);
274 string getCreateSql(
string table_name, *
hash opt);
277 softlist getRenameSql(
string table_name,
string new_name);
280 string getCreateSql(
string name,
string table_name, *
hash opt);
288 constructor(
string n,
string n_src);
291 string getCreateSql(
string table_name, *
hash opt);
294 list getRenameSql(
string table_name,
string new_name);
297 string getCreateSql(
string name,
string table_name, *
hash opt);
311 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs);
314 string getNativeTypeString();
359 private bool equalImpl(AbstractColumn c);
367 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs, softint n_scale);
370 string getNativeTypeString();
383 constructor(*
string ts);
386 bool setIndexBase(
string ix);
393 abstract AbstractIterator keyIterator();
396 getIndexSql(reference sql,
string name, *
hash opts);
409 constructor(
string n,
hash n_cols,
bool e =
True, *
string ts);
428 PgsqlColumn memberGate(
string k);
431 string getCreateSql(
string table_name, *
hash opts);
434 list getRenameSql(
string table_name,
string new_name);
437 string getCreateSql(
string name,
string table_name, *
hash opts);
448 constructor(
string n, *
hash c, *
string ts);
470 string getCreateSql(
string table_name, *
hash opts);
473 softlist getRenameSql(
string table_name,
string new_name);
506 constructor(
string n_name,
string n_src, *
string n_schemaname,
537 private bool equalImpl(AbstractFunctionBase t);
541 softlist
getRenameSql(
string table_name,
string new_name);
554 constructor(
string n,
string n_src, *
string a);
566 private bool equalImpl(AbstractFunctionBase t);
588 constructor(
string n,
string n_src,
string n_trigger);
603 const PGSQL_TempSavepoint =
"qore_pgsql_tmp_savepoint";
607 constructor(AbstractDatasource nds, *
hash opts);
610 private list featuresImpl();
622 private *AbstractSequence getSequenceImpl(
string name);
625 private *AbstractView getViewImpl(
string name);
634 private *AbstractFunction getFunctionImpl(
string name);
637 private AbstractFunction getProcedureImpl(
string name);
640 static *
string getFunctionArgs(
string err, reference src);
644 private list getDropSchemaSqlImpl(
hash schema_hash, *
hash opt);
647 private list getAlignSqlImpl(
hash schema_hash, *
hash opt);
668 private list listSequencesImpl();
671 private list listViewsImpl();
674 private string getCreateSqlImpl(
list l);
677 static string getCreateSql(
list l);
708 static any
tryExecArgs(AbstractDatasource
ds,
string sql, *softlist args);
711 static any
tryExecRaw(AbstractDatasource
ds,
string sql);
738 "timestamp without time zone": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
739 "timestamp": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
740 "timestamp with time zone": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
741 "time without time zone": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
742 "time": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
743 "time with time zone": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
744 "interval": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
759 "character varying":
"varchar",
761 "timestamp without time zone":
"timestamp",
762 "time without time zone":
"time",
768 "float":
"double precision",
784 const PgsqlColumnDescOptions = AbstractTable::ColumnDescOptions;
786 const PgsqlIndexOptions = AbstractTable::IndexOptions;
788 const PgsqlConstraintOptions = AbstractTable::ConstraintOptions + PgsqlIndexOptions + (
792 const PgsqlTableCreationOptions = AbstractTable::TableCreationOptions + PgsqlConstraintOptions + (
796 const PgsqlAlignTableOptions = AbstractTable::AlignTableOptions + PgsqlTableCreationOptions;
803 "code":
string (*
string cve, *
string arg) {
804 string sql = cve +
" over (";
806 sql +=
sprintf(
"partition by %s", arg);
812 "code":
string (
string arg1, any arg) {
813 return sprintf(
"to_char(%s, 'YYYY')", arg1);
817 "code":
string (
string arg1, any arg) {
818 return sprintf(
"to_char(%s, 'YYYY-MM')", arg1);
822 "code":
string (
string arg1, any arg) {
823 return sprintf(
"to_char(%s, 'YYYY-MM-DD')", arg1);
827 "code":
string (
string arg1, any arg) {
828 return sprintf(
"to_char(%s, 'YYYY-MM-DD HH24')", arg1);
847 constructor(AbstractDatasource nds,
string nname, *
hash opts);
858 PgsqlFunction addTriggerFunction(
string tfname,
string src,
string trigger);
861 private PgsqlFunction addTriggerFunctionUnlocked(
string tfname,
string src,
string trigger);
868 private hash getTableCreationOptions();
871 private hash getTableDescriptionHashOptions();
874 private hash getColumnDescOptions();
877 private hash getIndexOptions();
880 private hash getConstraintOptions();
883 private hash getAlignTableOptions();
890 private bool checkExistenceImpl();
893 private Columns describeImpl();
899 private Indexes getIndexesImpl();
902 private ForeignConstraints getForeignConstraintsImpl(*
hash opts);
905 private Constraints getConstraintsImpl();
908 private Triggers getTriggersImpl();
911 private string getCreateTableSqlImpl(*
hash opt);
917 private *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
920 private string getCreateSqlImpl(
list l);
923 private string getRenameSqlImpl(
string new_name);
926 private AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
929 private AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
932 private AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
935 private AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
938 private AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
941 private AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
944 private AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
947 private bool tryInsertImpl(
string sql,
hash row);
950 private hash getQoreTypeMapImpl();
953 private hash getTypeMapImpl();
960 private bool emptyImpl();
967 private softlist getDropSqlImpl();
970 private setupTableImpl(
hash desc, *
hash opt);
1002 private copyImpl(AbstractTable old);
*string viewowner
Owner of the view.
Definition: PgsqlSqlUtil.qm.dox.h:501
private bool supportsPackagesImpl()
returns True if the database supports packages
*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:495
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
represents a PostgreSQL-specific check constraint
Definition: PgsqlSqlUtil.qm.dox.h:285
string sprintf(string fmt,...)
private list listProceduresImpl()
since PostgreSQL only supports functions, this method is identical to listFunctionsImpl() ...
provides the PostgreSQL-specific implementation of the AbstractDatabase interface ...
Definition: PgsqlSqlUtil.qm.dox.h:593
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
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:302
const PgsqlNameMap
maps from verbose type names to simple type names
Definition: PgsqlSqlUtil.qm.dox.h:758
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
represents a PostgreSQL-specific trigger
Definition: PgsqlSqlUtil.qm.dox.h:521
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:206
private clearImpl()
clears PostgreSQL-specific table information
private hash getColumnOperatorMap()
returns the column operator map for this object
PgsqlColumn memberGate(string k)
returns the PgsqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
string trigger
trigger name
Definition: PgsqlSqlUtil.qm.dox.h:584
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
static any tryExecArgs(AbstractDatasource ds, string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
represents a PostgreSQL-specific index
Definition: PgsqlSqlUtil.qm.dox.h:241
const PgsqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with "functions" for table functions requ...
Definition: PgsqlSqlUtil.qm.dox.h:780
number number(softnumber n)
represents a PostgreSQL-specific trigger function
Definition: PgsqlSqlUtil.qm.dox.h:579
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
int byte_size
byte size of the column
Definition: PgsqlSqlUtil.qm.dox.h:307
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:246
represents a PostgreSQL-specific numeric column
Definition: PgsqlSqlUtil.qm.dox.h:364
const QoreTypeMap
maps qore type names to postgresql type names
Definition: PgsqlSqlUtil.qm.dox.h:766
static any tryExecRaw(AbstractDatasource ds, string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
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)
private any tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
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:211
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
private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh)
processes a string for use in SQL select statements when there is a "limit" argument, but no "orderby" or "offset" arguments
private bool supportsSequencesImpl()
returns True if the database supports sequences
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
const PgsqlTypeMap
maps postgresql type names to type configurations
Definition: PgsqlSqlUtil.qm.dox.h:720
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
private any tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: PgsqlSqlUtil.qm.dox.h:843
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
const PgsqlSchemaDescriptionOptions
PostgreSQL-specific schema description keys.
Definition: PgsqlSqlUtil.qm.dox.h:598
private bool supportsTypesImpl()
returns True if the database supports named types
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
string src
the source of the type
Definition: PgsqlSqlUtil.qm.dox.h:214
represents a PostgreSQL-specific primary key constraint
Definition: PgsqlSqlUtil.qm.dox.h:442
string string(softstring str)
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
private bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
private list listTablesImpl()
returns a list of string table names in the database
*string tablespace
tablespace name for the table, if known
Definition: PgsqlSqlUtil.qm.dox.h:837
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
represents a PostgreSQL-specific foreign constraint
Definition: PgsqlSqlUtil.qm.dox.h:268
constructor(string n_name, string n_src, *string n_schemaname, *string n_viewowner)
creates the object from the arguments
string getDropSql()
returns a string that can be used to drop the function from the database
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
constructor(string n_name, bool n_unique, hash n_cols, *string n_tablespace)
creates the object from the arguments
string schema
schema name for the table
Definition: PgsqlSqlUtil.qm.dox.h:840
const PgsqlCopMap
column operator specializations for PostgreSQL
Definition: PgsqlSqlUtil.qm.dox.h:799
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...
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument...
class for PostgreSQL sequences
Definition: PgsqlSqlUtil.qm.dox.h:478
PgsqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a PgsqlTable object corresponding to the arguments
provides the PostgreSQL-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: PgsqlSqlUtil.qm.dox.h:715
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
softlist getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
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:546
private copyImpl(AbstractTable old)
db-specific copy actions
private list listFunctionsImpl()
returns a list of string function names in the database