mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
items for functions which is converted to constants internally to support its correct printing added (BUG#4663)
mysql-test/r/view.result: test of functions in VIEW which is converted to constants internally mysql-test/t/view.test: test of functions in VIEW which is converted to constants internally sql/item.h: items for functions which is converted to constants internally to support its correct printing sql/item_create.cc: items for functions which is converted to constants internally to support its correct printing
This commit is contained in:
parent
46a0c8a7df
commit
c688b7b882
4 changed files with 61 additions and 10 deletions
|
@ -1053,3 +1053,8 @@ create index i1 on v1 (col1);
|
|||
ERROR HY000: 'test.v1' is not BASIC TABLE
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
CREATE VIEW v1 (f1,f2,f3,f4) AS SELECT connection_id(), pi(), current_user(), version();
|
||||
SHOW CREATE VIEW v1;
|
||||
Table Create Table
|
||||
v1 CREATE VIEW test.v1 AS select sql_no_cache connection_id() AS `f1`,pi() AS `f2`,current_user() AS `f3`,version() AS `f4`
|
||||
drop view v1;
|
||||
|
|
|
@ -997,3 +997,10 @@ create view v1 as select * from t1;
|
|||
create index i1 on v1 (col1);
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# connection_id(), pi(), current_user(), version() representation test
|
||||
#
|
||||
CREATE VIEW v1 (f1,f2,f3,f4) AS SELECT connection_id(), pi(), current_user(), version();
|
||||
SHOW CREATE VIEW v1;
|
||||
drop view v1;
|
||||
|
|
37
sql/item.h
37
sql/item.h
|
@ -669,6 +669,17 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class Item_static_int_func :public Item_int
|
||||
{
|
||||
const char *func_name;
|
||||
public:
|
||||
Item_static_int_func(const char *str_arg, longlong i, uint length)
|
||||
:Item_int(NullS, i, length), func_name(str_arg)
|
||||
{}
|
||||
void print(String *str) { str->append(func_name); }
|
||||
};
|
||||
|
||||
|
||||
class Item_uint :public Item_int
|
||||
{
|
||||
public:
|
||||
|
@ -724,6 +735,18 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class Item_static_real_func :public Item_real
|
||||
{
|
||||
const char *func_name;
|
||||
public:
|
||||
Item_static_real_func(const char *str, double val_arg, uint decimal_par,
|
||||
uint length)
|
||||
:Item_real(NullS, val_arg, decimal_par, length), func_name(str)
|
||||
{}
|
||||
void print(String *str) { str->append(func_name); }
|
||||
};
|
||||
|
||||
|
||||
class Item_float :public Item_real
|
||||
{
|
||||
public:
|
||||
|
@ -803,6 +826,20 @@ public:
|
|||
void cleanup() {}
|
||||
};
|
||||
|
||||
|
||||
class Item_static_string_func :public Item_string
|
||||
{
|
||||
const char *func_name;
|
||||
public:
|
||||
Item_static_string_func(const char *name_par, const char *str, uint length,
|
||||
CHARSET_INFO *cs,
|
||||
Derivation dv= DERIVATION_COERCIBLE)
|
||||
:Item_string(NullS, str, length, cs, dv), func_name(name_par)
|
||||
{}
|
||||
void print(String *str) { str->append(func_name); }
|
||||
};
|
||||
|
||||
|
||||
/* for show tables */
|
||||
|
||||
class Item_datetime :public Item_string
|
||||
|
|
|
@ -73,12 +73,13 @@ Item *create_func_connection_id(void)
|
|||
{
|
||||
THD *thd=current_thd;
|
||||
thd->lex->safe_to_cache_query= 0;
|
||||
return new Item_int(NullS,(longlong)
|
||||
((thd->slave_thread) ?
|
||||
thd->variables.pseudo_thread_id :
|
||||
thd->thread_id),
|
||||
10);
|
||||
}
|
||||
return new Item_static_int_func("connection_id()",
|
||||
(longlong)
|
||||
((thd->slave_thread) ?
|
||||
thd->variables.pseudo_thread_id :
|
||||
thd->thread_id),
|
||||
10);
|
||||
}
|
||||
|
||||
Item *create_func_conv(Item* a, Item *b, Item *c)
|
||||
{
|
||||
|
@ -293,7 +294,7 @@ Item *create_func_period_diff(Item* a, Item *b)
|
|||
|
||||
Item *create_func_pi(void)
|
||||
{
|
||||
return new Item_real("pi()",M_PI,6,8);
|
||||
return new Item_static_real_func("pi()", M_PI, 6, 8);
|
||||
}
|
||||
|
||||
Item *create_func_pow(Item* a, Item *b)
|
||||
|
@ -309,8 +310,9 @@ Item *create_func_current_user()
|
|||
|
||||
length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) -
|
||||
buff);
|
||||
return new Item_string(NullS, thd->memdup(buff, length), length,
|
||||
system_charset_info);
|
||||
return new Item_static_string_func("current_user()",
|
||||
thd->memdup(buff, length), length,
|
||||
system_charset_info);
|
||||
}
|
||||
|
||||
Item *create_func_radians(Item *a)
|
||||
|
@ -434,7 +436,7 @@ Item *create_func_uuid(void)
|
|||
|
||||
Item *create_func_version(void)
|
||||
{
|
||||
return new Item_string(NullS,server_version,
|
||||
return new Item_static_string_func("version()", server_version,
|
||||
(uint) strlen(server_version),
|
||||
system_charset_info, DERIVATION_IMPLICIT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue