diff options
author | unknown <dlenev@dlenev.mshome> | 2003-11-23 00:48:18 +0300 |
---|---|---|
committer | unknown <dlenev@dlenev.mshome> | 2003-11-23 00:48:18 +0300 |
commit | 00ddd4e56a90f04f7c2b515ff26b7ab0af08d599 (patch) | |
tree | 5cffe721a4aa43770cb11ce607fbae53c24ffb34 /sql/item.h | |
parent | f25cbdd9141004e6e9f0a7313d763c1cc1de36ec (diff) | |
download | mariadb-git-00ddd4e56a90f04f7c2b515ff26b7ab0af08d599.tar.gz |
Fix for bug #1500 "Server crash with mysql_prepare"
We treat Item_param whose value is not set as non-const.
This allows us to avoid use of Item_param's value (not yet existing) in
those fix_fields and fix_length_and_dec that do calculations if their
Items arguments are const. So we can call fix_fields for such items from
mysql_prepare safely.
sql/item.cc:
Now Item_param is non-constant (const_item()==FALSE) until its value is set.
sql/item.h:
Added Item::const_during_execution() method which indicates constants that will be known
during execution phase (but they may be not known during preparing phase for example parameters
of prep. statements.)
Made Item_param non-constant until its is value set, so its value won't be requested during
prepare statement step.
sql/item_func.cc:
Fulltext search AGAINST clause now allows prepared statement parameter as its argument.
Removed duplicate used_tables_cache update in Item_func_match::fix_fields()
(it is set during Item_func::fix_fields).
tests/client_test.c:
Added test for bug #1500 "Server crash with mysql_prepare"
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h index 8b35705f191..1e62e863ab7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -173,7 +173,17 @@ public: virtual cond_result eq_cmp_result() const { return COND_OK; } inline uint float_length(uint decimals_par) const { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} + /* + Returns true if this is constant (during query execution, i.e. its value + will not change until next fix_fields) and its value is known. + */ virtual bool const_item() const { return used_tables() == 0; } + /* + Returns true if this is constant but its value may be not known yet. + (Can be used for parameters of prep. stmts or of stored procedures.) + */ + virtual bool const_during_execution() const + { return (used_tables() & ~PARAM_TABLE_BIT) == 0; } virtual void print(String *str_arg) { str_arg->append(full_name()); } void print_item_w_name(String *); virtual void update_used_tables() {} @@ -318,6 +328,7 @@ public: class Item_param :public Item { public: + bool value_is_set; longlong int_value; double real_value; TIME ltime; @@ -336,6 +347,7 @@ public: item_result_type = STRING_RESULT; item_is_time= false; long_data_supplied= false; + value_is_set= 0; } enum Type type() const { return item_type; } double val(); @@ -363,6 +375,13 @@ public: String *query_val_str(String *str); enum_field_types field_type() const { return MYSQL_TYPE_STRING; } 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 + parameter is constant during execution. + */ + virtual table_map used_tables() const + { return value_is_set ? (table_map)0 : PARAM_TABLE_BIT; } void print(String *str) { str->append('?'); } }; |