Add check for existence of index prior to DROP INDEX

This commit is contained in:
Miles Lott 2001-09-23 11:58:10 +00:00
parent 379a433cf6
commit 2a738905e4
2 changed files with 27 additions and 1 deletions

View File

@ -508,7 +508,16 @@
if ($DEBUG) { echo '<br>RenameTable(): Altering column default for: ' . $sField; }
$oProc->m_odb->query("ALTER TABLE $sOldTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . "')",__LINE__,__FILE__);
}
$oProc->m_odb->query("DROP INDEX " . $sOldTableName . "_pkey",__LINE__,__FILE__);
$indexnames = $oProc->m_odb->index_names();
while(list($key,$val) = @each($indexnames))
{
$indexes[] = $val['index_name'];
}
if(isinarray($sOldTableName . '_pkey',$indexes)
{
$oProc->m_odb->query("DROP INDEX " . $sOldTableName . "_pkey",__LINE__,__FILE__);
}
return !!($oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME TO $sNewTableName"));
}

View File

@ -193,6 +193,23 @@
return $select;
}
/*!
@function isinarray
@abstract php3/4 compliant in_array()
@param $needle String to search for
@param $haystack Array to search
*/
function isinarray($needle,$haystack='')
{
if($haystack == '')
{
settype($haystack,'array');
$haystack = Array();
}
for($i=0;$i<count($haystack) && $haystack[$i] !=$needle;$i++);
return ($i!=count($haystack));
}
/* Include to check user authorization against the
password in ../header.inc.php to protect all of the setup
pages from unauthorized use.