Commit 384407aa authored by unknown's avatar unknown

Bug#21114 (Foreign key creation fails to table with name format)

Due to the complexity of this change, everything is documented in WL#3565

This patch is the third iteration, it takes into account the comments
received to date.


mysql-test/r/func_math.result:
  Improved test coverage
mysql-test/r/view.result:
  Name collision, x() is a geometry native in function
mysql-test/t/func_math.test:
  Improved test coverage
mysql-test/t/view.test:
  Name collision, x() is a geometry native in function
sql/item_create.cc:
  Revised the create_func implementation
sql/item_create.h:
  Revised the create_func implementation
sql/item_geofunc.h:
  Explicit Item allocation in the thread memory pool.
sql/lex.h:
  Removed function parsing from the lexical parser
sql/lex_symbol.h:
  Removed function parsing from the lexical parser
sql/mysql_priv.h:
  Server initialization and shutdown
sql/mysqld.cc:
  Server initialization and shutdown
sql/share/errmsg.txt:
  New error messages
sql/sql_yacc.yy:
  Removed function parsing from the lexical parser
tests/mysql_client_test.c:
  Spaces are no longer significant for function calls
mysql-test/include/parser_bug21114.inc:
  New tests
mysql-test/r/parser.result:
  New tests
mysql-test/r/parser_bug21114_innodb.result:
  New tests
mysql-test/t/parser.test:
  New tests
mysql-test/t/parser_bug21114_innodb.test:
  New tests
parent 83d5beec
#
# Bug#21114 (Foreign key creation fails to table with name format)
#
# Trying to trick the parser into thinking $FCT(...) is a function call,
# which is not in the CREATE TABLE and FOREIGN KEY ... REFERENCES syntax
#
# Usage :
#
# let $engine_type=InnoDb;
# let $verbose=1;
# let $FCT= <value_1>;
# -- source parser_stress_func.inc
# let $FCT= <value_2>;
# -- source parser_stress_func.inc
# let $verbose=0;
# let $FCT= <value_3>;
# -- source parser_stress_func.inc
# let $FCT= <value_4>;
# -- source parser_stress_func.inc
-- disable_warnings
eval drop table if exists $FCT;
drop table if exists bug21114_child;
-- enable_warnings
--disable_query_log
--disable_result_log
eval CREATE TABLE $FCT(
col1 int not null,
col2 int not null,
col3 varchar(10),
CONSTRAINT pk PRIMARY KEY (col1, col2)
) ENGINE $engine_type;
eval CREATE TABLE bug21114_child(
pk int not null,
fk_col1 int not null,
fk_col2 int not null,
fk_col3 int not null,
fk_col4 int not null,
CONSTRAINT fk_fct FOREIGN KEY (fk_col1, fk_col2)
REFERENCES $FCT(col1, col2),
CONSTRAINT fk_fct_space FOREIGN KEY (fk_col3, fk_col4)
REFERENCES $FCT (col1, col2)
) ENGINE $engine_type;
--enable_query_log
--enable_result_log
if ($verbose)
{
eval SHOW CREATE TABLE $FCT;
SHOW CREATE TABLE bug21114_child;
}
DROP TABLE bug21114_child;
eval DROP TABLE $FCT;
......@@ -102,6 +102,18 @@ Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2)
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
180 6.2831853071796
select format(atan(-2, 2), 6);
format(atan(-2, 2), 6)
-0.785398
select format(atan(pi(), 0), 6);
format(atan(pi(), 0), 6)
1.570796
select format(atan2(-2, 2), 6);
format(atan2(-2, 2), 6)
-0.785398
select format(atan2(pi(), 0), 6);
format(atan2(pi(), 0), 6)
1.570796
SELECT ACOS(1.0);
ACOS(1.0)
0
......
This diff is collapsed.
This diff is collapsed.
......@@ -791,13 +791,13 @@ test.`f``1` ()
5
drop view v1;
drop function `f``1`;
create function x () returns int return 5;
create view v1 as select x ();
create function a() returns int return 5;
create view v1 as select a();
select * from v1;
x ()
a()
5
drop view v1;
drop function x;
drop function a;
create table t2 (col1 char collate latin1_german2_ci);
create view v2 as select col1 collate latin1_german1_ci from t2;
show create view v2;
......
......@@ -34,6 +34,11 @@ select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6)
explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
select degrees(pi()),radians(360);
select format(atan(-2, 2), 6);
select format(atan(pi(), 0), 6);
select format(atan2(-2, 2), 6);
select format(atan2(pi(), 0), 6);
#
# Bug #2338 Trignometric arithmatic problems
#
......
This diff is collapsed.
This diff is collapsed.
......@@ -698,11 +698,11 @@ drop function `f``1`;
#
# tested problem when function name length close to ALIGN_SIZE
#
create function x () returns int return 5;
create view v1 as select x ();
create function a() returns int return 5;
create view v1 as select a();
select * from v1;
drop view v1;
drop function x;
drop function a;
#
# VIEW with collation
......
This diff is collapsed.
This diff is collapsed.
......@@ -348,11 +348,11 @@ class Item_func_srid: public Item_int_func
void fix_length_and_dec() { max_length= 10; }
};
#define GEOM_NEW(obj_constructor) new obj_constructor
#define GEOM_NEW(thd, obj_constructor) new (thd->mem_root) obj_constructor
#else /*HAVE_SPATIAL*/
#define GEOM_NEW(obj_constructor) NULL
#define GEOM_NEW(thd, obj_constructor) NULL
#endif
This diff is collapsed.
......@@ -26,7 +26,6 @@ typedef struct st_symbol {
const char *name;
uint tok;
uint length;
void *create_func;
struct st_sym_group *group;
} SYMBOL;
......
......@@ -2011,6 +2011,10 @@ inline void kill_delayed_threads(void) {}
/* Used by handlers to store things in schema tables */
bool schema_table_store_record(THD *thd, TABLE *table);
/* sql/item_create.cc */
int item_create_init();
void item_create_cleanup();
#endif /* MYSQL_SERVER */
#endif /* MYSQL_CLIENT */
......
......@@ -1184,6 +1184,7 @@ void clean_up(bool print_message)
hostname_cache_free();
item_user_lock_free();
lex_free(); /* Free some memory */
item_create_cleanup();
set_var_free();
free_charsets();
(void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */
......@@ -2693,6 +2694,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
return 1;
init_client_errs();
lex_init();
if (item_create_init())
return 1;
item_init();
set_var_init();
mysys_uses_curses=0;
......
......@@ -6006,4 +6006,8 @@ ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into"
ER_CANT_RENAME_LOG_TABLE
eng "Cannot rename '%s'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to '%s'"
ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000
eng "Incorrect parameter count in the call to native function '%-.64s'"
ER_WRONG_PARAMETERS_TO_NATIVE_FCT 42000
eng "Incorrect parameters in the call to native function '%-.64s'"
This diff is collapsed.
......@@ -8685,7 +8685,7 @@ static void test_sqlmode()
if (!opt_silent)
fprintf(stdout, "\n query: %s", query);
stmt= mysql_simple_prepare(mysql, query);
check_stmt_r(stmt);
check_stmt(stmt);
/* ANSI */
strmov(query, "SET SQL_MODE= \"ANSI\"");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment