From c8d8f053c0ac1249f4cff28ca3dd5954e6e95be3 Mon Sep 17 00:00:00 2001 From: chriskl Date: Tue, 12 Aug 2003 08:11:08 +0000 Subject: [PATCH] ability to create unique and partial indexes --- HISTORY | 2 ++ indexes.php | 48 ++++++++++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/HISTORY b/HISTORY index 6ada01c3..0d33c78d 100644 --- a/HISTORY +++ b/HISTORY @@ -25,6 +25,7 @@ Features: * Refresh feature on table browse * Support better formatted view dumps in 7.4 * When browsing data, numeric types are aligned right +* Ability to create unique and partial indexes Bug Fixes: * Lots of NULL value in table dump fixes (XML format changed slightly) @@ -32,6 +33,7 @@ Bug Fixes: * Support zero column tables * Correctly display the contents of bytea fields * Consider information_schema to be a system object +* Remember fields if index creation fails Version 3.0 ----------- diff --git a/indexes.php b/indexes.php index f8907b99..6d81f5ad 100644 --- a/indexes.php +++ b/indexes.php @@ -3,7 +3,7 @@ /** * List indexes on a table * - * $Id: indexes.php,v 1.15 2003/07/31 08:28:03 chriskl Exp $ + * $Id: indexes.php,v 1.16 2003/08/12 08:11:08 chriskl Exp $ */ // Include application functions @@ -21,9 +21,11 @@ global $PHP_SELF, $lang; if (!isset($_POST['formIndexName'])) $_POST['formIndexName'] = ''; + if (!isset($_POST['formIndexType'])) $_POST['formIndexType'] = null; if (!isset($_POST['formCols'])) $_POST['formCols'] = ''; + if (!isset($_POST['formWhere'])) $_POST['formWhere'] = ''; - echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']} : {$lang['strcreateindex']}

\n"; + echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']}: {$lang['strcreateindex']}

\n"; $misc->printMsg($msg); $attrs = &$localData->getTableAttributes($_REQUEST['table']); @@ -49,16 +51,14 @@ $buttonRemove->set_attribute("onclick", "buttonPressed(this);"); $buttonRemove->set_attribute("type", "button"); - $selTypes = new XHTML_select("formIndexType"); - $selTypes->set_data($localData->typIndexes); - echo "
\n"; echo "\n"; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo "\n"; echo "\n"; @@ -69,20 +69,30 @@ echo "
{$lang['strindexname']}
_maxNameLen}\" />
_maxNameLen}\" value=\"", + htmlspecialchars($_POST['formIndexName']), "\" />
{$lang['strtablecolumnlist']} {$lang['strindexcolumnlist']}
" . $selColumns->fetch() . "
\n"; echo ""; echo ""; - echo ""; + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo "
{$lang['strindextype']}" . $selTypes->fetch() . "
{$lang['strunique']}
{$lang['strwhere']}(_maxNameLen}\" value=\"", + htmlspecialchars($_POST['formWhere']), "\" />)
"; - echo "

\n"; echo $misc->form; echo "\n"; echo "\n"; - echo "

\n"; + echo "

\n"; echo "
\n"; - - echo "

href}&table=", urlencode($_REQUEST['table']), - "\">{$lang['strshowallindexes']}

\n"; } /** @@ -95,9 +105,10 @@ // Check that they've given a name and at least one column if ($_POST['formIndexName'] == '') doCreateIndex($lang['strindexneedsname']); - elseif ($_POST['IndexColumnList'] == '') doCreate($lang['strindexneedscols']); + elseif (!isset($_POST['IndexColumnList']) || $_POST['IndexColumnList'] == '') doCreateIndex($lang['strindexneedscols']); else { - $status = $localData->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], $_POST['formIndexType']); + $status = $localData->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], + $_POST['formIndexType'], isset($_POST['formUnique']), $_POST['formWhere']); if ($status == 0) doDefault($lang['strindexcreated']); else @@ -127,8 +138,8 @@ if ($localData->hasDropBehavior()) { echo "

{$lang['strcascade']}

\n"; } - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; } else { @@ -186,13 +197,14 @@ switch ($action) { case 'save_create_index': - doSaveCreateIndex(); + if (isset($_POST['cancel'])) doDefault(); + else doSaveCreateIndex(); break; case 'create_index': doCreateIndex(); break; case 'drop_index': - if (isset($_POST['yes'])) doDropIndex(false); + if (isset($_POST['drop'])) doDropIndex(false); else doDefault(); break; case 'confirm_drop_index': -- 2.39.5