From a96ffb29258a80f8dfaa11f336d0edaa23ad6cf6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 15:13:19 +0300 Subject: Fix for bugs #1885, #2464, #2539. Proper handling of default values for TIMESTAMP columns. The solution is not perfect since we just silently ignoring default value for first TIMESTAMP column and properly reflecting this fact in SHOW CREATE TABLE. We can't give a warning or simply support standard syntax (niladic functions as legal value for default) for first field since it is 4.0 tree. mysql-test/r/type_timestamp.result: Added test for bugs #1885, #2464, #2539 (proper support of default values for TIMESTAMP columns) mysql-test/t/type_timestamp.test: Added test for bugs #1885, #2464, #2539 (proper support of default values for TIMESTAMP columns) sql/field.cc: Enabled copying of defaults for TIMESTAMP fields when we are creating table with CREATE TABLE x (SELECT ...) sql/field.h: Set proper DEFAULT value for non-first TIMESTAMP column. sql/sql_parse.cc: Allowed default values for TIMESTAMP column. sql/sql_show.cc: Enabled printing of default values in SHOW CREATE TABLE and SHOW COLUMNS for all TIMESTAMP columns except first one. --- sql/field.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 8bcbf8ecc56..687c22bb69b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5124,8 +5124,7 @@ create_field::create_field(Field *old_field,Field *orig_field) interval=0; def=0; if (!old_field->is_real_null() && ! (flags & BLOB_FLAG) && - old_field->type() != FIELD_TYPE_TIMESTAMP && old_field->ptr && - orig_field) + old_field->ptr && orig_field) { char buff[MAX_FIELD_WIDTH],*pos; String tmp(buff,sizeof(buff)); -- cgit v1.2.1 From ef55f2dcdbc79c78aa37e6646ac2aef62c23e7d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 19:15:11 +0300 Subject: Fix for bug #2523 '"func_time" test fails on QNX'. Moved all range checks for TIMESTAMP value to my_gmt_sec(). Also fixed check of upper boundary of TIMESTAMP range (which also now will catch datetime values which are too small for TIMESTAMP in case if time_t is unsigned). mysql-test/r/timezone.result: Added test which checks if TIMESTAMP range is checked correctly (current time zone is honoured and both upper and lower bounds of TIMESTAMP range are checked). mysql-test/t/timezone.test: Added test which checks if TIMESTAMP range is checked correctly (current time zone is honoured and both upper and lower bounds of TIMESTAMP range are checked). sql/field.cc: Check if datetime value is in TIMESTAMP range has moved to my_gmt_sec() function. sql/mysql_priv.h: Added more constants for checking if datetime is in allowed range for TIMESTAMP. sql/time.cc: Check if datetime value is in TIMESTAMP range has moved to my_gmt_sec() function. Fixed check of its return value to catch overflows in both directions and also overflows in case of unsigned time_t. --- sql/field.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 687c22bb69b..ac3ebb4bfc7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2583,22 +2583,18 @@ static longlong fix_datetime(longlong nr, TIME *time_res) void Field_timestamp::store(longlong nr) { TIME l_time; - time_t timestamp; + time_t timestamp= 0; if ((nr= fix_datetime(nr, &l_time))) { long not_used; - if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR-1) - { + timestamp= my_gmt_sec(&l_time, ¬_used); + + if (!timestamp) current_thd->cuted_fields++; - timestamp=0; - } - else - timestamp=my_gmt_sec(&l_time, ¬_used); } - else - timestamp=0; + #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { -- cgit v1.2.1 From 709356d47343af2951cdcd02419c71fc49c35f85 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Feb 2004 01:35:17 +0200 Subject: Changed wellformedlen to well_formed_len Fixed that blobs >16M can be inserted/updated Fixed bug when doing CREATE TEMPORARY TABLE ... LIKE include/m_ctype.h: Changed wellformedlen to well_formed_len include/mysql.h: Fixed comment libmysql/libmysql.c: Fixed indentation libmysqld/lib_sql.cc: Fixed indentation mysql-test/r/ctype_utf8.result: updated warning numbers mysql-test/r/innodb.result: Moved test to right place mysql-test/r/myisam-blob.result: More test for blobs mysql-test/r/rpl000002.result: Move test to better place mysql-test/r/rpl_log.result: Move test to better place mysql-test/r/union.result: Move test to better place mysql-test/t/innodb.test: Moved test to right place mysql-test/t/myisam-blob.test: More test of blobs mysql-test/t/rpl000002.test: Move test to better place mysql-test/t/rpl_log.test: Move test to better place mysql-test/t/union.test: Move test to better place sql/field.cc: Changed wellformedlen to well_formed_len. Fixed that blobs >16M can be inserted/updated (new bug) sql/field.h: Code optimization sql/sql_lex.cc: Changed short variable names sql/sql_show.cc: Optimized quote handling sql/sql_table.cc: Fixed bug when doing CREATE TEMPORARY TABLE ... LIKE sql/sql_union.cc: Added comment strings/ctype-big5.c: Changed wellformedlen to well_formed_len strings/ctype-bin.c: Changed wellformedlen to well_formed_len strings/ctype-euc_kr.c: Changed wellformedlen to well_formed_len strings/ctype-gb2312.c: Changed wellformedlen to well_formed_len strings/ctype-gbk.c: Changed wellformedlen to well_formed_len strings/ctype-latin1.c: Changed wellformedlen to well_formed_len strings/ctype-mb.c: Changed wellformedlen to well_formed_len strings/ctype-simple.c: Changed wellformedlen to well_formed_len strings/ctype-sjis.c: Changed wellformedlen to well_formed_len strings/ctype-tis620.c: Changed wellformedlen to well_formed_len strings/ctype-ucs2.c: Changed wellformedlen to well_formed_len Indentation changes strings/ctype-ujis.c: Changed wellformedlen to well_formed_len strings/ctype-utf8.c: Changed wellformedlen to well_formed_len --- sql/field.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 1e926c0926e..4632fbc5c69 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4075,10 +4075,10 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) Make sure we don't break a multibyte sequence as well as don't copy a malformed data. */ - copy_length= field_charset->cset->wellformedlen(field_charset, - from,from+length, - field_length/ - field_charset->mbmaxlen); + copy_length= field_charset->cset->well_formed_len(field_charset, + from,from+length, + field_length/ + field_charset->mbmaxlen); memcpy(ptr,from,copy_length); if (copy_length < field_length) // Append spaces if shorter field_charset->cset->fill(field_charset,ptr+copy_length, @@ -4571,11 +4571,15 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) } copy_length= max_data_length(); - if (copy_length > length) - copy_length= length; - copy_length= field_charset->cset->wellformedlen(field_charset, - from,from+copy_length, - field_length); + /* + copy_length is ok as last argument to well_formed_len as this is never + used to limit the length of the data. The cut of long data is done with + the 'min()' call below. + */ + copy_length= field_charset->cset->well_formed_len(field_charset, + from,from + + min(length, copy_length), + copy_length); if (copy_length < length) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); -- cgit v1.2.1 From afa6728a9f7c00582b3dc9e96b2dce5c4ac1e56c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Mar 2004 08:50:37 +0200 Subject: Optimized GIS functions heap/hp_delete.c: Added comments mysql-test/r/gis.result: Updated results after name changes (all results line are unchanged) mysql-test/r/show_check.result: Update test results after fix in hp_delete.cc mysql-test/t/gis.test: Changed table names to longer, hopefully non conflicting ones. Added missing drop table mysys/hash.c: Inendation cleanup mysys/tree.c: Updated comments Decrease tree->allocated on delete (for status) sql/field.cc: Added safety checking for GIS objects sql/gstream.cc: Added copyright message Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/gstream.h: Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/item_create.cc: Indentation fixup sql/item_geofunc.cc: Use new gis interface functions and new gis class names. Simple optimizations Indentation fixups Fixed a lot of unlikely but possible errors. sql/item_geofunc.h: Moved SRID_SIZE to spatial.h sql/spatial.cc: Added copyright message Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/spatial.h: Made a lot of speed/space optimizations Changed class names to be MySQL compliant Indentation fixes Use bool instead of int as result type for functions that only return 0 or 1 sql/sql_string.cc: Simple optimizations sql/sql_string.h: Simple cleanups sql/structs.h: Added LEX_STRING_WITH_INIT (needed by spatial.cc) --- sql/field.cc | 70 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 24 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 4632fbc5c69..48e7dbb32ca 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4715,18 +4715,26 @@ void Field_blob::get_key_image(char *buff,uint length, #ifdef HAVE_SPATIAL if (type == itMBR) { - if (!blob_length) - return; - get_ptr(&blob); - + const char *dummy; MBR mbr; Geometry gobj; + + if (blob_length < SRID_SIZE) + { + bzero(buff, SIZEOF_STORED_DOUBLE*4); + return; + } + get_ptr(&blob); gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); - gobj.get_mbr(&mbr); - float8store(buff, mbr.xmin); - float8store(buff+8, mbr.xmax); - float8store(buff+16, mbr.ymin); - float8store(buff+24, mbr.ymax); + if (gobj.get_mbr(&mbr, &dummy)) + bzero(buff, SIZEOF_STORED_DOUBLE*4); + else + { + float8store(buff, mbr.xmin); + float8store(buff+8, mbr.xmax); + float8store(buff+16, mbr.ymin); + float8store(buff+24, mbr.ymax); + } return; } #endif /*HAVE_SPATIAL*/ @@ -4939,6 +4947,7 @@ uint Field_blob::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } + #ifdef HAVE_SPATIAL void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, @@ -4947,17 +4956,26 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, length-= HA_KEY_BLOB_LENGTH; ulong blob_length= get_length(ptr); char *blob; - get_ptr(&blob); - + const char *dummy; MBR mbr; + + if (blob_length < SRID_SIZE) + { + bzero(buff, SIZEOF_STORED_DOUBLE*4); + return; + } + get_ptr(&blob); Geometry gobj; gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); - gobj.get_mbr(&mbr); - float8store(buff, mbr.xmin); - float8store(buff + 8, mbr.xmax); - float8store(buff + 16, mbr.ymin); - float8store(buff + 24, mbr.ymax); - return; + if (gobj.get_mbr(&mbr, &dummy)) + bzero(buff, SIZEOF_STORED_DOUBLE*4); + else + { + float8store(buff, mbr.xmin); + float8store(buff + 8, mbr.xmax); + float8store(buff + 16, mbr.ymin); + float8store(buff + 24, mbr.ymax); + } } @@ -5001,16 +5019,16 @@ void Field_geom::sql_type(String &res) const int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) { if (!length) - { bzero(ptr, Field_blob::pack_length()); - } else { - // Should check given WKB - if (length < 4 + 1 + 4 + 8 + 8) // SRID + WKB_HEADER + X + Y - return 1; - uint32 wkb_type= uint4korr(from + 5); - if (wkb_type < 1 || wkb_type > 7) + // Check given WKB + uint32 wkb_type; + if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2) + goto err; + wkb_type= uint4korr(from + WKB_HEADER_SIZE); + if (wkb_type < (uint32) Geometry::wkbPoint || + wkb_type > (uint32) Geometry::wkb_end) return 1; Field_blob::store_length(length); if (table->copy_blobs || length <= MAX_FIELD_WIDTH) @@ -5021,6 +5039,10 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) bmove(ptr + packlength, (char*) &from, sizeof(char*)); } return 0; + +err: + bzero(ptr, Field_blob::pack_length()); + return 1; } #endif /*HAVE_SPATIAL*/ -- cgit v1.2.1 From c8bfc2324b14584f39dd271fa0dd34b0f181d167 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Mar 2004 21:08:14 +0400 Subject: Fixed bug #2082 'mysqldump converts "inf" to NULL' and added commands vertical_results and horisontal_results to client/mysqltest.c client/mysqltest.c: added commands vertical_results and horisontal_results mysql-test/r/insert.result: added test for bug #2082 'mysqldump converts "inf" to NULL' mysql-test/t/insert.test: Fixed bug #2082 'mysqldump converts "inf" to NULL' sql/field.cc: added test for Fixed bug #2082 'mysqldump converts "inf" to NULL' --- sql/field.cc | 114 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 40 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 4632fbc5c69..a2771dc67e3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2271,13 +2271,18 @@ void Field_longlong::sql_type(String &res) const int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) { int err; - Field_float::store(my_strntod(cs,(char*) from,len,(char**)NULL,&err)); - if (err || current_thd->count_cuted_fields && !test_if_real(from,len,cs)) + char *end; + double nr= my_strntod(cs,(char*) from,len,&end,&err); + if (!err && (!current_thd->count_cuted_fields || end-from==len)) + { + return Field_float::store(nr); + } + else { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); + Field_float::store(nr); return 1; } - return (err) ? 1 : 0; } @@ -2285,28 +2290,41 @@ int Field_float::store(double nr) { float j; int error= 0; - if (dec < NOT_FIXED_DEC) - nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point - if (unsigned_flag && nr < 0) - { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); - nr=0; - error= 1; - } - if (nr < -FLT_MAX) + + if (isnan(nr) || unsigned_flag && nr < 0) { - j= -FLT_MAX; + j= 0; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); error= 1; } - else if (nr > FLT_MAX) + else { - j=FLT_MAX; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); - error= 1; + double max_value; + if (dec >= NOT_FIXED_DEC) + { + max_value= FLT_MAX; + } + else + { + max_value= (log_10[field_length]-1)/log_10[dec]; + nr= floor(nr*log_10[dec]+0.5)/log_10[dec]; + } + if (nr < -max_value) + { + j= (float)-max_value; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + else if (nr > max_value) + { + j= (float)max_value; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + else + j= (float) nr; } - else - j= (float) nr; + #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { @@ -2544,41 +2562,57 @@ void Field_float::sql_type(String &res) const int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) { int err; - double j= my_strntod(cs,(char*) from,len,(char**)0,&err); - if (err || current_thd->count_cuted_fields && !test_if_real(from,len,cs)) - { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); - err= 1; - } - if (unsigned_flag && j < 0) + char *end; + double nr= my_strntod(cs,(char*) from,len,&end,&err); + if (!err && (!current_thd->count_cuted_fields || end-from==len)) { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); - j=0; - err= 1; + return Field_double::store(nr); } -#ifdef WORDS_BIGENDIAN - if (table->db_low_byte_first) + else { - float8store(ptr,j); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); + Field_double::store(nr); + return 1; } - else -#endif - doublestore(ptr,j); - return err; } int Field_double::store(double nr) { int error= 0; - if (dec < NOT_FIXED_DEC) - nr=floor(nr*log_10[dec]+0.5)/log_10[dec]; // To fixed point - if (unsigned_flag && nr < 0) + + if (isnan(nr) || unsigned_flag && nr < 0) { + nr= 0; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); - nr=0; error= 1; } + else + { + double max_value; + if (dec >= NOT_FIXED_DEC) + { + max_value= DBL_MAX; + } + else + { + max_value= (log_10[field_length]-1)/log_10[dec]; + nr= floor(nr*log_10[dec]+0.5)/log_10[dec]; + } + if (nr < -max_value) + { + nr= -max_value; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + else if (nr > max_value) + { + nr= max_value; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + } + #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { -- cgit v1.2.1 From 17c4d7f36182e58047231472dbeb1a9f2af60560 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Mar 2004 03:00:21 +0400 Subject: - added commands --query_vertical and --query_horisontal to client/mysqltest.cc - get my_strtod to return inf - get Field_float::store(double) and Field_double::store(float) to set null for nan value (as extra serg's recomendations to fix for patch on Bug #2082 'mysqldump converts "inf" to null') client/mysqltest.c: added commands --query_vertical and --query_horisontal mysql-test/r/insert.result: converted testcase so as my_strtod can return inf now mysql-test/r/mysqldump.result: converted testcase so as my_strtod can return inf now mysql-test/t/insert.test: corrected tests to using --query_vertical instead of pair (vertical_results,horisontal_results) sql/field.cc: corrected Field_float::store(double) and Field_double::store(double) to set null for nan value strings/strtod.c: get my_strtod to return inf --- sql/field.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index a2771dc67e3..32d7149ce63 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2291,7 +2291,14 @@ int Field_float::store(double nr) float j; int error= 0; - if (isnan(nr) || unsigned_flag && nr < 0) + if (isnan(nr)) + { + j= 0; + set_null(); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + else if (unsigned_flag && nr < 0) { j= 0; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); @@ -2581,7 +2588,14 @@ int Field_double::store(double nr) { int error= 0; - if (isnan(nr) || unsigned_flag && nr < 0) + if (isnan(nr)) + { + nr= 0; + set_null(); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); + error= 1; + } + else if (unsigned_flag && nr < 0) { nr= 0; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE); -- cgit v1.2.1 From f84ec3c062d62a2ed623461a51e7106af0a8ae22 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Mar 2004 12:04:00 +0400 Subject: Spatial code changed to get rid of inconsistent this->* operation Now we use virtual calls instead and redirect VMT pointer of the geometry object with 'new' operation sql/field.cc: Usage of the Geometry class changed sql/item_geofunc.cc: Usage of the Geometry class changed sql/spatial.cc: Now we rewrite the real VMT of the object with new operation sql/spatial.h: No need for the VMT-like structure and pointers to it sql/sql_yacc.yy: enum items was renamed accordingly to coding standards --- sql/field.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 93827a8cd1f..c4aef133e6d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4765,7 +4765,8 @@ void Field_blob::get_key_image(char *buff,uint length, { const char *dummy; MBR mbr; - Geometry gobj; + Geometry_buffer buffer; + Geometry *gobj; if (blob_length < SRID_SIZE) { @@ -4773,8 +4774,9 @@ void Field_blob::get_key_image(char *buff,uint length, return; } get_ptr(&blob); - gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); - if (gobj.get_mbr(&mbr, &dummy)) + gobj= Geometry::create_from_wkb(&buffer, + blob + SRID_SIZE, blob_length - SRID_SIZE); + if (gobj->get_mbr(&mbr, &dummy)) bzero(buff, SIZEOF_STORED_DOUBLE*4); else { @@ -5013,9 +5015,11 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, return; } get_ptr(&blob); - Geometry gobj; - gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); - if (gobj.get_mbr(&mbr, &dummy)) + Geometry_buffer buffer; + Geometry *gobj; + gobj= Geometry::create_from_wkb(&buffer, + blob + SRID_SIZE, blob_length - SRID_SIZE); + if (gobj->get_mbr(&mbr, &dummy)) bzero(buff, SIZEOF_STORED_DOUBLE*4); else { @@ -5075,7 +5079,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2) goto err; wkb_type= uint4korr(from + WKB_HEADER_SIZE); - if (wkb_type < (uint32) Geometry::wkbPoint || + if (wkb_type < (uint32) Geometry::wkb_point || wkb_type > (uint32) Geometry::wkb_end) return 1; Field_blob::store_length(length); -- cgit v1.2.1 From b0cfa449a6f35f0f9d061d7357131a83aa8d1b91 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Mar 2004 13:26:37 +0400 Subject: Fix for #233 (the second one) sql/field.cc: Field_geom::store() returns -1 as a sign of fatal error sql/field_conv.cc: set_field_to_null* return -1 now as the fatal error sql/item.cc: no sign inversions needed sql/opt_range.cc: -1 is the sign of fatal error now sql/sql_base.cc: -1 is the fatal error --- sql/field.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index c4aef133e6d..d65de2410d0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5081,7 +5081,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) wkb_type= uint4korr(from + WKB_HEADER_SIZE); if (wkb_type < (uint32) Geometry::wkb_point || wkb_type > (uint32) Geometry::wkb_end) - return 1; + return -1; Field_blob::store_length(length); if (table->copy_blobs || length <= MAX_FIELD_WIDTH) { // Must make a copy @@ -5094,7 +5094,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) err: bzero(ptr, Field_blob::pack_length()); - return 1; + return -1; } #endif /*HAVE_SPATIAL*/ -- cgit v1.2.1 From 6170af8c38dcba679235cd1a6254719f1eaf6890 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Mar 2004 16:35:49 +0100 Subject: warnings removed --- sql/field.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index c4aef133e6d..cd761004ad6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -107,7 +107,7 @@ bool test_if_int(const char *str, int length, const char *int_end, return 1; } - +#ifdef NOT_USED static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) { cs= system_charset_info; // QQ move test_if_real into CHARSET_INFO struct @@ -159,7 +159,7 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) } return 1; } - +#endif static inline uint field_length_without_space(const char *ptr, uint length) { @@ -2273,7 +2273,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) int err; char *end; double nr= my_strntod(cs,(char*) from,len,&end,&err); - if (!err && (!current_thd->count_cuted_fields || end-from==len)) + if (!err && (!current_thd->count_cuted_fields || end-from==(int)len)) { return Field_float::store(nr); } @@ -2570,8 +2570,8 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) { int err; char *end; - double nr= my_strntod(cs,(char*) from,len,&end,&err); - if (!err && (!current_thd->count_cuted_fields || end-from==len)) + double nr= my_strntod(cs,(char*) from,len,&end,&err); + if (!err && (!current_thd->count_cuted_fields || end-from==(int)len)) { return Field_double::store(nr); } -- cgit v1.2.1 From 022c5241a9ebcd6047b761ef437f51e62722f9e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Mar 2004 00:09:13 +0200 Subject: after merge fixes include/my_tree.h: After merge fixes mysql-test/r/create.result: After merge fixes mysql-test/r/insert.result: After merge fixes mysql-test/r/multi_update.result: After merge fixes mysql-test/r/query_cache.result: After merge fixes mysql-test/r/rpl_error_ignored_table.result: After merge fixes mysql-test/r/rpl_optimize.result: After merge fixes mysql-test/r/show_check.result: After merge fixes mysql-test/t/insert.test: After merge fixes (Remove columns with space last) mysql-test/t/multi_update.test: After merge fixes mysql-test/t/show_check.test: After merge fixes sql/field.cc: Remove compiler warnings sql/sql_base.cc: Fix bug when table was refreshed --- sql/field.cc | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index c4aef133e6d..3355c45519e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2264,25 +2264,23 @@ void Field_longlong::sql_type(String &res) const add_zerofill_and_unsigned(res); } + /**************************************************************************** -** single precision float + single precision float ****************************************************************************/ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) { - int err; + int error; char *end; - double nr= my_strntod(cs,(char*) from,len,&end,&err); - if (!err && (!current_thd->count_cuted_fields || end-from==len)) - { - return Field_float::store(nr); - } - else + double nr= my_strntod(cs,(char*) from,len,&end,&error); + if (error || ((uint) (end-from) != len && current_thd->count_cuted_fields)) { + error= 1; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); - Field_float::store(nr); - return 1; } + Field_float::store(nr); + return error; } @@ -2562,25 +2560,23 @@ void Field_float::sql_type(String &res) const add_zerofill_and_unsigned(res); } + /**************************************************************************** -** double precision floating point numbers + double precision floating point numbers ****************************************************************************/ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) { - int err; + int error; char *end; - double nr= my_strntod(cs,(char*) from,len,&end,&err); - if (!err && (!current_thd->count_cuted_fields || end-from==len)) - { - return Field_double::store(nr); - } - else + double nr= my_strntod(cs,(char*) from, len, &end, &error); + if (error || ((uint) (end-from) != len && current_thd->count_cuted_fields)) { + error= 1; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); - Field_double::store(nr); - return 1; } + Field_double::store(nr); + return error; } -- cgit v1.2.1 From 1a81e0414515cef6275b5d2f3f27b950aa1ff91f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Mar 2004 15:14:36 +0200 Subject: DBUG_ASSERT(fixed == 1); added to val* small optimisation in signed_literal sql/field.cc: layout fixed sql/item.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed fixed= 1; added where it was forgoten in fix_fields Item_string can be used without fix_fields sql/item.h: DBUG_ASSERT(fixed == 1); added to val* Item_string can be used without fix_fields sql/item_cmpfunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_cmpfunc.h: fixed layout and getting Item statistic sql/item_func.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_func.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_geofunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_strfunc.cc: DBUG_ASSERT(fixed == 1); added to val* layout fixed sql/item_strfunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_subselect.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_sum.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.cc: DBUG_ASSERT(fixed == 1); added to val* sql/item_timefunc.h: DBUG_ASSERT(fixed == 1); added to val* sql/item_uniq.h: DBUG_ASSERT(fixed == 1); added to val* sql/sql_base.cc: Item creation revised sql/sql_help.cc: Item creation revised sql/sql_load.cc: Item creation revised sql/sql_parse.cc: fix_field call added sql/sql_select.cc: Item creation revised sql/sql_show.cc: Item creation revised sql/sql_union.cc: Item creation revised sql/sql_update.cc: Item creation revised sql/sql_yacc.yy: Item creation revised small optimisation in signed_literal --- sql/field.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index c4aef133e6d..81fb38cf382 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5737,7 +5737,7 @@ create_field::create_field(Field *old_field,Field *orig_field) { pos= (char*) sql_memdup(tmp.ptr(),tmp.length()+1); pos[tmp.length()]=0; - def=new Item_string(pos,tmp.length(), charset); + def= new Item_string(pos, tmp.length(), charset); } } #ifdef HAVE_SPATIAL -- cgit v1.2.1 From 3c46af6cf4e935683e5288c55f8b4ff4badaa553 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Mar 2004 15:05:01 +0200 Subject: BTREE-indexes in HEAP tables can now be used to optimize ORDER BY Don't read character set files if we are using only the default charset. In most cases the user will not anymore get a warning about missing character set files Compare strings with space extend instead of space strip. Now the following comparisons holds: "a" == "a " and "a\t" < "a". (Bug #3152). Note: Because of the above fix, one has to do a REPAIR on any table that has an ascii character < 32 last in a CHAR/VARCHAR/TEXT columns. heap/hp_hash.c: Comments and DBUG information include/my_handler.h: Updated prototype for mi_compare_text myisam/ft_boolean_search.c: Updated calls to mi_compare_text myisam/ft_nlq_search.c: Updated calls to mi_compare_text myisam/ft_parser.c: Updated calls to mi_compare_text myisam/ft_stopwords.c: Updated calls to mi_compare_text myisam/ft_update.c: Updated calls to mi_compare_text myisam/mi_check.c: Updated calls to mi_compare_text myisam/mi_search.c: Changed all string comparisons that removed end space to instead extend the shorter string with space myisam/mi_unique.c: Updated calls to mi_compare_text myisam/mi_write.c: Updated calls to mi_compare_text myisam/myisam_ftdump.c: Removed compiler warning mysql-test/r/ctype_collate.result: Fixed wrong result mysql-test/r/heap_btree.result: More tests mysql-test/t/heap_btree.test: more tests mysys/charset.c: Don't read charsets if we are only using default charset Don't require 'init_available_charsets' to succeed. mysys/my_handler.c: Compare strings with space extend instead of space strip mysys/tree.c: Fixed code to get better results for range optimzier sql/field.cc: Compare strings with space extend instead of space strip sql/filesort.cc: Compare strings with space extend instead of space strip sql/ha_heap.cc: Created bit map for keys that are using BTREE. This allows the optimzer to use BTREE's for sorting sql/ha_heap.h: Created bit map for keys that are using BTREE. This allows the optimzer to use BTREE's for sorting strings/ctype-big5.c: Compare strings with space extend instead of space strip strings/ctype-czech.c: Indentation cleanup. Should be fixed to use space extend strings/ctype-gbk.c: Compare strings with space extend instead of space strip strings/ctype-latin1.c: Compare strings with space extend instead of space strip Added missing my_hash_sort_latin1_de function strings/ctype-mb.c: For binary strings, don't remove end space when comparing strings/ctype-simple.c: Compare strings with space extend instead of space strip strings/ctype-sjis.c: Compare strings with space extend instead of space strip strings/ctype-tis620.c: Added comments that we should fix end space handling strings/ctype-ucs2.c: indentation fixes strings/ctype-utf8.c: Added comments that we should fix end space handling strings/ctype-win1250ch.c: Added comments that we should fix end space handling --- sql/field.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 00b7b9ebdb9..574800b6180 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4209,10 +4209,10 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) void Field_string::sort_string(char *to,uint length) { uint tmp=my_strnxfrm(field_charset, - (unsigned char *)to, length, - (unsigned char *) ptr, field_length); + (unsigned char *) to, length, + (unsigned char *) ptr, field_length); if (tmp < length) - bzero(to + tmp, length - tmp); + field_charset->cset->fill(field_charset, to + tmp, length - tmp, ' '); } @@ -4384,7 +4384,8 @@ void Field_varstring::sort_string(char *to,uint length) (unsigned char *) to, length, (unsigned char *)ptr+2, tot_length); if (tot_length < length) - bzero(to+tot_length,length-tot_length); + field_charset->cset->fill(field_charset, to+tot_length,length-tot_length, + binary() ? (char) 0 : ' '); } @@ -4838,7 +4839,9 @@ void Field_blob::sort_string(char *to,uint length) (unsigned char *)to, length, (unsigned char *)blob, blob_length); if (blob_length < length) - bzero(to+blob_length, length-blob_length); + field_charset->cset->fill(field_charset, to+blob_length, + length-blob_length, + binary() ? (char) 0 : ' '); } } -- cgit v1.2.1 From 3eff43162ba3136ecd305534f1e9d7cc779ce301 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 26 Mar 2004 16:11:46 +0400 Subject: 1. New data types, from the user point of view: BINARY(N) and VARBIBARY(N) 2. More 4.0 compatibility and more BINARY keyword consistency: 2a. CREATE TABLE a (a CHAR(N) BINARY) is now synonym for CREATE TABLE a (a CHAR(N) COLLATE xxxx_bin) 2b. SELECT BINARY x is still synonin for SELECT x COLLATE xxxxx_bin. --- sql/field.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index b7362d74c5f..474715f4e26 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4224,7 +4224,8 @@ void Field_string::sql_type(String &res) const (field_length > 3 && (table->db_options_in_use & HA_OPTION_PACK_RECORD) ? - "varchar" : "char"), + (has_charset() ? "varchar" : "varbinary") : + (has_charset() ? "char" : "binary")), (int) field_length / charset()->mbmaxlen); res.length(length); } -- cgit v1.2.1 From bc12d57fa781c3c0320733b9f096835f951edbbc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Mar 2004 19:24:28 +0300 Subject: Fix to get correct metadata when using temporary tables to create result. (Bug #2654) client/mysqltest.c: Added support for --enable_metadata mysql-test/t/order_by.test: Improved comment scripts/mysqlaccess.sh: CGI is required (Bug #2988) sql/field.cc: Fix to get correct metadata when using temporary tables to create result sql/field.h: Fix to get correct metadata when using temporary tables to create result sql/sql_insert.cc: Fix to get correct metadata when using temporary tables to create result --- sql/field.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 474715f4e26..89c6464c5f0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -301,7 +301,8 @@ Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg) :ptr(ptr_arg),null_ptr(null_ptr_arg), - table(table_arg),table_name(table_arg ? table_arg->table_name : 0), + table(table_arg),orig_table(table_arg), + table_name(table_arg ? table_arg->table_name : 0), field_name(field_name_arg), query_id(0), key_start(0), part_of_key(0), part_of_sortkey(0), unireg_check(unireg_check_arg), @@ -349,9 +350,10 @@ void Field_num::add_zerofill_and_unsigned(String &res) const void Field_num::make_field(Send_field *field) { /* table_cache_key is not set for temp tables */ - field->db_name=table->table_cache_key ? table->table_cache_key : ""; - field->org_table_name=table->real_name; - field->table_name=table_name; + field->db_name= (orig_table->table_cache_key ? orig_table->table_cache_key : + ""); + field->org_table_name= orig_table->real_name; + field->table_name= orig_table->table_name; field->col_name=field->org_col_name=field_name; field->charsetnr= charset()->number; field->length=field_length; @@ -364,9 +366,10 @@ void Field_num::make_field(Send_field *field) void Field_str::make_field(Send_field *field) { /* table_cache_key is not set for temp tables */ - field->db_name=table->table_cache_key ? table->table_cache_key : ""; - field->org_table_name=table->real_name; - field->table_name=table_name; + field->db_name= (orig_table->table_cache_key ? orig_table->table_cache_key : + ""); + field->org_table_name= orig_table->real_name; + field->table_name= orig_table->table_name; field->col_name=field->org_col_name=field_name; field->charsetnr= charset()->number; field->length=field_length; -- cgit v1.2.1 From 32b28f92980ca2c057e61cb662f5c244e998d121 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Apr 2004 10:12:53 +0400 Subject: WL#1266 "Separate auto-set logic from TIMESTAMP type." Final version of patch. Adds support for specifying of DEFAULT NOW() and/or ON UPDATE NOW() clauses for TIMESTAMP field definition. Current implementation allows only one such field per table and uses several unireg types for storing info about this properties of field. It should be replaced with better implementation when new .frm format is introduced. include/mysqld_error.h: Added error codes for case when we have more than one column with NOW() in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. mysql-test/r/create.result: Added tests for using of DEFAULT NOW() and ON UPDATE NOW() with non-TIMESTAMP fields. mysql-test/r/show_check.result: Updated test results to reflect new default look of TIMESTAMP fields in SHOW CREATE TABLE. mysql-test/r/system_mysql_db.result: Updated test results to reflect new default look of TIMESTAMP fields in SHOW CREATE TABLE. mysql-test/r/type_ranges.result: Updated test results to reflect new default look of TIMESTAMP fields in SHOW COLUMNS. mysql-test/r/type_timestamp.result: Added tests for various DEFAULT and ON UPDATE clauses for TIMESTAMP fields definitions. mysql-test/t/create.test: Added tests for using of DEFAULT NOW() and ON UPDATE NOW() with non-TIMESTAMP fields. mysql-test/t/type_timestamp.test: Added tests for various DEFAULT and ON UPDATE clauses for TIMESTAMP fields definitions. sql/field.cc: Added support for various combinations of DEFAULT and ON UPDATE clauses for TIMESTAMP field. Setting TABLE::timestamp* members for TIMESTAMP fields with auto-set option taking into account their unireg type (which corresponds to various DEFAULT/ON UPDATE values combinations). Replaced TABLE::time_stamp with TABLE::timestamp_default_now/on_update_now couple moved their setup to separate method set_timestamp_offsets(), which now is called from open_table instead of Field_timestamp cons. sql/field.h: Added more unireg types for handling of DEFAULT NOW() and ON UPDATE NOW() for TIMESTAMP fields. Fixed value corresponding to DEFAULT item for TIMESTAMP field. sql/ha_berkeley.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_heap.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_innodb.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_isam.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_isammrg.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_myisam.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/ha_myisammrg.cc: Now TIMESTAMP column with auto-set property could be updated during INSERT or/and UPDATE independently. sql/item_func.h: We need to distinguish NOW() from other function for using in DEFAULT and in ON UPDATE clauses. sql/item_timefunc.h: We need to distinguish NOW() from other function for using in DEFAULT and in ON UPDATE clauses. sql/mysql_priv.h: Added parameter for ON UPDATE value to add_field_to_list() function. sql/share/czech/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/danish/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/dutch/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/english/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/estonian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/french/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/german/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/greek/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/hungarian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/italian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/japanese/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/korean/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/norwegian-ny/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/norwegian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/polish/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/portuguese/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/romanian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/russian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/serbian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/slovak/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/spanish/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/swedish/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/share/ukrainian/errmsg.txt: Added error messages for case when we have more than one column with NOW() (CURRENT_TIMESTAMP is just more standard alias) in DEFAULT or ON UPDATE clauses and for case when we are using ON UPDATE clause with wrong type. sql/sql_base.cc: Added setup of TABLE::timestamp_default_now/on_update_now pair for each statement to open_table(). sql/sql_insert.cc: Using TABLE::timestamp_default_now/on_update_now pair instead of old TABLE::time_stamp. Added check for case then REPLACE could not be converted to UPDATE because of different DEFAULT/ON UPDATE values for TIMESTAMP field. sql/sql_lex.h: Added member for value used in ON UPDATE clause to st_lex. sql/sql_load.cc: Using TABLE::timestamp_default_now/on_update_now pair instead of old TABLE::time_stamp. We don't need to restore these members since they are set up for each statement in open_table(). sql/sql_parse.cc: Added handling of DEFAULT NOW() and ON UPDATE NOW() clauses for TIMESTAMP fields to add_field_to_list() function. sql/sql_show.cc: Added support for DEFAULT CURRENT_TIMESTAMP (aka NOW() ) and ON UPDATE CURRENT_TIMESTAMP to SHOW CREATE TABLE and SHOW COLUMNS. sql/sql_table.cc: mysql_create_table() function - added check for number of TIMESTAMP fields with auto-set values and replacing of old style TIMESTAMPs with their newer analogs. mysql_alter_table(): Using TABLE::timestamp_default_now/on_update_now pair instead of old TABLE::time_stamp. We don't need to restore these members since they are set up for each statement in open_table(). sql/sql_update.cc: Left only setting of TABLE::timestamp_default_now/on_update_now to 0 since they should be already set up in open_table(). sql/sql_yacc.yy: Added support for DEFAULT NOW() and ON UPDATE NOW() in field definitions. sql/table.h: Replaced TABLE::time_stamp withTABLE::timestamp_default_now/timestamp_on_update_now pair which allows to distinguish TIMESTAMP's with various DEFAULT/ON UPDATE clauses and optimize checks if TIMESTAMP field should be set to NOW() in handlers. sql/unireg.cc: Now we are marking only TIMESTAMP fields with NOW() as default or as on update value as special field for unireg. --- sql/field.cc | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 8 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 89c6464c5f0..238d5e36147 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2842,11 +2842,50 @@ void Field_double::sql_type(String &res) const } -/**************************************************************************** -** timestamp -** The first timestamp in the table is automaticly updated -** by handler.cc. The form->timestamp points at the automatic timestamp. -****************************************************************************/ +/* + TIMESTAMP type. + Holds datetime values in range from 1970-01-01 00:00:01 UTC to + 2038-01-01 00:00:00 UTC stored as number of seconds since Unix + Epoch in UTC. + + Up to one of timestamps columns in the table can be automatically + set on row update and/or have NOW() as default value. + TABLE::timestamp_field points to Field object for such timestamp with + auto-set-on-update. TABLE::time_stamp holds offset in record + 1 for this + field, and is used by handler code which performs updates required. + + Actually SQL-99 says that we should allow niladic functions (like NOW()) + as defaults for any field. Current limitations (only NOW() and only + for one TIMESTAMP field) are because of restricted binary .frm format + and should go away in the future. + + Also because of this limitation of binary .frm format we use 5 different + unireg_check values with TIMESTAMP field to distinguish various cases of + DEFAULT or ON UPDATE values. These values are: + + TIMESTAMP_OLD_FIELD - old timestamp, if there was not any fields with + auto-set-on-update (or now() as default) in this table before, then this + field has NOW() as default and is updated when row changes, else it is + field which has 0 as default value and is not automaitcally updated. + TIMESTAMP_DN_FIELD - field with NOW() as default but not set on update + automatically (TIMESTAMP DEFAULT NOW()) + TIMESTAMP_UN_FIELD - field which is set on update automatically but has not + NOW() as default (but it may has 0 or some other const timestamp as + default) (TIMESTAMP ON UPDATE NOW()). + TIMESTAMP_DNUN_FIELD - field which has now() as default and is auto-set on + update. (TIMESTAMP DEFAULT NOW() ON UPDATE NOW()) + NONE - field which is not auto-set on update with some other than NOW() + default value (TIMESTAMP DEFAULT 0). + + Note that TIMESTAMP_OLD_FIELD's are never created explicitly now, they are + left only for preserving ability to read old tables. Such fields replaced + with their newer analogs in CREATE TABLE and in SHOW CREATE TABLE. This is + because we want to prefer NONE unireg_check before TIMESTAMP_OLD_FIELD for + "TIMESTAMP DEFAULT 'Const'" field. (Old timestamps allowed such + specification too but ignored default value for first timestamp, which of + course is non-standard.) In most cases user won't notice any change, only + exception is different behavior of old/new timestamps during ALTER TABLE. + */ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg, enum utype unireg_check_arg, @@ -2857,15 +2896,37 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg, unireg_check_arg, field_name_arg, table_arg, cs) { flags|=ZEROFILL_FLAG; /* 4.0 MYD compatibility */ - if (table && !table->timestamp_field) + if (table && !table->timestamp_field && + unireg_check != NONE) { - table->timestamp_field= this; // Automatic timestamp - table->time_stamp=(ulong) (ptr_arg - (char*) table->record[0])+1; + /* This timestamp has auto-update */ + table->timestamp_field= this; flags|=TIMESTAMP_FLAG; } } +/* + Sets TABLE::timestamp_default_now and TABLE::timestamp_on_update_now + members according to unireg type of this TIMESTAMP field. + + SYNOPSIS + Field_timestamp::set_timestamp_offsets() + +*/ +void Field_timestamp::set_timestamp_offsets() +{ + ulong timestamp= (ulong) (ptr - (char*) table->record[0]) + 1; + + DBUG_ASSERT(table->timestamp_field == this && unireg_check != NONE); + + table->timestamp_default_now= + (unireg_check == TIMESTAMP_UN_FIELD)? 0 : timestamp; + table->timestamp_on_update_now= + (unireg_check == TIMESTAMP_DN_FIELD)? 0 : timestamp; +} + + int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) { long tmp=(long) str_to_timestamp(from,len); -- cgit v1.2.1 From 7873b89fc50d420a5f538a5b60faf79131f86c4f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Apr 2004 13:56:05 +0300 Subject: Fixed many compiler warnings Fixed bugs in group_concat with ORDER BY and DISTINCT (Bugs #2695, #3381 and #3319) Fixed crash when doing rollback in slave and the io thread catched up with the sql thread Set locked_in_memory properly include/mysql_com.h: Fixed compiler warning libmysqld/emb_qcache.cc: Removed not used variable libmysqld/lib_sql.cc: Removed not used variable myisam/mi_locking.c: Added comment myisam/mi_rnext.c: Fixed bug in concurrent insert myisam/mi_rprev.c: Simple optimization mysql-test/r/func_gconcat.result: New tests mysql-test/t/func_gconcat.test: New tests mysql-test/t/func_group.test: Cleanup sql-common/client.c: Removed compiler warning sql/derror.cc: Better comments sql/field.cc: Removed not used function/variable sql/field.h: Removed not needed variable sql/ha_innodb.cc: Removed not used function sql/item.cc: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_func.cc: Fixed compiler warning sql/item_geofunc.cc: Fixed compiler warning sql/item_sum.cc: Fixed bugs in group_concat and added more comments (Bugs #2695, #3381 and #3319) - field->abs_offset was not needed - Wrong assumption of field order in temporary table - Some not used variables removed - Added ORDER BY fields after argument fields so that code in sql_select.cc can move all fields to point to temporary tables, if needed. - Optimized loops sql/item_sum.h: Bug fixing and cleanup of group_concat() sql/log.cc: Removed wrong comment sql/log_event.cc: Removed compiler warning sql/mysqld.cc: Set locked_in_memory properly sql/protocol.cc: Removed compiler warning sql/set_var.cc: Code cleanup sql/slave.cc: Fixed crash when doing rollback in slave and the io thread catched up with the sql thread sql/sql_cache.cc: Removed compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Removed compiler warnings sql/sql_lex.cc: Removed not used lable sql/sql_lex.h: Removed compiler warnings sql/sql_parse.cc: Removed compiler warnings sql/sql_prepare.cc: Removed compiler warnings sql/sql_select.cc: Removed not used variables Added function comments sql/sql_show.cc: Removed compiler warnings sql/sql_yacc.yy: Fix for ORDER BY handling in GROUP_CONCAT() --- sql/field.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 89c6464c5f0..89c955ed45a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -161,13 +161,6 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs) } #endif -static inline uint field_length_without_space(const char *ptr, uint length) -{ - const char *end= ptr+length; - while (end > ptr && end[-1] == ' ') - end--; - return (uint) (end-ptr); -} /* Tables of filed type compatibility. @@ -306,7 +299,7 @@ Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, field_name(field_name_arg), query_id(0), key_start(0), part_of_key(0), part_of_sortkey(0), unireg_check(unireg_check_arg), - field_length(length_arg),null_bit(null_bit_arg),abs_offset(0) + field_length(length_arg),null_bit(null_bit_arg) { flags=null_ptr ? 0: NOT_NULL_FLAG; comment.str= (char*) ""; @@ -5536,7 +5529,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length) case FIELD_TYPE_ENUM: abort(); return 0; // This shouldn't happen default: return 0; } - return 0; // This shouldn't happen + return 0; // Keep compiler happy } -- cgit v1.2.1 From 815c23f1e6431a6e20e8915fa92a71f7a754d5b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Apr 2004 19:57:33 +0500 Subject: Fixed charsetnr sent to the client --- sql/field.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 8408bfdf578..30ae20de94b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5623,6 +5623,18 @@ Field *make_field(char *ptr, uint32 field_length, null_pos=0; null_bit=0; } + + switch (field_type) + { + case FIELD_TYPE_DATE: + case FIELD_TYPE_NEWDATE: + case FIELD_TYPE_TIME: + case FIELD_TYPE_DATETIME: + case FIELD_TYPE_TIMESTAMP: + field_charset= &my_charset_bin; + default: break; + } + if (f_is_alpha(pack_flag)) { if (!f_is_packed(pack_flag)) -- cgit v1.2.1 From e9447881eb13378b06f0939091ab4e258a83ad51 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Apr 2004 04:33:58 +0300 Subject: Portability fixes Fixed problems with group_concat() and HAVING Updated crash-me values sql-bench/limits/mysql-4.0.cfg: Rename: sql-bench/limits/mysql.cfg -> sql-bench/limits/mysql-4.0.cfg include/my_global.h: Safety fix libmysqld/Makefile.am: Portability fix (For AIX 64 bit) mysql-test/r/func_gconcat.result: More tests mysql-test/t/func_gconcat.test: More tests sql/field.cc: Cleanups sql/init.cc: moved thread_stack_min to right place sql/item_sum.cc: Fixed problems with group_concat() and HAVING Removed some not needed variables sql/item_sum.h: Fixed problems with group_concat() and HAVING Removed some not needed variables sql/mysqld.cc: Moved thread_stack_min to right place to handle case where we didn't get as much stack space as we asked for sql/sql_parse.cc: More debugging sql/sql_select.cc: Cleanup sql/sql_yacc.yy: Fixed handling of Item_group_concat() in having. (Arguments should not be handled as refs) --- sql/field.cc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'sql/field.cc') diff --git a/sql/field.cc b/sql/field.cc index 30ae20de94b..d099da2d959 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2782,14 +2782,8 @@ int Field_double::cmp(const char *a_ptr, const char *b_ptr) else #endif { -/* could this ALWAYS be 2 calls to doubleget() ?? */ -#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) doubleget(a, a_ptr); doubleget(b, b_ptr); -#else - memcpy_fixed(&a,a_ptr,sizeof(double)); - memcpy_fixed(&b,b_ptr,sizeof(double)); -#endif } return (a < b) ? -1 : (a > b) ? 1 : 0; } @@ -2809,12 +2803,7 @@ void Field_double::sort_string(char *to,uint length __attribute__((unused))) } else #endif -/* could this ALWAYS be 2 calls to doubleget() ?? */ -#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) doubleget(nr,ptr); -#else - memcpy_fixed(&nr,ptr,sizeof(nr)); -#endif change_double_for_sort(nr, (byte*) to); } -- cgit v1.2.1