summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2003-03-13 13:44:03 +0100
committerunknown <serg@serg.mysql.com>2003-03-13 13:44:03 +0100
commit50da5c1858ca2343f950e748991714f2f6813a1e (patch)
tree7a057f11634bb468082003e00b9d3a2f310b8d91 /sql
parenta4aaac02f3b50f2009a163d531afb686a03e47dd (diff)
parentc7551b88408430007ed7c27ed5e9f40f584e29d0 (diff)
downloadmariadb-git-50da5c1858ca2343f950e748991714f2f6813a1e.tar.gz
merged
man/perror.1: Auto merged scripts/mysqld_safe.sh: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/item.cc: Auto merged sql/sql_select.cc: Auto merged strings/ctype-tis620.c: Auto merged mysql-test/r/analyse.result: ul mysql-test/r/group_by.result: ul mysql-test/r/select.result: ul
Diffstat (limited to 'sql')
-rw-r--r--sql/gen_lex_hash.cc2
-rw-r--r--sql/item.cc11
-rw-r--r--sql/item.h11
-rw-r--r--sql/sql_analyse.cc63
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/sql_select.cc6
6 files changed, 66 insertions, 36 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 8139cf4fdb0..1f604659272 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -294,7 +294,7 @@ void print_arrays()
function_plus,function_mod);
int *prva= (int*) my_alloca(sizeof(int)*function_mod);
- for (i=0 ; i <= function_mod; i++)
+ for (i=0 ; i < function_mod; i++)
prva[i]= max_symbol;
for (i=0;i<size;i++)
diff --git a/sql/item.cc b/sql/item.cc
index ec9b07c443c..0046f53c6fb 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -195,6 +195,17 @@ bool Item_field::get_date(TIME *ltime,bool fuzzydate)
return 0;
}
+bool Item_field::get_date_result(TIME *ltime,bool fuzzydate)
+{
+ if ((null_value=result_field->is_null()) ||
+ result_field->get_date(ltime,fuzzydate))
+ {
+ bzero((char*) ltime,sizeof(*ltime));
+ return 1;
+ }
+ return 0;
+}
+
bool Item_field::get_time(TIME *ltime)
{
if ((null_value=field->is_null()) || field->get_time(ltime))
diff --git a/sql/item.h b/sql/item.h
index a72079a6856..5e2c2ccc056 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -83,6 +83,8 @@ public:
virtual void split_sum_func(List<Item> &fields) {}
virtual bool get_date(TIME *ltime,bool fuzzydate);
virtual bool get_time(TIME *ltime);
+ virtual bool get_date_result(TIME *ltime,bool fuzzydate)
+ { return get_date(ltime,fuzzydate); }
virtual bool is_null() { return 0; }
virtual unsigned int size_of()= 0;
virtual void top_level_item() {}
@@ -142,8 +144,9 @@ public:
return field->result_type();
}
Field *tmp_table_field(TABLE *t_arg=(TABLE *)0) { return result_field; }
- bool get_date(TIME *ltime,bool fuzzydate);
- bool get_time(TIME *ltime);
+ bool get_date(TIME *ltime,bool fuzzydate);
+ bool get_date_result(TIME *ltime,bool fuzzydate);
+ bool get_time(TIME *ltime);
bool is_null() { return field->is_null(); }
unsigned int size_of() { return sizeof(*this);}
};
@@ -411,8 +414,8 @@ public:
return (*ref)->null_value;
}
bool get_date(TIME *ltime,bool fuzzydate)
- {
- return (null_value=(*ref)->get_date(ltime,fuzzydate));
+ {
+ return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
}
bool send(THD *thd, String *tmp) { return (*ref)->send(thd, tmp); }
void make_field(Send_field *field) { (*ref)->make_field(field); }
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index a75b7e304d1..5d3f9a0595c 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -241,14 +241,16 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
}
else
return 0;
-} //test_if_number
+}
-// Stores the biggest and the smallest value from current 'info'
-// to ev_num_info
-// If info contains an ulonglong number, which is bigger than
-// biggest positive number able to be stored in a longlong variable
-// and is marked as negative, function will return 0, else 1.
+/*
+ Stores the biggest and the smallest value from current 'info'
+ to ev_num_info
+ If info contains an ulonglong number, which is bigger than
+ biggest positive number able to be stored in a longlong variable
+ and is marked as negative, function will return 0, else 1.
+*/
bool get_ev_num_info(EV_NUM_INFO *ev_info, NUM_INFO *info, const char *num)
{
@@ -276,11 +278,13 @@ void free_string(String *s)
s->free();
}
+
void field_str::add()
{
char buff[MAX_FIELD_WIDTH], *ptr;
String s(buff, sizeof(buff)), *res;
ulong length;
+ TREE_ELEMENT *element;
if (!(res = item->val_str(&s)))
{
@@ -426,9 +430,11 @@ void field_real::add()
room_in_tree = 0; // Remove tree, out of RAM ?
delete_tree(&tree);
}
- // if element->count == 1, this element can be found only once from tree
- // if element->count == 2, or more, this element is already in tree
- else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
+ /*
+ if element->count == 1, this element can be found only once from tree
+ if element->count == 2, or more, this element is already in tree
+ */
+ else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
{
room_in_tree = 0; // Remove tree, too many elements
delete_tree(&tree);
@@ -457,6 +463,7 @@ void field_real::add()
}
} // field_real::add
+
void field_longlong::add()
{
char buff[MAX_FIELD_WIDTH];
@@ -479,9 +486,11 @@ void field_longlong::add()
room_in_tree = 0; // Remove tree, out of RAM ?
delete_tree(&tree);
}
- // if element->count == 1, this element can be found only once from tree
- // if element->count == 2, or more, this element is already in tree
- else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
+ /*
+ if element->count == 1, this element can be found only once from tree
+ if element->count == 2, or more, this element is already in tree
+ */
+ else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
{
room_in_tree = 0; // Remove tree, too many elements
delete_tree(&tree);
@@ -533,9 +542,11 @@ void field_ulonglong::add()
room_in_tree = 0; // Remove tree, out of RAM ?
delete_tree(&tree);
}
- // if element->count == 1, this element can be found only once from tree
- // if element->count == 2, or more, this element is already in tree
- else if (element->count == 1 && (tree_elements++) > pc->max_tree_elements)
+ /*
+ if element->count == 1, this element can be found only once from tree
+ if element->count == 2, or more, this element is already in tree
+ */
+ else if (element->count == 1 && (tree_elements++) >= pc->max_tree_elements)
{
room_in_tree = 0; // Remove tree, too many elements
delete_tree(&tree);
@@ -615,14 +626,16 @@ bool analyse::end_of_records()
func_items[8]->null_value = 1;
else
func_items[8]->set(res->ptr(), res->length());
- // count the dots, quotas, etc. in (ENUM("a","b","c"...))
- // if tree has been removed, don't suggest ENUM.
- // treemem is used to measure the size of tree for strings,
- // tree_elements is used to count the elements in tree in case of numbers.
- // max_treemem tells how long the string starting from ENUM("... and
- // ending to ..") shall at maximum be. If case is about numbers,
- // max_tree_elements will tell the length of the above, now
- // every number is considered as length 1
+ /*
+ count the dots, quotas, etc. in (ENUM("a","b","c"...))
+ If tree has been removed, don't suggest ENUM.
+ treemem is used to measure the size of tree for strings,
+ tree_elements is used to count the elements
+ max_treemem tells how long the string starting from ENUM("... and
+ ending to ..") shall at maximum be. If case is about numbers,
+ max_tree_elements will tell the length of the above, now
+ every number is considered as length 1
+ */
if (((*f)->treemem || (*f)->tree_elements) &&
(*f)->tree.elements_in_tree &&
(((*f)->treemem ? max_treemem : max_tree_elements) >
@@ -665,6 +678,7 @@ bool analyse::end_of_records()
ans.append("DATETIME", 8);
break;
case FIELD_TYPE_DATE:
+ case FIELD_TYPE_NEWDATE:
ans.append("DATE", 4);
break;
case FIELD_TYPE_SET:
@@ -676,9 +690,6 @@ bool analyse::end_of_records()
case FIELD_TYPE_TIME:
ans.append("TIME", 4);
break;
- case FIELD_TYPE_NEWDATE:
- ans.append("NEWDATE", 7);
- break;
case FIELD_TYPE_DECIMAL:
ans.append("DECIMAL", 7);
// if item is FIELD_ITEM, it _must_be_ Field_num in this case
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4d1e57f0c1e..660b37858b5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1693,8 +1693,7 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
else
thd->dupp_field=field;
}
- if (check_grants && !thd->master_access &&
- check_grant_column(thd,table,name,length))
+ if (check_grants && check_grant_column(thd,table,name,length))
return WRONG_GRANT;
return field;
}
@@ -1719,7 +1718,8 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables)
{
found_table=1;
Field *find=find_field_in_table(thd,tables->table,name,length,
- grant_option && !thd->master_access,1);
+ grant_option &&
+ tables->grant.want_privilege ,1);
if (find)
{
if (find == WRONG_GRANT)
@@ -1758,8 +1758,7 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables)
for (; tables ; tables=tables->next)
{
Field *field=find_field_in_table(thd,tables->table,name,length,
- grant_option &&
- !thd->master_access, allow_rowid);
+ grant_option && tables->grant.want_privilege ,allow_rowid);
if (field)
{
if (field == WRONG_GRANT)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ffe20095963..96de43ae55c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2527,6 +2527,12 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
{
JOIN_TAB *tab=join->join_tab+i;
table_map current_map= tab->table->map;
+ /*
+ Following force including random expression in last table condition.
+ It solve problem with select like SELECT * FROM t1 WHERE rand() > 0.5
+ */
+ if (i == join->tables-1)
+ current_map|= RAND_TABLE_BIT;
bool use_quick_range=0;
used_tables|=current_map;