diff options
author | unknown <monty@mysql.com> | 2004-10-22 18:44:51 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-10-22 18:44:51 +0300 |
commit | bc6652db9b1f5f302648c3a920fb1fa25449a6d8 (patch) | |
tree | 6faefd7a2f197f4031ef94eb74fc71f8f2936185 /sql | |
parent | cfcca61a177eecacdc2c525c1ba4fea082b1b1c4 (diff) | |
download | mariadb-git-bc6652db9b1f5f302648c3a920fb1fa25449a6d8.tar.gz |
Fix compiler warnings (detected by Intel's C++ compiler)
Fixed checking of privilege handling in CREATE ... SELECT (Bug #6094)
client/mysql.cc:
Fix compiler warnings
client/mysqltest.c:
Fix wrong counting of lines
Remove compiler warnings
heap/hp_hash.c:
Fix compiler warnings
innobase/dict/dict0load.c:
Fix compiler warnings
innobase/include/mem0mem.h:
Fix compiler warnings
libmysql/client_settings.h:
Fix compiler warnings
myisam/ft_nlq_search.c:
Add comments about compiler warnings
myisam/rt_index.c:
Add comments about compiler warnings
myisam/rt_mbr.c:
Add comments about compiler warnings
mysql-test/r/ps.result:
Test case for bug#6094
mysql-test/t/ps.test:
Test case for bug#6094
mysys/hash.c:
Fix compiler warnings
mysys/my_handler.c:
Add comments about compiler warnings
mysys/my_thr_init.c:
Add comments about compiler warnings
ndb/include/mgmapi/mgmapi.h:
Fix compiler warnings
regex/main.c:
Fix compiler warnings
sql/item.h:
Fix compiler warnings
sql/item_func.h:
Add comments about compiler warnings
sql/spatial.h:
Add comments about compiler warnings
sql/sql_lex.h:
Fix compiler warning
sql/sql_list.h:
Fix compiler warning
sql/sql_parse.cc:
Move testing of access rights of tables in CREATE ... SELECT to create_table_precheck() to fix privilege checking in CREATE ... SELECT
(Bug #6094)
sql/sql_prepare.cc:
Remove not needed empty line
sql/sql_string.h:
Fix compiler warnings
strings/ctype-mb.c:
Fix compiler warnings
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 3 | ||||
-rw-r--r-- | sql/item_func.h | 2 | ||||
-rw-r--r-- | sql/spatial.h | 9 | ||||
-rw-r--r-- | sql/sql_lex.h | 1 | ||||
-rw-r--r-- | sql/sql_list.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 85 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 1 | ||||
-rw-r--r-- | sql/sql_string.h | 4 |
8 files changed, 71 insertions, 36 deletions
diff --git a/sql/item.h b/sql/item.h index b3142ec4b06..0bf12794404 100644 --- a/sql/item.h +++ b/sql/item.h @@ -97,7 +97,8 @@ public: static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); } static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } - static void operator delete(void *ptr,size_t size) {} /*lint -e715 */ + static void operator delete(void *ptr,size_t size) {} + static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, diff --git a/sql/item_func.h b/sql/item_func.h index e61459cfbd8..6e43d66a32d 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -348,6 +348,7 @@ class Item_dec_func :public Item_real_func #ifndef HAVE_FINITE return value; #else + /* The following should be safe, even if we compare doubles */ if (finite(value) && value != POSTFIX_ERROR) return value; null_value=1; @@ -1032,6 +1033,7 @@ public: table_map not_null_tables() const { return 0; } bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); bool eq(const Item *, bool binary_cmp) const; + /* The following should be safe, even if we compare doubles */ longlong val_int() { DBUG_ASSERT(fixed == 1); return val()!=0.0; } double val(); void print(String *str); diff --git a/sql/spatial.h b/sql/spatial.h index 45db1ca8d00..b96434831a1 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -97,12 +97,14 @@ struct MBR int equals(const MBR *mbr) { + /* The following should be safe, even if we compare doubles */ return ((mbr->xmin == xmin) && (mbr->ymin == ymin) && (mbr->xmax == xmax) && (mbr->ymax == ymax)); } int disjoint(const MBR *mbr) { + /* The following should be safe, even if we compare doubles */ return ((mbr->xmin > xmax) || (mbr->ymin > ymax) || (mbr->xmax < xmin) || (mbr->ymax < ymin)); } @@ -114,6 +116,7 @@ struct MBR int touches(const MBR *mbr) { + /* The following should be safe, even if we compare doubles */ return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && ((mbr->ymin >= ymin) && (mbr->ymin <= ymax) || (mbr->ymax >= ymin) && (mbr->ymax <= ymax))) || @@ -124,18 +127,21 @@ struct MBR int within(const MBR *mbr) { + /* The following should be safe, even if we compare doubles */ return ((mbr->xmin <= xmin) && (mbr->ymin <= ymin) && (mbr->xmax >= xmax) && (mbr->ymax >= ymax)); } int contains(const MBR *mbr) { + /* The following should be safe, even if we compare doubles */ return ((mbr->xmin >= xmin) && (mbr->ymin >= ymin) && (mbr->xmax <= xmax) && (mbr->ymax <= ymax)); } bool inner_point(double x, double y) const { + /* The following should be safe, even if we compare doubles */ return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>x); } @@ -164,6 +170,9 @@ public: return buffer; } + static void operator delete(void *ptr, void *buffer) + {} + enum wkbType { wkb_point= 1, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 38cdde019ff..040a52ae30e 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -241,6 +241,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) {} + static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {} virtual ~st_select_lex_node() {} inline st_select_lex_node* get_master() { return master; } diff --git a/sql/sql_list.h b/sql/sql_list.h index c3b9c7f87ea..38c5af2a4f7 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -41,6 +41,8 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr, size_t size, MEM_ROOT *mem_root) + { TRASH(ptr, size); } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } #ifdef HAVE_purify bool dummy; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8279e32c8de..bb25fd57d0e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1862,8 +1862,8 @@ mysql_execute_command(THD *thd) { int res= 0; LEX *lex= thd->lex; - TABLE_LIST *tables= (TABLE_LIST*) lex->select_lex.table_list.first; SELECT_LEX *select_lex= &lex->select_lex; + TABLE_LIST *tables= (TABLE_LIST*) select_lex->table_list.first; SELECT_LEX_UNIT *unit= &lex->unit; DBUG_ENTER("mysql_execute_command"); @@ -2333,30 +2333,6 @@ mysql_execute_command(THD *thd) { select_result *result; - if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && - find_real_table_in_list(tables, create_table->db, - create_table->real_name)) - { - net_printf(thd,ER_UPDATE_TABLE_USED, create_table->real_name); - goto create_error; - } - if (lex->create_info.used_fields & HA_CREATE_USED_UNION) - { - TABLE_LIST *tab; - for (tab= tables; tab; tab= tab->next) - { - if (find_real_table_in_list((TABLE_LIST*) lex->create_info. - merge_list.first, - tables->db, tab->real_name)) - { - net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name); - goto create_error; - } - } - } - - if (tables && check_table_access(thd, SELECT_ACL, tables,0)) - goto create_error; // Error message is given select_lex->options|= SELECT_NO_UNLOCK; unit->offset_limit_cnt= select_lex->offset_limit; unit->select_limit_cnt= select_lex->select_limit+ @@ -5282,7 +5258,7 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) INSERT ... SELECT query pre-check SYNOPSIS - multi_delete_precheck() + insert_delete_precheck() thd Thread handler tables Global table list @@ -5404,26 +5380,69 @@ int insert_precheck(THD *thd, TABLE_LIST *tables) RETURN VALUE 0 OK 1 Error (message is sent to user) - -1 Error (message is not sent to user) */ int create_table_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *create_table) { LEX *lex= thd->lex; + SELECT_LEX *select_lex= &lex->select_lex; + ulong want_priv; + int error= 1; // Error message is given DBUG_ENTER("create_table_precheck"); - ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ? - CREATE_TMP_ACL : CREATE_ACL); + + want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ? + CREATE_TMP_ACL : CREATE_ACL); lex->create_info.alias= create_table->alias; if (check_access(thd, want_priv, create_table->db, &create_table->grant.privilege, 0, 0) || check_merge_table_access(thd, create_table->db, (TABLE_LIST *) lex->create_info.merge_list.first)) - DBUG_RETURN(1); - DBUG_RETURN((grant_option && want_priv != CREATE_TMP_ACL && - check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0)) ? - 1 : 0); + goto err; + if (grant_option && want_priv != CREATE_TMP_ACL && + check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0)) + goto err; + + if (select_lex->item_list.elements) + { + /* Check permissions for used tables in CREATE TABLE ... SELECT */ + + /* + For temporary tables or PREPARED STATEMETNS we don't have to check + if the created table exists + */ + if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && + ! thd->current_arena->is_stmt_prepare() && + find_real_table_in_list(tables, create_table->db, + create_table->real_name)) + { + net_printf(thd,ER_UPDATE_TABLE_USED, create_table->real_name); + + goto err; + } + if (lex->create_info.used_fields & HA_CREATE_USED_UNION) + { + TABLE_LIST *tab; + for (tab= tables; tab; tab= tab->next) + { + if (find_real_table_in_list((TABLE_LIST*) lex->create_info. + merge_list.first, + tables->db, tab->real_name)) + { + net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name); + goto err; + } + } + } + + if (tables && check_table_access(thd, SELECT_ACL, tables,0)) + goto err; + } + error= 0; + +err: + DBUG_RETURN(error); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 12f526c5566..0e939498925 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1391,7 +1391,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) lex->unit.create_total_list(thd, lex, &tables)) DBUG_RETURN(1); - switch (sql_command) { case SQLCOM_REPLACE: case SQLCOM_INSERT: diff --git a/sql/sql_string.h b/sql/sql_string.h index d8c4c3a87a1..2d368991159 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -71,7 +71,9 @@ public: } static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } - static void operator delete(void *ptr_arg,size_t size) /*lint -e715 */ + static void operator delete(void *ptr_arg,size_t size) + {} + static void operator delete(void *ptr_arg,size_t size, MEM_ROOT *mem_root) {} ~String() { free(); } |