From 79aaf0754d14b3a06b63fdfc5705064f6140cd1a Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Sat, 5 Nov 2005 01:44:35 +0100 Subject: [PATCH 1/3] mysql.spec.sh: Always use bundled zlib --- support-files/mysql.spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5cd9d1646a4..7a1219736ae 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -249,6 +249,7 @@ sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ --includedir=%{_includedir} \ --mandir=%{_mandir} \ --enable-thread-safe-client \ + --with-zlib-dir=bundled \ --with-readline ; # Add this for more debugging support # --with-debug From a1f56ea5a6414947dc17f565e98f102248e9f286 Mon Sep 17 00:00:00 2001 From: "petr@mysql.com" <> Date: Sat, 5 Nov 2005 15:08:15 +0300 Subject: [PATCH 2/3] Fix Bug#13894 Server crashes on update of CSV table --- mysql-test/r/csv.result | 20 ++++++++++++++++++++ mysql-test/t/csv.test | 18 ++++++++++++++++++ sql/examples/ha_tina.cc | 19 +++++++++---------- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index ea0d34271b5..78a1f34636c 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -4929,3 +4929,23 @@ Warnings: Note 1051 Unknown table 't2' Note 1051 Unknown table 't3' Note 1051 Unknown table 't4' +DROP TABLE IF EXISTS bug13894; +CREATE TABLE bug13894 ( val integer ) ENGINE = CSV; +INSERT INTO bug13894 VALUES (5); +INSERT INTO bug13894 VALUES (10); +INSERT INTO bug13894 VALUES (11); +INSERT INTO bug13894 VALUES (10); +SELECT * FROM bug13894; +val +5 +10 +11 +10 +UPDATE bug13894 SET val=6 WHERE val=10; +SELECT * FROM bug13894; +val +5 +11 +6 +6 +DROP TABLE bug13894; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 2ac46d75f9a..61b4f9607a5 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1314,4 +1314,22 @@ select period from t1; drop table if exists t1,t2,t3,t4; +# +# Bug #13894 Server crashes on update of CSV table +# + +--disable_warnings +DROP TABLE IF EXISTS bug13894; +--enable_warnings + +CREATE TABLE bug13894 ( val integer ) ENGINE = CSV; +INSERT INTO bug13894 VALUES (5); +INSERT INTO bug13894 VALUES (10); +INSERT INTO bug13894 VALUES (11); +INSERT INTO bug13894 VALUES (10); +SELECT * FROM bug13894; +UPDATE bug13894 SET val=6 WHERE val=10; +SELECT * FROM bug13894; +DROP TABLE bug13894; + # End of 4.1 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 8a9aa91c680..f4544670ed9 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -58,12 +58,16 @@ static int tina_init= 0; ** TINA tables *****************************************************************************/ -/* - Used for sorting chains. +/* + Used for sorting chains with qsort(). */ int sort_set (tina_set *a, tina_set *b) { - return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) ); + /* + We assume that intervals do not intersect. So, it is enought to compare + any two points. Here we take start of intervals for comparison. + */ + return ( a->begin > b->begin ? -1 : ( a->begin < b->begin ? 1 : 0 ) ); } static byte* tina_get_key(TINA_SHARE *share,uint *length, @@ -739,13 +743,8 @@ int ha_tina::rnd_end() qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set); for (ptr= chain; ptr < chain_ptr; ptr++) { - /* We peek a head to see if this is the last chain */ - if (ptr+1 == chain_ptr) - memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, - length - (size_t)ptr->end); - else - memmove((caddr_t)share->mapped_file + ptr->begin, (caddr_t)share->mapped_file + ptr->end, - (size_t)((ptr++)->begin - ptr->end)); + memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, + length - (size_t)ptr->end); length= length - (size_t)(ptr->end - ptr->begin); } From 038b300753440a9cc24da56c2ba9ff477726243c Mon Sep 17 00:00:00 2001 From: "petr@mysql.com" <> Date: Sun, 6 Nov 2005 02:11:12 +0300 Subject: [PATCH 3/3] Fix Bug#14672 Bug in deletion --- mysql-test/r/csv.result | 27 +++++++++++++++++++++++++++ mysql-test/t/csv.test | 19 +++++++++++++++++++ sql/examples/ha_tina.cc | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 78a1f34636c..2e3d11ad461 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -4949,3 +4949,30 @@ val 6 6 DROP TABLE bug13894; +DROP TABLE IF EXISTS bug14672; +CREATE TABLE bug14672 (c1 integer) engine = CSV; +INSERT INTO bug14672 VALUES (1), (2), (3); +SELECT * FROM bug14672; +c1 +1 +2 +3 +DELETE FROM bug14672 WHERE c1 = 2; +SELECT * FROM bug14672; +c1 +1 +3 +INSERT INTO bug14672 VALUES (4); +SELECT * FROM bug14672; +c1 +1 +3 +4 +INSERT INTO bug14672 VALUES (5); +SELECT * FROM bug14672; +c1 +1 +3 +4 +5 +DROP TABLE bug14672; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 61b4f9607a5..5b693335a43 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1332,4 +1332,23 @@ UPDATE bug13894 SET val=6 WHERE val=10; SELECT * FROM bug13894; DROP TABLE bug13894; +# +# Bug #14672 Bug in deletion +# + +--disable_warnings +DROP TABLE IF EXISTS bug14672; +--enable_warnings + +CREATE TABLE bug14672 (c1 integer) engine = CSV; +INSERT INTO bug14672 VALUES (1), (2), (3); +SELECT * FROM bug14672; +DELETE FROM bug14672 WHERE c1 = 2; +SELECT * FROM bug14672; +INSERT INTO bug14672 VALUES (4); +SELECT * FROM bug14672; +INSERT INTO bug14672 VALUES (5); +SELECT * FROM bug14672; +DROP TABLE bug14672; + # End of 4.1 tests diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index f4544670ed9..91e42bfea31 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -166,7 +166,8 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); - if ((share->data_file= my_open(data_file_name, O_RDWR, MYF(0))) == -1) + if ((share->data_file= my_open(data_file_name, O_RDWR|O_APPEND, + MYF(0))) == -1) goto error2; /* We only use share->data_file for writing, so we scan to the end to append */