Skip to content

MDEV-36484 Atomic DDL: Assertion `!param->got_error' failed upon unsu… #3991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: bb-11.8-MDEV-34870-join-order
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ static char **defaults_argv;
enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT};
typedef enum enum_info_type INFO_TYPE;

enum ss_comment_type { SSC_NONE= 0, SSC_CONDITIONAL, SSC_HINT };

static MYSQL mysql; /* The connection */
static my_bool ignore_errors=0,wait_flag=0,quick=0,
connected=0,opt_raw_data=0,unbuffered=0,output_tables=0,
Expand Down Expand Up @@ -1158,7 +1160,8 @@ static void fix_history(String *final_command);

static COMMANDS *find_command(char *name);
static COMMANDS *find_command(char cmd_name);
static bool add_line(String &, char *, size_t line_length, char *, bool *, bool);
static bool add_line(String &, char *, size_t line_length, char *,
bool *, ss_comment_type *, bool);
static void remove_cntrl(String &buffer);
static void print_table_data(MYSQL_RES *result);
static void print_table_data_html(MYSQL_RES *result);
Expand Down Expand Up @@ -2211,6 +2214,7 @@ static int read_and_execute(bool interactive)
char in_string=0;
ulong line_number=0;
bool ml_comment= 0;
ss_comment_type ss_comment= SSC_NONE;
COMMANDS *com;
size_t line_length= 0;
status.exit_status=1;
Expand Down Expand Up @@ -2357,7 +2361,8 @@ static int read_and_execute(bool interactive)
#endif
continue;
}
if (add_line(glob_buffer, line, line_length, &in_string, &ml_comment,
if (add_line(glob_buffer, line, line_length, &in_string,
&ml_comment, &ss_comment,
status.line_buff ? status.line_buff->truncated : 0))
break;
}
Expand Down Expand Up @@ -2526,13 +2531,13 @@ static COMMANDS *find_command(char *name)


static bool add_line(String &buffer, char *line, size_t line_length,
char *in_string, bool *ml_comment, bool truncated)
char *in_string, bool *ml_comment,
ss_comment_type *ss_comment, bool truncated)
{
uchar inchar;
char buff[80], *pos, *out;
COMMANDS *com;
bool need_space= 0;
bool ss_comment= 0;
DBUG_ENTER("add_line");

if (!line[0] && buffer.is_empty())
Expand Down Expand Up @@ -2607,7 +2612,7 @@ static bool add_line(String &buffer, char *line, size_t line_length,
DBUG_RETURN(1); // Quit
if (com->takes_params)
{
if (ss_comment)
if (*ss_comment != SSC_NONE)
{
/*
If a client-side macro appears inside a server-side comment,
Expand Down Expand Up @@ -2641,7 +2646,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
continue;
}
}
else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter))
else if (!*ml_comment && !*in_string && *ss_comment != SSC_HINT &&
is_prefix(pos, delimiter))
{
// Found a statement. Continue parsing after the delimiter
pos+= delimiter_length;
Expand Down Expand Up @@ -2729,8 +2735,9 @@ static bool add_line(String &buffer, char *line, size_t line_length,

break;
}
else if (!*in_string && inchar == '/' && *(pos+1) == '*' &&
!(*(pos+2) == '!' || (*(pos+2) == 'M' && *(pos+3) == '!')))
else if (!*in_string && inchar == '/' && pos[1] == '*' &&
pos[2] != '!' && !(pos[2] == 'M' && pos[3] == '!') &&
pos[2] != '+' && *ss_comment != SSC_HINT)
{
if (preserve_comments)
{
Expand All @@ -2746,7 +2753,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
out=line;
}
}
else if (*ml_comment && !ss_comment && inchar == '*' && *(pos + 1) == '/')
else if (*ml_comment && *ss_comment == SSC_NONE &&
inchar == '*' && *(pos + 1) == '/')
{
if (preserve_comments)
{
Expand All @@ -2767,14 +2775,24 @@ static bool add_line(String &buffer, char *line, size_t line_length,
}
else
{ // Add found char to buffer
if (!*in_string && inchar == '/' && *(pos + 1) == '*' &&
*(pos + 2) == '!')
ss_comment= 1;
else if (!*in_string && ss_comment && inchar == '*' && *(pos + 1) == '/')
ss_comment= 0;
if (!*in_string && inchar == '/' && pos[1] == '*')
{
if (pos[2] == '!')
*ss_comment= SSC_CONDITIONAL;
else if (pos[2] == '+')
*ss_comment= SSC_HINT;
}
else if (!*in_string && *ss_comment != SSC_NONE &&
inchar == '*' && *(pos + 1) == '/')
{
*ss_comment= SSC_NONE;
*out++= *pos++; // copy '*'
*out++= *pos; // copy '/'
continue;
}
if (inchar == *in_string)
*in_string= 0;
else if (!*ml_comment && !*in_string &&
else if (!*ml_comment && !*in_string && *ss_comment != SSC_HINT &&
(inchar == '\'' || inchar == '"' || inchar == '`'))
*in_string= (char) inchar;
if (!*ml_comment || preserve_comments)
Expand Down
9 changes: 9 additions & 0 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@ typedef struct st_io_cache /* Used when caching files */
size_t alloced_buffer;
} IO_CACHE;

