summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <patg@krsna.patg.net>2005-11-01 17:07:13 -0800
committerunknown <patg@krsna.patg.net>2005-11-01 17:07:13 -0800
commit02ac7bef876ba51f13c09174da7a706ea35b6613 (patch)
treece4d0c1782e669224f1b5e469cf82f8e9655c363 /sql
parentfe11647273c1264a2c676159b2c95ef9d32f80bf (diff)
parenta486b3d7c50ccf13e3a0c1a96f67ae541ec733f8 (diff)
downloadmariadb-git-02ac7bef876ba51f13c09174da7a706ea35b6613.tar.gz
Merge pgalbraith@bk-internal.mysql.com:/home/bk/mysql-5.0
into krsna.patg.net:/home/patg/mysql-build/mysql-5.0.test2
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.h3
-rw-r--r--sql/item_func.cc1
-rw-r--r--sql/item_timefunc.cc1
-rw-r--r--sql/spatial.cc39
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_select.h1
-rw-r--r--sql/sql_update.cc16
7 files changed, 41 insertions, 24 deletions
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 59f11bfd74a..99e13286554 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -94,6 +94,9 @@ class ha_berkeley: public handler
uint max_supported_keys() const { return MAX_KEY-1; }
uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; }
ha_rows estimate_rows_upper_bound();
+ uint max_supported_key_length() const { return 4294967295L; }
+ uint max_supported_key_part_length() const { return 4294967295L; }
+
const key_map *keys_to_use_for_scanning() { return &key_map_full; }
bool has_transactions() { return 1;}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 9c1d1f63635..44cee556dbd 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1378,6 +1378,7 @@ my_decimal *Item_func_abs::decimal_op(my_decimal *decimal_value)
void Item_func_abs::fix_length_and_dec()
{
Item_func_num1::fix_length_and_dec();
+ maybe_null= 1;
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 7f847005966..2b0314bb287 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2504,6 +2504,7 @@ void Item_func_add_time::fix_length_and_dec()
enum_field_types arg0_field_type;
decimals=0;
max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
+ maybe_null= 1;
/*
The field type for the result of an Item_func_add_time function is defined
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 3c36c319354..5af1bec45ca 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -129,15 +129,14 @@ Geometry *Geometry::construct(Geometry_buffer *buffer,
Geometry *result;
char byte_order;
- if (data_len < SRID_SIZE + 1 + 4)
+ if (data_len < SRID_SIZE + WKB_HEADER_SIZE) // < 4 + (1 + 4)
return NULL;
byte_order= data[SRID_SIZE];
geom_type= uint4korr(data + SRID_SIZE + 1);
- data+= SRID_SIZE + WKB_HEADER_SIZE;
if (!(result= create_by_typeid(buffer, (int) geom_type)))
return NULL;
- result->m_data= data;
- result->m_data_end= data + (data_len - (SRID_SIZE + WKB_HEADER_SIZE));
+ result->m_data= data+ SRID_SIZE + WKB_HEADER_SIZE;
+ result->m_data_end= data + data_len;
return result;
}
@@ -739,7 +738,7 @@ uint Gis_polygon::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo,
wkb+= ls_len;
}
- return wkb - wkb_orig;
+ return (uint) (wkb - wkb_orig);
}
@@ -1184,7 +1183,8 @@ uint Gis_multi_line_string::init_from_wkb(const char *wkb, uint len,
return 0;
res->q_append(n_line_strings);
- for (wkb+=4; n_line_strings; n_line_strings--)
+ wkb+= 4;
+ while (n_line_strings--)
{
Gis_line_string ls;
int ls_len;
@@ -1199,10 +1199,11 @@ uint Gis_multi_line_string::init_from_wkb(const char *wkb, uint len,
if (!(ls_len= ls.init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
- wkb+= (ls_len + WKB_HEADER_SIZE);
- len-= (ls_len + WKB_HEADER_SIZE);
+ ls_len+= WKB_HEADER_SIZE;;
+ wkb+= ls_len;
+ len-= ls_len;
}
- return wkb-wkb_orig;
+ return (uint) (wkb - wkb_orig);
}
@@ -1436,7 +1437,8 @@ uint Gis_multi_polygon::init_from_wkb(const char *wkb, uint len,
return 0;
res->q_append(n_poly);
- for (wkb+=4; n_poly; n_poly--)
+ wkb+=4;
+ while (n_poly--)
{
Gis_polygon p;
int p_len;
@@ -1450,10 +1452,11 @@ uint Gis_multi_polygon::init_from_wkb(const char *wkb, uint len,
if (!(p_len= p.init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
- wkb+= (p_len + WKB_HEADER_SIZE);
- len-= (p_len + WKB_HEADER_SIZE);
+ p_len+= WKB_HEADER_SIZE;
+ wkb+= p_len;
+ len-= p_len;
}
- return wkb-wkb_orig;
+ return (uint) (wkb - wkb_orig);
}
@@ -1733,7 +1736,8 @@ uint Gis_geometry_collection::init_from_wkb(const char *wkb, uint len,
return 0;
res->q_append(n_geom);
- for (wkb+=4; n_geom; n_geom--)
+ wkb+= 4;
+ while (n_geom--)
{
Geometry_buffer buffer;
Geometry *geom;
@@ -1752,10 +1756,11 @@ uint Gis_geometry_collection::init_from_wkb(const char *wkb, uint len,
!(g_len= geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
- wkb+= (g_len + WKB_HEADER_SIZE);
- len-= (g_len + WKB_HEADER_SIZE);
+ g_len+= WKB_HEADER_SIZE;
+ wkb+= g_len;
+ len-= g_len;
}
- return wkb-wkb_orig;
+ return (uint) (wkb - wkb_orig);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 61dc7772984..285a5c5696b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -102,8 +102,6 @@ static COND *optimize_cond(JOIN *join, COND *conds,
List<TABLE_LIST> *join_list,
Item::cond_result *cond_value);
static bool resolve_nested_join (TABLE_LIST *table);
-static COND *remove_eq_conds(THD *thd, COND *cond,
- Item::cond_result *cond_value);
static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
static bool open_tmp_table(TABLE *table);
static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
@@ -7474,7 +7472,7 @@ optimize_cond(JOIN *join, COND *conds, List<TABLE_LIST> *join_list,
COND_FALSE always false ( 1 = 2 )
*/
-static COND *
+COND *
remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
{
if (cond->type() == Item::COND_ITEM)
diff --git a/sql/sql_select.h b/sql/sql_select.h
index e0f4056e5da..28f5888af76 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -524,3 +524,4 @@ bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref);
bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error);
int safe_index_read(JOIN_TAB *tab);
+COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index f83bd24f5d3..bd19d4d85f3 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -132,7 +132,7 @@ int mysql_update(THD *thd,
ha_rows updated, found;
key_map old_used_keys;
TABLE *table;
- SQL_SELECT *select;
+ SQL_SELECT *select= 0;
READ_RECORD info;
SELECT_LEX *select_lex= &thd->lex->select_lex;
bool need_reopen;
@@ -228,11 +228,19 @@ int mysql_update(THD *thd,
DBUG_RETURN(1); /* purecov: inspected */
}
+ if (conds)
+ {
+ Item::cond_result cond_value;
+ conds= remove_eq_conds(thd, conds, &cond_value);
+ if (cond_value == Item::COND_FALSE)
+ limit= 0; // Impossible WHERE
+ }
// Don't count on usage of 'only index' when calculating which key to use
table->used_keys.clear_all();
- select= make_select(table, 0, 0, conds, 0, &error);
- if (error ||
- (select && select->check_quick(thd, safe_update, limit)) || !limit)
+ if (limit)
+ select= make_select(table, 0, 0, conds, 0, &error);
+ if (error || !limit ||
+ (select && select->check_quick(thd, safe_update, limit)))
{
delete select;
free_underlaid_joins(thd, select_lex);