fix rememberign search_path in sql window. add object type filter to find feature...
authorchriskl <chriskl>
Mon, 12 Jul 2004 07:13:32 +0000 (07:13 +0000)
committerchriskl <chriskl>
Mon, 12 Jul 2004 07:13:32 +0000 (07:13 +0000)
HISTORY
classes/database/Postgres.php
classes/database/Postgres73.php
database.php
sequences.php
sqledit.php

diff --git a/HISTORY b/HISTORY
index d977c0ee345d929c91263cc03da1b8e7bd49dcda..4011a23a3a1f1abbc0f5828fa430e712526babd1 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -10,6 +10,9 @@ Features
 * Tablespace support for 7.5
 * Support cancelling and killing backend processes in 7.5
 * Allow setting privileges on databases
+* Allow setting schema search path in SQL window
+* Allow filtering find results by object type
+* Show function arguments in find results
 
 Translations
 * Arabic from Zaki
index 9d5b65c1505267db0384f23588fefc510d5ba11f..d46b680d686cd29492dc2b8f74a54c29a2c82075 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.232 2004/07/10 09:23:24 chriskl Exp $
+ * $Id: Postgres.php,v 1.233 2004/07/12 07:13:32 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1629,11 +1629,10 @@ class Postgres extends BaseDB {
         * @param $startvalue The starting value
         * @param $cachevalue The cache value
         * @param $cycledvalue True if cycled, false otherwise
-        * @param $tablespace The tablespace ('' means none/default)
         * @return 0 success
         */
        function createSequence($sequence, $increment, $minvalue, $maxvalue, 
-                                                               $startvalue, $cachevalue, $cycledvalue, $tablespace) {
+                                                               $startvalue, $cachevalue, $cycledvalue) {
                $this->fieldClean($sequence);
                $this->clean($increment);
                $this->clean($minvalue);
@@ -1649,12 +1648,6 @@ class Postgres extends BaseDB {
                if ($cachevalue != '') $sql .= " CACHE {$cachevalue}";
                if ($cycledvalue) $sql .= " CYCLE";
                
-               // Tablespace
-               if ($this->hasTablespaces() && $tablespace != '') {
-                       $this->fieldClean($tablespace);
-                       $sql .= " TABLESPACE \"{$tablespace}\"";
-               }
-
                return $this->execute($sql);
        }
 
@@ -2362,9 +2355,10 @@ class Postgres extends BaseDB {
        /**
         * Searches all system catalogs to find objects that match a certain name.
         * @param $term The search term
+        * @param $filter The object type to restrict to ('' means no restriction)
         * @return A recordset
         */
-       function findObject($term) {
+       function findObject($term, $filter) {
                global $conf;
 
                // Escape search term for ~* match
@@ -2373,14 +2367,18 @@ class Postgres extends BaseDB {
                        $term = str_replace($v, "\\{$v}", $term);
                }
                $this->clean($term);
+               $this->clean($filter);
 
                // Build SQL, excluding system relations as necessary
                // Relations
+               $case_clause = "CASE WHEN relkind='r' THEN (CASE WHEN EXISTS (SELECT 1 FROM pg_rewrite r WHERE r.ev_class = pc.oid AND r.ev_type = '1') THEN 'VIEW'::VARCHAR ELSE 'TABLE'::VARCHAR END) WHEN relkind='v' THEN 'VIEW'::VARCHAR WHEN relkind='S' THEN 'SEQUENCE'::VARCHAR END";
                $sql = "
-                       SELECT CASE WHEN relkind='r' THEN (CASE WHEN EXISTS (SELECT 1 FROM pg_rewrite r WHERE r.ev_class = pc.oid AND r.ev_type = '1') THEN 'VIEW'::VARCHAR ELSE 'TABLE'::VARCHAR END) WHEN relkind='v' THEN 'VIEW'::VARCHAR WHEN relkind='S' THEN 'SEQUENCE'::VARCHAR END AS type, 
+                       SELECT {$case_clause} AS type, 
                                pc.oid, NULL::VARCHAR AS schemaname, NULL::VARCHAR AS relname, pc.relname AS name FROM pg_class pc
                                WHERE relkind IN ('r', 'v', 'S') AND relname ~* '.*{$term}.*'";
-               if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";                               
+               if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";                       
+               if ($filter == 'TABLE' || $filter == 'VIEW' || $filter == 'SEQUENCE') $sql .= " AND {$case_clause} = '{$filter}'";
+               elseif ($filter != '') $sql .= " AND FALSE";
 
                // Columns
                $sql .= "                               
@@ -2389,14 +2387,16 @@ class Postgres extends BaseDB {
                                NULL, NULL, pc.relname, pa.attname FROM pg_class pc,
                                pg_attribute pa WHERE pc.oid=pa.attrelid 
                                AND pa.attname ~* '.*{$term}.*' AND pa.attnum > 0 AND pc.relkind IN ('r', 'v')";
-               if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";                               
+               if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";
+               if ($filter != '' && $filter != 'COLUMNTABLE' || $filter != 'COLUMNVIEW') $sql .= " AND FALSE";
 
                // Functions
                $sql .= "
                        UNION ALL
-                       SELECT 'FUNCTION', pp.oid, NULL, NULL, pp.proname FROM pg_proc pp
+                       SELECT 'FUNCTION', pp.oid, NULL, NULL, pp.proname || '(' || oidvectortypes(pp.proargtypes) || ')' FROM pg_proc pp
                                WHERE proname ~* '.*{$term}.*'";
                if (!$conf['show_system']) $sql .= " AND pp.oid > '{$this->_lastSystemOID}'::oid";
+               if ($filter != '' && $filter != 'FUNCTION') $sql .= " AND FALSE";
                        
                // Indexes
                $sql .= "
@@ -2405,7 +2405,8 @@ class Postgres extends BaseDB {
                                pg_index pi, pg_class pc2 WHERE pc.oid=pi.indrelid 
                                AND pi.indexrelid=pc2.oid
                                AND pc2.relname ~* '.*{$term}.*' AND NOT pi.indisprimary AND NOT pi.indisunique";
-               if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";                              
+               if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";
+               if ($filter != '' && $filter != 'INDEX') $sql .= " AND FALSE";
 
                // Check Constraints
                $sql .= "
@@ -2414,6 +2415,8 @@ class Postgres extends BaseDB {
                                pg_relcheck pr WHERE pc.oid=pr.rcrelid
                                AND pr.rcname ~* '.*{$term}.*'";
                if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";                               
+               if ($filter != '' && $filter != 'CONSTRAINT') $sql .= " AND FALSE";
+               
                // Unique and Primary Key Constraints
                $sql .= "
                        UNION ALL
@@ -2421,7 +2424,8 @@ class Postgres extends BaseDB {
                                pg_index pi, pg_class pc2 WHERE pc.oid=pi.indrelid 
                                AND pi.indexrelid=pc2.oid
                                AND pc2.relname ~* '.*{$term}.*' AND (pi.indisprimary OR pi.indisunique)";
-               if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";                              
+               if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";      
+               if ($filter != '' && $filter != 'CONSTRAINT') $sql .= " AND FALSE";                     
 
                // Triggers
                $sql .= "
@@ -2430,6 +2434,7 @@ class Postgres extends BaseDB {
                                pg_trigger pt WHERE pc.oid=pt.tgrelid
                                AND pt.tgname ~* '.*{$term}.*'";
                if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";                               
+               if ($filter != '' && $filter != 'TRIGGER') $sql .= " AND FALSE";
 
                // Table Rules
                $sql .= "
@@ -2439,6 +2444,7 @@ class Postgres extends BaseDB {
                                WHERE c.relkind='r' AND NOT EXISTS (SELECT 1 FROM pg_rewrite r WHERE r.ev_class = c.oid AND r.ev_type = '1') 
                                AND r.rulename !~ '^_RET' AND c.oid = r.ev_class AND r.rulename ~* '.*{$term}.*'";
                if (!$conf['show_system']) $sql .= " AND c.relname NOT LIKE 'pg\\\\_%'";                                
+               if ($filter != '' && $filter != 'RULE') $sql .= " AND FALSE";
 
                // View Rules
                $sql .= "
@@ -2448,6 +2454,7 @@ class Postgres extends BaseDB {
                                WHERE c.relkind='r' AND EXISTS (SELECT 1 FROM pg_rewrite r WHERE r.ev_class = c.oid AND r.ev_type = '1')
                                AND r.rulename !~ '^_RET' AND c.oid = r.ev_class AND r.rulename ~* '.*{$term}.*'";
                if (!$conf['show_system']) $sql .= " AND c.relname NOT LIKE 'pg\\\\_%'";                                
+               if ($filter != '' && $filter != 'RULE') $sql .= " AND FALSE";
 
                // Advanced Objects
                if ($conf['show_advanced']) {
@@ -2457,6 +2464,7 @@ class Postgres extends BaseDB {
                                SELECT 'TYPE', pt.oid, NULL, NULL, pt.typname FROM pg_type pt
                                        WHERE typname ~* '.*{$term}.*' AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_class c WHERE c.oid = pt.typrelid))";
                        if (!$conf['show_system']) $sql .= " AND pt.oid > '{$this->_lastSystemOID}'::oid";
+                       if ($filter != '' && $filter != 'TYPE') $sql .= " AND FALSE";
 
                        // Operators
                        $sql .= "                               
@@ -2464,6 +2472,7 @@ class Postgres extends BaseDB {
                                SELECT 'OPERATOR', po.oid, NULL, NULL, po.oprname FROM pg_operator po
                                        WHERE oprname ~* '.*{$term}.*'";
                        if (!$conf['show_system']) $sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
+                       if ($filter != '' && $filter != 'OPERATOR') $sql .= " AND FALSE";
 
                        // Languages
                        $sql .= "                               
@@ -2471,6 +2480,7 @@ class Postgres extends BaseDB {
                                SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_language pl
                                        WHERE lanname ~* '.*{$term}.*'";
                        if (!$conf['show_system']) $sql .= " AND pl.lanispl";
+                       if ($filter != '' && $filter != 'LANGUAGE') $sql .= " AND FALSE";
 
                        // Aggregates
                        $sql .= "                               
@@ -2478,6 +2488,7 @@ class Postgres extends BaseDB {
                                SELECT DISTINCT ON (a.aggname) 'AGGREGATE', a.oid, NULL, NULL, a.aggname FROM pg_aggregate a 
                                        WHERE aggname ~* '.*{$term}.*'";
                        if (!$conf['show_system']) $sql .= " AND a.oid > '{$this->_lastSystemOID}'::oid";
+                       if ($filter != '' && $filter != 'AGGREGATE') $sql .= " AND FALSE";
 
                        // Op Classes
                        $sql .= "                               
@@ -2485,6 +2496,7 @@ class Postgres extends BaseDB {
                                SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, NULL, NULL, po.opcname FROM pg_opclass po
                                        WHERE po.opcname ~* '.*{$term}.*'";
                        if (!$conf['show_system']) $sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
+                       if ($filter != '' && $filter != 'OPCLASS') $sql .= " AND FALSE";
                }
                                
                $sql .= " ORDER BY type, schemaname, relname, name";
index e64a4f4b36a5d1d96916b1cd50cf166068169185..f48317423bb481398eb7a0a80bd35ece684edb34 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.125 2004/07/10 08:51:01 chriskl Exp $
+ * $Id: Postgres73.php,v 1.126 2004/07/12 07:13:33 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -730,14 +730,14 @@ class Postgres73 extends Postgres72 {
                                        pc.oid AS prooid,
                                        proname,
                                        lanname as prolanguage,
-                                       format_type(prorettype, NULL) as proresult,
+                                       pg_catalog.format_type(prorettype, NULL) as proresult,
                                        prosrc,
                                        probin,
                                        proretset,
                                        proisstrict,
                                        provolatile,
                                        prosecdef,
-                                       oidvectortypes(pc.proargtypes) AS proarguments,
+                                       pg_catalog.oidvectortypes(pc.proargtypes) AS proarguments,
                                        pg_catalog.obj_description(pc.oid, 'pg_proc') AS procomment
                                FROM
                                        pg_catalog.pg_proc pc, pg_catalog.pg_language pl
@@ -1308,15 +1308,17 @@ class Postgres73 extends Postgres72 {
        /**
         * Searches all system catalogs to find objects that match a certain name.
         * @param $term The search term
+        * @param $filter The object type to restrict to ('' means no restriction)
         * @return A recordset
         */
-       function findObject($term) {
+       function findObject($term, $filter) {
                global $conf;
 
                // Escape search term for ILIKE match
                $term = str_replace('_', '\\_', $term);
                $term = str_replace('%', '\\%', $term);
                $this->clean($term);
+               $this->clean($filter);
 
                // Exclude system relations if necessary
                if (!$conf['show_system']) {
@@ -1330,7 +1332,13 @@ class Postgres73 extends Postgres72 {
                        $lan_where = '';
                }
                
-               $sql = "
+               // Apply outer filter
+               $sql = '';
+               if ($filter != '') {
+                       $sql = "SELECT * FROM (";
+               }
+               
+               $sql .= "
                        SELECT 'SCHEMA' AS type, oid, NULL AS schemaname, NULL AS relname, nspname AS name 
                                FROM pg_catalog.pg_namespace pn WHERE nspname ILIKE '%{$term}%' {$where}
                        UNION ALL
@@ -1342,7 +1350,7 @@ class Postgres73 extends Postgres72 {
                                pg_catalog.pg_attribute pa WHERE pc.relnamespace=pn.oid AND pc.oid=pa.attrelid 
                                AND pa.attname ILIKE '%{$term}%' AND pa.attnum > 0 AND NOT pa.attisdropped AND pc.relkind IN ('r', 'v') {$where}
                        UNION ALL
-                       SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn 
+                       SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname || '(' || pg_catalog.oidvectortypes(pp.proargtypes) || ')' FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn 
                                WHERE pp.pronamespace=pn.oid AND NOT pp.proisagg AND pp.proname ILIKE '%{$term}%' {$where}
                        UNION ALL
                        SELECT 'INDEX', NULL, pn.nspname, pc.relname, pc2.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn,
@@ -1427,8 +1435,13 @@ class Postgres73 extends Postgres72 {
                        ";
                }
 
+               if ($filter != '') {
+                       // We use like to make RULE, CONSTRAINT and COLUMN searches work
+                       $sql .= ") AS sub WHERE type LIKE '{$filter}%' ";
+               }
+
                $sql .= "ORDER BY type, schemaname, relname, name";
-                       
+
                return $this->selectSet($sql);
        }       
 
index a3a08c5aaaff46b0b4e32347029e846f6a01df58..3a0f6d9ee73459d8ecff3177313c1b7cfd8665e8 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.52 2004/07/09 01:50:43 chriskl Exp $
+        * $Id: database.php,v 1.53 2004/07/12 07:13:32 chriskl Exp $
         */
 
        // Include application functions
         */
        function doFind($confirm = true, $msg = '') {
                global $PHP_SELF, $data, $data, $misc;
-               global $lang;
+               global $lang, $conf;
 
                if (!isset($_GET['term'])) $_GET['term'] = '';
+               if (!isset($_GET['filter'])) $_GET['filter'] = '';
 
                $misc->printDatabaseNav();
                $misc->printTitle(array($misc->printVal($_REQUEST['database']),$lang['strfind']));
                echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
                echo "<p><input name=\"term\" value=\"", htmlspecialchars($_GET['term']), 
                        "\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
+               // Output list of filters.  This is complex due to all the 'has' and 'conf' feature possibilities
+               echo "<select name=\"filter\">\n";
+               echo "\t<option value=\"\"", ($_GET['filter'] == '') ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n";
+               if ($data->hasSchemas())
+                       echo "\t<option value=\"SCHEMA\"", ($_GET['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
+               if ($data->hasTables())
+                       echo "\t<option value=\"TABLE\"", ($_GET['filter'] == 'TABLE') ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n";
+               if ($data->hasViews())
+                       echo "\t<option value=\"VIEW\"", ($_GET['filter'] == 'VIEW') ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n";
+               if ($data->hasSequences())
+                       echo "\t<option value=\"SEQUENCE\"", ($_GET['filter'] == 'SEQUENCE') ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n";
+               if ($data->hasTables() || $data->hasViews()) {
+                       echo "\t<option value=\"COLUMN\"", ($_GET['filter'] == 'COLUMN') ? ' selected="selected"' : '', ">{$lang['strcolumns']}</option>\n";
+                       echo "\t<option value=\"RULE\"", ($_GET['filter'] == 'RULE') ? ' selected="selected"' : '', ">{$lang['strrules']}</option>\n";
+               }
+               if ($data->hasTables()) {
+                       echo "\t<option value=\"INDEX\"", ($_GET['filter'] == 'INDEX') ? ' selected="selected"' : '', ">{$lang['strindexes']}</option>\n";
+                       echo "\t<option value=\"TRIGGER\"", ($_GET['filter'] == 'TRIGGER') ? ' selected="selected"' : '', ">{$lang['strtriggers']}</option>\n";
+               }
+               if ($data->hasTables() || $data->hasDomainConstraints())
+                       echo "\t<option value=\"CONSTRAINT\"", ($_GET['filter'] == 'CONSTRAINT') ? ' selected="selected"' : '', ">{$lang['strconstraints']}</option>\n";
+               if ($data->hasFunctions())
+                       echo "\t<option value=\"FUNCTION\"", ($_GET['filter'] == 'FUNCTION') ? ' selected="selected"' : '', ">{$lang['strfunctions']}</option>\n";
+               if ($data->hasTypes() && $conf['show_advanced'])
+                       echo "\t<option value=\"TYPE\"", ($_GET['filter'] == 'TYPE') ? ' selected="selected"' : '', ">{$lang['strtypes']}</option>\n";
+               if ($data->hasDomains())
+                       echo "\t<option value=\"DOMAIN\"", ($_GET['filter'] == 'DOMAIN') ? ' selected="selected"' : '', ">{$lang['strdomains']}</option>\n";
+               if ($data->hasOperators() && $conf['show_advanced'])
+                       echo "\t<option value=\"OPERATOR\"", ($_GET['filter'] == 'OPERATOR') ? ' selected="selected"' : '', ">{$lang['stroperators']}</option>\n";
+               if ($data->hasConversions() && $conf['show_advanced'])
+                       echo "\t<option value=\"CONVERSION\"", ($_GET['filter'] == 'CONVERSION') ? ' selected="selected"' : '', ">{$lang['strconversions']}</option>\n";
+               if ($data->hasLanguages() && $conf['show_advanced'])
+                       echo "\t<option value=\"LANGUAGE\"", ($_GET['filter'] == 'LANGUAGE') ? ' selected="selected"' : '', ">{$lang['strlanguages']}</option>\n";
+               if ($data->hasAggregates() && $conf['show_advanced'])
+                       echo "\t<option value=\"AGGREGATE\"", ($_GET['filter'] == 'AGGREGATE') ? ' selected="selected"' : '', ">{$lang['straggregates']}</option>\n";
+               if ($data->hasOpClasses() && $conf['show_advanced'])
+                       echo "\t<option value=\"OPCLASS\"", ($_GET['filter'] == 'OPCLASS') ? ' selected="selected"' : '', ">{$lang['stropclasses']}</option>\n";
+               echo "</select>\n";
                echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n";
                echo $misc->form;
                echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
@@ -57,7 +96,7 @@
                // If a search term has been specified, then perform the search
                // and display the results, grouped by object type
                if ($_GET['term'] != '') {
-                       $rs = &$data->findObject($_GET['term']);
+                       $rs = &$data->findObject($_GET['term'], $_GET['filter']);
                        if ($rs->recordCount() > 0) {
                                $curr = '';
                                while (!$rs->EOF) {
index ace87257bf69dcf2a1d9d84f033cc0bd23e99046..771608baf7025e2e60a3b5588fcc7c6772ed4815 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage sequences in a database
         *
-        * $Id: sequences.php,v 1.22 2004/07/10 09:23:24 chriskl Exp $
+        * $Id: sequences.php,v 1.23 2004/07/12 07:13:32 chriskl Exp $
         */
        
        // Include application functions
                                'title' => $lang['strowner'],
                                'field' => 'seqowner',
                        ),
-                       'tablespace' => array(
-                               'title' => $lang['strtablespace'],
-                               'field' => 'tablespace'
-                       ),
                        'actions' => array(
                                'title' => $lang['stractions'],
                        ),
@@ -66,8 +62,6 @@
                        ),
                );
                
-               if (!$data->hasTablespaces()) unset($columns['tablespace']);
-               
                $misc->printTable($sequences, $columns, $actions, $lang['strnosequences']);
                
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create&amp;{$misc->href}\">{$lang['strcreatesequence']}</a></p>\n";
                if (!isset($_POST['formMaxValue'])) $_POST['formMaxValue'] = '';
                if (!isset($_POST['formStartValue'])) $_POST['formStartValue'] = '';
                if (!isset($_POST['formCacheValue'])) $_POST['formCacheValue'] = '';
-               if (!isset($_POST['formSpc'])) $_POST['formSpc'] = '';
-               
-               // Fetch all tablespaces from the database
-               if ($data->hasTablespaces()) $tablespaces = &$data->getTablespaces();
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strsequences']} : {$lang['strcreatesequence']} </h2>\n";
                $misc->printMsg($msg);
                echo "<td class=\"data1\"><input type=\"checkbox\" name=\"formCycledValue\" value=\"",
                        (isset($_POST['formCycledValue']) ? ' checked="checked"' : ''), "\" /></td></tr>\n";
 
-               // Tablespace (if there are any)
-               if ($data->hasTablespaces() && $tablespaces->recordCount() > 0) {
-                       echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strtablespace']}</th>\n";
-                       echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formSpc\">\n";
-                       // Always offer the default (empty) option
-                       echo "\t\t\t\t<option value=\"\"",
-                               ($_POST['formSpc'] == '') ? ' selected="selected"' : '', "></option>\n";
-                       // Display all other tablespaces
-                       while (!$tablespaces->EOF) {
-                               $spcname = htmlspecialchars($tablespaces->f['spcname']);
-                               echo "\t\t\t\t<option value=\"{$spcname}\"",
-                                       ($spcname == $_POST['formSpc']) ? ' selected="selected"' : '', ">{$spcname}</option>\n";
-                               $tablespaces->moveNext();
-                       }
-                       echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n";
-               }
-                                                               
                echo "</table>\n";
                echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create_sequence\" />\n";
                echo $misc->form;
                global $data;
                global $lang;
                
-               // Default tablespace to null if it isn't set
-               if (!isset($_POST['formSpc'])) $_POST['formSpc'] = null;
-               
                // Check that they've given a name and at least one column
                if ($_POST['formSequenceName'] == '') doCreateSequence($lang['strsequenceneedsname']);
                else {
                        $status = $data->createSequence($_POST['formSequenceName'],
                                $_POST['formIncrement'], $_POST['formMinValue'],
                                $_POST['formMaxValue'], $_POST['formStartValue'],
-                               $_POST['formCacheValue'], isset($_POST['formCycledValue']), $_POST['formSpc']);
+                               $_POST['formCacheValue'], isset($_POST['formCycledValue']));
                        if ($status == 0) {
                                doDefault($lang['strsequencecreated']);
                        } else {
index 624605c34e047df243a50bd6e5bd5853e90499f5..e571c11bdec79e147a76c3f7569774d8fa5a933a 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.16 2004/07/09 03:24:12 chriskl Exp $
+        * $Id: sqledit.php,v 1.17 2004/07/12 07:13:32 chriskl Exp $
         */
 
        // Include application functions
                        // The javascript action on the select box reloads the popup whenever the database is changed.
                        // This ensures that the correct page encoding is used.  The exact URL to reload to is different
                        // between SQL and Find mode, however.
-                       if ($action == 'sql')
+                       if ($action == 'sql') {
                                echo "<p>{$lang['strdatabase']}: <select name=\"database\" onChange=\"location.href='sqledit.php?action=" . 
-                                               urlencode($action) . "&database=' + encodeURI(options[selectedIndex].value) + '&query=' + encodeURI(query.value) + (paginate.checked ? '&paginate=on' : '')  + '&" . 
-                                               SID . "'\">\n";
+                                               urlencode($action) . "&database=' + encodeURI(options[selectedIndex].value) + '&query=' + encodeURI(query.value) ";
+                               if ($data->hasSchemas()) echo "+ '&search_path=' + encodeURI(search_path.value) ";
+                               echo "+ (paginate.checked ? '&paginate=on' : '')  + '&" . SID . "'\">\n";
+                       }
                        else
                                echo "<p>{$lang['strdatabase']}: <select name=\"database\" onChange=\"location.href='sqledit.php?action=" . 
-                                               urlencode($action) . "&database=' + encodeURI(options[selectedIndex].value) + '&term=' + encodeURI(term.value) + '&" . SID . "'\">\n";
+                                               urlencode($action) . "&database=' + encodeURI(options[selectedIndex].value) + '&term=' + encodeURI(term.value) + '&filter=' + encodeURI(filter.value) + '&" . SID . "'\">\n";
                        
                        while (!$databases->EOF) {
                                $dbname = $databases->f['datname'];
         */
        function doFind() {
                global $PHP_SELF, $data, $misc;
-               global $lang;
+               global $lang, $conf;
 
                if (!isset($_GET['term'])) $_GET['term'] = '';
+               if (!isset($_GET['filter'])) $_GET['filter'] = '';
 
                $misc->printPopUpNav();
                echo "<h2>{$lang['strfind']}</h2>\n";
                _printDatabases();
                echo "</p><p><input name=\"term\" value=\"", htmlspecialchars($_GET['term']), 
                        "\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
+                       
+               // Output list of filters.  This is complex due to all the 'has' and 'conf' feature possibilities
+               echo "<select name=\"filter\">\n";
+               echo "\t<option value=\"\"", ($_GET['filter'] == '') ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n";
+               if ($data->hasSchemas())
+                       echo "\t<option value=\"SCHEMA\"", ($_GET['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
+               if ($data->hasTables())
+                       echo "\t<option value=\"TABLE\"", ($_GET['filter'] == 'TABLE') ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n";
+               if ($data->hasViews())
+                       echo "\t<option value=\"VIEW\"", ($_GET['filter'] == 'VIEW') ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n";
+               if ($data->hasSequences())
+                       echo "\t<option value=\"SEQUENCE\"", ($_GET['filter'] == 'SEQUENCE') ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n";
+               if ($data->hasTables() || $data->hasViews()) {
+                       echo "\t<option value=\"COLUMN\"", ($_GET['filter'] == 'COLUMN') ? ' selected="selected"' : '', ">{$lang['strcolumns']}</option>\n";
+                       echo "\t<option value=\"RULE\"", ($_GET['filter'] == 'RULE') ? ' selected="selected"' : '', ">{$lang['strrules']}</option>\n";
+               }
+               if ($data->hasTables()) {
+                       echo "\t<option value=\"INDEX\"", ($_GET['filter'] == 'INDEX') ? ' selected="selected"' : '', ">{$lang['strindexes']}</option>\n";
+                       echo "\t<option value=\"TRIGGER\"", ($_GET['filter'] == 'TRIGGER') ? ' selected="selected"' : '', ">{$lang['strtriggers']}</option>\n";
+               }
+               if ($data->hasTables() || $data->hasDomainConstraints())
+                       echo "\t<option value=\"CONSTRAINT\"", ($_GET['filter'] == 'CONSTRAINT') ? ' selected="selected"' : '', ">{$lang['strconstraints']}</option>\n";
+               if ($data->hasFunctions())
+                       echo "\t<option value=\"FUNCTION\"", ($_GET['filter'] == 'FUNCTION') ? ' selected="selected"' : '', ">{$lang['strfunctions']}</option>\n";
+               if ($data->hasTypes() && $conf['show_advanced'])
+                       echo "\t<option value=\"TYPE\"", ($_GET['filter'] == 'TYPE') ? ' selected="selected"' : '', ">{$lang['strtypes']}</option>\n";
+               if ($data->hasDomains())
+                       echo "\t<option value=\"DOMAIN\"", ($_GET['filter'] == 'DOMAIN') ? ' selected="selected"' : '', ">{$lang['strdomains']}</option>\n";
+               if ($data->hasOperators() && $conf['show_advanced'])
+                       echo "\t<option value=\"OPERATOR\"", ($_GET['filter'] == 'OPERATOR') ? ' selected="selected"' : '', ">{$lang['stroperators']}</option>\n";
+               if ($data->hasConversions() && $conf['show_advanced'])
+                       echo "\t<option value=\"CONVERSION\"", ($_GET['filter'] == 'CONVERSION') ? ' selected="selected"' : '', ">{$lang['strconversions']}</option>\n";
+               if ($data->hasLanguages() && $conf['show_advanced'])
+                       echo "\t<option value=\"LANGUAGE\"", ($_GET['filter'] == 'LANGUAGE') ? ' selected="selected"' : '', ">{$lang['strlanguages']}</option>\n";
+               if ($data->hasAggregates() && $conf['show_advanced'])
+                       echo "\t<option value=\"AGGREGATE\"", ($_GET['filter'] == 'AGGREGATE') ? ' selected="selected"' : '', ">{$lang['straggregates']}</option>\n";
+               if ($data->hasOpClasses() && $conf['show_advanced'])
+                       echo "\t<option value=\"OPCLASS\"", ($_GET['filter'] == 'OPCLASS') ? ' selected="selected"' : '', ">{$lang['stropclasses']}</option>\n";
+               echo "</select>\n";
+                                       
                echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n";
                echo $misc->form;
                echo "<input type=\"hidden\" name=\"action\" value=\"find\" /></p>\n";