@@ -960,119 +960,121 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
960
960
SEQUENCE *seq;
961
961
No_such_table_error_handler no_such_table_handler;
962
962
DBUG_ENTER (" Sql_cmd_alter_sequence::execute" );
963
+ {
963
964
#if defined(HAVE_REPLICATION)
964
- /* No wakeup():s of subsequent commits is allowed in this function. */
965
- wait_for_commit_raii suspend_wfc (thd);
965
+ /* No wakeup():s of subsequent commits is allowed in this function. */
966
+ wait_for_commit_raii suspend_wfc (thd);
966
967
#endif
967
968
968
- if (check_access (thd, ALTER_ACL, first_table->db .str ,
969
- &first_table->grant .privilege ,
970
- &first_table->grant .m_internal ,
971
- 0 , 0 ))
972
- DBUG_RETURN (TRUE ); /* purecov: inspected */
969
+ if (check_access (thd, ALTER_ACL, first_table->db .str ,
970
+ &first_table->grant .privilege ,
971
+ &first_table->grant .m_internal ,
972
+ 0 , 0 ))
973
+ DBUG_RETURN (TRUE ); /* purecov: inspected */
973
974
974
- if (check_grant (thd, ALTER_ACL, first_table, FALSE , 1 , FALSE ))
975
- DBUG_RETURN (TRUE ); /* purecov: inspected */
975
+ if (check_grant (thd, ALTER_ACL, first_table, FALSE , 1 , FALSE ))
976
+ DBUG_RETURN (TRUE ); /* purecov: inspected */
976
977
977
978
#ifdef WITH_WSREP
978
- if (WSREP (thd) && wsrep_thd_is_local (thd))
979
- {
980
- const bool used_engine= lex->create_info .used_fields & HA_CREATE_USED_ENGINE;
981
- if (wsrep_check_sequence (thd, new_seq, used_engine))
982
- DBUG_RETURN (TRUE );
979
+ if (WSREP (thd) && wsrep_thd_is_local (thd))
980
+ {
981
+ const bool used_engine= lex->create_info .used_fields & HA_CREATE_USED_ENGINE;
982
+ if (wsrep_check_sequence (thd, new_seq, used_engine))
983
+ DBUG_RETURN (TRUE );
984
+
985
+ if (wsrep_to_isolation_begin (thd, first_table->db .str ,
986
+ first_table->table_name .str ,
987
+ first_table))
988
+ {
989
+ DBUG_RETURN (TRUE );
990
+ }
991
+ }
992
+ #endif /* WITH_WSREP */
983
993
984
- if (wsrep_to_isolation_begin (thd, first_table->db .str ,
985
- first_table->table_name .str ,
986
- first_table))
994
+ if (if_exists ())
995
+ thd->push_internal_handler (&no_such_table_handler);
996
+ error= open_and_lock_tables (thd, first_table, FALSE , 0 );
997
+ if (if_exists ())
998
+ {
999
+ trapped_errors= no_such_table_handler.safely_trapped_errors ();
1000
+ thd->pop_internal_handler ();
1001
+ }
1002
+ if (unlikely (error))
987
1003
{
1004
+ if (trapped_errors)
1005
+ {
1006
+ StringBuffer<FN_REFLEN> tbl_name;
1007
+ tbl_name.append (&first_table->db );
1008
+ tbl_name.append (' .' );
1009
+ tbl_name.append (&first_table->table_name );
1010
+ push_warning_printf (thd, Sql_condition::WARN_LEVEL_NOTE,
1011
+ ER_UNKNOWN_SEQUENCES,
1012
+ ER_THD (thd, ER_UNKNOWN_SEQUENCES),
1013
+ tbl_name.c_ptr_safe ());
1014
+ my_ok (thd);
1015
+ DBUG_RETURN (FALSE );
1016
+ }
988
1017
DBUG_RETURN (TRUE );
989
1018
}
990
- }
991
- #endif /* WITH_WSREP */
992
1019
993
- if (if_exists ())
994
- thd->push_internal_handler (&no_such_table_handler);
995
- error= open_and_lock_tables (thd, first_table, FALSE , 0 );
996
- if (if_exists ())
997
- {
998
- trapped_errors= no_such_table_handler.safely_trapped_errors ();
999
- thd->pop_internal_handler ();
1000
- }
1001
- if (unlikely (error))
1002
- {
1003
- if (trapped_errors)
1020
+ table= first_table->table ;
1021
+ seq= table->s ->sequence ;
1022
+
1023
+ seq->write_lock (table);
1024
+ new_seq->reserved_until = seq->reserved_until ;
1025
+
1026
+ /* Copy from old sequence those fields that the user didn't specified */
1027
+ if (!(new_seq->used_fields & seq_field_used_increment))
1028
+ new_seq->increment = seq->increment ;
1029
+ if (!(new_seq->used_fields & seq_field_used_min_value))
1030
+ new_seq->min_value = seq->min_value ;
1031
+ if (!(new_seq->used_fields & seq_field_used_max_value))
1032
+ new_seq->max_value = seq->max_value ;
1033
+ if (!(new_seq->used_fields & seq_field_used_start))
1034
+ new_seq->start = seq->start ;
1035
+ if (!(new_seq->used_fields & seq_field_used_cache))
1036
+ new_seq->cache = seq->cache ;
1037
+ if (!(new_seq->used_fields & seq_field_used_cycle))
1038
+ new_seq->cycle = seq->cycle ;
1039
+
1040
+ /* If we should restart from a new value */
1041
+ if (new_seq->used_fields & seq_field_used_restart)
1004
1042
{
1005
- StringBuffer<FN_REFLEN> tbl_name;
1006
- tbl_name.append (&first_table->db );
1007
- tbl_name.append (' .' );
1008
- tbl_name.append (&first_table->table_name );
1009
- push_warning_printf (thd, Sql_condition::WARN_LEVEL_NOTE,
1010
- ER_UNKNOWN_SEQUENCES,
1011
- ER_THD (thd, ER_UNKNOWN_SEQUENCES),
1012
- tbl_name.c_ptr_safe ());
1013
- my_ok (thd);
1014
- DBUG_RETURN (FALSE );
1043
+ if (!(new_seq->used_fields & seq_field_used_restart_value))
1044
+ new_seq->restart = new_seq->start ;
1045
+ new_seq->reserved_until = new_seq->restart ;
1015
1046
}
1016
- DBUG_RETURN (TRUE );
1017
- }
1018
1047
1019
- table= first_table->table ;
1020
- seq= table->s ->sequence ;
1021
-
1022
- seq->write_lock (table);
1023
- new_seq->reserved_until = seq->reserved_until ;
1024
-
1025
- /* Copy from old sequence those fields that the user didn't specified */
1026
- if (!(new_seq->used_fields & seq_field_used_increment))
1027
- new_seq->increment = seq->increment ;
1028
- if (!(new_seq->used_fields & seq_field_used_min_value))
1029
- new_seq->min_value = seq->min_value ;
1030
- if (!(new_seq->used_fields & seq_field_used_max_value))
1031
- new_seq->max_value = seq->max_value ;
1032
- if (!(new_seq->used_fields & seq_field_used_start))
1033
- new_seq->start = seq->start ;
1034
- if (!(new_seq->used_fields & seq_field_used_cache))
1035
- new_seq->cache = seq->cache ;
1036
- if (!(new_seq->used_fields & seq_field_used_cycle))
1037
- new_seq->cycle = seq->cycle ;
1038
-
1039
- /* If we should restart from a new value */
1040
- if (new_seq->used_fields & seq_field_used_restart)
1041
- {
1042
- if (!(new_seq->used_fields & seq_field_used_restart_value))
1043
- new_seq->restart = new_seq->start ;
1044
- new_seq->reserved_until = new_seq->restart ;
1045
- }
1048
+ /* Let check_and_adjust think all fields are used */
1049
+ new_seq->used_fields = ~0 ;
1050
+ if (new_seq->check_and_adjust (0 ))
1051
+ {
1052
+ my_error (ER_SEQUENCE_INVALID_DATA, MYF (0 ),
1053
+ first_table->db .str ,
1054
+ first_table->table_name .str );
1055
+ error= 1 ;
1056
+ seq->write_unlock (table);
1057
+ goto end;
1058
+ }
1046
1059
1047
- /* Let check_and_adjust think all fields are used */
1048
- new_seq->used_fields = ~0 ;
1049
- if (new_seq->check_and_adjust (0 ))
1050
- {
1051
- my_error (ER_SEQUENCE_INVALID_DATA, MYF (0 ),
1052
- first_table->db .str ,
1053
- first_table->table_name .str );
1054
- error= 1 ;
1060
+ if (likely (!(error= new_seq->write (table, 1 ))))
1061
+ {
1062
+ /* Store the sequence values in table share */
1063
+ seq->copy (new_seq);
1064
+ }
1065
+ else
1066
+ table->file ->print_error (error, MYF (0 ));
1055
1067
seq->write_unlock (table);
1056
- goto end;
1057
- }
1058
-
1059
- if (likely (!(error= new_seq->write (table, 1 ))))
1060
- {
1061
- /* Store the sequence values in table share */
1062
- seq->copy (new_seq);
1068
+ if (trans_commit_stmt (thd))
1069
+ error= 1 ;
1070
+ if (trans_commit_implicit (thd))
1071
+ error= 1 ;
1072
+ DBUG_EXECUTE_IF (" hold_worker_on_schedule" ,
1073
+ {
1074
+ /* delay binlogging of a parent trx in rpl_parallel_seq */
1075
+ my_sleep (100000 );
1076
+ });
1063
1077
}
1064
- else
1065
- table->file ->print_error (error, MYF (0 ));
1066
- seq->write_unlock (table);
1067
- if (trans_commit_stmt (thd))
1068
- error= 1 ;
1069
- if (trans_commit_implicit (thd))
1070
- error= 1 ;
1071
- DBUG_EXECUTE_IF (" hold_worker_on_schedule" ,
1072
- {
1073
- /* delay binlogging of a parent trx in rpl_parallel_seq */
1074
- my_sleep (100000 );
1075
- });
1076
1078
if (likely (!error))
1077
1079
error= write_bin_log (thd, 1 , thd->query (), thd->query_length ());
1078
1080
if (likely (!error))
0 commit comments