Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
cc8d6d39
Commit
cc8d6d39
authored
Apr 23, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 287986: Bugzilla::DB::Mysql needs a way to read in a Schema object from the disk
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=Tomas.Kopal, a=justdave
parent
372be50d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
21 deletions
+41
-21
DB.pm
Bugzilla/DB.pm
+35
-21
Mysql.pm
Bugzilla/DB/Mysql.pm
+6
-0
No files found.
Bugzilla/DB.pm
View file @
cc8d6d39
...
...
@@ -304,26 +304,15 @@ sub bz_get_field_defs {
sub
bz_setup_database
{
my
(
$self
)
=
@_
;
# Get a list of the existing tables (if any) in the database
my
@current_tables
=
$self
->
bz_table_list_real
();
# If we haven't ever stored a serialized schema,
# set up the bz_schema table and store it.
$self
->
_bz_init_schema_storage
();
my
@desired_tables
=
$self
->
_bz_schema
->
get_table_list
();
foreach
my
$table_name
(
@desired_tables
)
{
next
if
grep
(
$_
eq
$table_name
,
@current_tables
);
print
"Creating table $table_name ...\n"
;
my
@table_sql
=
$self
->
_bz_schema
->
get_table_ddl
(
$table_name
);
foreach
my
$sql_statement
(
@table_sql
)
{
$self
->
do
(
$sql_statement
);
}
$self
->
bz_add_table
(
$table_name
);
}
# And now, if we haven't already stored the serialized schema,
# store the ABSTRACT_SCHEMA from Bugzilla::DB::Schema.
# XXX - The code is not ready for this yet, but once
# all the deps of bug 285111 are checked-in and
# tested, this should be uncommented.
#$self->_bz_init_schema_storage();
}
#####################################################################
...
...
@@ -775,17 +764,42 @@ These methods really are private. Do not override them in subclasses.
sub
_bz_init_schema_storage
{
my
(
$self
)
=
@_
;
my
$table_size
=
$self
->
selectrow_array
(
"SELECT COUNT(*) FROM bz_schema"
);
my
$table_size
;
eval
{
$table_size
=
$self
->
selectrow_array
(
"SELECT COUNT(*) FROM bz_schema"
);
};
if
(
!
$table_size
)
{
my
$init_schema
=
$self
->
_bz_get_initial_schema
;
my
$store_me
=
$init_schema
->
serialize_abstract
();
my
$schema_version
=
$init_schema
->
SCHEMA_VERSION
;
# If table_size is not defined, then we hit an error reading the
# bz_schema table, which means it probably doesn't exist yet. So,
# we have to create it. If we failed above for some other reason,
# we'll see the failure here.
# However, we must create the table after we do get_initial_schema,
# because some versions of get_initial_schema read that the table
# exists and then add it to the Schema, where other versions don't.
if
(
!
defined
$table_size
)
{
$self
->
_bz_add_table_raw
(
'bz_schema'
);
}
if
(
$table_size
==
0
)
{
print
"Initializing the new Schema storage...\n"
;
my
$store_me
=
$self
->
_bz_schema
->
serialize_abstract
();
my
$schema_version
=
$self
->
_bz_schema
->
SCHEMA_VERSION
;
my
$sth
=
$self
->
prepare
(
"INSERT INTO bz_schema "
.
" (schema_data, version) VALUES (?,?)"
);
$sth
->
bind_param
(
1
,
$store_me
,
$self
->
BLOB_TYPE
);
$sth
->
bind_param
(
2
,
Bugzilla::DB::Schema::
SCHEMA_VERSION
);
$sth
->
bind_param
(
2
,
$schema_version
);
$sth
->
execute
();
# And now we have to update the on-disk schema to hold the bz_schema
# table, if the bz_schema table didn't exist when we were called.
if
(
!
defined
$table_size
)
{
$self
->
_bz_real_schema
->
add_table
(
'bz_schema'
,
$self
->
_bz_schema
->
get_table_abstract
(
'bz_schema'
));
$self
->
_bz_store_real_schema
;
}
}
# Sanity check
elsif
(
$table_size
>
1
)
{
...
...
Bugzilla/DB/Mysql.pm
View file @
cc8d6d39
...
...
@@ -198,6 +198,12 @@ sub bz_rollback_transaction {
die
(
"Attempt to rollback transaction on DB without transaction support"
);
}
sub
_bz_get_initial_schema
{
my
(
$self
)
=
@_
;
return
$self
->
_bz_build_schema_from_disk
();
}
#####################################################################
# Database Setup
#####################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment