diff --git a/setup/inc/class.schema_proc_pgsql.inc.php b/setup/inc/class.schema_proc_pgsql.inc.php index fb69729ff4..2d45f7a0d4 100644 --- a/setup/inc/class.schema_proc_pgsql.inc.php +++ b/setup/inc/class.schema_proc_pgsql.inc.php @@ -508,7 +508,16 @@ if ($DEBUG) { echo '
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")); } diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php index a09f2b9683..c94df06137 100644 --- a/setup/inc/functions.inc.php +++ b/setup/inc/functions.inc.php @@ -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