142 namespace MysqlSqlUtil {
145 MysqlTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
152 parse_schema_name(
string nname, reference<*string> schema, reference<string> name);
165 constructor(
string n_name,
bool n_unique,
hash n_cols,
string n_type =
"BTREE") ;
180 string getRenameSql(
string table_name,
string new_name);
192 constructor(
string n, Columns c, ForeignConstraintTarget t) ;
195 string getCreateSql(
string table_name, *
hash opt);
199 softlist
getRenameSql(
string table_name,
string new_name);
202 string getCreateSql(
string name,
string table_name, *
hash opt);
205 string getAddSql(
string name,
string table_name, *
hash opt);
223 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs) ;
292 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) ;
295 string getNativeTypeString();
312 bool setIndexBase(
string ix);
319 abstract AbstractIterator keyIterator();
322 getIndexSql(reference<string> sql,
string name, *
hash opts);
329 constructor(
string n,
hash n_cols) ;
348 MysqlColumn memberGate(
string k);
351 string getCreateSql(
string table_name, *
hash opts);
354 list getRenameSql(
string table_name,
string new_name);
357 string getCreateSql(
string name,
string table_name, *
hash opts);
361 string getDropSql(
string table_name);
372 constructor(*
hash c) ;
394 string getCreateSql(
string table_name, *
hash opts);
398 softlist
getRenameSql(
string table_name,
string new_name);
434 softlist
getRenameSql(
string table_name,
string new_name);
442 constructor(
string n,
string n_src) ;
480 constructor(
string n_table_name,
string n_name,
number n_start = 1,
number n_increment = 1, *softnumber n_end) ;
518 constructor(
string n_name,
string n_src, *
string n_tablecatalog,
520 *
string n_checkoption, *
string n_definer,
521 *
string n_securitytype,
bool n_updatable)
576 update %s set id = last_insert_id(id + 1) where name = seq_name;
577 return last_insert_id();
623 "current_date" :
True,
624 "current_time" :
True,
625 "current_timestamp" :
True,
626 "current_user" :
True,
631 "day_microsecond" :
True,
642 "deterministic" :
True,
644 "distinctrow" :
True,
671 "high_priority" :
True,
672 "hour_microsecond" :
True,
673 "hour_minute" :
True,
674 "hour_second" :
True,
682 "insensitive" :
True,
693 "io_after_gtids" :
True,
694 "io_before_gtids" :
True,
710 "localtimestamp" :
True,
716 "low_priority" :
True,
717 "master_bind" :
True,
718 "master_ssl_verify_server_cert" :
True,
725 "minute_microsecond" :
True,
726 "minute_second" :
True,
731 "no_write_to_binlog" :
True,
768 "second_microsecond" :
True,
779 "sqlexception" :
True,
782 "sql_big_result" :
True,
783 "sql_calc_found_rows" :
True,
784 "sql_small_result" :
True,
787 "straight_join" :
True,
809 "utc_timestamp" :
True,
813 "varcharacter" :
True,
833 string sequence_table =
"sqlutil_sequences";
834 string sequence_function =
"sqlutil_nextval";
838 constructor(AbstractDatasource nds, *
hash opts) ;
847 string getSchemaName();
852 AbstractSequence makeSequenceImpl(
string name,
number start = 1,
number increment = 1, *softnumber end, *
hash opts);
858 *AbstractSequence getSequenceImpl(
string name);
864 *AbstractView getViewImpl(
string name);
882 *AbstractFunction getFunctionImpl(
string name);
888 static string makeParameter(
hash row);
894 AbstractFunction getProcedureImpl(
string name);
941 list listSequencesImpl();
947 list listViewsImpl();
953 string getCreateSqlImpl(
list l);
957 static string getCreateSql(
list l);
1062 "timestamp": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
1063 "time": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
1087 "integer":
"bigint",
1089 "number":
"decimal",
1090 "string":
"varchar",
1092 "binary":
"varbinary",
1116 const MysqlIndexOptions = AbstractTable::IndexOptions;
1118 const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
1122 const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
1124 const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
1131 if (name ==
"varchar") name =
"char";
1133 string sql =
sprintf (
"cast(%s as %s", cve, name);
1143 "code":
string (
string cve,
string arg) {
1144 return sprintf(
"concat(%s,%s)", arg, cve);
1150 "code":
string (
string cve,
string arg) {
1151 return sprintf(
"concat(%s,%s)", cve, arg);
1155 "code":
string (
string arg1,
auto arg) {
1156 return sprintf(
"date_format(%s, '%%Y')", arg1);
1160 "code":
string (
string arg1,
auto arg) {
1161 return sprintf(
"date_format(%s, '%%Y-%%m')", arg1);
1165 "code":
string (
string arg1,
auto arg) {
1166 return sprintf(
"date_format(%s, '%%Y-%%m-%%e')", arg1);
1170 "code":
string (
string arg1,
auto arg) {
1171 return sprintf(
"date_format(%s, '%%Y-%%m-%%e %%k')", arg1);
1175 "code":
string sub(
string arg1,
auto arg) {
1185 DT_YEAR :
"'%Y-01-01 00:00:00'",
1187 DT_DAY :
"'%Y-%m-%d 00:00:00'",
1188 DT_HOUR :
"'%Y-%m-%d %H:00:00'",
1197 string engine =
"innodb";
1201 constructor(AbstractDatasource nds,
string nname, *
hash opts) ;
1210 hash getTableCreationOptions();
1216 hash getTableDescriptionHashOptions();
1222 hash getColumnDescOptions();
1228 hash getIndexOptions();
1234 hash getConstraintOptions();
1240 hash getAlignTableOptions();
1253 bool checkExistenceImpl();
1259 Columns describeImpl();
1265 *
string getCreatePrimaryKeySqlUnlocked(*
hash opt,
bool cache =
True);
1277 Indexes getIndexesImpl();
1283 ForeignConstraints getForeignConstraintsImpl(*
hash opts);
1289 Constraints getConstraintsImpl();
1295 Triggers getTriggersImpl();
1299 string getCreateTableSqlImpl(*
hash opt);
1314 *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
1320 string getCreateSqlImpl(
list l);
1326 string getRenameSqlImpl(
string new_name);
1332 AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
1338 setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
1344 addColumnToTableUnlocked(AbstractColumn c);
1350 AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
1356 AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
1362 AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
1368 AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
1374 AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
1380 AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
1386 bool tryInsertImpl(
string sql,
hash row);
1392 hash getQoreTypeMapImpl();
1398 hash getTypeMapImpl();
1446 preSetupTableImpl(reference<hash> desc, *
hash opt);
1452 setupTableImpl(
hash desc, *
hash opt);
1500 *
hash doReturningImpl(
hash opt, reference<string> sql,
list args);
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
softlist getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
const MysqlColumnDescOptions
extends SqlUtil::AbstractTable::ColumnDescOptions with MySQL-specific values
Definition: MysqlSqlUtil.qm.dox.h:1110
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:219
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
const MysqlTypeMap
maps mysql type names to type configurations
Definition: MysqlSqlUtil.qm.dox.h:1050
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:189
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
string sprintf(string fmt,...)
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:538
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
bool hasArrayBind()
returns False because the mysql driver does not support array binds / bulk DML operations ...
string getDropSql(*hash opt)
returns a string that can be used to drop the sequence from the database
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a MysqlTable object corresponding to the arguments
const MysqlCopMap
column operator specializations for MySQL
Definition: MysqlSqlUtil.qm.dox.h:1127
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:502
bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in MySQL
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:555
bool hasReturningImpl()
returns True if the current database driver supports the "returning" clause in insert statements...
MysqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a MysqlDatabase object corresponding to the arguments
*string securitytype
security type value
Definition: MysqlSqlUtil.qm.dox.h:513
hash getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
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(softnumber n)
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
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...
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
hash getColumnOperatorMapImpl()
returns the column operator map for this object
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
const MysqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: MysqlSqlUtil.qm.dox.h:586
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:509
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
const MysqlComputeStatisticsOptions
Options for computeStatistics()
Definition: MysqlSqlUtil.qm.dox.h:581
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
bool supportsPackagesImpl()
returns True if the database supports packages
list listFunctionsImpl()
returns a list of string function names in the database
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
string getDropSql(string table_name)
returns a string that can be used to drop the foreign constraint from the database ...
list listProceduresImpl()
returns a list of string procedure names in the database
const MysqlSequenceFunction
MySQL sequence function.
Definition: MysqlSqlUtil.qm.dox.h:574
bool asteriskRequiresPrefix()
returns True if the database requires a wildcard "*" to be prefixed with the table name when it appea...
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
string getDropSql(*hash opt)
returns a string that can be used to drop the function from the database
MysqlColumn memberGate(string k)
returns the MysqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
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...
const MysqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with "engine" for the DB engine behind th...
Definition: MysqlSqlUtil.qm.dox.h:1100
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
represents a MySQL-specific function
Definition: MysqlSqlUtil.qm.dox.h:439
list listTablesImpl()
returns a list of string table names in the database
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
hash getDatabaseOptions()
returns driver-specific options to the base abstract class
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:1045
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:366
const MyusqlCreationOptions
MySQL creation options.
Definition: MysqlSqlUtil.qm.dox.h:571
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:411
static *string getSqlValue(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
const MysqlTruncDate
Map SqlUtil::cop_trunc_date() constants to PostgreSQL internal masks.
Definition: MysqlSqlUtil.qm.dox.h:1184
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
bool supportsTablespacesImpl()
returns True if the database support tablespaces
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the function in the database
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:511
static *string getSqlValueIntern(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
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
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions ...
Definition: MysqlSqlUtil.qm.dox.h:831
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
string string(softstring str, *string enc)
bool supportsTypesImpl()
returns True if the database supports named types
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
copyImpl(AbstractTable old)
db-specific copy actions
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
class for MySQL sequences based on a sequence table and autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:471
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:281
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:214
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:549
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:507
const MysqlReservedWords
hash of reserved words
Definition: MysqlSqlUtil.qm.dox.h:591
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:156
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
bool supportsName()
returns False since primary key constraints in MySQL have no name
const MysqlOptions
MySQL-specific options.
Definition: MysqlSqlUtil.qm.dox.h:543
const ComputeStatisticsOptions
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index 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; hwoever mysql does not support...
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
const MysqlDatabaseOptions
MySQL-specific database options.
Definition: MysqlSqlUtil.qm.dox.h:552
constructor(string n_name, bool n_unique, hash n_cols, string n_type="BTREE")
creates the object from the arguments
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
const ReclaimSpaceOptions
const QoreTypeMap
maps qore type names to postgresql type names
Definition: MysqlSqlUtil.qm.dox.h:1086