MysqlSqlUtil.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file MysqlSqlUtil.qm Qore user module for working with MySQL SQL data
/* MysqlSqlUtil.qm Copyright 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 required 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
namespace MysqlSqlUtil {
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts);
MysqlDatabase get_database(AbstractDatasource nds, *hash opts);
parse_schema_name(string nname, reference<*string> schema, reference<string> name);
class MysqlIndex : public SqlUtil::AbstractIndex {
public:
public :
string type;
public:
constructor(string n_name, bool n_unique, hash n_cols, string n_type = "BTREE") ;
string getCreateSql(string table_name, *hash opt);
private:
bool equalImpl(AbstractIndex ix);
public:
string getRenameSql(string table_name, string new_name);
string getDropSql(string table_name);
};
class MysqlForeignConstraint : 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);
string getAddSql(string name, string table_name, *hash opt);
string getDropSql(string table_name);
};
class MysqlColumn : 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) ;
softlist getAddColumnSql(AbstractTable t);
string getCreateSql(AbstractTable t);
softlist getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
string getRenameSql(AbstractTable t, string new_name);
private:
bool equalImpl(AbstractColumn c);
public:
};
class MysqlNumericColumn : public MysqlColumn,public SqlUtil::NumericColumnInfo {
public:
public :
bool unsigned;
bool auto_increment;
// auto-incrememnt columns must be either "unique" or "primary key" in mysql
bool pk = False;
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, softint bs, softint n_scale, bool n_unsigned = False, bool n_auto_increment = False, bool n_pk = False) ;
string getNativeTypeString();
private:
bool equalImpl(AbstractColumn c);
public:
};
class MysqlUniqueConstraintCommon : public SqlUtil::AbstractUniqueConstraint {
public:
constructor();
bool setIndexBase(string ix);
clearIndex();
abstract AbstractIterator keyIterator();
getIndexSql(reference<string> sql, string name, *hash opts);
};
class MysqlUniqueConstraint : public SqlUtil::AbstractUniqueConstraint,public MysqlUniqueConstraintCommon {
public:
constructor(string n, hash n_cols) ;
MysqlColumn 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);
string getDropSql(string table_name);
};
class MysqlPrimaryKey : public SqlUtil::AbstractPrimaryKey,public MysqlUniqueConstraintCommon {
public:
constructor();
constructor(*hash c) ;
MysqlColumn memberGate(string k);
string getCreateSql(string table_name, *hash opts);
softlist getRenameSql(string table_name, string new_name);
string getDropSql(string table_name);
bool supportsName();
};
class MysqlTrigger : 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 MysqlFunction : public SqlUtil::AbstractFunction {
public:
constructor(string n, string n_src) ;
softlist getCreateSql(*hash opt);
string getDropSql(*hash opt);
private:
bool equalImpl(AbstractFunctionBase t);
public:
softlist getRenameSql(string new_name, *hash opt);
};
class MysqlSequence : public SqlUtil::AbstractSequence {
public:
private :
string table_name;
public:
constructor(string n_table_name, 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);
string getDropSql(*hash opt);
};
class MysqlView : public SqlUtil::AbstractView {
public:
public :
*string tablecatalog;
*string checkoption;
*string definer;
*string securitytype;
public:
constructor(string n_name, string n_src, *string n_tablecatalog,
*string n_schema,
*string n_checkoption, *string n_definer,
*string n_securitytype, bool n_updatable)
;
string getCreateSql(*hash opt);
softlist getRenameSql(string new_name, *hash opt);
};
class MysqlDatabase : public SqlUtil::AbstractDatabase {
public:
public :
const MysqlOptions = (
"sequence_table": Type::String,
"sequence_function": Type::String,
);
const MysqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + MysqlOptions;
const MysqlDatabaseOptions = AbstractDatabase::DatabaseOptions + MysqlOptions;
const MysqlSequenceTable = (
"columns": (
"name": (
"qore_type": SqlUtil::VARCHAR,
"size": 40,
"notnull": True,
),
"id": (
"qore_type": Type::Number,
"size": 14,
"notnull": True,
),
),
);
const MyusqlCreationOptions = AbstractDatabase::CreationOptions;
const MysqlSequenceFunction = "%s(seq_name varchar(40)) returns decimal(14)
begin
update %s set id = last_insert_id(id + 1) where name = seq_name;
return last_insert_id();
end";
const MysqlComputeStatisticsOptions = ComputeStatisticsOptions + (
"no-binlog" : Type::Boolean,
);
const MysqlReclaimSpaceOptions = ReclaimSpaceOptions + (
"no-binlog" : Type::Boolean,
);
const MysqlReservedWords = (
"accessible" : True,
"add" : True,
"all" : True,
"alter" : True,
"analyze" : True,
"and" : True,
"as" : True,
"asc" : True,
"asensitive" : True,
"before" : True,
"between" : True,
"bigint" : True,
"binary" : True,
"blob" : True,
"both" : True,
"by" : True,
"call" : True,
"cascade" : True,
"case" : True,
"change" : True,
"char" : True,
"character" : True,
"check" : True,
"collate" : True,
"column" : True,
"condition" : True,
"constraint" : True,
"continue" : True,
"convert" : True,
"create" : True,
"cross" : True,
"current_date" : True,
"current_time" : True,
"current_timestamp" : True,
"current_user" : True,
"cursor" : True,
"database" : True,
"databases" : True,
"day_hour" : True,
"day_microsecond" : True,
"day_minute" : True,
"day_second" : True,
"dec" : True,
"decimal" : True,
"declare" : True,
"default" : True,
"delayed" : True,
"delete" : True,
"desc" : True,
"describe" : True,
"deterministic" : True,
"distinct" : True,
"distinctrow" : True,
"div" : True,
"double" : True,
"drop" : True,
"dual" : True,
"each" : True,
"else" : True,
"elseif" : True,
"enclosed" : True,
"escaped" : True,
"exists" : True,
"exit" : True,
"explain" : True,
"false" : True,
"fetch" : True,
"float" : True,
"float4" : True,
"float8" : True,
"for" : True,
"force" : True,
"foreign" : True,
"from" : True,
"fulltext" : True,
"get" : True,
"grant" : True,
"group" : True,
"having" : True,
"high_priority" : True,
"hour_microsecond" : True,
"hour_minute" : True,
"hour_second" : True,
"if" : True,
"ignore" : True,
"in" : True,
"index" : True,
"infile" : True,
"inner" : True,
"inout" : True,
"insensitive" : True,
"insert" : True,
"int" : True,
"int1" : True,
"int2" : True,
"int3" : True,
"int4" : True,
"int8" : True,
"integer" : True,
"interval" : True,
"into" : True,
"io_after_gtids" : True,
"io_before_gtids" : True,
"is" : True,
"iterate" : True,
"join" : True,
"key" : True,
"keys" : True,
"kill" : True,
"leading" : True,
"leave" : True,
"left" : True,
"like" : True,
"limit" : True,
"linear" : True,
"lines" : True,
"load" : True,
"localtime" : True,
"localtimestamp" : True,
"lock" : True,
"long" : True,
"longblob" : True,
"longtext" : True,
"loop" : True,
"low_priority" : True,
"master_bind" : True,
"master_ssl_verify_server_cert" : True,
"match" : True,
"maxvalue" : True,
"mediumblob" : True,
"mediumint" : True,
"mediumtext" : True,
"middleint" : True,
"minute_microsecond" : True,
"minute_second" : True,
"mod" : True,
"modifies" : True,
"natural" : True,
"not" : True,
"no_write_to_binlog" : True,
"null" : True,
"numeric" : True,
"on" : True,
"optimize" : True,
"option" : True,
"optionally" : True,
"or" : True,
"order" : True,
"out" : True,
"outer" : True,
"outfile" : True,
"partition" : True,
"precision" : True,
"primary" : True,
"procedure" : True,
"purge" : True,
"range" : True,
"read" : True,
"reads" : True,
"read_write" : True,
"real" : True,
"references" : True,
"regexp" : True,
"release" : True,
"rename" : True,
"repeat" : True,
"replace" : True,
"require" : True,
"resignal" : True,
"restrict" : True,
"return" : True,
"revoke" : True,
"right" : True,
"rlike" : True,
"schema" : True,
"schemas" : True,
"second_microsecond" : True,
"select" : True,
"sensitive" : True,
"separator" : True,
"set" : True,
"show" : True,
"signal" : True,
"smallint" : True,
"spatial" : True,
"specific" : True,
"sql" : True,
"sqlexception" : True,
"sqlstate" : True,
"sqlwarning" : True,
"sql_big_result" : True,
"sql_calc_found_rows" : True,
"sql_small_result" : True,
"ssl" : True,
"starting" : True,
"straight_join" : True,
"table" : True,
"terminated" : True,
"then" : True,
"tinyblob" : True,
"tinyint" : True,
"tinytext" : True,
"to" : True,
"trailing" : True,
"trigger" : True,
"true" : True,
"undo" : True,
"union" : True,
"unique" : True,
"unlock" : True,
"unsigned" : True,
"update" : True,
"usage" : True,
"use" : True,
"using" : True,
"utc_date" : True,
"utc_time" : True,
"utc_timestamp" : True,
"values" : True,
"varbinary" : True,
"varchar" : True,
"varcharacter" : True,
"varying" : True,
"when" : True,
"where" : True,
"while" : True,
"with" : True,
"write" : True,
"xor" : True,
"year_month" : True,
"zerofill" : True,
);
public:
private :
string schema;
Datasource seqds;
string sequence_table = "sqlutil_sequences";
string sequence_function = "sqlutil_nextval";
public:
constructor(AbstractDatasource nds, *hash opts) ;
private:
list featuresImpl();
public:
string getSchemaName();
private:
AbstractSequence 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:
MysqlFunction makeFunctionImpl(string name, string src, *hash opts);
public:
private:
MysqlFunction makeProcedureImpl(string name, string src, *hash opts);
public:
private:
*AbstractFunction getFunctionImpl(string name);
public:
private:
static string makeParameter(hash row);
public:
private:
AbstractFunction getProcedureImpl(string name);
public:
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:
private:
string getCreateSqlImpl(list l);
public:
static string getCreateSql(list l);
private:
hash getDatabaseOptions();
public:
private:
hash getSchemaDescriptionOptions();
public:
private:
hash getComputeStatisticsOptions();
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:
};
class MysqlTable : public SqlUtil::AbstractTable {
public:
public :
const MysqlTypeMap = (
"decimal": ("qore": Type::Number, "size": SZ_NUM,),
"tinyint": ("qore": Type::Int, "ai": True,),
"smallint": ("qore": Type::Int, "ai": True,),
"mediumint": ("qore": Type::Int, "ai": True,),
"int": ("qore": Type::Int, "ai": True,),
"bigint": ("qore": Type::Int, "ai": True,),
"float": ("qore": Type::Float, "ai": True,),
"double": ("qore": Type::Float, "ai": True,),
"date": ("qore": Type::Date,),
"datetime": ("qore": Type::Date,),
"timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6),"default_size": 6,),
"time": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 6),"default_size": 6,),
"year": ("qore": Type::Int,),
"char": ("qore": Type::String, "size": SZ_OPT, "size_range": (0, 255)),
"varchar": ("qore": Type::String, "size": SZ_MAND, "size_range": (0, 65535)),
"binary": ("qore": Type::Binary, "size": SZ_OPT, "size_range": (0, 255)),
"varbinary": ("qore": Type::Binary, "size": SZ_MAND, "size_range": (0, 65535)),
"tinytext": ("qore": Type::String,),
"text": ("qore": Type::String,),
"mediumtext": ("qore": Type::String,),
"longtext": ("qore": Type::String,),
"tinyblob": ("qore": Type::Binary,),
"blob": ("qore": Type::Binary,),
"mediumblob": ("qore": Type::Binary,),
"longblob": ("qore": Type::Binary,),
"bit": ("qore": Type::Int,),
);
const QoreTypeMap = (
"integer": "bigint",
"float": "double",
"number": "decimal",
"string": "varchar",
"date": "datetime",
"binary": "varbinary",
"bool": "tinyint",
SqlUtil::CHAR: "char",
SqlUtil::CLOB: "mediumtext",
SqlUtil::BLOB: "mediumblob",
);
const MysqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
"engine": Type::String,
);
const MysqlColumnDescOptions = AbstractTable::ColumnDescOptions + (
"unsigned": Type::Boolean,
"auto_increment": Type::Boolean,
"pk": Type::Boolean,
);
const MysqlIndexOptions = AbstractTable::IndexOptions;
const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
"index": Type::String,
);
const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
const MysqlCopMap = (
COP_CAST: (
"code": string (string cve, list args) {
string name = QoreTypeMap{args[0]} ?? args[0];
if (name == "varchar") name = "char"; // NOTE: due to current MariaSQL issue ("ERROR 1064 (42000)")
hash desc = MysqlTypeMap{name};
string sql = sprintf ("cast(%s as %s", cve, name);
switch (name);
sql += ")";
return sql;
},
),
COP_PREPEND: (
"arg": Type::String,
"sqlvalue": True,
"code": string (string cve, string arg) {
return sprintf("concat(%s,%s)", arg, cve);
},
),
COP_APPEND: (
"arg": Type::String,
"sqlvalue": True,
"code": string (string cve, string arg) {
return sprintf("concat(%s,%s)", cve, arg);
},
),
COP_YEAR: (
"code": string (string arg1, auto arg) {
return sprintf("date_format(%s, '%%Y')", arg1);
}
),
COP_YEAR_MONTH: (
"code": string (string arg1, auto arg) {
return sprintf("date_format(%s, '%%Y-%%m')", arg1);
}
),
COP_YEAR_DAY: (
"code": string (string arg1, auto arg) {
return sprintf("date_format(%s, '%%Y-%%m-%%e')", arg1);
}
),
COP_YEAR_HOUR: (
"code": string (string arg1, auto arg) {
return sprintf("date_format(%s, '%%Y-%%m-%%e %%k')", arg1);
}
),
COP_TRUNC_DATE: (
"code": string sub(string arg1, auto arg) {
if (!MysqlTruncDate.hasKey(arg));
return sprintf("cast(date_format(%s, %s) as datetime)", arg1, MysqlTruncDate{arg});
}
)
);
const MysqlTruncDate = (
DT_YEAR : "'%Y-01-01 00:00:00'",
DT_MONTH : "'%Y-%m-01 00:00:00'",
DT_DAY : "'%Y-%m-%d 00:00:00'",
DT_HOUR : "'%Y-%m-%d %H:00:00'",
DT_MINUTE : "'%Y-%m-%d %H:%i:00'",
DT_SECOND : "'%Y-%m-%d %H:%i:%s'",
);
public:
private :
string schema;
string engine = "innodb";
public:
constructor(AbstractDatasource nds, string nname, *hash opts) ;
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:
bool checkExistenceImpl();
public:
private:
Columns describeImpl();
public:
private:
*string getCreatePrimaryKeySqlUnlocked(*hash opt, bool cache = True);
public:
private:
MysqlPrimaryKey getPrimaryKeyImpl();
public:
private:
Indexes getIndexesImpl();
public:
private:
ForeignConstraints getForeignConstraintsImpl(*hash opts);
public:
private:
Constraints getConstraintsImpl();
public:
private:
Triggers getTriggersImpl();
public:
string getCreateTableSqlImpl(*hash opt);
bool hasArrayBind();
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:
setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
public:
private:
addColumnToTableUnlocked(AbstractColumn c);
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:
static *string getSqlValueIntern(auto v);
public:
string getColumnSqlName(string col);
list getColumnSqlNames(softlist cols);
static *string getSqlValue(auto v);
private:
bool emptyImpl();
public:
private:
preSetupTableImpl(reference<hash> desc, *hash opt);
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:
bool asteriskRequiresPrefix();
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:
bool hasReturningImpl();
private:
copyImpl(AbstractTable old);
public:
};
};
SqlUtil::AbstractConstraint::name
string name
MysqlSqlUtil::MysqlFunction::getCreateSql
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
MysqlSqlUtil::MysqlDatabase::getSchemaDescriptionOptions
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
MysqlSqlUtil::MysqlColumn::getAddColumnSql
softlist getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
MysqlSqlUtil::MysqlTable::MysqlColumnDescOptions
const MysqlColumnDescOptions
extends SqlUtil::AbstractTable::ColumnDescOptions with MySQL-specific values
Definition: MysqlSqlUtil.qm.dox.h:1110
Date
const Date
MysqlSqlUtil::MysqlColumn::byte_size
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:219
MysqlSqlUtil::MysqlColumn::getRenameSql
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
MysqlSqlUtil::MysqlTable::MysqlTypeMap
const MysqlTypeMap
maps mysql type names to type configurations
Definition: MysqlSqlUtil.qm.dox.h:1050
MysqlSqlUtil::MysqlView::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
String
const String
MysqlSqlUtil::MysqlForeignConstraint
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:189
MysqlSqlUtil::MysqlTrigger::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
sprintf
string sprintf(string fmt,...)
SqlUtil::AbstractTable
SqlUtil::VARCHAR
const VARCHAR
MysqlSqlUtil
the MysqlSqlUtil namespace contains all the objects in the MysqlSqlUtil module
Definition: MysqlSqlUtil.qm.dox.h:143
MysqlSqlUtil::MysqlDatabase
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:538
SqlUtil::AbstractTable::cache
cache(*hash opts)
MysqlSqlUtil::MysqlIndex::equalImpl
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
MysqlSqlUtil::MysqlTable::hasArrayBind
bool hasArrayBind()
returns False because the mysql driver does not support array binds / bulk DML operations ...
SqlUtil::AbstractIndex
MysqlSqlUtil::MysqlSequence::getDropSql
string getDropSql(*hash opt)
returns a string that can be used to drop the sequence from the database
MysqlSqlUtil::get_table
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a MysqlTable object corresponding to the arguments
MysqlSqlUtil::MysqlTable::MysqlCopMap
const MysqlCopMap
column operator specializations for MySQL
Definition: MysqlSqlUtil.qm.dox.h:1127
MysqlSqlUtil::MysqlView
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:502
MysqlSqlUtil::MysqlDatabase::supportsSequencesImpl
bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in MySQL
MysqlSqlUtil::MysqlDatabase::MysqlSequenceTable
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:555
MysqlSqlUtil::MysqlTable::hasReturningImpl
bool hasReturningImpl()
returns True if the current database driver supports the "returning" clause in insert statements...
MysqlSqlUtil::get_database
MysqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a MysqlDatabase object corresponding to the arguments
MysqlSqlUtil::MysqlView::securitytype
*string securitytype
security type value
Definition: MysqlSqlUtil.qm.dox.h:513
MysqlSqlUtil::MysqlDatabase::getComputeStatisticsOptions
hash getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
SqlUtil::NumericColumnInfo
True
const True
SZ_MAND
const SZ_MAND
SqlUtil::CHAR
const CHAR
SqlUtil::AbstractSequence
MysqlSqlUtil::MysqlColumn::getModifySqlImpl
softlist 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...
number
number number(softnumber n)
MysqlSqlUtil::MysqlDatabase::reclaimSpaceImpl
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
COP_YEAR_HOUR
const COP_YEAR_HOUR
MysqlSqlUtil::MysqlDatabase::getReclaimSpaceOptions
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
MysqlSqlUtil::MysqlForeignConstraint::getRenameSql
softlist getRenameSql(string table_name, string new_name)
returns a string that drops the constraint and re-adds it, since MySQL does not support renaming cons...
MysqlSqlUtil::MysqlFunction::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
MysqlSqlUtil::MysqlTable::getColumnOperatorMapImpl
hash getColumnOperatorMapImpl()
returns the column operator map for this object
MysqlSqlUtil::MysqlDatabase::computeStatisticsImpl
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
MysqlSqlUtil::MysqlColumn::getCreateSql
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
MysqlSqlUtil::MysqlDatabase::MysqlReclaimSpaceOptions
const MysqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: MysqlSqlUtil.qm.dox.h:586
SqlUtil::AbstractForeignConstraint
False
const False
SqlUtil::AbstractSqlUtilBase::l
Mutex l()
MysqlSqlUtil::MysqlView::checkoption
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:509
MysqlSqlUtil::MysqlTrigger::getCreateSql
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
MysqlSqlUtil::MysqlDatabase::MysqlComputeStatisticsOptions
const MysqlComputeStatisticsOptions
Options for computeStatistics()
Definition: MysqlSqlUtil.qm.dox.h:581
list
list list(...)
Float
const Float
MysqlSqlUtil::MysqlTable::getSqlValueImpl
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
SqlUtil::AbstractTable::name
string name
MysqlSqlUtil::MysqlDatabase::supportsPackagesImpl
bool supportsPackagesImpl()
returns True if the database supports packages
MysqlSqlUtil::MysqlDatabase::listFunctionsImpl
list listFunctionsImpl()
returns a list of string function names in the database
MysqlSqlUtil::MysqlTrigger::getDropSql
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
DT_DAY
const DT_DAY
MysqlSqlUtil::MysqlForeignConstraint::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the foreign constraint from the database ...
MysqlSqlUtil::MysqlDatabase::listProceduresImpl
list listProceduresImpl()
returns a list of string procedure names in the database
Boolean
const Boolean
SZ_NUM
const SZ_NUM
MysqlSqlUtil::MysqlDatabase::MysqlSequenceFunction
const MysqlSequenceFunction
MySQL sequence function.
Definition: MysqlSqlUtil.qm.dox.h:574
MysqlSqlUtil::MysqlTable::asteriskRequiresPrefix
bool asteriskRequiresPrefix()
returns True if the database requires a wildcard "*" to be prefixed with the table name when it appea...
MysqlSqlUtil::MysqlIndex::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
Binary
const Binary
MysqlSqlUtil::MysqlFunction::getDropSql
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
MysqlSqlUtil::MysqlPrimaryKey::memberGate
MysqlColumn memberGate(string k)
returns the MysqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
MysqlSqlUtil::MysqlTable::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 "order by" and "offset" argument...
MysqlSqlUtil::MysqlTable::MysqlTableDescriptionHashOptions
const MysqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with "engine" for the DB engine behind th...
Definition: MysqlSqlUtil.qm.dox.h:1100
MysqlSqlUtil::MysqlSequence::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
MysqlSqlUtil::MysqlFunction
represents a MySQL-specific function
Definition: MysqlSqlUtil.qm.dox.h:439
MysqlSqlUtil::MysqlDatabase::listTablesImpl
list listTablesImpl()
returns a list of string table names in the database
MysqlSqlUtil::MysqlColumn::equalImpl
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
MysqlSqlUtil::MysqlTable::uniqueIndexCreatesConstraintImpl
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
MysqlSqlUtil::MysqlDatabase::getDatabaseOptions
hash getDatabaseOptions()
returns driver-specific options to the base abstract class
MysqlSqlUtil::MysqlTable
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:1045
MysqlSqlUtil::MysqlPrimaryKey
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:366
COP_YEAR_MONTH
const COP_YEAR_MONTH
MysqlSqlUtil::MysqlDatabase::MyusqlCreationOptions
const MyusqlCreationOptions
MySQL creation options.
Definition: MysqlSqlUtil.qm.dox.h:571
MysqlSqlUtil::MysqlTrigger
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:411
SqlUtil::BLOB
const BLOB
MysqlSqlUtil::MysqlTable::getSqlValue
static *string getSqlValue(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
SqlUtil::CLOB
const CLOB
MysqlSqlUtil::MysqlTable::MysqlTruncDate
const MysqlTruncDate
Map SqlUtil::cop_trunc_date() constants to PostgreSQL internal masks.
Definition: MysqlSqlUtil.qm.dox.h:1184
MysqlSqlUtil::MysqlTable::getSqlName
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
MysqlSqlUtil::MysqlTable::supportsTablespacesImpl
bool supportsTablespacesImpl()
returns True if the database support tablespaces
MysqlSqlUtil::MysqlFunction::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
MysqlSqlUtil::MysqlPrimaryKey::getRenameSql
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
MysqlSqlUtil::MysqlView::definer
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:511
SqlUtil::AbstractFunction
COP_PREPEND
const COP_PREPEND
COP_TRUNC_DATE
const COP_TRUNC_DATE
SqlUtil::AbstractView
SqlUtil::AbstractSqlUtilBase::opts
*hash opts
MysqlSqlUtil::MysqlTable::getSqlValueIntern
static *string getSqlValueIntern(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
MysqlSqlUtil::MysqlNumericColumn::equalImpl
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
MysqlSqlUtil::MysqlDatabase::rebuildIndexImpl
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
MysqlSqlUtil::MysqlTable::doSelectLimitOnlyUnlockedImpl
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
MysqlSqlUtil::MysqlDatabase::seqds
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions ...
Definition: MysqlSqlUtil.qm.dox.h:831
Int
const Int
MysqlSqlUtil::MysqlSequence::constructor
constructor(string n_table_name, string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
COP_YEAR
const COP_YEAR
string
string string(softstring str, *string enc)
MysqlSqlUtil::MysqlDatabase::supportsTypesImpl
bool supportsTypesImpl()
returns True if the database supports named types
MysqlSqlUtil::MysqlView::constructor
constructor(string n_name, string n_src, *string n_tablecatalog, *string n_schema, *string n_checkoption, *string n_definer, *string n_securitytype, bool n_updatable)
creates the object from the arguments
SqlUtil::AbstractTrigger
MysqlSqlUtil::MysqlTable::copyImpl
copyImpl(AbstractTable old)
db-specific copy actions
SqlUtil::AbstractColumn
MysqlSqlUtil::MysqlTrigger::constructor
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
MysqlSqlUtil::MysqlSequence
class for MySQL sequences based on a sequence table and autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:471
COP_CAST
const COP_CAST
DT_MINUTE
const DT_MINUTE
DT_HOUR
const DT_HOUR
MysqlSqlUtil::MysqlSequence::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
MysqlSqlUtil::MysqlDatabase::getNextSequenceValueImpl
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
MysqlSqlUtil::MysqlNumericColumn
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:281
MysqlSqlUtil::MysqlColumn
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:214
COP_YEAR_DAY
const COP_YEAR_DAY
MysqlSqlUtil::MysqlDatabase::MysqlSchemaDescriptionOptions
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:549
MysqlSqlUtil::MysqlView::tablecatalog
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:507
DT_MONTH
const DT_MONTH
MysqlSqlUtil::MysqlDatabase::MysqlReservedWords
const MysqlReservedWords
hash of reserved words
Definition: MysqlSqlUtil.qm.dox.h:591
MysqlSqlUtil::MysqlView::getRenameSql
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
MysqlSqlUtil::MysqlPrimaryKey::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
MysqlSqlUtil::MysqlIndex
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:156
MysqlSqlUtil::MysqlTrigger::getRenameSql
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
MysqlSqlUtil::MysqlPrimaryKey::supportsName
bool supportsName()
returns False since primary key constraints in MySQL have no name
hash
hash hash(object obj)
MysqlSqlUtil::MysqlDatabase::MysqlOptions
const MysqlOptions
MySQL-specific options.
Definition: MysqlSqlUtil.qm.dox.h:543
SqlUtil::AbstractDatabase::ComputeStatisticsOptions
const ComputeStatisticsOptions
SZ_OPT
const SZ_OPT
MysqlSqlUtil::MysqlIndex::getCreateSql
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
MysqlSqlUtil::MysqlIndex::getRenameSql
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database; hwoever mysql does not support...
SqlUtil::AbstractDatabase
MysqlSqlUtil::MysqlTable::constraintsLinkedToIndexesImpl
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
DT_YEAR
const DT_YEAR
MysqlSqlUtil::MysqlDatabase::MysqlDatabaseOptions
const MysqlDatabaseOptions
MySQL-specific database options.
Definition: MysqlSqlUtil.qm.dox.h:552
SqlUtil::AbstractPrimaryKey
Number
const Number
MysqlSqlUtil::MysqlIndex::constructor
constructor(string n_name, bool n_unique, hash n_cols, string n_type="BTREE")
creates the object from the arguments
MysqlSqlUtil::MysqlDatabase::getCurrentSequenceValueImpl
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
MysqlSqlUtil::MysqlTable::getColumnSqlName
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
MysqlSqlUtil::MysqlTable::getColumnSqlNames
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
SqlUtil::AbstractUniqueConstraint
SqlUtil::AbstractDatabase::ReclaimSpaceOptions
const ReclaimSpaceOptions
DT_SECOND
const DT_SECOND
MysqlSqlUtil::MysqlTable::QoreTypeMap
const QoreTypeMap
maps qore type names to postgresql type names
Definition: MysqlSqlUtil.qm.dox.h:1086
COP_APPEND
const COP_APPEND