improved trigger/sp updates in database versioning
This commit is contained in:
@@ -47,15 +47,25 @@
|
|||||||
// Now and then a maintain.php update should be inserted, because multiple
|
// 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
|
// mutations may be run in one batch, and future mutations may depend on
|
||||||
// changed triggers, which may not be obvious.
|
// changed triggers, which may not be obvious.
|
||||||
|
//
|
||||||
// Of course, a trigger update mutation can also be inserted directly before a
|
// 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
|
// 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 ...)
|
// not depend on database changes which will be done by that mutation ...)
|
||||||
|
|
||||||
function update_triggers()
|
function update_triggers()
|
||||||
{
|
{
|
||||||
global $opt;
|
global $opt, $db_version;
|
||||||
echo " "; // space for the case of a DB password prompt
|
|
||||||
system('php ' . $opt['rootpath'] . 'doc/sql/stored-proc/maintain.php');
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1550
htdocs/doc/sql/stored-proc/maintain-113.inc.php
Normal file
1550
htdocs/doc/sql/stored-proc/maintain-113.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
1550
htdocs/doc/sql/stored-proc/maintain-current.inc.php
Normal file
1550
htdocs/doc/sql/stored-proc/maintain-current.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,7 @@
|
|||||||
sql_export_recordset($f, $rs) ... export recordset to file
|
sql_export_recordset($f, $rs) ... export recordset to file
|
||||||
sql_export_table($f, $table) ... export table to file
|
sql_export_table($f, $table) ... export table to file
|
||||||
sql_export_table_to_file($filename, $table)
|
sql_export_table_to_file($filename, $table)
|
||||||
|
sql_dropFunction ... drops stored procedure or trigger
|
||||||
|
|
||||||
sql_table_exists ... tests if a table exists
|
sql_table_exists ... tests if a table exists
|
||||||
sql_field_exists ... tests if a table and a field in this table exist
|
sql_field_exists ... tests if a table and a field in this table exist
|
||||||
@@ -1088,6 +1089,22 @@
|
|||||||
fclose($f);
|
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
|
// test if a database table exists
|
||||||
function sql_table_exists($table)
|
function sql_table_exists($table)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user