Commit f60e47fd authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

INSERT ... UPDATE syntax (syntax only)

sql_yacc.yy and sql_parse.cc cleanup
parent 27dc59e7
...@@ -135,6 +135,7 @@ static SYMBOL symbols[] = { ...@@ -135,6 +135,7 @@ static SYMBOL symbols[] = {
{ "DROP", SYM(DROP),0,0}, { "DROP", SYM(DROP),0,0},
{ "DUMPFILE", SYM(DUMPFILE),0,0}, { "DUMPFILE", SYM(DUMPFILE),0,0},
{ "DYNAMIC", SYM(DYNAMIC_SYM),0,0}, { "DYNAMIC", SYM(DYNAMIC_SYM),0,0},
{ "DUPLICATE", SYM(DUPLICATE),0,0},
{ "ERRORS", SYM(ERRORS),0,0}, { "ERRORS", SYM(ERRORS),0,0},
{ "END", SYM(END),0,0}, { "END", SYM(END),0,0},
{ "ELSE", SYM(ELSE),0,0}, { "ELSE", SYM(ELSE),0,0},
...@@ -342,7 +343,7 @@ static SYMBOL symbols[] = { ...@@ -342,7 +343,7 @@ static SYMBOL symbols[] = {
{ "SQL_CALC_FOUND_ROWS", SYM(SQL_CALC_FOUND_ROWS),0,0}, { "SQL_CALC_FOUND_ROWS", SYM(SQL_CALC_FOUND_ROWS),0,0},
{ "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM), 0, 0}, { "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM), 0, 0},
{ "SQL_SMALL_RESULT", SYM(SQL_SMALL_RESULT),0,0}, { "SQL_SMALL_RESULT", SYM(SQL_SMALL_RESULT),0,0},
{ "SQL_THREAD", SYM(SQL_THREAD),0,0}, { "SQL_THREAD", SYM(SQL_THREAD),0,0},
{ "SSL", SYM(SSL_SYM),0,0}, { "SSL", SYM(SSL_SYM),0,0},
{ "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN),0,0}, { "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN),0,0},
{ "START", SYM(START_SYM),0,0}, { "START", SYM(START_SYM),0,0},
......
...@@ -1905,7 +1905,7 @@ mysql_execute_command(THD *thd) ...@@ -1905,7 +1905,7 @@ mysql_execute_command(THD *thd)
select_lex->select_limit, select_lex->select_limit,
lex->duplicates); lex->duplicates);
} }
else else
{ {
multi_update *result; multi_update *result;
uint table_count; uint table_count;
...@@ -1932,8 +1932,8 @@ mysql_execute_command(THD *thd) ...@@ -1932,8 +1932,8 @@ mysql_execute_command(THD *thd)
if ((res=open_and_lock_tables(thd,tables))) if ((res=open_and_lock_tables(thd,tables)))
break; break;
unit->select_limit_cnt= HA_POS_ERROR; unit->select_limit_cnt= HA_POS_ERROR;
if (!setup_fields(thd,tables,select_lex->item_list,1,0,0) && if (!setup_fields(thd,tables,select_lex->item_list,1,0,0) &&
!setup_fields(thd,tables,lex->value_list,0,0,0) && !setup_fields(thd,tables,lex->value_list,0,0,0) &&
!thd->fatal_error && !thd->fatal_error &&
(result=new multi_update(thd,tables,select_lex->item_list, (result=new multi_update(thd,tables,select_lex->item_list,
lex->duplicates, table_count))) lex->duplicates, table_count)))
...@@ -1946,7 +1946,7 @@ mysql_execute_command(THD *thd) ...@@ -1946,7 +1946,7 @@ mysql_execute_command(THD *thd)
total_list.push_back(item); total_list.push_back(item);
while ((item=value_list++)) while ((item=value_list++))
total_list.push_back(item); total_list.push_back(item);
res= mysql_select(thd, tables, total_list, res= mysql_select(thd, tables, total_list,
select_lex->where, select_lex->where,
(ORDER *)NULL, (ORDER *)NULL, (Item *)NULL, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL,
...@@ -1960,26 +1960,20 @@ mysql_execute_command(THD *thd) ...@@ -1960,26 +1960,20 @@ mysql_execute_command(THD *thd)
res= -1; // Error is not sent res= -1; // Error is not sent
close_thread_tables(thd); close_thread_tables(thd);
} }
break;
case SQLCOM_INSERT:
if (check_access(thd,INSERT_ACL,tables->db,&tables->grant.privilege))
goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INSERT_ACL,tables))
goto error;
res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
lex->duplicates);
break; break;
case SQLCOM_REPLACE: case SQLCOM_REPLACE:
if (check_access(thd,INSERT_ACL | DELETE_ACL, case SQLCOM_INSERT:
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 */ goto error; /* purecov: inspected */
if (grant_option && check_grant(thd,INSERT_ACL | DELETE_ACL, if (grant_option && check_grant(thd,privilege,tables))
tables))
goto error; goto error;
res = mysql_insert(thd,tables,lex->field_list,lex->many_values, res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
DUP_REPLACE); lex->duplicates);
break; break;
}
case SQLCOM_REPLACE_SELECT: case SQLCOM_REPLACE_SELECT:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
{ {
...@@ -1989,8 +1983,8 @@ mysql_execute_command(THD *thd) ...@@ -1989,8 +1983,8 @@ mysql_execute_command(THD *thd)
select privileges for the rest select privileges for the rest
*/ */
{ {
ulong privilege= (lex->sql_command == SQLCOM_INSERT_SELECT ? ulong privilege= (lex->duplicates == DUP_REPLACE ?
INSERT_ACL : INSERT_ACL | DELETE_ACL); INSERT_ACL | DELETE_ACL : INSERT_ACL);
TABLE_LIST *save_next=tables->next; TABLE_LIST *save_next=tables->next;
tables->next=0; tables->next=0;
if (check_access(thd, privilege, 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