Commit 37a99172 authored by unknown's avatar unknown

INSERT ... UPDATE syntax (syntax only)

sql_yacc.yy and sql_parse.cc cleanup


sql/lex.h:
  INSERT ... UPDATE syntax
sql/sql_parse.cc:
  merged SQLCOM_REPLACE and SQLCOM_INSERT the same way their _SELECT counterparts were merged long time ago - just to remove duplicate code and be consistent :)
  now nobody needs SQLCOM_REPLACE* at all :))
sql/sql_yacc.yy:
  INSERT ... UPDATE syntax
  cleanup
parent b01993fd
......@@ -135,6 +135,7 @@ static SYMBOL symbols[] = {
{ "DROP", SYM(DROP),0,0},
{ "DUMPFILE", SYM(DUMPFILE),0,0},
{ "DYNAMIC", SYM(DYNAMIC_SYM),0,0},
{ "DUPLICATE", SYM(DUPLICATE),0,0},
{ "ERRORS", SYM(ERRORS),0,0},
{ "END", SYM(END),0,0},
{ "ELSE", SYM(ELSE),0,0},
......
......@@ -1961,25 +1961,19 @@ mysql_execute_command(THD *thd)
close_thread_tables(thd);
}
break;
case SQLCOM_REPLACE:
case SQLCOM_INSERT:
if (check_access(thd,INSERT_ACL,tables->db,&tables->grant.privilege))
{
ulong privilege= (lex->duplicates == DUP_REPLACE ?
INSERT_ACL | DELETE_ACL : INSERT_ACL);
if (check_access(thd,privilege,tables->db,&tables->grant.privilege))
goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INSERT_ACL,tables))
if (grant_option && check_grant(thd,privilege,tables))
goto error;
res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
lex->duplicates);
break;
case SQLCOM_REPLACE:
if (check_access(thd,INSERT_ACL | DELETE_ACL,
tables->db,&tables->grant.privilege))
goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INSERT_ACL | DELETE_ACL,
tables))
goto error;
res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
DUP_REPLACE);
break;
}
case SQLCOM_REPLACE_SELECT:
case SQLCOM_INSERT_SELECT:
{
......@@ -1989,8 +1983,8 @@ mysql_execute_command(THD *thd)
select privileges for the rest
*/
{
ulong privilege= (lex->sql_command == SQLCOM_INSERT_SELECT ?
INSERT_ACL : INSERT_ACL | DELETE_ACL);
ulong privilege= (lex->duplicates == DUP_REPLACE ?
INSERT_ACL | DELETE_ACL : INSERT_ACL);
TABLE_LIST *save_next=tables->next;
tables->next=0;
if (check_access(thd, privilege,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment