mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
type of parameter assignment for parameters from variables added (BUG#4280)
mysql-test/r/ps.result: parameters from variables (for field creation) mysql-test/t/ps.test: parameters from variables (for field creation) sql/item.cc: type of parameter assignment for parameters from variables sql/item.h: removed spaces at line ends in Item_param definition
This commit is contained in:
parent
d1e4305187
commit
ef0b6f0703
4 changed files with 42 additions and 10 deletions
|
@ -137,3 +137,17 @@ execute stmt1;
|
|||
FOUND_ROWS()
|
||||
0
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
set @arg00=1;
|
||||
prepare stmt1 from ' create table t1 (m int) as select 1 as m ' ;
|
||||
execute stmt1 ;
|
||||
select m from t1;
|
||||
m
|
||||
1
|
||||
drop table t1;
|
||||
prepare stmt1 from ' create table t1 (m int) as select ? as m ' ;
|
||||
execute stmt1 using @arg00;
|
||||
select m from t1;
|
||||
m
|
||||
1
|
||||
drop table t1;
|
||||
|
|
|
@ -140,3 +140,17 @@ execute stmt1;
|
|||
# Expect 0
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# parameters from variables (for field creation)
|
||||
#
|
||||
set @arg00=1;
|
||||
prepare stmt1 from ' create table t1 (m int) as select 1 as m ' ;
|
||||
execute stmt1 ;
|
||||
select m from t1;
|
||||
drop table t1;
|
||||
prepare stmt1 from ' create table t1 (m int) as select ? as m ' ;
|
||||
execute stmt1 using @arg00;
|
||||
select m from t1;
|
||||
drop table t1;
|
||||
|
|
|
@ -759,9 +759,13 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
|
|||
switch (entry->type) {
|
||||
case REAL_RESULT:
|
||||
set_double(*(double*)entry->value);
|
||||
item_type= Item::REAL_ITEM;
|
||||
item_result_type= REAL_RESULT;
|
||||
break;
|
||||
case INT_RESULT:
|
||||
set_int(*(longlong*)entry->value, 21);
|
||||
item_type= Item::INT_ITEM;
|
||||
item_result_type= INT_RESULT;
|
||||
break;
|
||||
case STRING_RESULT:
|
||||
{
|
||||
|
|
20
sql/item.h
20
sql/item.h
|
@ -422,7 +422,7 @@ public:
|
|||
|
||||
class Item_param :public Item
|
||||
{
|
||||
public:
|
||||
public:
|
||||
enum enum_item_param_state
|
||||
{
|
||||
NO_VALUE, NULL_VALUE, INT_VALUE, REAL_VALUE,
|
||||
|
@ -442,8 +442,8 @@ public:
|
|||
String str_value_ptr;
|
||||
union
|
||||
{
|
||||
longlong integer;
|
||||
double real;
|
||||
longlong integer;
|
||||
double real;
|
||||
/*
|
||||
Character sets conversion info for string values.
|
||||
Character sets of client and connection defined at bind time are used
|
||||
|
@ -456,7 +456,7 @@ public:
|
|||
/*
|
||||
This points at character set of connection if conversion
|
||||
to it is required (i. e. if placeholder typecode is not BLOB).
|
||||
Otherwise it's equal to character_set_client (to simplify
|
||||
Otherwise it's equal to character_set_client (to simplify
|
||||
check in convert_str_value()).
|
||||
*/
|
||||
CHARSET_INFO *final_character_set_of_str_value;
|
||||
|
@ -477,10 +477,10 @@ public:
|
|||
supply for this placeholder in mysql_stmt_execute.
|
||||
*/
|
||||
enum enum_field_types param_type;
|
||||
/*
|
||||
/*
|
||||
Offset of placeholder inside statement text. Used to create
|
||||
no-placeholders version of this statement for the binary log.
|
||||
*/
|
||||
*/
|
||||
uint pos_in_query;
|
||||
|
||||
Item_param(uint pos_in_query_arg);
|
||||
|
@ -515,11 +515,11 @@ public:
|
|||
const String *query_val_str(String *str) const;
|
||||
|
||||
bool convert_str_value(THD *thd);
|
||||
|
||||
|
||||
Item *new_item() { return new Item_param(pos_in_query); }
|
||||
/*
|
||||
If value for parameter was not set we treat it as non-const
|
||||
so noone will use parameters value in fix_fields still
|
||||
/*
|
||||
If value for parameter was not set we treat it as non-const
|
||||
so noone will use parameters value in fix_fields still
|
||||
parameter is constant during execution.
|
||||
*/
|
||||
virtual table_map used_tables() const
|
||||
|
|
Loading…
Add table
Reference in a new issue