improved trigger/sp updates in database versioning

This commit is contained in:
following
2013-06-24 13:38:19 +02:00
parent b95e9e474e
commit 62b7c973f5
5 changed files with 3154 additions and 1546 deletions

View File

@@ -47,15 +47,25 @@
// Now and then a maintain.php update should be inserted, because multiple
// mutations may be run in one batch, and future mutations may depend on
// changed triggers, which may not be obvious.
//
// Of course, a trigger update mutation can also be inserted directly before a
// mutation which needs it. (But take care that maintain.php at that point does
// not depend on database changes which will be done by that mutation ...)
function update_triggers()
{
global $opt;
echo " "; // space for the case of a DB password prompt
system('php ' . $opt['rootpath'] . 'doc/sql/stored-proc/maintain.php');
global $opt, $db_version;
$syncfile = $opt['rootpath'] . 'cache2/dbsv-running';
file_put_contents($syncfile,'dbsv is running');
system('php ' . $opt['rootpath'] . 'doc/sql/stored-proc/maintain.php --dbsv '.$db_version.' --flush');
if (file_exists($syncfile))
{
die("\nmaintain.php was not properly executed\n");
unlink($syncfile);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,7 @@
sql_export_recordset($f, $rs) ... export recordset to file
sql_export_table($f, $table) ... export table to file
sql_export_table_to_file($filename, $table)
sql_dropFunction ... drops stored procedure or trigger
sql_table_exists ... tests if a table exists
sql_field_exists ... tests if a table and a field in this table exist
@@ -1088,6 +1089,22 @@
fclose($f);
}
function sql_dropFunction($name)
{
global $dbname;
$rs = sql("SHOW FUNCTION STATUS LIKE '&1'", $name);
while ($r = sql_fetch_assoc($rs))
{
if ($r['Db'] == $dbname && $r['Name'] == $name && $r['Type'] == 'FUNCTION')
{
sql('DROP FUNCTION `&1`', $name);
return;
}
}
sql_free_result($rs);
}
// test if a database table exists
function sql_table_exists($table)
{