Move USE_PRAGMA_IMPLEMENTATION to proper place

Ensure that 'null_value' is not accessed before val() is called in FIELD() functions
Fixed initialization of key maps. This fixes some problems with keys when you have more than 64 keys
Fixed that ROLLUP don't always create a temporary table. This fix ensures that func_gconcat.test results are now predictable
This commit is contained in:
monty@mysql.com 2005-06-03 23:46:03 +03:00
parent fd17d75923
commit 29fd1f2fd9
47 changed files with 180 additions and 237 deletions

View File

@ -343,18 +343,6 @@ GROUP_CONCAT(b ORDER BY b)
First Row
Second Row
DROP TABLE t1;
CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
a_id b_list
1 1,2,3
2 4,5
3 NULL
DROP TABLE t2;
DROP TABLE t1;
CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID));
INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ');
CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC));
@ -462,15 +450,28 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL;
gc
NULL
DROP TABLE t1;
create table r2 (a int, b int);
insert into r2 values (1,1), (2,2);
select b x, (select group_concat(x) from r2) from r2;
x (select group_concat(x) from r2)
create table t2 (a int, b int);
insert into t2 values (1,1), (2,2);
select b x, (select group_concat(x) from t2) from t2;
x (select group_concat(x) from t2)
1 1,1
2 2,2
drop table r2;
create table t1 (d int, a int, b int, c int);
drop table t2;
create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int);
insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
select d,a,b from t1 order by a;
d a b
1 1 3
2 1 4
3 1 2
5 1 1
6 1 2
4 2 7
7 2 3
8 2 3
explain select a, group_concat(b) from t1 group by a with rollup;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
select a, group_concat(b) from t1 group by a with rollup;
a group_concat(b)
1 3,4,2,1,2

View File

@ -1647,3 +1647,15 @@ CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
ERROR HY000: The used table type doesn't support FULLTEXT indexes
DROP TABLE t1;
CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
a_id b_list
1 1,2,3
2 4,5
3 NULL
DROP TABLE t2;
DROP TABLE t1;

View File

@ -83,7 +83,7 @@ TV NULL NULL 600
NULL NULL NULL 7785
explain extended select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using temporary; Using filesort
1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort
Warnings:
Note 1003 select test.t1.product AS `product`,test.t1.country_id AS `country_id`,test.t1.year AS `year`,sum(test.t1.profit) AS `sum(profit)` from test.t1 group by test.t1.product,test.t1.country_id,test.t1.year with rollup
select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;

View File

@ -213,21 +213,6 @@ INSERT INTO t1 VALUES (1,'First Row'), (2,'Second Row');
SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a;
DROP TABLE t1;
#
# check null values #1
#
--disable_warnings
CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--enable_warnings
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
DROP TABLE t2;
DROP TABLE t1;
#
# check null values #2
#
@ -288,17 +273,19 @@ DROP TABLE t1;
#
# Bug #8656: Crash with group_concat on alias in outer table
#
create table r2 (a int, b int);
insert into r2 values (1,1), (2,2);
select b x, (select group_concat(x) from r2) from r2;
drop table r2;
create table t2 (a int, b int);
insert into t2 values (1,1), (2,2);
select b x, (select group_concat(x) from t2) from t2;
drop table t2;
#
# Bug #7405: problems with rollup
#
create table t1 (d int, a int, b int, c int);
create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int);
insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
select d,a,b from t1 order by a;
explain select a, group_concat(b) from t1 group by a with rollup;
select a, group_concat(b) from t1 group by a with rollup;
select a, group_concat(distinct b) from t1 group by a with rollup;
select a, group_concat(b order by b) from t1 group by a with rollup;

View File

@ -1187,3 +1187,18 @@ CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
--error 1214;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
DROP TABLE t1;
#
# check null values #1
#
--disable_warnings
CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a),
CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--enable_warnings
INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2);
SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz;
DROP TABLE t2;
DROP TABLE t1;

View File

@ -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>

View File

@ -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>

View File

@ -15,13 +15,10 @@
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
#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#ifdef HAVE_BLACKHOLE_DB
#include "ha_blackhole.h"

View File

@ -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"

View File

@ -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

View File

@ -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>
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#ifdef HAVE_ISAM
#include <m_ctype.h>
#include <myisampack.h>

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -20,13 +20,10 @@
NDB Cluster
*/
#include <my_global.h>
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#ifdef HAVE_NDBCLUSTER_DB
#include <my_dir.h>

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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);
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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)

View File

@ -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)
{

View File

@ -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>

View File

@ -16,10 +16,7 @@
/* Compability file */
#include <my_global.h>
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation
#endif
#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif

View File

@ -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 */

View File

@ -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"

View File

@ -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;

View File

@ -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"

View File

@ -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);
};

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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];

View File

@ -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
}
/*

View File

@ -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)

View File

@ -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>

View File

@ -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"

View File

@ -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;
}

View File

@ -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>

View File

@ -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);*/

View File

@ -28,13 +28,10 @@
** 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
#include "mysql_priv.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#include <my_pthread.h>
#ifdef HAVE_DLOPEN

View File

@ -4064,7 +4064,6 @@ replace:
}
insert_field_spec
{}
{}
;
insert_lock_option: