diff options
author | dlenev@dlenev.mshome <> | 2003-11-23 00:48:18 +0300 |
---|---|---|
committer | dlenev@dlenev.mshome <> | 2003-11-23 00:48:18 +0300 |
commit | 625371f306fbbf87d6e2aad247c912d232d39665 (patch) | |
tree | 5cffe721a4aa43770cb11ce607fbae53c24ffb34 /sql/item.h | |
parent | ba659679e7816cd9c992c866645f65b06e5f69de (diff) | |
download | mariadb-git-625371f306fbbf87d6e2aad247c912d232d39665.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.
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('?'); } }; |