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) ;
186 softlist
getRenameSql(
string table_name,
string new_name);
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) ;
221 softlist getAddColumnSql(AbstractTable t);
241 softlist getModifySqlImpl(AbstractTable t, AbstractColumn col, *
hash opt);
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);
378 softlist
getRenameSql(
string table_name,
string new_name);
407 private bool equalImpl(AbstractFunctionBase t);
411 softlist
getRenameSql(
string table_name,
string new_name);
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)
505 const MysqlOptions = (
511 const MysqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + MysqlOptions;
514 const MysqlDatabaseOptions = AbstractDatabase::DatabaseOptions + MysqlOptions;
517 const MysqlSequenceTable = (
533 const MyusqlCreationOptions = AbstractDatabase::CreationOptions;
536 const MysqlSequenceFunction =
"%s(seq_name varchar(40)) returns decimal(14) 538 update %s set id = last_insert_id(id + 1) where name = seq_name; 539 return last_insert_id(); 543 const MysqlComputeStatisticsOptions = ComputeStatisticsOptions + (
548 const MysqlReclaimSpaceOptions = ReclaimSpaceOptions + (
560 string sequence_table =
"sqlutil_sequences";
561 string sequence_function =
"sqlutil_nextval";
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);
608 private list listTablesImpl();
616 private list listFunctionsImpl();
624 private list listProceduresImpl();
627 private list listSequencesImpl();
630 private list listViewsImpl();
633 private string getCreateSqlImpl(
list l);
639 private hash getDatabaseOptions();
643 private hash getSchemaDescriptionOptions();
647 private hash getComputeStatisticsOptions();
651 private hash getReclaimSpaceOptions();
655 private softint getNextSequenceValueImpl(
string name);
659 private softint getCurrentSequenceValueImpl(
string name);
663 private bool supportsSequencesImpl();
667 private bool supportsTypesImpl();
671 private bool supportsPackagesImpl();
675 private bool rebuildIndexImpl(
string name, *
hash options);
679 private computeStatisticsImpl(*
hash options);
683 private reclaimSpaceImpl(*
hash options);
693 const MysqlTypeMap = (
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,),
729 const QoreTypeMap = (
735 "binary":
"varbinary",
743 const MysqlTableDescriptionHashOptions = AbstractTable::TableDescriptionHashOptions + (
753 const MysqlColumnDescOptions = AbstractTable::ColumnDescOptions + (
759 const MysqlIndexOptions = AbstractTable::IndexOptions;
761 const MysqlConstraintOptions = AbstractTable::ConstraintOptions + MysqlIndexOptions + (
765 const MysqlTableCreationOptions = AbstractTable::TableCreationOptions + MysqlConstraintOptions;
767 const MysqlAlignTableOptions = AbstractTable::AlignTableOptions + MysqlTableCreationOptions;
773 string name = QoreTypeMap{args[0]} ?? args[0];
774 if (name ==
"varchar") name =
"char";
775 hash desc = MysqlTypeMap{name};
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";
834 private hash getTableCreationOptions();
837 private hash getTableDescriptionHashOptions();
840 private hash getColumnDescOptions();
843 private hash getIndexOptions();
846 private hash getConstraintOptions();
849 private hash getAlignTableOptions();
853 private hash getColumnOperatorMap();
856 private bool checkExistenceImpl();
859 private Columns describeImpl();
862 private *
string getCreatePrimaryKeySqlUnlocked(*
hash opt,
bool cache =
True);
868 private Indexes getIndexesImpl();
871 private ForeignConstraints getForeignConstraintsImpl(*
hash opts);
874 private Constraints getConstraintsImpl();
877 private Triggers getTriggersImpl();
880 string getCreateTableSqlImpl(*
hash opt);
887 private *
list getCreateMiscSqlImpl(*
hash opt,
bool cache);
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();
936 private *
string getSqlValueImpl(any v);
942 static *
string getSqlValueIntern(any v);
958 static *
string getSqlValue(any v);
960 private bool emptyImpl();
963 private preSetupTableImpl(reference desc, *
hash opt);
966 private setupTableImpl(
hash desc, *
hash opt);
970 private bool constraintsLinkedToIndexesImpl();
974 private bool uniqueIndexCreatesConstraintImpl();
978 private bool supportsTablespacesImpl();
982 private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *
hash qh);
986 private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *
hash qh, *
hash jch, *
hash ch, *
hash psch,
list coll);
990 private bool asteriskRequiresPrefix();
993 private *
hash doReturningImpl(
hash opt, reference sql,
list args);
1000 bool hasReturningImpl();
1004 private copyImpl(AbstractTable old);
int byte_size
byte size of the column
Definition: MysqlSqlUtil.qm.dox.h:206
represents a MySQL-specific foreign constraint
Definition: MysqlSqlUtil.qm.dox.h:176
string sprintf(string fmt,...)
the MysqlSqlUtil namespace contains all the objects in the MysqlSqlUtil module
Definition: MysqlSqlUtil.qm.dox.h:133
provides the MySQL-specific implementation of the AbstractDatabase interface
Definition: MysqlSqlUtil.qm.dox.h:500
MysqlTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns a MysqlTable object corresponding to the arguments
represents a MySQL view
Definition: MysqlSqlUtil.qm.dox.h:466
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 equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
number number(softnumber n)
*string checkoption
checkoption clause
Definition: MysqlSqlUtil.qm.dox.h:474
string getDropSql(string table_name)
returns a string that can be used to drop the index from the table
represents a MySQL-specific function
Definition: MysqlSqlUtil.qm.dox.h:416
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
represents a MySQL-specific trigger
Definition: MysqlSqlUtil.qm.dox.h:391
*string definer
dafiner clause
Definition: MysqlSqlUtil.qm.dox.h:476
Datasource seqds
separate datasource dedicated for extern sequence implementation with autonomous transactions ...
Definition: MysqlSqlUtil.qm.dox.h:558
string string(softstring str, *string enc)
class for MySQL sequences based on a sequence table and autonomous transactions
Definition: MysqlSqlUtil.qm.dox.h:440
represents a MySQL-specific numeric column
Definition: MysqlSqlUtil.qm.dox.h:264
represents a MySQL-specific column
Definition: MysqlSqlUtil.qm.dox.h:201
*string tablecatalog
table catalog value
Definition: MysqlSqlUtil.qm.dox.h:472
represents a MySQL-specific index
Definition: MysqlSqlUtil.qm.dox.h:146
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...
constructor(string n_name, bool n_unique, hash n_cols, string n_type="BTREE")
creates the object from the arguments