Commit 60264b00 authored by Igor Babaev's avatar Igor Babaev

Fixed bug #610890.

The CREATE SHOW TABLE command misplaced virtual column specifiers:
the AS clause for a virtual column was put before optional
character set attributes, not after them as required by the syntax. 
parent 234e0014
......@@ -125,3 +125,11 @@ a p ROUND(a,p) ROUND(a,p+NULL)
1 0 1 NULL
0 NULL NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (a char(32), v char(32) CHARACTER SET ucs2 AS (a) VIRTUAL);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(32) DEFAULT NULL,
`v` char(32) CHARACTER SET ucs2 AS (a) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -128,3 +128,13 @@ INSERT INTO t1(p,a) VALUES (0,1);
INSERT INTO t1(p,a) VALUES (NULL,0);
SELECT a, p, ROUND(a,p), ROUND(a,p+NULL) FROM t1;
DROP TABLE t1;
#
# Bug#610890: SHOW CREATE TABLE with a virtual column
#
CREATE TABLE t1 (a char(32), v char(32) CHARACTER SET ucs2 AS (a) VIRTUAL);
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -1348,19 +1348,6 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
field->sql_type(type);
packet->append(type.ptr(), type.length(), system_charset_info);
if (field->vcol_info)
{
packet->append(STRING_WITH_LEN(" AS ("));
packet->append(field->vcol_info->expr_str.str,
field->vcol_info->expr_str.length,
system_charset_info);
packet->append(STRING_WITH_LEN(")"));
if (field->stored_in_db)
packet->append(STRING_WITH_LEN(" PERSISTENT"));
else
packet->append(STRING_WITH_LEN(" VIRTUAL"));
}
if (field->has_charset() &&
!(thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)))
{
......@@ -1380,6 +1367,19 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
}
}
if (field->vcol_info)
{
packet->append(STRING_WITH_LEN(" AS ("));
packet->append(field->vcol_info->expr_str.str,
field->vcol_info->expr_str.length,
system_charset_info);
packet->append(STRING_WITH_LEN(")"));
if (field->stored_in_db)
packet->append(STRING_WITH_LEN(" PERSISTENT"));
else
packet->append(STRING_WITH_LEN(" VIRTUAL"));
}
if (flags & NOT_NULL_FLAG)
packet->append(STRING_WITH_LEN(" NOT NULL"));
else if (field->type() == MYSQL_TYPE_TIMESTAMP)
......
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