From 67567f5c9aab1cd6400b581fa39a9cb41dc58265 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 14 Oct 2018 12:28:46 +0200 Subject: [PATCH 01/50] - Implement the CHECK TABLE statement and accept REPAIR and ANALYZE modified: storage/connect/connect.cc modified: storage/connect/ha_connect.cc modified: storage/connect/ha_connect.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp - MDEV-17212: Test if NumResultCols is implemented by the data source modified: storage/connect/odbconn.cpp - Change error type in Optimize modified: storage/connect/ha_connect.cc - Update version date modified: storage/connect/ha_connect.cc - Fix truncating error messages on first unrecognized latin1 character modified: storage/connect/ha_connect.cc - Fix MDEV-17343 Reject multi-table UPDATE/DELETE commands that crash on some systems modified: storage/connect/ha_connect.cc modified: storage/connect/tabext.cpp - Try fix some failing tests modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/jdbc_postgresql.result modified: storage/connect/mysql-test/connect/r/mysql_exec.result modified: storage/connect/mysql-test/connect/r/odbc_postgresql.result - Typo modified: storage/connect/global.h --- storage/connect/connect.cc | 2 +- storage/connect/global.h | 4 +- storage/connect/ha_connect.cc | 96 +++++++++++++++---- storage/connect/ha_connect.h | 6 +- .../connect/mysql-test/connect/r/jdbc.result | 13 +++ .../connect/r/jdbc_postgresql.result | 8 ++ .../mysql-test/connect/r/mysql_exec.result | 6 ++ .../connect/r/odbc_postgresql.result | 18 ++-- storage/connect/odbconn.cpp | 10 +- storage/connect/tabext.cpp | 6 ++ storage/connect/tabjdbc.cpp | 9 +- storage/connect/tabmysql.cpp | 11 ++- storage/connect/tabodbc.cpp | 13 ++- 13 files changed, 151 insertions(+), 51 deletions(-) diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 39123b18c59..21bca637eab 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, try { if (!c1) { - if (mode == MODE_INSERT) +// if (mode == MODE_INSERT) or CHECK TABLE // Allocate all column blocks for that table tdbp->ColDB(g, NULL, 0); diff --git a/storage/connect/global.h b/storage/connect/global.h index 472d09408c3..36e8a311124 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -1,7 +1,7 @@ /***********************************************************************/ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* (C) Copyright MariaDB Corporation Ab */ -/* Author Olivier Bertrand 1993-2017 */ +/* Author Olivier Bertrand 1993-2018 */ /***********************************************************************/ /***********************************************************************/ @@ -192,7 +192,7 @@ typedef struct _global { /* Global structure */ PACTIVITY Activityp; char Message[MAX_STR]; ulong More; /* Used by jsonudf */ - int Createas; /* To pass info to created table */ + int Createas; /* To pass multi to ext tables */ void *Xchk; /* indexes in create/alter */ short Alchecked; /* Checked for ALTER */ short Mrr; /* True when doing mrr */ diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 8811030e751..c9d8d34bd86 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -170,9 +170,9 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.06.0007 August 06, 2018"; + char version[]= "Version 1.06.0008 October 06, 2018"; #if defined(__WIN__) - char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; + char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -3290,6 +3290,58 @@ ha_rows ha_connect::records() } // end of records +int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt) +{ + int rc = HA_ADMIN_OK; + PGLOBAL g = ((table && table->in_use) ? GetPlug(table->in_use, xp) : + (xp) ? xp->g : NULL); + DBUG_ENTER("ha_connect::check"); + + if (!g || !table || xmod != MODE_READ) + DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); + + // Do not close the table if it was opened yet (possible?) + if (IsOpened()) { + if (IsPartitioned() && CheckColumnList(g)) // map can have been changed + rc = HA_ADMIN_CORRUPT; + else if (tdbp->OpenDB(g)) // Rewind table + rc = HA_ADMIN_CORRUPT; + + } else if (xp->CheckQuery(valid_query_id)) { + tdbp = NULL; // Not valid anymore + + if (OpenTable(g, false)) + rc = HA_ADMIN_CORRUPT; + + } else // possible? + DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); + + if (rc == HA_ADMIN_OK) { + TABTYPE type = GetTypeID(GetStringOption("Type", "*")); + + if (IsFileType(type)) { + if (check_opt->flags & T_MEDIUM) { + // TO DO + do { + if ((rc = CntReadNext(g, tdbp)) == RC_FX) + break; + + } while (rc != RC_EF); + + rc = (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT; + } else if (check_opt->flags & T_EXTEND) { + // TO DO + } // endif's flags + + } // endif file type + + } else + PushWarning(g, thd, 1); + + DBUG_RETURN(rc); +} // end of check + + /** Return an error message specific to this handler. @@ -3309,7 +3361,8 @@ bool ha_connect::get_error_message(int error, String* buf) if (trace(1)) htrc("GEM(%d): %s\n", error, g->Message); - buf->append(g->Message); + buf->append(ErrConvString(g->Message, strlen(g->Message), + &my_charset_latin1).ptr()); } else buf->append("Cannot retrieve error message"); @@ -3424,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); rc = 0; } else - rc = HA_ERR_INTERNAL_ERROR; + rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired } // endif rc @@ -3440,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) rc = HA_ERR_INTERNAL_ERROR; } // end catch + if (rc) + my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0)); + return rc; } // end of optimize @@ -4501,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, // case SQLCOM_REPLACE_SELECT: // newmode= MODE_UPDATE; // To be checked // break; - case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: + case SQLCOM_DELETE_MULTI: + *cras = true; + case SQLCOM_DELETE: case SQLCOM_TRUNCATE: newmode= MODE_DELETE; break; - case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: - newmode= MODE_UPDATE; + *cras = true; + case SQLCOM_UPDATE: + newmode= MODE_UPDATE; break; case SQLCOM_SELECT: case SQLCOM_OPTIMIZE: @@ -4533,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, newmode= MODE_ANY; break; // } // endif partitioned - - default: + case SQLCOM_REPAIR: // TODO implement it + newmode = MODE_UPDATE; + break; + default: htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); strcpy(g->Message, "CONNECT Unsupported command"); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); @@ -4546,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, switch (thd_sql_command(thd)) { case SQLCOM_CREATE_TABLE: *chk= true; - *cras= true; + break; + case SQLCOM_UPDATE_MULTI: + case SQLCOM_DELETE_MULTI: + *cras= true; case SQLCOM_INSERT: case SQLCOM_LOAD: case SQLCOM_INSERT_SELECT: // case SQLCOM_REPLACE: // case SQLCOM_REPLACE_SELECT: case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: case SQLCOM_TRUNCATE: case SQLCOM_UPDATE: - case SQLCOM_UPDATE_MULTI: case SQLCOM_SELECT: case SQLCOM_OPTIMIZE: case SQLCOM_SET_OPTION: @@ -4584,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, break; // } // endif partitioned - case SQLCOM_CHECK: // TODO implement it - case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... + case SQLCOM_CHECK: // TODO implement it + case SQLCOM_ANALYZE: // TODO implement it + case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... newmode= MODE_READ; break; default: @@ -4867,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) #endif // 0 if (cras) - g->Createas= 1; // To tell created table to ignore FLAG + g->Createas= 1; // To tell external tables of a multi-table command if (trace(1)) { #if 0 @@ -7248,7 +7310,7 @@ maria_declare_plugin(connect) 0x0107, /* version number (1.05) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.06.0007", /* string version */ + "1.06.0008", /* string version */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 4c5bf5856cc..07b1c2d2e7d 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond); //PFIL CheckFilter(PGLOBAL g); /** admin commands - called from mysql_admin_table */ -virtual int check(THD* thd, HA_CHECK_OPT* check_opt) -{ - // TODO: implement it - return HA_ADMIN_OK; // Just to avoid error message with checktables -} // end of check +virtual int check(THD* thd, HA_CHECK_OPT* check_opt); /** Number of rows in table. It will only be called if diff --git a/storage/connect/mysql-test/connect/r/jdbc.result b/storage/connect/mysql-test/connect/r/jdbc.result index 12c8779f96d..0dbdf851860 100644 --- a/storage/connect/mysql-test/connect/r/jdbc.result +++ b/storage/connect/mysql-test/connect/r/jdbc.result @@ -236,24 +236,37 @@ WHEELFOR SALESMAN 10030.00 MARTIN ENGINEER 10000.00 DROP TABLE t1, connect.emp; CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1'; +SELECT * FROM t2 WHERE command='drop table tx1'; command number message drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1' +Warnings: +Warning 1105 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1' SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))'; command number message create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM t2 WHERE command in ('insert into tx1 values(1,''The number one'',456.12)',"insert into tx1(a,b) values(2,'The number two'),(3,'The number three')"); command number message insert into tx1 values(1,'The number one',456.12) 1 Affected rows insert into tx1(a,b) values(2,'The number two'),(3,'The number three') 2 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM t2 WHERE command='update tx1 set c = 3.1416 where a = 2'; command number message update tx1 set c = 3.1416 where a = 2 1 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM t2 WHERE command='select * from tx1'; command number message select * from tx1 3 Result set column number +Warnings: +Warning 1105 Result set column number SELECT * FROM t2 WHERE command='delete from tx1 where a = 2'; command number message delete from tx1 where a = 2 1 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM connect.tx1; a b c 1 The number one 456.12 diff --git a/storage/connect/mysql-test/connect/r/jdbc_postgresql.result b/storage/connect/mysql-test/connect/r/jdbc_postgresql.result index 7969672dd66..07cc3c465ea 100644 --- a/storage/connect/mysql-test/connect/r/jdbc_postgresql.result +++ b/storage/connect/mysql-test/connect/r/jdbc_postgresql.result @@ -9,12 +9,18 @@ OPTION_LIST='Execsrc=1'; SELECT * FROM t2 WHERE command='drop table employee'; command number message drop table employee 0 Execute: org.postgresql.util.PSQLException: ERREUR: la table « employee » n'existe pas +Warnings: +Warning 1105 Execute: org.postgresql.util.PSQLException: ERREUR: la table « employee » n'existe pas SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2))'; command number message create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2)) 0 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)"; command number message insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows +Warnings: +Warning 1105 Affected rows CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' OPTION_LIST='Tabtype=TABLE,Maxres=10'; @@ -63,4 +69,6 @@ DROP SERVER 'postgresql'; SELECT * FROM t2 WHERE command='drop table employee'; command number message drop table employee 0 Affected rows +Warnings: +Warning 1105 Affected rows DROP TABLE t2; diff --git a/storage/connect/mysql-test/connect/r/mysql_exec.result b/storage/connect/mysql-test/connect/r/mysql_exec.result index c0400bc82e7..cc77240503b 100644 --- a/storage/connect/mysql-test/connect/r/mysql_exec.result +++ b/storage/connect/mysql-test/connect/r/mysql_exec.result @@ -35,6 +35,8 @@ insert ignore into t1(id) values(NULL) 1 1 Affected rows Warning 0 1364 Field 'msg' doesn't have a default value update t1 set msg = 'Four' where id = 4 0 1 Affected rows select * from t1 0 2 Result set columns +Warnings: +Warning 1105 Result set columns # # Checking Using Procedure # @@ -48,9 +50,13 @@ CALL p1('insert ignore into t1(id) values(NULL)'); command warnings number message insert ignore into t1(id) values(NULL) 1 1 Affected rows Warning 0 1364 Field 'msg' doesn't have a default value +Warnings: +Warning 1105 Affected rows CALL p1('update t1 set msg = "Five" where id = 5'); command warnings number message update t1 set msg = "Five" where id = 5 0 1 Affected rows +Warnings: +Warning 1105 Affected rows DROP PROCEDURE p1; DROP TABLE t1; connection slave; diff --git a/storage/connect/mysql-test/connect/r/odbc_postgresql.result b/storage/connect/mysql-test/connect/r/odbc_postgresql.result index 3426d23e29c..dc23dbdb990 100644 --- a/storage/connect/mysql-test/connect/r/odbc_postgresql.result +++ b/storage/connect/mysql-test/connect/r/odbc_postgresql.result @@ -99,9 +99,9 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu mtr public t1 a 4 int4 10 4 0 10 0 mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All columns in the schemas "public" and "schema1" CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%'; @@ -110,16 +110,16 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu mtr public t1 a 4 int4 10 4 0 10 0 mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All tables "t1" in all schemas CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks mtr public t1 a 4 int4 10 4 0 10 0 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # Table "t1" in the schema "public" CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1'; @@ -131,14 +131,14 @@ DROP TABLE t1; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL) CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='xxx.%.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks mtr public t1 a 4 int4 10 4 0 10 0 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # # Checking tables diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index f7b1a43a95d..6687513fa6c 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap) if (!Check(rc)) ThrowDBX(rc, fnc, hstmt); - rc = SQLNumResultCols(hstmt, &ncol); - - // n because we no more ignore the first column - if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) - ThrowDBX(MSG(COL_NUM_MISM)); + // Some data source do not implement SQLNumResultCols + if (Check(SQLNumResultCols(hstmt, &ncol))) + // n because we no more ignore the first column + if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) + ThrowDBX(MSG(COL_NUM_MISM)); // Unconditional to handle STRBLK's pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL)); diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp index 139e4199ed9..f2d5eb0e69d 100644 --- a/storage/connect/tabext.cpp +++ b/storage/connect/tabext.cpp @@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void) /***********************************************************************/ bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { + if (g->Createas) { + strcpy(g->Message, + "Multiple-table UPDATE/DELETE commands are not supported"); + return true; + } // endif multi + Desc = NULL; Tabname = GetStringCatInfo(g, "Name", (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp index 275b5edaeae..adb3fc4fb51 100644 --- a/storage/connect/tabjdbc.cpp +++ b/storage/connect/tabjdbc.cpp @@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Jcp->Close(); - return true; + // Next lines commented out because of CHECK TABLE + //Jcp->Close(); + //return true; } // endif Query Rows = 1; @@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g) Fpos++; // Used for progress info Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; return RC_OK; - } else + } else { + PushWarning(g, this, 1); return RC_EF; + } // endif Cmdlist } // end of ReadDB diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 605b3822430..ceffafac02c 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Myc.Close(); - return true; + // Next lines commented out because of CHECK TABLE + //Myc.Close(); + //return true; } // endif Cmdlist return false; @@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g) ++N; return RC_OK; - } else - return RC_EF; + } else { + PushWarning(g, this, 1); + return RC_EF; + } // endif Cmdlist } // end of ReadDB diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index f7bc3934fbd..fddfb0c0420 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Ocp->Close(); - return true; - } // endif Query + // Next lines commented out because of CHECK TABLE + //Ocp->Close(); + //return true; + } // endif Cmdlist Rows = 1; return false; @@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g) Fpos++; // Used for progress info Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; return RC_OK; - } else - return RC_EF; + } else { + PushWarning(g, this, 1); + return RC_EF; + } // endif Cmdlist } // end of ReadDB From 6cecb10a2f8b6536bed78ab6d3791d8befc9d732 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 7 Nov 2018 09:25:12 +0100 Subject: [PATCH 02/50] MDEV-11167: InnoDB: Warning: using a partial-field key prefix in search, results in assertion failure or "Can't find record" error Fix ha_rnd_init() argument (we do not doing scan but use rnd_pos) --- mysql-test/r/partition_innodb.result | 26 ++++++++++++++++++++++++ mysql-test/t/partition_innodb.test | 30 ++++++++++++++++++++++++++++ sql/sql_update.cc | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index f863ec5522a..ee3525cb085 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -890,3 +890,29 @@ ERROR HY000: Table definition has changed, please retry transaction SELECT b FROM t1 WHERE b = 0; ERROR HY000: Table definition has changed, please retry transaction DROP TABLE t1; +# +# MDEV-11167: InnoDB: Warning: using a partial-field key prefix +# in search, results in assertion failure or "Can't find record" error +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (b INT, c INT, KEY(b)) ENGINE=InnoDB PARTITION BY HASH(c) PARTITIONS 2; +CREATE ALGORITHM = MERGE VIEW v AS SELECT a, b FROM t1 STRAIGHT_JOIN t2 WHERE b = 'foo' WITH CHECK OPTION; +INSERT INTO t1 VALUES (1),(2); +INSERT IGNORE INTO t2 VALUES (2,2),('three',3),(4,4); +Warnings: +Warning 1366 Incorrect integer value: 'three' for column 'b' at row 2 +UPDATE v SET a = NULL ORDER BY a, b; +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'foo' +DROP view v; +DROP TABLE t1, t2; +SET @save_isp=@@innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent= ON; +CREATE TABLE t (f1 INT, f2 INT, KEY(f2)) ENGINE=InnoDB PARTITION BY HASH (f1) PARTITIONS 2; +INSERT IGNORE INTO t VALUES (NULL,0),(NULL,0),(0,21),(4,0),(1,8),(5,66); +CREATE ALGORITHM=MERGE VIEW v AS SELECT t1.* FROM t t1 JOIN t t2 WHERE t1.f1 < t2.f2 WITH LOCAL CHECK OPTION; +UPDATE v SET f2 = NULL; +ERROR HY000: CHECK OPTION failed 'test.v' +SET GLOBAL innodb_stats_persistent= @save_isp; +DROP view v; +DROP TABLE t; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index f6faa4cb0e6..5dbe9f467fa 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -996,3 +996,33 @@ SELECT b FROM t1 WHERE b = 0; SELECT b FROM t1 WHERE b = 0; --disconnect con1 DROP TABLE t1; + +--echo # +--echo # MDEV-11167: InnoDB: Warning: using a partial-field key prefix +--echo # in search, results in assertion failure or "Can't find record" error +--echo # + +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +CREATE TABLE t2 (b INT, c INT, KEY(b)) ENGINE=InnoDB PARTITION BY HASH(c) PARTITIONS 2; +CREATE ALGORITHM = MERGE VIEW v AS SELECT a, b FROM t1 STRAIGHT_JOIN t2 WHERE b = 'foo' WITH CHECK OPTION; + +INSERT INTO t1 VALUES (1),(2); +INSERT IGNORE INTO t2 VALUES (2,2),('three',3),(4,4); +UPDATE v SET a = NULL ORDER BY a, b; + +DROP view v; +DROP TABLE t1, t2; + +SET @save_isp=@@innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent= ON; + +CREATE TABLE t (f1 INT, f2 INT, KEY(f2)) ENGINE=InnoDB PARTITION BY HASH (f1) PARTITIONS 2; +INSERT IGNORE INTO t VALUES (NULL,0),(NULL,0),(0,21),(4,0),(1,8),(5,66); +CREATE ALGORITHM=MERGE VIEW v AS SELECT t1.* FROM t t1 JOIN t t2 WHERE t1.f1 < t2.f2 WITH LOCAL CHECK OPTION; +--error ER_VIEW_CHECK_FAILED +UPDATE v SET f2 = NULL; + +SET GLOBAL innodb_stats_persistent= @save_isp; +DROP view v; +DROP TABLE t; + diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 592e8158c0d..1972cc82454 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2309,7 +2309,7 @@ int multi_update::do_updates() check_opt_it.rewind(); while(TABLE *tbl= check_opt_it++) { - if ((local_error= tbl->file->ha_rnd_init(1))) + if ((local_error= tbl->file->ha_rnd_init(0))) { err_table= tbl; goto err; From 3fbee66499624cf2340eaebcd230cbabf0dd97ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 8 Nov 2018 14:50:32 +0200 Subject: [PATCH 03/50] MDEV-17645 innodb.log_file_name_debug does not clean up after itself The test innodb.log_file_name_debug failed to ensure that the bogus redo log record that its debug injection emitted would be consumed by a redo log checkpoint before running a subsequent test, which could perform crash recovery. Add an extra shutdown to ensure that a redo log checkpoint is generated. In this way, the following will succeed: ./mtr --no-reorder innodb.log_file_name_debug innodb.read_only_recovery --- mysql-test/suite/innodb/t/innodb-index.test | 5 +++++ mysql-test/suite/innodb/t/log_file_name_debug.test | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index 97014d84ca7..e575cff4774 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1115,6 +1115,11 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); --move_file $MYSQLD_DATADIR/test/t0.ibd $MYSQLD_DATADIR/test/t1.ibd --source include/start_mysqld.inc +if ($have_debug) { +# Initiate shutdown in order to issue a redo log checkpoint and to discard +# the redo log record that was emitted due to '+d,fil_names_write_bogus'. +--source include/restart_mysqld.inc +} SELECT * FROM t1; SELECT * FROM t2; diff --git a/mysql-test/suite/innodb/t/log_file_name_debug.test b/mysql-test/suite/innodb/t/log_file_name_debug.test index 0aaf798e2b3..d85fbf08194 100644 --- a/mysql-test/suite/innodb/t/log_file_name_debug.test +++ b/mysql-test/suite/innodb/t/log_file_name_debug.test @@ -44,5 +44,7 @@ SELECT * FROM t1; --let $restart_parameters= --source include/restart_mysqld.inc +# Initiate shutdown in order to issue a redo log checkpoint and to discard +# the redo log record that was emitted due to '+d,fil_names_write_bogus'. +--source include/restart_mysqld.inc DROP TABLE t1; - From 11df536b8a1a778bfd5908e933ec2306fdf16357 Mon Sep 17 00:00:00 2001 From: Teodor Mircea Ionita Date: Thu, 1 Nov 2018 09:14:19 +0000 Subject: [PATCH 04/50] travis: increase ccache size for linux jobs --- .travis.compiler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.compiler.sh b/.travis.compiler.sh index 7a3b0dbc371..6b8de374219 100755 --- a/.travis.compiler.sh +++ b/.travis.compiler.sh @@ -22,7 +22,7 @@ if [[ "${TRAVIS_OS_NAME}" == 'linux' ]]; then exclude_modules; if which ccache ; then CMAKE_OPT="${CMAKE_OPT} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" - ccache --max-size=1200M + ccache --max-size=2200M fi if [[ "${CXX}" == 'clang++' ]]; then export CXX CC=${CXX/++/} From d5e1f6a632ac8cb5ccf7eecf0717290232c0c240 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 6 Nov 2018 03:40:58 -0800 Subject: [PATCH 05/50] Fix typo sql_yacc --- sql/sql_yacc.yy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7e8243cbc4b..00297d77771 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1693,7 +1693,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT TIMESTAMP '2001-01-01 10:20:30'; SELECT * FROM t1 FOR SYSTEM_TIME AS OF TIMESTAMP CONCAT(@date,' ',@time); - - PERIOD: identifier, period for sytem time: + - PERIOD: identifier, period for system time: SELECT period FROM t1; ALTER TABLE DROP PERIOD FOR SYSTEM TIME; @@ -1705,7 +1705,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT user FROM t1; KILL USER foo; - Note, we need here only tokens that cause shirt/reduce conflicts + Note, we need here only tokens that cause shift/reduce conflicts with keyword identifiers. For example: opt_clause1: %empty | KEYWORD ... ; clause2: opt_clause1 ident; From 3074beaad6bf259c6427d77783ea821d0b16b424 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 9 Nov 2018 09:45:37 +0400 Subject: [PATCH 06/50] MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure Changing the way how a cursor is opened to fetch its structure only, e.g. for a cursor FOR loop record variable. The old methods with setting thd->lex->limit_rows_examined to an Item_uint(0) was not reliable and could push these messages into diagnostics area: The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0) The new method should be more reliable, as it completely prevents the call of do_select() in JOIN::exec_inner() during the cursor structure discovery, so the execution of the cursor SELECT query returns immediately after the preparation step (when the result row structure becomes known), without even entering the code that fetches the result rows. --- .../suite/compat/oracle/r/sp-cursor.result | 28 +++++++++ .../suite/compat/oracle/r/sp-package.result | 48 ++++++++++++++++ .../suite/compat/oracle/t/sp-cursor.test | 35 ++++++++++++ .../suite/compat/oracle/t/sp-package.test | 57 +++++++++++++++++++ sql/sp_head.cc | 4 +- sql/sp_rcontext.cc | 27 --------- sql/sql_class.h | 23 ++++++-- sql/sql_cursor.cc | 5 ++ sql/sql_select.cc | 2 +- 9 files changed, 193 insertions(+), 36 deletions(-) diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor.result b/mysql-test/suite/compat/oracle/r/sp-cursor.result index 03211509f8b..e539f38e307 100644 --- a/mysql-test/suite/compat/oracle/r/sp-cursor.result +++ b/mysql-test/suite/compat/oracle/r/sp-cursor.result @@ -949,3 +949,31 @@ def c%FOUND 3 1 0 Y 32896 0 63 def c%ROWCOUNT 8 21 1 Y 32896 0 63 c%ISOPEN c%NOTFOUND c%FOUND c%ROWCOUNT 1 NULL NULL 0 +# +# MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure +# +CREATE TABLE t1 +( +JOBN varchar(18) NOT NULL, +pk int(11) NOT NULL, +PRIMARY KEY (pk), +KEY (JOBN) +); +CREATE PROCEDURE p1 +AS +lS NUMBER(10) :=0; +CURSOR cBPD IS SELECT * FROM t1 WHERE JOBN='x'; +BEGIN +FOR lbpd IN cBPD LOOP +lS:=lS+1; +END LOOP; +EXCEPTION +WHEN OTHERS THEN +BEGIN +SELECT SQLERRM; +END; +END; +$$ +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/r/sp-package.result b/mysql-test/suite/compat/oracle/r/sp-package.result index 4c8fac26d2d..9a53b04d4ad 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package.result +++ b/mysql-test/suite/compat/oracle/r/sp-package.result @@ -2869,3 +2869,51 @@ msg This is p01 DROP PACKAGE pkg1; DROP TABLE t1; +# +# MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure +# +CREATE TABLE t1 ( +CTR varchar(2) NOT NULL, +COR varchar(3) NOT NULL, +DATE datetime NOT NULL, +CHAN varchar(4) NOT NULL, +CNO varchar(20) NOT NULL, +JOBN varchar(18) NOT NULL, +C1 varchar(30) DEFAULT NULL, +C2 varchar(30) DEFAULT NULL, +TIME datetime DEFAULT NULL, +AMT decimal(12,2) DEFAULT NULL, +DT datetime NOT NULL, +pk int(11) NOT NULL, +PRIMARY KEY (pk), +KEY Indx1 (JOBN) +); +CREATE PACKAGE xyz IS +PROCEDURE xyz123(ctr IN VARCHAR2,Jn IN VARCHAR2,R OUT VARCHAR2); +END; +$$ +CREATE OR REPLACE PACKAGE BODY xyz IS +PROCEDURE xyz123( +ctr IN VARCHAR2, +Jn IN VARCHAR2, +R OUT VARCHAR2) +AS +lS NUMBER(10) :=0; +CURSOR cBPD IS +SELECT CTR, COR, DATE, CHAN, CNO, C1, C2, TIME, AMT +FROM t1 WHERE JOBN=Jn; +BEGIN +FOR lbpd IN cBPD +LOOP +lS:=lS+1; +END LOOP; +EXCEPTION +WHEN OTHERS THEN +BEGIN +SELECT SQLERRM; +END; +END; +END $$ +CALL xyz.xyz123(17,18,@R); +DROP PACKAGE xyz; +DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/t/sp-cursor.test b/mysql-test/suite/compat/oracle/t/sp-cursor.test index 5a8b7b69f67..03b8b016ee0 100644 --- a/mysql-test/suite/compat/oracle/t/sp-cursor.test +++ b/mysql-test/suite/compat/oracle/t/sp-cursor.test @@ -952,3 +952,38 @@ $$ DELIMITER ;$$ --enable_ps_protocol --disable_metadata + + +--echo # +--echo # MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure +--echo # + +CREATE TABLE t1 +( + JOBN varchar(18) NOT NULL, + pk int(11) NOT NULL, + PRIMARY KEY (pk), + KEY (JOBN) +); + +DELIMITER $$; +CREATE PROCEDURE p1 +AS + lS NUMBER(10) :=0; + CURSOR cBPD IS SELECT * FROM t1 WHERE JOBN='x'; +BEGIN + FOR lbpd IN cBPD LOOP + lS:=lS+1; + END LOOP; +EXCEPTION + WHEN OTHERS THEN + BEGIN + SELECT SQLERRM; + END; +END; +$$ +DELIMITER ;$$ + +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/t/sp-package.test b/mysql-test/suite/compat/oracle/t/sp-package.test index e61dd37467c..04357a7487a 100644 --- a/mysql-test/suite/compat/oracle/t/sp-package.test +++ b/mysql-test/suite/compat/oracle/t/sp-package.test @@ -2624,3 +2624,60 @@ DELIMITER ;$$ CALL pkg1.p00; DROP PACKAGE pkg1; DROP TABLE t1; + + +--echo # +--echo # MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure +--echo # + +CREATE TABLE t1 ( + CTR varchar(2) NOT NULL, + COR varchar(3) NOT NULL, + DATE datetime NOT NULL, + CHAN varchar(4) NOT NULL, + CNO varchar(20) NOT NULL, + JOBN varchar(18) NOT NULL, + C1 varchar(30) DEFAULT NULL, + C2 varchar(30) DEFAULT NULL, + TIME datetime DEFAULT NULL, + AMT decimal(12,2) DEFAULT NULL, + DT datetime NOT NULL, + pk int(11) NOT NULL, + PRIMARY KEY (pk), + KEY Indx1 (JOBN) +); + +DELIMITER $$; + +CREATE PACKAGE xyz IS + PROCEDURE xyz123(ctr IN VARCHAR2,Jn IN VARCHAR2,R OUT VARCHAR2); +END; +$$ + +CREATE OR REPLACE PACKAGE BODY xyz IS + PROCEDURE xyz123( + ctr IN VARCHAR2, + Jn IN VARCHAR2, + R OUT VARCHAR2) + AS + lS NUMBER(10) :=0; + CURSOR cBPD IS + SELECT CTR, COR, DATE, CHAN, CNO, C1, C2, TIME, AMT + FROM t1 WHERE JOBN=Jn; + BEGIN + FOR lbpd IN cBPD + LOOP + lS:=lS+1; + END LOOP; + EXCEPTION + WHEN OTHERS THEN + BEGIN + SELECT SQLERRM; + END; + END; +END $$ +DELIMITER ;$$ + +CALL xyz.xyz123(17,18,@R); +DROP PACKAGE xyz; +DROP TABLE t1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index c1c938dd9e7..c8b9576fe88 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -4470,9 +4470,9 @@ sp_instr_cursor_copy_struct::exec_core(THD *thd, uint *nextp) */ if (!row->arguments()) { - sp_cursor tmp(thd, &m_lex_keeper); + sp_cursor tmp(thd, &m_lex_keeper, true); // Open the cursor without copying data - if (!(ret= tmp.open_view_structure_only(thd))) + if (!(ret= tmp.open(thd))) { Row_definition_list defs; if (!(ret= tmp.export_structure(thd, &defs))) diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 24777abe1c3..3e77d8c357b 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -748,33 +748,6 @@ int sp_cursor::open(THD *thd) } -/** - Open the cursor, but do not copy data. - This method is used to fetch the cursor structure - to cursor%ROWTYPE routine variables. - Data copying is suppressed by setting thd->lex->limit_rows_examined to 0. -*/ -int sp_cursor::open_view_structure_only(THD *thd) -{ - int res; - int thd_no_errors_save= thd->no_errors; - Item *limit_rows_examined= thd->lex->limit_rows_examined; // No data copying - if (!(thd->lex->limit_rows_examined= new (thd->mem_root) Item_uint(thd, 0))) - return -1; - thd->no_errors= true; // Suppress ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT - DBUG_ASSERT(!thd->killed); - res= open(thd); - /* - The query possibly exited on LIMIT ROWS EXAMINED and set thd->killed. - Reset it now. - */ - thd->reset_killed(); - thd->no_errors= thd_no_errors_save; - thd->lex->limit_rows_examined= limit_rows_examined; - return res; -} - - int sp_cursor::close(THD *thd) { if (! server_side_cursor) diff --git a/sql/sql_class.h b/sql/sql_class.h index acd48b07900..1a7eb943193 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5037,6 +5037,14 @@ public: Currently all intercepting classes derive from select_result_interceptor. */ virtual bool is_result_interceptor()=0; + + /* + This method is used to distinguish an normal SELECT from the cursor + structure discovery for cursor%ROWTYPE routine variables. + If this method returns "true", then a SELECT execution performs only + all preparation stages, but does not fetch any rows. + */ + virtual bool view_structure_only() const { return false; } }; @@ -5156,9 +5164,13 @@ private: { List *spvar_list; uint field_count; + bool m_view_structure_only; bool send_data_to_variable_list(List &vars, List &items); public: - Select_fetch_into_spvars(THD *thd_arg): select_result_interceptor(thd_arg) {} + Select_fetch_into_spvars(THD *thd_arg, bool view_structure_only) + :select_result_interceptor(thd_arg), + m_view_structure_only(view_structure_only) + {} void reset(THD *thd_arg) { select_result_interceptor::reset(thd_arg); @@ -5171,16 +5183,17 @@ private: virtual bool send_eof() { return FALSE; } virtual int send_data(List &items); virtual int prepare(List &list, SELECT_LEX_UNIT *u); + virtual bool view_structure_only() const { return m_view_structure_only; } }; public: sp_cursor() - :result(NULL), + :result(NULL, false), m_lex_keeper(NULL), server_side_cursor(NULL) { } - sp_cursor(THD *thd_arg, sp_lex_keeper *lex_keeper) - :result(thd_arg), + sp_cursor(THD *thd_arg, sp_lex_keeper *lex_keeper, bool view_structure_only) + :result(thd_arg, view_structure_only), m_lex_keeper(lex_keeper), server_side_cursor(NULL) {} @@ -5192,8 +5205,6 @@ public: int open(THD *thd); - int open_view_structure_only(THD *thd); - int close(THD *thd); my_bool is_open() diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 2a200d279b5..4f3b15c3254 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -92,6 +92,11 @@ public: if (materialized_cursor) materialized_cursor->on_table_fill_finished(); } + + bool view_structure_only() const + { + return result->view_structure_only(); + } }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f3e69ba2ead..08bf2a897fc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4025,7 +4025,7 @@ void JOIN::exec_inner() procedure ? procedure_fields_list : *fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - error= do_select(this, procedure); + error= result->view_structure_only() ? false : do_select(this, procedure); /* Accumulate the counts from all join iterations of all join parts. */ thd->inc_examined_row_count(join_examined_rows); DBUG_PRINT("counts", ("thd->examined_row_count: %lu", From 781f1a765b322d3d2a26c56e13d542403702a771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 9 Nov 2018 08:41:05 +0200 Subject: [PATCH 07/50] MDEV-17379: galera_new_cluster throws error in 10.3.10 Use exit instead of return. --- scripts/galera_new_cluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/galera_new_cluster.sh b/scripts/galera_new_cluster.sh index 5a8ca6958a7..e0763ed516a 100755 --- a/scripts/galera_new_cluster.sh +++ b/scripts/galera_new_cluster.sh @@ -28,4 +28,4 @@ extcode=$? systemctl set-environment _WSREP_NEW_CLUSTER='' -return $extcode +exit $extcode From 2d7d19a3cd18f4bc2ac39ac61e99eb8f2ff933ca Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 8 Nov 2018 22:54:03 -0800 Subject: [PATCH 08/50] MDEV-17574 SIGSEGV or Assertion `producing_item != __null' in Item_direct_view_ref::derived_field_transformer_for_where upon updating a view The condition pushed into a materialized derived / view mast be adjusted for the new context: its column references must be substituted for references to the columns of the underlying tables if the condition is pushed into WHERE. The substitution is performed by the 'transform' method. If the materialized derived is used in a mergeable view then the references to the columns of the view are represented by Item_direct_view_ref objects. The transform method first processes the item wrapped in such an object and only after this it transforms the object itself. The transformation procedure of an Item_direct_view_ref object has to know whether the item it wraps has been substituted. If so the procedure does not have to do anything. In the code before this patch it was not possible for the transformation procedure used by an Item_direct_view_ref object to find out whether a substitution for the wrapped item had happened. --- mysql-test/r/derived_cond_pushdown.result | 93 +++++++++++++++++++++++ mysql-test/t/derived_cond_pushdown.test | 27 +++++++ sql/item.cc | 32 +++++++- sql/item.h | 1 + 4 files changed, 150 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index f5bc72e91e7..14c8e4d5e8f 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -10387,4 +10387,97 @@ f 3 DROP VIEW v1; DROP TABLE t1; +# +# MDEV-17574: pushdown into derived from mergeable view +# used in multi-table UPDATE +# pushdown into materialized derived from mergeable view +# used in SELECT +# +CREATE TABLE t1 (f1 text, f2 int); +INSERT INTO t1 VALUES ('x',1), ('y',2); +CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t; +UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2; +EXPLAIN FORMAT=JSON UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t.f2 < 2", + "materialized": { + "query_block": { + "select_id": 3, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2" + } + } + } + }, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 = t.f2" + } + } +} +SELECT * FROM t1; +f1 f2 +z 1 +y 2 +CREATE VIEW v2 AS SELECT f2 FROM ( SELECT DISTINCT f2 FROM t1 ) AS t; +SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2; +f2 f1 f2 +1 z 1 +EXPLAIN FORMAT=JSON SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t.f2 < 2", + "materialized": { + "query_block": { + "select_id": 3, + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "t1.f2 < 2" + } + } + } + } + }, + "block-nl-join": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 2, + "filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNL", + "attached_condition": "t1.f2 = t.f2" + } + } +} +DROP VIEW v1,v2; +DROP TABLE t1; # End of 10.2 tests diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 46aa898c960..25cb29e13db 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -2075,4 +2075,31 @@ SELECT * FROM t1; DROP VIEW v1; DROP TABLE t1; +--echo # +--echo # MDEV-17574: pushdown into derived from mergeable view +--echo # used in multi-table UPDATE +--echo # pushdown into materialized derived from mergeable view +--echo # used in SELECT +--echo # + +CREATE TABLE t1 (f1 text, f2 int); +INSERT INTO t1 VALUES ('x',1), ('y',2); + +CREATE VIEW v1 AS SELECT f2 FROM ( SELECT f2 FROM t1 ) AS t; +let $q1 = +UPDATE v1, t1 SET t1.f1 = 'z' WHERE v1.f2 < 2 AND t1.f2 = v1.f2; +eval $q1; +eval EXPLAIN FORMAT=JSON $q1; + +SELECT * FROM t1; + +CREATE VIEW v2 AS SELECT f2 FROM ( SELECT DISTINCT f2 FROM t1 ) AS t; +let $q2 = +SELECT * FROM v2, t1 WHERE v2.f2 < 2 AND t1.f2 = v2.f2; +eval $q2; +eval EXPLAIN FORMAT=JSON $q2; + +DROP VIEW v1,v2; +DROP TABLE t1; + --echo # End of 10.2 tests diff --git a/sql/item.cc b/sql/item.cc index 2adec33491b..9ac1ed3947d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7143,13 +7143,21 @@ Item *Item_field::derived_field_transformer_for_having(THD *thd, uchar *arg) return this; if (!item_equal && used_tables() != tab_map) return this; - return get_field_item_for_having(thd, this, sel); + Item *item= get_field_item_for_having(thd, this, sel); + if (item) + item->marker|= SUBSTITUTION_FL; + return item; } Item *Item_direct_view_ref::derived_field_transformer_for_having(THD *thd, uchar *arg) { + if ((*ref)->marker & SUBSTITUTION_FL) + { + this->marker|= SUBSTITUTION_FL; + return this; + } st_select_lex *sel= (st_select_lex *)arg; table_map tab_map= sel->master_unit()->derived->table->map; if ((item_equal && !(item_equal->used_tables() & tab_map)) || @@ -7200,13 +7208,20 @@ Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg) st_select_lex *sel= (st_select_lex *)arg; Item *producing_item= find_producing_item(this, sel); if (producing_item) - return producing_item->build_clone(thd, thd->mem_root); + { + Item *producing_clone= producing_item->build_clone(thd, thd->mem_root); + if (producing_clone) + producing_clone->marker|= SUBSTITUTION_FL; + return producing_clone; + } return this; } Item *Item_direct_view_ref::derived_field_transformer_for_where(THD *thd, uchar *arg) { + if ((*ref)->marker & SUBSTITUTION_FL) + return (*ref); if (item_equal) { st_select_lex *sel= (st_select_lex *)arg; @@ -7258,7 +7273,13 @@ Item *Item_field::derived_grouping_field_transformer_for_where(THD *thd, st_select_lex *sel= (st_select_lex *)arg; Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel); if (gr_field) - return gr_field->producing_item->build_clone(thd, thd->mem_root); + { + Item *producing_clone= + gr_field->producing_item->build_clone(thd, thd->mem_root); + if (producing_clone) + producing_clone->marker|= SUBSTITUTION_FL; + return producing_clone; + } return this; } @@ -7267,6 +7288,11 @@ Item * Item_direct_view_ref::derived_grouping_field_transformer_for_where(THD *thd, uchar *arg) { + if ((*ref)->marker & SUBSTITUTION_FL) + { + this->marker|= SUBSTITUTION_FL; + return this; + } if (!item_equal) return this; st_select_lex *sel= (st_select_lex *)arg; diff --git a/sql/item.h b/sql/item.h index 8d02d981d38..3a64ea1a75d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -147,6 +147,7 @@ bool mark_unsupported_function(const char *w1, const char *w2, #define NO_EXTRACTION_FL (1 << 6) #define FULL_EXTRACTION_FL (1 << 7) +#define SUBSTITUTION_FL (1 << 8) #define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL) class DTCollation { From aa4772e75b80627a75e01bb8cdb1a55dd3547426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 9 Nov 2018 12:07:43 +0200 Subject: [PATCH 09/50] MDEV-13134: Remove an orphan .inc file --- .../suite/innodb/include/alter_instant.inc | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 mysql-test/suite/innodb/include/alter_instant.inc diff --git a/mysql-test/suite/innodb/include/alter_instant.inc b/mysql-test/suite/innodb/include/alter_instant.inc deleted file mode 100644 index cf0c082416b..00000000000 --- a/mysql-test/suite/innodb/include/alter_instant.inc +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE t1(f1 INT NOT NULL, - f2 INT NOT NULL, - f3 INT AS (f2 * f2) VIRTUAL)engine=innodb; - -INSERT INTO t1(f1, f2) VALUES(1, 1); - ---echo # ---echo # ALGORITHM=$algorithm_type ---echo # - ---enable_info ---echo # Add column at the end of the table ---error $error_code ---eval ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL", ALGORITHM=$algorithm_type - ---echo # Change virtual column expression ---error $error_code ---eval ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL, ALGORITHM=$algorithm_type - ---echo # Add virtual column ---error $error_code ---eval ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL, ALGORITHM=$algorithm_type - ---echo # Rename Column ---error $error_code ---eval ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL, ALGORITHM=$algorithm_type - ---echo # Rename table ---error $error_code ---eval ALTER TABLE t1 RENAME t2, algorithm=$algorithm_type - -DROP TABLE t2; ---disable_info From def2ac209a0c2644ee068abe05bd26a81aeb40c0 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 9 Nov 2018 17:08:13 +0400 Subject: [PATCH 10/50] MDEV-17652 Add sql_mode specific tokens for some keywords --- sql/gen_lex_token.cc | 3 +- sql/lex.h | 24 ++--- sql/sp_pcontext.cc | 13 +++ sql/sp_pcontext.h | 8 +- sql/sql_lex.cc | 18 ++++ sql/sql_yacc.yy | 235 +++++++++++++++++++++++++++++++++++-------- sql/sql_yacc_ora.yy | 215 +++++++++++++++++++++++---------------- 7 files changed, 370 insertions(+), 146 deletions(-) diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc index c03bfe66f47..aee0f12a4fe 100644 --- a/sql/gen_lex_token.cc +++ b/sql/gen_lex_token.cc @@ -255,7 +255,8 @@ void compute_tokens() set_start_expr_token(STARTS_SYM); set_start_expr_token(ENDS_SYM); set_start_expr_token(DEFAULT); - set_start_expr_token(RETURN_SYM); + set_start_expr_token(RETURN_MARIADB_SYM); + set_start_expr_token(RETURN_ORACLE_SYM); set_start_expr_token(IF_SYM); set_start_expr_token(ELSEIF_SYM); set_start_expr_token(CASE_SYM); diff --git a/sql/lex.h b/sql/lex.h index d336c273a18..d3878186696 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -82,7 +82,7 @@ static SYMBOL symbols[] = { { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)}, { "BACKUP", SYM(BACKUP_SYM)}, { "BEFORE", SYM(BEFORE_SYM)}, - { "BEGIN", SYM(BEGIN_SYM)}, + { "BEGIN", SYM(BEGIN_MARIADB_SYM)}, { "BETWEEN", SYM(BETWEEN_SYM)}, { "BIGINT", SYM(BIGINT)}, { "BINARY", SYM(BINARY)}, @@ -90,7 +90,7 @@ static SYMBOL symbols[] = { { "BIT", SYM(BIT_SYM)}, { "BLOB", SYM(BLOB_SYM)}, { "BLOCK", SYM(BLOCK_SYM)}, - { "BODY", SYM(BODY_SYM)}, + { "BODY", SYM(BODY_MARIADB_SYM)}, { "BOOL", SYM(BOOL_SYM)}, { "BOOLEAN", SYM(BOOLEAN_SYM)}, { "BOTH", SYM(BOTH)}, @@ -145,7 +145,7 @@ static SYMBOL symbols[] = { { "CONSTRAINT_SCHEMA", SYM(CONSTRAINT_SCHEMA_SYM)}, { "CONTAINS", SYM(CONTAINS_SYM)}, { "CONTEXT", SYM(CONTEXT_SYM)}, - { "CONTINUE", SYM(CONTINUE_SYM)}, + { "CONTINUE", SYM(CONTINUE_MARIADB_SYM)}, { "CONTRIBUTORS", SYM(CONTRIBUTORS_SYM)}, { "CONVERT", SYM(CONVERT_SYM)}, { "CPU", SYM(CPU_SYM)}, @@ -206,7 +206,7 @@ static SYMBOL symbols[] = { { "EACH", SYM(EACH_SYM)}, { "ELSE", SYM(ELSE)}, { "ELSEIF", SYM(ELSEIF_SYM)}, - { "ELSIF", SYM(ELSIF_SYM)}, + { "ELSIF", SYM(ELSIF_MARIADB_SYM)}, { "ENABLE", SYM(ENABLE_SYM)}, { "ENCLOSED", SYM(ENCLOSED)}, { "END", SYM(END)}, @@ -226,9 +226,9 @@ static SYMBOL symbols[] = { { "EXCHANGE", SYM(EXCHANGE_SYM)}, { "EXCLUDE", SYM(EXCLUDE_SYM)}, { "EXECUTE", SYM(EXECUTE_SYM)}, - { "EXCEPTION", SYM(EXCEPTION_SYM)}, + { "EXCEPTION", SYM(EXCEPTION_MARIADB_SYM)}, { "EXISTS", SYM(EXISTS)}, - { "EXIT", SYM(EXIT_SYM)}, + { "EXIT", SYM(EXIT_MARIADB_SYM)}, { "EXPANSION", SYM(EXPANSION_SYM)}, { "EXPORT", SYM(EXPORT_SYM)}, { "EXPLAIN", SYM(DESCRIBE)}, @@ -264,7 +264,7 @@ static SYMBOL symbols[] = { { "GET_FORMAT", SYM(GET_FORMAT)}, { "GET", SYM(GET_SYM)}, { "GLOBAL", SYM(GLOBAL_SYM)}, - { "GOTO", SYM(GOTO_SYM)}, + { "GOTO", SYM(GOTO_MARIADB_SYM)}, { "GRANT", SYM(GRANT)}, { "GRANTS", SYM(GRANTS)}, { "GROUP", SYM(GROUP_SYM)}, @@ -451,13 +451,13 @@ static SYMBOL symbols[] = { { "OPTIONALLY", SYM(OPTIONALLY)}, { "OR", SYM(OR_SYM)}, { "ORDER", SYM(ORDER_SYM)}, - { "OTHERS", SYM(OTHERS_SYM)}, + { "OTHERS", SYM(OTHERS_MARIADB_SYM)}, { "OUT", SYM(OUT_SYM)}, { "OUTER", SYM(OUTER)}, { "OUTFILE", SYM(OUTFILE)}, { "OVER", SYM(OVER_SYM)}, { "OWNER", SYM(OWNER_SYM)}, - { "PACKAGE", SYM(PACKAGE_SYM)}, + { "PACKAGE", SYM(PACKAGE_MARIADB_SYM)}, { "PACK_KEYS", SYM(PACK_KEYS_SYM)}, { "PAGE", SYM(PAGE_SYM)}, { "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)}, @@ -495,7 +495,7 @@ static SYMBOL symbols[] = { { "QUARTER", SYM(QUARTER_SYM)}, { "QUERY", SYM(QUERY_SYM)}, { "QUICK", SYM(QUICK)}, - { "RAISE", SYM(RAISE_SYM)}, + { "RAISE", SYM(RAISE_MARIADB_SYM)}, { "RANGE", SYM(RANGE_SYM)}, { "RAW", SYM(RAW)}, { "READ", SYM(READ_SYM)}, @@ -534,7 +534,7 @@ static SYMBOL symbols[] = { { "RESTRICT", SYM(RESTRICT)}, { "RESUME", SYM(RESUME_SYM)}, { "RETURNED_SQLSTATE",SYM(RETURNED_SQLSTATE_SYM)}, - { "RETURN", SYM(RETURN_SYM)}, + { "RETURN", SYM(RETURN_MARIADB_SYM)}, { "RETURNING", SYM(RETURNING_SYM)}, { "RETURNS", SYM(RETURNS_SYM)}, { "REUSE", SYM(REUSE_SYM)}, @@ -549,7 +549,7 @@ static SYMBOL symbols[] = { { "ROW", SYM(ROW_SYM)}, { "ROWCOUNT", SYM(ROWCOUNT_SYM)}, /* Oracle-N */ { "ROWS", SYM(ROWS_SYM)}, - { "ROWTYPE", SYM(ROWTYPE_SYM)}, + { "ROWTYPE", SYM(ROWTYPE_MARIADB_SYM)}, { "ROW_COUNT", SYM(ROW_COUNT_SYM)}, { "ROW_FORMAT", SYM(ROW_FORMAT_SYM)}, { "RTREE", SYM(RTREE_SYM)}, diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 83d674e7500..b0fee18ef05 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -409,6 +409,19 @@ sp_condition_value *sp_pcontext::find_condition(const LEX_CSTRING *name, NULL; } +sp_condition_value * +sp_pcontext::find_declared_or_predefined_condition(THD *thd, + const LEX_CSTRING *name) + const +{ + sp_condition_value *p= find_condition(name, false); + if (p) + return p; + if (thd->variables.sql_mode & MODE_ORACLE) + return find_predefined_condition(name); + return NULL; +} + static sp_condition_value // Warnings diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index e30af3fcde5..e607315cdaf 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -592,13 +592,7 @@ public: bool current_scope_only) const; sp_condition_value * - find_declared_or_predefined_condition(const LEX_CSTRING *name) const - { - sp_condition_value *p= find_condition(name, false); - if (p) - return p; - return find_predefined_condition(name); - } + find_declared_or_predefined_condition(THD *thd, const LEX_CSTRING *name) const; bool declare_condition(THD *thd, const LEX_CSTRING *name, sp_condition_value *val) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e5bfccfed29..cab5381e0ed 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -838,6 +838,24 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, DBUG_ASSERT(tok >= get_buf()); DBUG_ASSERT(tok < get_end_of_query()); + if (m_thd->variables.sql_mode & MODE_ORACLE) + { + switch (symbol->tok) { + case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM; + case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; + case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; + case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM; + case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; + case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; + case GOTO_MARIADB_SYM: return GOTO_ORACLE_SYM; + case OTHERS_MARIADB_SYM: return OTHERS_ORACLE_SYM; + case PACKAGE_MARIADB_SYM: return PACKAGE_ORACLE_SYM; + case RAISE_MARIADB_SYM: return RAISE_ORACLE_SYM; + case RETURN_MARIADB_SYM: return RETURN_ORACLE_SYM; + case ROWTYPE_MARIADB_SYM: return ROWTYPE_ORACLE_SYM; + } + } + if ((symbol->tok == NOT_SYM) && (m_thd->variables.sql_mode & MODE_HIGH_NOT_PRECEDENCE)) return NOT2_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 00297d77771..745dc5664dc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -936,6 +936,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token BIT_OR /* MYSQL-FUNC */ %token BIT_XOR /* MYSQL-FUNC */ %token BLOB_SYM /* SQL-2003-R */ +%token BODY_ORACLE_SYM /* Oracle-R */ %token BOTH /* SQL-2003-R */ %token BY /* SQL-2003-R */ %token CALL_SYM /* SQL-2003-R */ @@ -948,7 +949,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COLLATE_SYM /* SQL-2003-R */ %token CONDITION_SYM /* SQL-2003-R, SQL-2008-R */ %token CONSTRAINT /* SQL-2003-R */ -%token CONTINUE_SYM /* SQL-2003-R */ +%token CONTINUE_MARIADB_SYM /* SQL-2003-R, Oracle-R */ +%token CONTINUE_ORACLE_SYM /* SQL-2003-R, Oracle-R */ %token CONVERT_SYM /* SQL-2003-N */ %token COUNT_SYM /* SQL-2003-N */ %token CREATE /* SQL-2003-R */ @@ -987,6 +989,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ %token ELSEIF_SYM +%token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ %token EQUAL_SYM /* OPERATOR */ @@ -1005,6 +1008,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FROM %token FULLTEXT_SYM %token GE +%token GOTO_ORACLE_SYM /* Oracle-R */ %token GRANT /* SQL-2003-R */ %token GROUP_SYM /* SQL-2003-R */ %token GROUP_CONCAT_SYM @@ -1090,10 +1094,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token OR2_SYM %token ORDER_SYM /* SQL-2003-R */ %token OR_SYM /* SQL-2003-R */ +%token OTHERS_ORACLE_SYM /* SQL-2011-N, PLSQL-R */ %token OUTER %token OUTFILE %token OUT_SYM /* SQL-2003-R */ %token OVER_SYM +%token PACKAGE_ORACLE_SYM /* Oracle-R */ %token PAGE_CHECKSUM_SYM %token PARAM_MARKER %token PARSE_VCOL_EXPR_SYM @@ -1106,6 +1112,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PRIMARY_SYM /* SQL-2003-R */ %token PROCEDURE_SYM /* SQL-2003-R */ %token PURGE +%token RAISE_ORACLE_SYM /* PLSQL-R */ %token RANGE_SYM /* SQL-2003-R */ %token RANK_SYM %token READS_SYM /* SQL-2003-R */ @@ -1124,10 +1131,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token RESIGNAL_SYM /* SQL-2003-R */ %token RESTRICT %token RETURNING_SYM -%token RETURN_SYM /* SQL-2003-R */ +%token RETURN_MARIADB_SYM /* SQL-2003-R, PLSQL-R */ +%token RETURN_ORACLE_SYM /* SQL-2003-R, PLSQL-R */ %token REVOKE /* SQL-2003-R */ %token RIGHT /* SQL-2003-R */ %token ROWS_SYM /* SQL-2003-R */ +%token ROWTYPE_ORACLE_SYM /* PLSQL-R */ %token ROW_NUMBER_SYM %token SECOND_MICROSECOND_SYM %token SELECT_SYM /* SQL-2003-R */ @@ -1212,13 +1221,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* Keywords that have different reserved status in std/oracle modes. */ -%token BODY_SYM /* Oracle-R */ -%token ELSIF_SYM /* Oracle, reserved in PL/SQL*/ -%token GOTO_SYM /* Oracle, reserved in PL/SQL*/ -%token OTHERS_SYM /* SQL-2011-N */ -%token PACKAGE_SYM /* Oracle-R */ -%token RAISE_SYM /* Oracle-PLSQL-R */ -%token ROWTYPE_SYM /* Oracle-PLSQL-R */ +%token BODY_MARIADB_SYM // Oracle-R +%token ELSIF_MARIADB_SYM // PLSQL-R +%token EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R +%token GOTO_MARIADB_SYM // Oracle-R +%token OTHERS_MARIADB_SYM // SQL-2011-N, PLSQL-R +%token PACKAGE_MARIADB_SYM // Oracle-R +%token RAISE_MARIADB_SYM // PLSQL-R +%token ROWTYPE_MARIADB_SYM // PLSQL-R /* Non-reserved keywords @@ -1243,7 +1253,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token AVG_ROW_LENGTH %token AVG_SYM /* SQL-2003-N */ %token BACKUP_SYM -%token BEGIN_SYM /* SQL-2003-R, PLSQL-R */ +%token BEGIN_MARIADB_SYM /* SQL-2003-R, PLSQL-R */ +%token BEGIN_ORACLE_SYM /* SQL-2003-R, PLSQL-R */ %token BINLOG_SYM %token BIT_SYM /* MYSQL-FUNC */ %token BLOCK_SYM @@ -1333,8 +1344,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token EXAMINED_SYM %token EXCLUDE_SYM /* SQL-2011-N */ %token EXECUTE_SYM /* SQL-2003-R */ -%token EXCEPTION_SYM /* SQL-2003-N, Oracle-PLSQL-R */ -%token EXIT_SYM +%token EXCEPTION_MARIADB_SYM /* SQL-2003-N, PLSQL-R */ +%token EXIT_MARIADB_SYM /* PLSQL-R */ +%token EXIT_ORACLE_SYM /* PLSQL-R */ %token EXPANSION_SYM %token EXPORT_SYM %token EXTENDED_SYM @@ -1351,7 +1363,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FORMAT_SYM %token FOUND_SYM /* SQL-2003-R */ %token FULL /* SQL-2003-R */ -%token FUNCTION_SYM /* SQL-2003-R */ +%token FUNCTION_SYM /* SQL-2003-R, Oracle-R */ %token GENERAL %token GENERATED_SYM %token GEOMETRYCOLLECTION @@ -1937,6 +1949,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); signal_allowed_expr simple_target_specification condition_number + reset_lex_expr %type param_marker @@ -2045,7 +2058,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); query verb_clause create change select do drop insert replace insert2 insert_values update delete truncate rename compound_statement show describe load alter optimize keycache preload flush - reset purge begin commit rollback savepoint release + reset purge begin_stmt_mariadb commit rollback savepoint release slave master_def master_defs master_file_def slave_until_opts repair analyze opt_with_admin opt_with_admin_option analyze_table_list analyze_table_elem_spec @@ -2117,8 +2130,11 @@ END_OF_INPUT %type sp_proc_stmt_if %type sp_labeled_control sp_unlabeled_control %type sp_labeled_block sp_unlabeled_block sp_unlabeled_block_not_atomic +%type sp_proc_stmt_continue_oracle +%type sp_proc_stmt_exit_oracle %type sp_proc_stmt_leave %type sp_proc_stmt_iterate +%type sp_proc_stmt_goto_oracle %type sp_proc_stmt_open sp_proc_stmt_fetch sp_proc_stmt_close %type case_stmt_specification %type loop_body while_body repeat_body @@ -2141,7 +2157,7 @@ END_OF_INPUT %type index_hint_clause normal_join inner_join %type data_or_xml -%type signal_stmt resignal_stmt +%type signal_stmt resignal_stmt raise_stmt_oracle %type signal_condition_information_item_name %type trigger_follows_precedes_clause; @@ -2255,7 +2271,7 @@ opt_end_of_input: verb_clause: statement - | begin + | begin_stmt_mariadb | compound_statement ; @@ -2295,6 +2311,7 @@ statement: | preload | prepare | purge + | raise_stmt_oracle | release | rename | repair @@ -3659,8 +3676,10 @@ sp_cursor_stmt: ; sp_handler_type: - EXIT_SYM { $$= sp_handler::EXIT; } - | CONTINUE_SYM { $$= sp_handler::CONTINUE; } + EXIT_MARIADB_SYM { $$= sp_handler::EXIT; } + | CONTINUE_MARIADB_SYM { $$= sp_handler::CONTINUE; } + | EXIT_ORACLE_SYM { $$= sp_handler::EXIT; } + | CONTINUE_ORACLE_SYM { $$= sp_handler::CONTINUE; } /*| UNDO_SYM { QQ No yet } */ ; @@ -3730,7 +3749,7 @@ sp_hcond: } | ident /* CONDITION name */ { - $$= Lex->spcont->find_condition(&$1, false); + $$= Lex->spcont->find_declared_or_predefined_condition(thd, &$1); if (unlikely($$ == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); } @@ -3752,6 +3771,26 @@ sp_hcond: if (unlikely($$ == NULL)) MYSQL_YYABORT; } + | OTHERS_ORACLE_SYM /* All other SQLSTATEs */ + { + $$= new (thd->mem_root) sp_condition_value(sp_condition_value::EXCEPTION); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + ; + + +raise_stmt_oracle: + RAISE_ORACLE_SYM opt_set_signal_information + { + if (unlikely(Lex->add_resignal_statement(thd, NULL))) + MYSQL_YYABORT; + } + | RAISE_ORACLE_SYM signal_value opt_set_signal_information + { + if (unlikely(Lex->add_signal_statement(thd, $2))) + MYSQL_YYABORT; + } ; signal_stmt: @@ -3771,7 +3810,7 @@ signal_value: /* SIGNAL foo cannot be used outside of stored programs */ if (unlikely(lex->spcont == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); - cond= lex->spcont->find_condition(&$1, false); + cond= lex->spcont->find_declared_or_predefined_condition(thd, &$1); if (unlikely(cond == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); if (unlikely(cond->type != sp_condition_value::SQLSTATE)) @@ -4088,8 +4127,11 @@ sp_proc_stmt_in_returns_clause: sp_proc_stmt: sp_proc_stmt_in_returns_clause | sp_proc_stmt_statement + | sp_proc_stmt_continue_oracle + | sp_proc_stmt_exit_oracle | sp_proc_stmt_leave | sp_proc_stmt_iterate + | sp_proc_stmt_goto_oracle | sp_proc_stmt_open | sp_proc_stmt_fetch | sp_proc_stmt_close @@ -4165,8 +4207,14 @@ sp_proc_stmt_statement: } ; + +RETURN_ALLMODES_SYM: + RETURN_MARIADB_SYM + | RETURN_ORACLE_SYM + ; + sp_proc_stmt_return: - RETURN_SYM + RETURN_ALLMODES_SYM { Lex->sphead->reset_lex(thd); } expr { @@ -4177,8 +4225,71 @@ sp_proc_stmt_return: unlikely(sp->restore_lex(thd))) MYSQL_YYABORT; } + | RETURN_ORACLE_SYM + { + LEX *lex= Lex; + sp_head *sp= lex->sphead; + if (unlikely(sp->m_handler->add_instr_preturn(thd, sp, + lex->spcont))) + MYSQL_YYABORT; + } ; +reset_lex_expr: + { Lex->sphead->reset_lex(thd); } expr { $$= $2; } + ; + +sp_proc_stmt_exit_oracle: + EXIT_ORACLE_SYM + { + if (unlikely(Lex->sp_exit_statement(thd, NULL))) + MYSQL_YYABORT; + } + | EXIT_ORACLE_SYM label_ident + { + if (unlikely(Lex->sp_exit_statement(thd, &$2, NULL))) + MYSQL_YYABORT; + } + | EXIT_ORACLE_SYM WHEN_SYM reset_lex_expr + { + if (unlikely(Lex->sp_exit_statement(thd, $3)) || + unlikely(Lex->sphead->restore_lex(thd))) + MYSQL_YYABORT; + } + | EXIT_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr + { + if (unlikely(Lex->sp_exit_statement(thd, &$2, $4)) || + unlikely(Lex->sphead->restore_lex(thd))) + MYSQL_YYABORT; + } + ; + +sp_proc_stmt_continue_oracle: + CONTINUE_ORACLE_SYM + { + if (unlikely(Lex->sp_continue_statement(thd, NULL))) + MYSQL_YYABORT; + } + | CONTINUE_ORACLE_SYM label_ident + { + if (unlikely(Lex->sp_continue_statement(thd, &$2, NULL))) + MYSQL_YYABORT; + } + | CONTINUE_ORACLE_SYM WHEN_SYM reset_lex_expr + { + if (unlikely(Lex->sp_continue_statement(thd, $3)) || + unlikely(Lex->sphead->restore_lex(thd))) + MYSQL_YYABORT; + } + | CONTINUE_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr + { + if (unlikely(Lex->sp_continue_statement(thd, &$2, $4)) || + unlikely(Lex->sphead->restore_lex(thd))) + MYSQL_YYABORT; + } + ; + + sp_proc_stmt_leave: LEAVE_SYM label_ident { @@ -4195,6 +4306,14 @@ sp_proc_stmt_iterate: } ; +sp_proc_stmt_goto_oracle: + GOTO_ORACLE_SYM label_ident + { + if (unlikely(Lex->sp_goto_statement(thd, &$2))) + MYSQL_YYABORT; + } + ; + assignment_source_lex: { DBUG_ASSERT(Lex->sphead); @@ -4568,7 +4687,7 @@ sp_block_label: sp_labeled_block: sp_block_label - BEGIN_SYM + BEGIN_MARIADB_SYM { Lex->sp_block_init(thd, &$1); } @@ -4583,7 +4702,7 @@ sp_labeled_block: ; sp_unlabeled_block: - BEGIN_SYM + BEGIN_MARIADB_SYM { Lex->sp_block_init(thd); } @@ -4597,7 +4716,7 @@ sp_unlabeled_block: ; sp_unlabeled_block_not_atomic: - BEGIN_SYM not ATOMIC_SYM /* TODO: BEGIN ATOMIC (not -> opt_not) */ + BEGIN_MARIADB_SYM not ATOMIC_SYM /* TODO: BEGIN ATOMIC (not -> opt_not) */ { if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; @@ -12493,7 +12612,9 @@ opt_window_frame_exclusion: { $$= Window_frame::EXCL_GROUP; } | EXCLUDE_SYM TIES_SYM { $$= Window_frame::EXCL_TIES; } - | EXCLUDE_SYM NO_SYM OTHERS_SYM + | EXCLUDE_SYM NO_SYM OTHERS_MARIADB_SYM + { $$= Window_frame::EXCL_NONE; } + | EXCLUDE_SYM NO_SYM OTHERS_ORACLE_SYM { $$= Window_frame::EXCL_NONE; } ; @@ -13982,13 +14103,13 @@ show_param: lex->sql_command = SQLCOM_SHOW_CREATE_FUNC; lex->spname= $3; } - | CREATE PACKAGE_SYM sp_name + | CREATE PACKAGE_MARIADB_SYM sp_name { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE_PACKAGE; lex->spname= $3; } - | CREATE PACKAGE_SYM BODY_SYM sp_name + | CREATE PACKAGE_MARIADB_SYM BODY_MARIADB_SYM sp_name { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE_PACKAGE_BODY; @@ -14027,14 +14148,14 @@ show_param: if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } - | PACKAGE_SYM STATUS_SYM wild_and_where + | PACKAGE_MARIADB_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE; if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } - | PACKAGE_SYM BODY_SYM STATUS_SYM wild_and_where + | PACKAGE_MARIADB_SYM BODY_MARIADB_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE_BODY; @@ -14051,7 +14172,7 @@ show_param: Lex->sql_command= SQLCOM_SHOW_FUNC_CODE; Lex->spname= $3; } - | PACKAGE_SYM BODY_SYM CODE_SYM sp_name + | PACKAGE_MARIADB_SYM BODY_MARIADB_SYM CODE_SYM sp_name { Lex->sql_command= SQLCOM_SHOW_PACKAGE_BODY_CODE; Lex->spname= $4; @@ -15468,7 +15589,7 @@ keyword_sp_var_not_label: | INSTALL_SYM | OPTION | OPTIONS_SYM - | OTHERS_SYM + | OTHERS_MARIADB_SYM | OWNER_SYM | PARSER_SYM | PERIOD_SYM @@ -15568,7 +15689,8 @@ keyword_verb_clause: Keywords that start an SP block section. */ keyword_sp_block_section: - BEGIN_SYM + BEGIN_MARIADB_SYM + | EXCEPTION_ORACLE_SYM | END ; @@ -15639,7 +15761,7 @@ keyword_sp_var_and_label: | AVG_ROW_LENGTH | AVG_SYM | BLOCK_SYM - | BODY_SYM + | BODY_MARIADB_SYM | BTREE_SYM | CASCADED | CATALOG_NAME_SYM @@ -15691,7 +15813,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM - | ELSIF_SYM + | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM | ENGINES_SYM @@ -15701,7 +15823,7 @@ keyword_sp_var_and_label: | EVENT_SYM | EVENTS_SYM | EVERY_SYM - | EXCEPTION_SYM + | EXCEPTION_MARIADB_SYM | EXCHANGE_SYM | EXPANSION_SYM | EXPORT_SYM @@ -15718,7 +15840,7 @@ keyword_sp_var_and_label: | GENERATED_SYM | GET_FORMAT | GRANTS - | GOTO_SYM + | GOTO_MARIADB_SYM | HASH_SYM | HARD_SYM | HISTORY_SYM @@ -15813,7 +15935,7 @@ keyword_sp_var_and_label: | ONE_SYM | ONLINE_SYM | ONLY_SYM - | PACKAGE_SYM + | PACKAGE_MARIADB_SYM | PACK_KEYS_SYM | PAGE_SYM | PARTIAL @@ -15836,7 +15958,7 @@ keyword_sp_var_and_label: | QUARTER_SYM | QUERY_SYM | QUICK - | RAISE_SYM + | RAISE_MARIADB_SYM | READ_ONLY_SYM | REBUILD_SYM | RECOVER_SYM @@ -15863,7 +15985,7 @@ keyword_sp_var_and_label: | ROLLUP_SYM | ROUTINE_SYM | ROWCOUNT_SYM - | ROWTYPE_SYM + | ROWTYPE_MARIADB_SYM | ROW_COUNT_SYM | ROW_FORMAT_SYM | RTREE_SYM @@ -16545,6 +16667,20 @@ revoke_command: TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } + | grant_privileges ON PACKAGE_ORACLE_SYM grant_ident + FROM user_and_role_list + { + if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, + TYPE_ENUM_PACKAGE))) + MYSQL_YYABORT; + } + | grant_privileges ON PACKAGE_ORACLE_SYM BODY_ORACLE_SYM grant_ident + FROM user_and_role_list + { + if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, + TYPE_ENUM_PACKAGE_BODY))) + MYSQL_YYABORT; + } | ALL opt_privileges ',' GRANT OPTION FROM user_and_role_list { Lex->sql_command = SQLCOM_REVOKE_ALL; @@ -16598,6 +16734,20 @@ grant_command: TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } + | grant_privileges ON PACKAGE_ORACLE_SYM grant_ident TO_SYM grant_list + opt_require_clause opt_grant_options + { + if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, + TYPE_ENUM_PACKAGE))) + MYSQL_YYABORT; + } + | grant_privileges ON PACKAGE_ORACLE_SYM BODY_ORACLE_SYM grant_ident TO_SYM grant_list + opt_require_clause opt_grant_options + { + if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, + TYPE_ENUM_PACKAGE_BODY))) + MYSQL_YYABORT; + } | PROXY_SYM ON user TO_SYM grant_list opt_grant_option { LEX *lex= Lex; @@ -17009,8 +17159,8 @@ grant_option: | resource_option {} ; -begin: - BEGIN_SYM +begin_stmt_mariadb: + BEGIN_MARIADB_SYM { LEX *lex=Lex; lex->sql_command = SQLCOM_BEGIN; @@ -17717,7 +17867,8 @@ xid: ; begin_or_start: - BEGIN_SYM {} + BEGIN_MARIADB_SYM {} + | BEGIN_ORACLE_SYM {} | START_SYM {} ; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index d575fd497bc..529582d8dc9 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -330,6 +330,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token BIT_OR /* MYSQL-FUNC */ %token BIT_XOR /* MYSQL-FUNC */ %token BLOB_SYM /* SQL-2003-R */ +%token BODY_ORACLE_SYM /* Oracle-R */ %token BOTH /* SQL-2003-R */ %token BY /* SQL-2003-R */ %token CALL_SYM /* SQL-2003-R */ @@ -342,7 +343,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COLLATE_SYM /* SQL-2003-R */ %token CONDITION_SYM /* SQL-2003-R, SQL-2008-R */ %token CONSTRAINT /* SQL-2003-R */ -%token CONTINUE_SYM /* SQL-2003-R */ +%token CONTINUE_MARIADB_SYM /* SQL-2003-R, Oracle-R */ +%token CONTINUE_ORACLE_SYM /* SQL-2003-R, Oracle-R */ %token CONVERT_SYM /* SQL-2003-N */ %token COUNT_SYM /* SQL-2003-N */ %token CREATE /* SQL-2003-R */ @@ -381,6 +383,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ %token ELSEIF_SYM +%token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ %token EQUAL_SYM /* OPERATOR */ @@ -399,6 +402,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FROM %token FULLTEXT_SYM %token GE +%token GOTO_ORACLE_SYM /* Oracle-R */ %token GRANT /* SQL-2003-R */ %token GROUP_SYM /* SQL-2003-R */ %token GROUP_CONCAT_SYM @@ -484,10 +488,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token OR2_SYM %token ORDER_SYM /* SQL-2003-R */ %token OR_SYM /* SQL-2003-R */ +%token OTHERS_ORACLE_SYM /* SQL-2011-N, PLSQL-R */ %token OUTER %token OUTFILE %token OUT_SYM /* SQL-2003-R */ %token OVER_SYM +%token PACKAGE_ORACLE_SYM /* Oracle-R */ %token PAGE_CHECKSUM_SYM %token PARAM_MARKER %token PARSE_VCOL_EXPR_SYM @@ -500,6 +506,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PRIMARY_SYM /* SQL-2003-R */ %token PROCEDURE_SYM /* SQL-2003-R */ %token PURGE +%token RAISE_ORACLE_SYM /* PLSQL-R */ %token RANGE_SYM /* SQL-2003-R */ %token RANK_SYM %token READS_SYM /* SQL-2003-R */ @@ -518,10 +525,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token RESIGNAL_SYM /* SQL-2003-R */ %token RESTRICT %token RETURNING_SYM -%token RETURN_SYM /* SQL-2003-R */ +%token RETURN_MARIADB_SYM /* SQL-2003-R, PLSQL-R */ +%token RETURN_ORACLE_SYM /* SQL-2003-R, PLSQL-R */ %token REVOKE /* SQL-2003-R */ %token RIGHT /* SQL-2003-R */ %token ROWS_SYM /* SQL-2003-R */ +%token ROWTYPE_ORACLE_SYM /* PLSQL-R */ %token ROW_NUMBER_SYM %token SECOND_MICROSECOND_SYM %token SELECT_SYM /* SQL-2003-R */ @@ -606,13 +615,14 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); /* Keywords that have different reserved status in std/oracle modes. */ -%token BODY_SYM /* Oracle-R */ -%token ELSIF_SYM /* Oracle, reserved in PL/SQL*/ -%token GOTO_SYM /* Oracle, reserved in PL/SQL*/ -%token OTHERS_SYM /* SQL-2011-N */ -%token PACKAGE_SYM /* Oracle-R */ -%token RAISE_SYM /* Oracle-PLSQL-R */ -%token ROWTYPE_SYM /* Oracle-PLSQL-R */ +%token BODY_MARIADB_SYM // Oracle-R +%token ELSIF_MARIADB_SYM // PLSQL-R +%token EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R +%token GOTO_MARIADB_SYM // Oracle-R +%token OTHERS_MARIADB_SYM // SQL-2011-N, PLSQL-R +%token PACKAGE_MARIADB_SYM // Oracle-R +%token RAISE_MARIADB_SYM // PLSQL-R +%token ROWTYPE_MARIADB_SYM // PLSQL-R /* Non-reserved keywords @@ -637,7 +647,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token AVG_ROW_LENGTH %token AVG_SYM /* SQL-2003-N */ %token BACKUP_SYM -%token BEGIN_SYM /* SQL-2003-R, PLSQL-R */ +%token BEGIN_MARIADB_SYM /* SQL-2003-R, PLSQL-R */ +%token BEGIN_ORACLE_SYM /* SQL-2003-R, PLSQL-R */ %token BINLOG_SYM %token BIT_SYM /* MYSQL-FUNC */ %token BLOCK_SYM @@ -727,8 +738,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token EXAMINED_SYM %token EXCLUDE_SYM /* SQL-2011-N */ %token EXECUTE_SYM /* SQL-2003-R */ -%token EXCEPTION_SYM /* SQL-2003-N, Oracle-PLSQL-R */ -%token EXIT_SYM +%token EXCEPTION_MARIADB_SYM /* SQL-2003-N, PLSQL-R */ +%token EXIT_MARIADB_SYM /* PLSQL-R */ +%token EXIT_ORACLE_SYM /* PLSQL-R */ %token EXPANSION_SYM %token EXPORT_SYM %token EXTENDED_SYM @@ -745,7 +757,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FORMAT_SYM %token FOUND_SYM /* SQL-2003-R */ %token FULL /* SQL-2003-R */ -%token FUNCTION_SYM /* SQL-2003-R, Oracle-PLSQL-R */ +%token FUNCTION_SYM /* SQL-2003-R, Oracle-R */ %token GENERAL %token GENERATED_SYM %token GEOMETRYCOLLECTION @@ -1087,7 +1099,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT TIMESTAMP '2001-01-01 10:20:30'; SELECT * FROM t1 FOR SYSTEM_TIME AS OF TIMESTAMP CONCAT(@date,' ',@time); - - PERIOD: identifier, period for sytem time: + - PERIOD: identifier, period for system time: SELECT period FROM t1; ALTER TABLE DROP PERIOD FOR SYSTEM TIME; @@ -1099,7 +1111,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); SELECT user FROM t1; KILL USER foo; - Note, we need here only tokens that cause shirt/reduce conflicts + Note, we need here only tokens that cause shift/reduce conflicts with keyword identifiers. For example: opt_clause1: %empty | KEYWORD ... ; clause2: opt_clause1 ident; @@ -1452,7 +1464,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); query verb_clause create change select do drop insert replace insert2 insert_values update delete truncate rename compound_statement show describe load alter optimize keycache preload flush - reset purge commit rollback savepoint release + reset purge begin_stmt_mariadb commit rollback savepoint release slave master_def master_defs master_file_def slave_until_opts repair analyze opt_with_admin opt_with_admin_option analyze_table_list analyze_table_elem_spec @@ -1465,8 +1477,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); assign_to_keycache_parts preload_list preload_list_or_parts preload_keys preload_keys_parts select_item_list select_item values_list no_braces - no_braces_with_names opt_values_with_names values_with_names opt_limit_clause delete_limit_clause fields opt_values values + no_braces_with_names opt_values_with_names values_with_names procedure_list procedure_list2 procedure_item field_def handler opt_generated_always opt_ignore opt_column opt_restrict @@ -1527,11 +1539,11 @@ END_OF_INPUT %type sp_labeled_control sp_unlabeled_control %type sp_labeled_block sp_unlabeled_block %type sp_labelable_stmt -%type sp_proc_stmt_continue -%type sp_proc_stmt_exit +%type sp_proc_stmt_continue_oracle +%type sp_proc_stmt_exit_oracle %type sp_proc_stmt_leave %type sp_proc_stmt_iterate -%type sp_proc_stmt_goto +%type sp_proc_stmt_goto_oracle %type sp_proc_stmt_open sp_proc_stmt_fetch sp_proc_stmt_close %type case_stmt_specification %type loop_body while_body repeat_body @@ -1571,7 +1583,7 @@ END_OF_INPUT %type index_hint_clause normal_join inner_join %type data_or_xml -%type signal_stmt resignal_stmt raise_stmt +%type signal_stmt resignal_stmt raise_stmt_oracle %type signal_condition_information_item_name %type trigger_follows_precedes_clause; @@ -1685,6 +1697,7 @@ opt_end_of_input: verb_clause: statement + | begin_stmt_mariadb | compound_statement ; @@ -1724,7 +1737,7 @@ statement: | preload | prepare | purge - | raise_stmt + | raise_stmt_oracle | release | rename | repair @@ -2305,7 +2318,7 @@ create: | create_or_replace { Lex->set_command(SQLCOM_CREATE_SERVER, $1); } server_def { } - | create_or_replace definer_opt PACKAGE_SYM + | create_or_replace definer_opt PACKAGE_ORACLE_SYM opt_if_not_exists sp_name opt_create_package_chistics_init sp_tail_is remember_name @@ -2325,7 +2338,7 @@ create: if (unlikely(Lex->create_package_finalize(thd, $5, $13, $8, $12))) MYSQL_YYABORT; } - | create_or_replace definer_opt PACKAGE_SYM BODY_SYM + | create_or_replace definer_opt PACKAGE_ORACLE_SYM BODY_ORACLE_SYM opt_if_not_exists sp_name opt_create_package_chistics_init sp_tail_is remember_name @@ -2365,11 +2378,11 @@ package_implementation_executable_section: MYSQL_YYABORT; $$.init(0); } - | BEGIN_SYM sp_block_statements_and_exceptions END { $$= $2; } + | BEGIN_ORACLE_SYM sp_block_statements_and_exceptions END { $$= $2; } ; /* - Inside CREATE PACKATE BODY, package-wide items (e.g. variables) + Inside CREATE PACKAGE BODY, package-wide items (e.g. variables) must be declared before routine definitions. */ package_implementation_declare_section: @@ -3054,12 +3067,12 @@ sp_param_name_and_type: if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $$= $1, $2, $4, $6))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '%' ROWTYPE_SYM + | sp_param_name sp_decl_ident '%' ROWTYPE_ORACLE_SYM { if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $2))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '.' ident '%' ROWTYPE_SYM + | sp_param_name sp_decl_ident '.' ident '%' ROWTYPE_ORACLE_SYM { if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $2, $4))) MYSQL_YYABORT; @@ -3101,13 +3114,13 @@ sp_pdparam: if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $1, $3, $5, $7))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '%' ROWTYPE_SYM + | sp_param_name sp_opt_inout sp_decl_ident '%' ROWTYPE_ORACLE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $1, $3))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '.' ident '%' ROWTYPE_SYM + | sp_param_name sp_opt_inout sp_decl_ident '.' ident '%' ROWTYPE_ORACLE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $1, $3, $5))) @@ -3320,7 +3333,7 @@ sp_decl_vars: $$.init_using_vars($1); } | sp_decl_idents_init_vars - optionally_qualified_column_ident '%' ROWTYPE_SYM + optionally_qualified_column_ident '%' ROWTYPE_ORACLE_SYM sp_opt_default { if (unlikely(Lex->sp_variable_declarations_rowtype_finalize(thd, $1, $2, $5))) @@ -3346,7 +3359,7 @@ sp_decl_non_handler: $$.vars= $$.hndlrs= $$.curs= 0; $$.conds= 1; } - | ident_directly_assignable EXCEPTION_SYM + | ident_directly_assignable EXCEPTION_ORACLE_SYM { sp_condition_value *spcond= new (thd->mem_root) sp_condition_value_user_defined(); @@ -3420,8 +3433,10 @@ sp_cursor_stmt: ; sp_handler_type: - EXIT_SYM { $$= sp_handler::EXIT; } - | CONTINUE_SYM { $$= sp_handler::CONTINUE; } + EXIT_MARIADB_SYM { $$= sp_handler::EXIT; } + | CONTINUE_MARIADB_SYM { $$= sp_handler::CONTINUE; } + | EXIT_ORACLE_SYM { $$= sp_handler::EXIT; } + | CONTINUE_ORACLE_SYM { $$= sp_handler::CONTINUE; } /*| UNDO_SYM { QQ No yet } */ ; @@ -3491,7 +3506,7 @@ sp_hcond: } | ident /* CONDITION name */ { - $$= Lex->spcont->find_declared_or_predefined_condition(&$1); + $$= Lex->spcont->find_declared_or_predefined_condition(thd, &$1); if (unlikely($$ == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); } @@ -3507,7 +3522,13 @@ sp_hcond: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | OTHERS_SYM /* All other SQLSTATEs */ + | SQLEXCEPTION_SYM /* All other SQLSTATEs */ + { + $$= new (thd->mem_root) sp_condition_value(sp_condition_value::EXCEPTION); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + | OTHERS_ORACLE_SYM /* All other SQLSTATEs */ { $$= new (thd->mem_root) sp_condition_value(sp_condition_value::EXCEPTION); if (unlikely($$ == NULL)) @@ -3516,13 +3537,13 @@ sp_hcond: ; -raise_stmt: - RAISE_SYM opt_set_signal_information +raise_stmt_oracle: + RAISE_ORACLE_SYM opt_set_signal_information { if (unlikely(Lex->add_resignal_statement(thd, NULL))) MYSQL_YYABORT; } - | RAISE_SYM signal_value opt_set_signal_information + | RAISE_ORACLE_SYM signal_value opt_set_signal_information { if (unlikely(Lex->add_signal_statement(thd, $2))) MYSQL_YYABORT; @@ -3546,7 +3567,7 @@ signal_value: /* SIGNAL foo cannot be used outside of stored programs */ if (unlikely(lex->spcont == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); - cond= lex->spcont->find_declared_or_predefined_condition(&$1); + cond= lex->spcont->find_declared_or_predefined_condition(thd, &$1); if (unlikely(cond == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); if (unlikely(!cond->has_sql_state())) @@ -3855,11 +3876,11 @@ sp_proc_stmt: sp_labelable_stmt: sp_proc_stmt_statement - | sp_proc_stmt_continue - | sp_proc_stmt_exit + | sp_proc_stmt_continue_oracle + | sp_proc_stmt_exit_oracle | sp_proc_stmt_leave | sp_proc_stmt_iterate - | sp_proc_stmt_goto + | sp_proc_stmt_goto_oracle | sp_proc_stmt_open | sp_proc_stmt_fetch | sp_proc_stmt_close @@ -3956,8 +3977,14 @@ sp_proc_stmt_statement: } ; + +RETURN_ALLMODES_SYM: + RETURN_MARIADB_SYM + | RETURN_ORACLE_SYM + ; + sp_proc_stmt_return: - RETURN_SYM + RETURN_ALLMODES_SYM { Lex->sphead->reset_lex(thd); } expr { @@ -3968,7 +3995,7 @@ sp_proc_stmt_return: unlikely(sp->restore_lex(thd))) MYSQL_YYABORT; } - | RETURN_SYM + | RETURN_ORACLE_SYM { LEX *lex= Lex; sp_head *sp= lex->sphead; @@ -3982,24 +4009,24 @@ reset_lex_expr: { Lex->sphead->reset_lex(thd); } expr { $$= $2; } ; -sp_proc_stmt_exit: - EXIT_SYM +sp_proc_stmt_exit_oracle: + EXIT_ORACLE_SYM { if (unlikely(Lex->sp_exit_statement(thd, NULL))) MYSQL_YYABORT; } - | EXIT_SYM label_ident + | EXIT_ORACLE_SYM label_ident { if (unlikely(Lex->sp_exit_statement(thd, &$2, NULL))) MYSQL_YYABORT; } - | EXIT_SYM WHEN_SYM reset_lex_expr + | EXIT_ORACLE_SYM WHEN_SYM reset_lex_expr { if (unlikely(Lex->sp_exit_statement(thd, $3)) || unlikely(Lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } - | EXIT_SYM label_ident WHEN_SYM reset_lex_expr + | EXIT_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr { if (unlikely(Lex->sp_exit_statement(thd, &$2, $4)) || unlikely(Lex->sphead->restore_lex(thd))) @@ -4007,24 +4034,24 @@ sp_proc_stmt_exit: } ; -sp_proc_stmt_continue: - CONTINUE_SYM +sp_proc_stmt_continue_oracle: + CONTINUE_ORACLE_SYM { if (unlikely(Lex->sp_continue_statement(thd, NULL))) MYSQL_YYABORT; } - | CONTINUE_SYM label_ident + | CONTINUE_ORACLE_SYM label_ident { if (unlikely(Lex->sp_continue_statement(thd, &$2, NULL))) MYSQL_YYABORT; } - | CONTINUE_SYM WHEN_SYM reset_lex_expr + | CONTINUE_ORACLE_SYM WHEN_SYM reset_lex_expr { if (unlikely(Lex->sp_continue_statement(thd, $3)) || unlikely(Lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } - | CONTINUE_SYM label_ident WHEN_SYM reset_lex_expr + | CONTINUE_ORACLE_SYM label_ident WHEN_SYM reset_lex_expr { if (unlikely(Lex->sp_continue_statement(thd, &$2, $4)) || unlikely(Lex->sphead->restore_lex(thd))) @@ -4049,8 +4076,8 @@ sp_proc_stmt_iterate: } ; -sp_proc_stmt_goto: - GOTO_SYM label_ident +sp_proc_stmt_goto_oracle: + GOTO_ORACLE_SYM label_ident { if (unlikely(Lex->sp_goto_statement(thd, &$2))) MYSQL_YYABORT; @@ -4245,7 +4272,7 @@ sp_if: sp_elseifs: /* Empty */ - | ELSIF_SYM sp_if + | ELSIF_ORACLE_SYM sp_if | ELSE sp_proc_stmts1_implicit_block ; @@ -4421,7 +4448,7 @@ sp_block_label: sp_labeled_block: sp_block_label - BEGIN_SYM + BEGIN_ORACLE_SYM { Lex->sp_block_init(thd, &$1); if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) @@ -4444,7 +4471,7 @@ sp_labeled_block: if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) MYSQL_YYABORT; } - BEGIN_SYM + BEGIN_ORACLE_SYM sp_block_statements_and_exceptions END sp_opt_label @@ -4461,7 +4488,7 @@ opt_not_atomic: ; sp_unlabeled_block: - BEGIN_SYM opt_not_atomic + BEGIN_ORACLE_SYM opt_not_atomic { if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; @@ -4486,7 +4513,7 @@ sp_unlabeled_block: if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) MYSQL_YYABORT; } - BEGIN_SYM + BEGIN_ORACLE_SYM sp_block_statements_and_exceptions END { @@ -4509,7 +4536,7 @@ sp_body: if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) MYSQL_YYABORT; } - BEGIN_SYM + BEGIN_ORACLE_SYM sp_block_statements_and_exceptions { $2.hndlrs+= $5.hndlrs; @@ -4535,8 +4562,8 @@ sp_block_statements_and_exceptions: ; opt_exception_clause: - /* Empty */ { $$= 0; } - | EXCEPTION_SYM exception_handlers { $$= $2; } + /* Empty */ { $$= 0; } + | EXCEPTION_ORACLE_SYM exception_handlers { $$= $2; } ; exception_handlers: @@ -12632,7 +12659,9 @@ opt_window_frame_exclusion: { $$= Window_frame::EXCL_GROUP; } | EXCLUDE_SYM TIES_SYM { $$= Window_frame::EXCL_TIES; } - | EXCLUDE_SYM NO_SYM OTHERS_SYM + | EXCLUDE_SYM NO_SYM OTHERS_MARIADB_SYM + { $$= Window_frame::EXCL_NONE; } + | EXCLUDE_SYM NO_SYM OTHERS_ORACLE_SYM { $$= Window_frame::EXCL_NONE; } ; @@ -13127,7 +13156,7 @@ drop: lex->set_command(SQLCOM_DROP_DB, $3); lex->name= $4; } - | DROP PACKAGE_SYM opt_if_exists sp_name + | DROP PACKAGE_ORACLE_SYM opt_if_exists sp_name { LEX *lex= Lex; lex->set_command(SQLCOM_DROP_PACKAGE, $3); @@ -13135,7 +13164,7 @@ drop: my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PACKAGE")); lex->spname= $4; } - | DROP PACKAGE_SYM BODY_SYM opt_if_exists sp_name + | DROP PACKAGE_ORACLE_SYM BODY_ORACLE_SYM opt_if_exists sp_name { LEX *lex= Lex; lex->set_command(SQLCOM_DROP_PACKAGE_BODY, $4); @@ -14144,13 +14173,13 @@ show_param: lex->sql_command = SQLCOM_SHOW_CREATE_FUNC; lex->spname= $3; } - | CREATE PACKAGE_SYM sp_name + | CREATE PACKAGE_ORACLE_SYM sp_name { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE_PACKAGE; lex->spname= $3; } - | CREATE PACKAGE_SYM BODY_SYM sp_name + | CREATE PACKAGE_ORACLE_SYM BODY_ORACLE_SYM sp_name { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE_PACKAGE_BODY; @@ -14189,14 +14218,14 @@ show_param: if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } - | PACKAGE_SYM STATUS_SYM wild_and_where + | PACKAGE_ORACLE_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE; if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } - | PACKAGE_SYM BODY_SYM STATUS_SYM wild_and_where + | PACKAGE_ORACLE_SYM BODY_ORACLE_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE_BODY; @@ -14213,7 +14242,7 @@ show_param: Lex->sql_command= SQLCOM_SHOW_FUNC_CODE; Lex->spname= $3; } - | PACKAGE_SYM BODY_SYM CODE_SYM sp_name + | PACKAGE_ORACLE_SYM BODY_ORACLE_SYM CODE_SYM sp_name { Lex->sql_command= SQLCOM_SHOW_PACKAGE_BODY_CODE; Lex->spname= $4; @@ -15680,6 +15709,7 @@ keyword_sp_var_not_label: | INSTALL_SYM | OPTION | OPTIONS_SYM + | OTHERS_MARIADB_SYM | OWNER_SYM | PARSER_SYM | PERIOD_SYM @@ -15783,8 +15813,8 @@ keyword_verb_clause: Keywords that start an SP block section. */ keyword_sp_block_section: - BEGIN_SYM - | EXCEPTION_SYM + BEGIN_ORACLE_SYM + | EXCEPTION_ORACLE_SYM | END ; @@ -15855,6 +15885,7 @@ keyword_sp_var_and_label: | AVG_ROW_LENGTH | AVG_SYM | BLOCK_SYM + | BODY_MARIADB_SYM | BTREE_SYM | CASCADED | CATALOG_NAME_SYM @@ -15906,6 +15937,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM + | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM | ENGINES_SYM @@ -15915,7 +15947,7 @@ keyword_sp_var_and_label: | EVENT_SYM | EVENTS_SYM | EVERY_SYM - + | EXCEPTION_MARIADB_SYM | EXCHANGE_SYM | EXPANSION_SYM | EXPORT_SYM @@ -15932,6 +15964,7 @@ keyword_sp_var_and_label: | GENERATED_SYM | GET_FORMAT | GRANTS + | GOTO_MARIADB_SYM | HASH_SYM | HARD_SYM | HOSTS_SYM @@ -16025,7 +16058,7 @@ keyword_sp_var_and_label: | ONE_SYM | ONLINE_SYM | ONLY_SYM - + | PACKAGE_MARIADB_SYM | PACK_KEYS_SYM | PAGE_SYM | PARTIAL @@ -16048,7 +16081,7 @@ keyword_sp_var_and_label: | QUARTER_SYM | QUERY_SYM | QUICK - + | RAISE_MARIADB_SYM | READ_ONLY_SYM | REBUILD_SYM | RECOVER_SYM @@ -16075,6 +16108,7 @@ keyword_sp_var_and_label: | ROLLUP_SYM | ROUTINE_SYM | ROWCOUNT_SYM + | ROWTYPE_MARIADB_SYM | ROW_COUNT_SYM | ROW_FORMAT_SYM | RTREE_SYM @@ -16801,13 +16835,15 @@ revoke_command: TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } - | grant_privileges ON PACKAGE_SYM grant_ident FROM user_and_role_list + | grant_privileges ON PACKAGE_ORACLE_SYM grant_ident + FROM user_and_role_list { if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, TYPE_ENUM_PACKAGE))) MYSQL_YYABORT; } - | grant_privileges ON PACKAGE_SYM BODY_SYM grant_ident FROM user_and_role_list + | grant_privileges ON PACKAGE_ORACLE_SYM BODY_ORACLE_SYM grant_ident + FROM user_and_role_list { if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, TYPE_ENUM_PACKAGE_BODY))) @@ -16866,14 +16902,14 @@ grant_command: TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } - | grant_privileges ON PACKAGE_SYM grant_ident TO_SYM grant_list + | grant_privileges ON PACKAGE_ORACLE_SYM grant_ident TO_SYM grant_list opt_require_clause opt_grant_options { if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, TYPE_ENUM_PACKAGE))) MYSQL_YYABORT; } - | grant_privileges ON PACKAGE_SYM BODY_SYM grant_ident TO_SYM grant_list + | grant_privileges ON PACKAGE_ORACLE_SYM BODY_ORACLE_SYM grant_ident TO_SYM grant_list opt_require_clause opt_grant_options { if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, @@ -17291,6 +17327,16 @@ grant_option: | resource_option {} ; +begin_stmt_mariadb: + BEGIN_MARIADB_SYM + { + LEX *lex=Lex; + lex->sql_command = SQLCOM_BEGIN; + lex->start_transaction_opt= 0; + } + opt_work {} + ; + compound_statement: sp_proc_stmt_compound_ok { @@ -17858,7 +17904,7 @@ udf_tail: sf_return_type: - RETURN_SYM + RETURN_ORACLE_SYM { LEX *lex= Lex; lex->init_last_field(&lex->sphead->m_return_field_def, @@ -18029,7 +18075,8 @@ xid: ; begin_or_start: - BEGIN_SYM {} + BEGIN_MARIADB_SYM {} + | BEGIN_ORACLE_SYM {} | START_SYM {} ; From 5cfb043d2919439fccfa350edd9a3fdb4aaf229b Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 9 Nov 2018 22:55:34 +0400 Subject: [PATCH 11/50] MDEV-16174 Assertion `0' failed in Type_handler_string_result::make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) maybe_null should be always set to TRUE in Item_func_json_array_append::fix_length_and_dec() --- mysql-test/r/func_json.result | 14 ++++++++++++++ mysql-test/t/func_json.test | 13 +++++++++++++ sql/item_jsonfunc.cc | 1 + 3 files changed, 28 insertions(+) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index c828b2676b4..90458bcaa4e 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -810,3 +810,17 @@ SET @`json` := NULL, @`value` := NULL; SELECT JSON_MERGE('[1]', '[]'); JSON_MERGE('[1]', '[]') [1] +# +# MDEV-16174 Assertion `0' failed in Type_handler_string_result:: +# make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) +# +SET sql_mode=''; +CREATE TABLE t1 (fld varchar(16) NOT NULL); +CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `JSON_ARRAY_INSERT(fld, '$.[0]', '0')` varchar(25) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +SET sql_mode=default; diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 1dc16419cfd..d266641e3d2 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -468,3 +468,16 @@ SET @`json` := NULL, @`value` := NULL; --echo # SELECT JSON_MERGE('[1]', '[]'); + +--echo # +--echo # MDEV-16174 Assertion `0' failed in Type_handler_string_result:: +--echo # make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) +--echo # + +SET sql_mode=''; +CREATE TABLE t1 (fld varchar(16) NOT NULL); +CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; +SET sql_mode=default; + diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 60726050aca..27bc97f4c5e 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1562,6 +1562,7 @@ bool Item_func_json_array_append::fix_length_and_dec() } fix_char_length_ulonglong(char_length); + maybe_null= 1; return FALSE; } From a12b8ac8e9636f8258bcb17a0845b9317d870fd9 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Fri, 9 Nov 2018 19:53:40 +0530 Subject: [PATCH 12/50] MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free or Invalid write in JOIN::make_aggr_tables_info During the optimize state of a query, we come know that the result set would atmost contain one row, then for such a query we don't need to compute GROUP BY, ORDER BY and DISTINCT. --- mysql-test/r/distinct.result | 20 ++++++++++++ mysql-test/r/group_by.result | 10 ++++++ mysql-test/r/win.result | 62 ++++++++++++++++++++++++++++++++++++ mysql-test/t/distinct.test | 18 +++++++++++ mysql-test/t/group_by.test | 12 +++++++ mysql-test/t/win.test | 56 ++++++++++++++++++++++++++++++++ sql/sql_select.cc | 12 +++++++ 7 files changed, 190 insertions(+) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index e1bbf5adb79..850ce9a1965 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -1049,4 +1049,24 @@ b1+'0' b2+'0' b3+'0' b4+'0' b5+'0' b6 +'0' 1 0 0 1 0 1 0 1 0 0 1 0 DROP TABLE t1; +# +# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free +# or Invalid write in JOIN::make_aggr_tables_info +# +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +explain +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ) +UNION +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary +2 UNION t1 index NULL PRIMARY 4 NULL 2 Using index; Using temporary +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ) +UNION +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ); +1 +1 +drop table t1; End of 5.5 tests diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 9fee03877c5..9da6fa5ae8f 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2832,3 +2832,13 @@ select distinct 1 from t1 group by a,b with rollup limit 1; 1 1 drop table t1; +CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1)); +explain +SELECT 1 FROM t1 +GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +SELECT 1 FROM t1 +GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; +1 +drop table t1; diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 790b264fc09..c539ac4f252 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3361,3 +3361,65 @@ Esben Tuning 31 68.7500 Kaolin Tuning 88 68.7500 Tatiana Tuning 83 68.7500 drop table t1; +# +# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free +# or Invalid write in JOIN::make_aggr_tables_info +# +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) order by 1+2; +BIT_OR(100) OVER () +100 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM ( +SELECT +ROW_NUMBER() OVER(), i, sum(i) +FROM t1 +WHERE 1=0 +limit 0 +) AS sq; +ROW_NUMBER() OVER() i sum(i) +SELECT * FROM ( +SELECT +ROW_NUMBER() OVER(), i, sum(i) +FROM t1 +WHERE 1=0 +GROUP BY i +) AS sq; +ROW_NUMBER() OVER() i sum(i) +drop table t1; +create table t1 (a int); +explain +select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup; +1 row_number() over (order by 1) +drop table t1; +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP +HAVING @A := 'qwerty'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP +HAVING @A := 'qwerty'; +BIT_OR(100) OVER () +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) +HAVING @A := 'qwerty'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) +HAVING @A := 'qwerty'; +BIT_OR(100) OVER () +create table t1 (a int); +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM t1 +GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit +drop table t1; diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index c11f8b501bc..d41340c29fd 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -798,4 +798,22 @@ CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT); INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0); SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free +--echo # or Invalid write in JOIN::make_aggr_tables_info +--echo # + +CREATE TABLE t1 (pk INT PRIMARY KEY); +INSERT INTO t1 VALUES (1),(2); +explain +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ) +UNION +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ); + +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ) +UNION +( SELECT DISTINCT 1 FROM t1 ORDER BY BENCHMARK(1, MIN(pk)) ); +drop table t1; + --echo End of 5.5 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 275939df5c5..61be676bb11 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1948,3 +1948,15 @@ insert into t1 values(-126,7),(1,1),(0,0),(-1,1),(351,65534); select distinct 1 from t1 group by a,b with rollup limit 1; drop table t1; +# +# MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free +# or Invalid write in JOIN::make_aggr_tables_info +# + +CREATE TABLE t1 ( pk int, i1 int, v1 varchar(1)); +explain +SELECT 1 FROM t1 +GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; +SELECT 1 FROM t1 +GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; +drop table t1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index e9c8ee05773..7dda2b6215f 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2119,3 +2119,59 @@ SELECT name, test, score, FROM t1 ORDER BY test, name; drop table t1; + +--echo # +--echo # MDEV-12575: Server crash in AGGR_OP::put_record or in JOIN_CACHE::free +--echo # or Invalid write in JOIN::make_aggr_tables_info +--echo # + +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) order by 1+2; + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); + +SELECT * FROM ( + SELECT + ROW_NUMBER() OVER(), i, sum(i) + FROM t1 + WHERE 1=0 + limit 0 +) AS sq; + +SELECT * FROM ( + SELECT + ROW_NUMBER() OVER(), i, sum(i) + FROM t1 + WHERE 1=0 + GROUP BY i +) AS sq; +drop table t1; + +create table t1 (a int); +explain +select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup; +select distinct 1, row_number() over (order by 1) from t1 where a=0 group by a with rollup; +drop table t1; + +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP +HAVING @A := 'qwerty'; +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) WITH ROLLUP +HAVING @A := 'qwerty'; + +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) +HAVING @A := 'qwerty'; +SELECT DISTINCT BIT_OR(100) OVER () FROM dual +GROUP BY LEFT('2018-08-24', 100) +HAVING @A := 'qwerty'; + +create table t1 (a int); +explain +SELECT DISTINCT BIT_OR(100) OVER () FROM t1 +GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0; +drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0cdecf1bf2e..db3ed8a1aa9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2245,6 +2245,18 @@ setup_subq_exit: if (!tables_list || !table_count) { choose_tableless_subquery_plan(); + + /* The output has atmost one row */ + if (group_list) + { + group_list= NULL; + group_optimized_away= 1; + rollup.state= ROLLUP::STATE_NONE; + } + order= NULL; + simple_order= TRUE; + select_distinct= FALSE; + if (select_lex->have_window_funcs()) { if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)))) From 8e6f10335d2c6afb1d34e99af6e1ee49b6e4a875 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 10 Nov 2018 23:11:34 +0400 Subject: [PATCH 13/50] A join patch for MDEV-17660 and MDEV-17661 MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without MDEV-17661 Add sql_mode specific tokens for the keyword DECODE --- .../suite/compat/oracle/r/parser.result | 33 ++++++++++ mysql-test/suite/compat/oracle/t/parser.test | 58 +++++++++++++++++ sql/lex.h | 2 +- sql/sql_lex.cc | 1 + sql/sql_yacc.yy | 34 +++++++++- sql/sql_yacc_ora.yy | 64 +++++++++++-------- 6 files changed, 160 insertions(+), 32 deletions(-) diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index c8600c29bd4..4ee34e5e2b3 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -499,3 +499,36 @@ test.comment() Warnings: Note 1585 This function 'comment' has the same name as a native function DROP FUNCTION comment; +# +# MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without +# +BEGIN +<> +NULL; +END; +/ +BEGIN +<> +NULL; +END; +/ +BEGIN +<> +NULL; +END; +/ +BEGIN +<> +NULL; +END; +/ +BEGIN +<> +NULL; +END; +/ +BEGIN +<> +NULL; +END; +/ diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index 86b6b270ccd..b3387b3f922 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -258,3 +258,61 @@ enable_prepare_warnings; SELECT test.comment() FROM DUAL; disable_prepare_warnings; DROP FUNCTION comment; + + +--echo # +--echo # MDEV-17660 sql_mode=ORACLE: Some keywords do not work as label names: history, system, versioning, without +--echo # + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ diff --git a/sql/lex.h b/sql/lex.h index d3878186696..707bd464a14 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -739,7 +739,7 @@ static SYMBOL sql_functions[] = { { "DATE_ADD", SYM(DATE_ADD_INTERVAL)}, { "DATE_SUB", SYM(DATE_SUB_INTERVAL)}, { "DATE_FORMAT", SYM(DATE_FORMAT_SYM)}, - { "DECODE", SYM(DECODE_SYM)}, + { "DECODE", SYM(DECODE_MARIADB_SYM)}, { "DENSE_RANK", SYM(DENSE_RANK_SYM)}, { "EXTRACT", SYM(EXTRACT_SYM)}, { "FIRST_VALUE", SYM(FIRST_VALUE_SYM)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index cab5381e0ed..a80c6485cf0 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -844,6 +844,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM; case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; + case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM; case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM; case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 745dc5664dc..3b694a9cc81 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1314,7 +1314,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */ %token DAY_SYM /* SQL-2003-R */ %token DEALLOCATE_SYM /* SQL-2003-R */ -%token DECODE_SYM /* Oracle function, non-reserved */ +%token DECODE_MARIADB_SYM /* Function, non-reserved */ +%token DECODE_ORACLE_SYM /* Function, non-reserved */ %token DEFINER_SYM %token DELAYED_SYM %token DELAY_KEY_WRITE_SYM @@ -1961,6 +1962,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else ident_list ident_list_arg opt_expr_list + decode_when_list_oracle %type sp_cursor_stmt_lex @@ -10538,12 +10540,18 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | DECODE_SYM '(' expr ',' expr ')' + | DECODE_MARIADB_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_decode(thd, $3, $5); if (unlikely($$ == NULL)) MYSQL_YYABORT; } + | DECODE_ORACLE_SYM '(' expr ',' decode_when_list_oracle ')' + { + $5->push_front($3, thd->mem_root); + if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5)))) + MYSQL_YYABORT; + } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new (thd->mem_root) Item_extract(thd, $3, $5); @@ -11701,6 +11709,25 @@ when_list_opt_else: } ; +decode_when_list_oracle: + expr ',' expr + { + $$= new (thd->mem_root) List; + if (unlikely($$ == NULL) || + unlikely($$->push_back($1, thd->mem_root)) || + unlikely($$->push_back($3, thd->mem_root))) + MYSQL_YYABORT; + + } + | decode_when_list_oracle ',' expr + { + $$= $1; + if (unlikely($$->push_back($3, thd->mem_root))) + MYSQL_YYABORT; + } + ; + + /* Equivalent to in the SQL:2003 standard. */ /* Warning - may return NULL in case of incomplete SELECT */ table_ref: @@ -15801,7 +15828,8 @@ keyword_sp_var_and_label: | DATAFILE_SYM | DATE_FORMAT_SYM | DAY_SYM - | DECODE_SYM + | DECODE_MARIADB_SYM + | DECODE_ORACLE_SYM | DEFINER_SYM | DELAY_KEY_WRITE_SYM | DES_KEY_FILE diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 529582d8dc9..a58af90922c 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -708,7 +708,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */ %token DAY_SYM /* SQL-2003-R */ %token DEALLOCATE_SYM /* SQL-2003-R */ -%token DECODE_SYM /* Oracle function, non-reserved */ +%token DECODE_MARIADB_SYM /* Function, non-reserved */ +%token DECODE_ORACLE_SYM /* Function, non-reserved */ %token DEFINER_SYM %token DELAYED_SYM %token DELAY_KEY_WRITE_SYM @@ -1364,7 +1365,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type expr_list opt_udf_expr_list udf_expr_list when_list when_list_opt_else ident_list ident_list_arg opt_expr_list - decode_when_list + decode_when_list_oracle %type sp_cursor_stmt_lex @@ -10211,24 +10212,6 @@ column_default_non_parenthesized_expr: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | DATE_FORMAT_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DECODE_SYM '(' expr ',' decode_when_list ')' - { - $5->push_front($3, thd->mem_root); - if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5)))) - MYSQL_YYABORT; - } | DEFAULT '(' simple_ident ')' { Item_splocal *il= $3->get_item_splocal(); @@ -10565,6 +10548,30 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } + | DATE_FORMAT_SYM '(' expr ',' expr ')' + { + $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + | DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')' + { + $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + | DECODE_MARIADB_SYM '(' expr ',' expr ')' + { + $$= new (thd->mem_root) Item_func_decode(thd, $3, $5); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + | DECODE_ORACLE_SYM '(' expr ',' decode_when_list_oracle ')' + { + $5->push_front($3, thd->mem_root); + if (unlikely(!($$= new (thd->mem_root) Item_func_decode_oracle(thd, *$5)))) + MYSQL_YYABORT; + } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new (thd->mem_root) Item_extract(thd, $3, $5); @@ -11730,7 +11737,7 @@ when_list_opt_else: } ; -decode_when_list: +decode_when_list_oracle: expr ',' expr { $$= new (thd->mem_root) List; @@ -11740,7 +11747,7 @@ decode_when_list: MYSQL_YYABORT; } - | decode_when_list ',' expr + | decode_when_list_oracle ',' expr { $$= $1; if (unlikely($$->push_back($3, thd->mem_root))) @@ -15704,7 +15711,6 @@ keyword_sp_var_not_label: | FORMAT_SYM | GET_SYM | HELP_SYM - | HISTORY_SYM | HOST_SYM | INSTALL_SYM | OPTION @@ -15729,15 +15735,11 @@ keyword_sp_var_not_label: | START_SYM | STOP_SYM | STORED_SYM - | SYSTEM - | SYSTEM_TIME_SYM | TIES_SYM | UNICODE_SYM | UNINSTALL_SYM | UNBOUNDED_SYM - | VERSIONING_SYM | WITHIN - | WITHOUT | WRAPPER_SYM | XA_SYM | UPGRADE_SYM @@ -15925,7 +15927,8 @@ keyword_sp_var_and_label: | DATAFILE_SYM | DATE_FORMAT_SYM | DAY_SYM - | DECODE_SYM + | DECODE_MARIADB_SYM + | DECODE_ORACLE_SYM | DEFINER_SYM | DELAY_KEY_WRITE_SYM | DES_KEY_FILE @@ -15967,6 +15970,7 @@ keyword_sp_var_and_label: | GOTO_MARIADB_SYM | HASH_SYM | HARD_SYM + | HISTORY_SYM | HOSTS_SYM | HOUR_SYM | ID_SYM @@ -16144,6 +16148,8 @@ keyword_sp_var_and_label: | SUSPEND_SYM | SWAPS_SYM | SWITCHES_SYM + | SYSTEM + | SYSTEM_TIME_SYM | TABLE_NAME_SYM | TABLES | TABLE_CHECKSUM_SYM @@ -16169,6 +16175,7 @@ keyword_sp_var_and_label: | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | USE_FRM | VARIABLES + | VERSIONING_SYM | VIEW_SYM | VIRTUAL_SYM | VALUE_SYM @@ -16176,6 +16183,7 @@ keyword_sp_var_and_label: | WAIT_SYM | WEEK_SYM | WEIGHT_STRING_SYM + | WITHOUT | WORK_SYM | X509_SYM | XML_SYM From f5855ba03deef188516453b71e56d4239f74a653 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sun, 11 Nov 2018 09:35:05 +0400 Subject: [PATCH 14/50] MDEV-17664 Add sql_mode specific tokens for ':' and '%' --- sql/sql_lex.cc | 40 ++++++++++++++++- sql/sql_lex.h | 14 ++++++ sql/sql_yacc.yy | 74 ++++++++++++++++++++++++------- sql/sql_yacc_ora.yy | 105 +++++++++++++++++--------------------------- 4 files changed, 151 insertions(+), 82 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index a80c6485cf0..254889ac414 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1423,6 +1423,13 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd) } /* Fall through */ case MY_LEX_CHAR: // Unknown or single char token + { + if (c == '%' && (m_thd->variables.sql_mode & MODE_ORACLE)) + { + next_state= MY_LEX_START; + return PERCENT_ORACLE_SYM; + } + } case MY_LEX_SKIP: // This should not happen if (c != ')') next_state= MY_LEX_START; // Allow signed numbers @@ -1861,8 +1868,13 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd) case MY_LEX_SET_VAR: // Check if ':=' if (yyPeek() != '=') { - state= MY_LEX_CHAR; // Return ':' - break; + next_state= MY_LEX_START; + if (m_thd->variables.sql_mode & MODE_ORACLE) + { + yylval->kwd.set_keyword(m_tok_start, 1); + return COLON_ORACLE_SYM; + } + return (int) ':'; } yySkip(); return (SET_VAR); @@ -6655,6 +6667,30 @@ Item *LEX::make_item_colon_ident_ident(THD *thd, } +Item *LEX::make_item_plsql_cursor_attr(THD *thd, const LEX_CSTRING *name, + plsql_cursor_attr_t attr) +{ + uint offset; + if (unlikely(!spcont || !spcont->find_cursor(name, &offset, false))) + { + my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name->str); + return NULL; + } + switch (attr) { + case PLSQL_CURSOR_ATTR_ISOPEN: + return new (thd->mem_root) Item_func_cursor_isopen(thd, name, offset); + case PLSQL_CURSOR_ATTR_FOUND: + return new (thd->mem_root) Item_func_cursor_found(thd, name, offset); + case PLSQL_CURSOR_ATTR_NOTFOUND: + return new (thd->mem_root) Item_func_cursor_notfound(thd, name, offset); + case PLSQL_CURSOR_ATTR_ROWCOUNT: + return new (thd->mem_root) Item_func_cursor_rowcount(thd, name, offset); + } + DBUG_ASSERT(0); + return NULL; +} + + Item *LEX::make_item_sysvar(THD *thd, enum_var_type type, const LEX_CSTRING *name, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index ea2f61c3992..dbd201d2d7c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -182,6 +182,16 @@ enum enum_view_suid VIEW_SUID_DEFAULT= 2 }; + +enum plsql_cursor_attr_t +{ + PLSQL_CURSOR_ATTR_ISOPEN, + PLSQL_CURSOR_ATTR_FOUND, + PLSQL_CURSOR_ATTR_NOTFOUND, + PLSQL_CURSOR_ATTR_ROWCOUNT +}; + + /* These may not be declared yet */ class Table_ident; class sql_exchange; @@ -3642,6 +3652,10 @@ public: Item *make_item_colon_ident_ident(THD *thd, const Lex_ident_cli_st *a, const Lex_ident_cli_st *b); + // PLSQL: cursor%ISOPEN etc + Item *make_item_plsql_cursor_attr(THD *thd, const LEX_CSTRING *name, + plsql_cursor_attr_t attr); + // For "SELECT @@var", "SELECT @@var.field" Item *make_item_sysvar(THD *thd, enum_var_type type, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3b694a9cc81..8aea71b44ba 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -790,11 +790,6 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr) Lex_for_loop_st for_loop; Lex_for_loop_bounds_st for_loop_bounds; Lex_trim_st trim; - struct - { - LEX_CSTRING name; - uint offset; - } sp_cursor_name_and_offset; vers_history_point_t vers_history_point; /* pointers */ @@ -878,6 +873,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr) DDL_options_st object_ddl_options; enum vers_sys_type_t vers_range_unit; enum Column_definition::enum_column_versioning vers_column_versioning; + enum plsql_cursor_attr_t plsql_cursor_attr; } %{ @@ -1104,6 +1100,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PARAM_MARKER %token PARSE_VCOL_EXPR_SYM %token PARTITION_SYM /* SQL-2003-R */ +%token PERCENT_ORACLE_SYM /* INTERNAL */ %token PERCENT_RANK_SYM %token PERCENTILE_CONT_SYM %token PERCENTILE_DISC_SYM @@ -1278,6 +1275,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COALESCE /* SQL-2003-N */ %token CODE_SYM %token COLLATION_SYM /* SQL-2003-N */ +%token COLON_ORACLE_SYM /* INTERNAL */ %token COLUMNS %token COLUMN_ADD_SYM %token COLUMN_CHECK_SYM @@ -1933,7 +1931,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); geometry_function signed_literal expr_or_literal opt_escape sp_opt_default - simple_ident_nospvar simple_ident_q simple_ident_q2 + simple_ident_nospvar field_or_var limit_option part_func_expr window_func_expr @@ -1942,6 +1940,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); inverse_distribution_function percentile_function inverse_distribution_function_def + explicit_cursor_attr function_call_keyword function_call_keyword_timestamp function_call_nonkeyword @@ -2144,6 +2143,8 @@ END_OF_INPUT %type view_algorithm view_check_option %type view_suid opt_view_suid +%type plsql_cursor_attr + %type sp_decl_idents sp_decl_idents_init_vars %type sp_handler_type sp_hcond_list %type sp_cond sp_hcond sqlstate signal_value opt_signal_value @@ -10095,6 +10096,23 @@ dyncall_create_list: } ; + +plsql_cursor_attr: + ISOPEN_SYM { $$= PLSQL_CURSOR_ATTR_ISOPEN; } + | FOUND_SYM { $$= PLSQL_CURSOR_ATTR_FOUND; } + | NOTFOUND_SYM { $$= PLSQL_CURSOR_ATTR_NOTFOUND; } + | ROWCOUNT_SYM { $$= PLSQL_CURSOR_ATTR_ROWCOUNT; } + ; + +explicit_cursor_attr: + ident PERCENT_ORACLE_SYM plsql_cursor_attr + { + if (unlikely(!($$= Lex->make_item_plsql_cursor_attr(thd, &$1, $3)))) + MYSQL_YYABORT; + } + ; + + trim_operands: expr { $$.set(TRIM_BOTH, $1); } | LEADING expr FROM expr { $$.set(TRIM_LEADING, $2, $4); } @@ -10258,6 +10276,7 @@ column_default_non_parenthesized_expr: primary_expr: column_default_non_parenthesized_expr + | explicit_cursor_attr | '(' parenthesized_expr ')' { $$= $2; } ; @@ -10444,6 +10463,14 @@ function_call_keyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } + | SQL_SYM PERCENT_ORACLE_SYM ROWCOUNT_SYM + { + $$= new (thd->mem_root) Item_func_oracle_sql_rowcount(thd); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); + Lex->safe_to_cache_query= 0; + } | TIME_SYM '(' expr ')' { $$= new (thd->mem_root) Item_time_typecast(thd, $3, @@ -14956,6 +14983,19 @@ param_marker: YYLIP->get_tok_start() + 1)))) MYSQL_YYABORT; } + | COLON_ORACLE_SYM ident_cli + { + if (unlikely(!($$= Lex->add_placeholder(thd, &null_clex_str, + $1.pos(), $2.end())))) + MYSQL_YYABORT; + } + | COLON_ORACLE_SYM NUM + { + if (unlikely(!($$= Lex->add_placeholder(thd, &null_clex_str, + $1.pos(), + YYLIP->get_ptr())))) + MYSQL_YYABORT; + } ; signed_literal: @@ -15265,6 +15305,11 @@ simple_ident: if (unlikely(!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))) MYSQL_YYABORT; } + | COLON_ORACLE_SYM ident_cli '.' ident_cli + { + if (unlikely(!($$= Lex->make_item_colon_ident_ident(thd, &$2, &$4)))) + MYSQL_YYABORT; + } ; simple_ident_nospvar: @@ -15273,20 +15318,17 @@ simple_ident_nospvar: if (unlikely(!($$= Lex->create_item_ident_nosp(thd, &$1)))) MYSQL_YYABORT; } - | simple_ident_q { $$= $1; } - ; - -simple_ident_q: - ident '.' ident + | ident '.' ident { if (unlikely(!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3)))) MYSQL_YYABORT; } - | simple_ident_q2 - ; - -simple_ident_q2: - '.' ident '.' ident + | COLON_ORACLE_SYM ident_cli '.' ident_cli + { + if (unlikely(!($$= Lex->make_item_colon_ident_ident(thd, &$2, &$4)))) + MYSQL_YYABORT; + } + | '.' ident '.' ident { Lex_ident_sys none; if (unlikely(!($$= Lex->create_item_ident(thd, &none, &$2, &$4)))) diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index a58af90922c..e465e3a19b6 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -183,11 +183,6 @@ void ORAerror(THD *thd, const char *s) Lex_for_loop_st for_loop; Lex_for_loop_bounds_st for_loop_bounds; Lex_trim_st trim; - struct - { - LEX_CSTRING name; - uint offset; - } sp_cursor_name_and_offset; vers_history_point_t vers_history_point; /* pointers */ @@ -272,6 +267,7 @@ void ORAerror(THD *thd, const char *s) DDL_options_st object_ddl_options; enum vers_sys_type_t vers_range_unit; enum Column_definition::enum_column_versioning vers_column_versioning; + enum plsql_cursor_attr_t plsql_cursor_attr; } %{ @@ -498,6 +494,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PARAM_MARKER %token PARSE_VCOL_EXPR_SYM %token PARTITION_SYM /* SQL-2003-R */ +%token PERCENT_ORACLE_SYM /* INTERNAL */ %token PERCENT_RANK_SYM %token PERCENTILE_CONT_SYM %token PERCENTILE_DISC_SYM @@ -672,6 +669,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COALESCE /* SQL-2003-N */ %token CODE_SYM %token COLLATION_SYM /* SQL-2003-N */ +%token COLON_ORACLE_SYM /* INTERNAL */ %token COLUMNS %token COLUMN_ADD_SYM %token COLUMN_CHECK_SYM @@ -1081,7 +1079,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %left '&' %left SHIFT_LEFT SHIFT_RIGHT %left '-' '+' ORACLE_CONCAT_SYM -%left '*' '/' DIV_SYM MOD_SYM +%left '*' '/' '%' DIV_SYM MOD_SYM %left '^' %left MYSQL_CONCAT_SYM %left NEG '~' NOT2_SYM BINARY @@ -1242,7 +1240,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); remember_name remember_end remember_end_opt remember_tok_start remember_tok_end wild_and_where - colon_with_pos %type field_length opt_field_length opt_field_length_default_1 @@ -1551,6 +1548,8 @@ END_OF_INPUT %type view_algorithm view_check_option %type view_suid opt_view_suid + +%type plsql_cursor_attr %type sp_suid %type sp_decl_idents sp_decl_idents_init_vars @@ -1568,7 +1567,6 @@ END_OF_INPUT %type sp_block_statements_and_exceptions %type package_implementation_executable_section %type sp_instr_addr -%type sp_cursor_name_and_offset %type opt_exception_clause exception_handlers %type remember_lex package_routine_lex package_specification_function @@ -3058,22 +3056,22 @@ sp_param_name_and_type: if (unlikely(Lex->sp_param_fill_definition($$= $1))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '.' ident '%' TYPE_SYM + | sp_param_name sp_decl_ident '.' ident PERCENT_ORACLE_SYM TYPE_SYM { if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $$= $1, $2, $4))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '.' ident '.' ident '%' TYPE_SYM + | sp_param_name sp_decl_ident '.' ident '.' ident PERCENT_ORACLE_SYM TYPE_SYM { if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $$= $1, $2, $4, $6))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '%' ROWTYPE_ORACLE_SYM + | sp_param_name sp_decl_ident PERCENT_ORACLE_SYM ROWTYPE_ORACLE_SYM { if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $2))) MYSQL_YYABORT; } - | sp_param_name sp_decl_ident '.' ident '%' ROWTYPE_ORACLE_SYM + | sp_param_name sp_decl_ident '.' ident PERCENT_ORACLE_SYM ROWTYPE_ORACLE_SYM { if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $2, $4))) MYSQL_YYABORT; @@ -3103,25 +3101,25 @@ sp_pdparam: if (unlikely(Lex->sp_param_fill_definition($1))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '.' ident '%' TYPE_SYM + | sp_param_name sp_opt_inout sp_decl_ident '.' ident PERCENT_ORACLE_SYM TYPE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $1, $3, $5))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '.' ident '.' ident '%' TYPE_SYM + | sp_param_name sp_opt_inout sp_decl_ident '.' ident '.' ident PERCENT_ORACLE_SYM TYPE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $1, $3, $5, $7))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '%' ROWTYPE_ORACLE_SYM + | sp_param_name sp_opt_inout sp_decl_ident PERCENT_ORACLE_SYM ROWTYPE_ORACLE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $1, $3))) MYSQL_YYABORT; } - | sp_param_name sp_opt_inout sp_decl_ident '.' ident '%' ROWTYPE_ORACLE_SYM + | sp_param_name sp_opt_inout sp_decl_ident '.' ident PERCENT_ORACLE_SYM ROWTYPE_ORACLE_SYM { $1->mode= $2; if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $1, $3, $5))) @@ -3326,7 +3324,7 @@ sp_decl_vars: $$.init_using_vars($1); } | sp_decl_idents_init_vars - optionally_qualified_column_ident '%' TYPE_SYM + optionally_qualified_column_ident PERCENT_ORACLE_SYM TYPE_SYM sp_opt_default { if (unlikely(Lex->sp_variable_declarations_with_ref_finalize(thd, $1, $2, $5))) @@ -3334,7 +3332,7 @@ sp_decl_vars: $$.init_using_vars($1); } | sp_decl_idents_init_vars - optionally_qualified_column_ident '%' ROWTYPE_ORACLE_SYM + optionally_qualified_column_ident PERCENT_ORACLE_SYM ROWTYPE_ORACLE_SYM sp_opt_default { if (unlikely(Lex->sp_variable_declarations_rowtype_finalize(thd, $1, $2, $5))) @@ -9496,13 +9494,6 @@ select_item: } ; -colon_with_pos: - ':' - { - $$= (char *) YYLIP->get_tok_start(); - } - ; - remember_tok_start: { $$= (char*) YYLIP->get_tok_start(); @@ -9932,6 +9923,12 @@ bit_expr: if (unlikely($$ == NULL)) MYSQL_YYABORT; } + | bit_expr '%' bit_expr %prec '%' + { + $$= new (thd->mem_root) Item_func_mod(thd, $1, $3); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } | bit_expr DIV_SYM bit_expr %prec DIV_SYM { $$= new (thd->mem_root) Item_func_int_div(thd, $1, $3); @@ -10068,44 +10065,23 @@ dyncall_create_list: } ; -sp_cursor_name_and_offset: - ident - { - LEX *lex= Lex; - $$.name= $1; - if (unlikely(!lex->spcont || - !lex->spcont->find_cursor(&$1, &$$.offset, false))) - my_yyabort_error((ER_SP_CURSOR_MISMATCH, MYF(0), $1.str)); - } + +plsql_cursor_attr: + ISOPEN_SYM { $$= PLSQL_CURSOR_ATTR_ISOPEN; } + | FOUND_SYM { $$= PLSQL_CURSOR_ATTR_FOUND; } + | NOTFOUND_SYM { $$= PLSQL_CURSOR_ATTR_NOTFOUND; } + | ROWCOUNT_SYM { $$= PLSQL_CURSOR_ATTR_ROWCOUNT; } ; explicit_cursor_attr: - sp_cursor_name_and_offset '%' ISOPEN_SYM + ident PERCENT_ORACLE_SYM plsql_cursor_attr { - if (unlikely(!($$= new (thd->mem_root) - Item_func_cursor_isopen(thd, &$1.name, $1.offset)))) - MYSQL_YYABORT; - } - | sp_cursor_name_and_offset '%' FOUND_SYM - { - if (unlikely(!($$= new (thd->mem_root) - Item_func_cursor_found(thd, &$1.name, $1.offset)))) - MYSQL_YYABORT; - } - | sp_cursor_name_and_offset '%' NOTFOUND_SYM - { - if (unlikely(!($$= new (thd->mem_root) - Item_func_cursor_notfound(thd, &$1.name, $1.offset)))) - MYSQL_YYABORT; - } - | sp_cursor_name_and_offset '%' ROWCOUNT_SYM - { - if (unlikely(!($$= new (thd->mem_root) - Item_func_cursor_rowcount(thd, &$1.name, $1.offset)))) + if (unlikely(!($$= Lex->make_item_plsql_cursor_attr(thd, &$1, $3)))) MYSQL_YYABORT; } ; + trim_operands: expr { $$.set(TRIM_BOTH, $1); } | LEADING expr FROM expr { $$.set(TRIM_LEADING, $2, $4); } @@ -10456,7 +10432,7 @@ function_call_keyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | SQL_SYM '%' ROWCOUNT_SYM + | SQL_SYM PERCENT_ORACLE_SYM ROWCOUNT_SYM { $$= new (thd->mem_root) Item_func_oracle_sql_rowcount(thd); if (unlikely($$ == NULL)) @@ -15006,16 +14982,17 @@ param_marker: YYLIP->get_tok_start() + 1)))) MYSQL_YYABORT; } - | colon_with_pos ident_cli + | COLON_ORACLE_SYM ident_cli { if (unlikely(!($$= Lex->add_placeholder(thd, &null_clex_str, - $1, $2.end())))) + $1.pos(), $2.end())))) MYSQL_YYABORT; } - | colon_with_pos NUM + | COLON_ORACLE_SYM NUM { if (unlikely(!($$= Lex->add_placeholder(thd, &null_clex_str, - $1, YYLIP->get_ptr())))) + $1.pos(), + YYLIP->get_ptr())))) MYSQL_YYABORT; } ; @@ -15327,7 +15304,7 @@ simple_ident: if (unlikely(!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))) MYSQL_YYABORT; } - | colon_with_pos ident_cli '.' ident_cli + | COLON_ORACLE_SYM ident_cli '.' ident_cli { if (unlikely(!($$= Lex->make_item_colon_ident_ident(thd, &$2, &$4)))) MYSQL_YYABORT; @@ -15345,7 +15322,7 @@ simple_ident_nospvar: if (unlikely(!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3)))) MYSQL_YYABORT; } - | colon_with_pos ident_cli '.' ident_cli + | COLON_ORACLE_SYM ident_cli '.' ident_cli { if (unlikely(!($$= Lex->make_item_colon_ident_ident(thd, &$2, &$4)))) MYSQL_YYABORT; @@ -16252,12 +16229,12 @@ set_assign: unlikely(lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } - | colon_with_pos ident '.' ident SET_VAR + | COLON_ORACLE_SYM ident '.' ident SET_VAR { LEX *lex= Lex; if (unlikely(!lex->is_trigger_new_or_old_reference(&$2))) { - thd->parse_error(ER_SYNTAX_ERROR, $1); + thd->parse_error(ER_SYNTAX_ERROR, $1.pos()); MYSQL_YYABORT; } lex->set_stmt_init(); From 7f4aee22335c24a410d59978bf1cf20fc3fe90e3 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 12 Nov 2018 00:01:12 +0400 Subject: [PATCH 15/50] MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved --- .../suite/compat/oracle/r/parser.result | 14 +++++++++++ mysql-test/suite/compat/oracle/t/parser.test | 23 +++++++++++++++++++ sql/gen_lex_token.cc | 3 ++- sql/lex.h | 2 +- sql/sql_lex.cc | 1 + sql/sql_yacc.yy | 6 +++-- sql/sql_yacc_ora.yy | 4 +++- 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 4ee34e5e2b3..7540763696f 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -532,3 +532,17 @@ BEGIN NULL; END; / +# +# MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved +# +DECLARE +ELSEIF INT; +BEGIN +ELSEIF:=1; +END; +/ +BEGIN +<> +NULL; +END; +/ diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index b3387b3f922..dabd7956c44 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -316,3 +316,26 @@ BEGIN END; / DELIMITER ;/ + + +--echo # +--echo # MDEV-17666 sql_mode=ORACLE: Keyword ELSEIF should not be reserved +--echo # + +DELIMITER /; +DECLARE + ELSEIF INT; +BEGIN + ELSEIF:=1; +END; +/ +DELIMITER ;/ + +DELIMITER /; +BEGIN +<> + NULL; +END; +/ +DELIMITER ;/ + diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc index aee0f12a4fe..f8c511e53ff 100644 --- a/sql/gen_lex_token.cc +++ b/sql/gen_lex_token.cc @@ -258,7 +258,8 @@ void compute_tokens() set_start_expr_token(RETURN_MARIADB_SYM); set_start_expr_token(RETURN_ORACLE_SYM); set_start_expr_token(IF_SYM); - set_start_expr_token(ELSEIF_SYM); + set_start_expr_token(ELSEIF_MARIADB_SYM); + set_start_expr_token(ELSEIF_ORACLE_SYM); set_start_expr_token(CASE_SYM); set_start_expr_token(WHEN_SYM); set_start_expr_token(WHILE_SYM); diff --git a/sql/lex.h b/sql/lex.h index 707bd464a14..9f0be46e905 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -205,7 +205,7 @@ static SYMBOL symbols[] = { { "DYNAMIC", SYM(DYNAMIC_SYM)}, { "EACH", SYM(EACH_SYM)}, { "ELSE", SYM(ELSE)}, - { "ELSEIF", SYM(ELSEIF_SYM)}, + { "ELSEIF", SYM(ELSEIF_MARIADB_SYM)}, { "ELSIF", SYM(ELSIF_MARIADB_SYM)}, { "ENABLE", SYM(ENABLE_SYM)}, { "ENCLOSED", SYM(ENCLOSED)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 254889ac414..b0072b10c9c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -845,6 +845,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM; + case ELSEIF_MARIADB_SYM: return ELSEIF_ORACLE_SYM; case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM; case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8aea71b44ba..6a075e70cc5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -984,7 +984,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DUAL_SYM %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ -%token ELSEIF_SYM +%token ELSEIF_MARIADB_SYM %token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ @@ -1219,6 +1219,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); Keywords that have different reserved status in std/oracle modes. */ %token BODY_MARIADB_SYM // Oracle-R +%token ELSEIF_ORACLE_SYM %token ELSIF_MARIADB_SYM // PLSQL-R %token EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R %token GOTO_MARIADB_SYM // Oracle-R @@ -4510,7 +4511,7 @@ sp_if: sp_elseifs: /* Empty */ - | ELSEIF_SYM sp_if + | ELSEIF_MARIADB_SYM sp_if | ELSE sp_proc_stmts1 ; @@ -15883,6 +15884,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM + | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index e465e3a19b6..87482a51c43 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -378,7 +378,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DUAL_SYM %token EACH_SYM /* SQL-2003-R */ %token ELSE /* SQL-2003-R */ -%token ELSEIF_SYM +%token ELSEIF_MARIADB_SYM %token ELSIF_ORACLE_SYM /* PLSQL-R */ %token ENCLOSED %token END_OF_INPUT /* INTERNAL */ @@ -613,6 +613,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); Keywords that have different reserved status in std/oracle modes. */ %token BODY_MARIADB_SYM // Oracle-R +%token ELSEIF_ORACLE_SYM %token ELSIF_MARIADB_SYM // PLSQL-R %token EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R %token GOTO_MARIADB_SYM // Oracle-R @@ -15917,6 +15918,7 @@ keyword_sp_var_and_label: | DUMPFILE | DUPLICATE_SYM | DYNAMIC_SYM + | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | ENDS_SYM | ENGINE_SYM From b290ef8c76e2d7dfbae7a85766694a6fd4648eac Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Mon, 12 Nov 2018 01:50:07 +0400 Subject: [PATCH 16/50] MDEV-17454 JSON_VALID( '{"a":1]' ) evaluates to 1. Produce syntax error when '{...]'. --- mysql-test/r/func_json.result | 6 ++++++ mysql-test/t/func_json.test | 6 ++++++ strings/json_lib.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index 90458bcaa4e..74798b13e3a 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -824,3 +824,9 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1, t2; SET sql_mode=default; +# +# MDEV-17454 JSON_VALID( '{"a":1]' ) evaluates to 1 +# +select JSON_VALID( '{"a":1]' ); +JSON_VALID( '{"a":1]' ) +0 diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index d266641e3d2..43bd19801d5 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -481,3 +481,9 @@ SHOW CREATE TABLE t2; DROP TABLE t1, t2; SET sql_mode=default; +--echo # +--echo # MDEV-17454 JSON_VALID( '{"a":1]' ) evaluates to 1 +--echo # + +select JSON_VALID( '{"a":1]' ); + diff --git a/strings/json_lib.c b/strings/json_lib.c index 4f12cbb82b5..394517a4ab6 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -774,7 +774,7 @@ static json_state_handler json_actions[NR_JSON_STATES][NR_C_CLASSES]= syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, not_json_chr, bad_chr}, {/*OBJ_CONT*/ - unexpected_eos, syntax_error, end_object, syntax_error, end_array, + unexpected_eos, syntax_error, end_object, syntax_error, syntax_error, syntax_error, next_key, syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, syntax_error, not_json_chr, bad_chr}, {/*ARRAY_CONT*/ From cefef6a7044ba2210f17b2f49f6b31ddc6a99d01 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 12 Nov 2018 09:24:30 +0400 Subject: [PATCH 17/50] MDEV-17669 Add sql_mode specific tokens for the keyword DECLARE --- sql/gen_lex_token.cc | 2 +- sql/lex.h | 2 +- sql/sql_lex.cc | 1 + sql/sql_yacc.yy | 34 ++++++++++++++++++++-------------- sql/sql_yacc_ora.yy | 7 ++++--- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc index f8c511e53ff..7e0cfd097f9 100644 --- a/sql/gen_lex_token.cc +++ b/sql/gen_lex_token.cc @@ -33,7 +33,7 @@ from bison. See also YYMAXUTOK. */ -#define MY_MAX_TOKEN 1000 +#define MY_MAX_TOKEN 1100 /** Generated token. */ struct gen_lex_token_string { diff --git a/sql/lex.h b/sql/lex.h index 9f0be46e905..9add4e060af 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -176,7 +176,7 @@ static SYMBOL symbols[] = { { "DEALLOCATE", SYM(DEALLOCATE_SYM)}, { "DEC", SYM(DECIMAL_SYM)}, { "DECIMAL", SYM(DECIMAL_SYM)}, - { "DECLARE", SYM(DECLARE_SYM)}, + { "DECLARE", SYM(DECLARE_MARIADB_SYM)}, { "DEFAULT", SYM(DEFAULT)}, { "DEFINER", SYM(DEFINER_SYM)}, { "DELAYED", SYM(DELAYED_SYM)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b0072b10c9c..8edb7803943 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -844,6 +844,7 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM; case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; + case DECLARE_MARIADB_SYM: return DECLARE_ORACLE_SYM; case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM; case ELSEIF_MARIADB_SYM: return ELSEIF_ORACLE_SYM; case ELSIF_MARIADB_SYM: return ELSIF_ORACLE_SYM; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6a075e70cc5..fe21cf82db9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -967,7 +967,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DAY_SECOND_SYM %token DECIMAL_NUM %token DECIMAL_SYM /* SQL-2003-R */ -%token DECLARE_SYM /* SQL-2003-R */ +%token DECLARE_MARIADB_SYM /* SQL-2003-R */ +%token DECLARE_ORACLE_SYM /* Oracle-R */ %token DEFAULT /* SQL-2003-R */ %token DELETE_DOMAIN_ID_SYM %token DELETE_SYM /* SQL-2003-R */ @@ -2149,6 +2150,7 @@ END_OF_INPUT %type sp_decl_idents sp_decl_idents_init_vars %type sp_handler_type sp_hcond_list %type sp_cond sp_hcond sqlstate signal_value opt_signal_value +%type sp_decl_handler %type sp_decls sp_decl sp_decl_body sp_decl_variable_list %type sp_name %type sp_param_name sp_param_name_and_type @@ -3503,7 +3505,7 @@ sp_decls: ; sp_decl: - DECLARE_SYM sp_decl_body { $$= $2; } + DECLARE_MARIADB_SYM sp_decl_body { $$= $2; } ; @@ -3619,18 +3621,7 @@ sp_decl_body: $$.vars= $$.hndlrs= $$.curs= 0; $$.conds= 1; } - | sp_handler_type HANDLER_SYM FOR_SYM - { - if (unlikely(Lex->sp_handler_declaration_init(thd, $1))) - MYSQL_YYABORT; - } - sp_hcond_list sp_proc_stmt - { - if (unlikely(Lex->sp_handler_declaration_finalize(thd, $1))) - MYSQL_YYABORT; - $$.vars= $$.conds= $$.curs= 0; - $$.hndlrs= 1; - } + | sp_decl_handler | sp_decl_ident CURSOR_SYM { Lex->sp_block_init(thd); @@ -3648,6 +3639,21 @@ sp_decl_body: } ; +sp_decl_handler: + sp_handler_type HANDLER_SYM FOR_SYM + { + if (unlikely(Lex->sp_handler_declaration_init(thd, $1))) + MYSQL_YYABORT; + } + sp_hcond_list sp_proc_stmt + { + if (unlikely(Lex->sp_handler_declaration_finalize(thd, $1))) + MYSQL_YYABORT; + $$.vars= $$.conds= $$.curs= 0; + $$.hndlrs= 1; + } + ; + opt_parenthesized_cursor_formal_parameters: /* Empty */ | '(' sp_fdparams ')' diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 87482a51c43..b738b0b4b29 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -361,7 +361,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DAY_SECOND_SYM %token DECIMAL_NUM %token DECIMAL_SYM /* SQL-2003-R */ -%token DECLARE_SYM /* SQL-2003-R */ +%token DECLARE_MARIADB_SYM /* SQL-2003-R */ +%token DECLARE_ORACLE_SYM /* Oracle-R */ %token DEFAULT /* SQL-2003-R */ %token DELETE_DOMAIN_ID_SYM %token DELETE_SYM /* SQL-2003-R */ @@ -4462,7 +4463,7 @@ sp_labeled_block: MYSQL_YYABORT; } | sp_block_label - DECLARE_SYM + DECLARE_ORACLE_SYM { Lex->sp_block_init(thd, &$1); } @@ -4502,7 +4503,7 @@ sp_unlabeled_block: if (unlikely(Lex->sp_block_finalize(thd, Lex_spblock($4)))) MYSQL_YYABORT; } - | DECLARE_SYM + | DECLARE_ORACLE_SYM { if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; From 4b773ca2989218daf02df2d1cc502869e54dc1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Nov 2018 10:16:28 +0200 Subject: [PATCH 18/50] MDEV-13564 clean-up: Replace memset() with init() --- storage/innobase/handler/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 638b8d73770..be91befcf1a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13455,7 +13455,7 @@ int ha_innobase::truncate() dict_table_t* ib_table = m_prebuilt->table; const time_t update_time = ib_table->update_time; const ulint stored_lock = m_prebuilt->stored_select_lock_type; - memset(&info, 0, sizeof info); + info.init(); update_create_info_from_table(&info, table); if (dict_table_is_temporary(ib_table)) { From 1bba3cc2e7f120f2645c98f3bc96821c938cb4e7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 6 Nov 2018 11:37:15 +0100 Subject: [PATCH 19/50] C/C 3.0.7 --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 5d5c1ba5566..334964f0711 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 5d5c1ba55664f23cf474ff6278e467f85ada1a0f +Subproject commit 334964f0711c3fd027f634a239eee57bc912f7ff From 3f10cbf3e49a7e44429f69b9d74e74eefd8f97e4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 19 May 2018 15:13:53 +0000 Subject: [PATCH 20/50] pipe and shared memory protocol should be statically compiled into C/C --- cmake/mariadb_connector_c.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index fe2bcfa4a1f..c36087cb862 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -34,5 +34,9 @@ ENDIF() SET(PLUGIN_INSTALL_DIR ${INSTALL_PLUGINDIR}) SET(MARIADB_UNIX_ADDR ${MYSQL_UNIX_ADDR}) +SET(CLIENT_PLUGIN_PVIO_NPIPE STATIC) +SET(CLIENT_PLUGIN_PVIO_SHMEM STATIC) +SET(CLIENT_PLUGIN_PVIO_SOCKET STATIC) + MESSAGE("== Configuring MariaDB Connector/C") ADD_SUBDIRECTORY(libmariadb) From 4f9c44ed39af0b5531dfcc30d0037c1c71b8aaa6 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 19 May 2018 12:44:15 +0000 Subject: [PATCH 21/50] adjust MTR code after C/C changed the location of plugin libraries --- mysql-test/mysql-test-run.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b317be5e017..f428f16940f 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2591,7 +2591,7 @@ sub setup_vardir() { { for (<$bindir/storage/*$opt_vs_config/*.dll>, <$bindir/plugin/*$opt_vs_config/*.dll>, - <$bindir/libmariadb/plugins/*$opt_vs_config/*.dll>, + <$bindir/libmariadb$opt_vs_config/*.dll>, <$bindir/sql$opt_vs_config/*.dll>) { my $pname=basename($_); @@ -2612,6 +2612,7 @@ sub setup_vardir() { for (<$bindir/storage/*/*.so>, <$bindir/plugin/*/*.so>, <$bindir/libmariadb/plugins/*/*.so>, + <$bindir/libmariadb/*.so>, <$bindir/sql/*.so>) { my $pname=basename($_); From 85baa03c60d5e9da4890344f10fa0437337cb265 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 6 Nov 2018 21:18:49 +0100 Subject: [PATCH 22/50] update results after CONC-351 fix --- mysql-test/r/session_tracker_last_gtid.result | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mysql-test/r/session_tracker_last_gtid.result b/mysql-test/r/session_tracker_last_gtid.result index deffeca1333..795d0aaa2a2 100644 --- a/mysql-test/r/session_tracker_last_gtid.result +++ b/mysql-test/r/session_tracker_last_gtid.result @@ -2,13 +2,7 @@ # MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid # SET gtid_seq_no=1000; --- Tracker : SESSION_TRACK_SCHEMA --- test - SET @@session.session_track_system_variables='last_gtid'; --- Tracker : SESSION_TRACK_SCHEMA --- test - create table t1 (a int) engine=innodb; -- Tracker : SESSION_TRACK_SYSTEM_VARIABLES -- last_gtid From 59b87e75d04f0ed75256724c78f7fd7af2f96e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Nov 2018 18:06:41 +0200 Subject: [PATCH 23/50] Fix a comment --- storage/innobase/trx/trx0purge.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 825b9eab3a6..c20001c8df0 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1076,7 +1076,7 @@ trx_purge_initiate_truncate( os_file_truncate(file->name, file->handle, os_offset_t(size) << srv_page_size_shift, true); - /* This is only executed by the srv_coordinator_thread. */ + /* This is only executed by the srv_purge_coordinator_thread. */ export_vars.innodb_undo_truncations++; /* TODO: PUNCH_HOLE the garbage (with write-ahead logging) */ From 32bebfeefb219aec22468a6eae30ffd4a778544d Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Mon, 12 Nov 2018 18:19:31 +0200 Subject: [PATCH 24/50] Updated list of unstable tests for 10.2.19 --- mysql-test/unstable-tests | 213 +++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 106 deletions(-) diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index 055196004d9..2e517228bfd 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -23,66 +23,58 @@ # ############################################################################## -# Based on 10.2 339edd462f519573b1c505fb99fdbfc3bc765b5a +# Based on 10.2 85baa03c60d5e9da4890344f10fa0437337cb265 +main.alter_table : Modified in 10.2.19 main.alter_table_trans : MDEV-12084 - timeout main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result main.auth_named_pipe : MDEV-14724 - System error 2 -main.bootstrap : Modified in 10.2.17 -main.check_constraint : Modified in 10.2.17 +main.auto_increment_ranges_innodb : Modified in 10.2.19 main.connect : MDEV-17282 - Wrong result main.connect2 : MDEV-13885 - Server crash main.constraints : Modified in 10.2.18 main.count_distinct2 : MDEV-11768 - timeout main.create_delayed : MDEV-10605 - failed with timeout -main.create_or_replace : Modified in 10.2.18 -main.create_replace_tmp : Added in 10.2.17 -main.cte_nonrecursive : Modified in 10.2.18 -main.cte_recursive : Modified in 10.2.18 -main.cte_recursive_not_embedded : Added in 10.2.17 -main.ctype_binary : Modified in 10.2.17 -main.ctype_eucjpms : Modified in 10.2.17 -main.ctype_euckr : Modified in 10.2.17 -main.ctype_gbk : Modified in 10.2.17 -main.ctype_latin1 : Modified in 10.2.17 -main.ctype_ucs : Modified in 10.2.17 -main.ctype_ujis : Modified in 10.2.17 +main.create_or_replace : Modified in 10.2.19 +main.cte_nonrecursive : Modified in 10.2.19 +main.cte_recursive : Modified in 10.2.19 +main.ctype_latin1 : Modified in 10.2.19 +main.ctype_uca : Modified in 10.2.19 +main.ctype_ucs : MDEV-17681 - Data too long for column main.ctype_upgrade : MDEV-16945 - Error upon mysql_upgrade -main.ctype_utf16le : Modified in 10.2.17 -main.ctype_utf16 : MDEV-10675: timeout or extra warnings; modified in 10.2.17 -main.ctype_utf32 : Modified in 10.2.17 -main.ctype_utf8 : Modified in 10.2.17 -main.ctype_utf8mb4 : Modified in 10.2.17 +main.ctype_utf16 : MDEV-10675: timeout or extra warnings main.debug_sync : MDEV-10607 - internal error -main.derived : Modified in 10.2.17 -main.derived_cond_pushdown : Modified in 10.2.18 -main.derived_opt : MDEV-11768 - timeout -main.distinct : MDEV-14194 - Crash +main.derived_cond_pushdown : Modified in 10.2.19 +main.derived_opt : MDEV-11768 - timeout; modified in 10.2.19 +main.distinct : MDEV-14194 - Crash; modified in 10.2.19 main.drop_bad_db_type : MDEV-15676 - Wrong result main.events_2 : MDEV-13277 - Crash main.events_bugs : MDEV-12892 - Crash main.events_restart : MDEV-12236 - Server shutdown problem main.events_slowlog : MDEV-12821 - Wrong result -main.flush : Modified in 10.2.18 +main.flush : Modified in 10.2.19 +main.func_concat : Modified in 10.2.19 main.func_isnull : Modified in 10.2.18 -main.func_json : Modified in 10.2.18 +main.func_json : Modified in 10.2.19 main.func_time : Modified in 10.2.18 main.gis : MDEV-13411 - wrong result on P8; modified in 10.2.18 main.gis-precise : Modified in 10.2.18 main.grant : Modified in 10.2.18 +main.group_by : Modified in 10.2.19 main.group_min_max : Modified in 10.2.18 main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown main.index_intersect_innodb : MDEV-10643 - failed with timeout main.index_merge_innodb : MDEV-7142 - Plan mismatch +main.index_merge_myisam : Modified in 10.2.19 main.innodb_mysql_lock : MDEV-7861 - Wrong result main.join : Modified in 10.2.18 -main.join_cache : Modified in 10.2.17 -main.join_outer : Modified in 10.2.17 main.kill-2 : MDEV-13257 - Wrong result main.kill_processlist-6619 : MDEV-10793 - Wrong result +main.lock : Modified in 10.2.19 +main.lock_multi : Modified in 10.2.19 main.log_slow : MDEV-13263 - Wrong result main.log_tables-big : MDEV-13408 - wrong result -main.max_statement_time : Modified in 10.2.17 +main.lowercase_fs_off : Modified in 10.2.19 main.mdev-504 : MDEV-15171 - warning main.mdev375 : MDEV-10607 - sporadic "can't connect" main.merge : MDEV-10607 - sporadic "can't connect" @@ -97,21 +89,19 @@ main.mysqld_option_err : MDEV-12747 - Timeout main.mysqlhotcopy_myisam : MDEV-10995 - Hang on debug main.mysqlslap : MDEV-11801 - timeout main.mysqltest : MDEV-9269 - fails on Alpha; MDEV-13887 - Wrong result -main.mysqltest_tracking_info : Added in 10.2.17 main.openssl_1 : MDEV-13492 - Unknown SSL error main.openssl_6975 : MDEV-17184 - Failures with OpenSSL 1.1.1 main.order_by_optimizer_innodb : MDEV-10683 - Wrong result +main.order_by_zerolength-4285 : Modified in 10.2.19 main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock +main.partition_explicit_prune : Modified in 10.2.19 main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings main.ps : MDEV-11017 - Wrong result; modified in 10.2.18 main.query_cache : MDEV-16180 - Wrong result main.query_cache_debug : MDEV-15281 - Query cache is disabled main.range : Modified in 10.2.18 main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away -main.rename : Modified in 10.2.17 -main.reset_connection : Added in 10.2.17 main.selectivity : Modified in 10.2.18 -main.session_tracker_last_gtid : Added in 10.2.17 main.set_statement : MDEV-13183 - Wrong result main.shm : MDEV-12727 - Mismatch, ERROR 2013 main.show_explain : MDEV-10674 - Wrong result code @@ -127,22 +117,22 @@ main.ssl_timeout : MDEV-11244 - Crash main.stat_tables : Modified in 10.2.18 main.stat_tables_par : MDEV-13266 - Wrong result main.stat_tables_par_innodb : MDEV-14155 - Wrong rounding -main.statistics : Modified in 10.2.17 main.status : MDEV-13255 - Wrong result -main.subselect : Modified in 10.2.17 main.subselect_extra_no_semijoin : Modified in 10.2.18 main.subselect_innodb : MDEV-10614 - Sporadic wrong results -main.subselect_sj_mat : Modified in 10.2.17 -main.subselect_sj2_mat : Modified in 10.2.17 main.tc_heuristic_recover : MDEV-14189 - Wrong result main.type_blob : MDEV-15195 - Wrong result -main.type_datetime : MDEV-14322 - wrong result +main.type_datetime : Modified in 10.2.19 main.type_datetime_hires : MDEV-10687 - Timeout main.type_float : Modified in 10.2.18 -main.union : Modified in 10.2.17 +main.type_newdecimal : Modified in 10.2.19 +main.type_year : Modified in 10.2.19 main.userstat : MDEV-12904 - SSL errors -main.win : Modified in 10.2.18 +main.win : Modified in 10.2.19 main.win_lead_lag : Modified in 10.2.18 +main.win_percent_cume : Modified in 10.2.19 +main.win_rank : Modified in 10.2.19 +main.win_std : Modified in 10.2.19 main.xa : MDEV-11769 - lock wait timeout #---------------------------------------------------------------- @@ -156,17 +146,18 @@ archive-test_sql_discovery.discover : MDEV-16817 - Table marked as crashed #---------------------------------------------------------------- +auth_gssapi.basic : Modified in 10.2.19 + +#---------------------------------------------------------------- + binlog.binlog_commit_wait : MDEV-10150 - Mismatch -binlog.binlog_flush_binlogs_delete_domain : MDEV-14431 - Wrong exit code -binlog.binlog_incident : Modified in 10.1.36 +binlog.binlog_flush_binlogs_delete_domain : Modified in 10.2.19 binlog.binlog_killed : MDEV-12925 - Wrong result -binlog.binlog_tmp_table_row : Added in 10.2.17 binlog.binlog_xa_recover : MDEV-8517 - Extra checkpoint binlog.load_data_stm_view : MDEV-16948 - Wrong result #---------------------------------------------------------------- -binlog_encryption.binlog_incident : Modified in 10.1.36 binlog_encryption.binlog_xa_recover : MDEV-12908 - Extra checkpoint binlog_encryption.encrypted_master : MDEV-14201 - Extra warnings binlog_encryption.encrypted_master_switch_to_unencrypted : MDEV-14190 - Can't init tc log @@ -182,7 +173,7 @@ binlog_encryption.rpl_skip_replication : MDEV-13571 - Unexpected warning binlog_encryption.rpl_ssl : MDEV-14507 - Timeouts binlog_encryption.rpl_stm_relay_ign_space : MDEV-13278 - Wrong result (test assertion) binlog_encryption.rpl_sync : MDEV-13830 - Assertion failure -binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query +binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query; include file modified in 10.2.19 #---------------------------------------------------------------- @@ -201,7 +192,7 @@ encryption.innodb-checksum-algorithm : MDEV-12898 - Deadlock of thre encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate encryption.innodb_encrypt_log : MDEV-13725 - Wrong result encryption.innodb_encryption : MDEV-15675 - Timeout -encryption.innodb-encryption-alter : MDEV-13566 - Lock wait timeout +encryption.innodb-encryption-alter : MDEV-13566 - Lock wait timeout; modified in 10.2.19 encryption.innodb_encryption_discard_import : MDEV-16116 - Wrong result encryption.innodb_encryption-page-compression : MDEV-12630 - crash or assertion failure encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash @@ -252,31 +243,38 @@ galera_3nodes.* : Suite is not stable yet #---------------------------------------------------------------- +gcol.gcol_partition_innodb : Modified in 10.2.19 gcol.gcol_rollback : MDEV-16954 - Unknown storage engine 'InnoDB' -gcol.gcol_update : Include file modified in 10.2.17 gcol.innodb_virtual_basic : MDEV-16950 - Failing assertion -gcol.innodb_virtual_debug_purge : MDEV-16952 - Wrong result; modified in 10.2.17 -gcol.innodb_virtual_index : Include file modified in 10.2.17 +gcol.innodb_virtual_debug_purge : MDEV-16952 - Wrong result; modified in 10.2.19 +gcol.innodb_virtual_index : Modifed in 10.2.19 + +#---------------------------------------------------------------- + +heap.heap_btree : Modified in 10.2.19 #---------------------------------------------------------------- innodb.101_compatibility : MDEV-13891 - Wrong result -innodb.alter_copy : MDEV-16181 - Assertion failure -innodb.alter_crash : MDEV-16944 - The process cannot access the file -innodb.alter_kill : MDEV-16946 - Wrong result +innodb.alter_copy : MDEV-16181 - Assertion failure; modified in 10.2.19 +innodb.alter_crash : MDEV-16944 - The process cannot access the file; modified in 10.2.19 +innodb.alter_inplace_perfschema : Added in 10.2.19 +innodb.alter_kill : Modified in 10.2.19 +innodb.auto_increment_dup : Modified in 10.2.19 innodb.autoinc_persist : MDEV-15282 - Assertion failure innodb.binlog_consistent : MDEV-10618 - Server fails to start innodb.doublewrite : MDEV-12905 - Server crash +innodb.drop_table_background : Modified in 10.2.19 innodb.foreign-keys : Modified in 10.2.18 -innodb.foreign_key : Modified in 10.2.18 +innodb.foreign_key : Modified in 10.2.19 innodb.group_commit_crash : MDEV-14191 - InnoDB registration failed innodb.group_commit_crash_no_optimize_thread : MDEV-13830 - Assertion failure -innodb.index_merge_threshold : Include files modified in 10.2.17 innodb.innodb-32k-crash : MDEV-16953 - Corrupt log record found innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup -innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS +innodb.innodb-alter : Modified in 10.2.19 +innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS; modified in 10.2.19 innodb.innodb-alter-table : MDEV-10619 - Testcase timeout -innodb.innodb-alter-tempfile : MDEV-15285 - Table already exists +innodb.innodb-alter-tempfile : MDEV-15285 - Table already exists; modified in 10.2.19 innodb.innodb-blob : MDEV-12053 - Client crash innodb.innodb_buffer_pool_resize_with_chunks : MDEV-16964 - Assertion failure innodb.innodb_bug14147491 : MDEV-11808 - Index is corrupt @@ -287,6 +285,7 @@ innodb.innodb_bulk_create_index_replication : MDEV-15273 - Slave failed to start innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown innodb.innodb-get-fk : MDEV-13276 - Server crash +innodb.innodb-index : Modified in 10.2.19 innodb.innodb-index-online : MDEV-14809 - Cannot save statistics innodb.innodb_information_schema : MDEV-8851 - Wrong result innodb.innodb-lock : Modified in 10.2.18 @@ -297,55 +296,66 @@ innodb.innodb-page_compression_default : MDEV-13644 - Assertion failure innodb.innodb-page_compression_lzma : MDEV-14353 - Wrong result innodb.innodb-page_compression_zip : MDEV-10641 - mutex problem innodb.innodb_stats : MDEV-10682 - wrong result -innodb.innodb_stats_persistent : Include file modified in 10.2.17 innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed innodb.innodb-table-online : MDEV-13894 - Wrong result innodb.innodb_sys_semaphore_waits : MDEV-10331 - Semaphore wait -innodb.innodb-wl5522 : Modified in 10.2.17 innodb.innodb-wl5522-debug : MDEV-14200 - Wrong errno innodb.innodb_zip_innochecksum2 : MDEV-13882 - Extra warnings innodb.innodb_zip_innochecksum3 : MDEV-14486 - Resource temporarily unavailable innodb.log_corruption : MDEV-13251 - Wrong result innodb.log_data_file_size : MDEV-14204 - Server failed to start innodb.log_file_name : MDEV-14193 - Exception -innodb.log_file_size : MDEV-15668 - Not found pattern +innodb.log_file_name_debug : Modified in 10.2.19 +innodb.log_file_size : MDEV-15668 - Not found pattern; modified in 10.2.19 innodb.monitor : MDEV-16179 - Wrong result -innodb.purge_secondary : MDEV-15681 - Wrong result; include file modified in 10.2.17 +innodb.purge_secondary : MDEV-15681 - Wrong result innodb.purge_thread_shutdown : MDEV-13792 - Wrong result innodb.read_only_recovery : MDEV-13886 - Server crash innodb.recovery_shutdown : MDEV-15671 - Checksum mismatch in datafile +innodb.rename_table_debug : Added in 10.2.19 innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace innodb.table_definition_cache_debug : MDEV-14206 - Extra warning -innodb.table_flags : MDEV-13572 - Wrong result +innodb.table_flags : MDEV-13572 - Wrong result; modified in 10.2.19 innodb.temp_table_savepoint : MDEV-16182 - Wrong result -innodb.temporary_table : MDEV-13265 - Wrong result; modified in 10.2.17 -innodb.truncate_purge_debug : Include file modified in 10.2.17 +innodb.temporary_table : MDEV-13265 - Wrong result +innodb.truncate : Added in 10.2.19 +innodb.truncate_crash : Added in 10.2.19 +innodb.truncate_debug : Opt file added in 10.2.19 +innodb.truncate_foreign : Added in 10.2.19 +innodb.truncate_inject : Opt file added in 10.2.19 +innodb.truncate_missing : Added in 10.2.19 +innodb.truncate_purge_debug : Opt file added in 10.2.19 +innodb.truncate_restart : Opt file added in 10.2.19 innodb.update_time : MDEV-14804 - Wrong result -innodb.undo_log : Include file modified in 10.2.17 +innodb.undo_truncate : MDEV-17340 - Server hung; added in 10.2.19 +innodb.undo_truncate_recover : MDEV-17679 - MySQL server has gone away; added in 10.2.19 innodb.xa_recovery : MDEV-15279 - mysqld got exception -innodb_fts.fts_kill_query : Added in 10.2.17 +innodb_fts.crash_recovery : Modified in 10.2.19 +innodb_fts.fts_kill_query : Modified in 10.0.37 innodb_fts.innodb-fts-fic : MDEV-14154 - Assertion failure innodb_fts.innodb_fts_misc_debug : MDEV-14156 - Unexpected warning innodb_fts.innodb_fts_plugin : MDEV-13888 - Errors in server log innodb_fts.innodb_fts_stopword_charset : MDEV-13259 - Table crashed innodb_fts.sync : MDEV-14808 - Wrong result -innodb_fts.sync_ddl : Added in 10.2.17 -innodb_gis.create_spatial_index : Modified in 10.2.17 innodb_gis.kill_server : MDEV-16941 - Checksum mismatch -innodb_gis.rtree_compress : Include file modified in 10.2.17 -innodb_gis.rtree_concurrent_srch : MDEV-15284 - Wrong result with embedded -innodb_gis.rtree_purge : MDEV-15275 - Timeout; include file modified in 10.2.17 +innodb_gis.rtree_concurrent_srch : MDEV-15284 - Wrong result with embedded; modified in 10.2.19 +innodb_gis.rtree_purge : MDEV-15275 - Timeout innodb_gis.rtree_recovery : MDEV-15274 - Error on check innodb_gis.rtree_split : MDEV-14208 - Too many arguments -innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file; include file modified in 10.2.17 +innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file innodb_gis.types : MDEV-15679 - Table is marked as crashed innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed innodb_zip.innochecksum_3 : MDEV-13279 - Extra warnings +innodb_zip.restart : Opt file modified in 10.2.19 innodb_zip.wl6470_1 : MDEV-14240 - Assertion failure -innodb_zip.wl6501_1 : MDEV-10891 - Can't create UNIX socket +innodb_zip.wl6501_1 : MDEV-10891 - Can't create UNIX socket; opt file added in 10.2.19 +innodb_zip.wl6501_crash_3 : Opt file added in 10.2.19 +innodb_zip.wl6501_crash_4 : Opt file added in 10.2.19 +innodb_zip.wl6501_crash_5 : Opt file added in 10.2.19 +innodb_zip.wl6501_scale_1 : Opt file added in 10.2.19 innodb_zip.wl5522_debug_zip : MDEV-11600 - Operating system error number 2 innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error 192 @@ -353,6 +363,7 @@ innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error maria.concurrent : Added in 10.2.18 maria.create : Added in 10.2.18 +maria.fulltext2 : Added in 10.2.19 maria.insert_select : MDEV-12757 - Timeout maria.insert_select-7314 : MDEV-16492 - Timeout maria.maria : MDEV-14430 - Extra warning; modified in 10.2.18 @@ -371,22 +382,21 @@ mariabackup.full_backup : MDEV-16571 - Wrong result mariabackup.huge_lsn : MDEV-15662 - Sequence number is in the future mariabackup.incremental_backup : MDEV-14192 - Assertion failure mariabackup.incremental_ddl_during_backup : Added in 10.2.18 -mariabackup.incremental_encrypted : MDEV-15667 - Timeout; MDEV-14192 - Assertion failure; modified in 10.2.17 -mariabackup.innodb_log_optimize_ddl : Added in 10.2.17 +mariabackup.incremental_encrypted : MDEV-15667 - Timeout; MDEV-14192 - Assertion failure mariabackup.mdev-14447 : MDEV-15201 - Timeout mariabackup.mlog_index_load : Added in 10.2.18 mariabackup.nolock_ddl_during_backup_end : Added in 10.2.18 mariabackup.partial_exclude : MDEV-15270 - Error on exec mariabackup.recreate_table_during_backup : Added in 10.2.18 -mariabackup.rename_during_backup : Added in 10.2.18 +mariabackup.rename_during_backup : MDEV-14192 - Assertion failure; Added in 10.2.18 mariabackup.rename_during_mdl_lock : Modified in 10.2.18 mariabackup.skip_innodb : Added in 10.2.18 -mariabackup.truncate_during_backup : Added in 10.2.18 +mariabackup.truncate_during_backup : Modified in 10.2.19 mariabackup.undo_space_id : Opt file modified in 10.2.18 mariabackup.unsupported_redo : Modified in 10.2.18 mariabackup.xbstream : MDEV-14192 - Crash mariabackup.xb_page_compress : MDEV-14810 - status: 1, errno: 11 -mariabackup.xb_partition : MDEV-14192 - Assertion failure +mariabackup.xb_partition : MDEV-14192 - Assertion failure; MDEV-17584 - Crash on shutdown mariabackup.xb_compressed_encrypted : MDEV-14812 - Segmentation fault #---------------------------------------------------------------- @@ -395,17 +405,9 @@ mroonga/storage.column_datetime_32bit_2038 : Wrong resul mroonga/storage.column_datetime_32bit_before_unix_epoch : Wrong result on Alpha mroonga/storage.column_datetime_32bit_max : Wrong result on Alpha mroonga/storage.column_datetime_32bit_out_of_range : Wrong result on Alpha -mroonga/storage.index_multiple_column_range_all_used_less_than : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.index_multiple_column_range_all_used_less_than_or_equal : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.index_multiple_column_range_partially_used_have_prefix_less_than : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.index_multiple_column_range_partially_used_have_prefix_less_than_or_equal : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.index_multiple_column_range_partially_used_no_prefix_less_than : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.index_multiple_column_range_partially_used_no_prefix_less_than_or_equal : MDEV-16127 - Wrong result with GCC 8 mroonga/storage.index_multiple_column_unique_date_32bit_equal : Wrong result on Alpha mroonga/storage.index_multiple_column_unique_date_order_32bit_desc : Wrong result on Alpha mroonga/storage.index_multiple_column_unique_datetime_index_read : MDEV-8643 - Valgrind -mroonga/storage.optimization_order_limit_optimized_datetime_less_than : MDEV-16127 - Wrong result with GCC 8 -mroonga/storage.optimization_order_limit_optimized_datetime_less_than_or_equal : MDEV-16127 - Wrong result with GCC 8 mroonga/storage.repair_table_no_index_file : MDEV-9364 - Wrong result mroonga/wrapper.repair_table_no_index_file : MDEV-14807 - Wrong error message @@ -421,7 +423,6 @@ multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_ #---------------------------------------------------------------- -parts.alter_data_directory_innodb : Added in 10.2.17 parts.partition_alter2_2_maria : MDEV-14364 - Lost connection to MySQL server during query parts.partition_auto_increment_archive : MDEV-16491 - Marked as crashed and should be repaired parts.partition_auto_increment_maria : MDEV-14430 - Extra warning @@ -430,7 +431,6 @@ parts.partition_exch_qa_10 : MDEV-11765 - wrong result parts.partition_innodb_status_file : MDEV-12901 - Valgrind parts.partition_special_innodb : MDEV-16942 - Timeout parts.show_create : Modified in 10.2.18 -parts.truncate_locked : Added in 10.2.17 parts.update_and_cache : Added in 10.2.18 #---------------------------------------------------------------- @@ -466,7 +466,7 @@ perfschema_stress.* : MDEV-10996 - Not maintained #---------------------------------------------------------------- plugins.feedback_plugin_send : MDEV-7932, MDEV-11118 - Connection problems and such -plugins.processlist : MDEV-16574 - Wrong result; modified in 10.2.17 +plugins.processlist : MDEV-16574 - Wrong result plugins.server_audit : MDEV-9562 - crashes on sol10-sparc plugins.thread_pool_server_audit : MDEV-14295 - Wrong result @@ -475,32 +475,23 @@ plugins.thread_pool_server_audit : MDEV-14295 - Wrong result rocksdb.* : Tests are unstable rocksdb.2pc_group_commit : MDEV-14455 - Wrong result -rocksdb.add_index_inplace : MDEV-16648 - Server crash -rocksdb.allow_no_primary_key : MDEV-16634 - Server crash rocksdb.allow_no_primary_key_with_sk : MDEV-16639 - Server crash rocksdb.autoinc_crash_safe_partition : MDEV-16639, MDEV-16637 - Server crash -rocksdb.autoinc_secondary : MDEV-16638 - Server crash rocksdb.autoinc_vars_thread : MDEV-16573 - Debug sync timed out rocksdb.bloomfilter2 : MDEV-16564 - Wrong result -rocksdb.bloomfilter4 : MDEV-16649 - Server crash rocksdb.deadlock : MDEV-16033 - Timeout rocksdb.drop_index_inplace : MDEV-14162 - Crash on shutdown rocksdb.drop_table : MDEV-14308 - Timeout -rocksdb.drop_table2 : MDEV-16631 - Server crash rocksdb.drop_table3 : MDEV-16949 - Server crash rocksdb.dup_key_update : MDEV-17284 - Wrong result -rocksdb.issue255 : MDEV-16577 - Wrong plan rocksdb.locking_issues : MDEV-14464 - Wrong result rocksdb.mariadb_ignore_dirs : MDEV-16639 - Server crash rocksdb.mariadb_port_fixes : MDEV-16387 - Wrong plan rocksdb.max_open_files : MDEV-16639 - Server crash rocksdb.perf_context : MDEV-17285 - Wrong results -rocksdb.read_only_tx : MDEV-16565 - Server crash rocksdb.rocksdb_cf_options : MDEV-16639 - Server crash rocksdb.rocksdb_cf_per_partition : MDEV-16636 - Wrong result rocksdb.rocksdb_parts : MDEV-13843 - Wrong result -rocksdb.singledelete : MDEV-16633 - Server crash -rocksdb.truncate_table3 : MDEV-14506 - Lost connection to server rocksdb.ttl_primary_read_filtering : MDEV-16560 - Wrong result rocksdb.ttl_secondary : MDEV-16943 - Timeout rocksdb.ttl_secondary_read_filtering : MDEV-16560 - Wrong result @@ -521,7 +512,7 @@ roles.create_and_grant_role : MDEV-11772 - wrong result #---------------------------------------------------------------- rpl.last_insert_id : MDEV-10625 - warnings in error log -rpl.rpl_15867 : Added in 10.2.17 +rpl.rpl_15919 : Added in 10.2.19 rpl.rpl_auto_increment : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_bug45679 : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log @@ -551,23 +542,25 @@ rpl.rpl_insert_id : MDEV-15197 - Wrong result rpl.rpl_insert_id_pk : MDEV-16567 - Assertion failure rpl.rpl_insert_ignore : MDEV-14365 - Lost connection to MySQL server during query rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips +rpl.rpl_lcase_tblnames_rewrite_db : Added in 10.2.19 rpl.rpl_mariadb_slave_capability : MDEV-11018 - Extra lines in binlog rpl.rpl_mdev6020 : MDEV-15272 - Server crash rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_row_mixing_engines : MDEV-16561 - Timeout in master_pos_wait rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Failed sync_slave_with_master +rpl.rpl_old_master : Modified in 10.2.19 rpl.rpl_parallel : MDEV-10653 - Timeouts rpl.rpl_parallel_conflicts : MDEV-15272 - Server crash rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure rpl.rpl_parallel_multilevel2 : MDEV-14723 - Timeout -rpl.rpl_parallel_optimistic : MDEV-15278 - Failed to sync with master +rpl.rpl_parallel_optimistic : MDEV-15278 - Failed to sync with master; modified in 10.2.19 rpl.rpl_parallel_optimistic_nobinlog : MDEV-15278 - Failed to sync with master rpl.rpl_parallel_retry : MDEV-11119 - Crash; MDEV-17109 - Timeout rpl.rpl_parallel_temptable : MDEV-10356 - Crash rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips rpl.rpl_password_boundaries : MDEV-11534 - Slave IO warnings -rpl.rpl_row_001 : MDEV-16653 - Internal check fails; modified in 10.2.17 +rpl.rpl_row_001 : MDEV-16653 - Internal check fails rpl.rpl_row_basic_11bugs : MDEV-12171 - Server failed to start rpl.rpl_row_basic_2myisam : MDEV-13875 - command "diff_files" failed rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result @@ -575,6 +568,7 @@ rpl.rpl_row_img_blobs : MDEV-13875 - command "diff_files" failed rpl.rpl_row_img_eng_min : MDEV-13875 - diff_files failed rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed rpl.rpl_row_index_choice : MDEV-15196 - Slave crash +rpl.rpl_row_lcase_tblnames : Added in 10.2.19 rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x rpl.rpl_row_spatial : Added in 10.2.18 rpl.rpl_semi_sync : MDEV-11220 - Wrong result @@ -591,7 +585,7 @@ rpl.rpl_slave_load_tmpdir_not_exist : MDEV-14203 - Extra warning rpl.rpl_slow_query_log : MDEV-13250 - Test abort rpl.rpl_sp_effects : MDEV-13249 - Crash rpl.rpl_start_stop_slave : MDEV-13567 - Sync slave timeout -rpl.rpl_stm_000001 : Modified in 10.2.17 +rpl.rpl_stm_lcase_tblnames : Added in 10.2.19 rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_multi_query : MDEV-9501 - Failed registering on master rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion @@ -599,6 +593,7 @@ rpl.rpl_stm_stop_middle_group : MDEV-13791 - Server crash rpl.rpl_sync : MDEV-13830 - Assertion failure rpl.rpl_temporal_mysql56_to_mariadb53 : MDEV-9501 - Failed registering on master rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries +rpl.rpl_typeconv : Include file modified in 10.2.19 rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result rpl/extra/rpl_tests.* : MDEV-10994 - Not maintained @@ -635,12 +630,16 @@ stress.ddl_innodb : MDEV-10635 - Testcase timeout #---------------------------------------------------------------- sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x +sys_vars.delayed_insert_limit_func : MDEV-17683 - Wrong result; modified in 10.2.19 sys_vars.innodb_buffer_pool_dump_at_shutdown_basic : MDEV-14280 - Unexpected error -sys_vars.innodb_log_optimize_ddl_basic : Added in 10.2.17 +sys_vars.innodb_ft_result_cache_limit_32 : Added in 10.2.19 +sys_vars.innodb_ft_result_cache_limit_64 : Added in 10.2.19 +sys_vars.innodb_ft_result_cache_limit_basic : Modified in 10.2.19 sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash sys_vars.rpl_init_slave_func : MDEV-10149 - Test assertion sys_vars.slow_query_log_func : MDEV-14273 - Wrong result +sys_vars.sql_low_priority_updates_func : Modified in 10.2.19 sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result sys_vars.wait_timeout_func : MDEV-12896 - Wrong result sys_vars.wsrep_start_position_basic : Modified in 10.2.18 @@ -652,6 +651,7 @@ tokudb.* : suite.pm and multiple modifications in 10 tokudb.change_column_all_1000_10 : MDEV-12640 - Lost connection tokudb.change_column_bin : MDEV-12640 - Lost connection tokudb.change_column_char : MDEV-12822 - Lost connection +tokudb.change_column_varbin : MDEV-17682 - Timeout tokudb.cluster_filter : MDEV-10678 - Wrong execution plan tokudb.cluster_filter_hidden : MDEV-10678 - Wrong execution plan tokudb.cluster_filter_unpack_varchar : MDEV-10636 - Wrong execution plan @@ -672,13 +672,13 @@ tokudb.type_datetime : MDEV-15193 - Wrong result tokudb_alter_table.hcad_all_add2 : MDEV-15269 - Timeout -tokudb_bugs.alter_table_comment_rebuild_data : Added in 10.1.36 +tokudb_bugs.PS-3773 : Added in 10.0.37 +tokudb_bugs.alter_table_comment_rebuild_data : Added in 10.0.37 tokudb_bugs.checkpoint_lock : MDEV-10637 - Wrong processlist output tokudb_bugs.checkpoint_lock_3 : MDEV-10637 - Wrong processlist output tokudb_bugs.frm_store : MDEV-12823 - Valgrind tokudb_bugs.frm_store2 : MDEV-12823 - Valgrind tokudb_bugs.frm_store3 : MDEV-12823 - Valgrind -tokudb_bugs.PS-3773 : Added in 10.1.36 tokudb_bugs.xa : MDEV-11804 - Lock wait timeout tokudb_bugs.xa-3 : MDEV-16953 - Corrupt log record found @@ -695,7 +695,7 @@ rpl-tokudb.* : MDEV-14354 - Tests fail with tcmalloc unit.conc_basic-t : MDEV-15286 - not ok 7 - test_reconnect_maxpackage unit.conc_misc : MDEV-14811 - not ok 12 - test_conc49 unit.conc_ps_bugs : MDEV-13252 - not ok 44 test_bug4236 -unit.lf : MDEV-12897 - Signal 11 thrown +unit.lf : MDEV-12897 - Unexpected return code unit.ma_test_loghandler : MDEV-10638 - record read not ok unit.my_atomic : MDEV-15670 - Signal 11 thrown @@ -703,6 +703,7 @@ unit.my_atomic : MDEV-15670 - Signal 11 thrown vcol.index : Modified in 10.2.18 vcol.not_supported : MDEV-10639 - Testcase timeout +vcol.races : Added in 10.2.19 vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout vcol.vcol_misc : MDEV-16651 - Wrong error message @@ -710,6 +711,6 @@ vcol.vcol_misc : MDEV-16651 - Wrong error message wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node wsrep.mdev_6832 : MDEV-14195 - Check testcase failed -wsrep.variables : MDEV-14311 - Wrong result; modified in 10.2.18 +wsrep.variables : MDEV-14311 - Wrong result; MDEV-17585 - Deadlock; modified in 10.2.19 wsrep_info.plugin : MDEV-13569 - No nodes coming from prim view From e1dc05a6962bec79241197cf80ff1a07c3d957ee Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 12 Nov 2018 21:03:12 +0400 Subject: [PATCH 25/50] MDEV-17687 Add sql_mode specific tokens for keywords BLOB, CLOB, NUMBER, RAW, VARCHAR2 --- sql/lex.h | 10 +++---- sql/sql_lex.cc | 5 ++++ sql/sql_yacc.yy | 64 +++++++++++++++++++++++++++++++++++++-------- sql/sql_yacc_ora.yy | 52 +++++++++++++++++++++++------------- 4 files changed, 97 insertions(+), 34 deletions(-) diff --git a/sql/lex.h b/sql/lex.h index 9add4e060af..da20468d593 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -88,7 +88,7 @@ static SYMBOL symbols[] = { { "BINARY", SYM(BINARY)}, { "BINLOG", SYM(BINLOG_SYM)}, { "BIT", SYM(BIT_SYM)}, - { "BLOB", SYM(BLOB_SYM)}, + { "BLOB", SYM(BLOB_MARIADB_SYM)}, { "BLOCK", SYM(BLOCK_SYM)}, { "BODY", SYM(BODY_MARIADB_SYM)}, { "BOOL", SYM(BOOL_SYM)}, @@ -115,7 +115,7 @@ static SYMBOL symbols[] = { { "CIPHER", SYM(CIPHER_SYM)}, { "CLASS_ORIGIN", SYM(CLASS_ORIGIN_SYM)}, { "CLIENT", SYM(CLIENT_SYM)}, - { "CLOB", SYM(CLOB)}, + { "CLOB", SYM(CLOB_MARIADB_SYM)}, { "CLOSE", SYM(CLOSE_SYM)}, { "COALESCE", SYM(COALESCE)}, { "CODE", SYM(CODE_SYM)}, @@ -434,7 +434,7 @@ static SYMBOL symbols[] = { { "NOTFOUND", SYM(NOTFOUND_SYM)}, { "NO_WRITE_TO_BINLOG", SYM(NO_WRITE_TO_BINLOG)}, { "NULL", SYM(NULL_SYM)}, - { "NUMBER", SYM(NUMBER_SYM)}, + { "NUMBER", SYM(NUMBER_MARIADB_SYM)}, { "NUMERIC", SYM(NUMERIC_SYM)}, { "NVARCHAR", SYM(NVARCHAR_SYM)}, { "OF", SYM(OF_SYM)}, @@ -497,7 +497,7 @@ static SYMBOL symbols[] = { { "QUICK", SYM(QUICK)}, { "RAISE", SYM(RAISE_MARIADB_SYM)}, { "RANGE", SYM(RANGE_SYM)}, - { "RAW", SYM(RAW)}, + { "RAW", SYM(RAW_MARIADB_SYM)}, { "READ", SYM(READ_SYM)}, { "READ_ONLY", SYM(READ_ONLY_SYM)}, { "READ_WRITE", SYM(READ_WRITE_SYM)}, @@ -694,7 +694,7 @@ static SYMBOL symbols[] = { { "VARBINARY", SYM(VARBINARY)}, { "VARCHAR", SYM(VARCHAR)}, { "VARCHARACTER", SYM(VARCHAR)}, - { "VARCHAR2", SYM(VARCHAR2)}, + { "VARCHAR2", SYM(VARCHAR2_MARIADB_SYM)}, { "VARIABLES", SYM(VARIABLES)}, { "VARYING", SYM(VARYING)}, { "VIA", SYM(VIA_SYM)}, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 8edb7803943..155b8df26d5 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -842,7 +842,9 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, { switch (symbol->tok) { case BEGIN_MARIADB_SYM: return BEGIN_ORACLE_SYM; + case BLOB_MARIADB_SYM: return BLOB_ORACLE_SYM; case BODY_MARIADB_SYM: return BODY_ORACLE_SYM; + case CLOB_MARIADB_SYM: return CLOB_ORACLE_SYM; case CONTINUE_MARIADB_SYM: return CONTINUE_ORACLE_SYM; case DECLARE_MARIADB_SYM: return DECLARE_ORACLE_SYM; case DECODE_MARIADB_SYM: return DECODE_ORACLE_SYM; @@ -851,11 +853,14 @@ int Lex_input_stream::find_keyword(Lex_ident_cli_st *kwd, case EXCEPTION_MARIADB_SYM: return EXCEPTION_ORACLE_SYM; case EXIT_MARIADB_SYM: return EXIT_ORACLE_SYM; case GOTO_MARIADB_SYM: return GOTO_ORACLE_SYM; + case NUMBER_MARIADB_SYM: return NUMBER_ORACLE_SYM; case OTHERS_MARIADB_SYM: return OTHERS_ORACLE_SYM; case PACKAGE_MARIADB_SYM: return PACKAGE_ORACLE_SYM; case RAISE_MARIADB_SYM: return RAISE_ORACLE_SYM; + case RAW_MARIADB_SYM: return RAW_ORACLE_SYM; case RETURN_MARIADB_SYM: return RETURN_ORACLE_SYM; case ROWTYPE_MARIADB_SYM: return ROWTYPE_ORACLE_SYM; + case VARCHAR2_MARIADB_SYM: return VARCHAR2_ORACLE_SYM; } } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index fe21cf82db9..70ba47ffdfc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -931,7 +931,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token BIT_AND /* MYSQL-FUNC */ %token BIT_OR /* MYSQL-FUNC */ %token BIT_XOR /* MYSQL-FUNC */ -%token BLOB_SYM /* SQL-2003-R */ +%token BLOB_MARIADB_SYM /* SQL-2003-R */ +%token BLOB_ORACLE_SYM /* Oracle-R */ %token BODY_ORACLE_SYM /* Oracle-R */ %token BOTH /* SQL-2003-R */ %token BY /* SQL-2003-R */ @@ -1272,7 +1273,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token CIPHER_SYM %token CLASS_ORIGIN_SYM /* SQL-2003-N */ %token CLIENT_SYM -%token CLOB /* SQL-2003-R */ +%token CLOB_MARIADB_SYM /* SQL-2003-R */ +%token CLOB_ORACLE_SYM /* Oracle-R */ %token CLOSE_SYM /* SQL-2003-R */ %token COALESCE /* SQL-2003-N */ %token CODE_SYM @@ -1477,7 +1479,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token NOMINVALUE_SYM %token NO_WAIT_SYM %token NOWAIT_SYM -%token NUMBER_SYM /* SQL-2003-N, Oracle-R, PLSQL-R */ +%token NUMBER_MARIADB_SYM /* SQL-2003-N */ +%token NUMBER_ORACLE_SYM /* Oracle-R, PLSQL-R */ %token NVARCHAR_SYM %token OF_SYM /* SQL-1992-R, Oracle-R */ %token OFFSET_SYM @@ -1519,7 +1522,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token QUARTER_SYM %token QUERY_SYM %token QUICK -%token RAW /* Oracle-R */ +%token RAW_MARIADB_SYM +%token RAW_ORACLE_SYM /* Oracle-R */ %token READ_ONLY_SYM %token REBUILD_SYM %token RECOVER_SYM @@ -1638,7 +1642,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token USER_SYM /* SQL-2003-R */ %token USE_FRM %token VALUE_SYM /* SQL-2003-R */ -%token VARCHAR2 /* Oracle-R, PLSQL-R */ +%token VARCHAR2_MARIADB_SYM +%token VARCHAR2_ORACLE_SYM /* Oracle-R, PLSQL-R */ %token VARIABLES %token VERSIONING_SYM /* SQL-2011-R */ %token VIA_SYM @@ -4008,7 +4013,9 @@ simple_target_specification: ; statement_information_item_name: - NUMBER_SYM + NUMBER_MARIADB_SYM + { $$= Statement_information_item::NUMBER; } + | NUMBER_ORACLE_SYM { $$= Statement_information_item::NUMBER; } | ROW_COUNT_SYM { $$= Statement_information_item::ROW_COUNT; } @@ -6961,6 +6968,13 @@ field_type_numeric: } | DECIMAL_SYM float_options field_options { $$.set(&type_handler_newdecimal, $2);} + | NUMBER_ORACLE_SYM float_options field_options + { + if ($2.length() != 0) + $$.set(&type_handler_newdecimal, $2); + else + $$.set(&type_handler_double); + } | NUMERIC_SYM float_options field_options { $$.set(&type_handler_newdecimal, $2);} | FIXED_SYM float_options field_options @@ -6987,6 +7001,10 @@ field_type_string: { $$.set(&type_handler_varchar, $2); } + | VARCHAR2_ORACLE_SYM field_length opt_binary + { + $$.set(&type_handler_varchar, $2); + } | nvarchar field_length opt_bin_mod { $$.set(&type_handler_varchar, $2); @@ -6997,6 +7015,11 @@ field_type_string: Lex->charset=&my_charset_bin; $$.set(&type_handler_varchar, $2); } + | RAW_ORACLE_SYM field_length + { + Lex->charset= &my_charset_bin; + $$.set(&type_handler_varchar, $2); + } ; field_type_temporal: @@ -7063,11 +7086,16 @@ field_type_lob: Lex->charset=&my_charset_bin; $$.set(&type_handler_tiny_blob); } - | BLOB_SYM opt_field_length + | BLOB_MARIADB_SYM opt_field_length { Lex->charset=&my_charset_bin; $$.set(&type_handler_blob, $2); } + | BLOB_ORACLE_SYM opt_field_length + { + Lex->charset=&my_charset_bin; + $$.set(&type_handler_long_blob); + } | spatial_type float_options srid_option { #ifdef HAVE_SPATIAL @@ -7104,6 +7132,8 @@ field_type_lob: { $$.set(&type_handler_medium_blob); } | LONGTEXT opt_binary { $$.set(&type_handler_long_blob); } + | CLOB_ORACLE_SYM opt_binary + { $$.set(&type_handler_long_blob); } | LONG_SYM opt_binary { $$.set(&type_handler_medium_blob); } | JSON_SYM @@ -11649,6 +11679,14 @@ cast_type: { Lex->charset= thd->variables.collation_connection; } opt_binary { $$.set(&type_handler_long_blob, $2); } + | VARCHAR field_length + { Lex->charset= thd->variables.collation_connection; } + opt_binary + { $$.set(&type_handler_long_blob, $2); } + | VARCHAR2_ORACLE_SYM field_length + { Lex->charset= thd->variables.collation_connection; } + opt_binary + { $$.set(&type_handler_long_blob, $2); } | NCHAR_SYM opt_field_length { Lex->charset= national_charset_info; @@ -15785,7 +15823,8 @@ keyword_data_type: BIT_SYM | BOOLEAN_SYM | BOOL_SYM - | CLOB + | CLOB_MARIADB_SYM + | CLOB_ORACLE_SYM | DATE_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | DATETIME | ENUM @@ -15800,17 +15839,20 @@ keyword_data_type: | MULTIPOLYGON | NATIONAL_SYM | NCHAR_SYM - | NUMBER_SYM + | NUMBER_MARIADB_SYM + | NUMBER_ORACLE_SYM | NVARCHAR_SYM | POINT_SYM | POLYGON - | RAW + | RAW_MARIADB_SYM + | RAW_ORACLE_SYM | ROW_SYM | SERIAL_SYM | TEXT_SYM | TIMESTAMP %prec PREC_BELOW_CONTRACTION_TOKEN2 | TIME_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 - | VARCHAR2 + | VARCHAR2_MARIADB_SYM + | VARCHAR2_ORACLE_SYM | YEAR_SYM ; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index b738b0b4b29..68a63c6c8b3 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -325,7 +325,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token BIT_AND /* MYSQL-FUNC */ %token BIT_OR /* MYSQL-FUNC */ %token BIT_XOR /* MYSQL-FUNC */ -%token BLOB_SYM /* SQL-2003-R */ +%token BLOB_MARIADB_SYM /* SQL-2003-R */ +%token BLOB_ORACLE_SYM /* Oracle-R */ %token BODY_ORACLE_SYM /* Oracle-R */ %token BOTH /* SQL-2003-R */ %token BY /* SQL-2003-R */ @@ -666,7 +667,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token CIPHER_SYM %token CLASS_ORIGIN_SYM /* SQL-2003-N */ %token CLIENT_SYM -%token CLOB /* SQL-2003-R */ +%token CLOB_MARIADB_SYM /* SQL-2003-R */ +%token CLOB_ORACLE_SYM /* Oracle-R */ %token CLOSE_SYM /* SQL-2003-R */ %token COALESCE /* SQL-2003-N */ %token CODE_SYM @@ -871,7 +873,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token NOMINVALUE_SYM %token NO_WAIT_SYM %token NOWAIT_SYM -%token NUMBER_SYM /* SQL-2003-N, Oracle-R, PLSQL-R */ +%token NUMBER_MARIADB_SYM /* SQL-2003-N */ +%token NUMBER_ORACLE_SYM /* Oracle-R, PLSQL-R */ %token NVARCHAR_SYM %token OF_SYM /* SQL-1992-R, Oracle-R */ %token OFFSET_SYM @@ -913,7 +916,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token QUARTER_SYM %token QUERY_SYM %token QUICK -%token RAW /* Oracle-R */ +%token RAW_MARIADB_SYM +%token RAW_ORACLE_SYM /* Oracle-R */ %token READ_ONLY_SYM %token REBUILD_SYM %token RECOVER_SYM @@ -1032,7 +1036,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token USER_SYM /* SQL-2003-R */ %token USE_FRM %token VALUE_SYM /* SQL-2003-R */ -%token VARCHAR2 /* Oracle-R, PLSQL-R */ +%token VARCHAR2_MARIADB_SYM +%token VARCHAR2_ORACLE_SYM /* Oracle-R, PLSQL-R */ %token VARIABLES %token VERSIONING_SYM /* SQL-2011-R */ %token VIA_SYM @@ -3756,7 +3761,9 @@ simple_target_specification: ; statement_information_item_name: - NUMBER_SYM + NUMBER_MARIADB_SYM + { $$= Statement_information_item::NUMBER; } + | NUMBER_ORACLE_SYM { $$= Statement_information_item::NUMBER; } | ROW_COUNT_SYM { $$= Statement_information_item::ROW_COUNT; } @@ -6817,7 +6824,7 @@ field_type_numeric: } | DECIMAL_SYM float_options field_options { $$.set(&type_handler_newdecimal, $2);} - | NUMBER_SYM float_options field_options + | NUMBER_ORACLE_SYM float_options field_options { if ($2.length() != 0) $$.set(&type_handler_newdecimal, $2); @@ -6850,7 +6857,7 @@ field_type_string: { $$.set(&type_handler_varchar, $2); } - | VARCHAR2 field_length opt_binary + | VARCHAR2_ORACLE_SYM field_length opt_binary { $$.set(&type_handler_varchar, $2); } @@ -6864,7 +6871,7 @@ field_type_string: Lex->charset=&my_charset_bin; $$.set(&type_handler_varchar, $2); } - | RAW field_length + | RAW_ORACLE_SYM field_length { Lex->charset= &my_charset_bin; $$.set(&type_handler_varchar, $2); @@ -6891,7 +6898,7 @@ sp_param_field_type_string: { $$.set(&type_handler_varchar, $2); } - | VARCHAR2 opt_field_length_default_sp_param_varchar opt_binary + | VARCHAR2_ORACLE_SYM opt_field_length_default_sp_param_varchar opt_binary { $$.set(&type_handler_varchar, $2); } @@ -6905,7 +6912,7 @@ sp_param_field_type_string: Lex->charset= &my_charset_bin; $$.set(&type_handler_varchar, $2); } - | RAW opt_field_length_default_sp_param_varchar + | RAW_ORACLE_SYM opt_field_length_default_sp_param_varchar { Lex->charset= &my_charset_bin; $$.set(&type_handler_varchar, $2); @@ -6977,7 +6984,12 @@ field_type_lob: Lex->charset=&my_charset_bin; $$.set(&type_handler_tiny_blob); } - | BLOB_SYM opt_field_length + | BLOB_MARIADB_SYM opt_field_length + { + Lex->charset=&my_charset_bin; + $$.set(&type_handler_blob, $2); + } + | BLOB_ORACLE_SYM opt_field_length { Lex->charset=&my_charset_bin; $$.set(&type_handler_long_blob); @@ -7018,7 +7030,7 @@ field_type_lob: { $$.set(&type_handler_medium_blob); } | LONGTEXT opt_binary { $$.set(&type_handler_long_blob); } - | CLOB opt_binary + | CLOB_ORACLE_SYM opt_binary { $$.set(&type_handler_long_blob); } | LONG_SYM opt_binary { $$.set(&type_handler_medium_blob); } @@ -11617,7 +11629,7 @@ cast_type: { Lex->charset= thd->variables.collation_connection; } opt_binary { $$.set(&type_handler_long_blob, $2); } - | VARCHAR2 field_length + | VARCHAR2_ORACLE_SYM field_length { Lex->charset= thd->variables.collation_connection; } opt_binary { $$.set(&type_handler_long_blob, $2); } @@ -15814,7 +15826,8 @@ keyword_data_type: BIT_SYM | BOOLEAN_SYM | BOOL_SYM - | CLOB + | CLOB_MARIADB_SYM + | CLOB_ORACLE_SYM | DATE_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | DATETIME | ENUM @@ -15829,17 +15842,20 @@ keyword_data_type: | MULTIPOLYGON | NATIONAL_SYM | NCHAR_SYM - | NUMBER_SYM + | NUMBER_MARIADB_SYM + | NUMBER_ORACLE_SYM | NVARCHAR_SYM | POINT_SYM | POLYGON - | RAW + | RAW_MARIADB_SYM + | RAW_ORACLE_SYM | ROW_SYM | SERIAL_SYM | TEXT_SYM | TIMESTAMP %prec PREC_BELOW_CONTRACTION_TOKEN2 | TIME_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 - | VARCHAR2 + | VARCHAR2_MARIADB_SYM + | VARCHAR2_ORACLE_SYM | YEAR_SYM ; From c29c39a7dc2b36dfaa56ae8716cfd808e35d6673 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 13 Nov 2018 09:54:21 +0400 Subject: [PATCH 26/50] MDEV-17693 Shift/reduce conflicts for NAMES,ROLE,PASSWORD in the option_value_no_option_type grammar --- mysql-test/main/parser.result | 65 ++++++++++++++++ mysql-test/main/parser.test | 74 +++++++++++++++++++ .../suite/compat/oracle/r/parser.result | 63 ++++++++++++++++ mysql-test/suite/compat/oracle/t/parser.test | 73 ++++++++++++++++++ sql/sql_yacc.yy | 47 ++++++++++-- sql/sql_yacc_ora.yy | 49 ++++++++++-- 6 files changed, 359 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 32055538700..2ed1032f6cf 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1700,4 +1700,69 @@ SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT 1 +# +# MDEV-17693 Shift/reduce conflicts for NAMES,ROLE,PASSWORD in the option_value_no_option_type grammar +# +CREATE TABLE names (names INT); +SELECT names FROM names AS names; +names +DROP TABLE names; +CREATE TABLE password (password INT); +SELECT password FROM password AS password; +password +DROP TABLE password; +CREATE TABLE role (role INT); +SELECT role FROM role AS role; +role +DROP TABLE role; +BEGIN NOT ATOMIC +DECLARE names VARCHAR(32) DEFAULT '[names]'; +DECLARE password VARCHAR(32) DEFAULT '[password]'; +DECLARE role VARCHAR(32) DEFAULT '[role]'; +names: +LOOP +SELECT names; +LEAVE names; +END LOOP; +password: +LOOP +SELECT password; +LEAVE password; +END LOOP; +role: +LOOP +SELECT role; +LEAVE role; +END LOOP; +END; +$$ +names +[names] +password +[password] +role +[role] +BEGIN NOT ATOMIC +DECLARE names VARCHAR(32); +SET names='[names]'; +END; +$$ +ERROR 42000: Variable 'names' must be quoted with `...`, or renamed +BEGIN NOT ATOMIC +DECLARE password VARCHAR(32); +SET password='[password]'; +END; +$$ +ERROR 42000: Variable 'password' must be quoted with `...`, or renamed +BEGIN NOT ATOMIC +DECLARE role VARCHAR(32); +SET role='[role]'; +END; +$$ +SELECT @@GLOBAL.names; +ERROR HY000: Unknown system variable 'names' +SELECT @@GLOBAL.password; +ERROR HY000: Unknown system variable 'password' +SELECT @@GLOBAL.role; +ERROR HY000: Unknown system variable 'role' End of 10.3 tests diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 65db9c3cda3..040678a51df 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1459,4 +1459,78 @@ DROP PROCEDURE p1; (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT 1 ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); + +--echo # +--echo # MDEV-17693 Shift/reduce conflicts for NAMES,ROLE,PASSWORD in the option_value_no_option_type grammar +--echo # + +CREATE TABLE names (names INT); +SELECT names FROM names AS names; +DROP TABLE names; + +CREATE TABLE password (password INT); +SELECT password FROM password AS password; +DROP TABLE password; + +CREATE TABLE role (role INT); +SELECT role FROM role AS role; +DROP TABLE role; + +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE names VARCHAR(32) DEFAULT '[names]'; + DECLARE password VARCHAR(32) DEFAULT '[password]'; + DECLARE role VARCHAR(32) DEFAULT '[role]'; +names: + LOOP + SELECT names; + LEAVE names; + END LOOP; +password: + LOOP + SELECT password; + LEAVE password; + END LOOP; +role: + LOOP + SELECT role; + LEAVE role; + END LOOP; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_BAD_VAR_SHADOW +BEGIN NOT ATOMIC + DECLARE names VARCHAR(32); + SET names='[names]'; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_BAD_VAR_SHADOW +BEGIN NOT ATOMIC + DECLARE password VARCHAR(32); + SET password='[password]'; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE role VARCHAR(32); + SET role='[role]'; +END; +$$ +DELIMITER ;$$ + +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.names; +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.password; +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.role; + --echo End of 10.3 tests diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 7540763696f..1c60c1434a3 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -546,3 +546,66 @@ BEGIN NULL; END; / +# +# MDEV-17693 Shift/reduce conflicts for NAMES,ROLE,PASSWORD in the option_value_no_option_type grammar +# +CREATE TABLE names (names INT); +SELECT names FROM names AS names; +names +DROP TABLE names; +CREATE TABLE password (password INT); +SELECT password FROM password AS password; +password +DROP TABLE password; +CREATE TABLE role (role INT); +SELECT role FROM role AS role; +role +DROP TABLE role; +DECLARE +names VARCHAR(32) DEFAULT '[names]'; +password VARCHAR(32) DEFAULT '[password]'; +role VARCHAR(32) DEFAULT '[role]'; +BEGIN +<> +SELECT names; +<> +SELECT password; +<> +SELECT role; +END; +$$ +names +[names] +password +[password] +role +[role] +DECLARE +names VARCHAR(32); +BEGIN +SET names='[names]'; +END; +$$ +ERROR 42000: Variable 'names' must be quoted with `...`, or renamed +DECLARE +password VARCHAR(32); +BEGIN +SET password='[password]'; +END; +$$ +ERROR 42000: Variable 'password' must be quoted with `...`, or renamed +DECLARE +role VARCHAR(32); +BEGIN +SET role='[role]'; +END; +$$ +SELECT @@GLOBAL.names; +ERROR HY000: Unknown system variable 'names' +SELECT @@GLOBAL.password; +ERROR HY000: Unknown system variable 'password' +SELECT @@GLOBAL.role; +ERROR HY000: Unknown system variable 'role' +# +# End of 10.3 tests +# diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index dabd7956c44..067fd9beb48 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -339,3 +339,76 @@ END; / DELIMITER ;/ + +--echo # +--echo # MDEV-17693 Shift/reduce conflicts for NAMES,ROLE,PASSWORD in the option_value_no_option_type grammar +--echo # + +CREATE TABLE names (names INT); +SELECT names FROM names AS names; +DROP TABLE names; + +CREATE TABLE password (password INT); +SELECT password FROM password AS password; +DROP TABLE password; + +CREATE TABLE role (role INT); +SELECT role FROM role AS role; +DROP TABLE role; + +DELIMITER $$; +DECLARE + names VARCHAR(32) DEFAULT '[names]'; + password VARCHAR(32) DEFAULT '[password]'; + role VARCHAR(32) DEFAULT '[role]'; +BEGIN +<> + SELECT names; +<> + SELECT password; +<> + SELECT role; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_BAD_VAR_SHADOW +DECLARE + names VARCHAR(32); +BEGIN + SET names='[names]'; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +--error ER_SP_BAD_VAR_SHADOW +DECLARE + password VARCHAR(32); +BEGIN + SET password='[password]'; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +DECLARE + role VARCHAR(32); +BEGIN + SET role='[role]'; +END; +$$ +DELIMITER ;$$ + +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.names; +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.password; +--error ER_UNKNOWN_SYSTEM_VARIABLE +SELECT @@GLOBAL.role; + + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 70ba47ffdfc..812ded1e5c3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -884,10 +884,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 56 shift/reduce conflicts. + Currently there are 52 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 56 +%expect 52 /* Comments for TOKENS. @@ -1807,6 +1807,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ident label_ident sp_decl_ident + ident_set_usual_case ident_or_empty ident_table_alias ident_sysvar_name @@ -1828,6 +1829,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); keyword_data_type keyword_ident keyword_label + keyword_set_special_case + keyword_set_usual_case keyword_sp_block_section keyword_sp_decl keyword_sp_head @@ -15509,6 +15512,14 @@ ident_table_alias: } ; +ident_set_usual_case: + IDENT_sys + | keyword_set_usual_case + { + if (unlikely($$.copy_keyword(thd, &$1))) + MYSQL_YYABORT; + } + ; ident_sysvar_name: IDENT_sys @@ -15616,6 +15627,7 @@ user: user_maybe_role /* Keywords which we allow as table aliases. */ keyword_table_alias: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15627,6 +15639,7 @@ keyword_table_alias: /* Keyword that we allow for identifiers (except SP labels) */ keyword_ident: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15642,12 +15655,14 @@ keyword_ident: */ keyword_label: keyword_data_type + | keyword_set_special_case | keyword_sp_var_and_label | keyword_sysvar_type ; keyword_sysvar_name: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15658,6 +15673,18 @@ keyword_sysvar_name: keyword_sp_decl: keyword_data_type + | keyword_set_special_case + | keyword_sp_block_section + | keyword_sp_head + | keyword_sp_var_and_label + | keyword_sp_var_not_label + | keyword_sysvar_type + | keyword_verb_clause + | WINDOW_SYM + ; + +keyword_set_usual_case: + keyword_data_type | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15799,6 +15826,12 @@ keyword_verb_clause: | TRUNCATE_SYM /* Verb clause. Reserved in Oracle */ ; +keyword_set_special_case: + NAMES_SYM + | ROLE_SYM + | PASSWORD_SYM + ; + /* Keywords that start an SP block section. */ @@ -16036,7 +16069,6 @@ keyword_sp_var_and_label: | MYSQL_SYM | MYSQL_ERRNO_SYM | NAME_SYM - | NAMES_SYM | NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | NEXTVAL_SYM | NEW_SYM @@ -16061,7 +16093,6 @@ keyword_sp_var_and_label: | PARTIAL | PARTITIONING_SYM | PARTITIONS_SYM - | PASSWORD_SYM | PERSISTENT_SYM | PHASE_SYM | PLUGIN_SYM @@ -16101,7 +16132,6 @@ keyword_sp_var_and_label: | RETURNS_SYM | REUSE_SYM | REVERSE_SYM - | ROLE_SYM | ROLLUP_SYM | ROUTINE_SYM | ROWCOUNT_SYM @@ -16345,7 +16375,7 @@ option_value_following_option_type: /* Option values without preceding option_type. */ option_value_no_option_type: - ident equal set_expr_or_default + ident_set_usual_case equal set_expr_or_default { if (unlikely(Lex->set_variable(&$1, $3))) MYSQL_YYABORT; @@ -16462,6 +16492,11 @@ option_value_no_option_type: unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; } + | ROLE_SYM equal set_expr_or_default + { + if (unlikely(Lex->set_variable(&$1, $3))) + MYSQL_YYABORT; + } | PASSWORD_SYM opt_for_user text_or_password { LEX *lex = Lex; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 68a63c6c8b3..538daa8a5a6 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -278,10 +278,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %parse-param { THD *thd } %lex-param { THD *thd } /* - Currently there are 57 shift/reduce conflicts. + Currently there are 53 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 57 +%expect 53 /* Comments for TOKENS. @@ -1203,6 +1203,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ident label_ident sp_decl_ident + ident_set_usual_case ident_or_empty ident_table_alias ident_sysvar_name @@ -1225,6 +1226,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); keyword_data_type keyword_ident keyword_label + keyword_set_special_case + keyword_set_usual_case keyword_sp_block_section keyword_sp_decl keyword_sp_head @@ -15477,6 +15480,14 @@ ident_table_alias: } ; +ident_set_usual_case: + IDENT_sys + | keyword_set_usual_case + { + if (unlikely($$.copy_keyword(thd, &$1))) + MYSQL_YYABORT; + } + ; ident_sysvar_name: IDENT_sys @@ -15608,6 +15619,7 @@ user: user_maybe_role /* Keywords which we allow as table aliases. */ keyword_table_alias: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15620,6 +15632,7 @@ keyword_table_alias: /* Keyword that we allow for identifiers (except SP labels) */ keyword_ident: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15636,6 +15649,7 @@ keyword_ident: */ keyword_label: keyword_data_type + | keyword_set_special_case | keyword_sp_var_and_label | keyword_sysvar_type | FUNCTION_SYM @@ -15643,6 +15657,7 @@ keyword_label: keyword_sysvar_name: keyword_data_type + | keyword_set_special_case | keyword_sp_block_section | keyword_sp_head | keyword_sp_var_and_label @@ -15654,6 +15669,7 @@ keyword_sysvar_name: keyword_sp_decl: keyword_sp_head + | keyword_set_special_case | keyword_sp_var_and_label | keyword_sp_var_not_label | keyword_sysvar_type @@ -15661,8 +15677,21 @@ keyword_sp_decl: | WINDOW_SYM ; +keyword_set_usual_case: + keyword_data_type + | keyword_sp_block_section + | keyword_sp_head + | keyword_sp_var_and_label + | keyword_sp_var_not_label + | keyword_sysvar_type + | keyword_verb_clause + | FUNCTION_SYM + | WINDOW_SYM + ; + keyword_directly_assignable: keyword_data_type + | keyword_set_special_case | keyword_sp_var_and_label | keyword_sp_var_not_label | keyword_sysvar_type @@ -15802,6 +15831,12 @@ keyword_verb_clause: | TRUNCATE_SYM /* Verb clause. Reserved in Oracle */ ; +keyword_set_special_case: + NAMES_SYM + | ROLE_SYM + | PASSWORD_SYM + ; + /* Keywords that start an SP block section. */ @@ -16039,7 +16074,6 @@ keyword_sp_var_and_label: | MYSQL_SYM | MYSQL_ERRNO_SYM | NAME_SYM - | NAMES_SYM | NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | NEXTVAL_SYM | NEW_SYM @@ -16064,7 +16098,6 @@ keyword_sp_var_and_label: | PARTIAL | PARTITIONING_SYM | PARTITIONS_SYM - | PASSWORD_SYM | PERSISTENT_SYM | PHASE_SYM | PLUGIN_SYM @@ -16104,7 +16137,6 @@ keyword_sp_var_and_label: | RETURNS_SYM | REUSE_SYM | REVERSE_SYM - | ROLE_SYM | ROLLUP_SYM | ROUTINE_SYM | ROWCOUNT_SYM @@ -16397,7 +16429,7 @@ option_value_following_option_type: /* Option values without preceding option_type. */ option_value_no_option_type: - ident equal set_expr_or_default + ident_set_usual_case equal set_expr_or_default { if (unlikely(Lex->set_variable(&$1, $3))) MYSQL_YYABORT; @@ -16514,6 +16546,11 @@ option_value_no_option_type: unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; } + | ROLE_SYM equal set_expr_or_default + { + if (unlikely(Lex->set_variable(&$1, $3))) + MYSQL_YYABORT; + } | PASSWORD_SYM opt_for_user text_or_password { LEX *lex = Lex; From 6db773a5420fc7eedd6c02989967abbca3212143 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 15 Oct 2018 15:22:45 +0300 Subject: [PATCH 27/50] MDEV-17437 Semisync master fires invalid fd value assert The semisync ack collector hits fd's out-of-bound value assert through a stack of /usr/sbin/mysqld(_ZN12Ack_receiver17get_slave_socketsEP6fd_setPj+0x70)[0x7fa3bbe27400] /usr/sbin/mysqld(_ZN12Ack_receiver3runEv+0x540)[0x7fa3bbe27980] /usr/sbin/mysqld(ack_receive_handler+0x19)[0x7fa3bbe27a79] The reason of the failure must be the same as in https://bugs.mysql.com/bug.php?id=79865 whose fixes are applied with minor changes. Specifically, the semisync ack thread is changed to use poll() instead of select() on platforms where the former is defined. On the systems that still use select(), Ack receive thread will generate an error and semi sync will be switched off. Windows systems is exception case because on windows this limitation does not exists. The sustain manual testing with `mysqlslap --concurrency > 1024' in "background" while the slave io thread is restarting multiple times. --- sql/semisync_master_ack_receiver.cc | 55 ++++------- sql/semisync_master_ack_receiver.h | 147 +++++++++++++++++++++++++--- 2 files changed, 154 insertions(+), 48 deletions(-) diff --git a/sql/semisync_master_ack_receiver.cc b/sql/semisync_master_ack_receiver.cc index fc36ee35d5d..3fc3f4e31a4 100644 --- a/sql/semisync_master_ack_receiver.cc +++ b/sql/semisync_master_ack_receiver.cc @@ -173,25 +173,6 @@ inline void Ack_receiver::wait_for_slave_connection() mysql_cond_wait(&m_cond, &m_mutex); } -my_socket Ack_receiver::get_slave_sockets(fd_set *fds, uint *count) -{ - my_socket max_fd= INVALID_SOCKET; - Slave *slave; - I_List_iterator it(m_slaves); - - *count= 0; - FD_ZERO(fds); - while ((slave= it++)) - { - (*count)++; - my_socket fd= slave->sock_fd(); - max_fd= (fd > max_fd ? fd : max_fd); - FD_SET(fd, fds); - } - - return max_fd; -} - /* Auxilary function to initialize a NET object with given net buffer. */ static void init_net(NET *net, unsigned char *buff, unsigned int buff_len) { @@ -208,14 +189,17 @@ void Ack_receiver::run() THD *thd= new THD(next_thread_id(), false, true); NET net; unsigned char net_buff[REPLY_MESSAGE_MAX_LENGTH]; - fd_set read_fds; - my_socket max_fd= INVALID_SOCKET; - Slave *slave; my_thread_init(); DBUG_ENTER("Ack_receiver::run"); +#ifdef HAVE_POLL + Poll_socket_listener listener(m_slaves); +#else + Select_socket_listener listener(m_slaves); +#endif //HAVE_POLL + sql_print_information("Starting ack receiver thread"); thd->system_thread= SYSTEM_THREAD_SEMISYNC_MASTER_BACKGROUND; thd->thread_stack= (char*) &thd; @@ -231,9 +215,9 @@ void Ack_receiver::run() while (1) { - fd_set fds; int ret; - uint slave_count; + uint slave_count __attribute__((unused))= 0; + Slave *slave; mysql_mutex_lock(&m_mutex); if (unlikely(m_status == ST_STOPPING)) @@ -249,23 +233,25 @@ void Ack_receiver::run() continue; } - max_fd= get_slave_sockets(&read_fds, &slave_count); + if ((slave_count= listener.init_slave_sockets()) == 0) + goto end; m_slaves_changed= false; +#ifdef HAVE_POLL + DBUG_PRINT("info", ("fd count %u", slave_count)); +#else DBUG_PRINT("info", ("fd count %u, max_fd %d", slave_count,(int) max_fd)); +#endif } - struct timeval tv= {1, 0}; - fds= read_fds; - /* select requires max fd + 1 for the first argument */ - ret= select((int)(max_fd+1), &fds, NULL, NULL, &tv); + ret= listener.listen_on_sockets(); if (ret <= 0) { mysql_mutex_unlock(&m_mutex); ret= DBUG_EVALUATE_IF("rpl_semisync_simulate_select_error", -1, ret); - if (ret == -1) - sql_print_information("Failed to select() on semi-sync dump sockets, " + if (ret == -1 && errno != EINTR) + sql_print_information("Failed to wait on semi-sync sockets, " "error: errno=%d", socket_errno); /* Sleep 1us, so other threads can catch the m_mutex easily. */ my_sleep(1); @@ -273,11 +259,10 @@ void Ack_receiver::run() } set_stage_info(stage_reading_semi_sync_ack); - I_List_iterator it(m_slaves); - + Slave_ilist_iterator it(m_slaves); while ((slave= it++)) { - if (FD_ISSET(slave->sock_fd(), &fds)) + if (listener.is_socket_active(slave)) { ulong len; @@ -289,7 +274,7 @@ void Ack_receiver::run() repl_semisync_master.report_reply_packet(slave->server_id(), net.read_pos, len); else if (net.last_errno == ER_NET_READ_ERROR) - FD_CLR(slave->sock_fd(), &read_fds); + listener.clear_socket_info(slave); } } mysql_mutex_unlock(&m_mutex); diff --git a/sql/semisync_master_ack_receiver.h b/sql/semisync_master_ack_receiver.h index 619748a2159..9ff99edca5d 100644 --- a/sql/semisync_master_ack_receiver.h +++ b/sql/semisync_master_ack_receiver.h @@ -20,6 +20,22 @@ #include "my_pthread.h" #include "sql_class.h" #include "semisync.h" +#include + +struct Slave :public ilink +{ + THD *thd; + Vio vio; +#ifdef HAVE_POLL + uint m_fds_index; +#endif + my_socket sock_fd() const { return vio.mysql_socket.fd; } + uint server_id() const { return thd->variables.server_id; } +}; + +typedef I_List Slave_ilist; +typedef I_List_iterator Slave_ilist_iterator; + /** Ack_receiver is responsible to control ack receive thread and maintain slave information used by ack receive thread. @@ -92,18 +108,7 @@ private: /* If slave list is updated(add or remove). */ bool m_slaves_changed; - class Slave :public ilink - { -public: - THD *thd; - Vio vio; - - my_socket sock_fd() { return vio.mysql_socket.fd; } - uint server_id() { return thd->variables.server_id; } - }; - - I_List m_slaves; - + Slave_ilist m_slaves; pthread_t m_pid; /* Declare them private, so no one can copy the object. */ @@ -112,8 +117,124 @@ public: void set_stage_info(const PSI_stage_info &stage); void wait_for_slave_connection(); - my_socket get_slave_sockets(fd_set *fds, uint *count); }; + +#ifdef HAVE_POLL +#include +#include + +class Poll_socket_listener +{ +public: + Poll_socket_listener(const Slave_ilist &slaves) + :m_slaves(slaves) + { + } + + bool listen_on_sockets() + { + return poll(m_fds.data(), m_fds.size(), 1000 /*1 Second timeout*/); + } + + bool is_socket_active(const Slave *slave) + { + return m_fds[slave->m_fds_index].revents & POLLIN; + } + + void clear_socket_info(const Slave *slave) + { + m_fds[slave->m_fds_index].fd= -1; + m_fds[slave->m_fds_index].events= 0; + } + + uint init_slave_sockets() + { + Slave_ilist_iterator it(const_cast(m_slaves)); + Slave *slave; + uint fds_index= 0; + + m_fds.clear(); + while ((slave= it++)) + { + pollfd poll_fd; + poll_fd.fd= slave->sock_fd(); + poll_fd.events= POLLIN; + m_fds.push_back(poll_fd); + slave->m_fds_index= fds_index++; + } + return fds_index; + } + +private: + const Slave_ilist &m_slaves; + std::vector m_fds; +}; + +#else //NO POLL + +class Select_socket_listener +{ +public: + Select_socket_listener(const Slave_ilist &slaves) + :m_slaves(slaves), m_max_fd(INVALID_SOCKET) + { + } + + bool listen_on_sockets() + { + /* Reinitialze the fds with active fds before calling select */ + m_fds= m_init_fds; + struct timeval tv= {1,0}; + /* select requires max fd + 1 for the first argument */ + return select(m_max_fd+1, &m_fds, NULL, NULL, &tv); + } + + bool is_socket_active(const Slave *slave) + { + return FD_ISSET(slave->sock_fd(), &m_fds); + } + + void clear_socket_info(const Slave *slave) + { + FD_CLR(slave->sock_fd(), &m_init_fds); + } + + uint init_slave_sockets() + { + Slave_ilist_iterator it(m_slaves); + Slave *slave; + uint fds_index= 0; + + FD_ZERO(&m_init_fds); + while ((slave= it++)) + { + my_socket socket_id= slave->sock_fd(); + m_max_fd= (socket_id > m_max_fd ? socket_id : m_max_fd); +#ifndef WINDOWS + if (socket_id > FD_SETSIZE) + { + sql_print_error("Semisync slave socket fd is %u. " + "select() cannot handle if the socket fd is " + "greater than %u (FD_SETSIZE).", socket_id, FD_SETSIZE); + return 0; + } +#endif //WINDOWS + FD_SET(socket_id, &m_init_fds); + fds_index++; + } + return fds_index; + } + my_socket get_max_fd() { return m_max_fd; } + +private: + const Slave_ilist &m_slaves; + my_socket m_max_fd; + fd_set m_init_fds; + fd_set m_fds; +}; + +#endif //HAVE_POLL + extern Ack_receiver ack_receiver; #endif From 50bc55d462047281a4f74081a5325b64918494f1 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sat, 20 Oct 2018 12:49:46 +0300 Subject: [PATCH 28/50] MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end() Discrepancy in open indexes due to overwritten `read_partitions` upon `ha_open()` in `ha_partition::clone()`. [Fixes tempesta-tech/mariadb#551] --- mysql-test/main/partition_innodb.result | 11 +++++++++++ mysql-test/main/partition_innodb.test | 10 ++++++++++ sql/ha_partition.cc | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result index d27abc07984..c63cbc4601d 100644 --- a/mysql-test/main/partition_innodb.result +++ b/mysql-test/main/partition_innodb.result @@ -925,3 +925,14 @@ test_jfg test_jfg11 test_jfg test_jfg12#P#p1000 test_jfg test_jfg12#P#pmax DROP DATABASE test_jfg; +# +# MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end() +# +CREATE TABLE t1 (pk INT PRIMARY KEY, x INT, y INT, z INT, KEY (x), KEY (y, z)) +WITH SYSTEM VERSIONING +PARTITION BY SYSTEM_TIME (PARTITION p1 HISTORY, PARTITION pn CURRENT); +INSERT INTO t1 VALUES (1, 7, 8, 9), (2, NULL, NULL, NULL), (3, NULL, NULL, NULL); +SELECT COUNT(*) FROM t1 WHERE x IS NULL AND y IS NULL AND z IS NULL; +COUNT(*) +2 +DROP TABLE t1; diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test index 49430414913..d5b28430af3 100644 --- a/mysql-test/main/partition_innodb.test +++ b/mysql-test/main/partition_innodb.test @@ -1015,3 +1015,13 @@ SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE database_name = 'test_jfg'; DROP DATABASE test_jfg; + +--echo # +--echo # MDEV-16241 Assertion `inited==RND' failed in handler::ha_rnd_end() +--echo # +CREATE TABLE t1 (pk INT PRIMARY KEY, x INT, y INT, z INT, KEY (x), KEY (y, z)) +WITH SYSTEM VERSIONING +PARTITION BY SYSTEM_TIME (PARTITION p1 HISTORY, PARTITION pn CURRENT); +INSERT INTO t1 VALUES (1, 7, 8, 9), (2, NULL, NULL, NULL), (3, NULL, NULL, NULL); +SELECT COUNT(*) FROM t1 WHERE x IS NULL AND y IS NULL AND z IS NULL; +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c985ada64e6..1349571a3f8 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3516,7 +3516,8 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) if (init_partition_bitmaps()) goto err_alloc; - if (unlikely((error= + if (!MY_TEST(m_is_clone_of) && + unlikely((error= m_part_info->set_partition_bitmaps(m_partitions_to_open)))) goto err_alloc; From 8d61a7fb9fa5c400839fd54c851b8bb6c9c89ceb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 13 Nov 2018 06:17:19 +0100 Subject: [PATCH 29/50] compiler warning: this statement may fall through --- sql/sql_lex.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 155b8df26d5..38d356add20 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1430,13 +1430,12 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd) } /* Fall through */ case MY_LEX_CHAR: // Unknown or single char token - { if (c == '%' && (m_thd->variables.sql_mode & MODE_ORACLE)) { next_state= MY_LEX_START; return PERCENT_ORACLE_SYM; } - } + /* Fall through */ case MY_LEX_SKIP: // This should not happen if (c != ')') next_state= MY_LEX_START; // Allow signed numbers From 34a3972497dba006e597bf6c70aa3529a17ff8c9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 13 Nov 2018 06:25:52 +0100 Subject: [PATCH 30/50] MDEV-14429 sql_safe_updates in my.cnf not work update test results for embedded followup for 564a63b5a35 and 89a87e8e422 --- mysql-test/suite/funcs_1/r/is_routines_embedded.result | 6 +++--- mysql-test/suite/sys_vars/r/sysvars_server_embedded.result | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_routines_embedded.result b/mysql-test/suite/funcs_1/r/is_routines_embedded.result index a2acd83af49..1739a0c15c8 100644 --- a/mysql-test/suite/funcs_1/r/is_routines_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_routines_embedded.result @@ -198,7 +198,7 @@ SELECT * FROM db_datadict_2.res_6_408002_2; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost latin1 latin1_swedish_ci latin1_swedish_ci add_suppression def mtr add_suppression PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci check_testcase def mtr check_testcase PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name NOT IN ('timestamp') AND variable_name not like "Last_IO_Err*" AND variable_name != 'INNODB_IBUF_MAX_SIZE' AND variable_name != 'INNODB_USE_NATIVE_AIO' AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP' AND variable_name not like 'GTID%POS' AND variable_name != 'GTID_BINLOG_STATE' ORDER BY variable_name; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY BINARY SCHEMA_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema') ORDER BY BINARY SCHEMA_NAME; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql; SELECT * FROM INFORMATION_SCHEMA.EVENTS; SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert'); SELECT * FROM INFORMATION_SCHEMA.ROUTINES; SHOW STATUS LIKE 'slave_open_temp_tables'; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.plugin, mysql.proc, mysql.procs_priv, mysql.roles_mapping, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; SELECT * FROM INFORMATION_SCHEMA.PLUGINS; select * from information_schema.session_variables where variable_name = 'debug_sync'; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci -check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci +check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0, SQL_SAFE_UPDATES=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci connect testuser2, localhost, testuser2, , db_datadict; SELECT * FROM information_schema.routines; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION @@ -210,7 +210,7 @@ SELECT * FROM db_datadict_2.res_6_408002_2; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost latin1 latin1_swedish_ci latin1_swedish_ci add_suppression def mtr add_suppression PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci check_testcase def mtr check_testcase PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name NOT IN ('timestamp') AND variable_name not like "Last_IO_Err*" AND variable_name != 'INNODB_IBUF_MAX_SIZE' AND variable_name != 'INNODB_USE_NATIVE_AIO' AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP' AND variable_name not like 'GTID%POS' AND variable_name != 'GTID_BINLOG_STATE' ORDER BY variable_name; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY BINARY SCHEMA_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema') ORDER BY BINARY SCHEMA_NAME; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql; SELECT * FROM INFORMATION_SCHEMA.EVENTS; SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert'); SELECT * FROM INFORMATION_SCHEMA.ROUTINES; SHOW STATUS LIKE 'slave_open_temp_tables'; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.plugin, mysql.proc, mysql.procs_priv, mysql.roles_mapping, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; SELECT * FROM INFORMATION_SCHEMA.PLUGINS; select * from information_schema.session_variables where variable_name = 'debug_sync'; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci -check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci +check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0, SQL_SAFE_UPDATES=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci connect testuser3, localhost, testuser3, , test; SELECT * FROM information_schema.routines; SPECIFIC_NAME ROUTINE_CATALOG ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_BODY ROUTINE_DEFINITION EXTERNAL_NAME EXTERNAL_LANGUAGE PARAMETER_STYLE IS_DETERMINISTIC SQL_DATA_ACCESS SQL_PATH SECURITY_TYPE CREATED LAST_ALTERED SQL_MODE ROUTINE_COMMENT DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION @@ -222,7 +222,7 @@ SELECT * FROM db_datadict_2.res_6_408002_2; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost latin1 latin1_swedish_ci latin1_swedish_ci add_suppression def mtr add_suppression PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci check_testcase def mtr check_testcase PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name NOT IN ('timestamp') AND variable_name not like "Last_IO_Err*" AND variable_name != 'INNODB_IBUF_MAX_SIZE' AND variable_name != 'INNODB_USE_NATIVE_AIO' AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP' AND variable_name not like 'GTID%POS' AND variable_name != 'GTID_BINLOG_STATE' ORDER BY variable_name; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY BINARY SCHEMA_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema') ORDER BY BINARY SCHEMA_NAME; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' ORDER BY columns_in_mysql; SELECT * FROM INFORMATION_SCHEMA.EVENTS; SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert'); SELECT * FROM INFORMATION_SCHEMA.ROUTINES; SHOW STATUS LIKE 'slave_open_temp_tables'; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.plugin, mysql.proc, mysql.procs_priv, mysql.roles_mapping, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; SELECT * FROM INFORMATION_SCHEMA.PLUGINS; select * from information_schema.session_variables where variable_name = 'debug_sync'; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci -check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci +check_warnings def mtr check_warnings PROCEDURE NULL NULL NULL NULL NULL NULL NULL NULL SQL BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0, SQL_SAFE_UPDATES=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END NULL NULL SQL NO CONTAINS SQL NULL DEFINER YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss root@localhost utf8 utf8_general_ci latin1_swedish_ci connection default; disconnect testuser1; disconnect testuser2; diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 2d4f1fb3cea..efc380a396b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3889,7 +3889,7 @@ NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO -COMMAND_LINE_ARGUMENT NULL +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME SQL_SELECT_LIMIT SESSION_VALUE 18446744073709551615 GLOBAL_VALUE 18446744073709551615 From 573c4db57a9b9fc5998bd2a2f1311873ca78ab9f Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Tue, 13 Nov 2018 14:54:33 +0200 Subject: [PATCH 31/50] MDEV-17437 followup: fixing compilation on non-HAVE_POLL. --- sql/semisync_master_ack_receiver.cc | 3 ++- sql/semisync_master_ack_receiver.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/semisync_master_ack_receiver.cc b/sql/semisync_master_ack_receiver.cc index 3fc3f4e31a4..607d4844658 100644 --- a/sql/semisync_master_ack_receiver.cc +++ b/sql/semisync_master_ack_receiver.cc @@ -239,7 +239,8 @@ void Ack_receiver::run() #ifdef HAVE_POLL DBUG_PRINT("info", ("fd count %u", slave_count)); #else - DBUG_PRINT("info", ("fd count %u, max_fd %d", slave_count,(int) max_fd)); + DBUG_PRINT("info", ("fd count %u, max_fd %d", slave_count, + (int) listener.get_max_fd())); #endif } diff --git a/sql/semisync_master_ack_receiver.h b/sql/semisync_master_ack_receiver.h index 9ff99edca5d..feb3a51ccea 100644 --- a/sql/semisync_master_ack_receiver.h +++ b/sql/semisync_master_ack_receiver.h @@ -187,7 +187,7 @@ public: m_fds= m_init_fds; struct timeval tv= {1,0}; /* select requires max fd + 1 for the first argument */ - return select(m_max_fd+1, &m_fds, NULL, NULL, &tv); + return select((int) m_max_fd+1, &m_fds, NULL, NULL, &tv); } bool is_socket_active(const Slave *slave) @@ -202,7 +202,7 @@ public: uint init_slave_sockets() { - Slave_ilist_iterator it(m_slaves); + Slave_ilist_iterator it(const_cast(m_slaves)); Slave *slave; uint fds_index= 0; From 2a0b6de41bfd6cbd2ab2c02381ea89bb6bb612a4 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 13 Nov 2018 18:02:08 +0400 Subject: [PATCH 32/50] MDEV-17253 Oracle compatibility: The REVERSE key word for FOR loop behaves incorrectly --- mysql-test/main/sp-code.result | 12 ++-- mysql-test/main/sp-for-loop.result | 2 +- mysql-test/main/sp-for-loop.test | 2 +- .../suite/compat/oracle/r/sp-code.result | 42 ++++++------- mysql-test/suite/compat/oracle/r/sp.result | 60 ++++++++++++++++++- mysql-test/suite/compat/oracle/t/sp-code.test | 2 +- mysql-test/suite/compat/oracle/t/sp.test | 45 +++++++++++++- sql/sql_lex.cc | 16 ++--- sql/sql_lex.h | 4 +- sql/sql_yacc.yy | 7 +-- sql/sql_yacc_ora.yy | 7 +-- sql/structs.h | 29 ++++++--- 12 files changed, 169 insertions(+), 59 deletions(-) diff --git a/mysql-test/main/sp-code.result b/mysql-test/main/sp-code.result index c3af01d19e8..0ff30ba7764 100644 --- a/mysql-test/main/sp-code.result +++ b/mysql-test/main/sp-code.result @@ -1020,8 +1020,8 @@ i SHOW PROCEDURE CODE p1; Pos Instruction 0 set i@0 1 -1 set [upper_bound]@1 3 -2 jump_if_not 6(6) i@0 <= [upper_bound]@1 +1 set [target_bound]@1 3 +2 jump_if_not 6(6) i@0 <= [target_bound]@1 3 stmt 0 "SELECT i" 4 set i@0 i@0 + 1 5 jump 2 @@ -1058,11 +1058,11 @@ i j SHOW PROCEDURE CODE p1; Pos Instruction 0 set i@0 1 -1 set [upper_bound]@1 3 -2 jump_if_not 17(17) i@0 <= [upper_bound]@1 +1 set [target_bound]@1 3 +2 jump_if_not 17(17) i@0 <= [target_bound]@1 3 set j@2 1 -4 set [upper_bound]@3 3 -5 jump_if_not 13(13) j@2 <= [upper_bound]@3 +4 set [target_bound]@3 3 +5 jump_if_not 13(13) j@2 <= [target_bound]@3 6 jump_if_not 8(8) i@0 = 3 7 jump 17 8 jump_if_not 10(10) j@2 = 3 diff --git a/mysql-test/main/sp-for-loop.result b/mysql-test/main/sp-for-loop.result index 0da09586df5..d62d6ae3612 100644 --- a/mysql-test/main/sp-for-loop.result +++ b/mysql-test/main/sp-for-loop.result @@ -80,7 +80,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURNS INT BEGIN DECLARE total INT DEFAULT 0; fori: -FOR i IN REVERSE a..1 +FOR i IN REVERSE 1..a DO SET total= total + i; IF i = b THEN diff --git a/mysql-test/main/sp-for-loop.test b/mysql-test/main/sp-for-loop.test index 6350e9fb9d3..420ab58aaa7 100644 --- a/mysql-test/main/sp-for-loop.test +++ b/mysql-test/main/sp-for-loop.test @@ -86,7 +86,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURNS INT BEGIN DECLARE total INT DEFAULT 0; fori: - FOR i IN REVERSE a..1 + FOR i IN REVERSE 1..a DO SET total= total + i; IF i = b THEN diff --git a/mysql-test/suite/compat/oracle/r/sp-code.result b/mysql-test/suite/compat/oracle/r/sp-code.result index 1049563511c..1c6aacc8743 100644 --- a/mysql-test/suite/compat/oracle/r/sp-code.result +++ b/mysql-test/suite/compat/oracle/r/sp-code.result @@ -579,8 +579,8 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@2 0 1 set i@3 1 -2 set [upper_bound]@4 a@0 -3 jump_if_not 9(9) i@3 <= [upper_bound]@4 +2 set [target_bound]@4 a@0 +3 jump_if_not 9(9) i@3 <= [target_bound]@4 4 set total@2 total@2 + i@3 5 jump_if_not 7(7) i@3 = b@1 6 jump 9 @@ -598,7 +598,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURN INT AS total INT := 0; BEGIN -FOR i IN REVERSE a..1 +FOR i IN REVERSE 1..a LOOP total:= total + i; IF i = b THEN @@ -612,8 +612,8 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@2 0 1 set i@3 a@0 -2 set [upper_bound]@4 1 -3 jump_if_not 9(9) i@3 >= [upper_bound]@4 +2 set [target_bound]@4 1 +3 jump_if_not 9(9) i@3 >= [target_bound]@4 4 set total@2 total@2 + i@3 5 jump_if_not 7(7) i@3 = b@1 6 jump 9 @@ -651,12 +651,12 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@4 0 1 set ia@5 1 -2 set [upper_bound]@6 a@0 -3 jump_if_not 17(17) ia@5 <= [upper_bound]@6 +2 set [target_bound]@6 a@0 +3 jump_if_not 17(17) ia@5 <= [target_bound]@6 4 set total@4 total@4 + 1000 5 set ib@7 1 -6 set [upper_bound]@8 b@2 -7 jump_if_not 15(15) ib@7 <= [upper_bound]@8 +6 set [target_bound]@8 b@2 +7 jump_if_not 15(15) ib@7 <= [target_bound]@8 8 set total@4 total@4 + 1 9 jump_if_not 11(0) ib@7 = limitb@3 10 jump 15 @@ -698,8 +698,8 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@1 0 1 set i@2 1 -2 set [upper_bound]@3 a@0 -3 jump_if_not 11(11) i@2 <= [upper_bound]@3 +2 set [target_bound]@3 a@0 +3 jump_if_not 11(11) i@2 <= [target_bound]@3 4 set total@1 total@1 + 1000 5 jump_if_not 8(8) i@2 = 5 6 set i@2 i@2 + 1 @@ -735,11 +735,11 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@1 0 1 set i@2 1 -2 set [upper_bound]@3 a@0 -3 jump_if_not 16(16) i@2 <= [upper_bound]@3 +2 set [target_bound]@3 a@0 +3 jump_if_not 16(16) i@2 <= [target_bound]@3 4 set j@4 1 -5 set [upper_bound]@5 2 -6 jump_if_not 14(14) j@4 <= [upper_bound]@5 +5 set [target_bound]@5 2 +6 jump_if_not 14(14) j@4 <= [target_bound]@5 7 set total@1 total@1 + 1000 8 jump_if_not 11(11) i@2 = 5 9 set i@2 i@2 + 1 @@ -778,11 +778,11 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@1 0 1 set j@2 1 -2 set [upper_bound]@3 2 -3 jump_if_not 16(16) j@2 <= [upper_bound]@3 +2 set [target_bound]@3 2 +3 jump_if_not 16(16) j@2 <= [target_bound]@3 4 set i@4 1 -5 set [upper_bound]@5 a@0 -6 jump_if_not 14(14) i@4 <= [upper_bound]@5 +5 set [target_bound]@5 a@0 +6 jump_if_not 14(14) i@4 <= [target_bound]@5 7 set total@1 total@1 + 1000 8 jump_if_not 11(11) i@4 = 5 9 set i@4 i@4 + 1 @@ -814,8 +814,8 @@ SHOW FUNCTION CODE f1; Pos Instruction 0 set total@1 0 1 set i@2 1 -2 set [upper_bound]@3 a@0 -3 jump_if_not 10(10) i@2 <= [upper_bound]@3 +2 set [target_bound]@3 a@0 +3 jump_if_not 10(10) i@2 <= [target_bound]@3 4 jump_if_not 7(0) i@2 = 5 5 set i@2 i@2 + 1 6 jump 3 diff --git a/mysql-test/suite/compat/oracle/r/sp.result b/mysql-test/suite/compat/oracle/r/sp.result index 8e126b3f724..8fa49c4092a 100644 --- a/mysql-test/suite/compat/oracle/r/sp.result +++ b/mysql-test/suite/compat/oracle/r/sp.result @@ -843,7 +843,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURN INT AS total INT := 0; BEGIN -FOR i IN REVERSE a..1 +FOR i IN REVERSE 1..a LOOP total:= total + i; IF i = b THEN @@ -2502,3 +2502,61 @@ BEGIN SELECT 'a' IN ('b',v); END $$ ERROR HY000: Illegal parameter data types varchar and row for operation 'in' +# +# MDEV-17253 Oracle compatibility: The REVERSE key word for FOR loop behaves incorrectly +# +DECLARE +totalprice DECIMAL(12,2):=NULL; +loop_start INTEGER := 1; +BEGIN +FOR idx IN REVERSE loop_start..10 LOOP +SELECT idx; +END LOOP; +END; +$$ +idx +10 +idx +9 +idx +8 +idx +7 +idx +6 +idx +5 +idx +4 +idx +3 +idx +2 +idx +1 +CREATE PROCEDURE p1 AS +loop_start INTEGER := 1; +BEGIN +FOR idx IN REVERSE 3..loop_start LOOP +SELECT idx; +END LOOP; +END; +$$ +CALL p1(); +DROP PROCEDURE p1; +CREATE PROCEDURE p1 AS +loop_start INTEGER := 1; +BEGIN +FOR idx IN REVERSE loop_start..3 LOOP +SELECT idx; +END LOOP; +END; +$$ +CALL p1(); +idx +3 +idx +2 +idx +1 +DROP PROCEDURE p1; diff --git a/mysql-test/suite/compat/oracle/t/sp-code.test b/mysql-test/suite/compat/oracle/t/sp-code.test index 9a1f64e54b4..ea66ed80d2a 100644 --- a/mysql-test/suite/compat/oracle/t/sp-code.test +++ b/mysql-test/suite/compat/oracle/t/sp-code.test @@ -470,7 +470,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURN INT AS total INT := 0; BEGIN - FOR i IN REVERSE a..1 + FOR i IN REVERSE 1..a LOOP total:= total + i; IF i = b THEN diff --git a/mysql-test/suite/compat/oracle/t/sp.test b/mysql-test/suite/compat/oracle/t/sp.test index b88271ad3e2..6020bd95993 100644 --- a/mysql-test/suite/compat/oracle/t/sp.test +++ b/mysql-test/suite/compat/oracle/t/sp.test @@ -918,7 +918,7 @@ CREATE FUNCTION f1 (a INT, b INT) RETURN INT AS total INT := 0; BEGIN - FOR i IN REVERSE a..1 + FOR i IN REVERSE 1..a LOOP total:= total + i; IF i = b THEN @@ -2352,3 +2352,46 @@ BEGIN END $$ DELIMITER ;$$ +--echo # +--echo # MDEV-17253 Oracle compatibility: The REVERSE key word for FOR loop behaves incorrectly +--echo # + +DELIMITER $$; +DECLARE + totalprice DECIMAL(12,2):=NULL; + loop_start INTEGER := 1; +BEGIN + FOR idx IN REVERSE loop_start..10 LOOP + SELECT idx; + END LOOP; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE p1 AS + loop_start INTEGER := 1; +BEGIN + FOR idx IN REVERSE 3..loop_start LOOP + SELECT idx; + END LOOP; +END; +$$ +DELIMITER ;$$ +CALL p1(); +DROP PROCEDURE p1; + + +DELIMITER $$; +CREATE PROCEDURE p1 AS + loop_start INTEGER := 1; +BEGIN + FOR idx IN REVERSE loop_start..3 LOOP + SELECT idx; + END LOOP; +END; +$$ +DELIMITER ;$$ +CALL p1(); +DROP PROCEDURE p1; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 38d356add20..c048aeeb585 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -5695,7 +5695,7 @@ bool LEX::sp_for_loop_implicit_cursor_statement(THD *thd, return true; DBUG_ASSERT(thd->lex == this); bounds->m_direction= 1; - bounds->m_upper_bound= NULL; + bounds->m_target_bound= NULL; bounds->m_implicit_cursor= true; return false; } @@ -5739,7 +5739,7 @@ bool LEX::sp_for_loop_condition(THD *thd, const Lex_for_loop_st &loop) Item_splocal *args[2]; for (uint i= 0 ; i < 2; i++) { - sp_variable *src= i == 0 ? loop.m_index : loop.m_upper_bound; + sp_variable *src= i == 0 ? loop.m_index : loop.m_target_bound; args[i]= new (thd->mem_root) Item_splocal(thd, &sp_rcontext_handler_local, &src->name, src->offset, src->type_handler()); @@ -5800,11 +5800,11 @@ bool LEX::sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop, sp_add_for_loop_variable(thd, index, bounds.m_index->get_item())))) return true; - if (unlikely(!(loop->m_upper_bound= - bounds.m_upper_bound-> - sp_add_for_loop_upper_bound(thd, - bounds. - m_upper_bound->get_item())))) + if (unlikely(!(loop->m_target_bound= + bounds.m_target_bound-> + sp_add_for_loop_target_bound(thd, + bounds. + m_target_bound->get_item())))) return true; loop->m_direction= bounds.m_direction; loop->m_implicit_cursor= 0; @@ -5867,7 +5867,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd, bounds.m_index, item_func_sp))) return true; - loop->m_upper_bound= NULL; + loop->m_target_bound= NULL; loop->m_direction= bounds.m_direction; loop->m_cursor_offset= coffs; loop->m_implicit_cursor= bounds.m_implicit_cursor; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index dbd201d2d7c..13e1a5c0cf8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3736,9 +3736,9 @@ public: /* Integer range FOR LOOP methods */ sp_variable *sp_add_for_loop_variable(THD *thd, const LEX_CSTRING *name, Item *value); - sp_variable *sp_add_for_loop_upper_bound(THD *thd, Item *value) + sp_variable *sp_add_for_loop_target_bound(THD *thd, Item *value) { - LEX_CSTRING name= { STRING_WITH_LEN("[upper_bound]") }; + LEX_CSTRING name= { STRING_WITH_LEN("[target_bound]") }; return sp_add_for_loop_variable(thd, &name, value); } bool sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 812ded1e5c3..46eac699c04 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4769,16 +4769,13 @@ sp_for_loop_bounds: IN_SYM opt_sp_for_loop_direction for_loop_bound_expr DOT_DOT_SYM for_loop_bound_expr { - $$.m_direction= $2; - $$.m_index= $3; - $$.m_upper_bound= $5; - $$.m_implicit_cursor= false; + $$= Lex_for_loop_bounds_intrange($2, $3, $5); } | IN_SYM opt_sp_for_loop_direction for_loop_bound_expr { $$.m_direction= $2; $$.m_index= $3; - $$.m_upper_bound= NULL; + $$.m_target_bound= NULL; $$.m_implicit_cursor= false; } | IN_SYM opt_sp_for_loop_direction '(' sp_cursor_stmt ')' diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 538daa8a5a6..b8b2a862469 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -4615,16 +4615,13 @@ sp_for_loop_bounds: IN_SYM opt_sp_for_loop_direction for_loop_bound_expr DOT_DOT_SYM for_loop_bound_expr { - $$.m_direction= $2; - $$.m_index= $3; - $$.m_upper_bound= $5; - $$.m_implicit_cursor= false; + $$= Lex_for_loop_bounds_intrange($2, $3, $5); } | IN_SYM opt_sp_for_loop_direction for_loop_bound_expr { $$.m_direction= $2; $$.m_index= $3; - $$.m_upper_bound= NULL; + $$.m_target_bound= NULL; $$.m_implicit_cursor= false; } | IN_SYM opt_sp_for_loop_direction '(' sp_cursor_stmt ')' diff --git a/sql/structs.h b/sql/structs.h index d8b95a3509a..be9abbf4613 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -692,26 +692,41 @@ public: struct Lex_for_loop_bounds_st { public: - class sp_assignment_lex *m_index; - class sp_assignment_lex *m_upper_bound; + class sp_assignment_lex *m_index; // The first iteration value (or cursor) + class sp_assignment_lex *m_target_bound; // The last iteration value int8 m_direction; bool m_implicit_cursor; - bool is_for_loop_cursor() const { return m_upper_bound == NULL; } + bool is_for_loop_cursor() const { return m_target_bound == NULL; } +}; + + +class Lex_for_loop_bounds_intrange: public Lex_for_loop_bounds_st +{ +public: + Lex_for_loop_bounds_intrange(int8 direction, + class sp_assignment_lex *left_expr, + class sp_assignment_lex *right_expr) + { + m_direction= direction; + m_index= direction > 0 ? left_expr : right_expr; + m_target_bound= direction > 0 ? right_expr : left_expr; + m_implicit_cursor= false; + } }; struct Lex_for_loop_st { public: - class sp_variable *m_index; - class sp_variable *m_upper_bound; + class sp_variable *m_index; // The first iteration value (or cursor) + class sp_variable *m_target_bound; // The last iteration value int m_cursor_offset; int8 m_direction; bool m_implicit_cursor; void init() { m_index= 0; - m_upper_bound= 0; + m_target_bound= 0; m_direction= 0; m_implicit_cursor= false; } @@ -719,7 +734,7 @@ public: { *this= other; } - bool is_for_loop_cursor() const { return m_upper_bound == NULL; } + bool is_for_loop_cursor() const { return m_target_bound == NULL; } bool is_for_loop_explicit_cursor() const { return is_for_loop_cursor() && !m_implicit_cursor; From c688ab29ca83d2676d948477b585b3f278f38bbd Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 13 Nov 2018 11:14:21 -0500 Subject: [PATCH 33/50] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7454014f67c..0ecdac30b5d 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=19 +MYSQL_VERSION_PATCH=20 From f718477714aedd9fd598990169db6f512c9cae64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 14 Nov 2018 09:30:49 +0200 Subject: [PATCH 34/50] os_aio_validate_skip(): Fix a data race --- storage/innobase/os/os0file.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 5d0f3f4fc9c..6e4e578feaf 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1090,21 +1090,14 @@ os_aio_validate_skip() /** Try os_aio_validate() every this many times */ # define OS_AIO_VALIDATE_SKIP 13 - /** The os_aio_validate() call skip counter. - Use a signed type because of the race condition below. */ - static int os_aio_validate_count = OS_AIO_VALIDATE_SKIP; + static int os_aio_validate_count; - /* There is a race condition below, but it does not matter, - because this call is only for heuristic purposes. We want to - reduce the call frequency of the costly os_aio_validate() - check in debug builds. */ - --os_aio_validate_count; - - if (os_aio_validate_count > 0) { - return(true); + if (my_atomic_add32_explicit(&os_aio_validate_count, -1, + MY_MEMORY_ORDER_RELAXED) + % OS_AIO_VALIDATE_SKIP) { + return true; } - os_aio_validate_count = OS_AIO_VALIDATE_SKIP; return(os_aio_validate()); } #endif /* UNIV_DEBUG */ From 01d3e401971ab51bb4a2b9c8438b27d0161267f9 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Tue, 7 Aug 2018 15:28:58 +0200 Subject: [PATCH 35/50] MDEV-16217: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_num::get_date - clean up DEFAULT() to work only with default value and correctly print itself. - fix of DBUG_ASSERT about fields read/write - fix of field marking for write based really on the thd->mark_used_columns flag --- mysql-test/r/func_default.result | 10 +++++- mysql-test/r/func_time.result | 57 ++++++++++++++++++++++++++++++++ mysql-test/t/func_default.test | 5 +++ mysql-test/t/func_time.test | 32 ++++++++++++++++++ sql/field.cc | 17 ++++++++-- sql/field.h | 1 + sql/item.cc | 25 ++++++++++++-- sql/item.h | 5 +++ 8 files changed, 147 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result index 535be10da86..9699f0795e3 100644 --- a/mysql-test/r/func_default.result +++ b/mysql-test/r/func_default.result @@ -8,13 +8,21 @@ explain extended select default(str), default(strnull), default(intg), default(r id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select default('') AS `default(str)`,default('') AS `default(strnull)`,default(0) AS `default(intg)`,default(0) AS `default(rel)` from dual +Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from dual select * from t1 where str <> default(str); str strnull intg rel 0 0 explain select * from t1 where str <> default(str); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 +create view v1 as select default(str), default(strnull), default(intg), default(rel) from t1; +select * from v1; +default(str) default(strnull) default(intg) default(rel) +def NULL 10 3.14 +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select default(`t1`.`str`) AS `default(str)`,default(`t1`.`strnull`) AS `default(strnull)`,default(`t1`.`intg`) AS `default(intg)`,default(`t1`.`rel`) AS `default(rel)` from `t1` latin1 latin1_swedish_ci +drop view v1; drop table t1; CREATE TABLE t1 (id int(11), s varchar(20)); INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'); diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 5ca9cf5228f..16acf3fcbea 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -3423,3 +3423,60 @@ DROP TABLE t1,t2; # # End of 10.1 tests # +# +# MDEV-16217: Assertion `!table || (!table->read_set || +# bitmap_is_set(table->read_set, field_index))' +# failed in Field_num::get_date +# +CREATE TABLE t1 (pk int default 0, a1 date); +INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL); +CREATE VIEW v1 AS +SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1; +SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1; +a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) +0 +NULL +NULL +NULL +SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1; +a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) +0 +NULL +NULL +NULL +Warnings: +Warning 1292 Incorrect datetime value: '18446744073709551615' +CREATE TABLE t2 (pk int default 1, a1 date); +INSERT INTO t2 VALUES (4,NULL); +CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2; +select * from v2; +default(t1.pk) default(t2.pk) pk +0 1 1 +0 1 2 +0 1 3 +0 1 4 +show create view v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select default(`t1`.`pk`) AS `default(t1.pk)`,default(`t2`.`pk`) AS `default(t2.pk)`,`t1`.`pk` AS `pk` from (`t1` join `t2`) latin1 latin1_swedish_ci +CREATE view v3 as SELECT default(pk) from t2; +select * from v3; +default(pk) +1 +explain extended select * from v3; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual +explain extended select default(pk) from t2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select default(`test`.`t2`.`pk`) AS `default(pk)` from dual +show create view v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select default(`t2`.`pk`) AS `default(pk)` from `t2` latin1 latin1_swedish_ci +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; +# +# End of 10.2 tests +# diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test index fbd73990297..332bfca021f 100644 --- a/mysql-test/t/func_default.test +++ b/mysql-test/t/func_default.test @@ -11,6 +11,11 @@ explain extended select default(str), default(strnull), default(intg), default(r select * from t1 where str <> default(str); explain select * from t1 where str <> default(str); +create view v1 as select default(str), default(strnull), default(intg), default(rel) from t1; +select * from v1; +show create view v1; +drop view v1; + #TODO: uncomment when bug will be fixed #create table t2 select default(str), default(strnull), default(intg), default(rel) from t1; #show create table from t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 73f91bb90a0..d391e5f5059 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1910,3 +1910,35 @@ DROP TABLE t1,t2; --echo # --echo # End of 10.1 tests --echo # + +--echo # +--echo # MDEV-16217: Assertion `!table || (!table->read_set || +--echo # bitmap_is_set(table->read_set, field_index))' +--echo # failed in Field_num::get_date +--echo # +CREATE TABLE t1 (pk int default 0, a1 date); +INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL); + +CREATE VIEW v1 AS +SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1; + +SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1; +SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1; + +CREATE TABLE t2 (pk int default 1, a1 date); +INSERT INTO t2 VALUES (4,NULL); +CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2; +select * from v2; +show create view v2; +CREATE view v3 as SELECT default(pk) from t2; +select * from v3; +explain extended select * from v3; +explain extended select default(pk) from t2; +show create view v3; + +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/sql/field.cc b/sql/field.cc index caa84dc9932..6cd8940a893 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -70,8 +70,21 @@ const char field_separator=','; #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \ ((ulong) ((1LL << MY_MIN(arg, 4) * 8) - 1)) -#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))) -#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED DBUG_ASSERT(is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index)))) +// Column marked for read or the field set to read out or record[0] or [1] +#define ASSERT_COLUMN_MARKED_FOR_READ \ + DBUG_ASSERT(!table || \ + (!table->read_set || \ + bitmap_is_set(table->read_set, field_index) || \ + (!(ptr >= table->record[0] && \ + ptr < table->record[0] + table->s->reclength)))) + +#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED \ + DBUG_ASSERT(is_stat_field || !table || \ + (!table->write_set || \ + bitmap_is_set(table->write_set, field_index) || \ + (!(ptr >= table->record[0] && \ + ptr < table->record[0] + table->s->reclength))) || \ + (table->vcol_set && bitmap_is_set(table->vcol_set, field_index))) #define FLAGSTR(S,F) ((S) & (F) ? #F " " : "") diff --git a/sql/field.h b/sql/field.h index 22c276478b6..55c3ed4c4bd 100644 --- a/sql/field.h +++ b/sql/field.h @@ -630,6 +630,7 @@ public: bool utf8; /* Already in utf8 */ Item *expr; LEX_STRING name; /* Name of constraint */ + /* see VCOL_* (VCOL_FIELD_REF, ...) */ uint flags; Virtual_column_info() diff --git a/sql/item.cc b/sql/item.cc index 9ac1ed3947d..81da813a55e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8818,8 +8818,19 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) fixed= 1; return FALSE; } + + /* + DEFAULT() do not need table field so should not ask handler to bring + field value (mark column for read) + */ + enum_mark_columns save_mark_used_columns= thd->mark_used_columns; + thd->mark_used_columns= MARK_COLUMNS_NONE; if (!arg->fixed && arg->fix_fields(thd, &arg)) + { + thd->mark_used_columns= save_mark_used_columns; goto error; + } + thd->mark_used_columns= save_mark_used_columns; real_arg= arg->real_item(); @@ -8839,15 +8850,19 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) goto error; memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of()); - IF_DBUG(def_field->is_stat_field=1,); // a hack to fool ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED + // If non-constant default value expression if (def_field->default_value && def_field->default_value->flags) { uchar *newptr= (uchar*) thd->alloc(1+def_field->pack_length()); if (!newptr) goto error; + /* + Even if DEFAULT() do not read tables fields, the default value + expression can do it. + */ fix_session_vcol_expr_for_read(thd, def_field, def_field->default_value); if (thd->mark_used_columns != MARK_COLUMNS_NONE) - def_field->default_value->expr->walk(&Item::register_field_in_read_map, 1, 0); + def_field->default_value->expr->update_used_tables(); def_field->move_field(newptr+1, def_field->maybe_null() ? newptr : 0, 1); } else @@ -8871,6 +8886,12 @@ void Item_default_value::print(String *str, enum_query_type query_type) return; } str->append(STRING_WITH_LEN("default(")); + /* + We take DEFAULT from a field so do not need it value in case of const + tables but its name so we set QT_NO_DATA_EXPANSION (as we print for + table definition, also we do not need table and database name) + */ + query_type= (enum_query_type) (query_type | QT_NO_DATA_EXPANSION); arg->print(str, query_type); str->append(')'); } diff --git a/sql/item.h b/sql/item.h index 3a64ea1a75d..99eacdd6621 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5230,6 +5230,11 @@ public: return false; } table_map used_tables() const; + virtual void update_used_tables() + { + if (field && field->default_value) + field->default_value->expr->update_used_tables(); + } Field *get_tmp_table_field() { return 0; } Item *get_tmp_table_item(THD *thd) { return this; } Item_field *field_for_view_update() { return 0; } From 45769429d9a3bfa37ead21aa0d36214f980a00d7 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 14 Nov 2018 13:55:05 +0400 Subject: [PATCH 36/50] MDEV-17698 MEMORY engine performance regression --- sql/item.h | 4 ++++ sql/item_cmpfunc.cc | 18 +++++++----------- sql/sql_type_int.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/sql/item.h b/sql/item.h index d743cf6c19c..6bb97d3c3a3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1028,6 +1028,10 @@ public: If value is not null null_value flag will be reset to FALSE. */ virtual longlong val_int()=0; + Longlong_hybrid to_longlong_hybrid() + { + return Longlong_hybrid(val_int(), unsigned_flag); + } /** Get a value for CAST(x AS SIGNED). Too large positive unsigned integer values are converted diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ccbae1bad34..b1f7e54546a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2067,7 +2067,7 @@ bool Item_func_between::fix_length_and_dec() if (!args[0] || !args[1] || !args[2]) return TRUE; if (m_comparator.aggregate_for_comparison(Item_func_between::func_name(), - args, 3, true)) + args, 3, false)) { DBUG_ASSERT(current_thd->is_error()); return TRUE; @@ -2171,23 +2171,19 @@ longlong Item_func_between::val_int_cmp_string() longlong Item_func_between::val_int_cmp_int() { - longlong value= args[0]->val_int(), a, b; + Longlong_hybrid value= args[0]->to_longlong_hybrid(); if ((null_value= args[0]->null_value)) return 0; /* purecov: inspected */ - a= args[1]->val_int(); - b= args[2]->val_int(); + Longlong_hybrid a= args[1]->to_longlong_hybrid(); + Longlong_hybrid b= args[2]->to_longlong_hybrid(); if (!args[1]->null_value && !args[2]->null_value) - return (longlong) ((value >= a && value <= b) != negated); + return (longlong) ((value.cmp(a) >= 0 && value.cmp(b) <= 0) != negated); if (args[1]->null_value && args[2]->null_value) null_value= true; else if (args[1]->null_value) - { - null_value= value <= b; // not null if false range. - } + null_value= value.cmp(b) <= 0; // not null if false range. else - { - null_value= value >= a; - } + null_value= value.cmp(a) >= 0; return (longlong) (!null_value && negated); } diff --git a/sql/sql_type_int.h b/sql/sql_type_int.h index 1eda5651df5..7433bd5249f 100644 --- a/sql/sql_type_int.h +++ b/sql/sql_type_int.h @@ -24,12 +24,25 @@ class Longlong_hybrid protected: longlong m_value; bool m_unsigned; + int cmp_signed(const Longlong_hybrid& other) const + { + return m_value < other.m_value ? -1 : m_value == other.m_value ? 0 : 1; + } + int cmp_unsigned(const Longlong_hybrid& other) const + { + return (ulonglong) m_value < (ulonglong) other.m_value ? -1 : + m_value == other.m_value ? 0 : 1; + } public: Longlong_hybrid(longlong nr, bool unsigned_flag) :m_value(nr), m_unsigned(unsigned_flag) { } longlong value() const { return m_value; } bool is_unsigned() const { return m_unsigned; } + bool is_unsigned_outside_of_signed_range() const + { + return m_unsigned && ((ulonglong) m_value) > (ulonglong) LONGLONG_MAX; + } bool neg() const { return m_value < 0 && !m_unsigned; } ulonglong abs() const { @@ -39,6 +52,21 @@ public: return ((ulonglong) LONGLONG_MAX) + 1; return m_value < 0 ? -m_value : m_value; } + int cmp(const Longlong_hybrid& other) const + { + if (m_unsigned == other.m_unsigned) + return m_unsigned ? cmp_unsigned(other) : cmp_signed(other); + if (is_unsigned_outside_of_signed_range()) + return 1; + if (other.is_unsigned_outside_of_signed_range()) + return -1; + /* + The unsigned argument is in the range 0..LONGLONG_MAX. + The signed argument is in the range LONGLONG_MIN..LONGLONG_MAX. + Safe to compare as signed. + */ + return cmp_signed(other); + } }; #endif // SQL_TYPE_INT_INCLUDED From 13cd4cf436c1f7c38c6d9dfd8077c98fc655336b Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 13 Nov 2018 18:59:38 +0400 Subject: [PATCH 37/50] MDEV-17278 CURSOR FOR LOOP - ERROR: unexpected end of stream, read 0 bytes (SERVER CRASH) sp_instr_cursor_copy_struct::exec_core() created TYPELIBs on a wrong mem_root, the one which is initialized in sp_head::execute(), this code: /* init per-instruction memroot */ init_sql_alloc(&execute_mem_root, "per_instruction_memroot", MEM_ROOT_BLOCK_SIZE, 0, MYF(0)); This memory root cleans up after every sp_instr_xxx executed, so later sp_instr_cfetch::execute() tried to use already freed and trashed memory. Changing sp_instr_cursor_copy_struct::exec_core() to call tmp.export_structure() inside this block (not outside of it): thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); ... thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); So now TYPELIBs created by sp_instr_cursor_copy_struct::exec_core() are still available and valid when sp_instr_cfetch::execute() is called. They are freed at the end of dispatch_command() corresponding to the "CALL p1" statement. --- mysql-test/main/sp-cursor.result | 24 ++++++++++++++++++ mysql-test/main/sp-cursor.test | 21 ++++++++++++++++ .../compat/oracle/r/sp-cursor-rowtype.result | 25 +++++++++++++++++++ .../compat/oracle/t/sp-cursor-rowtype.test | 23 +++++++++++++++++ sql/sp_head.cc | 24 ++++++++++-------- 5 files changed, 106 insertions(+), 11 deletions(-) diff --git a/mysql-test/main/sp-cursor.result b/mysql-test/main/sp-cursor.result index f1dd8ed5eaa..42952be16e2 100644 --- a/mysql-test/main/sp-cursor.result +++ b/mysql-test/main/sp-cursor.result @@ -713,3 +713,27 @@ END; $$ CALL p1; DROP PROCEDURE p1; +# +# MDEV-17278 CURSOR FOR LOOP - ERROR: unexpected end of stream, read 0 bytes (SERVER CRASH) +# +CREATE TABLE t1 (id2 int, id int, en1 enum('aaa','a','b','c')); +INSERT INTO t1 VALUES(1,1,'aaa'),(2,2,'a'),(3,3,'b'),(4,4,'c'); +CREATE PROCEDURE p1() +BEGIN +FOR rec IN (SELECT en1 FROM t1) +DO +SELECT rec.en1; +END FOR; +END; +$$ +CALL p1(); +rec.en1 +aaa +rec.en1 +a +rec.en1 +b +rec.en1 +c +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/main/sp-cursor.test b/mysql-test/main/sp-cursor.test index 735514ff376..97483ef9caf 100644 --- a/mysql-test/main/sp-cursor.test +++ b/mysql-test/main/sp-cursor.test @@ -723,3 +723,24 @@ $$ DELIMITER ;$$ CALL p1; DROP PROCEDURE p1; + + +--echo # +--echo # MDEV-17278 CURSOR FOR LOOP - ERROR: unexpected end of stream, read 0 bytes (SERVER CRASH) +--echo # + +CREATE TABLE t1 (id2 int, id int, en1 enum('aaa','a','b','c')); +INSERT INTO t1 VALUES(1,1,'aaa'),(2,2,'a'),(3,3,'b'),(4,4,'c'); +DELIMITER $$; +CREATE PROCEDURE p1() +BEGIN + FOR rec IN (SELECT en1 FROM t1) + DO + SELECT rec.en1; + END FOR; +END; +$$ +DELIMITER ;$$ +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result b/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result index 093d52ba4e3..a60bbc38883 100644 --- a/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result +++ b/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result @@ -1479,3 +1479,28 @@ f1() 1 DROP FUNCTION f1; DROP TABLE t1; +# +# MDEV-17278 CURSOR FOR LOOP - ERROR: unexpected end of stream, read 0 bytes (SERVER CRASH) +# +CREATE TABLE t1 (id2 int, id int, en1 enum('aaa','a','b','c')); +INSERT INTO t1 VALUES(1,1,'aaa'),(2,2,'a'),(3,3,'b'),(4,4,'c'); +CREATE PROCEDURE p1() +AS +BEGIN +FOR rec IN (SELECT en1 FROM t1) +LOOP +SELECT rec.en1; +END LOOP; +END; +$$ +CALL p1(); +rec.en1 +aaa +rec.en1 +a +rec.en1 +b +rec.en1 +c +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/t/sp-cursor-rowtype.test b/mysql-test/suite/compat/oracle/t/sp-cursor-rowtype.test index 31e28d5c8de..ba0ca9b6a60 100644 --- a/mysql-test/suite/compat/oracle/t/sp-cursor-rowtype.test +++ b/mysql-test/suite/compat/oracle/t/sp-cursor-rowtype.test @@ -1572,3 +1572,26 @@ DELIMITER ;$$ SELECT f1(); DROP FUNCTION f1; DROP TABLE t1; + + +--echo # +--echo # MDEV-17278 CURSOR FOR LOOP - ERROR: unexpected end of stream, read 0 bytes (SERVER CRASH) +--echo # + +CREATE TABLE t1 (id2 int, id int, en1 enum('aaa','a','b','c')); +INSERT INTO t1 VALUES(1,1,'aaa'),(2,2,'a'),(3,3,'b'),(4,4,'c'); + +DELIMITER $$; +CREATE PROCEDURE p1() +AS +BEGIN + FOR rec IN (SELECT en1 FROM t1) + LOOP + SELECT rec.en1; + END LOOP; +END; +$$ +DELIMITER ;$$ +CALL p1(); +DROP PROCEDURE p1; +DROP TABLE t1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index c8b9576fe88..28411509adf 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -4475,19 +4475,21 @@ sp_instr_cursor_copy_struct::exec_core(THD *thd, uint *nextp) if (!(ret= tmp.open(thd))) { Row_definition_list defs; + /* + Create row elements on the caller arena. + It's the same arena that was used during sp_rcontext::create(). + This puts cursor%ROWTYPE elements on the same mem_root + where explicit ROW elements and table%ROWTYPE reside: + - tmp.export_structure() allocates new Spvar_definition instances + and their components (such as TYPELIBs). + - row->row_create_items() creates new Item_field instances. + They all are created on the same mem_root. + */ + Query_arena current_arena; + thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); if (!(ret= tmp.export_structure(thd, &defs))) - { - /* - Create row elements on the caller arena. - It's the same arena that was used during sp_rcontext::create(). - This puts cursor%ROWTYPE elements on the same mem_root - where explicit ROW elements and table%ROWTYPE reside. - */ - Query_arena current_arena; - thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); row->row_create_items(thd, &defs); - thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); - } + thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); tmp.close(thd); } } From 47274d902e63663522176614157b4eace8a17b8e Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 14 Nov 2018 15:46:53 +0100 Subject: [PATCH 38/50] fix of test suite --- mysql-test/r/partition_innodb.result | 2 +- mysql-test/t/partition_innodb.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index ee3525cb085..b1405be3f12 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -901,7 +901,7 @@ INSERT INTO t1 VALUES (1),(2); INSERT IGNORE INTO t2 VALUES (2,2),('three',3),(4,4); Warnings: Warning 1366 Incorrect integer value: 'three' for column 'b' at row 2 -UPDATE v SET a = NULL ORDER BY a, b; +UPDATE v SET a = NULL; Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'foo' DROP view v; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 5dbe9f467fa..5674a889023 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -1008,7 +1008,7 @@ CREATE ALGORITHM = MERGE VIEW v AS SELECT a, b FROM t1 STRAIGHT_JOIN t2 WHERE b INSERT INTO t1 VALUES (1),(2); INSERT IGNORE INTO t2 VALUES (2,2),('three',3),(4,4); -UPDATE v SET a = NULL ORDER BY a, b; +UPDATE v SET a = NULL; DROP view v; DROP TABLE t1, t2; From 7f175595c83b3ef55d6aa00cc7707ec565398bf5 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 15 Nov 2018 06:35:37 +0400 Subject: [PATCH 39/50] Backport for "MDEV-17698 MEMORY engine performance regression" Also, backporting a part of: MDEV-11485 Split Item_func_between::val_int() into virtual methods in Type_handler for easier merge to 10.3. --- sql/item.h | 4 + sql/item_cmpfunc.cc | 190 ++++++++++++++++++++++++-------------------- sql/item_cmpfunc.h | 5 ++ sql/sql_type_int.h | 28 +++++++ 4 files changed, 140 insertions(+), 87 deletions(-) diff --git a/sql/item.h b/sql/item.h index dacac2d725e..38dce1f3b97 100644 --- a/sql/item.h +++ b/sql/item.h @@ -794,6 +794,10 @@ public: If value is not null null_value flag will be reset to FALSE. */ virtual longlong val_int()=0; + Longlong_hybrid to_longlong_hybrid() + { + return Longlong_hybrid(val_int(), unsigned_flag); + } /* This is just a shortcut to avoid the cast. You should still use unsigned_flag to check the sign of the item. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d4a2c767b15..3af79c23ee7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -158,7 +158,10 @@ static int cmp_row_type(Item* item1, Item* item2) 0 otherwise */ -static int agg_cmp_type(Item_result *type, Item **items, uint nitems) +static int agg_cmp_type(Item_result *type, + Item **items, + uint nitems, + bool int_uint_as_dec) { uint unsigned_count= items[0]->unsigned_flag; type[0]= items[0]->cmp_type(); @@ -180,7 +183,9 @@ static int agg_cmp_type(Item_result *type, Item **items, uint nitems) If all arguments are of INT type but have different unsigned_flag values, switch to DECIMAL_RESULT. */ - if (type[0] == INT_RESULT && unsigned_count != nitems && unsigned_count != 0) + if (int_uint_as_dec && + type[0] == INT_RESULT && + unsigned_count != nitems && unsigned_count != 0) type[0]= DECIMAL_RESULT; return 0; } @@ -2295,7 +2300,7 @@ void Item_func_between::fix_length_and_dec() */ if (!args[0] || !args[1] || !args[2]) return; - if ( agg_cmp_type(&cmp_type, args, 3)) + if (agg_cmp_type(&cmp_type, args, 3, false)) return; if (cmp_type == STRING_RESULT && agg_arg_charsets_for_comparison(cmp_collation, args, 3)) @@ -2329,6 +2334,97 @@ void Item_func_between::fix_length_and_dec() } +longlong Item_func_between::val_int_cmp_string() +{ + String *value,*a,*b; + value=args[0]->val_str(&value0); + if ((null_value=args[0]->null_value)) + return 0; + a= args[1]->val_str(&value1); + b= args[2]->val_str(&value2); + if (!args[1]->null_value && !args[2]->null_value) + return (longlong) ((sortcmp(value,a,cmp_collation.collation) >= 0 && + sortcmp(value,b,cmp_collation.collation) <= 0) != + negated); + if (args[1]->null_value && args[2]->null_value) + null_value= true; + else if (args[1]->null_value) + { + // Set to not null if false range. + null_value= sortcmp(value,b,cmp_collation.collation) <= 0; + } + else + { + // Set to not null if false range. + null_value= sortcmp(value,a,cmp_collation.collation) >= 0; + } + return (longlong) (!null_value && negated); +} + + +longlong Item_func_between::val_int_cmp_int() +{ + Longlong_hybrid value= args[0]->to_longlong_hybrid(); + if ((null_value= args[0]->null_value)) + return 0; /* purecov: inspected */ + Longlong_hybrid a= args[1]->to_longlong_hybrid(); + Longlong_hybrid b= args[2]->to_longlong_hybrid(); + if (!args[1]->null_value && !args[2]->null_value) + return (longlong) ((value.cmp(a) >= 0 && value.cmp(b) <= 0) != negated); + if (args[1]->null_value && args[2]->null_value) + null_value= true; + else if (args[1]->null_value) + null_value= value.cmp(b) <= 0; // not null if false range. + else + null_value= value.cmp(a) >= 0; + return (longlong) (!null_value && negated); +} + + +longlong Item_func_between::val_int_cmp_decimal() +{ + my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf), + a_buf, *a_dec, b_buf, *b_dec; + if ((null_value=args[0]->null_value)) + return 0; /* purecov: inspected */ + a_dec= args[1]->val_decimal(&a_buf); + b_dec= args[2]->val_decimal(&b_buf); + if (!args[1]->null_value && !args[2]->null_value) + return (longlong) ((my_decimal_cmp(dec, a_dec) >= 0 && + my_decimal_cmp(dec, b_dec) <= 0) != negated); + if (args[1]->null_value && args[2]->null_value) + null_value= true; + else if (args[1]->null_value) + null_value= (my_decimal_cmp(dec, b_dec) <= 0); + else + null_value= (my_decimal_cmp(dec, a_dec) >= 0); + return (longlong) (!null_value && negated); +} + + +longlong Item_func_between::val_int_cmp_real() +{ + double value= args[0]->val_real(),a,b; + if ((null_value=args[0]->null_value)) + return 0; /* purecov: inspected */ + a= args[1]->val_real(); + b= args[2]->val_real(); + if (!args[1]->null_value && !args[2]->null_value) + return (longlong) ((value >= a && value <= b) != negated); + if (args[1]->null_value && args[2]->null_value) + null_value= true; + else if (args[1]->null_value) + { + null_value= value <= b; // not null if false range. + } + else + { + null_value= value >= a; + } + return (longlong) (!null_value && negated); +} + + longlong Item_func_between::val_int() { DBUG_ASSERT(fixed == 1); @@ -2370,94 +2466,14 @@ longlong Item_func_between::val_int() null_value= value >= a; break; } - case STRING_RESULT: - { - String *value,*a,*b; - value=args[0]->val_str(&value0); - if ((null_value=args[0]->null_value)) - return 0; - a=args[1]->val_str(&value1); - b=args[2]->val_str(&value2); - if (!args[1]->null_value && !args[2]->null_value) - return (longlong) ((sortcmp(value,a,cmp_collation.collation) >= 0 && - sortcmp(value,b,cmp_collation.collation) <= 0) != - negated); - if (args[1]->null_value && args[2]->null_value) - null_value=1; - else if (args[1]->null_value) - { - // Set to not null if false range. - null_value= sortcmp(value,b,cmp_collation.collation) <= 0; - } - else - { - // Set to not null if false range. - null_value= sortcmp(value,a,cmp_collation.collation) >= 0; - } - break; - } + return val_int_cmp_string(); case INT_RESULT: - { - longlong value=args[0]->val_int(), a, b; - if ((null_value=args[0]->null_value)) - return 0; /* purecov: inspected */ - a=args[1]->val_int(); - b=args[2]->val_int(); - if (!args[1]->null_value && !args[2]->null_value) - return (longlong) ((value >= a && value <= b) != negated); - if (args[1]->null_value && args[2]->null_value) - null_value=1; - else if (args[1]->null_value) - { - null_value= value <= b; // not null if false range. - } - else - { - null_value= value >= a; - } - break; - } + return val_int_cmp_int(); case DECIMAL_RESULT: - { - my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf), - a_buf, *a_dec, b_buf, *b_dec; - if ((null_value=args[0]->null_value)) - return 0; /* purecov: inspected */ - a_dec= args[1]->val_decimal(&a_buf); - b_dec= args[2]->val_decimal(&b_buf); - if (!args[1]->null_value && !args[2]->null_value) - return (longlong) ((my_decimal_cmp(dec, a_dec) >= 0 && - my_decimal_cmp(dec, b_dec) <= 0) != negated); - if (args[1]->null_value && args[2]->null_value) - null_value=1; - else if (args[1]->null_value) - null_value= (my_decimal_cmp(dec, b_dec) <= 0); - else - null_value= (my_decimal_cmp(dec, a_dec) >= 0); - break; - } + return val_int_cmp_decimal(); case REAL_RESULT: - { - double value= args[0]->val_real(),a,b; - if ((null_value=args[0]->null_value)) - return 0; /* purecov: inspected */ - a= args[1]->val_real(); - b= args[2]->val_real(); - if (!args[1]->null_value && !args[2]->null_value) - return (longlong) ((value >= a && value <= b) != negated); - if (args[1]->null_value && args[2]->null_value) - null_value=1; - else if (args[1]->null_value) - { - null_value= value <= b; // not null if false range. - } - else - { - null_value= value >= a; - } - break; - } + return val_int_cmp_real(); case ROW_RESULT: case IMPOSSIBLE_RESULT: DBUG_ASSERT(0); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index c4e6a53dd6b..12a12e05845 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -694,6 +694,11 @@ public: bool eval_not_null_tables(uchar *opt_arg); void fix_after_pullout(st_select_lex *new_parent, Item **ref); bool count_sargable_conds(uchar *arg); + + longlong val_int_cmp_string(); + longlong val_int_cmp_int(); + longlong val_int_cmp_real(); + longlong val_int_cmp_decimal(); }; diff --git a/sql/sql_type_int.h b/sql/sql_type_int.h index 1eda5651df5..7433bd5249f 100644 --- a/sql/sql_type_int.h +++ b/sql/sql_type_int.h @@ -24,12 +24,25 @@ class Longlong_hybrid protected: longlong m_value; bool m_unsigned; + int cmp_signed(const Longlong_hybrid& other) const + { + return m_value < other.m_value ? -1 : m_value == other.m_value ? 0 : 1; + } + int cmp_unsigned(const Longlong_hybrid& other) const + { + return (ulonglong) m_value < (ulonglong) other.m_value ? -1 : + m_value == other.m_value ? 0 : 1; + } public: Longlong_hybrid(longlong nr, bool unsigned_flag) :m_value(nr), m_unsigned(unsigned_flag) { } longlong value() const { return m_value; } bool is_unsigned() const { return m_unsigned; } + bool is_unsigned_outside_of_signed_range() const + { + return m_unsigned && ((ulonglong) m_value) > (ulonglong) LONGLONG_MAX; + } bool neg() const { return m_value < 0 && !m_unsigned; } ulonglong abs() const { @@ -39,6 +52,21 @@ public: return ((ulonglong) LONGLONG_MAX) + 1; return m_value < 0 ? -m_value : m_value; } + int cmp(const Longlong_hybrid& other) const + { + if (m_unsigned == other.m_unsigned) + return m_unsigned ? cmp_unsigned(other) : cmp_signed(other); + if (is_unsigned_outside_of_signed_range()) + return 1; + if (other.is_unsigned_outside_of_signed_range()) + return -1; + /* + The unsigned argument is in the range 0..LONGLONG_MAX. + The signed argument is in the range LONGLONG_MIN..LONGLONG_MAX. + Safe to compare as signed. + */ + return cmp_signed(other); + } }; #endif // SQL_TYPE_INT_INCLUDED From 1956695c69467375fc634ad709f1b32a2daf29b1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 15 Nov 2018 16:45:43 +0400 Subject: [PATCH 40/50] MDEV-17724 Wrong result for BETWEEN 0 AND 18446744073709551615 The fix for "MDEV-17698 MEMORY engine performance regression" previously fixed this problem. - Adding the test for MDEV-17724 - Re-recording wrong results for tests: * engines/iuds/r/insert_number * engines/iuds/r/update_delete_number which started to fail since MDEV-17698 --- mysql-test/r/bigint.result | 11 ++ .../suite/engines/iuds/r/insert_number.result | 100 ++++++++++++++++++ .../iuds/r/update_delete_number.result | 17 +++ mysql-test/t/bigint.test | 9 ++ 4 files changed, 137 insertions(+) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index b06ec5805a0..760b9c7b205 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -508,3 +508,14 @@ DROP TABLE t1; SELECT 100 BETWEEN 1 AND 9223372036854775808; 100 BETWEEN 1 AND 9223372036854775808 1 +# +# MDEV-17724 Wrong result for BETWEEN 0 AND 18446744073709551615 +# +CREATE TABLE t1 (c1 bigint(20) unsigned NOT NULL); +INSERT INTO t1 VALUES (0),(101),(255); +SELECT * FROM t1 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1; +c1 +0 +101 +255 +DROP TABLE t1; diff --git a/mysql-test/suite/engines/iuds/r/insert_number.result b/mysql-test/suite/engines/iuds/r/insert_number.result index ab56b82807c..9f937b33364 100644 --- a/mysql-test/suite/engines/iuds/r/insert_number.result +++ b/mysql-test/suite/engines/iuds/r/insert_number.result @@ -31565,8 +31565,33 @@ c1 c2 c3 c4 c5 c6 c7 0 -9223372036854775808 1 2 3 4 5 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6; c1 c2 c3 c4 c5 c6 c7 +0 NULL 5 6 NULL 0 NULL +0 -9223372036854775808 1 2 3 4 5 +0 0 17 18 19 20 21 +0 124 22 23 24 25 26 +0 124 27 28 29 30 31 +0 -9223372036854775808 31 32 33 34 35 +0 0 32 32 34 35 36 +101 0 37 38 39 40 41 +101 -102 103 104 105 106 107 +102 -109 110 111 112 113 114 +103 -109 110 111 112 113 114 +105 NULL 102 103 104 105 106 +108 -109 110 111 112 101 114 +108 -109 110 111 112 102 114 +108 -109 110 111 112 113 114 +115 -116 117 118 119 120 121 +122 -123 124 125 126 127 128 +255 -2147483648 6 7 8 9 10 +65535 -8388608 11 12 13 14 15 +16777215 -32768 16 17 18 19 20 +4294967295 -128 21 22 23 24 25 +18446744073709551615 9223372036854775807 26 27 28 29 30 +18446744073709551615 9223372036854775807 36 37 38 39 40 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 LIMIT 2; c1 c2 c3 c4 c5 c6 c7 +0 NULL 5 6 NULL 0 NULL +0 -9223372036854775808 1 2 3 4 5 SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6; c1 c2 c3 c4 c5 c6 c7 0 NULL 5 6 NULL 0 NULL @@ -31726,8 +31751,33 @@ c1 c2 c3 c4 c5 c6 c7 0 -9223372036854775808 31 32 33 34 35 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC; c1 c2 c3 c4 c5 c6 c7 +0 0 32 32 34 35 36 +0 -9223372036854775808 31 32 33 34 35 +0 124 27 28 29 30 31 +0 124 22 23 24 25 26 +0 0 17 18 19 20 21 +0 -9223372036854775808 1 2 3 4 5 +0 NULL 5 6 NULL 0 NULL +101 -102 103 104 105 106 107 +101 0 37 38 39 40 41 +102 -109 110 111 112 113 114 +103 -109 110 111 112 113 114 +105 NULL 102 103 104 105 106 +108 -109 110 111 112 113 114 +108 -109 110 111 112 102 114 +108 -109 110 111 112 101 114 +115 -116 117 118 119 120 121 +122 -123 124 125 126 127 128 +255 -2147483648 6 7 8 9 10 +65535 -8388608 11 12 13 14 15 +16777215 -32768 16 17 18 19 20 +4294967295 -128 21 22 23 24 25 +18446744073709551615 9223372036854775807 36 37 38 39 40 +18446744073709551615 9223372036854775807 26 27 28 29 30 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC LIMIT 2; c1 c2 c3 c4 c5 c6 c7 +0 0 32 32 34 35 36 +0 -9223372036854775808 31 32 33 34 35 SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6 DESC; c1 c2 c3 c4 c5 c6 c7 0 0 32 32 34 35 36 @@ -31993,8 +32043,33 @@ c1 c2 c3 c4 c5 c6 c7 18446744073709551615 9223372036854775807 36 37 38 39 40 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6; c1 c2 c3 c4 c5 c6 c7 +0 NULL 5 6 NULL 0 NULL +0 -9223372036854775808 1 2 3 4 5 +0 0 17 18 19 20 21 +0 124 22 23 24 25 26 +0 124 27 28 29 30 31 +0 -9223372036854775808 31 32 33 34 35 +0 0 32 32 34 35 36 +101 0 37 38 39 40 41 +101 -102 103 104 105 106 107 +102 -109 110 111 112 113 114 +103 -109 110 111 112 113 114 +105 NULL 102 103 104 105 106 +108 -109 110 111 112 101 114 +108 -109 110 111 112 102 114 +108 -109 110 111 112 113 114 +115 -116 117 118 119 120 121 +122 -123 124 125 126 127 128 +255 -2147483648 6 7 8 9 10 +65535 -8388608 11 12 13 14 15 +16777215 -32768 16 17 18 19 20 +4294967295 -128 21 22 23 24 25 +18446744073709551615 9223372036854775807 26 27 28 29 30 +18446744073709551615 9223372036854775807 36 37 38 39 40 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 LIMIT 2; c1 c2 c3 c4 c5 c6 c7 +0 NULL 5 6 NULL 0 NULL +0 -9223372036854775808 1 2 3 4 5 SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6; c1 c2 c3 c4 c5 c6 c7 0 NULL 5 6 NULL 0 NULL @@ -32154,8 +32229,33 @@ c1 c2 c3 c4 c5 c6 c7 18446744073709551615 9223372036854775807 26 27 28 29 30 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC; c1 c2 c3 c4 c5 c6 c7 +0 0 32 32 34 35 36 +0 -9223372036854775808 31 32 33 34 35 +0 124 27 28 29 30 31 +0 124 22 23 24 25 26 +0 0 17 18 19 20 21 +0 -9223372036854775808 1 2 3 4 5 +0 NULL 5 6 NULL 0 NULL +101 -102 103 104 105 106 107 +101 0 37 38 39 40 41 +102 -109 110 111 112 113 114 +103 -109 110 111 112 113 114 +105 NULL 102 103 104 105 106 +108 -109 110 111 112 113 114 +108 -109 110 111 112 102 114 +108 -109 110 111 112 101 114 +115 -116 117 118 119 120 121 +122 -123 124 125 126 127 128 +255 -2147483648 6 7 8 9 10 +65535 -8388608 11 12 13 14 15 +16777215 -32768 16 17 18 19 20 +4294967295 -128 21 22 23 24 25 +18446744073709551615 9223372036854775807 36 37 38 39 40 +18446744073709551615 9223372036854775807 26 27 28 29 30 SELECT * FROM t2 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1,c6 DESC LIMIT 2; c1 c2 c3 c4 c5 c6 c7 +0 0 32 32 34 35 36 +0 -9223372036854775808 31 32 33 34 35 SELECT * FROM t2 WHERE c1 IN (0,18446744073709551615) ORDER BY c1,c6 DESC; c1 c2 c3 c4 c5 c6 c7 0 0 32 32 34 35 36 diff --git a/mysql-test/suite/engines/iuds/r/update_delete_number.result b/mysql-test/suite/engines/iuds/r/update_delete_number.result index 8e190870092..e676b7a79f8 100644 --- a/mysql-test/suite/engines/iuds/r/update_delete_number.result +++ b/mysql-test/suite/engines/iuds/r/update_delete_number.result @@ -3768,8 +3768,25 @@ c1 c2 c3 -12 18446744073709551615 12 SELECT * FROM t2 WHERE c2 BETWEEN 0 AND 18446744073709551615 ORDER BY c2,c1; c1 c2 c3 +-4 4 4 +-9 9 9 +0 255 13 +-9223372036854775808 18446744073709551615 12 +-12 18446744073709551615 12 +-11 18446744073709551615 11 +-8 18446744073709551615 8 +-7 18446744073709551615 7 +-6 18446744073709551615 6 +-5 18446744073709551615 5 +-3 18446744073709551615 3 +-2 18446744073709551615 2 +-1 18446744073709551615 1 +50 18446744073709551615 10 +9223372036854775807 18446744073709551615 14 SELECT * FROM t2 WHERE c2 BETWEEN 0 AND 18446744073709551615 ORDER BY c2,c1 DESC LIMIT 2; c1 c2 c3 +-4 4 4 +-9 9 9 SELECT * FROM t2 WHERE c2 IN(0,18446744073709551615) ORDER BY c2,c1 DESC; c1 c2 c3 9223372036854775807 18446744073709551615 14 diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index fb18d60edd9..71fef813a8d 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -414,3 +414,12 @@ DROP TABLE t1; --echo # MDEV-9372 select 100 between 1 and 9223372036854775808 returns false --echo # SELECT 100 BETWEEN 1 AND 9223372036854775808; + +--echo # +--echo # MDEV-17724 Wrong result for BETWEEN 0 AND 18446744073709551615 +--echo # + +CREATE TABLE t1 (c1 bigint(20) unsigned NOT NULL); +INSERT INTO t1 VALUES (0),(101),(255); +SELECT * FROM t1 WHERE c1 BETWEEN 0 AND 18446744073709551615 ORDER BY c1; +DROP TABLE t1; From c6838cc646dde24a2a5518a3c07ef210c84f787a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 15 Nov 2018 17:52:57 +0200 Subject: [PATCH 41/50] MDEV-17726 Assertion `sqlcom != SQLCOM_TRUNCATE' failed in ha_innobase::delete_table after truncating temporary table THD::close_temporary_tables(): Assign lex->sql_command so that the debug assertion will not fail in ha_innobase::delete_table(). Alternatively, we could ensure that thd_killed() holds inside ha_innobase::delete_table(). There should be no impact for the non-debug build. The thd_sql_command() inside ha_innobase::delete_table() only affects the treatment of persistent FOREIGN KEY metadata. There is no persistent metadata nor foreign key constraints for temporary tables. No test case was added, because the failure is nondeterministic. --- sql/temporary_tables.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 3201b306fad..574ed96ada8 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2016 MariaDB Corporation + Copyright (c) 2016,2018 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -476,6 +476,7 @@ bool THD::close_temporary_tables() } DBUG_ASSERT(!rgi_slave); + lex->sql_command = SQLCOM_DROP_TABLE; /* Ensure we don't have open HANDLERs for tables we are about to close. From efc235d84d0df8a9895a5ae71c829303bbd39c8f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 12 Nov 2018 17:11:14 +0100 Subject: [PATCH 42/50] Fix test result. in 10.3, AWS encryption key was loaded during recovery, by the innodb purge thread, therefore no note "loaded key" was written by the foreground thread. --- mysql-test/suite/mariabackup/xb_aws_key_management.result | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/suite/mariabackup/xb_aws_key_management.result b/mysql-test/suite/mariabackup/xb_aws_key_management.result index 6efc76a8be3..fd12344dfa0 100644 --- a/mysql-test/suite/mariabackup/xb_aws_key_management.result +++ b/mysql-test/suite/mariabackup/xb_aws_key_management.result @@ -11,6 +11,4 @@ INSERT INTO t VALUES('foobar1'); SELECT * from t; c foobar1 -Warnings: -Note 1105 AWS KMS plugin: loaded key 1, version 1, key length 128 bit DROP TABLE t; From a93ac8d95fd504412bd819325bfaa816e317786c Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 13 Nov 2018 13:10:32 +0100 Subject: [PATCH 43/50] MDEV-16448 mysql_upgrade_service remove my.ini variables that are no more valid MDEV-16447 incorporate Innodb slow shutdown into mysql_upgrade_service.exe --- sql/CMakeLists.txt | 4 +- sql/mysql_upgrade_service.cc | 211 +++++++++++++++++++++--------- sql/upgrade_conf_file.cc | 177 +++++++++++++++++++++++++ win/upgrade_wizard/upgradeDlg.cpp | 25 ++-- 4 files changed, 344 insertions(+), 73 deletions(-) create mode 100644 sql/upgrade_conf_file.cc diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index d85e588abeb..c6910f469f9 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -489,9 +489,11 @@ IF(WIN32) ADD_LIBRARY(winservice STATIC winservice.c) TARGET_LINK_LIBRARIES(winservice shell32) + MYSQL_ADD_EXECUTABLE(mysql_upgrade_service mysql_upgrade_service.cc - COMPONENT Server) + upgrade_conf_file.cc + COMPONENT Server) TARGET_LINK_LIBRARIES(mysql_upgrade_service mysys winservice) ENDIF(WIN32) diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 1a3df4f5536..9ea78accf44 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -29,6 +29,9 @@ #include #include +#include + +extern int upgrade_config_file(const char *myini_path); /* We're using version APIs */ #pragma comment(lib, "version") @@ -47,6 +50,8 @@ static char mysqlupgrade_path[MAX_PATH]; static char defaults_file_param[MAX_PATH + 16]; /*--defaults-file= */ static char logfile_path[MAX_PATH]; +char my_ini_bck[MAX_PATH]; +mysqld_service_properties service_properties; static char *opt_service; static SC_HANDLE service; static SC_HANDLE scm; @@ -59,7 +64,7 @@ HANDLE logfile_handle; Maybe,they can be made parameters */ static unsigned int startup_timeout= 60; -static unsigned int shutdown_timeout= 60; +static unsigned int shutdown_timeout= 60*60; static struct my_option my_long_options[]= { @@ -112,6 +117,7 @@ static void die(const char *fmt, ...) fprintf(stderr, "FATAL ERROR: "); vfprintf(stderr, fmt, args); + fputc('\n', stderr); if (logfile_path[0]) { fprintf(stderr, "Additional information can be found in the log file %s", @@ -122,6 +128,11 @@ static void die(const char *fmt, ...) fflush(stdout); /* Cleanup */ + if (my_ini_bck[0]) + { + MoveFileEx(my_ini_bck, service_properties.inifile,MOVEFILE_REPLACE_EXISTING); + } + /* Stop service that we started, if it was not initally running at program start. @@ -309,77 +320,76 @@ void initiate_mysqld_shutdown() } } +static void get_service_config() +{ + scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!scm) + die("OpenSCManager failed with %u", GetLastError()); + service = OpenService(scm, opt_service, SERVICE_ALL_ACCESS); + if (!service) + die("OpenService failed with %u", GetLastError()); + BYTE config_buffer[8 * 1024]; + LPQUERY_SERVICE_CONFIGW config = (LPQUERY_SERVICE_CONFIGW)config_buffer; + DWORD size = sizeof(config_buffer); + DWORD needed; + if (!QueryServiceConfigW(service, config, size, &needed)) + die("QueryServiceConfig failed with %u", GetLastError()); + + if (get_mysql_service_properties(config->lpBinaryPathName, &service_properties)) + { + die("Not a valid MySQL service"); + } + + int my_major = MYSQL_VERSION_ID / 10000; + int my_minor = (MYSQL_VERSION_ID % 10000) / 100; + int my_patch = MYSQL_VERSION_ID % 100; + + if (my_major < service_properties.version_major || + (my_major == service_properties.version_major && my_minor < service_properties.version_minor)) + { + die("Can not downgrade, the service is currently running as version %d.%d.%d" + ", my version is %d.%d.%d", service_properties.version_major, service_properties.version_minor, + service_properties.version_patch, my_major, my_minor, my_patch); + } + if (service_properties.inifile[0] == 0) + { + /* + Weird case, no --defaults-file in service definition, need to create one. + */ + sprintf_s(service_properties.inifile, MAX_PATH, "%s\\my.ini", service_properties.datadir); + } + sprintf(defaults_file_param, "--defaults-file=%s", service_properties.inifile); +} /* Change service configuration (binPath) to point to mysqld from this installation. */ static void change_service_config() { - char defaults_file[MAX_PATH]; char default_character_set[64]; char buf[MAX_PATH]; - char commandline[3*MAX_PATH + 19]; + char commandline[3 * MAX_PATH + 19]; int i; - scm= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if(!scm) - die("OpenSCManager failed with %u", GetLastError()); - service= OpenService(scm, opt_service, SERVICE_ALL_ACCESS); - if (!service) - die("OpenService failed with %u", GetLastError()); - - BYTE config_buffer[8*1024]; - LPQUERY_SERVICE_CONFIGW config= (LPQUERY_SERVICE_CONFIGW)config_buffer; - DWORD size= sizeof(config_buffer); - DWORD needed; - if (!QueryServiceConfigW(service, config, size, &needed)) - die("QueryServiceConfig failed with %u", GetLastError()); - - mysqld_service_properties props; - if (get_mysql_service_properties(config->lpBinaryPathName, &props)) - { - die("Not a valid MySQL service"); - } - - int my_major= MYSQL_VERSION_ID/10000; - int my_minor= (MYSQL_VERSION_ID %10000)/100; - int my_patch= MYSQL_VERSION_ID%100; - - if(my_major < props.version_major || - (my_major == props.version_major && my_minor < props.version_minor)) - { - die("Can not downgrade, the service is currently running as version %d.%d.%d" - ", my version is %d.%d.%d", props.version_major, props.version_minor, - props.version_patch, my_major, my_minor, my_patch); - } - - if(props.inifile[0] == 0) - { - /* - Weird case, no --defaults-file in service definition, need to create one. - */ - sprintf_s(props.inifile, MAX_PATH, "%s\\my.ini", props.datadir); - } - /* Write datadir to my.ini, after converting backslashes to unix style slashes. */ - strcpy_s(buf, MAX_PATH, props.datadir); + strcpy_s(buf, MAX_PATH, service_properties.datadir); for(i= 0; buf[i]; i++) { if (buf[i] == '\\') buf[i]= '/'; } - WritePrivateProfileString("mysqld", "datadir",buf, props.inifile); + WritePrivateProfileString("mysqld", "datadir",buf, service_properties.inifile); /* Remove basedir from defaults file, otherwise the service wont come up in the new version, and will complain about mismatched message file. */ - WritePrivateProfileString("mysqld", "basedir",NULL, props.inifile); + WritePrivateProfileString("mysqld", "basedir",NULL, service_properties.inifile); /* Replace default-character-set with character-set-server, to avoid @@ -397,7 +407,7 @@ static void change_service_config() default_character_set, defaults_file); } - sprintf(defaults_file_param,"--defaults-file=%s", props.inifile); + sprintf(defaults_file_param,"--defaults-file=%s", service_properties.inifile); sprintf_s(commandline, "\"%s\" \"%s\" \"%s\"", mysqld_path, defaults_file_param, opt_service); if (!ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, @@ -449,23 +459,97 @@ int main(int argc, char **argv) reads them from pipe and uses as progress indicator. */ setvbuf(stdout, NULL, _IONBF, 0); + int phase = 0; + int max_phases=10; + get_service_config(); - log("Phase 1/8: Changing service configuration"); - change_service_config(); + bool my_ini_exists; + bool old_mysqld_exe_exists; - log("Phase 2/8: Stopping service"); + log("Phase %d/%d: Stopping service", ++phase,max_phases); stop_mysqld_service(); + my_ini_exists = (GetFileAttributes(service_properties.inifile) != INVALID_FILE_ATTRIBUTES); + if (!my_ini_exists) + { + HANDLE h = CreateFile(service_properties.inifile, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, + 0, CREATE_NEW, 0 ,0); + if (h != INVALID_HANDLE_VALUE) + { + CloseHandle(h); + } + else if (GetLastError() != ERROR_FILE_EXISTS) + { + die("Can't create ini file %s, last error %u", service_properties.inifile, GetLastError()); + } + } + + old_mysqld_exe_exists = (GetFileAttributes(service_properties.mysqld_exe) != INVALID_FILE_ATTRIBUTES); + log("Phase %d/%d: Fixing server config file%s", ++phase, max_phases, my_ini_exists ? "" : "(skipped)"); + + snprintf(my_ini_bck, sizeof(my_ini_bck), "%s.BCK", service_properties.inifile); + CopyFile(service_properties.inifile, my_ini_bck, FALSE); + upgrade_config_file(service_properties.inifile); + + log("Phase %d/%d: Ensuring innodb slow shutdown%s", ++phase, max_phases, + old_mysqld_exe_exists?",this can take some time":"(skipped)"); + + char socket_param[FN_REFLEN]; + sprintf_s(socket_param, "--socket=mysql_upgrade_service_%d", + GetCurrentProcessId()); + + DWORD start_duration_ms = 0; + + if (old_mysqld_exe_exists) + { + /* Start/stop server with --loose-innodb-fast-shutdown=0 */ + mysqld_process = (HANDLE)run_tool(P_NOWAIT, service_properties.mysqld_exe, + defaults_file_param, "--loose-innodb-fast-shutdown=0", "--skip-networking", + "--enable-named-pipe", socket_param, "--skip-slave-start", NULL); + + if (mysqld_process == INVALID_HANDLE_VALUE) + { + die("Cannot start mysqld.exe process, last error =%u", GetLastError()); + } + char pipe_name[64]; + snprintf(pipe_name, sizeof(pipe_name), "\\\\.\\pipe\\mysql_upgrade_service_%u", + GetCurrentProcessId()); + for (;;) + { + if (WaitForSingleObject(mysqld_process, 0) != WAIT_TIMEOUT) + die("mysqld.exe did not start"); + + if (WaitNamedPipe(pipe_name, 0)) + { + // Server started, shut it down. + initiate_mysqld_shutdown(); + if (WaitForSingleObject((HANDLE)mysqld_process, shutdown_timeout * 1000) != WAIT_OBJECT_0) + { + die("Could not shutdown server started with '--innodb-fast-shutdown=0'"); + } + DWORD exit_code; + if (!GetExitCodeProcess((HANDLE)mysqld_process, &exit_code)) + { + die("Could not get mysqld's exit code"); + } + if (exit_code) + { + die("Could not get successfully shutdown mysqld"); + } + CloseHandle(mysqld_process); + break; + } + Sleep(500); + start_duration_ms += 500; + } + } /* Start mysqld.exe as non-service skipping privileges (so we do not care about the password). But disable networking and enable pipe for communication, for security reasons. */ - char socket_param[FN_REFLEN]; - sprintf_s(socket_param,"--socket=mysql_upgrade_service_%d", - GetCurrentProcessId()); - log("Phase 3/8: Starting mysqld for upgrade"); + log("Phase %d/%d: Starting mysqld for upgrade",++phase,max_phases); mysqld_process= (HANDLE)run_tool(P_NOWAIT, mysqld_path, defaults_file_param, "--skip-networking", "--skip-grant-tables", "--enable-named-pipe", socket_param,"--skip-slave-start", NULL); @@ -475,8 +559,8 @@ int main(int argc, char **argv) die("Cannot start mysqld.exe process, errno=%d", errno); } - log("Phase 4/8: Waiting for startup to complete"); - DWORD start_duration_ms= 0; + log("Phase %d/%d: Waiting for startup to complete",++phase,max_phases); + start_duration_ms= 0; for(;;) { if (WaitForSingleObject(mysqld_process, 0) != WAIT_TIMEOUT) @@ -493,7 +577,7 @@ int main(int argc, char **argv) start_duration_ms+= 500; } - log("Phase 5/8: Running mysql_upgrade"); + log("Phase %d/%d: Running mysql_upgrade",++phase,max_phases); int upgrade_err= (int) run_tool(P_WAIT, mysqlupgrade_path, "--protocol=pipe", "--force", socket_param, NULL); @@ -501,10 +585,13 @@ int main(int argc, char **argv) if (upgrade_err) die("mysql_upgrade failed with error code %d\n", upgrade_err); - log("Phase 6/8: Initiating server shutdown"); + log("Phase %d/%d: Changing service configuration", ++phase, max_phases); + change_service_config(); + + log("Phase %d/%d: Initiating server shutdown",++phase, max_phases); initiate_mysqld_shutdown(); - log("Phase 7/8: Waiting for shutdown to complete"); + log("Phase %d/%d: Waiting for shutdown to complete",++phase, max_phases); if (WaitForSingleObject(mysqld_process, shutdown_timeout*1000) != WAIT_OBJECT_0) { @@ -514,7 +601,7 @@ int main(int argc, char **argv) CloseHandle(mysqld_process); mysqld_process= NULL; - log("Phase 8/8: Starting service%s", + log("Phase %d/%d: Starting service%s",++phase,max_phases, (initial_service_state == SERVICE_RUNNING)?"":" (skipped)"); if (initial_service_state == SERVICE_RUNNING) { @@ -527,6 +614,10 @@ int main(int argc, char **argv) CloseServiceHandle(scm); if (logfile_handle) CloseHandle(logfile_handle); + if(my_ini_bck[0]) + { + DeleteFile(my_ini_bck); + } my_end(0); exit(0); } diff --git a/sql/upgrade_conf_file.cc b/sql/upgrade_conf_file.cc new file mode 100644 index 00000000000..4e167f0263f --- /dev/null +++ b/sql/upgrade_conf_file.cc @@ -0,0 +1,177 @@ +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + + +/* + Variables that were present in older releases, but are now removed. + to get the list of variables that are present in current release + execute + + SELECT LOWER(variable_name) from INFORMATION_SCHEMA.GLOBAL_VARIABLES ORDER BY 1 + + Compare the list between releases to figure out which variables have gone. + + Note : the list below only includes the default-compiled server and none of the + loadable plugins. +*/ +#include +#include +#include +#include +#include + +static const char *removed_variables[] = +{ +"aria_recover", +"debug_crc_break", +"engine_condition_pushdown", +"have_csv", +"have_innodb", +"have_ndbcluster", +"have_partitioning", +"innodb_adaptive_flushing_method", +"innodb_adaptive_hash_index_partitions", +"innodb_additional_mem_pool_size", +"innodb_api_bk_commit_interval", +"innodb_api_disable_rowlock", +"innodb_api_enable_binlog", +"innodb_api_enable_mdl", +"innodb_api_trx_level", +"innodb_blocking_buffer_pool_restore", +"innodb_buffer_pool_populate", +"innodb_buffer_pool_restore_at_startup", +"innodb_buffer_pool_shm_checksum", +"innodb_buffer_pool_shm_key", +"innodb_checkpoint_age_target", +"innodb_cleaner_eviction_factor", +"innodb_cleaner_flush_chunk_size", +"innodb_cleaner_free_list_lwm", +"innodb_cleaner_lru_chunk_size", +"innodb_cleaner_lsn_age_factor", +"innodb_cleaner_max_flush_time", +"innodb_cleaner_max_lru_time", +"innodb_corrupt_table_action", +"innodb_dict_size_limit", +"innodb_doublewrite_file", +"innodb_empty_free_list_algorithm", +"innodb_fake_changes", +"innodb_fast_checksum", +"innodb_file_format", +"innodb_file_format_check", +"innodb_file_format_max", +"innodb_flush_neighbor_pages", +"innodb_foreground_preflush", +"innodb_ibuf_accel_rate", +"innodb_ibuf_active_contract", +"innodb_ibuf_max_size", +"innodb_import_table_from_xtrabackup", +"innodb_instrument_semaphores", +"innodb_kill_idle_transaction", +"innodb_large_prefix", +"innodb_lazy_drop_table", +"innodb_locking_fake_changes", +"innodb_log_arch_dir", +"innodb_log_arch_expire_sec", +"innodb_log_archive", +"innodb_log_block_size", +"innodb_log_checksum_algorithm", +"innodb_max_bitmap_file_size", +"innodb_max_changed_pages", +"innodb_merge_sort_block_size", +"innodb_mirrored_log_groups", +"innodb_mtflush_threads", +"innodb_persistent_stats_root_page", +"innodb_print_lock_wait_timeout_info", +"innodb_purge_run_now", +"innodb_purge_stop_now", +"innodb_read_ahead", +"innodb_recovery_stats", +"innodb_recovery_update_relay_log", +"innodb_show_locks_held", +"innodb_show_verbose_locks", +"innodb_stats_auto_update", +"innodb_stats_update_need_lock", +"innodb_support_xa", +"innodb_thread_concurrency_timer_based", +"innodb_track_changed_pages", +"innodb_track_redo_log_now", +"innodb_use_fallocate", +"innodb_use_global_flush_log_at_trx_commit", +"innodb_use_mtflush", +"innodb_use_stacktrace", +"innodb_use_sys_malloc", +"innodb_use_sys_stats_table", +"innodb_use_trim", +"log", +"log_slow_queries", +"rpl_recovery_rank", +"sql_big_tables", +"sql_low_priority_updates", +"sql_max_join_size" +}; + + +static int cmp_strings(const void* a, const void *b) +{ + return strcmp((const char *)a, *(const char **)b); +} + +/** + Convert file from a previous version, by removing +*/ +int upgrade_config_file(const char *myini_path) +{ +#define MY_INI_SECTION_SIZE 32*1024 +3 + static char section_data[MY_INI_SECTION_SIZE]; + for (const char *section_name : { "mysqld","server","mariadb" }) + { + DWORD size = GetPrivateProfileSection(section_name, section_data, MY_INI_SECTION_SIZE, myini_path); + if (size == MY_INI_SECTION_SIZE - 2) + { + return -1; + } + + for (char *keyval = section_data; *keyval; keyval += strlen(keyval) + 1) + { + char varname[256]; + char *key_end = strchr(keyval, '='); + if (!key_end) + key_end = keyval+ strlen(keyval); + + if (key_end - keyval > sizeof(varname)) + continue; + // copy and normalize (convert dash to underscore) to variable names + for (char *p = keyval, *q = varname;; p++,q++) + { + if (p == key_end) + { + *q = 0; + break; + } + *q = (*p == '-') ? '_' : *p; + } + const char *v = (const char *)bsearch(varname, removed_variables, sizeof(removed_variables) / sizeof(removed_variables[0]), + sizeof(char *), cmp_strings); + + if (v) + { + fprintf(stdout, "Removing variable '%s' from config file\n", varname); + // delete variable + *key_end = 0; + WritePrivateProfileString(section_name, keyval, 0, myini_path); + } + } + } + return 0; +} diff --git a/win/upgrade_wizard/upgradeDlg.cpp b/win/upgrade_wizard/upgradeDlg.cpp index d996c0ebe5d..793e89886d6 100644 --- a/win/upgrade_wizard/upgradeDlg.cpp +++ b/win/upgrade_wizard/upgradeDlg.cpp @@ -422,21 +422,22 @@ void CUpgradeDlg::UpgradeOneService(const string& servicename) { allMessages[lines%MAX_MESSAGES] = output_line; m_DataDir.SetWindowText(allMessages[lines%MAX_MESSAGES].c_str()); - output_line.clear(); lines++; - /* - Updating progress dialog.There are currently 9 messages from - mysql_upgrade_service (actually it also writes Phase N/M but - we do not parse the output right now). - */ -#define EXPRECTED_MYSQL_UPGRADE_MESSAGES 9 + int curPhase, numPhases; - int stepsTotal= m_ProgressTotal*EXPRECTED_MYSQL_UPGRADE_MESSAGES; - int stepsCurrent= m_ProgressCurrent*EXPRECTED_MYSQL_UPGRADE_MESSAGES - + lines; - int percentDone= stepsCurrent*100/stepsTotal; - m_Progress.SetPos(percentDone); + // Parse output line to update progress indicator + if (strncmp(output_line.c_str(),"Phase ",6) == 0 && + sscanf(output_line.c_str() +6 ,"%d/%d",&curPhase,&numPhases) == 2 + && numPhases > 0 ) + { + int stepsTotal= m_ProgressTotal*numPhases; + int stepsCurrent= m_ProgressCurrent*numPhases+ curPhase; + int percentDone= stepsCurrent*100/stepsTotal; + m_Progress.SetPos(percentDone); + m_Progress.SetPos(stepsCurrent * 100 / stepsTotal); + } + output_line.clear(); } else { From 705abdebaf192adb5642b6f0e7d0a1f8027b262b Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Fri, 16 Nov 2018 10:39:08 +0530 Subject: [PATCH 44/50] MDEV-13170: Database service (MySQL) stops after update with trigger For prepare statemtent/stored procedures we rollback the items to original ones after prepare execution in the function reinit_stmt_before_use. This rollback is done for group by, order by clauses but is not done for the window specification containing the order by and partition by clause of the window function. --- mysql-test/r/win.result | 34 ++++++++++++++++++++++++++++++++++ mysql-test/t/win.test | 41 +++++++++++++++++++++++++++++++++++++++++ sql/sql_prepare.cc | 12 ++++++++++++ 3 files changed, 87 insertions(+) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index c539ac4f252..4ffa9f34c1d 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3423,3 +3423,37 @@ GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit drop table t1; +# +# MDEV-13170: Database service (MySQL) stops after update with trigger +# +CREATE TABLE t1 ( t1_id int, point_id int, ml_id int, UNIQUE KEY t1_ml_u (ml_id,point_id)) ; +INSERT INTO t1 VALUES (1,1,8884),(2,1,8885); +CREATE TABLE t2 ( db_time datetime, au_nr int, col_id int, new_val int); +CREATE TABLE t3 (id1 int, id2 int, d1 int); +CREATE TRIGGER t1_aurtrg AFTER UPDATE ON t1 FOR EACH ROW begin +CREATE OR REPLACE TEMPORARY TABLE trg_u AS +WITH l AS +(SELECT a.*, +Max(t2.col_id) over (PARTITION BY a.d1), +Max(t2.new_val) over (PARTITION BY a.d1) +FROM +(SELECT d1 , id1, id2 FROM t3) a +JOIN t2 ON (a.d1=t2.db_time AND a.id1=t2.au_nr)) +SELECT 1; +END;// +update t1 set ml_id=8884 where point_id=1; +ERROR 23000: Duplicate entry '8884-1' for key 't1_ml_u' +update t1 set ml_id=8884 where point_id=1; +ERROR 23000: Duplicate entry '8884-1' for key 't1_ml_u' +drop table t1, t2,t3; +CREATE TABLE t1 (i INT, a char); +INSERT INTO t1 VALUES (1, 'a'),(2, 'b'); +create view v1 as select * from t1; +PREPARE stmt FROM "SELECT i, row_number() over (partition by i order by i) FROM v1"; +execute stmt; +i row_number() over (partition by i order by i) +1 1 +2 1 +deallocate prepare stmt; +drop table t1; +drop view v1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index 7dda2b6215f..807d394edd3 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2175,3 +2175,44 @@ explain SELECT DISTINCT BIT_OR(100) OVER () FROM t1 GROUP BY LEFT('2018-08-24', 100) having 1=1 limit 0; drop table t1; + +--echo # +--echo # MDEV-13170: Database service (MySQL) stops after update with trigger +--echo # + +CREATE TABLE t1 ( t1_id int, point_id int, ml_id int, UNIQUE KEY t1_ml_u (ml_id,point_id)) ; +INSERT INTO t1 VALUES (1,1,8884),(2,1,8885); + +CREATE TABLE t2 ( db_time datetime, au_nr int, col_id int, new_val int); +CREATE TABLE t3 (id1 int, id2 int, d1 int); + +delimiter //; + +CREATE TRIGGER t1_aurtrg AFTER UPDATE ON t1 FOR EACH ROW begin +CREATE OR REPLACE TEMPORARY TABLE trg_u AS +WITH l AS + (SELECT a.*, + Max(t2.col_id) over (PARTITION BY a.d1), + Max(t2.new_val) over (PARTITION BY a.d1) + FROM + (SELECT d1 , id1, id2 FROM t3) a + JOIN t2 ON (a.d1=t2.db_time AND a.id1=t2.au_nr)) +SELECT 1; + + END;// + + delimiter ;// +--error 1062 +update t1 set ml_id=8884 where point_id=1; +--error 1062 +update t1 set ml_id=8884 where point_id=1; +drop table t1, t2,t3; + +CREATE TABLE t1 (i INT, a char); +INSERT INTO t1 VALUES (1, 'a'),(2, 'b'); +create view v1 as select * from t1; +PREPARE stmt FROM "SELECT i, row_number() over (partition by i order by i) FROM v1"; +execute stmt; +deallocate prepare stmt; +drop table t1; +drop view v1; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 65f7c85b4ec..c3156ce1d5c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2927,6 +2927,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) { SELECT_LEX *sl= lex->all_selects_list; DBUG_ENTER("reinit_stmt_before_use"); + Window_spec *win_spec; /* We have to update "thd" pointer in LEX, all its units and in LEX::result, @@ -2995,6 +2996,17 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) /* Fix ORDER list */ for (order= sl->order_list.first; order; order= order->next) order->item= &order->item_ptr; + /* Fix window functions too */ + List_iterator it(sl->window_specs); + + while ((win_spec= it++)) + { + for (order= win_spec->partition_list->first; order; order= order->next) + order->item= &order->item_ptr; + for (order= win_spec->order_list->first; order; order= order->next) + order->item= &order->item_ptr; + } + { #ifndef DBUG_OFF bool res= From ab812c108978b65f73076ff1e8fbf8011cb23787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 16 Nov 2018 10:36:57 +0200 Subject: [PATCH 45/50] MDEV-17726: A better fix THD::close_temporary_tables(): Revert the change. ha_innobase::delete_table(): Move the work-around inside a debug assertion, and check thd_kill_level() instead of thd_killed(), because the latter would not hold for KILL_CONNECTION. --- sql/temporary_tables.cc | 3 +-- storage/innobase/handler/ha_innodb.cc | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 574ed96ada8..3201b306fad 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2016,2018 MariaDB Corporation + Copyright (c) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -476,7 +476,6 @@ bool THD::close_temporary_tables() } DBUG_ASSERT(!rgi_slave); - lex->sql_command = SQLCOM_DROP_TABLE; /* Ensure we don't have open HANDLERs for tables we are about to close. diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index be91befcf1a..293a80ecbcc 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13187,17 +13187,25 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom) int ha_innobase::delete_table(const char* name) { enum_sql_command sqlcom = enum_sql_command(thd_sql_command(ha_thd())); + /* SQLCOM_TRUNCATE should be passed via ha_innobase::truncate() only. - if (sqlcom == SQLCOM_TRUNCATE - && thd_killed(ha_thd()) - && (m_prebuilt == NULL - || dict_table_is_temporary(m_prebuilt->table))) { - sqlcom = SQLCOM_DROP_TABLE; - } + On client disconnect, when dropping temporary tables, the + previous sqlcom would not be overwritten. In such a case, we + will have thd_kill_level() != NOT_KILLED, !m_prebuilt can + hold, and sqlcom could be anything, including TRUNCATE. - /* SQLCOM_TRUNCATE will be passed via ha_innobase::truncate() only. */ - DBUG_ASSERT(sqlcom != SQLCOM_TRUNCATE); - return delete_table(name, sqlcom); + The sqlcom only matters for persistent tables; no persistent + metadata or FOREIGN KEY metadata is kept for temporary + tables. Therefore, we relax the assertion. If there is a bug + that slips through this assertion due to !m_prebuilt, the + worst impact should be that on DROP TABLE of a persistent + table, FOREIGN KEY constraints will be ignored and their + metadata will not be removed. */ + DBUG_ASSERT(sqlcom != SQLCOM_TRUNCATE + || (thd_kill_level(ha_thd()) != NOT_KILLED + && (!m_prebuilt + || m_prebuilt->table->is_temporary()))); + return delete_table(name, sqlcom); } /** Remove all tables in the named database inside InnoDB. From 37d6d3b661315617953f1a8c5d53a2cb6558992e Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 16 Nov 2018 16:54:33 +0200 Subject: [PATCH 46/50] Max transid was not stored directly after Aria recovery This caused ma_test_recovery.pl to fail Other things: - Fixed bug where "ma_test_recovert.pl --abort-on-error" didn't abort on error --- storage/maria/ha_maria.cc | 3 ++- storage/maria/ma_init.c | 2 ++ storage/maria/ma_recovery.c | 8 ++++++- storage/maria/unittest/ma_test_recovery.pl | 27 +++++++++++++++++----- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index cd13384f144..10ec7ad4d67 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -3606,7 +3606,8 @@ static int ha_maria_init(void *p) TRANSLOG_DEFAULT_FLAGS, 0) || maria_recovery_from_log() || ((force_start_after_recovery_failures != 0 || - maria_recovery_changed_data) && mark_recovery_success()) || + maria_recovery_changed_data || recovery_failures) && + mark_recovery_success()) || ma_checkpoint_init(checkpoint_interval); maria_multi_threaded= maria_in_ha_maria= TRUE; maria_create_trn_hook= maria_create_trn_for_mysql; diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index 3b8f3ce9072..8af3c41a3a1 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -81,6 +81,7 @@ int maria_init(void) void maria_end(void) { + DBUG_ENTER("maria_end"); if (maria_inited) { TrID trid; @@ -111,6 +112,7 @@ void maria_end(void) mysql_mutex_destroy(&THR_LOCK_maria); my_hash_free(&maria_stored_state); } + DBUG_VOID_RETURN; } /** diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index e015007c9fd..d1cb2d584b3 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -473,7 +473,13 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn, fflush(stderr); } - set_if_bigger(max_trid_in_control_file, max_long_trid); + if (max_long_trid > max_trid_in_control_file) + { + if (ma_control_file_write_and_force(last_checkpoint_lsn, last_logno, + max_long_trid, recovery_failures)) + goto err; + } + if (take_checkpoints && checkpoint_useful) { /* No dirty pages, all tables are closed, no active transactions, save: */ diff --git a/storage/maria/unittest/ma_test_recovery.pl b/storage/maria/unittest/ma_test_recovery.pl index f3a5bffbc36..fdc7ee689b2 100755 --- a/storage/maria/unittest/ma_test_recovery.pl +++ b/storage/maria/unittest/ma_test_recovery.pl @@ -235,8 +235,8 @@ sub main # It is impossible to do a "cmp" between .good and .after_undo, # because the UNDO phase generated log # records whose LSN tagged pages. Another reason is that rolling back - # INSERT only marks the rows free, does not empty them (optimization), so - # traces of the INSERT+rollback remain. + # INSERT only marks the rows free, does not empty them + # (optimization), so traces of the INSERT+rollback remain. check_table_is_same($table, $checksum); print MY_LOG "testing idempotency\n"; @@ -298,11 +298,11 @@ sub check_table_is_same $com= "$maria_exe_path/aria_chk$suffix -dvv $table | grep -v \"Creation time:\" | grep -v \"recover time:\""; $com.= "| grep -v \"file length\" | grep -v \"LSNs:\" | grep -v \"UUID:\" > $tmp/aria_chk_message.txt 2>&1"; - $res= `$com`; + $res= my_exec2($com); print MY_LOG $res; - $res= `$maria_exe_path/aria_chk$suffix -ss -e --read-only $table`; + $res= my_exec2("$maria_exe_path/aria_chk$suffix -ss -e --read-only $table"); print MY_LOG $res; - $checksum2= `$maria_exe_path/aria_chk$suffix -dss $table`; + $checksum2= my_exec2("$maria_exe_path/aria_chk$suffix -dss $table"); if ("$checksum" ne "$checksum2") { print MY_LOG "checksum differs for $table before and after recovery\n"; @@ -311,7 +311,7 @@ sub check_table_is_same $com= "diff $tmp/aria_chk_message.good.txt $tmp/aria_chk_message.txt "; $com.= "> $tmp/aria_chk_diff.txt || true"; - $res= `$com`; + $res= my_exec2($com); print MY_LOG $res; if (-s "$tmp/aria_chk_diff.txt") @@ -455,6 +455,21 @@ sub my_exec return $res; } +sub my_exec2 +{ + my($command)= @_; + my $res, $err; + $res= `$command`; + if ($? != 0 && $opt_abort_on_error) + { + $err= $?; + print "$command\n"; + print "failed with error: $err\n"; + exit(1); + } + return $res; +} + #### #### usage From f037b910981aa2422af8cd043311eb8369e96f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 11:11:53 +0200 Subject: [PATCH 47/50] MDEV-17726: Fix compiler warning Compare against the correct constant 0. NOT_KILLED belongs to enum killed_state, while THD_IS_NOT_KILLED is what we want. --- storage/innobase/handler/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 293a80ecbcc..0b7bc5f16af 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13202,7 +13202,7 @@ int ha_innobase::delete_table(const char* name) table, FOREIGN KEY constraints will be ignored and their metadata will not be removed. */ DBUG_ASSERT(sqlcom != SQLCOM_TRUNCATE - || (thd_kill_level(ha_thd()) != NOT_KILLED + || (thd_kill_level(ha_thd()) != THD_IS_NOT_KILLED && (!m_prebuilt || m_prebuilt->table->is_temporary()))); return delete_table(name, sqlcom); From cb5bca721b47cfb344146d5d104263da752661eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 11:40:10 +0200 Subject: [PATCH 48/50] MDEV-17765 lock_discard_page() may fail to discard locks for SPATIAL INDEX lock_discard_page(): Traverse and discard the B-tree record locks only if they exist. Else, discard the R-tree (spatial) index locks. --- storage/innobase/lock/lock0lock.cc | 69 ++++++++++++++++-------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 3169313d874..a9cc8ab1901 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -3424,48 +3424,55 @@ lock_update_discard( lock_mutex_enter(); - if (!lock_rec_get_first_on_page(lock_sys->rec_hash, block) - && (!lock_rec_get_first_on_page(lock_sys->prdt_hash, block))) { - /* No locks exist on page, nothing to do */ + if (lock_rec_get_first_on_page(lock_sys->rec_hash, block)) { + ut_ad(!lock_rec_get_first_on_page(lock_sys->prdt_hash, block)); + ut_ad(!lock_rec_get_first_on_page(lock_sys->prdt_page_hash, + block)); + /* Inherit all the locks on the page to the record and + reset all the locks on the page */ - lock_mutex_exit(); + if (page_is_comp(page)) { + rec = page + PAGE_NEW_INFIMUM; - return; - } + do { + heap_no = rec_get_heap_no_new(rec); - /* Inherit all the locks on the page to the record and reset all - the locks on the page */ + lock_rec_inherit_to_gap(heir_block, block, + heir_heap_no, heap_no); - if (page_is_comp(page)) { - rec = page + PAGE_NEW_INFIMUM; + lock_rec_reset_and_release_wait( + block, heap_no); - do { - heap_no = rec_get_heap_no_new(rec); + rec = page + rec_get_next_offs(rec, TRUE); + } while (heap_no != PAGE_HEAP_NO_SUPREMUM); + } else { + rec = page + PAGE_OLD_INFIMUM; - lock_rec_inherit_to_gap(heir_block, block, - heir_heap_no, heap_no); + do { + heap_no = rec_get_heap_no_old(rec); - lock_rec_reset_and_release_wait(block, heap_no); + lock_rec_inherit_to_gap(heir_block, block, + heir_heap_no, heap_no); - rec = page + rec_get_next_offs(rec, TRUE); - } while (heap_no != PAGE_HEAP_NO_SUPREMUM); + lock_rec_reset_and_release_wait( + block, heap_no); + + rec = page + rec_get_next_offs(rec, FALSE); + } while (heap_no != PAGE_HEAP_NO_SUPREMUM); + } + + lock_rec_free_all_from_discard_page_low( + block->page.id.space(), block->page.id.page_no(), + lock_sys->rec_hash); } else { - rec = page + PAGE_OLD_INFIMUM; - - do { - heap_no = rec_get_heap_no_old(rec); - - lock_rec_inherit_to_gap(heir_block, block, - heir_heap_no, heap_no); - - lock_rec_reset_and_release_wait(block, heap_no); - - rec = page + rec_get_next_offs(rec, FALSE); - } while (heap_no != PAGE_HEAP_NO_SUPREMUM); + lock_rec_free_all_from_discard_page_low( + block->page.id.space(), block->page.id.page_no(), + lock_sys->prdt_hash); + lock_rec_free_all_from_discard_page_low( + block->page.id.space(), block->page.id.page_no(), + lock_sys->prdt_page_hash); } - lock_rec_free_all_from_discard_page(block); - lock_mutex_exit(); } From ff88e4bb8ae1bd8e903c403a598e7d2c5d2bbcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 11:42:14 +0200 Subject: [PATCH 49/50] Remove many redundant #include from InnoDB --- storage/innobase/btr/btr0btr.cc | 3 --- storage/innobase/buf/buf0buf.cc | 4 ---- storage/innobase/buf/buf0dblwr.cc | 1 - storage/innobase/buf/buf0flu.cc | 4 +--- storage/innobase/buf/buf0lru.cc | 1 - storage/innobase/buf/buf0rea.cc | 2 +- storage/innobase/data/data0data.cc | 2 -- storage/innobase/data/data0type.cc | 2 -- storage/innobase/dict/dict0boot.cc | 2 -- storage/innobase/dict/dict0crea.cc | 4 ---- storage/innobase/dict/dict0defrag_bg.cc | 5 +---- storage/innobase/dict/dict0dict.cc | 2 -- storage/innobase/dict/dict0load.cc | 3 --- storage/innobase/dict/dict0stats.cc | 3 --- storage/innobase/dict/dict0stats_bg.cc | 1 - storage/innobase/fil/fil0crypt.cc | 1 - storage/innobase/fil/fil0fil.cc | 4 ---- storage/innobase/fil/fil0pagecompress.cc | 1 - storage/innobase/fsp/fsp0file.cc | 5 ----- storage/innobase/fsp/fsp0fsp.cc | 3 --- storage/innobase/fsp/fsp0space.cc | 3 --- storage/innobase/fsp/fsp0sysspace.cc | 3 --- storage/innobase/fts/fts0ast.cc | 2 -- storage/innobase/fts/fts0fts.cc | 3 --- storage/innobase/fts/fts0opt.cc | 2 -- storage/innobase/fts/fts0que.cc | 3 --- storage/innobase/ha/ha0storage.cc | 1 - storage/innobase/handler/ha_innodb.cc | 2 -- storage/innobase/handler/handler0alter.cc | 4 +--- storage/innobase/handler/i_s.cc | 5 +---- storage/innobase/ibuf/ibuf0ibuf.cc | 3 --- storage/innobase/include/btr0bulk.h | 1 - storage/innobase/include/buf0buf.ic | 2 -- storage/innobase/include/dict0crea.h | 3 +-- storage/innobase/include/dict0dict.h | 2 -- storage/innobase/include/dict0load.h | 2 -- storage/innobase/include/dict0mem.h | 1 - storage/innobase/include/fsp0file.h | 5 +---- storage/innobase/include/fsp0fsp.h | 1 - storage/innobase/include/fsp0space.h | 2 -- storage/innobase/include/fsp0sysspace.h | 1 - storage/innobase/include/fts0ast.h | 1 - storage/innobase/include/fts0fts.h | 2 -- storage/innobase/include/fts0plugin.h | 2 +- storage/innobase/include/fts0types.ic | 3 --- storage/innobase/include/gis0type.h | 3 --- storage/innobase/include/log0recv.h | 2 -- storage/innobase/include/mem0mem.ic | 2 -- storage/innobase/include/page0types.h | 1 - storage/innobase/include/rem0cmp.h | 7 +++---- storage/innobase/include/rem0cmp.ic | 1 + storage/innobase/include/row0mysql.h | 16 +++++++--------- storage/innobase/include/row0trunc.h | 1 - storage/innobase/include/trx0purge.h | 2 ++ storage/innobase/include/trx0trx.h | 8 +++----- storage/innobase/include/trx0types.h | 2 -- storage/innobase/include/ut0mutex.h | 4 ---- storage/innobase/include/ut0new.h | 4 +--- storage/innobase/include/ut0vec.ic | 2 -- storage/innobase/lock/lock0lock.cc | 8 ++------ storage/innobase/lock/lock0prdt.cc | 9 --------- storage/innobase/lock/lock0wait.cc | 2 +- storage/innobase/log/log0log.cc | 2 +- storage/innobase/log/log0recv.cc | 4 +--- storage/innobase/mem/mem0mem.cc | 2 -- storage/innobase/mtr/mtr0mtr.cc | 1 - storage/innobase/os/os0event.cc | 2 -- storage/innobase/os/os0file.cc | 8 +------- storage/innobase/os/os0proc.cc | 7 +------ storage/innobase/os/os0thread.cc | 8 ++------ storage/innobase/page/page0cur.cc | 2 -- storage/innobase/pars/pars0opt.cc | 1 - storage/innobase/pars/pars0pars.cc | 3 --- storage/innobase/que/que0que.cc | 5 ----- storage/innobase/rem/rem0cmp.cc | 11 ++--------- storage/innobase/rem/rem0rec.cc | 8 ++------ storage/innobase/row/row0ftsort.cc | 7 +------ storage/innobase/row/row0import.cc | 4 ---- storage/innobase/row/row0ins.cc | 6 ------ storage/innobase/row/row0log.cc | 1 - storage/innobase/row/row0merge.cc | 4 ---- storage/innobase/row/row0mysql.cc | 4 +--- storage/innobase/row/row0quiesce.cc | 3 --- storage/innobase/row/row0row.cc | 2 -- storage/innobase/row/row0sel.cc | 2 -- storage/innobase/row/row0trunc.cc | 2 +- storage/innobase/row/row0umod.cc | 2 -- storage/innobase/row/row0undo.cc | 2 -- storage/innobase/row/row0upd.cc | 2 -- storage/innobase/row/row0vers.cc | 2 -- storage/innobase/srv/srv0conc.cc | 4 +--- storage/innobase/srv/srv0srv.cc | 3 --- storage/innobase/srv/srv0start.cc | 4 ---- storage/innobase/sync/sync0arr.cc | 6 ------ storage/innobase/sync/sync0debug.cc | 3 --- storage/innobase/sync/sync0rw.cc | 9 --------- storage/innobase/trx/trx0i_s.cc | 9 +++------ storage/innobase/trx/trx0purge.cc | 3 --- storage/innobase/trx/trx0rec.cc | 1 - storage/innobase/trx/trx0roll.cc | 6 +----- storage/innobase/trx/trx0rseg.cc | 1 - storage/innobase/trx/trx0sys.cc | 3 --- storage/innobase/trx/trx0trx.cc | 4 ---- storage/innobase/trx/trx0undo.cc | 3 --- storage/innobase/ut/ut0dbg.cc | 3 +-- storage/innobase/ut/ut0new.cc | 2 -- storage/innobase/ut/ut0rbt.cc | 3 --- 107 files changed, 47 insertions(+), 313 deletions(-) diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 696d493e078..d06568535e6 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -26,9 +26,7 @@ Created 6/2/1994 Heikki Tuuri *******************************************************/ #include "btr0btr.h" -#include "ha_prototypes.h" -#include "fsp0sysspace.h" #include "page0page.h" #include "page0zip.h" #include "gis0rtree.h" @@ -43,7 +41,6 @@ Created 6/2/1994 Heikki Tuuri #include "trx0trx.h" #include "srv0mon.h" #include "gis0geo.h" -#include "ut0new.h" #include "dict0boot.h" #include "row0sel.h" /* row_search_max_autoinc() */ diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index be70a723232..2f6eb080958 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -47,7 +47,6 @@ Created 11/5/1995 Heikki Tuuri #include "btr0btr.h" #include "fil0fil.h" #include "fil0crypt.h" -#include "fsp0sysspace.h" #include "buf0buddy.h" #include "lock0lock.h" #include "sync0rw.h" @@ -62,12 +61,10 @@ Created 11/5/1995 Heikki Tuuri #include "dict0dict.h" #include "log0recv.h" #include "srv0mon.h" -#include "fsp0sysspace.h" #endif /* !UNIV_INNOCHECKSUM */ #include "page0zip.h" #include "sync0sync.h" #include "buf0dump.h" -#include "ut0new.h" #include #include #include @@ -75,7 +72,6 @@ Created 11/5/1995 Heikki Tuuri #include "fil0pagecompress.h" #include "fsp0pagecompress.h" #endif -#include "ha_prototypes.h" #include "ut0byte.h" #include diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index bed24fd7704..f7b31eefa41 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -24,7 +24,6 @@ Doublwrite buffer module Created 2011/12/19 *******************************************************/ -#include "ha_prototypes.h" #include "buf0dblwr.h" #include "buf0buf.h" #include "buf0checksum.h" diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index a73b841b627..a84a79669a7 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -25,9 +25,8 @@ The database buffer buf_pool flush algorithm Created 11/11/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include -#include #include #include "buf0flu.h" @@ -47,7 +46,6 @@ Created 11/11/1995 Heikki Tuuri #include "os0file.h" #include "trx0sys.h" #include "srv0mon.h" -#include "fsp0sysspace.h" #include "ut0stage.h" #include "fil0pagecompress.h" #ifdef UNIV_LINUX diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 331f6d4a3f2..9218ea1b141 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -44,7 +44,6 @@ Created 11/5/1995 Heikki Tuuri #include "log0recv.h" #include "srv0srv.h" #include "srv0mon.h" -#include "lock0lock.h" /** The number of blocks from the LRU_old pointer onward, including the block pointed to, must be buf_pool->LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 3d5a319a820..372b1c5e0a0 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -24,7 +24,7 @@ The database buffer read Created 11/5/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include #include "buf0rea.h" diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc index 7fb0eae611c..cd5a8024db1 100644 --- a/storage/innobase/data/data0data.cc +++ b/storage/innobase/data/data0data.cc @@ -24,8 +24,6 @@ SQL data field and tuple Created 5/30/1994 Heikki Tuuri *************************************************************************/ -#include "ha_prototypes.h" - #include "data0data.h" #include "rem0rec.h" #include "rem0cmp.h" diff --git a/storage/innobase/data/data0type.cc b/storage/innobase/data/data0type.cc index 54cdfa35803..02e79ab6983 100644 --- a/storage/innobase/data/data0type.cc +++ b/storage/innobase/data/data0type.cc @@ -24,8 +24,6 @@ Data types Created 1/16/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "data0type.h" /* At the database startup we store the default-charset collation number of diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index ec53591c323..43c64c86aec 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -24,8 +24,6 @@ Data dictionary creation and booting Created 4/18/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "dict0boot.h" #include "dict0crea.h" #include "btr0btr.h" diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 758a45de943..d66762a011e 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -24,8 +24,6 @@ Database object creation Created 1/8/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "dict0crea.h" #include "btr0pcur.h" #include "btr0btr.h" @@ -42,8 +40,6 @@ Created 1/8/1996 Heikki Tuuri #include "ut0vec.h" #include "dict0priv.h" #include "fts0priv.h" -#include "fsp0space.h" -#include "fsp0sysspace.h" #include "srv0start.h" /*****************************************************************//** diff --git a/storage/innobase/dict/dict0defrag_bg.cc b/storage/innobase/dict/dict0defrag_bg.cc index 69038d4cb77..6347a239812 100644 --- a/storage/innobase/dict/dict0defrag_bg.cc +++ b/storage/innobase/dict/dict0defrag_bg.cc @@ -27,11 +27,8 @@ Created 25/08/2016 Jan Lindström #include "dict0stats.h" #include "dict0stats_bg.h" #include "dict0defrag_bg.h" -#include "row0mysql.h" +#include "btr0btr.h" #include "srv0start.h" -#include "ut0new.h" - -#include static ib_mutex_t defrag_pool_mutex; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 436612c195f..914c9946977 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -60,7 +60,6 @@ ib_warn_row_too_big(const dict_table_t* table); #include "dict0mem.h" #include "dict0priv.h" #include "dict0stats.h" -#include "fsp0sysspace.h" #include "fts0fts.h" #include "fts0types.h" #include "lock0lock.h" @@ -81,7 +80,6 @@ ib_warn_row_too_big(const dict_table_t* table); #include "srv0start.h" #include "sync0sync.h" #include "trx0undo.h" -#include "ut0new.h" #include #include diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 77415d30643..2fe34886df2 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -25,8 +25,6 @@ from dictionary tables Created 4/24/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "dict0load.h" #include "mysql_version.h" @@ -39,7 +37,6 @@ Created 4/24/1996 Heikki Tuuri #include "dict0priv.h" #include "dict0stats.h" #include "fsp0file.h" -#include "fsp0sysspace.h" #include "fts0priv.h" #include "mach0data.h" #include "page0page.h" diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 2719c7e7222..7f3930ba18b 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -25,7 +25,6 @@ Created Jan 06, 2010 Vasil Dimov *******************************************************/ #include "univ.i" - #include "ut0ut.h" #include "ut0rnd.h" #include "dyn0buf.h" @@ -33,8 +32,6 @@ Created Jan 06, 2010 Vasil Dimov #include "trx0trx.h" #include "pars0pars.h" #include "dict0stats.h" -#include "ha_prototypes.h" -#include "ut0new.h" #include #include "btr0btr.h" diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 423558f70c8..55bcafddc70 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -30,7 +30,6 @@ Created Apr 25, 2012 Vasil Dimov #include "dict0defrag_bg.h" #include "row0mysql.h" #include "srv0start.h" -#include "ut0new.h" #include "fil0fil.h" #ifdef WITH_WSREP # include "mysql/service_wsrep.h" diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 6c32531a07e..77760d7159a 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -39,7 +39,6 @@ Modified Jan Lindström jan.lindstrom@mariadb.com #include "btr0scrub.h" #include "fsp0fsp.h" #include "fil0pagecompress.h" -#include "ha_prototypes.h" // IB_LOG_ #include /** Mutex for keys */ diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 38ad8caf137..6c5ae70a2cc 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -33,10 +33,7 @@ Created 10/25/1995 Heikki Tuuri #include "dict0boot.h" #include "dict0dict.h" #include "fsp0file.h" -#include "fsp0file.h" #include "fsp0fsp.h" -#include "fsp0space.h" -#include "fsp0sysspace.h" #include "hash0hash.h" #include "log0log.h" #include "log0recv.h" @@ -49,7 +46,6 @@ Created 10/25/1995 Heikki Tuuri #include "row0trunc.h" #include "srv0start.h" #include "trx0purge.h" -#include "ut0new.h" #include "buf0lru.h" #include "ibuf0ibuf.h" #include "os0event.h" diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 491de512156..1c734f39f15 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -47,7 +47,6 @@ Updated 14/02/2015 #include "page0zip.h" #include "trx0sys.h" #include "row0mysql.h" -#include "ha_prototypes.h" // IB_LOG_ #include "buf0lru.h" #include "ibuf0ibuf.h" #include "sync0sync.h" diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 6e9f307ebc8..4a8874d0fa5 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -24,16 +24,11 @@ Tablespace data file implementation Created 2013-7-26 by Kevin Lewis *******************************************************/ -#include "ha_prototypes.h" - #include "fil0fil.h" #include "fsp0types.h" -#include "fsp0sysspace.h" #include "os0file.h" #include "page0page.h" #include "srv0start.h" -#include "ut0new.h" -#include "fil0crypt.h" /** Initialize the name, size and order of this datafile @param[in] name tablespace name, will be copied diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 7bf31504119..11c5c65d861 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -24,8 +24,6 @@ File space management Created 11/29/1995 Heikki Tuuri ***********************************************************************/ -#include "ha_prototypes.h" - #include "fsp0fsp.h" #include "buf0buf.h" #include "fil0fil.h" @@ -41,7 +39,6 @@ Created 11/29/1995 Heikki Tuuri #include "btr0sea.h" #include "dict0boot.h" #include "log0log.h" -#include "fsp0sysspace.h" #include "dict0mem.h" #include "fsp0types.h" diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index 9ca2786b935..df234f7274e 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -24,9 +24,6 @@ Shared tablespace implementation. Created 2012-11-16 by Sunny Bains as srv/srv0space.cc *******************************************************/ -#include "ha_prototypes.h" - -#include "fsp0space.h" #include "fsp0sysspace.h" #include "fsp0fsp.h" #include "os0file.h" diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index e9f04cbd6c5..baf864bc1c3 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -24,8 +24,6 @@ Created 2012-11-16 by Sunny Bains as srv/srv0space.cc Refactored 2013-7-26 by Kevin Lewis *******************************************************/ -#include "ha_prototypes.h" - #include "fsp0sysspace.h" #include "srv0start.h" #include "trx0sys.h" @@ -33,7 +31,6 @@ Refactored 2013-7-26 by Kevin Lewis #include "mem0mem.h" #include "os0file.h" #include "row0mysql.h" -#include "ut0new.h" /** The server header file is included to access opt_initialize global variable. If server passes the option for create/open DB to SE, we should remove such diff --git a/storage/innobase/fts/fts0ast.cc b/storage/innobase/fts/fts0ast.cc index d6695cec5be..9a5eb2b49bb 100644 --- a/storage/innobase/fts/fts0ast.cc +++ b/storage/innobase/fts/fts0ast.cc @@ -24,8 +24,6 @@ Full Text Search parser helper file. Created 2007/3/16 Sunny Bains. ***********************************************************************/ -#include "ha_prototypes.h" - #include "fts0ast.h" #include "fts0pars.h" #include "fts0fts.h" diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index aadd0e7a554..7d6dd75ced8 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -22,8 +22,6 @@ this program; if not, write to the Free Software Foundation, Inc., Full Text Search interface ***********************************************************************/ -#include "ha_prototypes.h" - #include "trx0roll.h" #include "row0mysql.h" #include "row0upd.h" @@ -40,7 +38,6 @@ Full Text Search interface #include "dict0stats.h" #include "btr0pcur.h" #include "sync0sync.h" -#include "ut0new.h" static const ulint FTS_MAX_ID_LEN = 32; diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 9adfb16c438..a87e7091c1a 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -26,8 +26,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang ***********************************************************************/ -#include "ha_prototypes.h" - #include "fts0fts.h" #include "row0sel.h" #include "que0types.h" diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index f4f10b7f016..2396a376853 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -25,8 +25,6 @@ Created 2007/03/27 Sunny Bains Completed 2011/7/10 Sunny and Jimmy Yang *******************************************************/ -#include "ha_prototypes.h" - #include "dict0dict.h" #include "ut0rbt.h" #include "row0sel.h" @@ -36,7 +34,6 @@ Completed 2011/7/10 Sunny and Jimmy Yang #include "fts0pars.h" #include "fts0types.h" #include "fts0plugin.h" -#include "ut0new.h" #include #include diff --git a/storage/innobase/ha/ha0storage.cc b/storage/innobase/ha/ha0storage.cc index cde4cc04cb7..a6960675adc 100644 --- a/storage/innobase/ha/ha0storage.cc +++ b/storage/innobase/ha/ha0storage.cc @@ -25,7 +25,6 @@ its own storage, avoiding duplicates. Created September 22, 2007 Vasil Dimov *******************************************************/ -#include "ha_prototypes.h" #include "ha0storage.h" #include "hash0hash.h" #include "mem0mem.h" diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0b7bc5f16af..e6c57b015a0 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -78,8 +78,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0stats_bg.h" #include "fil0fil.h" #include "fsp0fsp.h" -#include "fsp0space.h" -#include "fsp0sysspace.h" #include "fts0fts.h" #include "fts0plugin.h" #include "fts0priv.h" diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 7a4d4221e09..632b5dd5a5a 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -23,7 +23,7 @@ Smart ALTER TABLE *******************************************************/ /* Include necessary SQL headers */ -#include "ha_prototypes.h" +#include "univ.i" #include #include #include @@ -38,7 +38,6 @@ Smart ALTER TABLE #include "dict0priv.h" #include "dict0stats.h" #include "dict0stats_bg.h" -#include "fsp0sysspace.h" #include "log0log.h" #include "rem0types.h" #include "row0log.h" @@ -52,7 +51,6 @@ Smart ALTER TABLE #include "pars0pars.h" #include "row0sel.h" #include "ha_innodb.h" -#include "ut0new.h" #include "ut0stage.h" static const char *MSG_UNSUPPORTED_ALTER_ONLINE_ON_VIRTUAL_COLUMN= diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 064e0e88113..3e5fca6541a 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -25,10 +25,9 @@ Created July 18, 2007 Vasil Dimov Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits) *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include #include -#include "univ.i" #include #include @@ -58,8 +57,6 @@ Modified Dec 29, 2014 Jan Lindström (Added sys_semaphore_waits) #include "sync0arr.h" #include "fil0fil.h" #include "fil0crypt.h" -#include "fsp0sysspace.h" -#include "ut0new.h" #include "dict0crea.h" /** structure associates a name string with a file page type and/or buffer diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index b45333eba5a..1fd7f7a2241 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -24,8 +24,6 @@ Insert buffer Created 7/19/1997 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "ibuf0ibuf.h" #include "sync0sync.h" #include "btr0sea.h" @@ -58,7 +56,6 @@ my_bool srv_ibuf_disable_background_merge; #include "log0recv.h" #include "que0que.h" #include "srv0start.h" /* srv_shutdown_state */ -#include "fsp0sysspace.h" #include "rem0cmp.h" /* STRUCTURE OF AN INSERT BUFFER RECORD diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h index edf34bd5ae4..a63ab9ded0d 100644 --- a/storage/innobase/include/btr0bulk.h +++ b/storage/innobase/include/btr0bulk.h @@ -28,7 +28,6 @@ Created 03/11/2014 Shaohua Wang #include "dict0dict.h" #include "page0cur.h" -#include "ut0new.h" #include diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index da7bff31821..91c602f71b0 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -35,9 +35,7 @@ Created 11/5/1995 Heikki Tuuri #include "buf0flu.h" #include "buf0lru.h" #include "buf0rea.h" -#include "sync0debug.h" #include "fsp0types.h" -#include "ut0new.h" /** A chunk of buffers. The buffer pool is allocated in chunks. */ struct buf_chunk_t{ diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 5d149f24921..c57a63652a2 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri #include "row0types.h" #include "mtr0mtr.h" #include "fil0crypt.h" -#include "fsp0space.h" /*********************************************************************//** Creates a table create graph. diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index bb4e15ea329..44aff739d93 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri #include "dict0mem.h" #include "dict0types.h" #include "fsp0fsp.h" -#include "fsp0sysspace.h" #include "hash0hash.h" #include "mem0mem.h" #include "rem0types.h" @@ -42,7 +41,6 @@ Created 1/8/1996 Heikki Tuuri #include "trx0types.h" #include "ut0byte.h" #include "ut0mem.h" -#include "ut0new.h" #include "ut0rnd.h" #include #include "fsp0fsp.h" diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 9ba42007568..b35add02d9d 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -28,13 +28,11 @@ Created 4/24/1996 Heikki Tuuri #ifndef dict0load_h #define dict0load_h -#include "univ.i" #include "dict0types.h" #include "trx0types.h" #include "ut0byte.h" #include "mem0mem.h" #include "btr0types.h" -#include "ut0new.h" #include diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index fc120149c5f..671018d20e9 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -47,7 +47,6 @@ Created 1/8/1996 Heikki Tuuri #include "buf0buf.h" #include "gis0type.h" #include "os0once.h" -#include "ut0new.h" #include "fil0fil.h" #include #include "fil0crypt.h" diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index 68e9f687fcd..9bc7b4bf9c9 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -27,12 +27,9 @@ Created 2013-7-26 by Kevin Lewis #ifndef fsp0file_h #define fsp0file_h -#include "ha_prototypes.h" -#include "log0log.h" #include "mem0mem.h" #include "os0file.h" -#include "fil0crypt.h" -#include +#include "fil0fil.h" /** Types of raw partitions in innodb_data_file_path */ enum device_t { diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index 3e4c0368b00..af60383b0ca 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -33,7 +33,6 @@ Created 12/18/1995 Heikki Tuuri #ifndef UNIV_INNOCHECKSUM -#include "fsp0space.h" #include "fut0lst.h" #include "mtr0mtr.h" #include "page0types.h" diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h index 9f869fda158..88e5bb583de 100644 --- a/storage/innobase/include/fsp0space.h +++ b/storage/innobase/include/fsp0space.h @@ -27,11 +27,9 @@ Created 2013-7-26 by Kevin Lewis #ifndef fsp0space_h #define fsp0space_h -#include "univ.i" #include "fsp0file.h" #include "fsp0fsp.h" #include "fsp0types.h" -#include "ut0new.h" #include diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h index efbd4fc3f24..a60891c5515 100644 --- a/storage/innobase/include/fsp0sysspace.h +++ b/storage/innobase/include/fsp0sysspace.h @@ -26,7 +26,6 @@ Created 2013-7-26 by Kevin Lewis #ifndef fsp0sysspace_h #define fsp0sysspace_h -#include "univ.i" #include "fsp0space.h" /** If the last data file is auto-extended, we add this many pages to it diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index 2a2b25c36bd..0b55d458036 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -27,7 +27,6 @@ Created 2007/03/16/03 Sunny Bains #ifndef INNOBASE_FST0AST_H #define INNOBASE_FST0AST_H -#include "ha_prototypes.h" #include "mem0mem.h" #ifdef UNIV_PFS_MEMORY diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 11749c991f0..ce628438cb0 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -27,8 +27,6 @@ Created 2011/09/02 Sunny Bains #ifndef fts0fts_h #define fts0fts_h -#include "ha_prototypes.h" - #include "data0type.h" #include "data0types.h" #include "dict0types.h" diff --git a/storage/innobase/include/fts0plugin.h b/storage/innobase/include/fts0plugin.h index 9bc9b6b9dd7..1e822ec3415 100644 --- a/storage/innobase/include/fts0plugin.h +++ b/storage/innobase/include/fts0plugin.h @@ -26,7 +26,7 @@ Created 2013/06/04 Shaohua Wang #ifndef INNOBASE_FTS0PLUGIN_H #define INNOBASE_FTS0PLUGIN_H -#include "ha_prototypes.h" +#include "univ.i" extern struct st_mysql_ftparser fts_default_parser; diff --git a/storage/innobase/include/fts0types.ic b/storage/innobase/include/fts0types.ic index a8712751412..18bc87213fc 100644 --- a/storage/innobase/include/fts0types.ic +++ b/storage/innobase/include/fts0types.ic @@ -27,9 +27,6 @@ Created 2007-03-27 Sunny Bains #ifndef INNOBASE_FTS0TYPES_IC #define INNOBASE_FTS0TYPES_IC -#include "rem0cmp.h" -#include "ha_prototypes.h" - /******************************************************************//** Duplicate a string. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ diff --git a/storage/innobase/include/gis0type.h b/storage/innobase/include/gis0type.h index 14c098f9608..887b06f3613 100644 --- a/storage/innobase/include/gis0type.h +++ b/storage/innobase/include/gis0type.h @@ -26,8 +26,6 @@ Created 2013/03/27 Jimmy Yang #ifndef gis0type_h #define gis0type_h -#include "univ.i" - #include "buf0buf.h" #include "data0type.h" #include "data0types.h" @@ -41,7 +39,6 @@ Created 2013/03/27 Jimmy Yang #include "ut0wqueue.h" #include "que0types.h" #include "gis0geo.h" -#include "ut0new.h" #include #include diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index d3c891c9cba..267f8f6778d 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -27,13 +27,11 @@ Created 9/20/1997 Heikki Tuuri #ifndef log0recv_h #define log0recv_h -#include "univ.i" #include "ut0byte.h" #include "buf0types.h" #include "hash0hash.h" #include "log0log.h" #include "mtr0types.h" -#include "ut0new.h" #include #include diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 4d76f07694d..42dda9e0bb9 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -24,8 +24,6 @@ The memory management Created 6/8/1994 Heikki Tuuri *************************************************************************/ -#include "ut0new.h" - #ifdef UNIV_DEBUG # define mem_heap_create_block(heap, n, type, file_name, line) \ mem_heap_create_block_func(heap, n, file_name, line, type) diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index fe56468c454..53a03466dde 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -29,7 +29,6 @@ Created 2/2/1994 Heikki Tuuri #include "univ.i" #include "dict0types.h" #include "mtr0types.h" -#include "ut0new.h" #include diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h index 216e3a7655b..899624a003e 100644 --- a/storage/innobase/include/rem0cmp.h +++ b/storage/innobase/include/rem0cmp.h @@ -27,12 +27,11 @@ Created 7/1/1994 Heikki Tuuri #ifndef rem0cmp_h #define rem0cmp_h -#include "ha_prototypes.h" #include "data0data.h" #include "data0type.h" -#include "dict0dict.h" -#include "rem0rec.h" -#include +#include "dict0types.h" +#include "rem0types.h" +#include "page0types.h" /*************************************************************//** Returns TRUE if two columns are equal for comparison purposes. diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic index bf913b93bfb..290c1455f27 100644 --- a/storage/innobase/include/rem0cmp.ic +++ b/storage/innobase/include/rem0cmp.ic @@ -24,6 +24,7 @@ Created 7/1/1994 Heikki Tuuri ************************************************************************/ #include +#include /** Compare two data fields. @param[in] dfield1 data field; must have type field set diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index a16fd30c6ea..f3fdf5b4c42 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -28,21 +28,19 @@ Created 9/17/2000 Heikki Tuuri #ifndef row0mysql_h #define row0mysql_h -#include "ha_prototypes.h" -#include "sql_list.h" -#include "sql_cmd.h" - #include "data0data.h" #include "que0types.h" #include "dict0types.h" #include "trx0types.h" #include "row0types.h" -#include "btr0pcur.h" -#include "trx0types.h" -#include "fil0crypt.h" +#include "btr0types.h" +#include "lock0types.h" +#include "fil0fil.h" +#include "fts0fts.h" +#include "gis0type.h" -// Forward declaration -struct SysIndexCallback; +#include "sql_list.h" +#include "sql_cmd.h" extern ibool row_rollback_on_timeout; diff --git a/storage/innobase/include/row0trunc.h b/storage/innobase/include/row0trunc.h index 4d6bdee225c..5915596a389 100644 --- a/storage/innobase/include/row0trunc.h +++ b/storage/innobase/include/row0trunc.h @@ -31,7 +31,6 @@ Created 2013-04-25 Krunal Bauskar #include "dict0boot.h" #include "fil0fil.h" #include "srv0start.h" -#include "ut0new.h" #include diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 8d31a50f028..5aae3a530f7 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -36,6 +36,8 @@ Created 3/26/1996 Heikki Tuuri #include "fil0fil.h" #include "read0types.h" +#include + /** A dummy undo record used as a return value when we have a whole undo log which needs no purge */ extern trx_undo_rec_t trx_purge_dummy_rec; diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 917222477b1..440f4101c5c 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -27,21 +27,19 @@ Created 3/26/1996 Heikki Tuuri #ifndef trx0trx_h #define trx0trx_h -#include - -#include "ha_prototypes.h" - #include "dict0types.h" #include "trx0types.h" #include "lock0types.h" -#include "log0log.h" #include "que0types.h" #include "mem0mem.h" #include "trx0xa.h" #include "ut0vec.h" #include "fts0fts.h" +#include +#include + // Forward declaration struct mtr_t; diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index b42871bef31..de26de44193 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -29,10 +29,8 @@ Created 3/26/1996 Heikki Tuuri #include "ut0byte.h" #include "ut0mutex.h" -#include "ut0new.h" #include -#include #include //#include diff --git a/storage/innobase/include/ut0mutex.h b/storage/innobase/include/ut0mutex.h index dc387dadbdc..3dbd7919a2f 100644 --- a/storage/innobase/include/ut0mutex.h +++ b/storage/innobase/include/ut0mutex.h @@ -29,12 +29,8 @@ Created 2012-03-24 Sunny Bains. #ifndef ut0mutex_h #define ut0mutex_h -extern uint srv_spin_wait_delay; -extern ulong srv_n_spin_wait_rounds; - #include "sync0policy.h" #include "ib0mutex.h" -#include /** Create a typedef using the MutexType @param[in] M Mutex type diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 955e7b026c7..86fcbd59418 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -136,8 +136,6 @@ InnoDB: #include "mysql/psi/psi_memory.h" /* PSI_memory_key, PSI_memory_info */ -#include "univ.i" - #include "os0proc.h" /* os_mem_alloc_large() */ #include "os0thread.h" /* os_thread_sleep() */ #include "ut0ut.h" /* ut_strcmp_functor, ut_basename_noext() */ diff --git a/storage/innobase/include/ut0vec.ic b/storage/innobase/include/ut0vec.ic index 17f4df579b6..bf774c84683 100644 --- a/storage/innobase/include/ut0vec.ic +++ b/storage/innobase/include/ut0vec.ic @@ -23,8 +23,6 @@ A vector of pointers to data items Created 4/6/2006 Osku Salerma ************************************************************************/ -#include "ut0new.h" - #define IB_VEC_OFFSET(v, i) (vec->sizeof_value * i) /******************************************************************** diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index a9cc8ab1901..c2a0494a5d7 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -26,8 +26,7 @@ Created 5/7/1996 Heikki Tuuri #define LOCK_MODULE_IMPLEMENTATION - -#include "ha_prototypes.h" +#include "univ.i" #include #include @@ -37,11 +36,8 @@ Created 5/7/1996 Heikki Tuuri #include "dict0mem.h" #include "trx0purge.h" #include "trx0sys.h" -#include "srv0mon.h" #include "ut0vec.h" -#include "btr0btr.h" -#include "dict0boot.h" -#include "ut0new.h" +#include "btr0cur.h" #include "row0sel.h" #include "row0mysql.h" #include "row0vers.h" diff --git a/storage/innobase/lock/lock0prdt.cc b/storage/innobase/lock/lock0prdt.cc index 5843508741d..a179b0719cf 100644 --- a/storage/innobase/lock/lock0prdt.cc +++ b/storage/innobase/lock/lock0prdt.cc @@ -29,17 +29,8 @@ Created 9/7/2013 Jimmy Yang #include "lock0lock.h" #include "lock0priv.h" #include "lock0prdt.h" -#include "ha_prototypes.h" -#include "trx0purge.h" #include "dict0mem.h" -#include "dict0boot.h" -#include "trx0sys.h" -#include "srv0mon.h" -#include "ut0vec.h" -#include "btr0btr.h" -#include "dict0boot.h" #include "que0que.h" -#include /*********************************************************************//** Get a minimum bounding box from a Predicate diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index d6c812e1af0..055c67bacc3 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -26,7 +26,7 @@ Created 25/5/2010 Sunny Bains #define LOCK_MODULE_IMPLEMENTATION -#include "ha_prototypes.h" +#include "univ.i" #include #include diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 8fa8662ca31..4a789382004 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -31,7 +31,7 @@ Database log Created 12/9/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include #include diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 42623aa9655..f8e9a64f9d4 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -25,7 +25,7 @@ Recovery Created 9/20/1997 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include #include @@ -52,8 +52,6 @@ Created 9/20/1997 Heikki Tuuri #include "trx0undo.h" #include "trx0rec.h" #include "fil0fil.h" -#include "fsp0sysspace.h" -#include "ut0new.h" #include "row0trunc.h" #include "buf0rea.h" #include "srv0srv.h" diff --git a/storage/innobase/mem/mem0mem.cc b/storage/innobase/mem/mem0mem.cc index c101980d543..b4f1dd0602f 100644 --- a/storage/innobase/mem/mem0mem.cc +++ b/storage/innobase/mem/mem0mem.cc @@ -24,8 +24,6 @@ The memory management Created 6/9/1994 Heikki Tuuri *************************************************************************/ -#include "ha_prototypes.h" - #include "mem0mem.h" #include "buf0buf.h" #include "srv0srv.h" diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 9367d537424..dafa41e7a9c 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -28,7 +28,6 @@ Created 11/26/1995 Heikki Tuuri #include "buf0buf.h" #include "buf0flu.h" -#include "fsp0sysspace.h" #include "page0types.h" #include "mtr0log.h" #include "log0log.h" diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc index b687af3e21c..71b86df24a4 100644 --- a/storage/innobase/os/os0event.cc +++ b/storage/innobase/os/os0event.cc @@ -25,8 +25,6 @@ Created 2012-09-23 Sunny Bains #include "os0event.h" #include "ut0mutex.h" -#include "ha_prototypes.h" -#include "ut0new.h" #ifdef _WIN32 #include diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 4d71eaf552b..26cc70e6e41 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -34,11 +34,8 @@ Created 10/21/1995 Heikki Tuuri *******************************************************/ #ifndef UNIV_INNOCHECKSUM - -#include "ha_prototypes.h" -#include "sql_const.h" - #include "os0file.h" +#include "sql_const.h" #ifdef UNIV_LINUX #include @@ -48,9 +45,6 @@ Created 10/21/1995 Heikki Tuuri #include "srv0srv.h" #include "srv0start.h" #include "fil0fil.h" -#include "fil0crypt.h" -#include "fsp0fsp.h" -#include "fil0pagecompress.h" #include "srv0srv.h" #ifdef HAVE_LINUX_UNISTD_H #include "unistd.h" diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index 22966690ab0..1a6da03a402 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -24,12 +24,7 @@ process control primitives Created 9/30/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - -#include "os0proc.h" -#include "srv0srv.h" -#include "ut0mem.h" -#include "ut0byte.h" +#include "univ.i" /* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and MAP_ANON but MAP_ANON is marked as deprecated */ diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index 3986c4f4c44..e0d96276b55 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -24,13 +24,9 @@ The interface to the operating system thread control primitives Created 9/8/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - +#include "univ.i" #include "os0thread.h" -#include "ut0new.h" #include "srv0srv.h" -#include "os0event.h" -#include /** Number of threads active. */ ulint os_thread_count; diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 6bdb7f56842..2327d11f1fa 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -25,8 +25,6 @@ The page cursor Created 10/4/1994 Heikki Tuuri *************************************************************************/ -#include "ha_prototypes.h" - #include "page0cur.h" #include "page0zip.h" #include "btr0btr.h" diff --git a/storage/innobase/pars/pars0opt.cc b/storage/innobase/pars/pars0opt.cc index f08037d15aa..934cd80fd14 100644 --- a/storage/innobase/pars/pars0opt.cc +++ b/storage/innobase/pars/pars0opt.cc @@ -33,7 +33,6 @@ Created 12/21/1997 Heikki Tuuri #include "que0que.h" #include "pars0grm.h" #include "pars0pars.h" -#include "lock0lock.h" #define OPT_EQUAL 1 /* comparison by = */ #define OPT_COMPARISON 2 /* comparison by <, >, <=, or >= */ diff --git a/storage/innobase/pars/pars0pars.cc b/storage/innobase/pars/pars0pars.cc index 56ca037f247..d7447810912 100644 --- a/storage/innobase/pars/pars0pars.cc +++ b/storage/innobase/pars/pars0pars.cc @@ -26,8 +26,6 @@ Created 11/19/1996 Heikki Tuuri /* Historical note: Innobase executed its first SQL string (CREATE TABLE) on 1/27/1998 */ -#include "ha_prototypes.h" - #include "pars0pars.h" #include "row0sel.h" #include "row0ins.h" @@ -42,7 +40,6 @@ on 1/27/1998 */ #include "data0type.h" #include "trx0trx.h" #include "trx0roll.h" -#include "lock0lock.h" #include "eval0eval.h" /* Global variable used while parsing a single procedure or query : the code is diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 99d8c70a2c0..05964403543 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -24,8 +24,6 @@ Query graph Created 5/27/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "que0que.h" #include "trx0trx.h" #include "trx0roll.h" @@ -37,9 +35,6 @@ Created 5/27/1996 Heikki Tuuri #include "dict0crea.h" #include "log0log.h" #include "eval0proc.h" -#include "lock0lock.h" -#include "eval0eval.h" -#include "pars0types.h" #define QUE_MAX_LOOPS_WITHOUT_CHECK 16 diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index 0e2bc9b30de..62581bbac38 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -23,17 +23,10 @@ Comparison services for records Created 7/1/1994 Heikki Tuuri ************************************************************************/ -#include "ha_prototypes.h" - #include "rem0cmp.h" +#include "rem0rec.h" +#include "dict0mem.h" #include "handler0alter.h" -#include "srv0srv.h" - -#include -#include -#include -#include -#include /* ALPHABETICAL ORDER ================== diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index 562dc53e9f8..35b0235b8ec 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -26,15 +26,9 @@ Created 5/30/1994 Heikki Tuuri #include "rem0rec.h" #include "page0page.h" -#include "mtr0mtr.h" #include "mtr0log.h" #include "fts0fts.h" -#ifdef WITH_WSREP -#include -#endif /* WITH_WSREP */ -#include "gis0geo.h" #include "trx0sys.h" -#include "mach0data.h" /* PHYSICAL RECORD (OLD STYLE) =========================== @@ -2201,6 +2195,8 @@ rec_offs_make_nth_extern( rec_offs_base(offsets)[1 + n] |= REC_OFFS_EXTERNAL; } #ifdef WITH_WSREP +# include "ha_prototypes.h" + int wsrep_rec_get_foreign_key( byte *buf, /* out: extracted key */ diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 507b7c25ed4..810b5387aec 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -24,16 +24,11 @@ Create Full Text Index with (parallel) merge sort Created 10/13/2010 Jimmy Yang *******************************************************/ -#include "ha_prototypes.h" - -#include "dict0dict.h" -#include "row0merge.h" -#include "pars0pars.h" #include "row0ftsort.h" +#include "dict0dict.h" #include "row0merge.h" #include "row0row.h" #include "btr0cur.h" -#include "btr0bulk.h" #include "fts0plugin.h" #include "log0crypt.h" diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 71520dd1b84..66807ced2c1 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -24,11 +24,8 @@ Import a tablespace to a running instance. Created 2012-02-08 by Sunny Bains. *******************************************************/ -#include "ha_prototypes.h" - #include "row0import.h" #include "btr0pcur.h" -#include "btr0sea.h" #include "que0que.h" #include "dict0boot.h" #include "ibuf0ibuf.h" @@ -39,7 +36,6 @@ Created 2012-02-08 by Sunny Bains. #include "srv0start.h" #include "row0quiesce.h" #include "fil0pagecompress.h" -#include "ut0new.h" #ifdef HAVE_LZO #include "lzo/lzo1x.h" #endif diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 3362e5302b1..2db545973a3 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -24,11 +24,8 @@ Insert into a table Created 4/20/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0ins.h" #include "dict0dict.h" -#include "dict0boot.h" #include "trx0rec.h" #include "trx0undo.h" #include "btr0btr.h" @@ -38,7 +35,6 @@ Created 4/20/1996 Heikki Tuuri #include "que0que.h" #include "row0upd.h" #include "row0sel.h" -#include "row0row.h" #include "row0log.h" #include "rem0cmp.h" #include "lock0lock.h" @@ -48,8 +44,6 @@ Created 4/20/1996 Heikki Tuuri #include "buf0lru.h" #include "fts0fts.h" #include "fts0types.h" -#include "m_string.h" -#include "gis0geo.h" /************************************************************************* IMPORTANT NOTE: Any operation that generates redo MUST check that there diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 7e6760da372..16a71fbe896 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -35,7 +35,6 @@ Created 2011-05-26 Marko Makela #include "que0que.h" #include "srv0mon.h" #include "handler0alter.h" -#include "ut0new.h" #include "ut0stage.h" #include "trx0rec.h" diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 953f3070a11..f623cfb6df4 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -30,8 +30,6 @@ Completed by Sunny Bains and Marko Makela #include -#include "ha_prototypes.h" - #include "row0merge.h" #include "row0ext.h" #include "row0log.h" @@ -49,8 +47,6 @@ Completed by Sunny Bains and Marko Makela #include "row0vers.h" #include "handler0alter.h" #include "btr0bulk.h" -#include "fsp0sysspace.h" -#include "ut0new.h" #include "ut0stage.h" #include "fil0crypt.h" diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 4b20d378473..b098617afda 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -25,7 +25,7 @@ Contains also create table and other data dictionary operations. Created 9/17/2000 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" +#include "univ.i" #include #include #include @@ -46,7 +46,6 @@ Created 9/17/2000 Heikki Tuuri #include "fil0fil.h" #include "fil0crypt.h" #include "fsp0file.h" -#include "fsp0sysspace.h" #include "fts0fts.h" #include "fts0types.h" #include "ibuf0ibuf.h" @@ -68,7 +67,6 @@ Created 9/17/2000 Heikki Tuuri #include "srv0start.h" #include "row0ext.h" #include "srv0start.h" -#include "ut0new.h" #include #include diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index de71c786fd8..865780c3df5 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -24,14 +24,11 @@ Quiesce a tablespace. Created 2012-02-08 by Sunny Bains. *******************************************************/ -#include "ha_prototypes.h" - #include "row0quiesce.h" #include "row0mysql.h" #include "ibuf0ibuf.h" #include "srv0start.h" #include "trx0purge.h" -#include "fsp0sysspace.h" #ifdef HAVE_MY_AES_H #include diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index 4c88130334e..a01238fd21a 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -24,8 +24,6 @@ General row routines Created 4/20/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0row.h" #include "data0type.h" #include "dict0dict.h" diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 5d142c24490..e27b1b9df77 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -54,9 +54,7 @@ Created 12/19/1997 Heikki Tuuri #include "read0read.h" #include "buf0lru.h" #include "srv0srv.h" -#include "ha_prototypes.h" #include "srv0mon.h" -#include "ut0new.h" /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc index c6c752a92b8..c326a9468a0 100644 --- a/storage/innobase/row/row0trunc.cc +++ b/storage/innobase/row/row0trunc.cc @@ -26,13 +26,13 @@ Created 2013-04-12 Sunny Bains #include "row0mysql.h" #include "pars0pars.h" +#include "btr0pcur.h" #include "dict0crea.h" #include "dict0boot.h" #include "dict0stats.h" #include "dict0stats_bg.h" #include "lock0lock.h" #include "fts0fts.h" -#include "fsp0sysspace.h" #include "srv0start.h" #include "row0trunc.h" #include "os0file.h" diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 3b87c3ae1b7..4ed4e74fce3 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -24,8 +24,6 @@ Undo modify of a row Created 2/27/1997 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0umod.h" #include "dict0dict.h" #include "dict0stats.h" diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc index 9f5d05f8f9f..3f960235f3e 100644 --- a/storage/innobase/row/row0undo.cc +++ b/storage/innobase/row/row0undo.cc @@ -24,8 +24,6 @@ Row undo Created 1/8/1997 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0undo.h" #include "fsp0fsp.h" #include "mach0data.h" diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 28658428e98..ccb18cb843b 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -24,8 +24,6 @@ Update of a row Created 12/27/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0upd.h" #include "dict0dict.h" #include "dict0mem.h" diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc index 811654fdef8..30aa44dcb33 100644 --- a/storage/innobase/row/row0vers.cc +++ b/storage/innobase/row/row0vers.cc @@ -24,8 +24,6 @@ Row versions Created 2/6/1997 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "row0vers.h" #include "dict0dict.h" #include "dict0boot.h" diff --git a/storage/innobase/srv/srv0conc.cc b/storage/innobase/srv/srv0conc.cc index a1ffa8986a8..9e2aa7d7af4 100644 --- a/storage/innobase/srv/srv0conc.cc +++ b/storage/innobase/srv/srv0conc.cc @@ -38,13 +38,11 @@ InnoDB concurrency manager Created 2011/04/18 Sunny Bains *******************************************************/ -#include "ha_prototypes.h" -#include - #include "srv0srv.h" #include "trx0trx.h" #include "row0mysql.h" #include "dict0dict.h" +#include #include /** Number of times a thread is allowed to enter InnoDB within the same diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 0aebdb1cfd3..08d201511da 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -46,14 +46,11 @@ Created 10/8/1995 Heikki Tuuri // #include "mysql/psi/mysql_stage.h" // #include "mysql/psi/psi.h" -#include "ha_prototypes.h" - #include "btr0sea.h" #include "buf0flu.h" #include "buf0lru.h" #include "dict0boot.h" #include "dict0load.h" -#include "fsp0sysspace.h" #include "ibuf0ibuf.h" #include "lock0lock.h" #include "log0recv.h" diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 5cb3f6572c0..8719d26d5f3 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -41,8 +41,6 @@ Created 2/16/1996 Heikki Tuuri #include "my_global.h" -#include "ha_prototypes.h" - #include "mysqld.h" #include "mysql/psi/mysql_stage.h" #include "mysql/psi/psi.h" @@ -76,7 +74,6 @@ Created 2/16/1996 Heikki Tuuri #include "srv0start.h" #include "srv0srv.h" #include "btr0defragment.h" -#include "fsp0sysspace.h" #include "row0trunc.h" #include "mysql/service_wsrep.h" /* wsrep_recovery */ #include "trx0rseg.h" @@ -107,7 +104,6 @@ Created 2/16/1996 Heikki Tuuri #include "zlib.h" #include "ut0crc32.h" #include "btr0scrub.h" -#include "ut0new.h" /** Log sequence number immediately after startup */ lsn_t srv_start_lsn; diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index f1589e1f3a7..183aa09dc2b 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -31,7 +31,6 @@ The wait array used in synchronization primitives Created 9/5/1995 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" #include "sync0arr.h" #include #include @@ -46,13 +45,8 @@ Created 9/5/1995 Heikki Tuuri #include #include -#include "sync0sync.h" #include "lock0lock.h" #include "sync0rw.h" -#include "sync0debug.h" -#include "os0event.h" -#include "os0file.h" -#include "srv0srv.h" /* WAIT ARRAY diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc index d41d52b2f7d..deb081a6819 100644 --- a/storage/innobase/sync/sync0debug.cc +++ b/storage/innobase/sync/sync0debug.cc @@ -32,11 +32,8 @@ Created 2012-08-21 Sunny Bains #include "sync0sync.h" #include "sync0debug.h" - -#include "ut0new.h" #include "srv0start.h" -#include #include #include #include diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc index 22d94af0a6c..31a8234dea7 100644 --- a/storage/innobase/sync/sync0rw.cc +++ b/storage/innobase/sync/sync0rw.cc @@ -32,15 +32,6 @@ Created 9/11/1995 Heikki Tuuri *******************************************************/ #include "sync0rw.h" -#include "ha_prototypes.h" - -#include "os0thread.h" -#include "mem0mem.h" -#include "srv0srv.h" -#include "os0event.h" -#include "srv0mon.h" -#include "sync0debug.h" -#include "ha_prototypes.h" #include "my_cpu.h" #include diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index 363b61b0cfe..374c7b12db1 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -36,9 +36,7 @@ Created July 17, 2007 Vasil Dimov From the symptoms, this is related to bug#46587 in the MySQL bug DB. */ -#include "ha_prototypes.h" -#include - +#include "trx0i_s.h" #include "buf0buf.h" #include "dict0dict.h" #include "ha0storage.h" @@ -52,10 +50,9 @@ Created July 17, 2007 Vasil Dimov #include "srv0srv.h" #include "sync0rw.h" #include "sync0sync.h" -#include "trx0i_s.h" #include "trx0sys.h" -#include "trx0trx.h" -#include "ut0mem.h" + +#include /** Initial number of rows in the table cache */ #define TABLE_CACHE_INITIAL_ROWSNUM 1024 diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index c20001c8df0..c4f272acf07 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -24,8 +24,6 @@ Purge old versions Created 3/26/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "trx0purge.h" #include "fsp0fsp.h" #include "fut0fut.h" @@ -37,7 +35,6 @@ Created 3/26/1996 Heikki Tuuri #include "row0purge.h" #include "row0upd.h" #include "srv0mon.h" -#include "fsp0sysspace.h" #include "srv0srv.h" #include "srv0start.h" #include "sync0sync.h" diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 9c0008831a8..e700d5e0f58 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -38,7 +38,6 @@ Created 3/26/1996 Heikki Tuuri #include "trx0purge.h" #include "trx0rseg.h" #include "row0row.h" -#include "fsp0sysspace.h" #include "row0mysql.h" /*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/ diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 2c14c9d895a..0e277c67453 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -24,12 +24,9 @@ Transaction rollback Created 3/26/1996 Heikki Tuuri *******************************************************/ -#include "my_config.h" -#include - -#include "ha_prototypes.h" #include "trx0roll.h" +#include #include #include "fsp0fsp.h" @@ -47,7 +44,6 @@ Created 3/26/1996 Heikki Tuuri #include "trx0sys.h" #include "trx0trx.h" #include "trx0undo.h" -#include "ha_prototypes.h" /** This many pages must be undone before a truncate is tried within rollback */ diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 1c2d708ed4b..3d5320cdd15 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -30,7 +30,6 @@ Created 3/26/1996 Heikki Tuuri #include "srv0srv.h" #include "trx0purge.h" #include "srv0mon.h" -#include "fsp0sysspace.h" #include diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index e2e42dc6569..f4c043a3ca9 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -24,8 +24,6 @@ Transaction system Created 3/26/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "mysqld.h" #include "trx0sys.h" #include "sql_error.h" @@ -43,7 +41,6 @@ Created 3/26/1996 Heikki Tuuri #include "log0recv.h" #include "os0file.h" #include "read0read.h" -#include "fsp0sysspace.h" #include diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 4aba7a64ed8..b56cb9609ab 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -24,8 +24,6 @@ The transaction Created 3/26/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "trx0trx.h" #ifdef WITH_WSREP @@ -42,7 +40,6 @@ Created 3/26/1996 Heikki Tuuri #include "read0read.h" #include "srv0mon.h" #include "srv0srv.h" -#include "fsp0sysspace.h" #include "srv0start.h" #include "trx0purge.h" #include "trx0rec.h" @@ -50,7 +47,6 @@ Created 3/26/1996 Heikki Tuuri #include "trx0rseg.h" #include "trx0undo.h" #include "trx0xa.h" -#include "ut0new.h" #include "ut0pool.h" #include "ut0vec.h" diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 33a38b915be..98db4bf4e9e 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -24,8 +24,6 @@ Transaction undo log Created 3/26/1996 Heikki Tuuri *******************************************************/ -#include "ha_prototypes.h" - #include "trx0undo.h" #include "fsp0fsp.h" #include "mach0data.h" @@ -36,7 +34,6 @@ Created 3/26/1996 Heikki Tuuri #include "trx0purge.h" #include "trx0rec.h" #include "trx0rseg.h" -#include "trx0trx.h" /* How should the old versions in the history list be managed? ---------------------------------------------------------- diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index 7df189ac560..56a2eb80337 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -24,8 +24,7 @@ Debug utilities for Innobase. Created 1/30/1994 Heikki Tuuri **********************************************************************/ -#include "ha_prototypes.h" - +#include "univ.i" #include "ut0dbg.h" /*************************************************************//** diff --git a/storage/innobase/ut/ut0new.cc b/storage/innobase/ut/ut0new.cc index 052db2fe7bd..8aad921278c 100644 --- a/storage/innobase/ut/ut0new.cc +++ b/storage/innobase/ut/ut0new.cc @@ -25,8 +25,6 @@ Created May 26, 2014 Vasil Dimov #include "univ.i" -#include "ut0new.h" - /** Maximum number of retries to allocate memory. */ const size_t alloc_max_retries = 60; diff --git a/storage/innobase/ut/ut0rbt.cc b/storage/innobase/ut/ut0rbt.cc index cb8e4f2df20..0da924fed43 100644 --- a/storage/innobase/ut/ut0rbt.cc +++ b/storage/innobase/ut/ut0rbt.cc @@ -23,9 +23,6 @@ Red-Black tree implementation Created 2007-03-20 Sunny Bains ***********************************************************************/ -#include "univ.i" - -#include "ut0new.h" #include "ut0rbt.h" /**********************************************************************//** From e669e705a1a7d2bbdd42734cb9fc8349a5f2f118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 13:13:39 +0200 Subject: [PATCH 50/50] Fix the Windows build Commit ff88e4bb8ae1bd8e903c403a598e7d2c5d2bbcaf broke the Windows build. Clean up one more redundant #include to fix it. --- storage/innobase/include/srv0srv.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 832a67539da..4117a3f0dd3 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -42,12 +42,11 @@ Created 10/10/1995 Heikki Tuuri #ifndef srv0srv_h #define srv0srv_h -#include "my_global.h" +#include "univ.i" #include "mysql/psi/mysql_stage.h" #include "mysql/psi/psi.h" -#include "univ.i" #include "log0log.h" #include "os0event.h" #include "que0types.h"