Commit 531b847f authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
parents 06c17bac 3612707c
...@@ -342,7 +342,7 @@ static struct my_option my_long_options[] = ...@@ -342,7 +342,7 @@ static struct my_option my_long_options[] =
{"result-file", 'r', {"result-file", 'r',
"Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).", "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"routines", 'R', "Dump routines FUNCTIONS and PROCEDURES.", {"routines", 'R', "Dump stored routines (functions and procedures).",
(gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL, (gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET, {"set-charset", OPT_SET_CHARSET,
......
...@@ -118,15 +118,12 @@ extern "C" { ...@@ -118,15 +118,12 @@ extern "C" {
/* do not use the extended time in LibC sys\stat.h */ /* do not use the extended time in LibC sys\stat.h */
#define _POSIX_SOURCE #define _POSIX_SOURCE
/* Kernel call on NetWare that will only yield if our time slice is up */
void kYieldIfTimeSliceUp(void);
/* Some macros for portability */ /* Some macros for portability */
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time(NULL)+(SEC); (ABSTIME).tv_nsec=0; } #define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time(NULL)+(SEC); (ABSTIME).tv_nsec=0; }
/* extra protection against CPU Hogs on NetWare */ /* extra protection against CPU Hogs on NetWare */
#define NETWARE_YIELD kYieldIfTimeSliceUp() #define NETWARE_YIELD pthread_yield()
/* Screen mode for help texts */ /* Screen mode for help texts */
#define NETWARE_SET_SCREEN_MODE(A) setscreenmode(A) #define NETWARE_SET_SCREEN_MODE(A) setscreenmode(A)
......
...@@ -115,3 +115,29 @@ select * from t1 procedure analyse (1,1); ...@@ -115,3 +115,29 @@ select * from t1 procedure analyse (1,1);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL
drop table t1; drop table t1;
create table t1 (product varchar(32), country_id int not null, year int,
profit int);
insert into t1 values ( 'Computer', 2,2000, 1200),
( 'TV', 1, 1999, 150),
( 'Calculator', 1, 1999,50),
( 'Computer', 1, 1999,1500),
( 'Computer', 1, 2000,1500),
( 'TV', 1, 2000, 150),
( 'TV', 2, 2000, 100),
( 'TV', 2, 2000, 100),
( 'Calculator', 1, 2000,75),
( 'Calculator', 2, 2000,75),
( 'TV', 1, 1999, 100),
( 'Computer', 1, 1999,1200),
( 'Computer', 2, 2000,1500),
( 'Calculator', 2, 2000,75),
( 'Phone', 3, 2003,10)
;
create table t2 (country_id int primary key, country char(20) not null);
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.product Computer TV 2 8 0 0 4.2500 NULL ENUM('Computer','Phone','TV') NOT NULL
sum(profit) 10 6900 2 4 0 0 1946 2868 ENUM('10','275','600','6900') NOT NULL
avg(profit) 10.0000 1380.0000 7 9 0 0 394.6875 570.2003 ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
drop table t1,t2;
...@@ -641,3 +641,16 @@ create table if not exists t1 (a int); ...@@ -641,3 +641,16 @@ create table if not exists t1 (a int);
Warnings: Warnings:
Note 1050 Table 't1' already exists Note 1050 Table 't1' already exists
drop table t1; drop table t1;
create table t1 (
a varchar(112) charset utf8 collate utf8_bin not null,
primary key (a)
) select 'test' as a ;
Warnings:
Warning 1364 Field 'a' doesn't have a default value
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(112) character set utf8 collate utf8_bin NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
...@@ -170,6 +170,12 @@ insert into t1 values (1); ...@@ -170,6 +170,12 @@ insert into t1 values (1);
select rand(i) from t1; select rand(i) from t1;
ERROR HY000: Incorrect arguments to RAND ERROR HY000: Incorrect arguments to RAND
drop table t1; drop table t1;
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
a
http://www.foo.com/
drop table t1;
set sql_mode='traditional'; set sql_mode='traditional';
select ln(-1); select ln(-1);
ln(-1) ln(-1)
......
...@@ -176,7 +176,7 @@ Table Create Table ...@@ -176,7 +176,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(3,0) unsigned NOT NULL default '0', `round(15.4,-1)` decimal(3,0) unsigned NOT NULL default '0',
`truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0', `truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0',
`abs(-1.1)` decimal(2,1) NOT NULL default '0.0', `abs(-1.1)` decimal(2,1) default NULL,
`-(-1.1)` decimal(2,1) NOT NULL default '0.0' `-(-1.1)` decimal(2,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
......
...@@ -65,5 +65,30 @@ insert into t1 values (100000); ...@@ -65,5 +65,30 @@ insert into t1 values (100000);
select * from t1 procedure analyse (1,1); select * from t1 procedure analyse (1,1);
drop table t1; drop table t1;
#
# Bug #14138 ROLLUP and PROCEDURE ANALYSE() hang server
#
create table t1 (product varchar(32), country_id int not null, year int,
profit int);
insert into t1 values ( 'Computer', 2,2000, 1200),
( 'TV', 1, 1999, 150),
( 'Calculator', 1, 1999,50),
( 'Computer', 1, 1999,1500),
( 'Computer', 1, 2000,1500),
( 'TV', 1, 2000, 150),
( 'TV', 2, 2000, 100),
( 'TV', 2, 2000, 100),
( 'Calculator', 1, 2000,75),
( 'Calculator', 2, 2000,75),
( 'TV', 1, 1999, 100),
( 'Computer', 1, 1999,1200),
( 'Computer', 2, 2000,1500),
( 'Calculator', 2, 2000,75),
( 'Phone', 3, 2003,10)
;
create table t2 (country_id int primary key, country char(20) not null);
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
drop table t1,t2;
# End of 4.1 tests # End of 4.1 tests
...@@ -545,4 +545,13 @@ create table t1 (a int); ...@@ -545,4 +545,13 @@ create table t1 (a int);
create table if not exists t1 (a int); create table if not exists t1 (a int);
drop table t1; drop table t1;
# BUG#14139
create table t1 (
a varchar(112) charset utf8 collate utf8_bin not null,
primary key (a)
) select 'test' as a ;
--warning 1364
show create table t1;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -15,5 +15,4 @@ rpl_relayrotate : Unstable test case, bug#12429 ...@@ -15,5 +15,4 @@ rpl_relayrotate : Unstable test case, bug#12429
rpl_until : Unstable test case, bug#12429 rpl_until : Unstable test case, bug#12429
rpl_deadlock : Unstable test case, bug#12429 rpl_deadlock : Unstable test case, bug#12429
kill : Unstable test case, bug#9712 kill : Unstable test case, bug#9712
federated : Broken test case, bug#14272
archive_gis : The test fails on 32bit Linux archive_gis : The test fails on 32bit Linux
...@@ -116,6 +116,16 @@ insert into t1 values (1); ...@@ -116,6 +116,16 @@ insert into t1 values (1);
select rand(i) from t1; select rand(i) from t1;
drop table t1; drop table t1;
#
# Bug #14009: use of abs() on null value causes problems with filesort
#
# InnoDB is required to reproduce the fault, but it is okay if we default to
# MyISAM when testing.
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
drop table t1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -8186,8 +8186,20 @@ void Field_bit_as_char::sql_type(String &res) const ...@@ -8186,8 +8186,20 @@ void Field_bit_as_char::sql_type(String &res) const
Handling of field and create_field Handling of field and create_field
*****************************************************************************/ *****************************************************************************/
/*
Convert create_field::length from number of characters to number of bytes
SYNOPSIS
create_field::create_length_to_internal_length()
DESCRIPTION
Convert create_field::length from number of characters to number of bytes,
save original value in chars_length.
*/
void create_field::create_length_to_internal_length(void) void create_field::create_length_to_internal_length(void)
{ {
chars_length= length;
switch (sql_type) { switch (sql_type) {
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
......
...@@ -1368,7 +1368,15 @@ public: ...@@ -1368,7 +1368,15 @@ public:
LEX_STRING comment; // Comment for field LEX_STRING comment; // Comment for field
Item *def; // Default value Item *def; // Default value
enum enum_field_types sql_type; enum enum_field_types sql_type;
/*
At various stages in execution this can be length of field in bytes or
max number of characters.
*/
ulong length; ulong length;
/*
The value of 'length' before a call to create_length_to_internal_length
*/
uint32 chars_length;
uint decimals, flags, pack_length, key_length; uint decimals, flags, pack_length, key_length;
Field::utype unireg_check; Field::utype unireg_check;
TYPELIB *interval; // Which interval to use TYPELIB *interval; // Which interval to use
......
...@@ -526,6 +526,7 @@ public: ...@@ -526,6 +526,7 @@ public:
double val_real_from_decimal(); double val_real_from_decimal();
virtual Field *get_tmp_table_field() { return 0; } virtual Field *get_tmp_table_field() { return 0; }
/* This is also used to create fields in CREATE ... SELECT: */
virtual Field *tmp_table_field(TABLE *t_arg) { return 0; } virtual Field *tmp_table_field(TABLE *t_arg) { return 0; }
virtual const char *full_name() const { return name ? name : "???"; } virtual const char *full_name() const { return name ? name : "???"; }
......
...@@ -636,6 +636,7 @@ void Item_func_num1::fix_num_length_and_dec() ...@@ -636,6 +636,7 @@ void Item_func_num1::fix_num_length_and_dec()
{ {
decimals= args[0]->decimals; decimals= args[0]->decimals;
max_length= args[0]->max_length; max_length= args[0]->max_length;
maybe_null= 1;
} }
......
...@@ -804,7 +804,7 @@ typedef struct st_lex ...@@ -804,7 +804,7 @@ typedef struct st_lex
/* /*
A flag that indicates what kinds of derived tables are present in the A flag that indicates what kinds of derived tables are present in the
query (0 if no derived tables, otherwise a combination of flags query (0 if no derived tables, otherwise a combination of flags
DERIVED_SUBQUERY and DERIVED_VIEW. DERIVED_SUBQUERY and DERIVED_VIEW).
*/ */
uint8 derived_tables; uint8 derived_tables;
uint8 create_view_algorithm; uint8 create_view_algorithm;
......
...@@ -1175,18 +1175,21 @@ JOIN::save_join_tab() ...@@ -1175,18 +1175,21 @@ JOIN::save_join_tab()
void void
JOIN::exec() JOIN::exec()
{ {
List<Item> *columns_list= &fields_list;
int tmp_error; int tmp_error;
DBUG_ENTER("JOIN::exec"); DBUG_ENTER("JOIN::exec");
error= 0; error= 0;
if (procedure) if (procedure)
{ {
if (procedure->change_columns(fields_list) || procedure_fields_list= fields_list;
result->prepare(fields_list, unit)) if (procedure->change_columns(procedure_fields_list) ||
result->prepare(procedure_fields_list, unit))
{ {
thd->limit_found_rows= thd->examined_row_count= 0; thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
columns_list= &procedure_fields_list;
} }
(void) result->prepare2(); // Currently, this cannot fail. (void) result->prepare2(); // Currently, this cannot fail.
...@@ -1197,7 +1200,7 @@ JOIN::exec() ...@@ -1197,7 +1200,7 @@ JOIN::exec()
(zero_result_cause?zero_result_cause:"No tables used")); (zero_result_cause?zero_result_cause:"No tables used"));
else else
{ {
result->send_fields(fields_list, result->send_fields(*columns_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
/* /*
We have to test for 'conds' here as the WHERE may not be constant We have to test for 'conds' here as the WHERE may not be constant
...@@ -1208,9 +1211,9 @@ JOIN::exec() ...@@ -1208,9 +1211,9 @@ JOIN::exec()
(!conds || conds->val_int()) && (!conds || conds->val_int()) &&
(!having || having->val_int())) (!having || having->val_int()))
{ {
if (do_send_rows && (procedure ? (procedure->send_row(fields_list) || if (do_send_rows &&
procedure->end_of_records()) (procedure ? (procedure->send_row(procedure_fields_list) ||
: result->send_data(fields_list))) procedure->end_of_records()) : result->send_data(fields_list)))
error= 1; error= 1;
else else
{ {
...@@ -1234,7 +1237,7 @@ JOIN::exec() ...@@ -1234,7 +1237,7 @@ JOIN::exec()
if (zero_result_cause) if (zero_result_cause)
{ {
(void) return_zero_rows(this, result, select_lex->leaf_tables, fields_list, (void) return_zero_rows(this, result, select_lex->leaf_tables, *columns_list,
send_row_on_empty_set(), send_row_on_empty_set(),
select_options, select_options,
zero_result_cause, zero_result_cause,
...@@ -1668,7 +1671,7 @@ JOIN::exec() ...@@ -1668,7 +1671,7 @@ JOIN::exec()
{ {
thd->proc_info="Sending data"; thd->proc_info="Sending data";
DBUG_PRINT("info", ("%s", thd->proc_info)); DBUG_PRINT("info", ("%s", thd->proc_info));
result->send_fields(*curr_fields_list, result->send_fields(*columns_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
error= do_select(curr_join, curr_fields_list, NULL, procedure); error= do_select(curr_join, curr_fields_list, NULL, procedure);
thd->limit_found_rows= curr_join->send_records; thd->limit_found_rows= curr_join->send_records;
...@@ -9020,6 +9023,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) ...@@ -9020,6 +9023,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
int rc= 0; int rc= 0;
enum_nested_loop_state error= NESTED_LOOP_OK; enum_nested_loop_state error= NESTED_LOOP_OK;
JOIN_TAB *join_tab; JOIN_TAB *join_tab;
List<Item> *columns_list= procedure? &join->procedure_fields_list : fields;
DBUG_ENTER("do_select"); DBUG_ENTER("do_select");
join->procedure=procedure; join->procedure=procedure;
...@@ -9053,7 +9057,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) ...@@ -9053,7 +9057,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
error= (*end_select)(join,join_tab,1); error= (*end_select)(join,join_tab,1);
} }
else if (join->send_row_on_empty_set()) else if (join->send_row_on_empty_set())
rc= join->result->send_data(*join->fields); rc= join->result->send_data(*columns_list);
} }
else else
{ {
...@@ -10082,7 +10086,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -10082,7 +10086,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
DBUG_RETURN(NESTED_LOOP_OK); // Didn't match having DBUG_RETURN(NESTED_LOOP_OK); // Didn't match having
error=0; error=0;
if (join->procedure) if (join->procedure)
error=join->procedure->send_row(*join->fields); error=join->procedure->send_row(join->procedure_fields_list);
else if (join->do_send_rows) else if (join->do_send_rows)
error=join->result->send_data(*join->fields); error=join->result->send_data(*join->fields);
if (error) if (error)
......
...@@ -244,6 +244,7 @@ class JOIN :public Sql_alloc ...@@ -244,6 +244,7 @@ class JOIN :public Sql_alloc
//Part, shared with list above, emulate following list //Part, shared with list above, emulate following list
List<Item> tmp_fields_list1, tmp_fields_list2, tmp_fields_list3; List<Item> tmp_fields_list1, tmp_fields_list2, tmp_fields_list3;
List<Item> &fields_list; // hold field list passed to mysql_select List<Item> &fields_list; // hold field list passed to mysql_select
List<Item> procedure_fields_list;
int error; int error;
ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select
......
...@@ -839,8 +839,8 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -839,8 +839,8 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->charset= (dup_field->charset ? sql_field->charset= (dup_field->charset ?
dup_field->charset : dup_field->charset :
create_info->default_table_charset); create_info->default_table_charset);
sql_field->length= dup_field->length; sql_field->length= dup_field->chars_length;
sql_field->pack_length= dup_field->pack_length; sql_field->pack_length= dup_field->pack_length;
sql_field->key_length= dup_field->key_length; sql_field->key_length= dup_field->key_length;
sql_field->create_length_to_internal_length(); sql_field->create_length_to_internal_length();
sql_field->decimals= dup_field->decimals; sql_field->decimals= dup_field->decimals;
......
...@@ -336,7 +336,7 @@ int mysql_update(THD *thd, ...@@ -336,7 +336,7 @@ int mysql_update(THD *thd,
/* If quick select is used, initialize it before retrieving rows. */ /* If quick select is used, initialize it before retrieving rows. */
if (select && select->quick && select->quick->reset()) if (select && select->quick && select->quick->reset())
goto err; goto err;
if (used_index == MAX_KEY) if (used_index == MAX_KEY || (select && select->quick))
init_read_record(&info,thd,table,select,0,1); init_read_record(&info,thd,table,select,0,1);
else else
init_read_record_idx(&info, thd, table, 1, used_index); init_read_record_idx(&info, thd, table, 1, used_index);
......
...@@ -550,13 +550,13 @@ typedef struct st_table_list ...@@ -550,13 +550,13 @@ typedef struct st_table_list
*/ */
st_table_list *referencing_view; st_table_list *referencing_view;
/* /*
security context (non-zero only for tables which belong Security context (non-zero only for tables which belong
to view with SQL SEQURITY DEFINER) to view with SQL SECURITY DEFINER)
*/ */
Security_context *security_ctx; Security_context *security_ctx;
/* /*
this view security context (non-zero only for views with This view security context (non-zero only for views with
SQL SEQURITY DEFINER) SQL SECURITY DEFINER)
*/ */
Security_context *view_sctx; Security_context *view_sctx;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment