Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
29da7a1a
Commit
29da7a1a
authored
Jul 09, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16542 Fix ALTER TABLE FORCE to upgrade temporal types
parent
aa01f51b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
588 additions
and
5 deletions
+588
-5
mysql-test/main/type_temporal_mysql56_debug.result
mysql-test/main/type_temporal_mysql56_debug.result
+416
-0
mysql-test/main/type_temporal_mysql56_debug.test
mysql-test/main/type_temporal_mysql56_debug.test
+105
-0
sql/field.cc
sql/field.cc
+2
-5
sql/sql_show.cc
sql/sql_show.cc
+6
-0
sql/sql_type.cc
sql/sql_type.cc
+42
-0
sql/sql_type.h
sql/sql_type.h
+17
-0
No files found.
mysql-test/main/type_temporal_mysql56_debug.result
0 → 100644
View file @
29da7a1a
This diff is collapsed.
Click to expand it.
mysql-test/main/type_temporal_mysql56_debug.test
0 → 100644
View file @
29da7a1a
--
echo
#
--
echo
# Start of 10.4 tests
--
echo
#
--
echo
#
--
echo
# MDEV-16542 Fix ALTER TABLE FORCE to upgrade temporal types
--
echo
#
DELIMITER
$$
;
CREATE
PROCEDURE
mdev16542_create_select
()
BEGIN
SELECT
'# CREATE..SELECT and SHOW'
AS
``
;
CREATE
TABLE
t2
AS
SELECT
a0
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
COALESCE
(
a0
),
COALESCE
(
a1
),
COALESCE
(
a2
),
COALESCE
(
a3
),
COALESCE
(
a4
),
COALESCE
(
a5
),
COALESCE
(
a6
)
FROM
t1
;
SHOW
CREATE
TABLE
t2
;
DROP
TABLE
t2
;
END
;
$$
CREATE
PROCEDURE
mdev16542_alter_force_and_show
()
BEGIN
SELECT
'# ALTER..FORCE and SHOW'
AS
``
;
ALTER
TABLE
t1
FORCE
;
SHOW
CREATE
TABLE
t1
;
END
;
$$
CREATE
PROCEDURE
mdev16542
()
BEGIN
SET
SESSION
debug_dbug
=
"+d,sql_type"
;
SELECT
'# Original table'
AS
``
;
SHOW
CREATE
TABLE
t1
;
CALL
mdev16542_create_select
();
CALL
mdev16542_alter_force_and_show
();
SELECT
'# Setting @@global.mysql56_temporal_format=false'
AS
``
;
SET
@@
global
.
mysql56_temporal_format
=
false
;
CALL
mdev16542_create_select
();
CALL
mdev16542_alter_force_and_show
();
SELECT
'# Setting @@global.mysql56_temporal_format=true'
AS
``
;
SET
@@
global
.
mysql56_temporal_format
=
true
;
CALL
mdev16542_create_select
();
CALL
mdev16542_alter_force_and_show
();
SET
SESSION
debug_dbug
=
"-d,sql_type"
;
END
;
$$
DELIMITER
;
$$
SET
@@
global
.
mysql56_temporal_format
=
true
;
CREATE
TABLE
t1
(
a0
TIME
,
a1
TIME
(
1
),
a2
TIME
(
2
),
a3
TIME
(
3
),
a4
TIME
(
4
),
a5
TIME
(
5
),
a6
TIME
(
6
)
);
CALL
mdev16542
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a0
DATETIME
,
a1
DATETIME
(
1
),
a2
DATETIME
(
2
),
a3
DATETIME
(
3
),
a4
DATETIME
(
4
),
a5
DATETIME
(
5
),
a6
DATETIME
(
6
)
);
CALL
mdev16542
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a0
TIMESTAMP
,
a1
TIMESTAMP
(
1
),
a2
TIMESTAMP
(
2
),
a3
TIMESTAMP
(
3
),
a4
TIMESTAMP
(
4
),
a5
TIMESTAMP
(
5
),
a6
TIMESTAMP
(
6
)
);
CALL
mdev16542
;
DROP
TABLE
t1
;
SET
@@
global
.
mysql56_temporal_format
=
DEFAULT
;
DROP
PROCEDURE
mdev16542
;
DROP
PROCEDURE
mdev16542_create_select
;
DROP
PROCEDURE
mdev16542_alter_force_and_show
;
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
sql/field.cc
View file @
29da7a1a
...
...
@@ -10709,11 +10709,6 @@ Column_definition::Column_definition(THD *thd, Field *old_field,
key_length
/=
charset
->
mbmaxlen
;
break
;
case
MYSQL_TYPE_STRING
:
/* Change CHAR -> VARCHAR if dynamic record length */
if
(
old_field
->
type
()
==
MYSQL_TYPE_VAR_STRING
)
set_handler
(
&
type_handler_varchar
);
/* fall through */
case
MYSQL_TYPE_ENUM
:
case
MYSQL_TYPE_SET
:
case
MYSQL_TYPE_VARCHAR
:
...
...
@@ -10761,6 +10756,8 @@ Column_definition::Column_definition(THD *thd, Field *old_field,
char_length
=
(
uint
)
length
;
type_handler
()
->
Column_definition_implicit_upgrade
(
this
);
/*
Copy the default (constant/function) from the column object orig_field, if
supplied. We do this if all these conditions are met:
...
...
sql/sql_show.cc
View file @
29da7a1a
...
...
@@ -2184,6 +2184,12 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
field
->
sql_type
(
type
);
packet
->
append
(
type
.
ptr
(),
type
.
length
(),
system_charset_info
);
DBUG_EXECUTE_IF
(
"sql_type"
,
packet
->
append
(
" /* "
);
packet
->
append
(
field
->
type_handler
()
->
version
().
ptr
());
packet
->
append
(
" */ "
);
);
if
(
field
->
has_charset
()
&&
!
(
sql_mode
&
(
MODE_MYSQL323
|
MODE_MYSQL40
)))
{
if
(
field
->
charset
()
!=
share
->
table_charset
)
...
...
sql/sql_type.cc
View file @
29da7a1a
...
...
@@ -472,6 +472,11 @@ const Name
Type_handler_datetime_common
::
m_name_datetime
(
STRING_WITH_LEN
(
"datetime"
)),
Type_handler_timestamp_common
::
m_name_timestamp
(
STRING_WITH_LEN
(
"timestamp"
));
const
Name
Type_handler
::
m_version_default
(
STRING_WITH_LEN
(
""
)),
Type_handler
::
m_version_mariadb53
(
STRING_WITH_LEN
(
"mariadb-5.3"
)),
Type_handler
::
m_version_mysql56
(
STRING_WITH_LEN
(
"mysql-5.6"
));
const
Type_limits_int
Type_handler_tiny
::
m_limits_sint8
=
Type_limits_sint8
(),
...
...
@@ -6532,3 +6537,40 @@ bool Type_handler_decimal_result::Item_eq_value(THD *thd,
}
/***************************************************************************/
void
Type_handler_var_string
::
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
{
// Change old VARCHAR to new VARCHAR
c
->
set_handler
(
&
type_handler_varchar
);
}
void
Type_handler_time_common
::
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
{
if
(
opt_mysql56_temporal_format
)
c
->
set_handler
(
&
type_handler_time2
);
else
c
->
set_handler
(
&
type_handler_time
);
}
void
Type_handler_datetime_common
::
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
{
if
(
opt_mysql56_temporal_format
)
c
->
set_handler
(
&
type_handler_datetime2
);
else
c
->
set_handler
(
&
type_handler_datetime
);
}
void
Type_handler_timestamp_common
::
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
{
if
(
opt_mysql56_temporal_format
)
c
->
set_handler
(
&
type_handler_timestamp2
);
else
c
->
set_handler
(
&
type_handler_timestamp
);
}
sql/sql_type.h
View file @
29da7a1a
...
...
@@ -1031,6 +1031,9 @@ class Information_schema_character_attributes
class
Type_handler
{
protected:
static
const
Name
m_version_default
;
static
const
Name
m_version_mysql56
;
static
const
Name
m_version_mariadb53
;
String
*
print_item_value_csstr
(
THD
*
thd
,
Item
*
item
,
String
*
str
)
const
;
String
*
print_item_value_temporal
(
THD
*
thd
,
Item
*
item
,
String
*
str
,
const
Name
&
type_name
,
String
*
buf
)
const
;
...
...
@@ -1096,6 +1099,7 @@ class Type_handler
const
Type_handler
*
h2
);
virtual
const
Name
name
()
const
=
0
;
virtual
const
Name
version
()
const
{
return
m_version_default
;
}
virtual
enum_field_types
field_type
()
const
=
0
;
virtual
enum_field_types
real_field_type
()
const
{
return
field_type
();
}
/**
...
...
@@ -1253,6 +1257,9 @@ class Type_handler
virtual
Field
*
make_conversion_table_field
(
TABLE
*
TABLE
,
uint
metadata
,
const
Field
*
target
)
const
=
0
;
// Automatic upgrade, e.g. for ALTER TABLE t1 FORCE
virtual
void
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
{
}
virtual
bool
Column_definition_fix_attributes
(
Column_definition
*
c
)
const
=
0
;
virtual
bool
Column_definition_prepare_stage1
(
THD
*
thd
,
MEM_ROOT
*
mem_root
,
...
...
@@ -2878,6 +2885,7 @@ class Type_handler_time_common: public Type_handler_temporal_result
return
Item_divisor_precision_increment_with_seconds
(
item
);
}
const
Type_handler
*
type_handler_for_comparison
()
const
;
void
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
;
bool
Column_definition_fix_attributes
(
Column_definition
*
c
)
const
;
bool
Item_save_in_value
(
Item
*
item
,
st_value
*
value
)
const
;
bool
Item_send
(
Item
*
item
,
Protocol
*
protocol
,
st_value
*
buf
)
const
...
...
@@ -2923,6 +2931,7 @@ class Type_handler_time: public Type_handler_time_common
public:
static
uint
hires_bytes
(
uint
dec
)
{
return
m_hires_bytes
[
dec
];
}
virtual
~
Type_handler_time
()
{}
const
Name
version
()
const
{
return
m_version_mariadb53
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
const
Field
*
target
)
const
;
...
...
@@ -2948,6 +2957,7 @@ class Type_handler_time2: public Type_handler_time_common
{
public:
virtual
~
Type_handler_time2
()
{}
const
Name
version
()
const
{
return
m_version_mysql56
;
}
enum_field_types
real_field_type
()
const
{
return
MYSQL_TYPE_TIME2
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
...
...
@@ -3082,6 +3092,7 @@ class Type_handler_datetime_common: public Type_handler_temporal_with_date
}
Item
*
create_typecast_item
(
THD
*
thd
,
Item
*
item
,
const
Type_cast_attributes
&
attr
)
const
;
void
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
;
bool
Column_definition_fix_attributes
(
Column_definition
*
c
)
const
;
uint
Item_decimal_scale
(
const
Item
*
item
)
const
{
...
...
@@ -3115,6 +3126,7 @@ class Type_handler_datetime: public Type_handler_datetime_common
public:
static
uint
hires_bytes
(
uint
dec
)
{
return
m_hires_bytes
[
dec
];
}
virtual
~
Type_handler_datetime
()
{}
const
Name
version
()
const
{
return
m_version_mariadb53
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
const
Field
*
target
)
const
;
...
...
@@ -3140,6 +3152,7 @@ class Type_handler_datetime2: public Type_handler_datetime_common
{
public:
virtual
~
Type_handler_datetime2
()
{}
const
Name
version
()
const
{
return
m_version_mysql56
;
}
enum_field_types
real_field_type
()
const
{
return
MYSQL_TYPE_DATETIME2
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
...
...
@@ -3178,6 +3191,7 @@ class Type_handler_timestamp_common: public Type_handler_temporal_with_date
{
return
true
;
}
void
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
;
bool
Column_definition_fix_attributes
(
Column_definition
*
c
)
const
;
uint
Item_decimal_scale
(
const
Item
*
item
)
const
{
...
...
@@ -3211,6 +3225,7 @@ class Type_handler_timestamp: public Type_handler_timestamp_common
public:
static
uint
sec_part_bytes
(
uint
dec
)
{
return
m_sec_part_bytes
[
dec
];
}
virtual
~
Type_handler_timestamp
()
{}
const
Name
version
()
const
{
return
m_version_mariadb53
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
const
Field
*
target
)
const
;
...
...
@@ -3236,6 +3251,7 @@ class Type_handler_timestamp2: public Type_handler_timestamp_common
{
public:
virtual
~
Type_handler_timestamp2
()
{}
const
Name
version
()
const
{
return
m_version_mysql56
;
}
enum_field_types
real_field_type
()
const
{
return
MYSQL_TYPE_TIMESTAMP2
;
}
uint32
calc_pack_length
(
uint32
length
)
const
;
Field
*
make_conversion_table_field
(
TABLE
*
,
uint
metadata
,
...
...
@@ -3436,6 +3452,7 @@ class Type_handler_var_string: public Type_handler_string
{
return
varstring_type_handler
(
item
);
}
void
Column_definition_implicit_upgrade
(
Column_definition
*
c
)
const
;
bool
Column_definition_fix_attributes
(
Column_definition
*
c
)
const
;
bool
Column_definition_prepare_stage2
(
Column_definition
*
c
,
handler
*
file
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment