forked from extern/egroupware
fixed rename_table() in schema_proc_pgsql, wich was relying on index_names() and therefore was broken with ADODB.
This commit is contained in:
parent
52fb31997e
commit
20ee4f1d27
@ -793,6 +793,26 @@ if (is_array($str)) $this->halt('db::db_addslashes('.print_r($str,True).",'$type
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing column names that are the primary keys of $tablename.
|
||||
*
|
||||
* @return array of columns
|
||||
*/
|
||||
function pkey_columns($tablename)
|
||||
{
|
||||
if (!$this->Link_ID && !$this->connect())
|
||||
{
|
||||
return False;
|
||||
}
|
||||
// REMOVE-IF-ONLY-ADODB
|
||||
if (isset($GLOBALS['phpgw_info']['server']['use_adodb']) &&
|
||||
!@$GLOBALS['phpgw_info']['server']['use_adodb'])
|
||||
{
|
||||
return array();
|
||||
}
|
||||
return $this->Link_ID->MetaPrimaryKeys($tablename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database
|
||||
*
|
||||
|
@ -602,14 +602,16 @@
|
||||
$oProc->m_odb->query("ALTER TABLE $sOldTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . "')",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
$indexes = array();
|
||||
$indexnames = $oProc->m_odb->index_names();
|
||||
while(list($key,$val) = @each($indexnames))
|
||||
{
|
||||
$indexes[] = $val['index_name'];
|
||||
}
|
||||
if(!in_array($sOldTableName . '_pkey',$indexes)) // no idea how this can happen
|
||||
$pkeys = $oProc->m_odb->pkey_columns($sOldTableName);
|
||||
if(!in_array($sOldTableName . '_pkey',$indexes) && !isset($pkeys[0])) // no idea how this can happen
|
||||
{
|
||||
$oProc->m_odb->query("DROP INDEX " . $sOldTableName . "_pkey",__LINE__,__FILE__);
|
||||
$oProc->m_odb->query("ALTER TABLE " . $sOldTableName . " DROP CONSTRAINT " . $sOldTableName . "_pkey",__LINE__,__FILE__);
|
||||
}
|
||||
else // rename the index
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user