Commit 0497f0c2 authored by Kristofer Pettersson's avatar Kristofer Pettersson

auto-merge

parents fc1acef6 2c38ed0d
......@@ -1894,4 +1894,18 @@ DROP TABLE t1;
create table `me:i`(id int);
drop table `me:i`;
# --
# -- Bug#45829: CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing
# --
drop table if exists t1,t2,t3;
create table t1 (a int) transactional=0;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'transactional=0' at line 1
create table t2 (a int) page_checksum=1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page_checksum=1' at line 1
create table t3 (a int) row_format=page;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page' at line 1
# -- End of Bug#45829
End of 5.1 tests
......@@ -1068,7 +1068,13 @@ partition by range (a)
subpartition by hash(a)
(partition p0 values less than (0),
partition p1 values less than (1) (subpartition sp0));
ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '))' at line 5
ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near 'subpartition sp0))' at line 5
create table t1 (a int, b int)
partition by list (a)
subpartition by hash(a)
(partition p0 values in (0),
partition p1 values in (1) (subpartition sp0));
ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near 'subpartition sp0))' at line 5
create table t1 (a int)
partition by hash (a)
(partition p0 (subpartition sp0));
......
......@@ -19,5 +19,50 @@ fn16456()
timestamp
set binlog_format=STATEMENT;
select fn16456();
ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
drop function fn16456;
set global log_bin_trust_function_creators=0;
create function fn16456()
returns int deterministic
begin
return unix_timestamp();
end|
set binlog_format=ROW;
select fn16456();
fn16456()
timestamp
set binlog_format=STATEMENT;
select fn16456();
fn16456()
timestamp
drop function fn16456;
set global log_bin_trust_function_creators=0;
create function fn16456()
returns int no sql
begin
return unix_timestamp();
end|
set binlog_format=ROW;
select fn16456();
fn16456()
timestamp
set binlog_format=STATEMENT;
select fn16456();
fn16456()
timestamp
drop function fn16456;
set global log_bin_trust_function_creators=0;
create function fn16456()
returns int reads sql data
begin
return unix_timestamp();
end|
set binlog_format=ROW;
select fn16456();
fn16456()
timestamp
set binlog_format=STATEMENT;
select fn16456();
fn16456()
timestamp
drop function fn16456;
-- source include/have_log_bin.inc
# Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
# BUG#41166 stored function requires "deterministic" if binlog_format is "statement"
# save status
......@@ -55,15 +56,131 @@ select fn16456();
set binlog_format=STATEMENT;
--error ER_BINLOG_ROW_RBR_TO_SBR
--error ER_BINLOG_UNSAFE_ROUTINE
select fn16456();
# restore status
# clean
drop function fn16456;
# success in definition with deterministic
set global log_bin_trust_function_creators=0;
delimiter |;
create function fn16456()
returns int deterministic
begin
return unix_timestamp();
end|
delimiter ;|
# allow funcall in RBR
set binlog_format=ROW;
--replace_column 1 timestamp
select fn16456();
# allow funcall in SBR
set binlog_format=STATEMENT;
--replace_column 1 timestamp
select fn16456();
# clean
drop function fn16456;
# success in definition with NO SQL
set global log_bin_trust_function_creators=0;
delimiter |;
create function fn16456()
returns int no sql
begin
return unix_timestamp();
end|
delimiter ;|
# allow funcall in RBR
set binlog_format=ROW;
--replace_column 1 timestamp
select fn16456();
# allow funcall in SBR
set binlog_format=STATEMENT;
--replace_column 1 timestamp
select fn16456();
# clean
drop function fn16456;
# success in definition with reads sql data
set global log_bin_trust_function_creators=0;
delimiter |;
create function fn16456()
returns int reads sql data
begin
return unix_timestamp();
end|
delimiter ;|
# allow funcall in RBR
set binlog_format=ROW;
--replace_column 1 timestamp
select fn16456();
# allow funcall in SBR
set binlog_format=STATEMENT;
--replace_column 1 timestamp
select fn16456();
# clean
drop function fn16456;
# restore status
--disable_query_log
eval set binlog_format=$oblf;
eval set global log_bin_trust_function_creators=$otfc;
......
......@@ -1539,5 +1539,29 @@ DROP TABLE t1;
create table `me:i`(id int);
drop table `me:i`;
###########################################################################
#
# Bug#45829 CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing
#
--echo
--echo # --
--echo # -- Bug#45829: CREATE TABLE TRANSACTIONAL PAGE_CHECKSUM ROW_FORMAT=PAGE accepted, does nothing
--echo # --
--echo
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
--error ER_PARSE_ERROR
create table t1 (a int) transactional=0;
--error ER_PARSE_ERROR
create table t2 (a int) page_checksum=1;
--error ER_PARSE_ERROR
create table t3 (a int) row_format=page;
--echo
--echo # -- End of Bug#45829
--echo
--echo End of 5.1 tests
......@@ -1019,6 +1019,17 @@ subpartition by hash(a)
(partition p0 values less than (0),
partition p1 values less than (1) (subpartition sp0));
#
# Bug 46354 Crash with subpartition
#
--error ER_PARSE_ERROR
create table t1 (a int, b int)
partition by list (a)
subpartition by hash(a)
(partition p0 values in (0),
partition p1 values in (1) (subpartition sp0));
#
# BUG 15961 No error when subpartition defined without subpartition by clause
#
......
......@@ -62,7 +62,9 @@ static const LEX_STRING sys_table_aliases[]=
};
const char *ha_row_type[] = {
"", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE", "?","?","?"
"", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT",
/* Reserved to be "PAGE" in future versions */ "?",
"?","?","?"
};
const char *tx_isolation_names[] =
......
......@@ -280,7 +280,9 @@ enum legacy_db_type
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT,
/** Unused. Reserved for future versions. */
ROW_TYPE_PAGE };
enum enum_binlog_func {
BFN_RESET_LOGS= 1,
......@@ -323,7 +325,9 @@ enum enum_binlog_command {
#define HA_CREATE_USED_PASSWORD (1L << 17)
#define HA_CREATE_USED_CONNECTION (1L << 18)
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
/** Unused. Reserved for future versions. */
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
/** Unused. Reserved for future versions. */
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
typedef ulonglong my_xid; // this line is the same as in log_event.h
......@@ -914,13 +918,14 @@ typedef struct st_ha_create_information
uint options; /* OR of HA_CREATE_ options */
uint merge_insert_method;
uint extra_size; /* length of extra data segment */
/* 0 not used, 1 if not transactional, 2 if transactional */
/** Transactional or not. Unused; reserved for future versions. */
enum ha_choice transactional;
bool table_existed; /* 1 in create if table existed */
bool frm_only; /* 1 if no ha_create_table() */
bool varchar; /* 1 if table has a VARCHAR */
enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */
enum ha_choice page_checksum; /* If we have page_checksums */
/** Per-page checksums or not. Unused; reserved for future versions. */
enum ha_choice page_checksum;
} HA_CREATE_INFO;
......
......@@ -5990,6 +5990,9 @@ Item_func_sp::execute_impl(THD *thd)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context *save_security_ctx= thd->security_ctx;
#endif
enum enum_sp_data_access access=
(m_sp->m_chistics->daccess == SP_DEFAULT_ACCESS) ?
SP_DEFAULT_ACCESS_MAPPING : m_sp->m_chistics->daccess;
DBUG_ENTER("Item_func_sp::execute_impl");
......@@ -6007,11 +6010,13 @@ Item_func_sp::execute_impl(THD *thd)
Throw an error if a non-deterministic function is called while
statement-based replication (SBR) is active.
*/
if (!m_sp->m_chistics->detistic && !trust_function_creators &&
(access == SP_CONTAINS_SQL || access == SP_MODIFIES_SQL_DATA) &&
(mysql_bin_log.is_open() &&
thd->variables.binlog_format == BINLOG_FORMAT_STMT))
{
my_error(ER_BINLOG_ROW_RBR_TO_SBR, MYF(0));
my_error(ER_BINLOG_UNSAFE_ROUTINE, MYF(0));
goto error;
}
......
......@@ -387,7 +387,6 @@ static SYMBOL symbols[] = {
{ "PACK_KEYS", SYM(PACK_KEYS_SYM)},
{ "PARSER", SYM(PARSER_SYM)},
{ "PAGE", SYM(PAGE_SYM)},
{ "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)},
{ "PARTIAL", SYM(PARTIAL)},
{ "PARTITION", SYM(PARTITION_SYM)},
{ "PARTITIONING", SYM(PARTITIONING_SYM)},
......@@ -543,7 +542,6 @@ static SYMBOL symbols[] = {
{ "TO", SYM(TO_SYM)},
{ "TRAILING", SYM(TRAILING)},
{ "TRANSACTION", SYM(TRANSACTION_SYM)},
{ "TRANSACTIONAL", SYM(TRANSACTIONAL_SYM)},
{ "TRIGGER", SYM(TRIGGER_SYM)},
{ "TRIGGERS", SYM(TRIGGERS_SYM)},
{ "TRUE", SYM(TRUE_SYM)},
......
......@@ -70,9 +70,6 @@ enum
MYSQL_PROC_FIELD_COUNT
};
/* Tells what SP_DEFAULT_ACCESS should be mapped to */
#define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL
/*************************************************************************/
/**
......
......@@ -17,6 +17,9 @@
#ifndef _SP_H_
#define _SP_H_
/* Tells what SP_DEFAULT_ACCESS should be mapped to */
#define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL
// Return codes from sp_create_*, sp_drop_*, and sp_show_*:
#define SP_OK 0
#define SP_KEY_NOT_FOUND -1
......
......@@ -74,9 +74,6 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **),
grant_names, NULL};
#endif
/* Match the values of enum ha_choice */
static const char *ha_choice_values[] = {"", "0", "1"};
static void store_key_options(THD *thd, String *packet, TABLE *table,
KEY *key_info);
......@@ -1428,11 +1425,6 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
if (share->db_create_options & HA_OPTION_CHECKSUM)
packet->append(STRING_WITH_LEN(" CHECKSUM=1"));
if (share->page_checksum != HA_CHOICE_UNDEF)
{
packet->append(STRING_WITH_LEN(" PAGE_CHECKSUM="));
packet->append(ha_choice_values[(uint) share->page_checksum], 1);
}
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
packet->append(STRING_WITH_LEN(" DELAY_KEY_WRITE=1"));
if (create_info.row_type != ROW_TYPE_DEFAULT)
......@@ -1440,11 +1432,6 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(" ROW_FORMAT="));
packet->append(ha_row_type[(uint) create_info.row_type]);
}
if (share->transactional != HA_CHOICE_UNDEF)
{
packet->append(STRING_WITH_LEN(" TRANSACTIONAL="));
packet->append(ha_choice_values[(uint) share->transactional], 1);
}
if (table->s->key_block_size)
{
char *end;
......@@ -3591,21 +3578,12 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
/* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
if (share->db_create_options & HA_OPTION_CHECKSUM)
ptr=strmov(ptr," checksum=1");
if (share->page_checksum != HA_CHOICE_UNDEF)
ptr= strxmov(ptr, " page_checksum=",
ha_choice_values[(uint) share->page_checksum], NullS);
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
ptr=strmov(ptr," delay_key_write=1");
if (share->row_type != ROW_TYPE_DEFAULT)
ptr=strxmov(ptr, " row_format=",
ha_row_type[(uint) share->row_type],
NullS);
if (share->transactional != HA_CHOICE_UNDEF)
{
ptr= strxmov(ptr, " TRANSACTIONAL=",
(share->transactional == HA_CHOICE_YES ? "1" : "0"),
NullS);
}
if (share->key_block_size)
{
ptr= strmov(ptr, " KEY_BLOCK_SIZE=");
......@@ -3615,9 +3593,6 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
if (is_partitioned)
ptr= strmov(ptr, " partitioned");
#endif
if (share->transactional != HA_CHOICE_UNDEF)
ptr= strxmov(ptr, " transactional=",
ha_choice_values[(uint) share->transactional], NullS);
table->field[19]->store(option_buff+1,
(ptr == option_buff ? 0 :
(uint) (ptr-option_buff)-1), cs);
......
......@@ -5928,8 +5928,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE))
create_info->key_block_size= table->s->key_block_size;
if (!(used_fields & HA_CREATE_USED_TRANSACTIONAL))
create_info->transactional= table->s->transactional;
if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
{
......
......@@ -889,7 +889,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token OWNER_SYM
%token PACK_KEYS_SYM
%token PAGE_SYM
%token PAGE_CHECKSUM_SYM
%token PARAM_MARKER
%token PARSER_SYM
%token PARTIAL /* SQL-2003-N */
......@@ -1048,7 +1047,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token TO_SYM /* SQL-2003-R */
%token TRAILING /* SQL-2003-R */
%token TRANSACTION_SYM
%token TRANSACTIONAL_SYM
%token TRIGGERS_SYM
%token TRIGGER_SYM /* SQL-2003-R */
%token TRIM /* SQL-2003-N */
......@@ -4208,6 +4206,10 @@ opt_sub_partition:
if (Lex->part_info->no_subparts != 0 &&
!Lex->part_info->use_default_subpartitions)
{
/*
We come here when we have defined subpartitions on the first
partition but not on all the subsequent partitions.
*/
my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR));
MYSQL_YYABORT;
}
......@@ -4250,6 +4252,23 @@ sub_part_definition:
partition_info *part_info= lex->part_info;
partition_element *curr_part= part_info->current_partition;
partition_element *sub_p_elem= new partition_element(curr_part);
if (part_info->use_default_subpartitions &&
part_info->partitions.elements >= 2)
{
/*
create table t1 (a int)
partition by list (a) subpartition by hash (a)
(partition p0 values in (1),
partition p1 values in (2) subpartition sp11);
causes use to arrive since we are on the second
partition, but still use_default_subpartitions
is set. When we come here we're processing at least
the second partition (the current partition processed
have already been put into the partitions list.
*/
my_parse_error(ER(ER_PARTITION_WRONG_NO_SUBPART_ERROR));
MYSQL_YYABORT;
}
if (!sub_p_elem ||
curr_part->subpartitions.push_back(sub_p_elem))
{
......@@ -4466,11 +4485,6 @@ create_table_option:
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
}
| PAGE_CHECKSUM_SYM opt_equal choice
{
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
Lex->create_info.page_checksum= $3;
}
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
{
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
......@@ -4530,11 +4544,6 @@ create_table_option:
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
Lex->create_info.key_block_size= $3;
}
| TRANSACTIONAL_SYM opt_equal choice
{
Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL;
Lex->create_info.transactional= $3;
}
;
default_charset:
......@@ -4616,7 +4625,6 @@ row_types:
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
;
merge_insert_types:
......@@ -11559,7 +11567,6 @@ keyword_sp:
| ONE_SYM {}
| PACK_KEYS_SYM {}
| PAGE_SYM {}
| PAGE_CHECKSUM_SYM {}
| PARTIAL {}
| PARTITIONING_SYM {}
| PARTITIONS_SYM {}
......@@ -11636,7 +11643,6 @@ keyword_sp:
| TEXT_SYM {}
| THAN_SYM {}
| TRANSACTION_SYM {}
| TRANSACTIONAL_SYM {}
| TRIGGERS_SYM {}
| TIMESTAMP {}
| TIMESTAMP_ADD {}
......
......@@ -724,8 +724,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (!head[32]) // New frm file in 3.23
{
share->avg_row_length= uint4korr(head+34);
share->transactional= (ha_choice) (head[39] & 3);
share->page_checksum= (ha_choice) ((head[39] >> 2) & 3);
share->row_type= (row_type) head[40];
share->table_charset= get_charset((uint) head[38],MYF(0));
share->null_field_first= 1;
......@@ -2492,8 +2490,11 @@ File create_frm(THD *thd, const char *name, const char *db,
int4store(fileinfo+34,create_info->avg_row_length);
fileinfo[38]= (create_info->default_table_charset ?
create_info->default_table_charset->number : 0);
fileinfo[39]= (uchar) ((uint) create_info->transactional |
((uint) create_info->page_checksum << 2));
/*
In future versions, we will store in fileinfo[39] the values of the
TRANSACTIONAL and PAGE_CHECKSUM clauses of CREATE TABLE.
*/
fileinfo[39]= 0;
fileinfo[40]= (uchar) create_info->row_type;
/* Next few bytes where for RAID support */
fileinfo[41]= 0;
......
......@@ -361,7 +361,9 @@ typedef struct st_table_share
}
enum row_type row_type; /* How rows are stored */
enum tmp_table_type tmp_table;
/** Transactional or not. Unused; reserved for future versions. */
enum ha_choice transactional;
/** Per-page checksums or not. Unused; reserved for future versions. */
enum ha_choice page_checksum;
uint ref_count; /* How many TABLE objects uses this */
......
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