Skip to content

Commit

Permalink
Merge 10.2 into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed May 2, 2019
2 parents 0d6fb43 + 2370eeb commit 158247d
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 35 deletions.
20 changes: 19 additions & 1 deletion mysql-test/main/constraints.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
drop table if exists t1;
create table t1 (a int check (a>0));
show create table t1;
Table Create Table
Expand Down Expand Up @@ -111,6 +110,25 @@ long_enough_name CREATE TABLE `long_enough_name` (
CONSTRAINT `constr` CHECK (`f6` >= 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE long_enough_name;
CREATE TABLE test.t(t int COMMENT 't_comment' CHECK(t>0));
SHOW CREATE TABLE test.t;
Table Create Table
t CREATE TABLE `t` (
`t` int(11) DEFAULT NULL COMMENT 't_comment' CHECK (`t` > 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP table test.t;
SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
CREATE TABLE test.t (f int foo=bar check(f>0));
Warnings:
Warning 1911 Unknown option 'foo'
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`f` int(11) DEFAULT NULL `foo`=bar CHECK (`f` > 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP table test.t;
SET @@SQL_MODE=@OLD_SQL_MODE;
create table t1 (a int check (a>10)) select 100 as 'a';
show create table t1;
Table Create Table
Expand Down
23 changes: 18 additions & 5 deletions mysql-test/main/constraints.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#
# Testing of constraints
#
--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1 (a int check (a>0));
show create table t1;
insert into t1 values (1);
Expand Down Expand Up @@ -104,7 +100,24 @@ SHOW CREATE TABLE long_enough_name;
DROP TABLE long_enough_name;

#
# Check that we don't loose constraints as part of CREATE ... SELECT
# MDEV-17654 Incorrect syntax returned for column with CHECK constraint
# in the "SHOW CREATE TABLE ..." result
#

CREATE TABLE test.t(t int COMMENT 't_comment' CHECK(t>0));
SHOW CREATE TABLE test.t;
DROP table test.t;

SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';

CREATE TABLE test.t (f int foo=bar check(f>0));
SHOW CREATE TABLE t;
DROP table test.t;
SET @@SQL_MODE=@OLD_SQL_MODE;

#
# Check that we don't lose constraints as part of CREATE ... SELECT
#

create table t1 (a int check (a>10)) select 100 as 'a';
Expand Down
32 changes: 26 additions & 6 deletions mysql-test/main/trigger.result
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ ERROR HY000: Can't update table 't2' in stored function/trigger because it is al
DROP TABLE t1;
DROP TRIGGER t_insert;
DROP TABLE t2;
End of 5.0 tests
# End of 5.0 tests
drop table if exists table_25411_a;
drop table if exists table_25411_b;
create table table_25411_a(a int);
Expand Down Expand Up @@ -2131,7 +2131,7 @@ b
# Work around Bug#45235
DROP DATABASE db1;
USE test;
End of 5.1 tests.
# End of 5.1 tests.
create table t1 (i int);
create table t2 (i int);
flush tables;
Expand All @@ -2150,7 +2150,7 @@ select * from t2;
i
2
drop table t1,t2;
End of 5.2 tests.
# End of 5.2 tests.
#
# Bug#34453 Can't change size of file (Errcode: 1224)
#
Expand Down Expand Up @@ -2253,7 +2253,7 @@ c
aaa
DROP TABLE t1;

End of 5.5 tests.
# End of 5.5 tests.
#
# BUG #910083: materialized subquery in a trigger
#
Expand Down Expand Up @@ -2300,7 +2300,7 @@ b
SET optimizer_switch=@save_optimizer_switch;
DROP TRIGGER tr;
DROP TABLE t1, t2;
End of 5.3 tests.
# End of 5.3 tests.
set time_zone="+00:00";
SET TIMESTAMP=UNIX_TIMESTAMP('2001-01-01 10:20:30');
SET @@session.sql_mode = 'STRICT_ALL_TABLES,STRICT_TRANS_TABLES';
Expand Down Expand Up @@ -2407,7 +2407,24 @@ AFTER UPDATE ON t1 FOR EACH ROW SELECT (SELECT b FROM t2) INTO @x;
# Running 20000 queries
DROP TABLE t1,t2;
#
# Start of 10.3 tests
# MDEV-19188 Server Crash When Using a Trigger With A Number of Virtual Columns on INSERT/UPDATE
#
CREATE TABLE t1 (
virt1 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt2 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt3 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt4 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt5 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt6 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt7 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt8 INT GENERATED ALWAYS AS (0) VIRTUAL
);
INSERT INTO t1 () VALUES ();
CREATE TRIGGER t1_trigger BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 () VALUES ();
DROP TABLE t1;
#
# End of 10.2 tests
#
#
# MDEV-12461 TYPE OF and ROW TYPE OF anchored data types
Expand All @@ -2426,3 +2443,6 @@ SELECT * FROM t1;
a b total
10 20 30
DROP TABLE t1;
#
# End of 10.3 tests
#
34 changes: 28 additions & 6 deletions mysql-test/main/trigger.test
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ DROP TABLE t1;
DROP TRIGGER t_insert;
DROP TABLE t2;

--echo End of 5.0 tests
--echo # End of 5.0 tests

#
# Bug#25411 (trigger code truncated)
Expand Down Expand Up @@ -2406,7 +2406,7 @@ let $MYSQLD_DATADIR = `select @@datadir`;
DROP DATABASE db1;
USE test;

--echo End of 5.1 tests.
--echo # End of 5.1 tests.

#
# Test that using a trigger will not open mysql.proc
Expand All @@ -2430,7 +2430,7 @@ select * from t1;
select * from t2;
drop table t1,t2;

--echo End of 5.2 tests.
--echo # End of 5.2 tests.

--echo #
--echo # Bug#34453 Can't change size of file (Errcode: 1224)
Expand Down Expand Up @@ -2574,7 +2574,7 @@ SELECT c FROM t1;
DROP TABLE t1;

--echo
--echo End of 5.5 tests.
--echo # End of 5.5 tests.

--echo #
--echo # BUG #910083: materialized subquery in a trigger
Expand Down Expand Up @@ -2613,7 +2613,7 @@ SET optimizer_switch=@save_optimizer_switch;
DROP TRIGGER tr;
DROP TABLE t1, t2;

--echo End of 5.3 tests.
--echo # End of 5.3 tests.

#
# MDEV-4829 BEFORE INSERT triggers dont issue 1406 error
Expand Down Expand Up @@ -2737,9 +2737,27 @@ while ($n)

DROP TABLE t1,t2;

--echo #
--echo # MDEV-19188 Server Crash When Using a Trigger With A Number of Virtual Columns on INSERT/UPDATE
--echo #

CREATE TABLE t1 (
virt1 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt2 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt3 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt4 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt5 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt6 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt7 INT GENERATED ALWAYS AS (0) VIRTUAL,
virt8 INT GENERATED ALWAYS AS (0) VIRTUAL
);
INSERT INTO t1 () VALUES ();
CREATE TRIGGER t1_trigger BEFORE INSERT ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 () VALUES ();
DROP TABLE t1;

--echo #
--echo # Start of 10.3 tests
--echo # End of 10.2 tests
--echo #

--echo #
Expand All @@ -2760,3 +2778,7 @@ DELIMITER ;$$
INSERT INTO t1 (a,b) VALUES (10, 20);
SELECT * FROM t1;
DROP TABLE t1;

--echo #
--echo # End of 10.3 tests
--echo #
46 changes: 42 additions & 4 deletions sql/signal_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#define SIGNAL_FMT "signal %d"
#endif

#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

/*
We are handling signals/exceptions in this file.
Any global variables we read should be 'volatile sig_atomic_t'
Expand All @@ -44,6 +48,43 @@ extern volatile sig_atomic_t ld_assume_kernel_is_set;

extern const char *optimizer_switch_names[];

static inline void output_core_info()
{
/* proc is optional on some BSDs so it can't hurt to look */
#ifdef HAVE_READLINK
char buff[PATH_MAX];
ssize_t len;
int fd;
if ((len= readlink("/proc/self/cwd", buff, sizeof(buff))) >= 0)
{
my_safe_printf_stderr("Writing a core file...\nWorking directory at %.*s\n",
(int) len, buff);
}
if ((fd= my_open("/proc/self/limits", O_RDONLY, MYF(0))) >= 0)
{
my_safe_printf_stderr("Resource Limits:\n");
while ((len= my_read(fd, (uchar*)buff, sizeof(buff), MYF(0))) > 0)
{
my_write_stderr(buff, len);
}
my_close(fd, MYF(0));
}
#ifdef __linux__
if ((fd= my_open("/proc/sys/kernel/core_pattern", O_RDONLY, MYF(0))) >= 0)
{
len= my_read(fd, (uchar*)buff, sizeof(buff), MYF(0));
my_safe_printf_stderr("Core pattern: %.*s\n", (int) len, buff);
my_close(fd, MYF(0));
}
#endif
#else
char buff[80];
my_getwd(buff, sizeof(buff), 0);
my_safe_printf_stderr("Writing a core file at %s\n", buff);
fflush(stderr);
#endif
}

/**
* Handler for fatal signals on POSIX, exception handler on Windows.
*
Expand Down Expand Up @@ -295,13 +336,10 @@ extern "C" sig_handler handle_fatal_signal(int sig)
}
#endif

output_core_info();
#ifdef HAVE_WRITE_CORE
if (test_flags & TEST_CORE_ON_SIGNAL)
{
char buff[80];
my_getwd(buff, sizeof(buff), 0);
my_safe_printf_stderr("Writing a core file at %s\n", buff);
fflush(stderr);
my_write_core(sig);
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions sql/sql_analyze_stmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void Filesort_tracker::print_json_members(Json_writer *writer)
else if (r_limit == 0)
writer->add_str(varied_str);
else
writer->add_ll((longlong) rint(r_limit));
writer->add_ll(r_limit);
}

writer->add_member("r_used_priority_queue");
Expand All @@ -61,13 +61,13 @@ void Filesort_tracker::print_json_members(Json_writer *writer)
if (!get_r_loops())
writer->add_member("r_output_rows").add_null();
else
writer->add_member("r_output_rows").add_ll((longlong) rint(r_output_rows /
get_r_loops()));
writer->add_member("r_output_rows").add_ll(
(longlong) rint((double)r_output_rows / get_r_loops()));

if (sort_passes)
{
writer->add_member("r_sort_passes").add_ll((longlong) rint(sort_passes /
get_r_loops()));
writer->add_member("r_sort_passes").add_ll(
(longlong) rint((double)sort_passes / get_r_loops()));
}

if (sort_buffer_size != 0)
Expand Down
17 changes: 10 additions & 7 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,16 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
!(sql_mode & MODE_NO_FIELD_OPTIONS))
packet->append(STRING_WITH_LEN(" AUTO_INCREMENT"));
}

if (field->comment.length)
{
packet->append(STRING_WITH_LEN(" COMMENT "));
append_unescaped(packet, field->comment.str, field->comment.length);
}

append_create_options(thd, packet, field->option_list, check_options,
hton->field_options);

if (field->check_constraint)
{
StringBuffer<MAX_FIELD_WIDTH> str(&my_charset_utf8mb4_general_ci);
Expand All @@ -2314,13 +2324,6 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(")"));
}

if (field->comment.length)
{
packet->append(STRING_WITH_LEN(" COMMENT "));
append_unescaped(packet, field->comment.str, field->comment.length);
}
append_create_options(thd, packet, field->option_list, check_options,
hton->field_options);
}

key_info= table->key_info;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Table_triggers_list: public Sql_alloc
Field **nullable_fields() { return record0_field; }
void reset_extra_null_bitmap()
{
size_t null_bytes= (trigger_table->s->stored_fields -
size_t null_bytes= (trigger_table->s->fields -
trigger_table->s->null_fields + 7)/8;
bzero(extra_null_bitmap, null_bytes);
}
Expand Down

0 comments on commit 158247d

Please sign in to comment.