Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
4d382798
Commit
4d382798
authored
23 years ago
by
Philip Lijnzaad
Browse files
Options
Downloads
Patches
Plain Diff
separated tmp_db creation from the table(s) it creates. Untested.
parent
f889e43f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/dump_by_chr.pl
+78
-27
78 additions, 27 deletions
scripts/dump_by_chr.pl
with
78 additions
and
27 deletions
scripts/dump_by_chr.pl
+
78
−
27
View file @
4d382798
...
...
@@ -112,8 +112,11 @@ my $embldb;
my
$estdb
;
my
$mousedb
;
# this one is not settable (used during embl dump)
my
$tmpdb
=
"
__embl_dump_tmpdb_$$
";
# this one is not settable (used during embl dump and may elsewhere).
# There is at most one $tmpdb.
my
$tmpdb
=
undef
;
# (yes, global, naughtynaughty ...)
# sorry, but this has to be on the production server, otherwise I can't do
# the joins ...
...
...
@@ -423,7 +426,9 @@ SELECT trlsi.*
";
dump_data
(
$sql
,
$satdb
,
'
translation_stable_id
');
### bug here: joining int(10) to varchar(40), works bht looses index : slow
### bug here: joining int(10) to varchar(40), works but looses index : slow
### therefore, create a tmp table containing the mapping and indexes.
$sql
=
"
SELECT distinct pf.*
FROM
$litedb
.gene lg,
...
...
@@ -858,7 +863,7 @@ SELECT distinct ctg.internal_id as internal_id, ctg.clone as clone, dna as dna
ALTER TABLE tmp_contig ADD KEY(internal_id);
ALTER TABLE tmp_contig ADD KEY(clone);
";
create_tmp_
db
(
$tmpdb
,
$sql
,
'
tmp_contig
');
create_tmp_
table
(
$sql
,
'
tmp_contig
');
## die "DEBUG: I only wanted this tmptable ...";
# now for the real tables:
...
...
@@ -1051,7 +1056,7 @@ WHERE ctg.internal_id = e.contig_id
";
dump_data
(
$sql
,
$satdb
,
'
Xref
');
drop_tmp_db
(
$tmpdb
);
&
drop_tmp_db
();
return
;
}
# dump_embl
...
...
@@ -1138,52 +1143,98 @@ sub dump_schema {
}
}
# dump_schema
sub
make_tmp_name
{
return
"
__embl_dump_tmpdb_$$
";
}
sub
create_tmp_db
{
# create a (temporay) database
my
(
$db
,
$sql
,
$table
)
=
@_
;
warn
"
Creating
$db
with table
$table
\n
";
# create a (temporary) database
if
(
defined
$tmpdb
)
{
return
;
}
$tmpdb
=
make_tmp_name
;
warn
"
Creating temporary database '
$tmpdb
'
\n
";
my
(
$cmd
)
=
"
$mysqladmin
-u
$user
-h
$host
$pass_arg
create
$db
";
my
(
$cmd
)
=
"
$mysqladmin
-u
$user
-h
$host
$pass_arg
create
$
tmp
db
";
my
(
$out
)
=
`
$cmd
2>&1
`;
if
(
$?
||
$out
)
{
drop_tmp_db
(
$db
);
# just in case
&
drop_tmp_db
;
# in case it was created
die
"
``
$cmd
'' exited with exit status $? and stdout/err:
$out
";
}
return
;
}
sub
drop_tmp_db
{
if
(
!
defined
$tmpdb
)
{
warn
"
Can't drop temporary db, it's not defined
"
.
"
(although it might exist and would be called
"
.
&make_tmp_name
.
"
)
";
return
;
}
# warn "DEBUG: NOT Dropping $db\n";
# return;
warn
"
Dropping
$tmpdb
\n
";
my
(
$cmd
)
=
"
$mysqladmin
--force -u
$user
-h
$host
$pass_arg
drop
$tmpdb
";
my
(
$out
)
=
`
$cmd
2>&1
`;
if
(
$?
||
$out
ne
"
Database
\"
$tmpdb
\"
dropped
\n
"
)
{
warn
"
``
$cmd
'' exited with exit status $? and unexpected stdout/err:
$out
";
}
$tmpdb
=
undef
;
return
;
}
# drop_tmp_db
sub
create_tmp_table
{
my
(
$sql
,
$table
)
=
@_
;
if
(
!
defined
(
$tmpdb
)
)
{
&create_tmp_db
();
}
if
(
$sql
!~
/$table/i
)
{
confess
"
table name '
$table
' not found in SQL statement:
$sql
";
}
if
(
$check_sql
)
{
## NOTE: this is very hackish, I expect an SQL string that looks like
## "create ... select ; alter ...", containing stuff for a single table.
$sql
=~
s/distinct//gi
;
$sql
=~
s/;/ limit 1;/
;
# just so we have *something*
## To speed it up, get rid of any DISTINCTs and add LIMIT 1
$sql
=~
s/distinct//gi
;
# makes it slow, so get rid of it
$sql
=~
s/;/ limit 1;/
;
# just get the first line
# warn "SQL\n\n$sql\n\n";
}
# now create
and
populate the table
$cmd
=
"
echo
\"
$sql
\"
|
$mysql
-N -q --batch -h
$host
-u
$user
$pass_arg
$tmpdb
";
# now create
/
populate the table
my
$cmd
=
"
echo
\"
$sql
\"
|
$mysql
-N -q --batch -h
$host
-u
$user
$pass_arg
$tmpdb
";
$out
=
`
$cmd
2>&1
`;
my
$out
=
`
$cmd
2>&1
`;
if
(
$?
||
$out
)
{
#
drop_tmp_
db($db); ? prolly too harsh
warn
"
``
$cmd
'' exited with exit status $?
and
stdout/err:
$out
";
drop_tmp_
table
(
$table
);
# that's why we needed the $table arg.
warn
"
``
$cmd
'' exited with exit status $?
or (unexpected)
stdout/err:
$out
";
}
return
;
}
# create_tmp_db
sub
drop_tmp_
db
{
my
(
$
db
)
=
@_
;
sub
drop_tmp_
table
{
my
(
$
table
)
=
@_
;
# warn "DEBUG: NOT Dropping $db\n";
# return;
warn
"
Dropping
$db
\n
";
if
(
!
defined
(
$tmpdb
)
)
{
confess
"
Can't drop table
$table
: tmpdb not defined
"
.
"
(although if it exists, it would be called
"
.
&make_tmp_name
.
"
)
";
}
my
(
$cmd
)
=
"
$mysqladmin
--force -u
$user
-h
$host
$pass_arg
drop
$db
";
warn
"
Dropping
$table
from
$tmpdb
\n
";
my
(
$cmd
)
=
"
echo 'DROP TABLE
$table
' |
$mysql
-u
$user
-h
$host
$pass_arg
$tmpdb
";
my
(
$out
)
=
`
$cmd
2>&1
`;
if
(
$?
||
$out
ne
"
Database
\"
$tmpdb
\"
dropped
\n
"
)
{
warn
"
``
$cmd
'' exited with exit status $?
and
unexpected stdout/err:
$out
";
if
(
$?
||
$out
ne
""
)
{
confess
"
``
$cmd
'' exited with exit status $?
or (
unexpected
)
stdout/err:
$out
";
}
return
;
}
# drop_tmp_
db
}
# drop_tmp_
table
sub
dump_data
{
my
(
$sql
,
$satdb
,
$tablename
)
=
@_
;
...
...
@@ -1212,7 +1263,7 @@ sub dump_data {
warn
"
dumping
$tablename
...
\n
";
if
(
system
(
$cmd
)
)
{
drop_tmp_db
(
$tmpdb
);
# might be needed
&
drop_tmp_db
(
$tmpdb
);
# might be needed
die
"
``
$cmd
'' exited with exit-status $?
";
}
}
# dump_data
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment