Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions Bugzilla/DB/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ use Storable qw(dclone freeze thaw);
# New SCHEMA_VERSIONs (2+) use this
use Data::Dumper;

# New New Schema (4+) use this
use Sereal qw(encode_sereal decode_sereal);

# Whether or not this database can safely create FKs when doing a
# CREATE TABLE statement. This is false for most DBs, because they
# prevent you from creating FKs on tables and columns that don't
Expand Down Expand Up @@ -197,7 +200,7 @@ update this column in this table."

=cut

use constant SCHEMA_VERSION => 3;
use constant SCHEMA_VERSION => 4;
use constant ADD_COLUMN => 'ADD COLUMN';
# Multiple FKs can be added using ALTER TABLE ADD CONSTRAINT in one
# SQL statement. This isn't true for all databases.
Expand Down Expand Up @@ -2996,16 +2999,7 @@ sub columns_equal {
sub serialize_abstract {
my ($self) = @_;

# Make it ok to eval
local $Data::Dumper::Purity = 1;

# Avoid cross-refs
local $Data::Dumper::Deepcopy = 1;

# Always sort keys to allow textual compare
local $Data::Dumper::Sortkeys = 1;

return Dumper($self->{abstract_schema});
return encode_sereal($self->{abstract_schema});
}

=item C<deserialize_abstract($serialized, $version)>
Expand All @@ -3030,12 +3024,15 @@ sub deserialize_abstract {
if ($version < 2) {
$thawed_hash = thaw($serialized);
}
else {
elsif ($version > 1 && $version < 4) {
my $cpt = new Safe;
$cpt->reval($serialized) ||
die "Unable to restore cached schema: " . $@;
$thawed_hash = ${$cpt->varglob('VAR1')};
}
else {
$thawed_hash = decode_sereal($serialized);
}

# Version 2 didn't have the "created" key for REFERENCES items.
if ($version < 3) {
Expand Down Expand Up @@ -3082,7 +3079,7 @@ object.

sub get_empty_schema {
my ($class) = @_;
return $class->deserialize_abstract(Dumper({}), SCHEMA_VERSION);
return $class->deserialize_abstract(encode_sereal({}), SCHEMA_VERSION);
}

1;
Expand Down