147 namespace FreetdsSqlUtil {
150 FreetdsTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
157 parse_schema_name(
string nname, reference schema, reference name);
171 constructor(
string n_name,
bool n_unique,
hash n_cols, *
string n_filegroup) ;
179 private bool equalImpl(AbstractIndex ix);
183 string getRenameSql(
string table_name,
string new_name);
192 constructor(
string n, Columns c, ForeignConstraintTarget t) ;
199 softlist getRenameSql(
string table_name,
string new_name);
219 list getRenameSql(
string table_name,
string new_name);
238 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs) ;
287 private bool equalImpl(AbstractColumn c);
296 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs, softint n_scale) ;
384 list getRenameSql(
string table_name,
string new_name);
436 softlist
getRenameSql(
string table_name,
string new_name);
462 constructor(
string n_name,
string n_src, *
string n_schemaname) ;
491 private bool equalImpl(AbstractFunctionBase t);
495 softlist
getRenameSql(
string table_name,
string new_name);
508 constructor(
string n,
string n_src, *
string a) ;
520 private bool equalImpl(AbstractFunctionBase t);
543 const FreeTDS_TempSavepoint =
"qore_freetds_tmp_savepoint";
550 constructor(AbstractDatasource nds, *
hash opts) ;
553 private list featuresImpl();
559 private *AbstractSequence getSequenceImpl(
string name);
562 private *AbstractView getViewImpl(
string name);
571 private *AbstractFunction getFunctionImpl(
string name);
574 private AbstractFunction getProcedureImpl(
string name);
577 private list getDropSchemaSqlImpl(
hash schema_hash, *
hash opt);
580 private list getAlignSqlImpl(
hash schema_hash, *
hash opt);
601 private list listSequencesImpl();
604 private list listViewsImpl();
666 static any
tryExecArgs(AbstractDatasource
ds,
string sql, *softlist args);
669 static any
tryExecRaw(AbstractDatasource
ds,
string sql);
737 "binary":
"varbinary",
747 const FreetdsColumnDescOptions = AbstractTable::ColumnDescOptions;
749 const FreetdsIndexOptions = AbstractTable::IndexOptions;
751 const FreetdsConstraintOptions = AbstractTable::ConstraintOptions + FreetdsIndexOptions;
753 const FreetdsTableCreationOptions = AbstractTable::TableCreationOptions + FreetdsConstraintOptions;
755 const FreetdsAlignTableOptions = AbstractTable::AlignTableOptions + FreetdsTableCreationOptions;
759 "tablehint":
"softstringlist",
764 "fastfirstrow":
True,
768 "readcommitted":
True,
770 "readuncommitted":
True,
771 "repeatableread":
True,
773 "serializable":
True,
789 return sprintf(
"substring(%s,%v,%v) = %v", cn);
800 string sql =
sprintf (
"cast (%s as %s", cve, name);
810 "code":
string (
string cve,
string arg) {
811 return sprintf(
"%s + %s", arg, cve);
817 "code":
string (
string cve,
string arg) {
818 return sprintf(
"%s + %s", cve, arg);
822 "code":
string (
string cve,
list args) {
824 return sprintf(
"substring(%s,%d,32767)", cve, args[0]);
825 return sprintf(
"substring(%s,%d,%d)", cve, args[0], args[1]);
831 "code":
string (*
string cve, *
string arg) {
832 string sql = cve +
" over (";
834 sql +=
sprintf(
"partition by %s", arg);
840 "code":
string (
string arg1, any arg) {
841 return sprintf(
"substring(convert(varchar, dt, 120), 1, 4)", arg1);
845 "code":
string (
string arg1, any arg) {
846 return sprintf(
"substring(convert(varchar, dt, 120), 1, 7)", arg1);
850 "code":
string (
string arg1, any arg) {
851 return sprintf(
"substring(convert(varchar, dt, 120), 1, 10)", arg1);
855 "code":
string (
string arg1, any arg) {
856 return sprintf(
"substring(convert(varchar, dt, 120), 1, 13)", arg1);
862 "code":
string (*
string cve,
hash arg, reference psch) {
863 string sql =
sprintf(
"next value for %s", arg.seq);
871 "code":
string (*
string cve,
hash arg) {
872 throw "SEQUENCE-ERROR",
sprintf(
"cannot select the current value of sequence %y because this database does not support this operation", arg.seq);
881 "placeholder":
"next value for %v",
890 "code":
string (*
string cve,
string arg) {
891 return sprintf(
"next value for %s", arg);
896 "code":
string (*
string cve,
string arg) {
897 throw "SEQUENCE-ERROR",
sprintf(
"cannot select the current value of sequence %y because this database does not support this operation", arg);
916 constructor(AbstractDatasource nds,
string nname, *
hash opts) ;
939 private string getFromIntern(
string from, *
hash qh);
942 private hash getTableCreationOptions();
945 private hash getTableDescriptionHashOptions();
948 private hash getColumnDescOptions();
951 private hash getIndexOptions();
954 private hash getConstraintOptions();
957 private hash getAlignTableOptions();
980 private bool checkExistenceImpl();
983 private Columns describeImpl();
986 private Columns describeSybaseImpl();
989 private Columns describeMssqlImpl();
1001 private Indexes getIndexesImpl();
1004 private Indexes getIndexesSybaseImpl();
1007 private Indexes getIndexesMssqlImpl();
1010 private ForeignConstraints getForeignConstraintsImpl(*
hash opts);
1013 private ForeignConstraints getForeignConstraintsSybaseImpl();
1016 private ForeignConstraints getForeignConstraintsMssqlImpl();
1019 private Constraints getConstraintsImpl();
1022 private Constraints getConstraintsSybaseImpl();
1025 private Constraints getConstraintsMssqlImpl();
1028 private Triggers getTriggersImpl();
1038 private *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
1045 private string getRenameSqlImpl(
string new_name);
1048 private AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
1051 private AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
1054 private AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
1057 private AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
1060 private AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
1063 private AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
1066 private AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
1069 private bool tryInsertImpl(
string sql,
hash row);
1072 private hash getQoreTypeMapImpl();
1075 private hash getTypeMapImpl();
1082 private bool emptyImpl();
1089 private setupTableImpl(
hash desc, *
hash opt);
1121 private copyImpl(AbstractTable old);
1124 private *
hash doReturningImpl(
hash opt, reference sql,
list args);
1127 private softbool tryUpdate(
string sql,
hash row, Columns cols,
list updc);
softlist getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
private bool supportsSequencesImpl()
returns True if the database supports sequences
constructor(string n, Columns c, ForeignConstraintTarget t)
creates the constraint from the supplied arguments
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 ...
constructor(string n_name, string n_src, *string n_schemaname)
creates the object from the arguments
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:678
string sprintf(string fmt,...)
private bool supportsPackagesImpl()
returns True if the database supports packages
bool ss_has_merge
"has merge" flag for SQL server
Definition: FreetdsSqlUtil.qm.dox.h:681
private bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
constructor()
creates an empty primary key object
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
private hash getColumnOperatorMap()
returns the column operator map for this object
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
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
const FreetdsOpMap
where operator specializations for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:781
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(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
represents a FreeTDS-specific numeric column
Definition: FreetdsSqlUtil.qm.dox.h:292
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
class for FreeTDS sequences
Definition: FreetdsSqlUtil.qm.dox.h:441
FreetdsColumn memberGate(string k)
returns the FreetdsColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception...
static bool isSybase(AbstractDatasource ds)
returns True if the DB is a Sybase database
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string schema
schema name for the table
Definition: FreetdsSqlUtil.qm.dox.h:909
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
string getSchemaName()
returns the schema name
represents a FreeTDS-specific column
Definition: FreetdsSqlUtil.qm.dox.h:228
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
constructor(string n, string n_src)
creates the constraint from the supplied arguments
represents a FreeTDS-specific primary key constraint
Definition: FreetdsSqlUtil.qm.dox.h:397
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
const FreetdsTypeMap
maps postgresql type names to type configurations
Definition: FreetdsSqlUtil.qm.dox.h:684
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 FreetdsTableDescriptionHashOptions
equal to SqlUtil::AbstractTable::TableDescriptionHashOptions
Definition: FreetdsSqlUtil.qm.dox.h:745
bool hasArrayBind()
returns False because the freetds driver does not support array binds / bulk DML operations ...
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
private hash getWhereOperatorMap()
returns the "where" operator map for this object
private hash getInsertOperatorMap()
returns the insert operator map for this object
bool is_sybase
sybase flag
Definition: FreetdsSqlUtil.qm.dox.h:538
common base class for unique constraints
Definition: FreetdsSqlUtil.qm.dox.h:305
number number(softnumber n)
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 ...
int byte_size
byte size of the column
Definition: FreetdsSqlUtil.qm.dox.h:233
string getNativeTypeString()
returns a string giving the native type of the column
class modeling a unique constraint
Definition: FreetdsSqlUtil.qm.dox.h:343
*string filegroup
the tablespace (filegroup) name of the index
Definition: FreetdsSqlUtil.qm.dox.h:166
constructor(*string ts)
creates the constraint with an optional filegroup name
represents a FreeTDS-specific foreign constraint
Definition: FreetdsSqlUtil.qm.dox.h:188
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
private string getCreateTableSqlImpl(*hash opt)
returns a string that can be used to create the table in the database
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function 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 ...
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
private softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
const FreetdsReclaimSpaceOptions
Options for reclaimSpace()
Definition: FreetdsSqlUtil.qm.dox.h:546
constructor(string n_name, bool n_unique, hash n_cols, *string n_filegroup)
creates the object from the arguments
private string getCreateSqlImpl(list l)
returns a string that can be used to create the table in the database
Functions triggerFunctions
contains any trigger functions supporting triggers on the table
Definition: FreetdsSqlUtil.qm.dox.h:912
setTablespace(*string ts)
sets or clears the filegroup name
private bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
const FreetdsCopMap
column operator specializations for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:795
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 ...
*string getTablespace()
returns the filegroup name used for this constraint, if known
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 ...
provides the FreeTDS-specific implementation of the AbstractDatabase interface
Definition: FreetdsSqlUtil.qm.dox.h:533
const MsSqlServerTableHints
query hints
Definition: FreetdsSqlUtil.qm.dox.h:763
clearIndex()
clears any index base for the constraint
represents a FreeTDS-specific index
Definition: FreetdsSqlUtil.qm.dox.h:161
private hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
FreetdsColumn memberGate(string k)
returns the FreetdsColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception...
private softlist listTablesImpl()
returns a list of string table names in the database
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
private bool supportsTypesImpl()
returns True if the database supports named types
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch, *hash psch, list coll)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument...
represents a FreeTDS view
Definition: FreetdsSqlUtil.qm.dox.h:458
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
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
const FreetdsSelectOptions
select options supported by FreetdsSqlUtil
Definition: FreetdsSqlUtil.qm.dox.h:758
provides the FreeTDS-specific implementation of the SqlUtil::AbstractTable interface ...
Definition: FreetdsSqlUtil.qm.dox.h:673
represents a FreeTDS-specific check constraint
Definition: FreetdsSqlUtil.qm.dox.h:208
static string getCreateSql(list l)
returns a string that can be used to create the schema in the database
private computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
private list listProceduresImpl()
since FreeTDS only supports functions, this method is identical to listFunctionsImpl() ...
code getUpsertClosure(hash row, int upsert_strategy=UpsertAuto, *hash opt)
returns a closure for performing upserts; if the underlying dataserver supports an optimized MERGE st...
bool enabled
True if the constraint is enabled, False if not
Definition: FreetdsSqlUtil.qm.dox.h:348
FreetdsDatabase get_database(AbstractDatasource nds, *hash opts)
returns a FreetdsDatabase object corresponding to the arguments
getIndexSql(reference sql, string name, *hash opts)
adds index options onto the sql creation string
constructor(string n, hash n_cols, bool e=True, *string ts)
creates the object with the given attributes
*string filegroup
any filegroup for the unique key index
Definition: FreetdsSqlUtil.qm.dox.h:310
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the constraint
const QoreTypeMap
maps qore type names to postgresql type names
Definition: FreetdsSqlUtil.qm.dox.h:731
string string(softstring str, *string enc)
string getDropSql()
returns a string that can be used to drop the function from the database
bool setIndexBase(string ix)
sets the supporting index name
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
represents a FreeTDS-specific trigger
Definition: FreetdsSqlUtil.qm.dox.h:475
string getNativeTypeString()
returns a string giving the native type of the column
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
private string getCreateSqlImpl(list l)
returns a string that can be used to create the schema in the database
const FreetdsUopMap
a hash of default update operator definitions for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:886
represents a FreeTDS-specific function
Definition: FreetdsSqlUtil.qm.dox.h:500
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
FreetdsTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a FreetdsTable object corresponding to the arguments
private any tryExecRawImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
private hash getSelectOptions()
returns the select options for this driver
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
private clearImpl()
clears FreeTDS-specific table information
string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
private list listFunctionsImpl()
returns a list of string function names in the database
setName(string new_name)
sets the new name of the function
const FreetdsSchemaDescriptionOptions
FreeTDS-specific schema description keys.
Definition: FreetdsSqlUtil.qm.dox.h:541
abstract AbstractIterator keyIterator()
returns an iterator for keys iterating a list of string key names
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
bool isEnabled()
returns True if the constraint is enabled, False if not
string join(string str,...)
private copyImpl(AbstractTable old)
db-specific copy actions
*string filegroup
filegroup name for the table, if known
Definition: FreetdsSqlUtil.qm.dox.h:906
softlist getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
private hash getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
const FreetdsIopMap
a hash of default value operator descriptions for FreeTDS
Definition: FreetdsSqlUtil.qm.dox.h:878
const ReclaimSpaceOptions
private reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
*string getTablespaceName()
returns the data filegroup name for the table or NOTHING if none is known