summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-06-30 15:06:54 +0300
committerSergei Petrunia <psergey@askmonty.org>2021-06-30 15:06:54 +0300
commit586870f9effa48831fda2590f2aee2b95b30be39 (patch)
treebc674573cb34b871045c4db1ebd7d7eea1349314
parent29098083f7ac3b445ee59c3e765eb634ec70b947 (diff)
parenteb20c91b55e4b51be533314994b36bf9b24016f3 (diff)
downloadmariadb-git-586870f9effa48831fda2590f2aee2b95b30be39.tar.gz
Merge 10.2->10.3
-rw-r--r--.gitignore2
-rw-r--r--cmake/cpack_rpm.cmake6
-rw-r--r--mysql-test/main/cte_nonrecursive.result55
-rw-r--r--mysql-test/main/cte_nonrecursive.test29
-rw-r--r--mysql-test/main/derived_cond_pushdown.result146
-rw-r--r--mysql-test/main/derived_cond_pushdown.test70
-rw-r--r--mysql-test/main/gis-json.result10
-rw-r--r--mysql-test/main/gis-json.test7
-rw-r--r--mysql-test/main/information_schema.result2
-rw-r--r--mysql-test/main/information_schema_all_engines.result12
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is.result4
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is_embedded.result4
-rw-r--r--mysql-test/suite/funcs_1/r/is_tables_is.result92
-rw-r--r--mysql-test/suite/funcs_1/r/is_tables_is_embedded.result92
-rw-r--r--mysql-test/suite/galera/r/lp1376747-4.result2
-rw-r--r--mysql-test/suite/galera/t/lp1376747-4.test2
-rw-r--r--sql/handler.h2
-rw-r--r--sql/item_create.cc5
-rw-r--r--sql/lex.h7
-rw-r--r--sql/spatial.cc6
-rw-r--r--sql/sql_derived.cc79
-rw-r--r--sql/sql_show.cc83
-rw-r--r--storage/innobase/os/os0file.cc38
23 files changed, 736 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index f5a365a42e7..c26767717c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -520,3 +520,5 @@ compile_commands.json
# Visual Studio Code workspace
.vscode/
+
+.cache/clangd
diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake
index 7a56c1e5289..1be5d26d7e0 100644
--- a/cmake/cpack_rpm.cmake
+++ b/cmake/cpack_rpm.cmake
@@ -127,7 +127,11 @@ SET(ignored
"%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
)
-SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
+SET(CPACK_RPM_server_USER_FILELIST
+ ${ignored}
+ "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*"
+ "%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql"
+ )
SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf")
SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 0992c97a857..550864b20c6 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -1964,6 +1964,61 @@ call p1();
ERROR 42S22: Unknown column 'a' in 'field list'
drop procedure p1;
drop table t1,t2;
+#
+# MDEV-20411: SP containing only one SELECT with WITH clause
+#
+create procedure sp1 ()
+with cte as (select 1 as a) select * from cte;
+call sp1();
+a
+1
+call sp1();
+a
+1
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+create procedure sp2 ()
+with cte as (select * from t1) select * from cte;
+call sp2();
+a
+3
+7
+1
+7
+1
+1
+3
+1
+5
+call sp2();
+a
+3
+7
+1
+7
+1
+1
+3
+1
+5
+create procedure sp3 ()
+with cte as (select * from t1 group by a) select * from cte;
+call sp3();
+a
+1
+3
+5
+7
+call sp3();
+a
+1
+3
+5
+7
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop table t1;
# End of 10.2 tests
#
# MDEV-21673: several references to CTE that uses
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index dcb76e47034..ac74683ad44 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -1463,6 +1463,35 @@ drop procedure p1;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-20411: SP containing only one SELECT with WITH clause
+--echo #
+
+create procedure sp1 ()
+with cte as (select 1 as a) select * from cte;
+call sp1();
+call sp1();
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5);
+
+create procedure sp2 ()
+with cte as (select * from t1) select * from cte;
+call sp2();
+call sp2();
+
+create procedure sp3 ()
+with cte as (select * from t1 group by a) select * from cte;
+call sp3();
+call sp3();
+
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+
+drop table t1;
+
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 6e84a83fd24..b886db20eed 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -10690,6 +10690,152 @@ Warnings:
Note 1003 /* select#1 */ select `v2`.`a` AS `a`,`v2`.`f` AS `f`,`v2`.`g` AS `g` from `test`.`v2` where `v2`.`a` = `v2`.`f` and `v2`.`a` = `v2`.`g`
drop view v1,v2;
drop table t1;
+#
+# MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP
+#
+create function f1(a int) returns int DETERMINISTIC return (a+1);
+create table t1 (
+pk int primary key,
+a int,
+b int,
+key(a)
+);
+create table t2(a int);
+insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t3(a int);
+insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C;
+insert into t1 select a,a,a from t3;
+create view v1 as
+select
+t1.a as col1,
+f1(t1.b) as col2
+from
+t1;
+create view v2 as
+select
+t1.a as col1,
+f1(t1.b) as col2
+from
+t1;
+create view v3 as
+select col2, col1 from v1
+union all
+select col2, col1 from v2;
+explain select * from v3 where col1=123;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
+2 DERIVED t1 ref a a 5 const 1
+3 UNION t1 ref a a 5 const 1
+# This must use ref accesses for reading table t1, not full scans:
+explain format=json
+select * from v3 where col1=123 and col2=321;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v3.col1 = 123 and v3.col2 = 321",
+ "materialized": {
+ "query_block": {
+ "union_result": {
+ "table_name": "<union2,3>",
+ "access_type": "ALL",
+ "query_specifications": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ref",
+ "possible_keys": ["a"],
+ "key": "a",
+ "key_length": "5",
+ "used_key_parts": ["a"],
+ "ref": ["const"],
+ "rows": 1,
+ "filtered": 100
+ }
+ }
+ },
+ {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ref",
+ "possible_keys": ["a"],
+ "key": "a",
+ "key_length": "5",
+ "used_key_parts": ["a"],
+ "ref": ["const"],
+ "rows": 1,
+ "filtered": 100
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+}
+drop function f1;
+drop view v1,v2,v3;
+drop table t1, t2,t3;
+#
+# Another testcase, with pushdown through GROUP BY
+#
+create table t1 (a int, b int);
+insert into t1 values (1,1),(2,2),(3,3);
+create function f1(a int) returns int DETERMINISTIC return (a+1);
+create view v2(a, a2, s) as
+select a, f1(a), sum(b) from t1 group by a, f1(a);
+# Here,
+# "(s+1) > 10" will be pushed into HAVING
+# "a > 1" will be pushed all the way to the table scan on t1
+# "a2>123" will be pushed into HAVING (as it refers to an SP call which
+# prevents pushing it to the WHERE)
+explain format=json
+select * from v2 where (s+1) > 10 AND a > 1 and a2>123;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "s + 1 > 10 and a2 > 123",
+ "filesort": {
+ "sort_key": "t1.a, f1(t1.a)",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.a > 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+drop view v2;
+drop function f1;
+drop table t1;
# End of 10.2 tests
#
# MDEV-14579: pushdown conditions into materialized views/derived tables
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 244ec1453a8..9bb9d9b9bcc 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -2238,6 +2238,76 @@ eval explain extended $q2;
drop view v1,v2;
drop table t1;
+--echo #
+--echo # MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP
+--echo #
+create function f1(a int) returns int DETERMINISTIC return (a+1);
+
+create table t1 (
+ pk int primary key,
+ a int,
+ b int,
+ key(a)
+);
+
+create table t2(a int);
+insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t3(a int);
+insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C;
+
+insert into t1 select a,a,a from t3;
+
+create view v1 as
+select
+ t1.a as col1,
+ f1(t1.b) as col2
+from
+ t1;
+
+create view v2 as
+select
+ t1.a as col1,
+ f1(t1.b) as col2
+from
+ t1;
+create view v3 as
+select col2, col1 from v1
+union all
+select col2, col1 from v2;
+
+explain select * from v3 where col1=123;
+
+--echo # This must use ref accesses for reading table t1, not full scans:
+explain format=json
+select * from v3 where col1=123 and col2=321;
+
+drop function f1;
+drop view v1,v2,v3;
+drop table t1, t2,t3;
+
+--echo #
+--echo # Another testcase, with pushdown through GROUP BY
+--echo #
+create table t1 (a int, b int);
+insert into t1 values (1,1),(2,2),(3,3);
+
+create function f1(a int) returns int DETERMINISTIC return (a+1);
+
+create view v2(a, a2, s) as
+select a, f1(a), sum(b) from t1 group by a, f1(a);
+
+--echo # Here,
+--echo # "(s+1) > 10" will be pushed into HAVING
+--echo # "a > 1" will be pushed all the way to the table scan on t1
+--echo # "a2>123" will be pushed into HAVING (as it refers to an SP call which
+--echo # prevents pushing it to the WHERE)
+explain format=json
+select * from v2 where (s+1) > 10 AND a > 1 and a2>123;
+
+drop view v2;
+drop function f1;
+drop table t1;
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/gis-json.result b/mysql-test/main/gis-json.result
index e52a7c809c6..ace9e9e9ae2 100644
--- a/mysql-test/main/gis-json.result
+++ b/mysql-test/main/gis-json.result
@@ -107,6 +107,16 @@ Warning 4076 Incorrect GeoJSON format - empty 'coordinates' array.
SELECT ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }");
ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }")
NULL
+SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}'));
+ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}'))
+NULL
+Warnings:
+Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
+SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }'));
+ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }'))
+NULL
+Warnings:
+Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function.
#
# End of 10.2 tests
#
diff --git a/mysql-test/main/gis-json.test b/mysql-test/main/gis-json.test
index a97e9411e5c..ff6298c50a6 100644
--- a/mysql-test/main/gis-json.test
+++ b/mysql-test/main/gis-json.test
@@ -46,6 +46,13 @@ SELECT st_astext(st_geomfromgeojson('{"type": "MultiPolygon","coordinates": []}'
SELECT ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }");
+#
+# MDEV-25461 Assertion `je->state == JST_KEY' failed in Geometry::create_from_json.
+#
+
+SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}'));
+
+SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }'));
--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result
index 28c1122ac03..0559c42350d 100644
--- a/mysql-test/main/information_schema.result
+++ b/mysql-test/main/information_schema.result
@@ -65,6 +65,7 @@ GEOMETRY_COLUMNS
GLOBAL_STATUS
GLOBAL_VARIABLES
INDEX_STATISTICS
+KEYWORDS
KEY_CACHES
KEY_COLUMN_USAGE
PARAMETERS
@@ -79,6 +80,7 @@ SCHEMA_PRIVILEGES
SESSION_STATUS
SESSION_VARIABLES
SPATIAL_REF_SYS
+SQL_FUNCTIONS
STATISTICS
SYSTEM_VARIABLES
TABLES
diff --git a/mysql-test/main/information_schema_all_engines.result b/mysql-test/main/information_schema_all_engines.result
index 2916858b5a6..41d6ab3b2f4 100644
--- a/mysql-test/main/information_schema_all_engines.result
+++ b/mysql-test/main/information_schema_all_engines.result
@@ -41,6 +41,7 @@ INNODB_SYS_VIRTUAL
INNODB_TABLESPACES_ENCRYPTION
INNODB_TABLESPACES_SCRUBBING
INNODB_TRX
+KEYWORDS
KEY_CACHES
KEY_COLUMN_USAGE
PARAMETERS
@@ -55,6 +56,7 @@ SCHEMA_PRIVILEGES
SESSION_STATUS
SESSION_VARIABLES
SPATIAL_REF_SYS
+SQL_FUNCTIONS
STATISTICS
SYSTEM_VARIABLES
TABLES
@@ -121,6 +123,7 @@ INNODB_SYS_VIRTUAL TABLE_ID
INNODB_TABLESPACES_ENCRYPTION SPACE
INNODB_TABLESPACES_SCRUBBING SPACE
INNODB_TRX trx_id
+KEYWORDS WORD
KEY_CACHES KEY_CACHE_NAME
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
PARAMETERS SPECIFIC_SCHEMA
@@ -135,6 +138,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
SESSION_STATUS VARIABLE_NAME
SESSION_VARIABLES VARIABLE_NAME
SPATIAL_REF_SYS SRID
+SQL_FUNCTIONS FUNCTION
STATISTICS TABLE_SCHEMA
SYSTEM_VARIABLES VARIABLE_NAME
TABLES TABLE_SCHEMA
@@ -201,6 +205,7 @@ INNODB_SYS_VIRTUAL TABLE_ID
INNODB_TABLESPACES_ENCRYPTION SPACE
INNODB_TABLESPACES_SCRUBBING SPACE
INNODB_TRX trx_id
+KEYWORDS WORD
KEY_CACHES KEY_CACHE_NAME
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
PARAMETERS SPECIFIC_SCHEMA
@@ -215,6 +220,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA
SESSION_STATUS VARIABLE_NAME
SESSION_VARIABLES VARIABLE_NAME
SPATIAL_REF_SYS SRID
+SQL_FUNCTIONS FUNCTION
STATISTICS TABLE_SCHEMA
SYSTEM_VARIABLES VARIABLE_NAME
TABLES TABLE_SCHEMA
@@ -356,6 +362,7 @@ Database: information_schema
| INNODB_TABLESPACES_ENCRYPTION |
| INNODB_TABLESPACES_SCRUBBING |
| INNODB_TRX |
+| KEYWORDS |
| KEY_CACHES |
| KEY_COLUMN_USAGE |
| PARAMETERS |
@@ -370,6 +377,7 @@ Database: information_schema
| SESSION_STATUS |
| SESSION_VARIABLES |
| SPATIAL_REF_SYS |
+| SQL_FUNCTIONS |
| STATISTICS |
| SYSTEM_VARIABLES |
| TABLES |
@@ -426,6 +434,7 @@ Database: INFORMATION_SCHEMA
| INNODB_TABLESPACES_ENCRYPTION |
| INNODB_TABLESPACES_SCRUBBING |
| INNODB_TRX |
+| KEYWORDS |
| KEY_CACHES |
| KEY_COLUMN_USAGE |
| PARAMETERS |
@@ -440,6 +449,7 @@ Database: INFORMATION_SCHEMA
| SESSION_STATUS |
| SESSION_VARIABLES |
| SPATIAL_REF_SYS |
+| SQL_FUNCTIONS |
| STATISTICS |
| SYSTEM_VARIABLES |
| TABLES |
@@ -459,5 +469,5 @@ Wildcard: inf_rmation_schema
| information_schema |
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') GROUP BY TABLE_SCHEMA;
table_schema count(*)
-information_schema 65
+information_schema 67
mysql 31
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result
index 913f6646bcf..bb6bc085043 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is.result
@@ -181,6 +181,7 @@ def information_schema INDEX_STATISTICS INDEX_NAME 3 '' NO varchar 192 576 NULL
def information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL
def information_schema INDEX_STATISTICS TABLE_NAME 2 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NEVER NULL
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NEVER NULL
+def information_schema KEYWORDS WORD 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL
def information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL
def information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL
@@ -337,6 +338,7 @@ def information_schema SPATIAL_REF_SYS AUTH_NAME 2 '' NO varchar 512 1536 NULL N
def information_schema SPATIAL_REF_SYS AUTH_SRID 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select NEVER NULL
def information_schema SPATIAL_REF_SYS SRID 1 0 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) select NEVER NULL
def information_schema SPATIAL_REF_SYS SRTEXT 4 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select NEVER NULL
+def information_schema SQL_FUNCTIONS FUNCTION 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL
def information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) select NEVER NULL
def information_schema STATISTICS COLUMN_NAME 8 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
@@ -719,6 +721,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
+3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
NULL information_schema KEY_CACHES SEGMENT_NUMBER int NULL NULL NULL NULL int(3) unsigned
@@ -875,6 +878,7 @@ NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smalli
3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8 utf8_general_ci varchar(512)
NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5)
3.0000 information_schema SPATIAL_REF_SYS SRTEXT varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
+3.0000 information_schema SQL_FUNCTIONS FUNCTION varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema STATISTICS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema STATISTICS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
index 30e36d9ca97..51fbb18cab3 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
@@ -181,6 +181,7 @@ def information_schema INDEX_STATISTICS INDEX_NAME 3 '' NO varchar 192 576 NULL
def information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL
def information_schema INDEX_STATISTICS TABLE_NAME 2 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) NEVER NULL
def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) NEVER NULL
+def information_schema KEYWORDS WORD 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL
def information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL
def information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL
@@ -337,6 +338,7 @@ def information_schema SPATIAL_REF_SYS AUTH_NAME 2 '' NO varchar 512 1536 NULL N
def information_schema SPATIAL_REF_SYS AUTH_SRID 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) NEVER NULL
def information_schema SPATIAL_REF_SYS SRID 1 0 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) NEVER NULL
def information_schema SPATIAL_REF_SYS SRTEXT 4 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) NEVER NULL
+def information_schema SQL_FUNCTIONS FUNCTION 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL
def information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) NEVER NULL
def information_schema STATISTICS COLUMN_NAME 8 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
@@ -719,6 +721,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small
3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21)
+3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned
NULL information_schema KEY_CACHES SEGMENT_NUMBER int NULL NULL NULL NULL int(3) unsigned
@@ -875,6 +878,7 @@ NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smalli
3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8 utf8_general_ci varchar(512)
NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5)
3.0000 information_schema SPATIAL_REF_SYS SRTEXT varchar 2048 6144 utf8 utf8_general_ci varchar(2048)
+3.0000 information_schema SQL_FUNCTIONS FUNCTION varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema STATISTICS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema STATISTICS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result
index 51b4f5576ad..70564ab6af8 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is.result
@@ -439,6 +439,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME KEYWORDS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME KEY_CACHES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -764,6 +787,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME SQL_FUNCTIONS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME STATISTICS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -1480,6 +1526,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME KEYWORDS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME KEY_CACHES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -1805,6 +1874,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME SQL_FUNCTIONS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME STATISTICS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
index 51b4f5576ad..70564ab6af8 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
@@ -439,6 +439,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME KEYWORDS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME KEY_CACHES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -764,6 +787,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME SQL_FUNCTIONS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME STATISTICS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -1480,6 +1526,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME KEYWORDS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME KEY_CACHES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -1805,6 +1874,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME SQL_FUNCTIONS
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 11
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME STATISTICS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result
index 3370e1d3d8e..efce740ea88 100644
--- a/mysql-test/suite/galera/r/lp1376747-4.result
+++ b/mysql-test/suite/galera/r/lp1376747-4.result
@@ -27,8 +27,8 @@ t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-set debug_sync= 'RESET';
connection node_2a;
+set debug_sync= 'RESET';
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = DEFAULT;
SHOW CREATE TABLE t1;
diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test
index d19ff422ab0..724901da068 100644
--- a/mysql-test/suite/galera/t/lp1376747-4.test
+++ b/mysql-test/suite/galera/t/lp1376747-4.test
@@ -46,10 +46,10 @@ SET debug_sync='now SIGNAL go2';
# the cluster as there is new FTRL that is still pausing it.
UNLOCK TABLES;
SHOW CREATE TABLE t1;
-set debug_sync= 'RESET';
--connection node_2a
--reap
+set debug_sync= 'RESET';
UNLOCK TABLES;
SET SESSION wsrep_sync_wait = DEFAULT;
diff --git a/sql/handler.h b/sql/handler.h
index d318dc57cdd..e3e8e9fc5d9 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -978,6 +978,7 @@ enum enum_schema_tables
SCH_FILES,
SCH_GLOBAL_STATUS,
SCH_GLOBAL_VARIABLES,
+ SCH_KEYWORDS,
SCH_KEY_CACHES,
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
@@ -993,6 +994,7 @@ enum enum_schema_tables
SCH_SESSION_STATUS,
SCH_SESSION_VARIABLES,
SCH_STATISTICS,
+ SCH_SQL_FUNCTIONS,
SCH_SYSTEM_VARIABLES,
SCH_TABLES,
SCH_TABLESPACES,
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 70ac2abe959..657397c41dd 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -7033,7 +7033,6 @@ Create_func_year_week::create_native(THD *thd, LEX_CSTRING *name,
return func;
}
-
#define BUILDER(F) & F::s_singleton
#ifdef HAVE_SPATIAL
@@ -7053,7 +7052,7 @@ Create_func_year_week::create_native(THD *thd, LEX_CSTRING *name,
- keep 1 line per entry, it makes grep | sort easier
*/
-static Native_func_registry func_array[] =
+Native_func_registry func_array[] =
{
{ { STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
{ { STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
@@ -7407,6 +7406,8 @@ static Native_func_registry func_array[] =
{ {0, 0}, NULL}
};
+size_t func_array_length= sizeof(func_array) / sizeof(Native_func_registry) - 1;
+
static HASH native_functions_hash;
extern "C" uchar*
diff --git a/sql/lex.h b/sql/lex.h
index 070ac5cc147..823e95bb863 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -45,7 +45,7 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
lists
*/
-static SYMBOL symbols[] = {
+SYMBOL symbols[] = {
{ "&&", SYM(AND_AND_SYM)},
{ "<=", SYM(LE)},
{ "<>", SYM(NE)},
@@ -726,7 +726,7 @@ static SYMBOL symbols[] = {
};
-static SYMBOL sql_functions[] = {
+SYMBOL sql_functions[] = {
{ "ADDDATE", SYM(ADDDATE_SYM)},
{ "BIT_AND", SYM(BIT_AND)},
{ "BIT_OR", SYM(BIT_OR)},
@@ -777,4 +777,7 @@ static SYMBOL sql_functions[] = {
{ "VAR_SAMP", SYM(VAR_SAMP_SYM)},
};
+size_t symbols_length= sizeof(symbols) / sizeof(SYMBOL);
+size_t sql_functions_length= sizeof(sql_functions) / sizeof(SYMBOL);
+
#endif /* LEX_INCLUDED */
diff --git a/sql/spatial.cc b/sql/spatial.cc
index bda64c6d420..53e8c4c8bdd 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -539,7 +539,11 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer,
goto handle_geometry_key;
feature_type_found= 1;
}
+ else /* can't understand the type. */
+ break;
}
+ else /* The "type" value can only be string. */
+ break;
}
else if (key_len == coord_keyname_len &&
memcmp(key_buf, coord_keyname, coord_keyname_len) == 0)
@@ -556,6 +560,8 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer,
coord_start= je->value_begin;
if (ci && ci != &geometrycollection_class)
goto create_geom;
+ if (json_skip_level(je))
+ goto err_return;
}
}
else if (key_len == geometries_keyname_len &&
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 8f10013bed1..93dc62828ac 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -1264,6 +1264,68 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived)
}
+/*
+ @brief
+ Given condition cond and transformer+argument, try transforming as many
+ conjuncts as possible.
+
+ @detail
+ The motivation of this function is to convert the condition that's being
+ pushed into a WHERE clause with derived_field_transformer_for_where or
+ with derived_grouping_field_transformer_for_where.
+ The transformer may fail for some sub-condition, in this case we want to
+ convert the most restrictive part of the condition that can be pushed.
+
+ This function only does it for top-level AND: conjuncts that could not be
+ converted are dropped.
+
+ @return
+ Converted condition, or NULL if nothing could be converted
+*/
+
+static
+Item *transform_condition_or_part(THD *thd,
+ Item *cond,
+ Item_transformer transformer,
+ uchar *arg)
+{
+ if (cond->type() != Item::COND_ITEM ||
+ ((Item_cond*) cond)->functype() != Item_func::COND_AND_FUNC)
+ {
+ Item *new_item= cond->transform(thd, transformer, arg);
+ // Indicate that the condition is not pushable
+ if (!new_item)
+ cond->clear_extraction_flag();
+ return new_item;
+ }
+
+ List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
+ Item *item;
+ while ((item=li++))
+ {
+ Item *new_item= item->transform(thd, transformer, arg);
+ if (!new_item)
+ {
+ // Indicate that the condition is not pushable
+ item->clear_extraction_flag();
+ li.remove();
+ }
+ else
+ li.replace(new_item);
+ }
+
+ switch (((Item_cond*) cond)->argument_list()->elements)
+ {
+ case 0:
+ return NULL;
+ case 1:
+ return ((Item_cond*) cond)->argument_list()->head();
+ default:
+ return cond;
+ }
+}
+
+
/**
@brief
Extract the condition depended on derived table/view and pushed it there
@@ -1395,9 +1457,11 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
if (!sl->join->group_list && !sl->with_sum_func)
{
/* extracted_cond_copy is pushed into where of sl */
- extracted_cond_copy= extracted_cond_copy->transform(thd,
- &Item::derived_field_transformer_for_where,
- (uchar*) sl);
+ extracted_cond_copy=
+ transform_condition_or_part(thd,
+ extracted_cond_copy,
+ &Item::derived_field_transformer_for_where,
+ (uchar*)sl);
if (extracted_cond_copy)
{
extracted_cond_copy->walk(
@@ -1424,9 +1488,12 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
pushed into the where clause of sl to make them usable in the new context
*/
if (cond_over_grouping_fields)
- cond_over_grouping_fields= cond_over_grouping_fields->transform(thd,
- &Item::derived_grouping_field_transformer_for_where,
- (uchar*) sl);
+ {
+ cond_over_grouping_fields=
+ transform_condition_or_part(thd, cond_over_grouping_fields,
+ &Item::derived_grouping_field_transformer_for_where,
+ (uchar*) sl);
+ }
if (cond_over_grouping_fields)
{
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2e02d418210..e7c42cbc8e4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -64,6 +64,19 @@
#endif
#include "transaction.h"
+
+#include "lex_symbol.h"
+#define KEYWORD_SIZE 64
+
+extern SYMBOL symbols[];
+extern size_t symbols_length;
+
+extern SYMBOL sql_functions[];
+extern size_t sql_functions_length;
+
+extern Native_func_registry func_array[];
+extern size_t func_array_length;
+
enum enum_i_s_events_fields
{
ISE_EVENT_CATALOG= 0,
@@ -7894,6 +7907,60 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond)
DBUG_RETURN(res);
}
+int add_symbol_to_table(const char* name, TABLE* table){
+ DBUG_ENTER("add_symbol_to_table");
+
+ uint length= strlen(name);
+
+ // If you've added a new SQL keyword longer than KEYWORD_SIZE,
+ // please increase the defined max length
+ DBUG_ASSERT(length < KEYWORD_SIZE);
+
+ restore_record(table, s->default_values);
+ table->field[0]->set_notnull();
+ table->field[0]->store(name, length,
+ system_charset_info);
+ if (schema_table_store_record(table->in_use, table))
+ DBUG_RETURN(1);
+
+ DBUG_RETURN(0);
+}
+
+int fill_i_s_keywords(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ DBUG_ENTER("fill_i_s_keywords");
+
+ TABLE *table= tables->table;
+
+ for (uint i= 0; i < symbols_length; i++){
+ const char *name= symbols[i].name;
+ if (add_symbol_to_table(name, table))
+ DBUG_RETURN(1);
+ }
+
+ DBUG_RETURN(0);
+}
+
+int fill_i_s_sql_functions(THD *thd, TABLE_LIST *tables, COND *cond) {
+ DBUG_ENTER("fill_i_s_sql_functions");
+
+ TABLE *table= tables->table;
+
+ for (uint i= 0; i < sql_functions_length; i++){
+ const char *name= sql_functions[i].name;
+ if (add_symbol_to_table(name, table))
+ DBUG_RETURN(1);
+ }
+
+ for (uint i= 0; i < func_array_length; i++){
+ const char *name= func_array[i].name.str;
+ if (add_symbol_to_table(name, table))
+ DBUG_RETURN(1);
+ }
+
+ DBUG_RETURN(0);
+}
+
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
{
@@ -9187,6 +9254,18 @@ ST_FIELD_INFO enabled_roles_fields_info[]=
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
};
+ST_FIELD_INFO keywords_field_info[]=
+{
+ {"WORD", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
+};
+
+ST_FIELD_INFO sql_functions_field_info[]=
+{
+ {"FUNCTION", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
+};
+
ST_FIELD_INFO engines_fields_info[]=
{
@@ -9890,6 +9969,8 @@ ST_SCHEMA_TABLE schema_tables[]=
fill_status, make_old_format, 0, 0, -1, 0, 0},
{"GLOBAL_VARIABLES", variables_fields_info, 0,
fill_variables, make_old_format, 0, 0, -1, 0, 0},
+ {"KEYWORDS", keywords_field_info, 0,
+ fill_i_s_keywords, 0, 0, -1, -1, 0, 0},
{"KEY_CACHES", keycache_fields_info, 0,
fill_key_cache_tables, 0, 0, -1,-1, 0, 0},
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0,
@@ -9925,6 +10006,8 @@ ST_SCHEMA_TABLE schema_tables[]=
{"STATISTICS", stat_fields_info, 0,
get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0,
OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE},
+ {"SQL_FUNCTIONS", sql_functions_field_info, 0,
+ fill_i_s_sql_functions, 0, 0, -1, -1, 0, 0},
{"SYSTEM_VARIABLES", sysvars_fields_info, 0,
fill_sysvars, make_old_format, 0, 0, -1, 0, 0},
{"TABLES", tables_fields_info, 0,
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index bba682689a6..811a8c7485a 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -5366,6 +5366,8 @@ os_file_set_size(
fallback:
#else
+ struct stat statbuf;
+
if (is_sparse) {
bool success = !ftruncate(file, size);
if (!success) {
@@ -5379,10 +5381,17 @@ fallback:
# ifdef HAVE_POSIX_FALLOCATE
int err;
do {
- os_offset_t current_size = os_file_get_size(file);
- err = current_size >= size
- ? 0 : posix_fallocate(file, current_size,
+ if (fstat(file, &statbuf)) {
+ err = errno;
+ } else {
+ os_offset_t current_size = statbuf.st_size;
+ if (current_size >= size) {
+ return true;
+ }
+ current_size &= ~os_offset_t(statbuf.st_blksize - 1);
+ err = posix_fallocate(file, current_size,
size - current_size);
+ }
} while (err == EINTR
&& srv_shutdown_state <= SRV_SHUTDOWN_INITIATED);
@@ -5405,6 +5414,27 @@ fallback:
# endif /* HAVE_POSIX_ALLOCATE */
#endif /* _WIN32*/
+#ifdef _WIN32
+ os_offset_t current_size = os_file_get_size(file);
+ FILE_STORAGE_INFO info;
+ if (GetFileInformationByHandleEx(file, FileStorageInfo, &info,
+ sizeof info)) {
+ if (info.LogicalBytesPerSector) {
+ current_size &= ~os_offset_t(info.LogicalBytesPerSector
+ - 1);
+ }
+ }
+#else
+ if (fstat(file, &statbuf)) {
+ return false;
+ }
+ os_offset_t current_size = statbuf.st_size
+ & ~os_offset_t(statbuf.st_blksize - 1);
+#endif
+ if (current_size >= size) {
+ return true;
+ }
+
/* Write up to 1 megabyte at a time. */
ulint buf_size = ut_min(ulint(64),
ulint(size >> srv_page_size_shift))
@@ -5420,8 +5450,6 @@ fallback:
/* Write buffer full of zeros */
memset(buf, 0, buf_size);
- os_offset_t current_size = os_file_get_size(file);
-
while (current_size < size
&& srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) {
ulint n_bytes;