Commit 51a70748 authored by unknown's avatar unknown

MDEV-4292 fix.

Fixed printing column_get finction.
parent 2b89b0a2
This diff is collapsed.
...@@ -546,3 +546,60 @@ select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0)))); ...@@ -546,3 +546,60 @@ select hex(COLUMN_CREATE(0, COLUMN_GET(@a, 9 AS DECIMAL(19,0))));
select hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal))); select hex(COLUMN_CREATE(0, COLUMN_GET(COLUMN_CREATE(0, 0.0 as decimal), 0 as decimal)));
select hex(COLUMN_CREATE(0, 0.0 as decimal)); select hex(COLUMN_CREATE(0, 0.0 as decimal));
--echo #
--echo # MDEV-4292: parse error when selecting on views using dynamic column
--echo #
create table t1 (i int, d blob);
create view v1 as select i, column_get(d, 1 as binary) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as int) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as unsigned int) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as date) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as time) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as datetime) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as decimal) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as double) as a from t1;
select * from v1;
show create view v1;
drop view v1;
create view v1 as select i, column_get(d, 1 as char) as a from t1;
select * from v1;
show create view v1;
drop view v1;
drop table t1;
--echo #
--echo # end of 5.3 tests
--echo #
...@@ -4246,11 +4246,16 @@ null: ...@@ -4246,11 +4246,16 @@ null:
void Item_dyncol_get::print(String *str, enum_query_type query_type) void Item_dyncol_get::print(String *str, enum_query_type query_type)
{ {
/* see create_func_dyncol_get */
DBUG_ASSERT(str->length() >= 5);
DBUG_ASSERT(strncmp(str->ptr() + str->length() - 5, "cast(", 5) == 0);
str->length(str->length() - 5); // removing "cast("
str->append(STRING_WITH_LEN("column_get(")); str->append(STRING_WITH_LEN("column_get("));
args[0]->print(str, query_type); args[0]->print(str, query_type);
str->append(','); str->append(',');
args[1]->print(str, query_type); args[1]->print(str, query_type);
str->append(')'); /* let the parent cast item add " as <type>)" */
} }
......
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