diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-03-24 18:03:44 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-03-24 18:03:44 +0300 |
commit | f10885675c5a01cec9c9905d9fc00be5266e8fcc (patch) | |
tree | 9f13d4fcc3ac732dc94fe2cae446f6f8c2b4e02b /libmysql/libmysql.c | |
parent | 41b6e42421e3baa2983833a138fb3f1303f263b5 (diff) | |
parent | c203c8daf87a7ca20eeb08b60174ea7c7f12f257 (diff) | |
download | mariadb-git-f10885675c5a01cec9c9905d9fc00be5266e8fcc.tar.gz |
Manual merge of mysql-trunk into mysql-trunk-merge.
Conflicts:
Text conflict in client/mysqlbinlog.cc
Text conflict in mysql-test/Makefile.am
Text conflict in mysql-test/collections/default.daily
Text conflict in mysql-test/r/mysqlbinlog_row_innodb.result
Text conflict in mysql-test/suite/rpl/r/rpl_typeconv_innodb.result
Text conflict in mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
Text conflict in mysql-test/suite/rpl/t/rpl_row_create_table.test
Text conflict in mysql-test/suite/rpl/t/rpl_slave_skip.test
Text conflict in mysql-test/suite/rpl/t/rpl_typeconv_innodb.test
Text conflict in mysys/charset.c
Text conflict in sql/field.cc
Text conflict in sql/field.h
Text conflict in sql/item.h
Text conflict in sql/item_func.cc
Text conflict in sql/log.cc
Text conflict in sql/log_event.cc
Text conflict in sql/log_event_old.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/rpl_utility.cc
Text conflict in sql/rpl_utility.h
Text conflict in sql/set_var.cc
Text conflict in sql/share/Makefile.am
Text conflict in sql/sql_delete.cc
Text conflict in sql/sql_plugin.cc
Text conflict in sql/sql_select.cc
Text conflict in sql/sql_table.cc
Text conflict in storage/example/ha_example.h
Text conflict in storage/federated/ha_federated.cc
Text conflict in storage/myisammrg/ha_myisammrg.cc
Text conflict in storage/myisammrg/myrg_open.c
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r-- | libmysql/libmysql.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 367789b949e..901fa1f0c4c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -559,7 +559,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) if ((*options->local_infile_init)(&li_ptr, net_filename, options->local_infile_userdata)) { - VOID(my_net_write(net,(const uchar*) "",0)); /* Server needs one packet */ + (void) my_net_write(net,(const uchar*) "",0); /* Server needs one packet */ net_flush(net); strmov(net->sqlstate, unknown_sqlstate); net->last_errno= @@ -3376,12 +3376,13 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, param output buffer descriptor field column metadata value column data - width default number of significant digits used when converting - float/double to string + type either MY_GCVT_ARG_FLOAT or MY_GCVT_ARG_DOUBLE. + Affects the maximum number of significant digits + returned by my_gcvt(). */ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, - double value, int width) + double value, my_gcvt_arg_type type) { char *buffer= (char *)param->buffer; double val64 = (value < 0 ? -floor(-value) : floor(value)); @@ -3465,42 +3466,24 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, floating point -> string conversion nicely, honor all typecodes and param->offset possibly set in mysql_stmt_fetch_column */ - char buff[MAX_DOUBLE_STRING_REP_LENGTH]; - char *end; - /* TODO: move this to a header shared between client and server. */ -#define NOT_FIXED_DEC 31 + char buff[FLOATING_POINT_BUFFER]; + size_t len; if (field->decimals >= NOT_FIXED_DEC) -#undef NOT_FIXED_DEC - { - /* - DBL_DIG below is to ensure that the server and client has the same - precisions. This will ensure that on the same machine you get the - same value as a string independent of the protocol you use. - */ - sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1, - param->buffer_length), - min(DBL_DIG, width), value); - end= strcend(buff, ' '); - *end= 0; - } + len= my_gcvt(value, type, + (int) min(sizeof(buff)-1, param->buffer_length), + buff, NULL); else - { - sprintf(buff, "%.*f", (int) field->decimals, value); - end= strend(buff); - } + len= my_fcvt(value, (int) field->decimals, buff, NULL); + if (field->flags & ZEROFILL_FLAG && len < field->length && + field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1) { - size_t length= end - buff; - if (field->flags & ZEROFILL_FLAG && length < field->length && - field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1) - { - bmove_upp((uchar*) buff + field->length, (uchar*) buff + length, - length); - bfill((char*) buff, field->length - length, '0'); - length= field->length; - } - fetch_string_with_conversion(param, buff, length); + bmove_upp((uchar*) buff + field->length, (uchar*) buff + len, + len); + bfill((char*) buff, field->length - len, '0'); + len= field->length; } + fetch_string_with_conversion(param, buff, len); break; } @@ -3545,7 +3528,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param, { ulonglong value= TIME_to_ulonglong(my_time); fetch_float_with_conversion(param, field, - ulonglong2double(value), DBL_DIG); + ulonglong2double(value), MY_GCVT_ARG_DOUBLE); break; } case MYSQL_TYPE_TINY: @@ -3639,7 +3622,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, { float value; float4get(value,*row); - fetch_float_with_conversion(param, field, value, FLT_DIG); + fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_FLOAT); *row+= 4; break; } @@ -3647,7 +3630,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, { double value; float8get(value,*row); - fetch_float_with_conversion(param, field, value, DBL_DIG); + fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_DOUBLE); *row+= 8; break; } |