Commit 69c5eefb authored by Leigh Stoller's avatar Leigh Stoller

Add -i option to exports_tables, which creates a version for

distributions; includes lock/delete statements to clear out existing
tables before filling them again.

Add db-fill-dist target to sql/GNUmakefile to use this new option.

Add target to utah/Makefile to call into the sql makefile and run the
db-fill-dist target. Be careful not to check this version in locally
of course.
parent d32ab09a
......@@ -32,5 +32,11 @@ db-fill:
@/usr/testbed/sbin/wap /usr/testbed/sbin/export_tables \
> database-fill.sql
db-fill-dist:
@/usr/testbed/sbin/wap /usr/testbed/sbin/export_tables -i \
> database-fill.sql
sitevars:
@mysqldump -t tbdb sitevariables > sitevars-create.sql
dist: db-fill-dist
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -13,6 +13,11 @@
use English;
my $dist = 0;
if (@ARGV && $ARGV[0] eq "-i") {
$dist = 1;
}
#
# Configure variables
#
......@@ -45,7 +50,8 @@ while (my ($table_name) = $result->fetchrow()) {
#
# Run mysqldump, and read its stdout
#
open(FH,"$mysqldump -t $DBNAME $table_names |") or
open(FH, "$mysqldump " .
($dist ? "--add-locks" : "") . " -t $DBNAME $table_names |") or
die "Unable to run $mysqldump: $!\n";
#
......@@ -62,4 +68,8 @@ while (<FH>) {
$1 ne '*') { next; }
print;
if ($dist && /LOCK TABLES ([-\w]*) WRITE/i) {
print "DELETE FROM $1;\n";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment