Files
archived-web-pecl/sql/create2drop
2019-01-25 00:22:14 +01:00

39 lines
1.6 KiB
Perl
Executable File

#!/usr/bin/perl -s
# +----------------------------------------------------------------------+
# | The PECL website |
# +----------------------------------------------------------------------+
# | Copyright (c) 1999-2019 The PHP Group |
# +----------------------------------------------------------------------+
# | This source file is subject to version 3.01 of the PHP license, |
# | that is bundled with this package in the file LICENSE, and is |
# | available through the world-wide-web at the following url: |
# | https://php.net/license/3_01.txt |
# | If you did not receive a copy of the PHP license and are unable to |
# | obtain it through the world-wide-web, please send a note to |
# | license@php.net so we can mail you a copy immediately. |
# +----------------------------------------------------------------------+
# | Authors: |
# +----------------------------------------------------------------------+
if ($mysql) {
$dbtype = "mysql";
$transactions = 0;
} elsif ($solid) {
$dbtype = "solid";
$transactions = 1;
} else {
die "unknown db type";
}
while (<>) {
if (/^\"?CREATE\s+(TABLE|SEQUENCE|INDEX|UNIQUE\s+INDEX|PROCEDURE|VIEW|EVENT|ROLE|USER)\s+([a-z0-9_]+)/i) {
($type, $name) = ($1, $2);
$type =~ s/UNIQUE\s+//;
print "DROP $type $name;\n";
if ($transactions) {
print "COMMIT WORK;\n";
}
}
}