Add sql from phppgadmin for finding indexes on pg < 7.3

This commit is contained in:
Miles Lott 2004-03-05 13:32:00 +00:00
parent 04f3331e7d
commit 05fb371651

View File

@ -369,11 +369,21 @@
$oProc->Halt_On_Error = 'no';
$aIx = array();
/* This select excludes any indexes that are just base indexes for constraints. */
$sql = "SELECT pg_catalog.pg_get_indexdef(i.indexrelid) as pg_get_indexdef FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c.relname = '$sTableName' AND pg_catalog.pg_table_is_visible(c.oid) AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT EXISTS ( SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) WHERE d.classid = c2.tableoid AND d.objid = c2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') ) ORDER BY c2.relname";
if(@$oProc->m_odb->db_version >= 7.3)
{
$sql = "SELECT pg_catalog.pg_get_indexdef(i.indexrelid) as pg_get_indexdef FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c.relname = '$sTableName' AND pg_catalog.pg_table_is_visible(c.oid) AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT EXISTS ( SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) WHERE d.classid = c2.tableoid AND d.objid = c2.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p') ) ORDER BY c2.relname";
$num = 0;
}
else
{
$sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_get_indexdef(i.indexrelid) FROM pg_class c, pg_class c2, pg_index i WHERE c.relname = '$sTableName' AND c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT i.indisprimary AND NOT i.indisunique ORDER BY c2.relname";
$num = 3;
}
@$oProc->m_odb->query($sql);
$oProc->m_odb->next_record();
$indexfields = ereg_replace("^CREATE.+\(",'',$oProc->m_odb->f(0));
$indexfields = ereg_replace("^CREATE.+\(",'',$oProc->m_odb->f($num));
$indexfields = ereg_replace("\)$",'',$indexfields);
$aIx = explode(',',$indexfields);
$i = 0;
@ -384,7 +394,7 @@
}
/* Restore original value */
$oProc->Halt_On_Error = $tmp;
//echo "Indices from $sTableName<pre>pk=".print_r($aPk,True)."\nix=".print_r($aIx,True)."\nuc=".print_r($aUc,True)."</pre>\n";
echo "Indices from $sTableName<pre>pk=".print_r($aPk,True)."\nix=".print_r($aIx,True)."\nuc=".print_r($aUc,True)."</pre>\n";
}
function _CopyAlteredTable($oProc, &$aTables, $sSource, $sDest)