summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2005-06-02 09:50:47 +0200
committerunknown <tomas@poseidon.ndb.mysql.com>2005-06-02 09:50:47 +0200
commitc01a9fc22bbe40dbe36fe31c2d960d81119392d3 (patch)
tree7007e35d5106c2d789cf579e9891c82deca15283
parent815d705f0e7d8ef5d90d592da15c82cf0b4881df (diff)
parentbda8d58d8eb58017c8745a9fac418d87e7e889c5 (diff)
downloadmariadb-git-c01a9fc22bbe40dbe36fe31c2d960d81119392d3.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.1 sql/field.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/log_event.cc: Auto merged sql/opt_range.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_udf.cc: Auto merged
-rw-r--r--client/sql_string.cc3
-rw-r--r--mysql-test/r/func_str.result6
-rw-r--r--mysql-test/r/lowercase_table2.result12
-rw-r--r--mysql-test/r/rpl_failed_optimize.result1
-rw-r--r--mysql-test/t/func_str.test6
-rw-r--r--mysys/raid.cc2
-rw-r--r--sql/examples/ha_archive.cc4
-rw-r--r--sql/examples/ha_example.cc4
-rw-r--r--sql/examples/ha_tina.cc4
-rw-r--r--sql/field.cc2
-rw-r--r--sql/ha_berkeley.cc2
-rw-r--r--sql/ha_blackhole.cc2
-rw-r--r--sql/ha_heap.cc2
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/ha_myisam.cc2
-rw-r--r--sql/ha_myisammrg.cc2
-rw-r--r--sql/ha_ndbcluster.cc2
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/hash_filo.cc2
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_func.cc24
-rw-r--r--sql/item_geofunc.cc2
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/item_timefunc.cc2
-rw-r--r--sql/item_uniq.cc3
-rw-r--r--sql/log_event.cc3
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/procedure.cc2
-rw-r--r--sql/protocol.cc2
-rw-r--r--sql/protocol_cursor.cc2
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_crypt.cc2
-rw-r--r--sql/sql_list.cc2
-rw-r--r--sql/sql_map.cc2
-rw-r--r--sql/sql_olap.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_string.cc3
-rw-r--r--sql/sql_table.cc146
-rw-r--r--sql/sql_udf.cc2
-rw-r--r--sql/tztime.cc12
-rw-r--r--vio/viossl.c45
46 files changed, 242 insertions, 96 deletions
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 51f802e7465..be4354227a5 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -16,11 +16,12 @@
/* This file is originally from the mysql distribution. Coded by monty */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index bbb5a94606e..1c6a4393dfc 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -794,3 +794,9 @@ id aes_decrypt(str, 'bar')
1 foo
2 NULL
DROP TABLE t1, t2;
+select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
+field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
+3 3 3
+select field(NULL,1,2,NULL), field(NULL,1,2,0);
+field(NULL,1,2,NULL) field(NULL,1,2,0)
+0 0
diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result
index 8361b66817a..1015990df9a 100644
--- a/mysql-test/r/lowercase_table2.result
+++ b/mysql-test/r/lowercase_table2.result
@@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` (
RENAME TABLE T1 TO T2;
SHOW TABLES LIKE "T2";
Tables_in_test (T2)
-t2
+T2
SELECT * FROM t2;
a
1
@@ -83,25 +83,25 @@ t3
RENAME TABLE T3 TO T1;
SHOW TABLES LIKE "T1";
Tables_in_test (T1)
-t1
+T1
ALTER TABLE T1 add b int;
SHOW TABLES LIKE "T1";
Tables_in_test (T1)
-t1
+T1
ALTER TABLE T1 RENAME T2;
SHOW TABLES LIKE "T2";
Tables_in_test (T2)
-t2
+T2
LOCK TABLE T2 WRITE;
ALTER TABLE T2 drop b;
SHOW TABLES LIKE "T2";
Tables_in_test (T2)
-t2
+T2
UNLOCK TABLES;
RENAME TABLE T2 TO T1;
SHOW TABLES LIKE "T1";
Tables_in_test (T1)
-t1
+T1
SELECT * from T1;
a
1
diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result
index c7199e56ec8..fd711f89222 100644
--- a/mysql-test/r/rpl_failed_optimize.result
+++ b/mysql-test/r/rpl_failed_optimize.result
@@ -9,6 +9,7 @@ BEGIN;
INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
+test.t1 optimize error Lock wait timeout exceeded; try restarting transaction
test.t1 optimize status Operation failed
Warnings:
Error 1205 Lock wait timeout exceeded; try restarting transaction
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index b3c875f7bf5..728f0e2c084 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -523,3 +523,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
ORDER BY t1.id;
DROP TABLE t1, t2;
+
+#
+# Bug #10944: Mishandling of NULL arguments in FIELD()
+#
+select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
+select field(NULL,1,2,NULL), field(NULL,1,2,0);
diff --git a/mysys/raid.cc b/mysys/raid.cc
index 29819a878c4..a645c0109db 100644
--- a/mysys/raid.cc
+++ b/mysys/raid.cc
@@ -70,6 +70,8 @@
tonu@mysql.com & monty@mysql.com
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc
index f28ba79a00e..1c498d661f0 100644
--- a/sql/examples/ha_archive.cc
+++ b/sql/examples/ha_archive.cc
@@ -14,7 +14,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#ifdef __GNUC__
+#include <my_global.h>
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc
index 562b51878bf..76745e16c5c 100644
--- a/sql/examples/ha_example.cc
+++ b/sql/examples/ha_example.cc
@@ -63,7 +63,9 @@
-Brian
*/
-#ifdef __GNUC__
+#include <my_global.h>
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc
index 9ac446587ec..bfa3622b1af 100644
--- a/sql/examples/ha_tina.cc
+++ b/sql/examples/ha_tina.cc
@@ -38,7 +38,9 @@ TODO:
-Brian
*/
-#ifdef __GNUC__
+#include <my_global.h>
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/field.cc b/sql/field.cc
index aa99b9a31eb..ed9d3e1ecd9 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -19,6 +19,8 @@
** This file implements classes defined in field.h
*****************************************************************************/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 5942973c732..46f510bb905 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -47,6 +47,8 @@
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc
index 6a841801487..00128d3d3b6 100644
--- a/sql/ha_blackhole.cc
+++ b/sql/ha_blackhole.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index cd655eeb0a9..3581b26a585 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index e0ac67f5820..5f4027c1a88 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -27,6 +27,8 @@ have disables the InnoDB inlining in this file. */
in Windows?
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 3f756eab0ee..f66aa025b86 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index ec185c43fb8..c2c754c6d1e 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index dc4f535a186..fc21a634b00 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -20,6 +20,8 @@
NDB Cluster
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/handler.cc b/sql/handler.cc
index 7f57e67c76e..ff9a8e96268 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -17,6 +17,8 @@
/* Handler-calling-functions */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc
index ec200768222..34f3cd6b035 100644
--- a/sql/hash_filo.cc
+++ b/sql/hash_filo.cc
@@ -20,6 +20,8 @@
** to usage.
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item.cc b/sql/item.cc
index 2b132fb1b7e..913c01f5992 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 66f0bf9c395..a7abb5f9be8 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -17,6 +17,8 @@
/* This file defines all compare functions */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 47dffa679e9..3767844e200 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -17,6 +17,8 @@
/* This file defines all numerical functions */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
@@ -2322,11 +2324,15 @@ void Item_func_locate::print(String *str)
longlong Item_func_field::val_int()
{
DBUG_ASSERT(fixed == 1);
+
+ if (args[0]->is_null())
+ return 0;
+
if (cmp_type == STRING_RESULT)
{
String *field;
- if (!(field=args[0]->val_str(&value)))
- return 0; // -1 if null ?
+ if (!(field= args[0]->val_str(&value)))
+ return 0;
for (uint i=1 ; i < arg_count ; i++)
{
String *tmp_value=args[i]->val_str(&tmp);
@@ -2337,20 +2343,16 @@ longlong Item_func_field::val_int()
else if (cmp_type == INT_RESULT)
{
longlong val= args[0]->val_int();
- if (args[0]->is_null())
- return 0;
for (uint i=1; i < arg_count ; i++)
{
- if (val == args[i]->val_int() && ! args[i]->is_null())
- return (longlong) (i);
+ if (!args[i]->is_null() && val == args[i]->val_int())
+ return (longlong) (i);
}
}
else if (cmp_type == DECIMAL_RESULT)
{
my_decimal dec_arg_buf, *dec_arg,
dec_buf, *dec= args[0]->val_decimal(&dec_buf);
- if (args[0]->is_null())
- return 0;
for (uint i=1; i < arg_count; i++)
{
dec_arg= args[i]->val_decimal(&dec_arg_buf);
@@ -2361,12 +2363,10 @@ longlong Item_func_field::val_int()
else
{
double val= args[0]->val_real();
- if (args[0]->is_null())
- return 0;
for (uint i=1; i < arg_count ; i++)
{
- if (val == args[i]->val_real() && ! args[i]->is_null())
- return (longlong) (i);
+ if (!args[i]->is_null() && val == args[i]->val_real())
+ return (longlong) (i);
}
}
return 0;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index e2b0eb5ce07..3173994f90f 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -17,6 +17,8 @@
/* This file defines all spatial functions */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index e870fe5aa43..4808159fe98 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -20,6 +20,8 @@
** (This shouldn't be needed)
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4556f60a659..da9a2140446 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -22,6 +22,8 @@ SUBSELECT TODO:
(sql_select.h/sql_select.cc)
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index b9f3cc49d64..af3828ab2c6 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -17,6 +17,8 @@
/* Sum functions (COUNT, MIN...) */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 3b6ca48fadd..0f2c9a2907d 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -17,6 +17,8 @@
/* This file defines all time functions */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc
index 8734e671817..f6cf83ebb10 100644
--- a/sql/item_uniq.cc
+++ b/sql/item_uniq.cc
@@ -15,6 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Compability file */
+
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation
#endif
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 12104b27dd3..9410a42373a 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -16,6 +16,9 @@
#ifndef MYSQL_CLIENT
+
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index e3672864f7b..3f2ea7ef562 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -36,6 +36,8 @@
QUICK_RANGEs are also created in this step.
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/procedure.cc b/sql/procedure.cc
index 554e2cd0565..38a043300bc 100644
--- a/sql/procedure.cc
+++ b/sql/procedure.cc
@@ -17,6 +17,8 @@
/* Procedures (functions with changes output of select) */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 57922cdc677..8019f3a123b 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -19,6 +19,8 @@
The actual communction is handled by the net_xxx functions in net_serv.cc
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc
index ed2d0b583d0..c38a7cdecae 100644
--- a/sql/protocol_cursor.cc
+++ b/sql/protocol_cursor.cc
@@ -19,6 +19,8 @@
The actual communction is handled by the net_xxx functions in net_serv.cc
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 106fced8e88..5f0db0bd2d5 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -48,6 +48,8 @@
new attribute.
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 6706cee8e9d..55e6dfb3cbe 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -23,6 +23,8 @@
** - type set is out of optimization yet
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 438bfdbcb73..862cf940173 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -22,6 +22,8 @@
**
*****************************************************************************/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc
index f21a109e95d..eda7f0f6bbb 100644
--- a/sql/sql_crypt.cc
+++ b/sql/sql_crypt.cc
@@ -23,6 +23,8 @@
needs something like 'ssh'.
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_list.cc b/sql/sql_list.cc
index d57a7dfe4e3..485c569f49c 100644
--- a/sql/sql_list.cc
+++ b/sql/sql_list.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_map.cc b/sql/sql_map.cc
index 9346f3df305..556d37a405c 100644
--- a/sql/sql_map.cc
+++ b/sql/sql_map.cc
@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index 831b15cf7ef..b349eda0e2e 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -28,6 +28,8 @@
#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2edd8388d9b..32bb1ef8eaf 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -17,6 +17,8 @@
/* mysql_select and join optimization */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 51f802e7465..be4354227a5 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -16,11 +16,12 @@
/* This file is originally from the mysql distribution. Coded by monty */
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7e1e295cb44..98a5a147502 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -40,6 +40,34 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
ha_rows *copied,ha_rows *deleted);
static bool prepare_blob_field(THD *thd, create_field *sql_field);
+
+/*
+ Build the path to a file for a table (or the base path that can
+ then have various extensions stuck on to it).
+
+ SYNOPSIS
+ build_table_path()
+ buff Buffer to build the path into
+ bufflen sizeof(buff)
+ db Name of database
+ table Name of table
+ ext Filename extension
+
+ RETURN
+ 0 Error
+ # Size of path
+ */
+
+static uint build_table_path(char *buff, size_t bufflen, const char *db,
+ const char *table, const char *ext)
+{
+ strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext,
+ NullS);
+ return unpack_filename(buff,buff);
+}
+
+
+
/*
delete (drop) tables.
@@ -223,8 +251,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove form file and isam files */
- strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS);
- (void) unpack_filename(path,path);
+ build_table_path(path, sizeof(path), db, alias, reg_ext);
}
if (drop_temporary ||
(access(path,F_OK) &&
@@ -316,13 +343,10 @@ int quick_rm_table(enum db_type base,const char *db,
{
char path[FN_REFLEN];
int error=0;
- my_snprintf(path, sizeof(path), "%s/%s/%s%s",
- mysql_data_home, db, table_name, reg_ext);
- unpack_filename(path,path);
+ build_table_path(path, sizeof(path), db, table_name, reg_ext);
if (my_delete(path,MYF(0)))
error=1; /* purecov: inspected */
- my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, db, table_name);
- unpack_filename(path,path);
+ build_table_path(path, sizeof(path), db, table_name, "");
return ha_delete_table(current_thd, base, path, table_name, 0) || error;
}
@@ -1516,11 +1540,9 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!create_info->default_table_charset)
{
HA_CREATE_INFO db_info;
- uint length;
char path[FN_REFLEN];
- strxmov(path, mysql_data_home, "/", db, NullS);
- length= unpack_dirname(path,path); // Convert if not unix
- strmov(path+length, MY_DB_OPT_FILE);
+ /* Abuse build_table_path() to build the path to the db.opt file */
+ build_table_path(path, sizeof(path), db, MY_DB_OPT_FILE, "");
load_db_opt(thd, path, &db_info);
create_info->default_table_charset= db_info.default_table_charset;
}
@@ -1534,17 +1556,18 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check if table exists */
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
- my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s",
- mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id,
- thd->tmp_table++, reg_ext);
+ char tmp_table_name[NAME_LEN+1];
+ my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x",
+ tmp_file_prefix, current_pid, thd->thread_id,
+ thd->tmp_table++);
if (lower_case_table_names)
- my_casedn_str(files_charset_info, path);
+ my_casedn_str(files_charset_info, tmp_table_name);
create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
+ build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext);
}
else
- my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, db,
- alias, reg_ext);
- unpack_filename(path,path);
+ build_table_path(path, sizeof(path), db, alias, reg_ext);
+
/* Check if table already exists */
if ((create_info->options & HA_LEX_CREATE_TMP_TABLE)
&& find_temporary_table(thd,db,table_name))
@@ -1782,40 +1805,43 @@ mysql_rename_table(enum db_type base,
const char *new_db,
const char *new_name)
{
- char from[FN_REFLEN], to[FN_REFLEN];
- char tmp_from[NAME_LEN+1], tmp_to[NAME_LEN+1];
+ char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
+ char *from_base= from, *to_base= to;
+ char tmp_name[NAME_LEN+1];
handler *file=(base == DB_TYPE_UNKNOWN ? 0 : get_new_handler((TABLE*) 0, base));
int error=0;
DBUG_ENTER("mysql_rename_table");
+ build_table_path(from, sizeof(from), old_db, old_name, "");
+ build_table_path(to, sizeof(to), new_db, new_name, "");
+
+ /*
+ If lower_case_table_names == 2 (case-preserving but case-insensitive
+ file system) and the storage is not HA_FILE_BASED, we need to provide
+ a lowercase file name, but we leave the .frm in mixed case.
+ */
if (lower_case_table_names == 2 && file &&
!(file->table_flags() & HA_FILE_BASED))
{
- /* Table handler expects to get all file names as lower case */
- strmov(tmp_from, old_name);
- my_casedn_str(files_charset_info, tmp_from);
- old_name= tmp_from;
+ strmov(tmp_name, old_name);
+ my_casedn_str(files_charset_info, tmp_name);
+ build_table_path(lc_from, sizeof(lc_from), old_db, tmp_name, "");
+ from_base= lc_from;
- strmov(tmp_to, new_name);
- my_casedn_str(files_charset_info, tmp_to);
- new_name= tmp_to;
+ strmov(tmp_name, new_name);
+ my_casedn_str(files_charset_info, tmp_name);
+ build_table_path(lc_to, sizeof(lc_to), new_db, tmp_name, "");
+ to_base= lc_to;
}
- my_snprintf(from, sizeof(from), "%s/%s/%s",
- mysql_data_home, old_db, old_name);
- my_snprintf(to, sizeof(to), "%s/%s/%s",
- mysql_data_home, new_db, new_name);
- fn_format(from,from,"","",4);
- fn_format(to,to, "","",4);
- if (!file ||
- !(error=file->rename_table((const char*) from,(const char *) to)))
+ if (!file || !(error=file->rename_table(from_base, to_base)))
{
if (rename_file_ext(from,to,reg_ext))
{
error=my_errno;
/* Restore old file name */
if (file)
- file->rename_table((const char*) to,(const char *) from);
+ file->rename_table(to_base, from_base);
}
}
delete file;
@@ -1992,8 +2018,8 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list,
if (!(table= table_list->table)) /* if open_ltable failed */
{
char name[FN_REFLEN];
- strxmov(name, mysql_data_home, "/", table_list->db, "/",
- table_list->table_name, NullS);
+ build_table_path(name, sizeof(name), table_list->db,
+ table_list->table_name, "");
if (openfrm(thd, name, "", 0, 0, 0, &tmp_table))
DBUG_RETURN(0); // Can't open frm file
table= &tmp_table;
@@ -2328,6 +2354,28 @@ send_result_message:
((result_code= table->table->file->analyze(thd, check_opt)) > 0))
result_code= 0; // analyze went ok
}
+ if (result_code) // either mysql_recreate_table or analyze failed
+ {
+ const char *err_msg;
+ if ((err_msg= thd->net.last_error))
+ {
+ if (!thd->vio_ok())
+ {
+ sql_print_error(err_msg);
+ }
+ else
+ {
+ /* Hijack the row already in-progress. */
+ protocol->store("error", 5, system_charset_info);
+ protocol->store(err_msg, system_charset_info);
+ (void)protocol->write();
+ /* Start off another row for HA_ADMIN_FAILED */
+ protocol->prepare_for_resend();
+ protocol->store(table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
+ }
+ }
+ }
result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK;
table->next_local= save_next_local;
table->next_global= save_next_global;
@@ -2859,11 +2907,10 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
else
{
if (table->file->add_index(table, key_info_buffer, key_count)||
- (my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home,
- table_list->db, (lower_case_table_names == 2) ?
- table_list->alias: table_list->table_name, reg_ext) >=
- (int) sizeof(path)) ||
- ! unpack_filename(path, path) ||
+ build_table_path(path, sizeof(path), table_list->db,
+ (lower_case_table_names == 2) ?
+ table_list->alias : table_list->table_name,
+ reg_ext) != 0 ||
mysql_create_frm(thd, path, &create_info,
fields, key_count, key_info_buffer, table->file))
/* don't need to free((gptr) key_info_buffer);*/
@@ -2961,11 +3008,10 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
&keys, /*tmp_table*/ 0, &db_options, table->file,
&key_info_buffer, key_count,
/*select_field_count*/ 0)||
- (snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home,
- table_list->db, (lower_case_table_names == 2)?
- table_list->alias: table_list->table_name, reg_ext)>=
- (int)sizeof(path))||
- ! unpack_filename(path, path)||
+ build_table_path(path, sizeof(path), table_list->db,
+ (lower_case_table_names == 2) ?
+ table_list->alias : table_list->table_name,
+ reg_ext) != 0 ||
mysql_create_frm(thd, path, &create_info,
fields, key_count, key_info_buffer, table->file))
/*don't need to free((gptr) key_numbers);*/
@@ -3719,9 +3765,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
shutdown.
*/
char path[FN_REFLEN];
- my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home,
- new_db, table_name);
- fn_format(path,path,"","",4);
+ build_table_path(path, sizeof(path), new_db, table_name, "");
table=open_temporary_table(thd, path, new_db, tmp_name,0);
if (table)
{
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 556c49901da..7f90defab13 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -28,6 +28,8 @@
dynamic functions, so this shouldn't be a real problem.
*/
+#include <my_global.h>
+
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: implement sql_udf.h
#endif
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 11cdf64de29..a52b9701e8e 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -20,18 +20,20 @@
(We will refer to this code as to elsie-code further.)
*/
-#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
-#endif
-
/*
We should not include mysql_priv.h in mysql_tzinfo_to_sql utility since
it creates unsolved link dependencies on some platforms.
*/
+
+#include <my_global.h>
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
+#pragma implementation // gcc: Class implementation
+#endif
+
#if !defined(TZINFO2SQL) && !defined(TESTTIME)
#include "mysql_priv.h"
#else
-#include <my_global.h>
#include <my_time.h>
#include "tztime.h"
#include <my_sys.h>
diff --git a/vio/viossl.c b/vio/viossl.c
index 4233b276346..9a5eb1eb8df 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -128,26 +128,32 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size)
int vio_ssl_fastsend(Vio * vio __attribute__((unused)))
{
- int r= 0;
+ int r=0;
DBUG_ENTER("vio_ssl_fastsend");
-#ifdef IPTOS_THROUGHPUT
+#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__)
{
-#ifndef __EMX__
- int tos = IPTOS_THROUGHPUT;
- if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)))
-#endif /* !__EMX__ */
- {
- int nodelay = 1;
- if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay,
- sizeof(nodelay))) {
- DBUG_PRINT("warning",
- ("Couldn't set socket option for fast send"));
- r= -1;
- }
- }
+ int tos= IPTOS_THROUGHPUT;
+ r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos));
+ }
+#endif /* IPTOS_THROUGHPUT && !__EMX__ */
+ if (!r)
+ {
+#ifdef __WIN__
+ BOOL nodelay= 1;
+ r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay,
+ sizeof(nodelay));
+#else
+ int nodelay= 1;
+ r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay,
+ sizeof(nodelay));
+#endif /* __WIN__ */
+ }
+ if (r)
+ {
+ DBUG_PRINT("warning", ("Couldn't set socket option for fast send"));
+ r= -1;
}
-#endif /* IPTOS_THROUGHPUT */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
@@ -427,6 +433,11 @@ void vio_ssl_timeout(Vio *vio __attribute__((unused)),
uint which __attribute__((unused)),
uint timeout __attribute__((unused)))
{
- /* Not yet implemented (non critical) */
+#ifdef __WIN__
+ ulong wait_timeout= (ulong) timeout * 1000;
+ (void) setsockopt(vio->sd, SOL_SOCKET,
+ which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout,
+ sizeof(wait_timeout));
+#endif /* __WIN__ */
}
#endif /* HAVE_OPENSSL */