132 namespace MysqlSqlUtil {
135 MysqlTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
142 parse_schema_name(
string nname, reference schema, reference name);
155 constructor(
string n_name,
bool n_unique,
hash n_cols,
string n_type =
"BTREE") ;
163 private bool equalImpl(AbstractIndex ix);
167 string getRenameSql(
string table_name,
string new_name);
179 constructor(
string n, Columns c, ForeignConstraintTarget t) ;
182 string getCreateSql(
string table_name, *
hash opt);
186 softlist
getRenameSql(
string table_name,
string new_name);
189 string getCreateSql(
string name,
string table_name, *
hash opt);
192 string getAddSql(
string name,
string table_name, *
hash opt);
210 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs) ;
259 private bool equalImpl(AbstractColumn c);
275 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) ;
278 string getNativeTypeString();
282 private bool equalImpl(AbstractColumn c);
292 bool setIndexBase(
string ix);
299 abstract AbstractIterator keyIterator();
302 getIndexSql(reference sql,
string name, *
hash opts);
309 constructor(
string n,
hash n_cols) ;
328 MysqlColumn memberGate(
string k);
331 string getCreateSql(
string table_name, *
hash opts);
334 list getRenameSql(
string table_name,
string new_name);
337 string getCreateSql(
string name,
string table_name, *
hash opts);
341 string getDropSql(
string table_name);
352 constructor(*
hash c) ;
374 string getCreateSql(
string table_name, *
hash opts);
378 softlist
getRenameSql(
string table_name,
string new_name);
407 private bool equalImpl(AbstractFunctionBase t);
411 softlist
getRenameSql(
string table_name,
string new_name);
419 constructor(
string n,
string n_src) ;
431 private bool equalImpl(AbstractFunctionBase t);
449 constructor(
string n_table_name,
string n_name,
number n_start = 1,
number n_increment = 1, *softnumber n_end) ;
483 constructor(
string n_name,
string n_src, *
string n_tablecatalog,
485 *
string n_checkoption, *
string n_definer,
486 *
string n_securitytype,
bool n_updatable)
538 update %s set id = last_insert_id(id + 1) where name = seq_name;
539 return last_insert_id();
560 string sequence_table =
"sqlutil_sequences";
561 string sequence_function =
"sqlutil_nextval";
565 constructor(AbstractDatasource nds, *
hash opts) ;
568 private list featuresImpl();
571 string getSchemaName();
574 private AbstractSequence makeSequenceImpl(
string name,
number start = 1,
number increment = 1, *softnumber end, *
hash opts);
577 private *AbstractSequence getSequenceImpl(
string name);
580 private *AbstractView getViewImpl(
string name);
589 private *AbstractFunction getFunctionImpl(
string name);
594 static string makeParameter(
hash row);
598 private AbstractFunction getProcedureImpl(
string name);
601 private list getDropSchemaSqlImpl(
hash schema_hash, *
hash opt);
604 private list getAlignSqlImpl(
hash schema_hash, *
hash opt);
627 private list listSequencesImpl();
630 private list listViewsImpl();
633 private string getCreateSqlImpl(
list l);
636 static string getCreateSql(
list l);
705 "timestamp": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
706 "time": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
735 "binary":
"varbinary",
759 const MysqlIndexOptions = AbstractTable::IndexOptions;
761 const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
765 const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
767 const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
774 if (name ==
"varchar") name =
"char";
776 string sql =
sprintf (
"cast(%s as %s", cve, name);
786 "code":
string (
string cve,
string arg) {
787 return sprintf(
"concat(%s,%s)", arg, cve);
793 "code":
string (
string cve,
string arg) {
794 return sprintf(
"concat(%s,%s)", cve, arg);
798 "code":
string (
string arg1, any arg) {
799 return sprintf(
"date_format(%s, '%%Y')", arg1);
803 "code":
string (
string arg1, any arg) {
804 return sprintf(
"date_format(%s, '%%Y-%%m')", arg1);
808 "code":
string (
string arg1, any arg) {
809 return sprintf(
"date_format(%s, '%%Y-%%m-%%e')", arg1);
813 "code":
string (
string arg1, any arg) {
814 return sprintf(
"date_format(%s, '%%Y-%%m-%%e %%k')", arg1);
823 string engine =
"innodb";
827 constructor(AbstractDatasource nds,
string nname, *
hash opts) ;
834 private hash getTableCreationOptions();
837 private hash getTableDescriptionHashOptions();
840 private hash getColumnDescOptions();
843 private hash getIndexOptions();
846 private hash getConstraintOptions();
849 private hash getAlignTableOptions();
856 private bool checkExistenceImpl();
859 private Columns describeImpl();
862 private *
string getCreatePrimaryKeySqlUnlocked(*
hash opt,
bool cache =
True);
865 private MysqlPrimaryKey getPrimaryKeyImpl();
868 private Indexes getIndexesImpl();
871 private ForeignConstraints getForeignConstraintsImpl(*
hash opts);
874 private Constraints getConstraintsImpl();
877 private Triggers getTriggersImpl();
880 string getCreateTableSqlImpl(*
hash opt);
890 private *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
893 private string getCreateSqlImpl(
list l);
896 private string getRenameSqlImpl(
string new_name);
899 private AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
902 private setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
905 private addColumnToTableUnlocked(AbstractColumn c);
908 private AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
911 private AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
914 private AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
917 private AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
920 private AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
923 private AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
926 private bool tryInsertImpl(
string sql,
hash row);
929 private hash getQoreTypeMapImpl();
932 private hash getTypeMapImpl();
960 private bool emptyImpl();
963 private preSetupTableImpl(reference desc, *
hash opt);
966 private setupTableImpl(
hash desc, *
hash opt);
993 private *
hash doReturningImpl(
hash opt, reference sql,
list args);
1004 private copyImpl(AbstractTable old);
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
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:753
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:206
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:693
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
string getDropSql()
returns a string that can be used to drop the function from the database
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:176
string getDropSql()
returns a string that can be used to drop the sequence from the database
string sprintf(string fmt,...)
private bool supportsSequencesImpl()
returns True since we have a workaround implementation for sequences in MySQL
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:500
bool hasArrayBind()
returns False because the mysql driver does not support array binds / bulk DML operations ...
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
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:770
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:466
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:517
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
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:478
private bool supportsPackagesImpl()
returns True if the database supports packages
private bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
private bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
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...
softlist getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
number number(softnumber n)
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
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...
private hash getReclaimSpaceOptions()
returns driver-specific options to the base abstract class
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
private hash getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
const MysqlReclaimSpaceOptions
Options for reclaimSpace()
Definition: MysqlSqlUtil.qm.dox.h:548
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:474
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:543
private bool asteriskRequiresPrefix()
returns True if the database requires a wildcard "*" to be prefixed with the table name when it appea...
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 ...
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
const MysqlSequenceFunction
MySQL sequence function.
Definition: MysqlSqlUtil.qm.dox.h:536
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
MysqlColumn memberGate(string k)
returns the MysqlColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
const MysqlTableDescriptionHashOptions
extends SqlUtil::AbstractTable::TableDescriptionHashOptions with "engine" for the DB engine behind th...
Definition: MysqlSqlUtil.qm.dox.h:743
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:416
private copyImpl(AbstractTable old)
db-specific copy actions
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:688
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:346
const MyusqlCreationOptions
MySQL creation options.
Definition: MysqlSqlUtil.qm.dox.h:533
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
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:391
private softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
private hash getDatabaseOptions()
returns driver-specific options to the base abstract class
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
private list listFunctionsImpl()
returns a list of string function names in the database
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:476
private reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
private list listTablesImpl()
returns a list of string table names in the database
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...
static *string getSqlValueIntern(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions ...
Definition: MysqlSqlUtil.qm.dox.h:558
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)
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
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
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:440
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
private computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics() ...
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:264
private bool supportsTypesImpl()
returns True if the database supports named types
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:201
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:511
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:472
private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
private list listProceduresImpl()
returns a list of string procedure names in the database
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:146
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
private hash getColumnOperatorMap()
returns the column operator map for this object
const MysqlOptions
MySQL-specific options.
Definition: MysqlSqlUtil.qm.dox.h:505
const ComputeStatisticsOptions
static *string getSqlValue(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
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...
const MysqlDatabaseOptions
MySQL-specific database options.
Definition: MysqlSqlUtil.qm.dox.h:514
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
constructor(string n_name, bool n_unique, hash n_cols, string n_type="BTREE")
creates the object from the arguments
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
const ReclaimSpaceOptions
const QoreTypeMap
maps qore type names to postgresql type names
Definition: MysqlSqlUtil.qm.dox.h:729