diff options
author | Andrei Elkin <aelkin@mysql.com> | 2008-06-19 21:47:59 +0300 |
---|---|---|
committer | Andrei Elkin <aelkin@mysql.com> | 2008-06-19 21:47:59 +0300 |
commit | bf327673103c73ff06401a417ebe0a4aae053200 (patch) | |
tree | 11737c99f6b55ce09a940cf41b895e0764b08d3c /sql/structs.h | |
parent | 40bcbf9bef3a1eb8ead711f116a690a17003c1cb (diff) | |
download | mariadb-git-bf327673103c73ff06401a417ebe0a4aae053200.tar.gz |
Bug#36443 Server crashes when executing insert when insert trigger on table
The crash appeared to be a result of allocating an instance of Discrete_interval
automatically that that was referred in out-of-declaration scope.
Fixed with correcting backing up and restoring scheme of
auto_inc_intervals_forced, introduced by bug#33029, by means of shallow copying;
added simulation code that forces executing those fixes of the former bug that
targeted at master-and-slave having incompatible bug#33029-prone versions.
mysql-test/suite/bugs/r/rpl_bug33029.result:
new results file
mysql-test/suite/bugs/t/rpl_bug33029.test:
test merely checks no crash happens on slave.
sql/slave.cc:
forcing to execute special logics implemented for bug#33029 if
simulate_bug33029 the debug option is set.
sql/sql_class.cc:
swaps of backed and the actual auto_inc_intervals_forced basing on shallow coping.
sql/structs.h:
Removing the deep _copy() and methods associated with it;
adding methods to Discrete_intervals_list:
private `=', copy constructor to prevent using;
private set_members();
public copy_shallow(), swap(), get_{head, tail, current}();
empty_no_free() through set_members().
Diffstat (limited to 'sql/structs.h')
-rw-r--r-- | sql/structs.h | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/sql/structs.h b/sql/structs.h index 809175fdde4..0a20eee0e9a 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -314,31 +314,22 @@ private: */ Discrete_interval *current; uint elements; // number of elements - - /* helper function for copy construct and assignment operator */ - void copy_(const Discrete_intervals_list& from) - { - for (Discrete_interval *i= from.head; i; i= i->next) - { - Discrete_interval j= *i; - append(&j); - } + void set_members(Discrete_interval *h, Discrete_interval *t, + Discrete_interval *c, uint el) + { + head= h; + tail= t; + current= c; + elements= el; } + void operator=(Discrete_intervals_list &); /* prevent use of these */ + Discrete_intervals_list(const Discrete_intervals_list &); + public: Discrete_intervals_list() : head(NULL), current(NULL), elements(0) {}; - Discrete_intervals_list(const Discrete_intervals_list& from) - { - copy_(from); - } - void operator=(const Discrete_intervals_list& from) - { - empty(); - copy_(from); - } void empty_no_free() { - head= current= NULL; - elements= 0; + set_members(NULL, NULL, NULL, 0); } void empty() { @@ -350,7 +341,24 @@ public: } empty_no_free(); } - + void copy_shallow(const Discrete_intervals_list * dli) + { + head= dli->get_head(); + tail= dli->get_tail(); + current= dli->get_current(); + elements= dli->nb_elements(); + } + void swap (Discrete_intervals_list * dli) + { + Discrete_interval *h, *t, *c; + uint el; + h= dli->get_head(); + t= dli->get_tail(); + c= dli->get_current(); + el= dli->nb_elements(); + dli->copy_shallow(this); + set_members(h, t, c, el); + } const Discrete_interval* get_next() { Discrete_interval *tmp= current; @@ -364,4 +372,7 @@ public: ulonglong minimum() const { return (head ? head->minimum() : 0); }; ulonglong maximum() const { return (head ? tail->maximum() : 0); }; uint nb_elements() const { return elements; } + Discrete_interval* get_head() const { return head; }; + Discrete_interval* get_tail() const { return tail; }; + Discrete_interval* get_current() const { return current; }; }; |