summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-02-07 16:38:37 +0200
committerunknown <monty@mashka.mysql.fi>2003-02-07 16:38:37 +0200
commite751d298369061cfd8b3362712cce11aa8efbaa5 (patch)
treee5a5f635842a20157ef2ed69775c40aad98631f7 /sql
parentd66e60248c9f448b9d251358e0acfd97d1e3f84e (diff)
parentf06b0d9f3cfeaee8098db22eeecf41f6c072c479 (diff)
downloadmariadb-git-e751d298369061cfd8b3362712cce11aa8efbaa5.tar.gz
Merge with 4.0 to get fix for MIN/MAX
BitKeeper/etc/ignore: added support-files/MacOSX/Info.plist Makefile.am: Auto merged include/my_global.h: Auto merged mysql-test/r/distinct.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/join.result: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/order_by.test: Auto merged mysql-test/t/show_check.test: Auto merged sql/filesort.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/lex.h: Auto merged sql/opt_range.cc: Auto merged sql/opt_range.h: Auto merged sql/slave.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged configure.in: Use local version mysql-test/r/func_group.result: merge mysql-test/r/order_by.result: merge mysql-test/r/show_check.result: merge mysql-test/t/func_group.test: merge mysql-test/t/join.test: merge sql/mysql_priv.h: Use local version sql/sql_yacc.yy: merge sql/table.cc: USe local
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc5
-rw-r--r--sql/ha_innodb.cc27
-rw-r--r--sql/lex.h1
-rw-r--r--sql/opt_range.cc5
-rw-r--r--sql/opt_range.h2
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_yacc.yy39
7 files changed, 65 insertions, 19 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 27c4b962515..8bf9c648e82 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -450,7 +450,10 @@ static void make_sortkey(register SORTPARAM *param,
{
if (field->is_null())
{
- bzero((char*) to,sort_field->length+1);
+ if (sort_field->reverse)
+ bfill(to,sort_field->length+1,(char) 255);
+ else
+ bzero((char*) to,sort_field->length+1);
to+= sort_field->length+1;
continue;
}
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 12aa7c0b6f5..23c6082da92 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -2292,7 +2292,18 @@ convert_search_mode_to_innobase(
case HA_READ_AFTER_KEY: return(PAGE_CUR_G);
case HA_READ_BEFORE_KEY: return(PAGE_CUR_L);
case HA_READ_PREFIX: return(PAGE_CUR_GE);
- case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE_OR_EXTENDS);
+ case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE);
+ /* TODO: 1) this should really be
+ return(PAGE_CUR_LE_OR_EXTENDS); but since MySQL uses
+ a wrong flag in search, we convert this to PAGE_CUR_LE;
+ 2) if the character set is not latin1, then InnoDB
+ uses a MySQL function innobase_mysql_cmp() to
+ compare CHAR and VARCHAR strings; since that function
+ does not return the number of matched bytes,
+ PAGE_CUR_LE_OR_EXTENDS does not currently work: we
+ should probably write my_sortncmp_with_n_matcehd_bytes()
+ to determine if a field 'extends' another;
+ see dev-public discussion on Feb 7th, 2003 */
default: assert(0);
}
@@ -4175,7 +4186,10 @@ static void free_share(INNOBASE_SHARE *share)
}
/*********************************************************************
-Stores a MySQL lock into a 'lock' field in a handle. */
+Converts a MySQL table lock stored in the 'lock' field of the handle to
+a proper type before storing the lock. MySQL also calls this when it
+releases a lock. */
+
THR_LOCK_DATA**
ha_innobase::store_lock(
@@ -4201,8 +4215,13 @@ ha_innobase::store_lock(
binlog) requires the use of a locking read */
prebuilt->select_lock_type = LOCK_S;
- } else {
- /* We set possible LOCK_X value in external_lock, not yet
+ } else if (lock_type != TL_IGNORE) {
+
+ /* In ha_berkeley.cc there is a comment that MySQL
+ may in exceptional cases call this with TL_IGNORE also
+ when it is NOT going to release the lock. */
+
+ /* We set possible LOCK_X value in external_lock, not yet
here even if this would be SELECT ... FOR UPDATE */
prebuilt->select_lock_type = LOCK_NONE;
diff --git a/sql/lex.h b/sql/lex.h
index 67b2ba85dc0..d2d26e46c1c 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -274,6 +274,7 @@ static SYMBOL symbols[] = {
{ "NULL", SYM(NULL_SYM),0,0},
{ "NUMERIC", SYM(NUMERIC_SYM),0,0},
{ "OFFSET", SYM(OFFSET_SYM),0,0},
+ { "OLD_PASSWORD", SYM(PASSWORD),0,0},
{ "ON", SYM(ON),0,0},
{ "OPEN", SYM(OPEN_SYM),0,0},
{ "OPTIMIZE", SYM(OPTIMIZE),0,0},
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 980390f04bf..3dbcdaf0537 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2564,8 +2564,7 @@ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUICK_SELECT *q, uint used_key_parts)
for (r = it++; r; r = it++)
{
rev_ranges.push_front(r);
- if (not_read_after_key && range_reads_after_key(r) ||
- test_if_null_range(r,used_key_parts))
+ if (not_read_after_key && range_reads_after_key(r))
{
it.rewind(); // Reset range
error = HA_ERR_UNSUPPORTED;
@@ -2734,6 +2733,7 @@ bool QUICK_SELECT_DESC::range_reads_after_key(QUICK_RANGE *range_arg)
/* True if we are reading over a key that may have a NULL value */
+#ifdef NOT_USED
bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range_arg,
uint used_key_parts)
{
@@ -2779,6 +2779,7 @@ bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range_arg,
return 1; // Covers null part
return 0;
}
+#endif
/*****************************************************************************
diff --git a/sql/opt_range.h b/sql/opt_range.h
index e96c3792f24..bc56fb99b4b 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -103,7 +103,9 @@ public:
private:
int cmp_prev(QUICK_RANGE *range);
bool range_reads_after_key(QUICK_RANGE *range);
+#ifdef NOT_USED
bool test_if_null_range(QUICK_RANGE *range, uint used_key_parts);
+#endif
void reset(void) { next=0; rev_it.rewind(); }
List<QUICK_RANGE> rev_ranges;
List_iterator<QUICK_RANGE> rev_it;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f61ea4e8c10..00f7ed9bfc9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4981,6 +4981,11 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
{
if ((error=(*join_tab->next_select)(join,join_tab+1,0)) < 0)
return error;
+ /*
+ Test if this was a SELECT DISTINCT query on a table that
+ was not in the field list; In this case we can abort if
+ we found a row, as no new rows can be added to the result.
+ */
if (not_used_in_distinct && found_records != join->found_records)
return 0;
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a633c307830..44f63a2abe3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -649,7 +649,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
insert_values update delete truncate rename
show describe load alter optimize flush
reset purge begin commit rollback slave master_def master_defs
- repair restore backup analyze check
+ repair restore backup analyze check start
field_list field_list_item field_spec kill
select_item_list select_item values_list no_braces
opt_limit_clause delete_limit_clause fields opt_values values
@@ -730,6 +730,7 @@ verb_clause:
| select
| set
| slave
+ | start
| show
| truncate
| handler
@@ -1566,6 +1567,11 @@ slave:
}
;
+start:
+ START_SYM TRANSACTION_SYM { Lex->sql_command = SQLCOM_BEGIN;}
+ {}
+ ;
+
slave_thread_opts:
slave_thread_opt
| slave_thread_opts ',' slave_thread_opt;
@@ -2421,7 +2427,7 @@ sum_expr:
{ $$=new Item_sum_and($3); }
| BIT_OR '(' in_sum_expr ')'
{ $$=new Item_sum_or($3); }
- | COUNT_SYM '(' '*' ')'
+ | COUNT_SYM '(' opt_all '*' ')'
{ $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
| COUNT_SYM '(' in_sum_expr ')'
{ $$=new Item_sum_count($3); }
@@ -2441,6 +2447,7 @@ sum_expr:
{ $$=new Item_sum_sum($3); };
in_sum_expr:
+ opt_all
{
LEX *lex= Lex;
if (lex->current_select->inc_in_sum_expr())
@@ -2452,7 +2459,7 @@ in_sum_expr:
expr
{
Select->select_lex()->in_sum_expr--;
- $$=$2;
+ $$= $3;
};
cast_type:
@@ -2523,19 +2530,22 @@ opt_pad:
join_table_list:
'(' join_table_list ')' { $$=$2; }
| join_table { $$=$1; }
+ | join_table_list ',' join_table_list { $$=$3; }
| join_table_list normal_join join_table_list { $$=$3; }
| join_table_list STRAIGHT_JOIN join_table_list
{ $$=$3 ; $$->straight=1; }
- | join_table_list INNER_SYM JOIN_SYM join_table_list ON expr
- { add_join_on($4,$6); $$=$4; }
- | join_table_list INNER_SYM JOIN_SYM join_table_list
+ | join_table_list normal_join join_table_list ON expr
+ { add_join_on($3,$5); $$=$3; }
+ | join_table_list normal_join join_table_list
+ USING
{
SELECT_LEX *sel= Select->select_lex();
sel->db1=$1->db; sel->table1=$1->alias;
- sel->db2=$4->db; sel->table2=$4->alias;
+ sel->db2=$3->db; sel->table2=$3->alias;
}
- USING '(' using_list ')'
- { add_join_on($4,$8); $$=$4; }
+ '(' using_list ')'
+ { add_join_on($3,$7); $$=$3; }
+
| join_table_list LEFT opt_outer JOIN_SYM join_table_list ON expr
{ add_join_on($5,$7); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; }
| join_table_list LEFT opt_outer JOIN_SYM join_table_list
@@ -2564,9 +2574,10 @@ join_table_list:
{ add_join_natural($1,$4); $$=$4; };
normal_join:
- ',' {}
- | JOIN_SYM {}
- | CROSS JOIN_SYM {};
+ JOIN_SYM {}
+ | INNER_SYM JOIN_SYM {}
+ | CROSS JOIN_SYM {}
+ ;
join_table:
{
@@ -2712,6 +2723,10 @@ opt_table_alias:
| table_alias ident
{ $$= (LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING)); };
+opt_all:
+ /* empty */
+ | ALL
+ ;
where_clause:
/* empty */ { Select->select_lex()->where= 0; }