diff options
author | unknown <serg@serg.mylan> | 2004-08-19 03:02:09 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-08-19 03:02:09 +0200 |
commit | ae2bf6275e971f45cdfda8dada9a9bfd6f75e746 (patch) | |
tree | bb710739af8b8fd4ec8ff388deaf56c37a27d24a /sql | |
parent | 945625ebaa21468fdf0b2a3c1786fca50bdd5aa2 (diff) | |
download | mariadb-git-ae2bf6275e971f45cdfda8dada9a9bfd6f75e746.tar.gz |
after merge fixes
strings/my_vsnprintf.c:
%.#s support in my_vsnprintf
BitKeeper/etc/ignore:
Added EXCEPTIONS-CLIENT to the ignore list
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 29 | ||||
-rw-r--r-- | sql/field.h | 8 | ||||
-rw-r--r-- | sql/protocol.cc | 10 | ||||
-rw-r--r-- | sql/sql_string.h | 8 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
5 files changed, 25 insertions, 32 deletions
diff --git a/sql/field.cc b/sql/field.cc index 4458c14160d..caf4e22f4ca 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4268,24 +4268,21 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) Store double value in Field_string or Field_varstring. SYNOPSIS - store_double_in_string_field() - field field to store value in - field_length number of characters in the field + store(double nr) nr number DESCRIPTION Pretty prints double number into field_length characters buffer. */ -static int store_double_in_string_field(Field_str *field, uint32 field_length, - double nr) +int Field_str::store(double nr) { bool use_scientific_notation=TRUE; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; int length; - if (field_length < 32 && nr > 1) + if (field_length < 32 && nr > 1) // TODO: negative numbers { - if (field->ceiling == 0) + if (ceiling == 0) { static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 }; double p= 1; @@ -4294,23 +4291,17 @@ static int store_double_in_string_field(Field_str *field, uint32 field_length, if (field_length & j) p*= e[i]; } - field->ceiling= p-1; + ceiling= p-1; } - use_scientific_notation= (field->ceiling < nr); + use_scientific_notation= (ceiling < nr); } length= sprintf(buff, "%-.*g", use_scientific_notation ? max(0,field_length-5) : field_length, nr); DBUG_ASSERT(length <= field_length); - return field->store(buff, (uint) length); + return store((const char *)buff, (uint) length, charset()); } -int Field_string::store(double nr) - { - return store_double_in_string_field(this, field_length, nr); -} - - int Field_string::store(longlong nr) { char buff[64]; @@ -4479,12 +4470,6 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) } -int Field_varstring::store(double nr) -{ - return store_double_in_string_field(this, field_length, nr); -} - - int Field_varstring::store(longlong nr) { char buff[64]; diff --git a/sql/field.h b/sql/field.h index 694d1efa285..fe06cd96f1a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -336,21 +336,23 @@ public: class Field_str :public Field { protected: CHARSET_INFO *field_charset; -public: double ceiling; // for ::store(double nr) +public: Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg,CHARSET_INFO *charset) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, table_arg), ceiling(0.0) - { + { field_charset=charset; if (charset->state & MY_CS_BINSORT) flags|=BINARY_FLAG; } Item_result result_type () const { return STRING_RESULT; } uint decimals() const { return NOT_FIXED_DEC; } + int store(double nr); + int store(const char *to,uint length,CHARSET_INFO *cs)=0; void make_field(Send_field *); uint size_of() const { return sizeof(*this); } CHARSET_INFO *charset(void) const { return field_charset; } @@ -905,7 +907,6 @@ public: bool zero_pack() const { return 0; } void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); } int store(const char *to,uint length,CHARSET_INFO *charset); - int store(double nr); int store(longlong nr); double val_real(void); longlong val_int(void); @@ -951,7 +952,6 @@ public: uint32 pack_length() const { return (uint32) field_length+2; } uint32 key_length() const { return (uint32) field_length; } int store(const char *to,uint length,CHARSET_INFO *charset); - int store(double nr); int store(longlong nr); double val_real(void); longlong val_int(void); diff --git a/sql/protocol.cc b/sql/protocol.cc index 2812a92497f..7c4b09ac3e3 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -200,13 +200,13 @@ net_printf(THD *thd, uint errcode, ...) 2+SQLSTATE_LENGTH+1 : 2) : 0); #ifndef EMBEDDED_LIBRARY text_pos=(char*) net->buff + head_length + offset + 1; + length=(char*)net->buff_end-text_pos; +#else + length=sizeof(text_pos)-1; #endif - (void) my_vsnprintf(my_const_cast(char*) (text_pos), - (char*)net->buff_end-text_pos, + length=my_vsnprintf(my_const_cast(char*) (text_pos), + min(length, sizeof(net->last_error)), format,args); - length=(uint) strlen((char*) text_pos); - if (length >= sizeof(net->last_error)) - length=sizeof(net->last_error)-1; /* purecov: inspected */ va_end(args); #ifndef EMBEDDED_LIBRARY diff --git a/sql/sql_string.h b/sql/sql_string.h index 0179b3ebadc..d8c4c3a87a1 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -95,6 +95,14 @@ public: Ptr[str_length]=0; return Ptr; } + inline char *c_ptr_safe() + { + if (Ptr && str_length < Alloced_length) + Ptr[str_length]=0; + else + (void) realloc(str_length); + return Ptr; + } void set(String &str,uint32 offset,uint32 arg_length) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index be3ac10c398..1b091c26a6d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1936,7 +1936,7 @@ alter_list_item: if (check_table_name($3->table.str,$3->table.length) || $3->db.str && check_db_name($3->db.str)) { - net_printf(&lex->thd->net,ER_WRONG_TABLE_NAME,$3->table.str); + net_printf(lex->thd,ER_WRONG_TABLE_NAME,$3->table.str); YYABORT; } lex->alter_info.flags|= ALTER_RENAME; |