sql_yacc.yy, sql_parse.cc, sql_lex.h, mysqld.cc, lex.h:

  Add syntax SAVEPOINT id and ROLLBACK TO SAVEPOINT id. This is compatible with DB2 and Oracle but not with SQL Server. Savepoints do not do anything yet, this is just parsing.
parent 0058593c
...@@ -309,6 +309,7 @@ static SYMBOL symbols[] = { ...@@ -309,6 +309,7 @@ static SYMBOL symbols[] = {
{ "ROLLUP", SYM(ROLLUP_SYM),0,0}, { "ROLLUP", SYM(ROLLUP_SYM),0,0},
{ "ROW", SYM(ROW_SYM),0,0}, { "ROW", SYM(ROW_SYM),0,0},
{ "ROWS", SYM(ROWS_SYM),0,0}, { "ROWS", SYM(ROWS_SYM),0,0},
{ "SAVEPOINT", SYM(SAVEPOINT_SYM),0,0},
{ "SECOND", SYM(SECOND_SYM),0,0}, { "SECOND", SYM(SECOND_SYM),0,0},
{ "SELECT", SYM(SELECT_SYM),0,0}, { "SELECT", SYM(SELECT_SYM),0,0},
{ "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0}, { "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0},
......
...@@ -4021,6 +4021,7 @@ struct show_var_st status_vars[]= { ...@@ -4021,6 +4021,7 @@ struct show_var_st status_vars[]= {
{"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG}, {"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG},
{"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG}, {"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG},
{"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG}, {"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG},
{"Com_savepoint", (char*) (com_stat+(uint) SQLCOM_SAVEPOINT),SHOW_LONG},
{"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG}, {"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG},
{"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG}, {"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG},
{"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG}, {"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG},
......
...@@ -54,7 +54,8 @@ enum enum_sql_command { ...@@ -54,7 +54,8 @@ enum enum_sql_command {
SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION, SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION,
SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK, SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK,
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE, SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP, SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SAVEPOINT,
SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER, SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE, SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS, SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_SHOW_BINLOGS,
...@@ -154,6 +155,7 @@ typedef struct st_lex ...@@ -154,6 +155,7 @@ typedef struct st_lex
SQL_LIST proc_list, auxilliary_table_list; SQL_LIST proc_list, auxilliary_table_list;
TYPELIB *interval; TYPELIB *interval;
create_field *last_field; create_field *last_field;
char* savepoint_name; // Transaction savepoint id
Item *default_value; Item *default_value;
CONVERT *convert_set; CONVERT *convert_set;
CONVERT *thd_convert_set; // Set with SET CHAR SET CONVERT *thd_convert_set; // Set with SET CHAR SET
......
...@@ -2533,6 +2533,9 @@ mysql_execute_command(void) ...@@ -2533,6 +2533,9 @@ mysql_execute_command(void)
res= -1; res= -1;
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
break; break;
case SQLCOM_SAVEPOINT:
send_ok(&thd->net);
break;
default: /* Impossible */ default: /* Impossible */
send_ok(&thd->net); send_ok(&thd->net);
break; break;
......
...@@ -135,6 +135,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -135,6 +135,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token RESET_SYM %token RESET_SYM
%token ROLLBACK_SYM %token ROLLBACK_SYM
%token ROLLUP_SYM %token ROLLUP_SYM
%token SAVEPOINT_SYM
%token SELECT_SYM %token SELECT_SYM
%token SHOW %token SHOW
%token SLAVE %token SLAVE
...@@ -573,7 +574,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -573,7 +574,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
query verb_clause create change select do drop insert replace insert2 query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename insert_values update delete truncate rename
show describe load alter optimize flush show describe load alter optimize flush
reset purge begin commit rollback slave master_def master_defs reset purge begin commit rollback savepoint
slave master_def master_defs
repair restore backup analyze check start repair restore backup analyze check start
field_list field_list_item field_spec kill column_def key_def field_list field_list_item field_spec kill column_def key_def
select_item_list select_item values_list no_braces select_item_list select_item values_list no_braces
...@@ -649,6 +651,7 @@ verb_clause: ...@@ -649,6 +651,7 @@ verb_clause:
| restore | restore
| revoke | revoke
| rollback | rollback
| savepoint
| select | select
| set | set
| slave | slave
...@@ -3382,6 +3385,7 @@ keyword: ...@@ -3382,6 +3385,7 @@ keyword:
| ROWS_SYM {} | ROWS_SYM {}
| ROW_FORMAT_SYM {} | ROW_FORMAT_SYM {}
| ROW_SYM {} | ROW_SYM {}
| SAVEPOINT_SYM {}
| SECOND_SYM {} | SECOND_SYM {}
| SERIALIZABLE_SYM {} | SERIALIZABLE_SYM {}
| SESSION_SYM {} | SESSION_SYM {}
...@@ -3915,8 +3919,22 @@ commit: ...@@ -3915,8 +3919,22 @@ commit:
COMMIT_SYM { Lex->sql_command = SQLCOM_COMMIT;}; COMMIT_SYM { Lex->sql_command = SQLCOM_COMMIT;};
rollback: rollback:
ROLLBACK_SYM { Lex->sql_command = SQLCOM_ROLLBACK;}; ROLLBACK_SYM
{
Lex->sql_command = SQLCOM_ROLLBACK;
Lex->savepoint_name = NULL;
}
| ROLLBACK_SYM TO_SYM SAVEPOINT_SYM ident
{
Lex->sql_command = SQLCOM_ROLLBACK;
Lex->savepoint_name = $4.str;
};
savepoint:
SAVEPOINT_SYM ident
{
Lex->sql_command = SQLCOM_SAVEPOINT;
Lex->savepoint_name = $2.str;
};
/* /*
** UNIONS : glue selects together ** UNIONS : glue selects together
......
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