forked from extern/egroupware
Add check for existence of index prior to DROP INDEX
This commit is contained in:
parent
379a433cf6
commit
2a738905e4
@ -508,7 +508,16 @@
|
|||||||
if ($DEBUG) { echo '<br>RenameTable(): Altering column default for: ' . $sField; }
|
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("ALTER TABLE $sOldTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . "')",__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__);
|
$oProc->m_odb->query("DROP INDEX " . $sOldTableName . "_pkey",__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
return !!($oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME TO $sNewTableName"));
|
return !!($oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME TO $sNewTableName"));
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,23 @@
|
|||||||
return $select;
|
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
|
/* Include to check user authorization against the
|
||||||
password in ../header.inc.php to protect all of the setup
|
password in ../header.inc.php to protect all of the setup
|
||||||
pages from unauthorized use.
|
pages from unauthorized use.
|
||||||
|
Loading…
Reference in New Issue
Block a user