summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc5
-rw-r--r--sql/ha_berkeley.cc5
-rw-r--r--sql/ha_blackhole.cc7
-rw-r--r--sql/ha_heap.cc5
-rw-r--r--sql/ha_innodb.cc5
-rw-r--r--sql/ha_isam.cc8
-rw-r--r--sql/ha_isammrg.cc5
-rw-r--r--sql/ha_myisam.cc5
-rw-r--r--sql/ha_myisammrg.cc5
-rw-r--r--sql/ha_ndbcluster.cc7
-rw-r--r--sql/handler.cc5
-rw-r--r--sql/hash_filo.cc5
-rw-r--r--sql/item.cc5
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--sql/item_func.cc16
-rw-r--r--sql/item_geofunc.cc5
-rw-r--r--sql/item_strfunc.cc5
-rw-r--r--sql/item_subselect.cc5
-rw-r--r--sql/item_sum.cc5
-rw-r--r--sql/item_timefunc.cc5
-rw-r--r--sql/item_uniq.cc7
-rw-r--r--sql/log_event.cc4
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/opt_range.cc5
-rw-r--r--sql/opt_range.h8
-rw-r--r--sql/procedure.cc5
-rw-r--r--sql/protocol.cc5
-rw-r--r--sql/protocol_cursor.cc5
-rw-r--r--sql/set_var.cc5
-rw-r--r--sql/sql_analyse.cc5
-rw-r--r--sql/sql_class.cc5
-rw-r--r--sql/sql_crypt.cc5
-rw-r--r--sql/sql_insert.cc8
-rw-r--r--sql/sql_list.cc5
-rw-r--r--sql/sql_map.cc5
-rw-r--r--sql/sql_olap.cc5
-rw-r--r--sql/sql_select.cc90
-rw-r--r--sql/sql_string.cc2
-rw-r--r--sql/sql_table.cc8
-rw-r--r--sql/sql_udf.cc7
-rw-r--r--sql/sql_yacc.yy1
42 files changed, 121 insertions, 193 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 21c3fe12bb2..292bbe80362 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -19,13 +19,10 @@
** This file implements classes defined in field.h
*****************************************************************************/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "sql_select.h"
#include <m_ctype.h>
#include <errno.h>
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index d4adea4a7b4..35a137df97b 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -47,13 +47,10 @@
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#ifdef HAVE_BERKELEY_DB
#include <m_ctype.h>
#include <myisampack.h>
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc
index a5456d54c1b..109098948ac 100644
--- a/sql/ha_blackhole.cc
+++ b/sql/ha_blackhole.cc
@@ -15,14 +15,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
+#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
#ifdef HAVE_BLACKHOLE_DB
#include "ha_blackhole.h"
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index ef0d0022860..ad0e8819842 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <myisampack.h>
#include "ha_heap.h"
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index b3b82df5469..2016f58083a 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -28,13 +28,10 @@ have disables the InnoDB inlining in this file. */
in Windows?
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "slave.h"
#ifdef HAVE_INNOBASE_DB
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc
index b755c63698f..b074edf719d 100644
--- a/sql/ha_isam.cc
+++ b/sql/ha_isam.cc
@@ -14,14 +14,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
+#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#ifdef HAVE_ISAM
#include <m_ctype.h>
#include <myisampack.h>
diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc
index 7e14ccb43bf..f6fe1a49e9e 100644
--- a/sql/ha_isammrg.cc
+++ b/sql/ha_isammrg.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#ifdef HAVE_ISAM
#include <m_ctype.h>
#ifndef MASTER
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index b4ac8cc777f..34e6c429a8f 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include <myisampack.h>
#include "ha_myisam.h"
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 3374ee1271a..1f9e6a71d16 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include "ha_myisammrg.h"
#ifndef MASTER
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 516703112dd..d361bec8fcc 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -20,14 +20,11 @@
NDB Cluster
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
+#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
#ifdef HAVE_NDBCLUSTER_DB
#include <my_dir.h>
#include "ha_ndbcluster.h"
diff --git a/sql/handler.cc b/sql/handler.cc
index d47bb02a58c..d9db1afff7a 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -17,13 +17,10 @@
/* Handler-calling-functions */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "ha_heap.h"
#include "ha_myisam.h"
#include "ha_myisammrg.h"
diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc
index 34f3cd6b035..a16ff6ac7be 100644
--- a/sql/hash_filo.cc
+++ b/sql/hash_filo.cc
@@ -20,11 +20,8 @@
** to usage.
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "hash_filo.h"
diff --git a/sql/item.cc b/sql/item.cc
index d32a6581049..96fa1a8fac4 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include "my_dir.h"
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index f53dcb43e5c..b17c4a9fbf7 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -17,13 +17,10 @@
/* This file defines all compare functions */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include "sql_select.h"
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ad8479c7b0b..2d16ef5e183 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -17,13 +17,10 @@
/* This file defines all numerical functions */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "slave.h" // for wait_for_master_pos
#include <m_ctype.h>
#include <hash.h>
@@ -1491,9 +1488,6 @@ longlong Item_func_field::val_int()
{
DBUG_ASSERT(fixed == 1);
- if (args[0]->null_value)
- return 0;
-
if (cmp_type == STRING_RESULT)
{
String *field;
@@ -1509,18 +1503,22 @@ longlong Item_func_field::val_int()
else if (cmp_type == INT_RESULT)
{
longlong val= args[0]->val_int();
+ if (args[0]->null_value)
+ return 0;
for (uint i=1; i < arg_count ; i++)
{
- if (!args[i]->null_value && val == args[i]->val_int())
+ if (val == args[i]->val_int() && !args[i]->null_value)
return (longlong) (i);
}
}
else
{
double val= args[0]->val();
+ if (args[0]->null_value)
+ return 0;
for (uint i=1; i < arg_count ; i++)
{
- if (!args[i]->null_value && val == args[i]->val())
+ if (val == args[i]->val() && !args[i]->null_value)
return (longlong) (i);
}
}
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index e907c5a0d45..9dbc1724824 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -17,14 +17,11 @@
/* This file defines all spatial functions */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
#ifdef HAVE_SPATIAL
#include <m_ctype.h>
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 725712f4e85..56b06cb02c4 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -20,13 +20,10 @@
** (This shouldn't be needed)
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#ifdef HAVE_OPENSSL
#include <openssl/des.h>
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f7defd96b04..9bd9eff5ef7 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -22,13 +22,10 @@ SUBSELECT TODO:
(sql_select.h/sql_select.cc)
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "sql_select.h"
inline Item * and_items(Item* cond, Item *item)
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 9c35fb1d427..5c34dc6a603 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -17,14 +17,11 @@
/* Sum functions (COUNT, MIN...) */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
Item_sum::Item_sum(List<Item> &list)
:arg_count(list.elements)
{
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 9f5cd61f95a..b7f9236ce46 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -17,13 +17,10 @@
/* This file defines all time functions */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include <time.h>
diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc
index c83373bd8b0..8e9653aba88 100644
--- a/sql/item_uniq.cc
+++ b/sql/item_uniq.cc
@@ -16,10 +16,7 @@
/* Compability file */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation
+#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 9701ef2ff00..866a7c21bb4 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -17,12 +17,10 @@
#ifndef MYSQL_CLIENT
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
#include "slave.h"
#include <my_dir.h>
#endif /* MYSQL_CLIENT */
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 5b9e81620ce..0d058190a46 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -37,7 +37,7 @@ typedef ulong key_part_map; /* Used for finding key parts */
/* useful constants */
extern const key_map key_map_empty;
-extern const key_map key_map_full;
+extern key_map key_map_full; /* Should be threaded as const */
extern const char *primary_key_name;
#include "mysql_com.h"
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5e3142ccf0e..44b91fd3530 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -351,6 +351,9 @@ char mysql_real_data_home[FN_REFLEN],
*opt_init_connect, *opt_init_slave,
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
+const key_map key_map_empty(0);
+key_map key_map_full(0); // Will be initialized later
+
const char *opt_date_time_formats[3];
char *language_ptr, *default_collation_name, *default_character_set_name;
@@ -5677,6 +5680,7 @@ static void mysql_init_variables(void)
mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
bzero((gptr) &com_stat, sizeof(com_stat));
+ key_map_full.set_all();
/* Character sets */
system_charset_info= &my_charset_utf8_general_ci;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 7b37f0ce4f7..4b6e56468d2 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -23,13 +23,10 @@
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include <nisam.h>
#include "sql_select.h"
diff --git a/sql/opt_range.h b/sql/opt_range.h
index b55bb4708bf..87e0315a09e 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -143,10 +143,14 @@ class SQL_SELECT :public Sql_alloc {
~SQL_SELECT();
void cleanup();
bool check_quick(THD *thd, bool force_quick_range, ha_rows limit)
- { return test_quick_select(thd, key_map(~(uint)0), 0, limit, force_quick_range) < 0; }
+ {
+ key_map tmp;
+ tmp.set_all();
+ return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0;
+ }
inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; }
int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
- ha_rows limit, bool force_quick_range=0);
+ ha_rows limit, bool force_quick_range);
};
diff --git a/sql/procedure.cc b/sql/procedure.cc
index 10689dd36f6..bd742f645d2 100644
--- a/sql/procedure.cc
+++ b/sql/procedure.cc
@@ -17,13 +17,10 @@
/* Procedures (functions with changes output of select) */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "procedure.h"
#include "sql_analyse.h" // Includes procedure
#ifdef USE_PROC_RANGE
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 835bd986fb8..9a1a05591dd 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -19,13 +19,10 @@
The actual communction is handled by the net_xxx functions in net_serv.cc
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <stdarg.h>
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc
index 53a03001544..bb6a0eab2ee 100644
--- a/sql/protocol_cursor.cc
+++ b/sql/protocol_cursor.cc
@@ -19,13 +19,10 @@
The actual communction is handled by the net_xxx functions in net_serv.cc
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <mysql.h>
bool Protocol_cursor::send_fields(List<Item> *list, uint flag)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 5564ba096ac..b89cdffd4cb 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -48,13 +48,10 @@
new attribute.
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <mysql.h>
#include "slave.h"
#include <my_getopt.h>
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 678bdbb4588..df66b3c4228 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -23,13 +23,10 @@
** - type set is out of optimization yet
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "procedure.h"
#include "sql_analyse.h"
#include <m_ctype.h>
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index ff45b164893..fff1e3a3b54 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -22,13 +22,10 @@
**
*****************************************************************************/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <m_ctype.h>
#include <sys/stat.h>
#include <thr_alarm.h>
diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc
index eda7f0f6bbb..1cfa0eb8570 100644
--- a/sql/sql_crypt.cc
+++ b/sql/sql_crypt.cc
@@ -23,14 +23,11 @@
needs something like 'ssh'.
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
SQL_CRYPT::SQL_CRYPT(const char *password)
{
ulong rand_nr[2];
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index b4021943967..718e6b00ddc 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -752,7 +752,7 @@ public:
volatile bool status,dead;
COPY_INFO info;
I_List<delayed_row> rows;
- uint group_count;
+ ulong group_count;
TABLE_LIST table_list; // Argument
delayed_insert()
@@ -1420,7 +1420,7 @@ static void free_delayed_insert_blobs(register TABLE *table)
bool delayed_insert::handle_inserts(void)
{
int error;
- uint max_rows;
+ ulong max_rows;
bool using_ignore=0, using_bin_log=mysql_bin_log.is_open();
delayed_row *row;
DBUG_ENTER("handle_inserts");
@@ -1439,11 +1439,11 @@ bool delayed_insert::handle_inserts(void)
}
thd.proc_info="insert";
- max_rows=delayed_insert_limit;
+ max_rows= delayed_insert_limit;
if (thd.killed || table->version != refresh_version)
{
thd.killed=1;
- max_rows= ~(uint)0; // Do as much as possible
+ max_rows= ~(ulong)0; // Do as much as possible
}
/*
diff --git a/sql/sql_list.cc b/sql/sql_list.cc
index 485c569f49c..219ff85946e 100644
--- a/sql/sql_list.cc
+++ b/sql/sql_list.cc
@@ -15,14 +15,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
-
list_node end_of_list;
void free_list(I_List <i_string_pair> *list)
diff --git a/sql/sql_map.cc b/sql/sql_map.cc
index 9baacd1bc4b..408938e7639 100644
--- a/sql/sql_map.cc
+++ b/sql/sql_map.cc
@@ -15,13 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#ifdef HAVE_MMAP
#include <sys/mman.h>
#include <sys/stat.h>
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index a365cbb0614..5631cf9dcef 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -28,13 +28,10 @@
#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "sql_select.h"
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9661c0c13c9..38e54ed7104 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -17,13 +17,10 @@
/* mysql_select and join optimization */
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include "sql_select.h"
#include <m_ctype.h>
@@ -35,9 +32,6 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"ref_or_null","unique_subquery","index_subquery"
};
-const key_map key_map_empty(0);
-const key_map key_map_full(~(uint)0);
-
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
DYNAMIC_ARRAY *keyuse);
@@ -66,7 +60,7 @@ static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables);
static void update_depend_map(JOIN *join);
static void update_depend_map(JOIN *join, ORDER *order);
static ORDER *remove_const(JOIN *join,ORDER *first_order,COND *cond,
- bool *simple_order);
+ bool change_list, bool *simple_order);
static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables,
List<Item> &fields, bool send_row,
uint select_options, const char *info,
@@ -613,7 +607,7 @@ JOIN::optimize()
/* Optimize distinct away if possible */
{
ORDER *org_order= order;
- order=remove_const(this, order,conds,&simple_order);
+ order=remove_const(this, order,conds,1, &simple_order);
/*
If we are using ORDER BY NULL or ORDER BY const_expression,
return result in any order (even if we are using a GROUP BY)
@@ -681,8 +675,9 @@ JOIN::optimize()
DBUG_RETURN(1);
}
simple_group= 0;
- if (rollup.state == ROLLUP::STATE_NONE)
- group_list= remove_const(this, group_list, conds, &simple_group);
+ group_list= remove_const(this, group_list, conds,
+ rollup.state == ROLLUP::STATE_NONE,
+ &simple_group);
if (!group_list && group)
{
order=0; // The output has only one row
@@ -694,7 +689,7 @@ JOIN::optimize()
if (procedure && procedure->group)
{
group_list= procedure->group= remove_const(this, procedure->group, conds,
- &simple_group);
+ 1, &simple_group);
calc_group_buffer(this, group_list);
}
@@ -1638,8 +1633,8 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
{
select->head=table;
table->reginfo.impossible_range=0;
- if ((error=select->test_quick_select(thd, *(key_map *)keys,(table_map) 0,
- limit)) == 1)
+ if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0,
+ limit, 0)) == 1)
DBUG_RETURN(select->quick->records);
if (error == -1)
{
@@ -3452,7 +3447,8 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
join_tab->select_cond=0;
join_tab->quick=0;
join_tab->type= JT_ALL; /* Map through all records */
- join_tab->keys.init(~(uint)0); /* test everything in quick */
+ join_tab->keys.init();
+ join_tab->keys.set_all(); /* test everything in quick */
join_tab->info=0;
join_tab->on_expr=0;
join_tab->ref.key = -1;
@@ -3684,7 +3680,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
(join->select_options &
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
- join->unit->select_limit_cnt)) < 0)
+ join->unit->select_limit_cnt), 0) < 0)
{
/*
Before reporting "Impossible WHERE" for the whole query
@@ -3697,7 +3693,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
(join->select_options &
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
- join->unit->select_limit_cnt)) < 0)
+ join->unit->select_limit_cnt),0) < 0)
DBUG_RETURN(1); // Impossible WHERE
}
else
@@ -4200,20 +4196,39 @@ static void update_depend_map(JOIN *join, ORDER *order)
/*
- simple_order is set to 1 if sort_order only uses fields from head table
- and the head table is not a LEFT JOIN table
+ Remove all constants and check if ORDER only contains simple expressions
+
+ SYNOPSIS
+ remove_const()
+ join Join handler
+ first_order List of SORT or GROUP order
+ cond WHERE statement
+ change_list Set to 1 if we should remove things from list
+ If this is not set, then only simple_order is
+ calculated
+ simple_order Set to 1 if we are only using simple expressions
+
+ RETURN
+ Returns new sort order
+
+ simple_order is set to 1 if sort_order only uses fields from head table
+ and the head table is not a LEFT JOIN table
+
*/
static ORDER *
-remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order)
+remove_const(JOIN *join,ORDER *first_order, COND *cond,
+ bool change_list, bool *simple_order)
{
if (join->tables == join->const_tables)
- return 0; // No need to sort
- DBUG_ENTER("remove_const");
+ return change_list ? 0 : first_order; // No need to sort
+
ORDER *order,**prev_ptr;
table_map first_table= join->join_tab[join->const_tables].table->map;
table_map not_const_tables= ~join->const_table_map;
table_map ref;
+ DBUG_ENTER("remove_const");
+
prev_ptr= &first_order;
*simple_order= join->join_tab[join->const_tables].on_expr ? 0 : 1;
@@ -4244,7 +4259,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order)
}
if ((ref=order_tables & (not_const_tables ^ first_table)))
{
- if (!(order_tables & first_table) && only_eq_ref_tables(join,first_order,ref))
+ if (!(order_tables & first_table) &&
+ only_eq_ref_tables(join,first_order, ref))
{
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
continue;
@@ -4253,11 +4269,13 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order)
}
}
}
- *prev_ptr= order; // use this entry
+ if (change_list)
+ *prev_ptr= order; // use this entry
prev_ptr= &order->next;
}
- *prev_ptr=0;
- if (!first_order) // Nothing to sort/group
+ if (change_list)
+ *prev_ptr=0;
+ if (prev_ptr == &first_order) // Nothing to sort/group
*simple_order=1;
DBUG_PRINT("exit",("simple_order: %d",(int) *simple_order));
DBUG_RETURN(first_order);
@@ -6357,7 +6375,7 @@ test_if_quick_select(JOIN_TAB *tab)
delete tab->select->quick;
tab->select->quick=0;
return tab->select->test_quick_select(tab->join->thd, tab->keys,
- (table_map) 0, HA_POS_ERROR);
+ (table_map) 0, HA_POS_ERROR, 0);
}
@@ -7352,12 +7370,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
parameres are set correctly by the range optimizer.
*/
key_map new_ref_key_map;
- new_ref_key_map.clear_all(); /* Force the creation of quick select */
- new_ref_key_map.set_bit(new_ref_key); /* only for new_ref_key. */
+ new_ref_key_map.clear_all(); // Force the creation of quick select
+ new_ref_key_map.set_bit(new_ref_key); // only for new_ref_key.
if (select->test_quick_select(tab->join->thd, new_ref_key_map, 0,
- (tab->join->select_options & OPTION_FOUND_ROWS) ?
- HA_POS_ERROR : tab->join->unit->select_limit_cnt) <= 0)
+ (tab->join->select_options &
+ OPTION_FOUND_ROWS) ?
+ HA_POS_ERROR :
+ tab->join->unit->select_limit_cnt,0) <=
+ 0)
DBUG_RETURN(0);
}
ref_key= new_ref_key;
@@ -8902,6 +8923,8 @@ bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_fields,
for (uint i=0 ; i <= send_group_parts ;i++)
sum_funcs_end[i]= func;
}
+ else if (rollup.state == ROLLUP::STATE_READY)
+ DBUG_RETURN(FALSE); // Don't put end marker
*func=0; // End marker
DBUG_RETURN(FALSE);
}
@@ -9415,9 +9438,10 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
This is an element that is used by the GROUP BY and should be
set to NULL in this level
*/
+ Item_null_result *null_item;
item->maybe_null= 1; // Value will be null sometimes
- Item_null_result *null_item= rollup.null_items[i];
- null_item->result_field= ((Item_field *) item)->result_field;
+ null_item= rollup.null_items[i];
+ null_item->result_field= item->get_tmp_table_field();
item= null_item;
break;
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index e5339782f02..983c2d90a1d 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -17,11 +17,9 @@
/* 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_sys.h>
#include <m_string.h>
#include <m_ctype.h>
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7e80a71beb0..3aa6da7ad0c 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -325,7 +325,7 @@ int quick_rm_table(enum db_type base,const char *db,
build_table_path(path, sizeof(path), db, table_name, reg_ext);
if (my_delete(path,MYF(0)))
error=1; /* purecov: inspected */
- build_table_path(path, sizeof(path), db, table_name, "");
+ *fn_ext(path)= 0; // Remove reg_ext
return ha_delete_table(base,path) || error;
}
@@ -1339,7 +1339,7 @@ int 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)
{
- char tmp_table_name[NAME_LEN+1];
+ char tmp_table_name[tmp_file_prefix_length+22+22+22+3];
my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x",
tmp_file_prefix, current_pid, thd->thread_id,
thd->tmp_table++);
@@ -2622,7 +2622,7 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
build_table_path(path, sizeof(path), table_list->db,
(lower_case_table_names == 2) ?
table_list->alias : table_list->real_name,
- reg_ext) != 0 ||
+ 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);*/
@@ -2723,7 +2723,7 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
build_table_path(path, sizeof(path), table_list->db,
(lower_case_table_names == 2) ?
table_list->alias : table_list->real_name,
- reg_ext) != 0 ||
+ 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);*/
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index deed806db2a..72c92a5c53a 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -28,13 +28,10 @@
** dynamic functions, so this shouldn't be a real problem.
*/
-#include <my_global.h>
-
+#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: implement sql_udf.h
+#pragma implementation // gcc: Class implementation
#endif
-
-#include "mysql_priv.h"
#include <my_pthread.h>
#ifdef HAVE_DLOPEN
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7585f0b10a0..bc21649fe54 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4064,7 +4064,6 @@ replace:
}
insert_field_spec
{}
- {}
;
insert_lock_option: