Skip to content

Commit 026ec1d

Browse files
merged
2 parents 6ac4944 + e10fd44 commit 026ec1d

11 files changed

Lines changed: 106 additions & 53 deletions

File tree

man/perror.1

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
.TH perror 1 "19 December 2000" "MySQL 3.23" "MySQL database"
22
.SH NAME
3-
.BR perror
4-
can be used to display a description for a system error code, or an MyISAM/ISAM table handler error code. The error messages are mostly system dependent.
5-
.SH USAGE
6-
perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
3+
perror \- describes a system or MySQL error code.
74
.SH SYNOPSIS
8-
.B perror
9-
.RB [ \-? | \-\-help ]
10-
.RB [ \-I | \-\-info ]
11-
.RB [ \-s | \-\-silent ]
12-
.RB [ \-v | \-\-verbose ]
13-
.RB [ \-V | \-\-version ]
5+
perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
146
.SH DESCRIPTION
7+
Can be used to display a description for a system error code, or an MyISAM/ISAM table handler error code.
8+
The error messages are mostly system dependent.
9+
.SH OPTIONS
1510
.TP
1611
.BR \-? | \-\-help
1712
Displays this help and exits.

mysql-test/t/analyse.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#
44

55
drop table if exists t1,t2;
6-
create table t1 (i int, j int);
7-
insert into t1 values (1,2), (3,4), (5,6), (7,8);
6+
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
7+
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
88
select * from t1 procedure analyse();
9+
select * from t1 procedure analyse(2);
910
create table t2 select * from t1 procedure analyse();
1011
select * from t2;
1112
drop table t1,t2;
13+

mysql-test/t/group_by.test

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ CREATE TABLE t1 (
6868

6969
INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
7070

71-
!$1056 SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
71+
--error 1056
72+
SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
7273

7374
drop table t1;
7475

@@ -255,6 +256,14 @@ select sql_big_result score,count(*) from t1 group by score desc;
255256
drop table t1;
256257

257258
#
259+
260+
# not purely group_by bug, but group_by is involved...
261+
262+
create table t1 (a date default null, b date default null);
263+
insert t1 values ('1999-10-01','2000-01-10'), ('1997-01-01','1998-10-01');
264+
select a,min(b) c,count(distinct rand()) from t1 group by a having c<a + interval 1 day;
265+
drop table t1;
266+
258267
# Compare with hash keys
259268
#
260269

mysql-test/t/select.test

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,10 +1722,26 @@ drop table t4, t3, t2, t1;
17221722

17231723
#
17241724
# Test of DO
1725+
#
17251726

17261727
DO 1;
17271728
DO benchmark(100,1+1),1,1;
17281729

1730+
#
1731+
# random in WHERE clause
1732+
#
1733+
1734+
CREATE TABLE t1 (
1735+
id mediumint(8) unsigned NOT NULL auto_increment,
1736+
pseudo varchar(35) NOT NULL default '',
1737+
PRIMARY KEY (id),
1738+
UNIQUE KEY pseudo (pseudo)
1739+
);
1740+
INSERT INTO t1 (pseudo) VALUES ('test');
1741+
INSERT INTO t1 (pseudo) VALUES ('test1');
1742+
SELECT 1 from t1 where rand() > 2;
1743+
DROP TABLE t1;
1744+
17291745
#
17301746
# Test of bug with SUM(CASE...)
17311747
#
@@ -1794,10 +1810,11 @@ select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
17941810
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
17951811
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
17961812
drop table t1;
1797-
drop table if exists t1,t2;
1813+
17981814
CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) TYPE=MyISAM;
17991815
INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);
18001816
CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=MyISAM;
18011817
INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);
18021818
select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5;
1803-
drop table if exists t1,t2;
1819+
drop table t1,t2;
1820+

scripts/mysqld_safe.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ parse_arguments() {
3939
--datadir=*) DATADIR=`echo "$arg" | sed -e "s;--datadir=;;"` ;;
4040
--pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;;
4141
--user=*)
42-
if [ $SET_USER == 0 ]
43-
then
42+
if test $SET_USER -eq 0
43+
then
4444
user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1
4545
fi
4646
;;

sql/gen_lex_hash.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void print_arrays()
294294
function_plus,function_mod);
295295

296296
int *prva= (int*) my_alloca(sizeof(int)*function_mod);
297-
for (i=0 ; i <= function_mod; i++)
297+
for (i=0 ; i < function_mod; i++)
298298
prva[i]= max_symbol;
299299

300300
for (i=0;i<size;i++)

sql/item.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ bool Item_field::get_date(TIME *ltime,bool fuzzydate)
195195
return 0;
196196
}
197197

198+
bool Item_field::get_date_result(TIME *ltime,bool fuzzydate)
199+
{
200+
if ((null_value=result_field->is_null()) ||
201+
result_field->get_date(ltime,fuzzydate))
202+
{
203+
bzero((char*) ltime,sizeof(*ltime));
204+
return 1;
205+
}
206+
return 0;
207+
}
208+
198209
bool Item_field::get_time(TIME *ltime)
199210
{
200211
if ((null_value=field->is_null()) || field->get_time(ltime))

sql/item.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class Item {
8383
virtual void split_sum_func(List<Item> &fields) {}
8484
virtual bool get_date(TIME *ltime,bool fuzzydate);
8585
virtual bool get_time(TIME *ltime);
86+
virtual bool get_date_result(TIME *ltime,bool fuzzydate)
87+
{ return get_date(ltime,fuzzydate); }
8688
virtual bool is_null() { return 0; }
8789
virtual unsigned int size_of()= 0;
8890
virtual void top_level_item() {}
@@ -142,8 +144,9 @@ class Item_field :public Item_ident
142144
return field->result_type();
143145
}
144146
Field *tmp_table_field(TABLE *t_arg=(TABLE *)0) { return result_field; }
145-
bool get_date(TIME *ltime,bool fuzzydate);
146-
bool get_time(TIME *ltime);
147+
bool get_date(TIME *ltime,bool fuzzydate);
148+
bool get_date_result(TIME *ltime,bool fuzzydate);
149+
bool get_time(TIME *ltime);
147150
bool is_null() { return field->is_null(); }
148151
unsigned int size_of() { return sizeof(*this);}
149152
};
@@ -411,8 +414,8 @@ class Item_ref :public Item_ident
411414
return (*ref)->null_value;
412415
}
413416
bool get_date(TIME *ltime,bool fuzzydate)
414-
{
415-
return (null_value=(*ref)->get_date(ltime,fuzzydate));
417+
{
418+
return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
416419
}
417420
bool send(THD *thd, String *tmp) { return (*ref)->send(thd, tmp); }
418421
void make_field(Send_field *field) { (*ref)->make_field(field); }

sql/sql_analyse.cc

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,16 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
241241
}
242242
else
243243
return 0;
244-
} //test_if_number
244+
}
245245

246246

247-
// Stores the biggest and the smallest value from current 'info'
248-
// to ev_num_info
249-
// If info contains an ulonglong number, which is bigger than
250-
// biggest positive number able to be stored in a longlong variable
251-
// and is marked as negative, function will return 0, else 1.
247+
/*
248+
Stores the biggest and the smallest value from current 'info'
249+
to ev_num_info
250+
If info contains an ulonglong number, which is bigger than
251+
biggest positive number able to be stored in a longlong variable
252+
and is marked as negative, function will return 0, else 1.
253+
*/
252254

253255
bool get_ev_num_info(EV_NUM_INFO *ev_info, NUM_INFO *info, const char *num)
254256
{
@@ -276,11 +278,13 @@ void free_string(String *s)
276278
s->free();
277279
}
278280

281+
279282
void field_str::add()
280283
{
281284
char buff[MAX_FIELD_WIDTH], *ptr;
282285
String s(buff, sizeof(buff)), *res;
283286
ulong length;
287+
TREE_ELEMENT *element;
284288

285289
if (!(res = item->val_str(&s)))
286290
{
@@ -426,9 +430,11 @@ void field_real::add()
426430
room_in_tree = 0; // Remove tree, out of RAM ?
427431
delete_tree(&tree);
428432
}
429-
// if element->count == 1, this element can be found only once from tree
430-
// if element->count == 2, or more, this element is already in tree
431-
else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
433+
/*
434+
if element->count == 1, this element can be found only once from tree
435+
if element->count == 2, or more, this element is already in tree
436+
*/
437+
else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
432438
{
433439
room_in_tree = 0; // Remove tree, too many elements
434440
delete_tree(&tree);
@@ -457,6 +463,7 @@ void field_real::add()
457463
}
458464
} // field_real::add
459465

466+
460467
void field_longlong::add()
461468
{
462469
char buff[MAX_FIELD_WIDTH];
@@ -479,9 +486,11 @@ void field_longlong::add()
479486
room_in_tree = 0; // Remove tree, out of RAM ?
480487
delete_tree(&tree);
481488
}
482-
// if element->count == 1, this element can be found only once from tree
483-
// if element->count == 2, or more, this element is already in tree
484-
else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
489+
/*
490+
if element->count == 1, this element can be found only once from tree
491+
if element->count == 2, or more, this element is already in tree
492+
*/
493+
else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
485494
{
486495
room_in_tree = 0; // Remove tree, too many elements
487496
delete_tree(&tree);
@@ -533,9 +542,11 @@ void field_ulonglong::add()
533542
room_in_tree = 0; // Remove tree, out of RAM ?
534543
delete_tree(&tree);
535544
}
536-
// if element->count == 1, this element can be found only once from tree
537-
// if element->count == 2, or more, this element is already in tree
538-
else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
545+
/*
546+
if element->count == 1, this element can be found only once from tree
547+
if element->count == 2, or more, this element is already in tree
548+
*/
549+
else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
539550
{
540551
room_in_tree = 0; // Remove tree, too many elements
541552
delete_tree(&tree);
@@ -615,14 +626,16 @@ bool analyse::end_of_records()
615626
func_items[8]->null_value = 1;
616627
else
617628
func_items[8]->set(res->ptr(), res->length());
618-
// count the dots, quotas, etc. in (ENUM("a","b","c"...))
619-
// if tree has been removed, don't suggest ENUM.
620-
// treemem is used to measure the size of tree for strings,
621-
// tree_elements is used to count the elements in tree in case of numbers.
622-
// max_treemem tells how long the string starting from ENUM("... and
623-
// ending to ..") shall at maximum be. If case is about numbers,
624-
// max_tree_elements will tell the length of the above, now
625-
// every number is considered as length 1
629+
/*
630+
count the dots, quotas, etc. in (ENUM("a","b","c"...))
631+
If tree has been removed, don't suggest ENUM.
632+
treemem is used to measure the size of tree for strings,
633+
tree_elements is used to count the elements
634+
max_treemem tells how long the string starting from ENUM("... and
635+
ending to ..") shall at maximum be. If case is about numbers,
636+
max_tree_elements will tell the length of the above, now
637+
every number is considered as length 1
638+
*/
626639
if (((*f)->treemem || (*f)->tree_elements) &&
627640
(*f)->tree.elements_in_tree &&
628641
(((*f)->treemem ? max_treemem : max_tree_elements) >
@@ -665,6 +678,7 @@ bool analyse::end_of_records()
665678
ans.append("DATETIME", 8);
666679
break;
667680
case FIELD_TYPE_DATE:
681+
case FIELD_TYPE_NEWDATE:
668682
ans.append("DATE", 4);
669683
break;
670684
case FIELD_TYPE_SET:
@@ -676,9 +690,6 @@ bool analyse::end_of_records()
676690
case FIELD_TYPE_TIME:
677691
ans.append("TIME", 4);
678692
break;
679-
case FIELD_TYPE_NEWDATE:
680-
ans.append("NEWDATE", 7);
681-
break;
682693
case FIELD_TYPE_DECIMAL:
683694
ans.append("DECIMAL", 7);
684695
// if item is FIELD_ITEM, it _must_be_ Field_num in this case

sql/sql_base.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,8 +1693,7 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
16931693
else
16941694
thd->dupp_field=field;
16951695
}
1696-
if (check_grants && !thd->master_access &&
1697-
check_grant_column(thd,table,name,length))
1696+
if (check_grants && check_grant_column(thd,table,name,length))
16981697
return WRONG_GRANT;
16991698
return field;
17001699
}
@@ -1719,7 +1718,8 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables)
17191718
{
17201719
found_table=1;
17211720
Field *find=find_field_in_table(thd,tables->table,name,length,
1722-
grant_option && !thd->master_access,1);
1721+
grant_option &&
1722+
tables->grant.want_privilege ,1);
17231723
if (find)
17241724
{
17251725
if (find == WRONG_GRANT)
@@ -1758,8 +1758,7 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables)
17581758
for (; tables ; tables=tables->next)
17591759
{
17601760
Field *field=find_field_in_table(thd,tables->table,name,length,
1761-
grant_option &&
1762-
!thd->master_access, allow_rowid);
1761+
grant_option && tables->grant.want_privilege ,allow_rowid);
17631762
if (field)
17641763
{
17651764
if (field == WRONG_GRANT)

0 commit comments

Comments
 (0)