125 namespace MysqlSqlUtil {
128 MysqlTable
get_table(AbstractDatasource nds,
string nname, *
hash opts);
135 parse_schema_name(
string nname, reference schema, reference name);
148 constructor(
string n_name,
bool n_unique,
hash n_cols,
string n_type =
"BTREE");
156 private bool equalImpl(AbstractIndex ix);
160 string getRenameSql(
string table_name,
string new_name);
172 constructor(
string n, Columns c, ForeignConstraintTarget t);
175 string getCreateSql(
string table_name, *
hash opt);
179 softlist
getRenameSql(
string table_name,
string new_name);
182 string getCreateSql(
string name,
string table_name, *
hash opt);
185 string getAddSql(
string name,
string table_name, *
hash opt);
203 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string cm, softint bs);
248 private bool equalImpl(AbstractColumn c);
264 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);
267 string getNativeTypeString();
271 private bool equalImpl(AbstractColumn c);
281 bool setIndexBase(
string ix);
288 abstract AbstractIterator keyIterator();
291 getIndexSql(reference sql,
string name, *
hash opts);
298 constructor(
string n,
hash n_cols);
317 MysqlColumn memberGate(
string k);
320 string getCreateSql(
string table_name, *
hash opts);
323 list getRenameSql(
string table_name,
string new_name);
326 string getCreateSql(
string name,
string table_name, *
hash opts);
330 string getDropSql(
string table_name);
341 constructor(*
hash c);
363 string getCreateSql(
string table_name, *
hash opts);
367 softlist
getRenameSql(
string table_name,
string new_name);
396 private bool equalImpl(AbstractFunctionBase t);
400 softlist
getRenameSql(
string table_name,
string new_name);
408 constructor(
string n,
string n_src);
420 private bool equalImpl(AbstractFunctionBase t);
438 constructor(
string n_table_name,
string n_name,
number n_start = 1,
number n_increment = 1, *softnumber n_end);
472 constructor(
string n_name,
string n_src, *
string n_tablecatalog,
474 *
string n_checkoption, *
string n_definer,
475 *
string n_securitytype,
bool n_updatable)
519 update %s set id = last_insert_id(id + 1) where name = seq_name;
520 return last_insert_id();
531 string sequence_table =
"sqlutil_sequences";
532 string sequence_function =
"sqlutil_nextval";
536 constructor(AbstractDatasource nds, *
hash opts);
539 private list featuresImpl();
542 string getSchemaName();
545 private AbstractSequence makeSequenceImpl(
string name,
number start = 1,
number increment = 1, *softnumber end, *
hash opts);
548 private *AbstractSequence getSequenceImpl(
string name);
551 private *AbstractView getViewImpl(
string name);
560 private *AbstractFunction getFunctionImpl(
string name);
565 static string makeParameter(
hash row);
569 private AbstractFunction getProcedureImpl(
string name);
572 private list getDropSchemaSqlImpl(
hash schema_hash, *
hash opt);
575 private list getAlignSqlImpl(
hash schema_hash, *
hash opt);
598 private list listSequencesImpl();
601 private list listViewsImpl();
604 private string getCreateSqlImpl(
list l);
607 static string getCreateSql(
list l);
648 "timestamp": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
649 "time": (
"qore":
Type::Date,
"size":
SZ_OPT,
"size_range": (0, 6),
"default_size": 6,),
678 "binary":
"varbinary",
702 const MysqlIndexOptions = AbstractTable::IndexOptions;
704 const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
708 const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
710 const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
717 "code":
string (
string cve,
string arg) {
718 return sprintf(
"concat(%s,%s)", arg, cve);
724 "code":
string (
string cve,
string arg) {
725 return sprintf(
"concat(%s,%s)", cve, arg);
729 "code":
string (
string arg1, any arg) {
730 return sprintf(
"date_format(%s, '%%Y')", arg1);
734 "code":
string (
string arg1, any arg) {
735 return sprintf(
"date_format(%s, '%%Y-%%m')", arg1);
739 "code":
string (
string arg1, any arg) {
740 return sprintf(
"date_format(%s, '%%Y-%%m-%%e')", arg1);
744 "code":
string (
string arg1, any arg) {
745 return sprintf(
"date_format(%s, '%%Y-%%m-%%e %%k')", arg1);
754 string engine =
"innodb";
758 constructor(AbstractDatasource nds,
string nname, *
hash opts);
765 private hash getTableCreationOptions();
768 private hash getTableDescriptionHashOptions();
771 private hash getColumnDescOptions();
774 private hash getIndexOptions();
777 private hash getConstraintOptions();
780 private hash getAlignTableOptions();
787 private bool checkExistenceImpl();
790 private Columns describeImpl();
793 private *
string getCreatePrimaryKeySqlUnlocked(*
hash opt,
bool cache =
True);
796 private MysqlPrimaryKey getPrimaryKeyImpl();
799 private Indexes getIndexesImpl();
802 private ForeignConstraints getForeignConstraintsImpl(*
hash opts);
805 private Constraints getConstraintsImpl();
808 private Triggers getTriggersImpl();
811 string getCreateTableSqlImpl(*
hash opt);
817 private *
list getAlignSqlImpl(AbstractTable table, *
hash opt);
820 private string getCreateSqlImpl(
list l);
823 private string getRenameSqlImpl(
string new_name);
826 private AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable =
True);
829 private setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
832 private addColumnToTableUnlocked(AbstractColumn c);
835 private AbstractPrimaryKey addPrimaryKeyImpl(
string cname,
hash ch, *
hash opt);
838 private AbstractIndex addIndexImpl(
string iname,
bool enabled,
hash ch, *
hash opt);
841 private AbstractForeignConstraint addForeignConstraintImpl(
string cname,
hash ch,
string table,
hash tch, *
hash opt);
844 private AbstractCheckConstraint addCheckConstraintImpl(
string cname,
string src, *
hash opt);
847 private AbstractUniqueConstraint addUniqueConstraintImpl(
string cname,
hash ch, *
hash opt);
850 private AbstractTrigger addTriggerImpl(
string tname,
string src, *
hash opt);
853 private bool tryInsertImpl(
string sql,
hash row);
856 private hash getQoreTypeMapImpl();
859 private hash getTypeMapImpl();
887 private bool emptyImpl();
890 private preSetupTableImpl(reference desc, *
hash opt);
893 private setupTableImpl(
hash desc, *
hash opt);
917 private copyImpl(AbstractTable old);
softlist getCreateSql(*hash opt)
returns a string that can be used to create the function in the database
const MysqlColumnDescOptions
extends SqlUtil::AbstractTable::ColumnDescOptions with MySQL-specific values
Definition: MysqlSqlUtil.qm.dox.h:696
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:199
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:636
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:169
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:489
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:713
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:455
const MysqlSequenceTable
MySQL sequence emulation table.
Definition: MysqlSqlUtil.qm.dox.h:501
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
MysqlDatabase get_database(AbstractDatasource nds, *hash opts)
returns a MysqlDatabase object corresponding to the arguments
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument...
*string securitytype
security type value
Definition: MysqlSqlUtil.qm.dox.h:467
private bool supportsPackagesImpl()
returns True if the database supports packages
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...
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:463
softlist getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger 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 ...
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:517
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:686
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:405
private copyImpl(AbstractTable old)
db-specific copy actions
provides the MySQL-specific implementation of the AbstractTable interface
Definition: MysqlSqlUtil.qm.dox.h:631
represents a MySQL-specific primary key constraint
Definition: MysqlSqlUtil.qm.dox.h:335
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:380
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
softlist getRenameSql(string table_name, string new_name)
primary keys have no name in MySQL so this method returns an empty list
string string(softstring str)
private list listFunctionsImpl()
returns a list of string function names in the database
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:465
private list listTablesImpl()
returns a list of string table names in the database
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:529
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
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:429
private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:253
private bool supportsTypesImpl()
returns True if the database supports named types
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:194
const MysqlSchemaDescriptionOptions
MySQL-specific schema description keys.
Definition: MysqlSqlUtil.qm.dox.h:494
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:461
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:139
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
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...
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 QoreTypeMap
maps qore type names to postgresql type names
Definition: MysqlSqlUtil.qm.dox.h:672