summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authormonty@mashka.mysql.fi <>2002-11-20 21:44:32 +0200
committermonty@mashka.mysql.fi <>2002-11-20 21:44:32 +0200
commitf86d328927018f0392ee8c01af19f76d26865417 (patch)
tree6d1c49650f360f83a93d9c85a7d16e095176aae3 /sql/sql_delete.cc
parent5601da7ad30d1029f66889000263f4733605ceec (diff)
downloadmariadb-git-f86d328927018f0392ee8c01af19f76d26865417.tar.gz
Added some compatibility modes (for the future)
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 2d869fdda49..811cc7c5f5e 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -35,18 +35,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
SQL_SELECT *select=0;
READ_RECORD info;
bool using_limit=limit != HA_POS_ERROR;
- bool using_transactions, safe_update;
+ bool using_transactions, safe_update, const_cond;
ha_rows deleted;
DBUG_ENTER("mysql_delete");
if (!table_list->db)
table_list->db=thd->db;
- if (((safe_update=thd->options & OPTION_SAFE_UPDATES)) && !conds)
- {
- send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
- DBUG_RETURN(1);
- }
-
if (!(table = open_ltable(thd,table_list, lock_type)))
DBUG_RETURN(-1);
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
@@ -56,9 +50,17 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
setup_ftfuncs(&thd->lex.select_lex))
DBUG_RETURN(-1);
+ const_cond= (!conds || conds->const_item());
+ safe_update=test(thd->options & OPTION_SAFE_UPDATES);
+ if (safe_update && const_cond)
+ {
+ send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
+ DBUG_RETURN(1);
+ }
+
/* Test if the user wants to delete all rows */
- if (!using_limit && (!conds || conds->const_item()) &&
- !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && !safe_update)
+ if (!using_limit && const_cond &&
+ !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)))
{
deleted= table->file->records;
if (!(error=table->file->delete_all_rows()))