typedef struct Prepared_error
{
uint code;
char message[MYSYS_ERRMSG_SIZE];
myf flags;
} MY_PREPARED_ERROR;

typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);

Expand Down Expand Up @@ -743,6 +750,8 @@ extern int my_error_register(const char** (*get_errmsgs) (int nr),
extern my_bool my_error_unregister(uint first, uint last);
extern void my_message(uint my_err, const char *str,myf MyFlags);
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
extern struct Prepared_error my_error_prepare(uint nr, myf MyFlags, ...);
extern void my_error_issue(struct Prepared_error* error);
extern my_bool my_init(void);
extern void my_end(int infoflag);
extern int my_redel(const char *from, const char *to, time_t backup_time_stamp,
Expand Down
3 changes: 3 additions & 0 deletions libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/json_table.cc
../sql/opt_histogram_json.cc
../sql/sp_instr.cc
../sql/opt_hints_parser.cc ../sql/opt_hints_parser.h
../sql/scan_char.h
../sql/opt_hints.cc ../sql/opt_hints.h
${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/include/default_optimizer_switch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set @save_optimizer_switch=@@optimizer_switch;
set @save_join_cache_level=@@join_cache_level;

set optimizer_switch="index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on";
set optimizer_switch="index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,duplicateweedout=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on";

set optimizer_use_condition_selectivity=4;
set optimizer_search_depth=62;
Expand Down
27 changes: 27 additions & 0 deletions mysql-test/main/lowercase_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,30 @@ DROP PACKAGE test.pkg;
#
# End of 11.4 tests
#
#
# Start of 11.7 tests
#
#
# MDEV-33281 Implement optimizer hints like in MySQL
#
SET NAMES utf8mb4;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2);
SELECT /*+BKA(a) BKA(å)*/ a.a FROM t1 a, t1 å;
a
1
2
1
2
SELECT a.a, A.a FROM t1 a, t1 A;
ERROR 42000: Not unique table/alias: 'A'
SELECT /*+BKA(a) BKA(A)*/ a.a FROM t1 a;
a
1
2
Warnings:
Warning 4210 Hint BKA("A") is ignored as conflicting/duplicated
DROP TABLE t1;
#
# End of 11.7 tests
#
32 changes: 32 additions & 0 deletions mysql-test/main/lowercase_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,35 @@ DROP PACKAGE test.pkg;
--echo #
--echo # End of 11.4 tests
--echo #


--echo #
--echo # Start of 11.7 tests
--echo #

--echo #
--echo # MDEV-33281 Implement optimizer hints like in MySQL
--echo #

SET NAMES utf8mb4;

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2);

--enable_prepare_warnings
# Test that aliases are accent sensitive with lowercase-table-names=1
# Test that table names in hints are also accent sensitive
SELECT /*+BKA(a) BKA(å)*/ a.a FROM t1 a, t1 å;

# Test that aliases are case insensitive with lowercase-table-names=1
--error ER_NONUNIQ_TABLE
SELECT a.a, A.a FROM t1 a, t1 A;
# Test that table names in hints are also case insensitive
SELECT /*+BKA(a) BKA(A)*/ a.a FROM t1 a;
--disable_prepare_warnings

DROP TABLE t1;

--echo #
--echo # End of 11.7 tests
--echo #
25 changes: 25 additions & 0 deletions mysql-test/main/lowercase_table5.result
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,28 @@ DROP DATABASE MYSQL;
#
# End of 10.5 tests
#
#
# Start of 11.7 tests
#
#
# MDEV-33281 Implement optimizer hints like in MySQL
#
SET NAMES utf8mb4;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2);
SELECT /*+BKA(a) BKA(å)*/ a.a, å.a FROM t1 a, t1 å;
a a
1 1
2 1
1 2
2 2
SELECT /*+BKA(a) BKA(A)*/ a.a, A.a FROM t1 a, t1 A;
a a
1 1
2 1
1 2
2 2
DROP TABLE t1;
#
# End of 11.7 tests
#
27 changes: 27 additions & 0 deletions mysql-test/main/lowercase_table5.test
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,30 @@ DROP DATABASE MYSQL;
--echo #
--echo # End of 10.5 tests
--echo #

