From 0ce02f6d98b5eb94797a935e06fa89f37a241b52 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2006 16:32:12 +0400 Subject: [PATCH 1/4] Fix for bug #22533: Traditional: Too-long bit value not rejected. Problem: storing >=8 byte hexadecimal values we don't check data. Fix: check if the data fits the {u}longlong range. mysql-test/r/select.result: Fix for bug #22533: Traditional: Too-long bit value not rejected. - test result. mysql-test/t/range.test: Fix for bug #22533: Traditional: Too-long bit value not rejected. - adjusted. mysql-test/t/select.test: Fix for bug #22533: Traditional: Too-long bit value not rejected. - test case. sql/item.cc: Fix for bug #22533: Traditional: Too-long bit value not rejected. - limit storing value to {U}LONGLONG_MAX in numeric context. --- mysql-test/r/select.result | 17 +++++++++++++++++ mysql-test/t/range.test | 4 ++-- mysql-test/t/select.test | 13 ++++++++++++- sql/item.cc | 25 +++++++++++++++++++------ 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index f09143fcaa6..6dc971a953c 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2819,3 +2819,20 @@ select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; min(key1) 0.37619999051094 DROP TABLE t1,t2; +create table t1(a bigint unsigned, b bigint); +insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), +(0x10000000000000000, 0x10000000000000000), +(0x8fffffffffffffff, 0x8fffffffffffffff); +Warnings: +Warning 1264 Data truncated; out of range for column 'a' at row 1 +Warning 1264 Data truncated; out of range for column 'b' at row 1 +Warning 1264 Data truncated; out of range for column 'a' at row 2 +Warning 1264 Data truncated; out of range for column 'b' at row 2 +Warning 1264 Data truncated; out of range for column 'b' at row 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF +drop table t1; +End of 4.1 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 245178d7d4a..6d3b2fb52ee 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -400,8 +400,8 @@ select count(*) from t1 where x = 18446744073709551601; create table t2 (x bigint not null); -insert into t2(x) values (0xfffffffffffffff0); -insert into t2(x) values (0xfffffffffffffff1); +insert into t2(x) values (-16); +insert into t2(x) values (-15); select * from t2; select count(*) from t2 where x>0; select count(*) from t2 where x=0; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 3f9fb59d26f..0dc179e9b4b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2342,4 +2342,15 @@ select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5; DROP TABLE t1,t2; --enable_ps_protocol -# End of 4.1 tests +# +# Bug #22533: storing large hex strings +# + +create table t1(a bigint unsigned, b bigint); +insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), + (0x10000000000000000, 0x10000000000000000), + (0x8fffffffffffffff, 0x8fffffffffffffff); +select hex(a), hex(b) from t1; +drop table t1; + +--echo End of 4.1 tests diff --git a/sql/item.cc b/sql/item.cc index 94f0a24fcc3..30f34f9ec3b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2340,18 +2340,31 @@ longlong Item_varbinary::val_int() int Item_varbinary::save_in_field(Field *field, bool no_conversions) { - int error; field->set_notnull(); if (field->result_type() == STRING_RESULT) + return field->store(str_value.ptr(), str_value.length(), + collation.collation); + + ulonglong nr; + uint32 length= str_value.length(); + if (length > 8) { - error=field->store(str_value.ptr(),str_value.length(),collation.collation); + nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX; + goto warn; } - else + nr= (ulonglong) val_int(); + if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX)) { - longlong nr=val_int(); - error=field->store(nr); + nr= LONGLONG_MAX; + goto warn; } - return error; + return field->store((longlong) nr); + +warn: + if (!field->store((longlong) nr)) + field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, + 1); + return 1; } From af3d6c48fb7488ff247853e87d3772070bb536ca Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jan 2007 13:30:01 -0800 Subject: [PATCH 2/4] Adding support for versioned libndbclient.so. bug #13522 configure.in: Added variables to support ndbclient library versioning. Set version to 1.0.0 for 4.1 ndb/src/Makefile.am: Making use of new variables. Adding support for versioned libraries. --- configure.in | 7 +++++++ ndb/src/Makefile.am | 2 ++ 2 files changed, 9 insertions(+) diff --git a/configure.in b/configure.in index 8457a2dcad0..e85b8e795ba 100644 --- a/configure.in +++ b/configure.in @@ -14,6 +14,10 @@ DOT_FRM_VERSION=6 SHARED_LIB_MAJOR_VERSION=14 SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0 +NDB_SHARED_LIB_MAJOR_VERSION=1 +NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 + + # ndb version NDB_VERSION_MAJOR=4 NDB_VERSION_MINOR=1 @@ -73,6 +77,9 @@ AC_DEFINE_UNQUOTED([DOT_FRM_VERSION], [$DOT_FRM_VERSION], [Version of .frm files]) AC_SUBST(SHARED_LIB_MAJOR_VERSION) AC_SUBST(SHARED_LIB_VERSION) +AC_SUBST(NDB_SHARED_LIB_MAJOR_VERSION) +AC_SUBST(NDB_SHARED_LIB_VERSION) + AC_SUBST(AVAILABLE_LANGUAGES) AC_SUBST(AVAILABLE_LANGUAGES_ERRORS) AC_SUBST_FILE(AVAILABLE_LANGUAGES_ERRORS_RULES) diff --git a/ndb/src/Makefile.am b/ndb/src/Makefile.am index eb1cf1c6543..ffa45e57196 100644 --- a/ndb/src/Makefile.am +++ b/ndb/src/Makefile.am @@ -6,6 +6,8 @@ ndblib_LTLIBRARIES = libndbclient.la libndbclient_la_SOURCES = +libndbclient_la_LDFLAGS = -version-info @NDB_SHARED_LIB_VERSION@ + libndbclient_la_LIBADD = \ ndbapi/libndbapi.la \ common/transporter/libtransporter.la \ From 8f16a2555651b4d29eafe094cb6f36ea8803896d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jan 2007 16:21:43 -0800 Subject: [PATCH 3/4] Added version script information to actually version the symbols. ndb/src/libndb.ver.in: BitKeeper file /home/mtaylor/src/mysql-4.1-maint/ndb/src/libndb.ver.in --- configure.in | 9 +++++++++ ndb/src/Makefile.am | 2 +- ndb/src/libndb.ver.in | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 ndb/src/libndb.ver.in diff --git a/configure.in b/configure.in index e85b8e795ba..47965876627 100644 --- a/configure.in +++ b/configure.in @@ -449,6 +449,15 @@ if $LD --version 2>/dev/null|grep -q GNU; then fi AC_SUBST(LD_VERSION_SCRIPT) +# libndbclient versioning when linked with GNU ld. +if $LD --version 2>/dev/null|grep -q GNU; then + NDB_LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/ndb/src/libndb.ver" + AC_CONFIG_FILES(ndb/src/libndb.ver) +fi +AC_SUBST(NDB_LD_VERSION_SCRIPT) + + + # Avoid bug in fcntl on some versions of linux AC_MSG_CHECKING([if we should use 'skip-external-locking' as default for $target_os]) # Any wariation of Linux diff --git a/ndb/src/Makefile.am b/ndb/src/Makefile.am index ffa45e57196..056bb5a1734 100644 --- a/ndb/src/Makefile.am +++ b/ndb/src/Makefile.am @@ -6,7 +6,7 @@ ndblib_LTLIBRARIES = libndbclient.la libndbclient_la_SOURCES = -libndbclient_la_LDFLAGS = -version-info @NDB_SHARED_LIB_VERSION@ +libndbclient_la_LDFLAGS = -version-info @NDB_SHARED_LIB_VERSION@ @NDB_LD_VERSION_SCRIPT@ libndbclient_la_LIBADD = \ ndbapi/libndbapi.la \ diff --git a/ndb/src/libndb.ver.in b/ndb/src/libndb.ver.in new file mode 100644 index 00000000000..72bf93d196f --- /dev/null +++ b/ndb/src/libndb.ver.in @@ -0,0 +1,2 @@ +libndbclient_@NDB_SHARED_LIB_MAJOR_VERSION@ { global: *; }; + From 7f5bcdaaa5f25dca746ea70f3c5f9dd8ab9884e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Jan 2007 12:19:53 +0400 Subject: [PATCH 4/4] after merge fix. mysql-test/r/range.result: Fix for bug #22533: Traditional: Too-long bit value not rejected. - results adjusted. --- mysql-test/r/range.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index f25d94f8066..25b67ecf5a7 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -504,8 +504,8 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 create table t2 (x bigint not null); -insert into t2(x) values (0xfffffffffffffff0); -insert into t2(x) values (0xfffffffffffffff1); +insert into t2(x) values (-16); +insert into t2(x) values (-15); select * from t2; x -16