summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmysql/libmysql.c11
-rw-r--r--mysql-test/r/fulltext_order_by.result74
-rw-r--r--mysql-test/r/ps_2myisam.result20
-rw-r--r--mysql-test/r/ps_3innodb.result20
-rw-r--r--mysql-test/r/ps_4heap.result16
-rw-r--r--mysql-test/r/ps_5merge.result40
-rw-r--r--mysql-test/r/ps_6bdb.result20
-rw-r--r--mysql-test/r/ps_7ndb.result20
-rw-r--r--mysql-test/r/select.result35
-rw-r--r--mysql-test/t/fulltext_order_by.test81
-rw-r--r--mysql-test/t/select.test40
-rw-r--r--sql/field.cc4
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/sql_select.cc12
-rw-r--r--tests/mysql_client_test.c74
15 files changed, 397 insertions, 73 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index a896460beeb..f622b2d2fb2 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1869,6 +1869,16 @@ static void net_clear_error(NET *net)
}
}
+static void stmt_clear_error(MYSQL_STMT *stmt)
+{
+ if (stmt->last_errno)
+ {
+ stmt->last_errno= 0;
+ stmt->last_error[0]= '\0';
+ strmov(stmt->sqlstate, not_error_sqlstate);
+ }
+}
+
/*
Set statement error code, sqlstate, and error message
from given errcode and sqlstate.
@@ -4959,6 +4969,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
stmt->state= MYSQL_STMT_INIT_DONE;
return 1;
}
+ stmt_clear_error(stmt);
}
}
stmt->state= MYSQL_STMT_PREPARE_DONE;
diff --git a/mysql-test/r/fulltext_order_by.result b/mysql-test/r/fulltext_order_by.result
index dc51454f1d5..130d096e00f 100644
--- a/mysql-test/r/fulltext_order_by.result
+++ b/mysql-test/r/fulltext_order_by.result
@@ -86,3 +86,77 @@ a rel
1 1
2 2
drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+thread int(11) NOT NULL default '0',
+beitrag longtext NOT NULL,
+PRIMARY KEY (id),
+KEY thread (thread),
+FULLTEXT KEY beitrag (beitrag)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ;
+CREATE TABLE t2 (
+id int(11) NOT NULL auto_increment,
+text varchar(100) NOT NULL default '',
+PRIMARY KEY (id),
+KEY text (text)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ;
+CREATE TABLE t3 (
+id int(11) NOT NULL auto_increment,
+forum int(11) NOT NULL default '0',
+betreff varchar(70) NOT NULL default '',
+PRIMARY KEY (id),
+KEY forum (forum),
+FULLTEXT KEY betreff (betreff)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(b.betreff) against ('+abc' in boolean mode)
+group by a.text, b.id, b.betreff
+union
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(c.beitrag) against ('+abc' in boolean mode)
+group by
+a.text, b.id, b.betreff
+order by
+match(b.betreff) against ('+abc' in boolean mode) desc;
+ERROR 42S02: Unknown table 'b' in order clause
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(b.betreff) against ('+abc' in boolean mode)
+union
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(c.beitrag) against ('+abc' in boolean mode)
+order by
+match(b.betreff) against ('+abc' in boolean mode) desc;
+ERROR 42S02: Unknown table 'b' in order clause
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(b.betreff) against ('+abc' in boolean mode)
+union
+select a.text, b.id, b.betreff
+from
+t2 a inner join t3 b on a.id = b.forum inner join
+t1 c on b.id = c.thread
+where
+match(c.beitrag) against ('+abc' in boolean mode)
+order by
+match(betreff) against ('+abc' in boolean mode) desc;
+text id betreff
+drop table t1,t2,t3;
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index a9342636349..64dc09f864c 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -77,8 +77,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -1810,17 +1810,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1828,8 +1828,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 3a470d218d1..792d74231f2 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -77,8 +77,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -1793,17 +1793,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1811,8 +1811,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index beeaff05ece..7dcb8546a83 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1794,17 +1794,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1812,8 +1812,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index fada983a561..77b1a242452 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -120,8 +120,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -1730,17 +1730,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1748,8 +1748,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
@@ -3132,8 +3132,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -4742,17 +4742,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -4760,8 +4760,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result
index 404c25c2c37..0489c7ef078 100644
--- a/mysql-test/r/ps_6bdb.result
+++ b/mysql-test/r/ps_6bdb.result
@@ -77,8 +77,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -1793,17 +1793,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1811,8 +1811,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index ffddec6d5c2..b0049b3e943 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -77,8 +77,8 @@ def test t9 t9 c25 c25 252 65535 4 Y 144 0 63
def test t9 t9 c26 c26 252 65535 4 Y 16 0 8
def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63
def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8
-def test t9 t9 c29 c29 252 16777215 8 Y 144 0 63
-def test t9 t9 c30 c30 252 16777215 8 Y 16 0 8
+def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63
+def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8
def test t9 t9 c31 c31 254 5 3 Y 256 0 8
def test t9 t9 c32 c32 254 24 7 Y 2048 0 8
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32
@@ -1793,17 +1793,17 @@ def test t5 t5 param02 param02 246 67 32 Y 0 30 63
def test t5 t5 const03 const03 5 17 1 N 32769 31 63
def test t5 t5 param03 param03 5 23 1 Y 32768 31 63
def test t5 t5 const04 const04 253 3 3 N 1 0 8
-def test t5 t5 param04 param04 252 16777215 3 Y 16 0 8
+def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8
def test t5 t5 const05 const05 253 3 3 N 129 0 63
-def test t5 t5 param05 param05 252 16777215 3 Y 144 0 63
+def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63
def test t5 t5 const06 const06 253 10 10 N 1 0 8
-def test t5 t5 param06 param06 252 16777215 10 Y 16 0 8
+def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8
def test t5 t5 const07 const07 10 10 10 Y 128 0 63
-def test t5 t5 param07 param07 252 16777215 10 Y 144 0 63
+def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63
def test t5 t5 const08 const08 253 19 19 N 1 0 8
-def test t5 t5 param08 param08 252 16777215 19 Y 16 0 8
+def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
-def test t5 t5 param09 param09 252 16777215 19 Y 144 0 63
+def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63
def test t5 t5 const10 const10 3 10 9 N 32769 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
@@ -1811,8 +1811,8 @@ def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
def test t5 t5 param13 param13 246 67 0 Y 0 30 63
-def test t5 t5 param14 param14 252 16777215 0 Y 16 0 8
-def test t5 t5 param15 param15 252 16777215 0 Y 144 0 63
+def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8
+def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63
const01 8
param01 8
const02 8.0
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index d02c28a0a97..d0503d1b83b 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2711,3 +2711,38 @@ DROP TABLE t1,t2;
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
16 16 2 2
+CREATE TABLE t1 (
+acct_id int(11) NOT NULL default '0',
+profile_id smallint(6) default NULL,
+UNIQUE KEY t1$acct_id (acct_id),
+KEY t1$profile_id (profile_id)
+);
+INSERT INTO t1 VALUES (132,17),(133,18);
+CREATE TABLE t2 (
+profile_id smallint(6) default NULL,
+queue_id int(11) default NULL,
+seq int(11) default NULL,
+KEY t2$queue_id (queue_id)
+);
+INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
+CREATE TABLE t3 (
+id int(11) NOT NULL default '0',
+qtype int(11) default NULL,
+seq int(11) default NULL,
+warn_lvl int(11) default NULL,
+crit_lvl int(11) default NULL,
+rr1 tinyint(4) NOT NULL default '0',
+rr2 int(11) default NULL,
+default_queue tinyint(4) NOT NULL default '0',
+KEY t3$qtype (qtype),
+KEY t3$id (id)
+);
+INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
+(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
+SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
+WHERE
+(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
+(pq.queue_id = q.id) AND (q.rr1 <> 1);
+COUNT(*)
+4
+drop table t1,t2,t3;
diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test
index 5c1b4127d8c..6894f63fa77 100644
--- a/mysql-test/t/fulltext_order_by.test
+++ b/mysql-test/t/fulltext_order_by.test
@@ -54,3 +54,84 @@ SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1;
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a;
drop table t1;
+# BUG#11869
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ thread int(11) NOT NULL default '0',
+ beitrag longtext NOT NULL,
+ PRIMARY KEY (id),
+ KEY thread (thread),
+ FULLTEXT KEY beitrag (beitrag)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ;
+
+CREATE TABLE t2 (
+ id int(11) NOT NULL auto_increment,
+ text varchar(100) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY text (text)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ;
+
+CREATE TABLE t3 (
+ id int(11) NOT NULL auto_increment,
+ forum int(11) NOT NULL default '0',
+ betreff varchar(70) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY forum (forum),
+ FULLTEXT KEY betreff (betreff)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
+
+--error 1109
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(b.betreff) against ('+abc' in boolean mode)
+group by a.text, b.id, b.betreff
+union
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(c.beitrag) against ('+abc' in boolean mode)
+group by
+ a.text, b.id, b.betreff
+order by
+ match(b.betreff) against ('+abc' in boolean mode) desc;
+
+--error 1109
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(b.betreff) against ('+abc' in boolean mode)
+union
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(c.beitrag) against ('+abc' in boolean mode)
+order by
+ match(b.betreff) against ('+abc' in boolean mode) desc;
+
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(b.betreff) against ('+abc' in boolean mode)
+union
+select a.text, b.id, b.betreff
+from
+ t2 a inner join t3 b on a.id = b.forum inner join
+ t1 c on b.id = c.thread
+where
+ match(c.beitrag) against ('+abc' in boolean mode)
+order by
+ match(betreff) against ('+abc' in boolean mode) desc;
+
+drop table t1,t2,t3;
+
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 2e4bb3e13ad..712658a19a6 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2290,3 +2290,43 @@ DROP TABLE t1,t2;
#
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
+# Test for BUG#11700
+CREATE TABLE t1 (
+ acct_id int(11) NOT NULL default '0',
+ profile_id smallint(6) default NULL,
+ UNIQUE KEY t1$acct_id (acct_id),
+ KEY t1$profile_id (profile_id)
+);
+INSERT INTO t1 VALUES (132,17),(133,18);
+
+CREATE TABLE t2 (
+ profile_id smallint(6) default NULL,
+ queue_id int(11) default NULL,
+ seq int(11) default NULL,
+ KEY t2$queue_id (queue_id)
+);
+INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
+
+CREATE TABLE t3 (
+ id int(11) NOT NULL default '0',
+ qtype int(11) default NULL,
+ seq int(11) default NULL,
+ warn_lvl int(11) default NULL,
+ crit_lvl int(11) default NULL,
+ rr1 tinyint(4) NOT NULL default '0',
+ rr2 int(11) default NULL,
+ default_queue tinyint(4) NOT NULL default '0',
+ KEY t3$qtype (qtype),
+ KEY t3$id (id)
+);
+
+INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
+ (36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
+
+SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
+WHERE
+ (pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
+ (pq.queue_id = q.id) AND (q.rr1 <> 1);
+
+drop table t1,t2,t3;
+
diff --git a/sql/field.cc b/sql/field.cc
index 925fca8ac43..bb035ce5d37 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -47,6 +47,8 @@ uchar Field_null::null[1]={1};
const char field_separator=',';
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320
+#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
+((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
/*
Rules for merging different types of fields in UNION
@@ -6696,7 +6698,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg,uint blob_pack_length,
CHARSET_INFO *cs)
- :Field_longstr(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L,
+ :Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
table_arg, cs),
packlength(blob_pack_length)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 296083b256e..ece2fdc4fb0 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4395,6 +4395,9 @@ bool Item_func_match::fix_index()
if (key == NO_SUCH_KEY)
return 0;
+
+ if (!table)
+ goto err;
for (keynr=0 ; keynr < table->s->keys ; keynr++)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 524fc784422..3d9315a2bd6 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5169,11 +5169,17 @@ static void add_not_null_conds(JOIN *join)
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
Item_field *not_null_item= (Item_field*)item;
JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab;
- Item_func_isnotnull *notnull;
+ Item *notnull;
if (!(notnull= new Item_func_isnotnull(not_null_item)))
DBUG_VOID_RETURN;
-
- notnull->quick_fix_field();
+ /*
+ We need to do full fix_fields() call here in order to have correct
+ notnull->const_item(). This is needed e.g. by test_quick_select
+ when it is called from make_join_select after this function is
+ called.
+ */
+ if (notnull->fix_fields(join->thd, join->tables_list, &notnull))
+ DBUG_VOID_RETURN;
DBUG_EXECUTE("where",print_where(notnull,
referred_tab->table->alias););
add_cond_and_fix(&referred_tab->select_cond, notnull);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 0b88fa1b273..a056814a153 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -698,7 +698,7 @@ static void verify_prepare_field(MYSQL_RES *result,
fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)",
field->org_table, org_table);
fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db);
- fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)",
+ fprintf(stdout, "\n length :`%lu`\t(expected: `%lu`)",
field->length, length * cs->mbmaxlen);
fprintf(stdout, "\n maxlength:`%ld`", field->max_length);
fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr);
@@ -13634,6 +13634,76 @@ static void test_client_character_set()
myquery(rc);
}
+/* Test correct max length for MEDIUMTEXT and LONGTEXT columns */
+
+static void test_bug9735()
+{
+ MYSQL_RES *res;
+ int rc;
+
+ myheader("test_bug9735");
+
+ rc= mysql_query(mysql, "drop table if exists t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "create table t1 (a mediumtext, b longtext) "
+ "character set latin1");
+ myquery(rc);
+ rc= mysql_query(mysql, "select * from t1");
+ myquery(rc);
+ res= mysql_store_result(mysql);
+ verify_prepare_field(res, 0, "a", "a", MYSQL_TYPE_BLOB,
+ "t1", "t1", current_db, (1U << 24)-1, 0);
+ verify_prepare_field(res, 1, "b", "b", MYSQL_TYPE_BLOB,
+ "t1", "t1", current_db, ~0U, 0);
+ mysql_free_result(res);
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+}
+
+
+/* Bug#11183 "mysql_stmt_reset() doesn't reset information about error" */
+
+static void test_bug11183()
+{
+ int rc;
+ MYSQL_STMT *stmt;
+ char bug_statement[]= "insert into t1 values (1)";
+
+ myheader("test_bug11183");
+
+ mysql_query(mysql, "drop table t1 if exists");
+ mysql_query(mysql, "create table t1 (a int)");
+
+ stmt= mysql_stmt_init(mysql);
+ DIE_UNLESS(stmt != 0);
+
+ rc= mysql_stmt_prepare(stmt, bug_statement, strlen(bug_statement));
+ check_execute(stmt, rc);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+
+ /* Trying to execute statement that should fail on execute stage */
+ rc= mysql_stmt_execute(stmt);
+ DIE_UNLESS(rc);
+
+ mysql_stmt_reset(stmt);
+ DIE_UNLESS(mysql_stmt_errno(stmt) == 0);
+
+ mysql_query(mysql, "create table t1 (a int)");
+
+ /* Trying to execute statement that should pass ok */
+ if (mysql_stmt_execute(stmt))
+ {
+ mysql_stmt_reset(stmt);
+ DIE_UNLESS(mysql_stmt_errno(stmt) == 0);
+ }
+
+ mysql_stmt_close(stmt);
+
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+}
/*
Read and parse arguments and MySQL options from my.cnf
@@ -13876,6 +13946,8 @@ static struct my_tests_st my_tests[]= {
{ "test_bug11172", test_bug11172 },
{ "test_bug11656", test_bug11656 },
{ "test_bug10214", test_bug10214 },
+ { "test_bug9735", test_bug9735 },
+ { "test_bug11183", test_bug11183 },
{ 0, 0 }
};