|
|
Choosing A Webhost: |
CVS update of libmysequoia/src (CarobMySQL.cpp Utils.cpp): msg#00171db.carob.cvs
Date: Wednesday, March 29, 2006 @ 13:00:43 Author: zsolt Path: /cvsroot/carob/libmysequoia/src Modified: CarobMySQL.cpp (1.67 -> 1.68) Utils.cpp (1.36 -> 1.37) - float / double formating at the prepared statements - modified alloc_row_data() to use prepared statements float/double conversion (see bug LMS-3) ----------------+ CarobMySQL.cpp | 20 ++++++++++++++++++-- Utils.cpp | 31 ++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 5 deletions(-) Index: libmysequoia/src/CarobMySQL.cpp diff -u libmysequoia/src/CarobMySQL.cpp:1.67 libmysequoia/src/CarobMySQL.cpp:1.68 --- libmysequoia/src/CarobMySQL.cpp:1.67 Tue Mar 28 14:25:11 2006 +++ libmysequoia/src/CarobMySQL.cpp Wed Mar 29 13:00:43 2006 @@ -904,8 +904,8 @@ /* TODO maybe we can change it, after carob implemented * date/time conversion functions correctly */ - //Set up a conversion buffer for time, date, datetime conversion - char buffer[20]; + //Set up a conversion buffer for time, date, datetime, float, double conversion + char buffer[400]; MYSQL_BIND b; memset(&b, 0, sizeof(b)); @@ -950,6 +950,22 @@ field_len = *b.length; break; } + case MYSQL_TYPE_FLOAT: + { + float f = drsPtr->getFloat(i+1); + getFromFloat(&b,fPtr,&f); + result += buffer; + field_len = strlen(buffer); + break; + } + case MYSQL_TYPE_DOUBLE: + { + double d = drsPtr->getDouble(i+1); + getFromDouble(&b,fPtr,&d); + result += buffer; + field_len = strlen(buffer); + break; + } default: if (fPtr->flags & BINARY_FLAG) { Index: libmysequoia/src/Utils.cpp diff -u libmysequoia/src/Utils.cpp:1.36 libmysequoia/src/Utils.cpp:1.37 --- libmysequoia/src/Utils.cpp:1.36 Fri Mar 24 10:02:40 2006 +++ libmysequoia/src/Utils.cpp Wed Mar 29 13:00:43 2006 @@ -37,6 +37,7 @@ #include <ctime> #include <sstream> #include <ctype.h> +#include <cfloat> using namespace CarobNS; using namespace std; @@ -643,8 +644,20 @@ case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: { - // TODO precision - int len = snprintf((char *)bind->buffer, bind->buffer_length, "%.*f", (int)field->decimals, f); + int len; + if (field->decimals >= 31) + { + len = sprintf((char *)bind->buffer, "%-*.*g", (int)bind->buffer_length, (int)min(14, FLT_DIG), f); + if (len > 0 && (unsigned)len < bind->buffer_length) + { + char *c = strchr((char *)bind->buffer, ' '); + *c = 0; + len = c - (char *)bind->buffer; + } + } + else + len = snprintf((char *)bind->buffer, bind->buffer_length, "%.*f", (int)field->decimals, f); + error = (len < 0) || ((unsigned int)len >= bind->buffer_length); break; } @@ -722,7 +735,19 @@ case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: { - int len = snprintf((char *)bind->buffer, bind->buffer_length, "%.*f", (int)field->decimals, d); + int len; + if (field->decimals >= 31) + { + len = snprintf((char *)bind->buffer, bind->buffer_length, "%-*.*g", (int)bind->buffer_length, (int)min(14, DBL_DIG), d); + if (len > 0 && (unsigned)len <= bind->buffer_length) + { + char *c = strchr((char *)bind->buffer, ' '); + *c = 0; + len = c - (char *)bind->buffer; + } + } + else + len = snprintf((char *)bind->buffer, bind->buffer_length, "%.*f", (int)field->decimals, d); error = (len < 0) || ((unsigned int)len >= bind->buffer_length); break; }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of odbsequoia/doc (INSTALL), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of libmysequoia/src (Utils.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of libmysequoia/src (CarobCommon.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of libmysequoia/src (Utils.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|