diff options
author | unknown <patg@krsna.patg.net> | 2005-11-01 17:07:13 -0800 |
---|---|---|
committer | unknown <patg@krsna.patg.net> | 2005-11-01 17:07:13 -0800 |
commit | 02ac7bef876ba51f13c09174da7a706ea35b6613 (patch) | |
tree | ce4d0c1782e669224f1b5e469cf82f8e9655c363 | |
parent | fe11647273c1264a2c676159b2c95ef9d32f80bf (diff) | |
parent | a486b3d7c50ccf13e3a0c1a96f67ae541ec733f8 (diff) | |
download | mariadb-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
-rw-r--r-- | client/mysql.cc | 9 | ||||
-rw-r--r-- | client/mysqltest.c | 13 | ||||
-rw-r--r-- | myisam/mi_check.c | 2 | ||||
-rw-r--r-- | mysql-test/r/bdb.result | 56 | ||||
-rw-r--r-- | mysql-test/r/update.result | 8 | ||||
-rw-r--r-- | mysql-test/t/update.test | 9 | ||||
-rw-r--r-- | mysys/base64.c | 18 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 19 | ||||
-rw-r--r-- | sql/ha_berkeley.h | 3 | ||||
-rw-r--r-- | sql/item_func.cc | 1 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 1 | ||||
-rw-r--r-- | sql/spatial.cc | 39 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.h | 1 | ||||
-rw-r--r-- | sql/sql_update.cc | 16 |
15 files changed, 124 insertions, 75 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index bf417e73e22..441687e2e4e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1133,10 +1133,11 @@ static COMMANDS *find_command(char *name,char cmd_char) parsing the row and calling find_command() */ if (strstr(name, "\\g") || (strstr(name, delimiter) && - strlen(name) >= 9 && - my_strnncoll(charset_info,(uchar*) name, - 9, - (const uchar*) "delimiter", 9))) + !(strlen(name) >= 9 && + !my_strnncoll(charset_info, + (uchar*) name, 9, + (const uchar*) "delimiter", + 9)))) DBUG_RETURN((COMMANDS *) 0); if ((end=strcont(name," \t"))) { diff --git a/client/mysqltest.c b/client/mysqltest.c index 6543dba0bb8..58c0928c36d 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -3616,19 +3616,24 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) /* Read result from each column */ for (col_idx= 0; col_idx < num_fields; col_idx++) { - /* FIXME is string terminated? */ - const char *val= (const char *)bind[col_idx].buffer; - ulonglong len= *bind[col_idx].length; + const char *val; + ulonglong len; if (col_idx < max_replace_column && replace_column[col_idx]) { val= replace_column[col_idx]; len= strlen(val); } - if (*bind[col_idx].is_null) + else if (*bind[col_idx].is_null) { val= "NULL"; len= 4; } + else + { + /* FIXME is string terminated? */ + val= (const char *) bind[col_idx].buffer; + len= *bind[col_idx].length; + } if (!display_result_vertically) { if (col_idx) /* No tab before first col */ diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 5e7b8e5a898..6296193d6b0 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1848,7 +1848,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, if (sort_one_index(param,info,keyinfo,next_page,new_file)) { DBUG_PRINT("error", - ("From page: %ld, keyoffset: 0x%lx used_length: %d", + ("From page: %ld, keyoffset: %lu used_length: %d", (ulong) pagepos, (ulong) (keypos - buff), (int) used_length)); DBUG_DUMP("buff",(byte*) buff,used_length); diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 2bba44d36e9..530ff6ef59b 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1584,8 +1584,6 @@ g 10 h 10 i 10 alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); -Warnings: -Warning 1071 Specified key was too long; max key length is 255 bytes show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1594,7 +1592,7 @@ t1 CREATE TABLE `t1` ( `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), - KEY `v` (`v`(255)) + KEY `v` (`v`) ) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1 select count(*) from t1 where v='a'; count(*) @@ -1616,19 +1614,19 @@ count(*) 9 explain select count(*) from t1 where v='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 258 const # Using where +1 SIMPLE t1 ref v v 303 const # Using where explain select count(*) from t1 where v like 'a%'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 258 NULL # Using where +1 SIMPLE t1 range v v 303 NULL # Using where explain select count(*) from t1 where v between 'a' and 'a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 258 const # Using where +1 SIMPLE t1 ref v v 303 const # Using where explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 258 const # Using where +1 SIMPLE t1 ref v v 303 const # Using where explain select * from t1 where v='a'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 258 const # Using where +1 SIMPLE t1 ref v v 303 const # Using where select v,count(*) from t1 group by v limit 10; v count(*) a 1 @@ -1656,15 +1654,15 @@ i 10 select sql_big_result v,count(t) from t1 group by v limit 10; v count(t) a 1 -a 10 -b 10 -c 10 -d 10 -e 10 -f 10 -g 10 -h 10 -i 10 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 alter table t1 drop key v, add key v (v(30)); show create table t1; Table Create Table @@ -1746,8 +1744,6 @@ g 10 h 10 i 10 alter table t1 modify v varchar(600), drop key v, add key v (v); -Warnings: -Warning 1071 Specified key was too long; max key length is 255 bytes show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1756,7 +1752,7 @@ t1 CREATE TABLE `t1` ( `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), - KEY `v` (`v`(255)) + KEY `v` (`v`) ) ENGINE=BerkeleyDB DEFAULT CHARSET=latin1 select v,count(*) from t1 group by v limit 10; v count(*) @@ -1785,15 +1781,15 @@ i 10 select sql_big_result v,count(t) from t1 group by v limit 10; v count(t) a 1 -a 10 -b 10 -c 10 -d 10 -e 10 -f 10 -g 10 -h 10 -i 10 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 +h 10 +i 10 drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); @@ -1874,7 +1870,7 @@ a b drop table t1; create table t1 (v varchar(65530), key(v)); Warnings: -Warning 1071 Specified key was too long; max key length is 255 bytes +Warning 1071 Specified key was too long; max key length is 1024 bytes drop table if exists t1; create table t1 (v varchar(65536)); Warnings: diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 71de6830963..aeb44fa4e6c 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -337,3 +337,11 @@ a b 22 3 23 3 drop table t1; +create table t1 (f1 date not null); +insert into t1 values('2000-01-01'),('0000-00-00'); +update t1 set f1='2002-02-02' where f1 is null; +select * from t1; +f1 +2000-01-01 +2002-02-02 +drop table t1; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 9235d30c500..2a151f0dd38 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -261,4 +261,13 @@ update t1 set a=a+12,b=3 order by a limit 3; select * from t1 order by a; drop table t1; + +# +# Bug#14186 select datefield is null not updated +# +create table t1 (f1 date not null); +insert into t1 values('2000-01-01'),('0000-00-00'); +update t1 set f1='2002-02-02' where f1 is null; +select * from t1; +drop table t1; # End of 4.1 tests diff --git a/mysys/base64.c b/mysys/base64.c index 0fcd6f096f5..0165982fb67 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -27,9 +27,13 @@ static char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" int base64_needed_encoded_length(int length_of_data) { - return ceil(length_of_data * 4 / 3) /* base64 chars */ + - ceil(length_of_data / (76 * 3 / 4)) /* Newlines */ + - 3 /* Padding */; + int nb_base64_chars; + nb_base64_chars= (length_of_data + 2) / 3 * 4; + + return + nb_base64_chars + /* base64 char incl padding */ + (nb_base64_chars - 1)/ 76 + /* newlines */ + 1; /* NUL termination of string */ } @@ -89,6 +93,7 @@ base64_encode(const void *src, size_t src_len, char *dst) else *dst++= base64_table[(c >> 0) & 0x3f]; } + *dst= '\0'; return 0; } @@ -209,6 +214,7 @@ main(void) size_t j; size_t k, l; size_t dst_len; + size_t needed_length; for (i= 0; i < 500; i++) { @@ -227,8 +233,12 @@ main(void) } /* Encode */ - str= (char *) malloc(base64_needed_encoded_length(src_len)); + needed_length= base64_needed_encoded_length(src_len); + str= (char *) malloc(needed_length); + for (k= 0; k < needed_length; k++) + str[k]= 0xff; /* Fill memory to check correct NUL termination */ require(base64_encode(src, src_len, str) == 0); + require(needed_length == strlen(str) + 1); /* Decode */ dst= (char *) malloc(base64_needed_decoded_length(strlen(str))); diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 873aff251db..a584c384712 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -11,6 +11,7 @@ # executing mysqld_safe KILL_MYSQLD=1; +MYSQLD= trap '' 1 2 3 15 # we shouldn't let anyone kill us @@ -174,14 +175,6 @@ export MYSQL_HOME user=@MYSQLD_USER@ niceness=0 -# Use the mysqld-max binary by default if the user doesn't specify a binary -if test -x $ledir/mysqld-max -then - MYSQLD=mysqld-max -else - MYSQLD=mysqld -fi - # these rely on $DATADIR by default, so we'll set them later on pid_file= err_log= @@ -220,6 +213,16 @@ then chown $user $mysql_unix_port_dir fi +# Use the mysqld-max binary by default if the user doesn't specify a binary +if test -z "$MYSQLD" +then + if test -x $ledir/mysqld-max + then + MYSQLD=mysqld-max + else + MYSQLD=mysqld + fi +fi if test ! -x $ledir/$MYSQLD then 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); |