--echo #
--echo # Start of 11.7 tests
--echo #

--echo #
--echo # MDEV-33281 Implement optimizer hints like in MySQL
--echo #

SET NAMES utf8mb4;

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2);

# Test that table aliases are accent sensitive with lowercase-table-names=0
# Test that table names in hints are also accent sensitive
SELECT /*+BKA(a) BKA(å)*/ a.a, å.a FROM t1 a, t1 å;

# Test that table aliases are case sensitive with lowercase-table-names=0
# Test that table names in hints are also case sensitive
SELECT /*+BKA(a) BKA(A)*/ a.a, A.a FROM t1 a, t1 A;

DROP TABLE t1;

--echo #
--echo # End of 11.7 tests
--echo #
16 changes: 16 additions & 0 deletions mysql-test/main/mysql_comments.result
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Trigger sql_mode SQL Original Statement character_set_client collation_connectio
t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n\n\n\n \n declare b int;\n declare c float;\n\n \n \n\n \n set NEW.data := 12;\nend latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci --TIME--
id data
trig 12
id data
trig 12
id data
trig 12
id data
trig 12
id data
trig 12
"Pass 2 : --enable-comments"
1
1
Expand Down Expand Up @@ -60,5 +68,13 @@ Trigger sql_mode SQL Original Statement character_set_client collation_connectio
t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n# comment 1a\n-- comment 1b\n/*\n comment 1c\n*/\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\n set NEW.data := 12;\nend latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci --TIME--
id data
trig 12
id data
trig 12
id data
trig 12
id data
trig 12
id data
trig 12
set global sql_mode=default;
End of 5.0 tests
12 changes: 12 additions & 0 deletions mysql-test/main/mysql_comments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ show create trigger t1_bi;
insert into t1(id) value ("trig");
select * from t1;

##============================================================================
## Optimizer hints
##============================================================================

select /*+ no_icp(t1)*/* from t1;
select /*+ no_icp(t1) " ;,` */* from t1;
select /*+ "some text" */* from t1;

select /* no_icp(t1)
no_bka(t1)
*/* from t1;

##============================================================================
## Cleanup
##============================================================================
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/mysqld--help.result
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ The following specify which files/extra groups are read (specified before remain
index_merge_sort_union, index_merge_intersection,
index_merge_sort_intersection, index_condition_pushdown,
derived_merge, derived_with_keys, firstmatch, loosescan,
materialization, in_to_exists, semijoin,
duplicateweedout, materialization, in_to_exists, semijoin,
partial_match_rowid_merge, partial_match_table_scan,
subquery_cache, mrr, mrr_cost_based, mrr_sort_keys,
outer_join_with_cache, semijoin_with_cache,
Expand Down Expand Up @@ -1880,7 +1880,7 @@ optimizer-rowid-copy-cost 0.002653
optimizer-scan-setup-cost 10
optimizer-search-depth 62
optimizer-selectivity-sampling-limit 100
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on,cset_narrowing=on,sargable_casefold=on
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,duplicateweedout=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on,cset_narrowing=on,sargable_casefold=on
optimizer-trace
optimizer-trace-max-mem-size 1048576
optimizer-use-condition-selectivity 4
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/mysqltest_tracking_info.result
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set @save_optimizer_switch=@@optimizer_switch;
SET @@session.session_track_system_variables='optimizer_switch';
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- optimizer_switch: index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on,cset_narrowing=on,sargable_casefold=on
-- optimizer_switch: index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,duplicateweedout=on,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on,cset_narrowing=on,sargable_casefold=on

set @@optimizer_switch=@save_optimizer_switch;
SET @@session.session_track_system_variables= @save_session_track_system_variables;
Expand Down
Loading