+support for show_system in casts
fix getIndexes() and getConstraints() for < 7.3 to know about index type
(eg. constraints can only be btree indexes)
re-enable help system
all DROP and ALTER commands MUST be fully schema-qualified otherwise you can accidentally drop stuff in pg_catalog :(
-
* if you click on a database it shows a list of database objects in that
* database.
*
- * $Id: browser.php,v 1.19 2003/10/26 10:59:16 chriskl Exp $
+ * $Id: browser.php,v 1.20 2003/10/26 12:12:28 chriskl Exp $
*/
// Include application functions
addNodes($db_node, $querystr);
}
+
+ // Casts
+ if ($data->hasCasts()) {
+ $cast_node = &new HTML_TreeNode(array(
+ 'text' => addslashes($lang['strcasts']),
+ 'link' => addslashes(htmlspecialchars("casts.php?{$querystr}")),
+ 'icon' => "../../../images/themes/{$conf['theme']}/types.png",
+ 'expandedIcon' => "../../../images/themes/{$conf['theme']}/types.png",
+ 'expanded' => false,
+ 'linkTarget' => 'detail'));
+ // Add folder to database
+ $db_node->addItem($cast_node);
+ }
+
// Add node to menu
$root->addItem($db_node);
--- /dev/null
+<?php
+
+ /**
+ * Manage casts in a database
+ *
+ * $Id: casts.php,v 1.1 2003/10/26 12:12:28 chriskl Exp $
+ */
+
+ // Include application functions
+ include_once('libraries/lib.inc.php');
+
+ $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+ if (!isset($msg)) $msg = '';
+ $PHP_SELF = $_SERVER['PHP_SELF'];
+
+ /**
+ * Show default list of casts in the database
+ */
+ function doDefault($msg = '') {
+ global $data, $localData, $misc, $database;
+ global $PHP_SELF, $lang;
+
+ echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strcasts']}</h2>\n";
+ $misc->printMsg($msg);
+
+ $casts = &$localData->getcasts();
+
+ if ($casts->recordCount() > 0) {
+ echo "<table>\n";
+ echo "<tr><th class=\"data\">{$lang['strsourcetype']}</th><th class=\"data\">{$lang['strtargettype']}</th>";
+ echo "<th class=\"data\">{$lang['strfunction']}</th><th class=\"data\">{$lang['strimplicit']}</th>";
+ echo "</tr>\n";
+ $i = 0;
+ while (!$casts->EOF) {
+ $id = (($i % 2) == 0 ? '1' : '2');
+ echo "<tr><td class=\"data{$id}\">", $misc->printVal($casts->f['castsource']), "</td>\n";
+ echo "<td class=\"data{$id}\">", $misc->printVal($casts->f['casttarget']), "</td>\n";
+ echo "<td class=\"data{$id}\">", $misc->printVal($casts->f['castfunc']), "</td>\n";
+ echo "<td class=\"data{$id}\">", $misc->printVal($casts->f['castcontext']), "</td>\n";
+ echo "</tr>\n";
+ $casts->moveNext();
+ $i++;
+ }
+ echo "</table>\n";
+ }
+ else {
+ echo "<p>{$lang['strnocasts']}</p>\n";
+ }
+
+// echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create&{$misc->href}\">{$lang['strcreatecast']}</a></p>\n";
+ }
+
+ $misc->printHeader($lang['strcasts']);
+ $misc->printBody();
+
+ switch ($action) {
+ case 'save_create':
+ if (isset($_POST['cancel'])) doDefault();
+ else doSaveCreate();
+ break;
+ case 'create':
+ doCreate();
+ break;
+ case 'drop':
+ if (isset($_POST['cancel'])) doDefault();
+ else doDrop(false);
+ break;
+ case 'confirm_drop':
+ doDrop(true);
+ break;
+ case 'properties':
+ doProperties();
+ break;
+ default:
+ doDefault();
+ break;
+ }
+
+ $misc->printFooter();
+
+?>
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: BaseDB.php,v 1.31 2003/10/12 05:46:32 chriskl Exp $
+ * $Id: BaseDB.php,v 1.32 2003/10/26 12:12:28 chriskl Exp $
*/
include_once('classes/database/ADODB_base.php');
function hasRules() { return false; }
function hasLanguages() { return false; }
function hasSchemas() { return false; }
- function hasConversions() { return false; }
+ function hasConversions() { return false; }
function hasGrantOption() { return false; }
function hasCluster() { return false; }
function hasDropBehavior() { return false; }
function hasWithoutOIDs() { return false; }
function hasAlterTableOwner() { return false; }
function hasPartialIndexes() { return false; }
+ function hasCasts() { return false; }
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.72 2003/10/26 10:59:16 chriskl Exp $
+ * $Id: Postgres73.php,v 1.73 2003/10/26 12:12:28 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
$this->clean($table);
$sql = "
- SELECT\r
- c.relname AS tablename,\r
- u.usename AS tableowner,\r
- pg_catalog.obj_description(c.oid, 'pg_class') AS tablecomment\r
- FROM pg_catalog.pg_class c\r
- LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner\r
- LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\r
- WHERE c.relkind = 'r'\r
- AND n.nspname = '{$this->_schema}'\r
+ SELECT
+ c.relname AS tablename,
+ u.usename AS tableowner,
+ pg_catalog.obj_description(c.oid, 'pg_class') AS tablecomment
+ FROM pg_catalog.pg_class c
+ LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
+ WHERE c.relkind = 'r'
+ AND n.nspname = '{$this->_schema}'
AND c.relname = '{$table}'";
return $this->selectSet($sql);
return $this->execute($sql);
}
- // Inheritance functions\r
- \r
- /**\r
- * Finds the names and schemas of parent tables (in order)\r
- * @param $table The table to find the parents for\r
- * @return A recordset\r
- */\r
- function &getTableParents($table) {\r
- $this->clean($table);\r
- \r
- $sql = "\r
- SELECT \r
- pn.nspname AS schemaname, relname\r
- FROM\r
- pg_catalog.pg_class pc, pg_catalog.pg_inherits pi, pg_catalog.pg_namespace pn\r
- WHERE\r
+ // Inheritance functions
+
+ /**
+ * Finds the names and schemas of parent tables (in order)
+ * @param $table The table to find the parents for
+ * @return A recordset
+ */
+ function &getTableParents($table) {
+ $this->clean($table);
+
+ $sql = "
+ SELECT
+ pn.nspname AS schemaname, relname
+ FROM
+ pg_catalog.pg_class pc, pg_catalog.pg_inherits pi, pg_catalog.pg_namespace pn
+ WHERE
pc.oid=pi.inhparent
- AND pc.relnamespace=pn.oid\r
+ AND pc.relnamespace=pn.oid
AND pi.inhrelid = (SELECT oid from pg_catalog.pg_class WHERE relname='{$table}'
- AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '{$this->_schema}'))\r
- ORDER BY\r
- pi.inhseqno\r
- ";\r
- \r
- return $this->selectSet($sql); \r
- } \r
-\r
-\r
- /**\r
- * Finds the names and schemas of child tables\r
- * @param $table The table to find the children for\r
- * @return A recordset\r
- */\r
- function &getTableChildren($table) {\r
- $this->clean($table);\r
- \r
- $sql = "\r
- SELECT \r
- pn.nspname AS schemaname, relname\r
- FROM\r
- pg_catalog.pg_class pc, pg_catalog.pg_inherits pi, pg_catalog.pg_namespace pn\r
- WHERE\r
+ AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '{$this->_schema}'))
+ ORDER BY
+ pi.inhseqno
+ ";
+
+ return $this->selectSet($sql);
+ }
+
+
+ /**
+ * Finds the names and schemas of child tables
+ * @param $table The table to find the children for
+ * @return A recordset
+ */
+ function &getTableChildren($table) {
+ $this->clean($table);
+
+ $sql = "
+ SELECT
+ pn.nspname AS schemaname, relname
+ FROM
+ pg_catalog.pg_class pc, pg_catalog.pg_inherits pi, pg_catalog.pg_namespace pn
+ WHERE
pc.oid=pi.inhrelid
- AND pc.relnamespace=pn.oid\r
+ AND pc.relnamespace=pn.oid
AND pi.inhparent = (SELECT oid from pg_catalog.pg_class WHERE relname='{$table}'
- AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '{$this->_schema}'))\r
- ";\r
- \r
- return $this->selectSet($sql); \r
+ AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '{$this->_schema}'))
+ ";
+
+ return $this->selectSet($sql);
}
// View functions
return $this->selectSet($sql);
}
+
+ // Cast functions
+
+ /**
+ * Returns a list of all casts in the database
+ * @return All casts
+ */
+ function &getCasts() {
+
+ $sql = "
+ SELECT
+ castsource::pg_catalog.regtype AS castsource,
+ casttarget::pg_catalog.regtype AS casttarget,
+ CASE WHEN castfunc = 0 THEN '(binary compatible)'
+ ELSE p.proname
+ END AS castfunc,
+ CASE WHEN c.castcontext = 'e' THEN 'no'
+ WHEN c.castcontext = 'a' THEN 'in assignment'
+ ELSE 'yes'
+ END AS castcontext
+ FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p
+ ON c.castfunc = p.oid
+ ORDER BY 1, 2
+ ";
+
+ return $this->selectSet($sql);
+ }
// Capabilities
function hasSchemas() { return true; }
function hasDropColumn() { return true; }
function hasDomains() { return true; }
function hasAlterTrigger() { return true; }
+ function hasCasts() { return true; }
}
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.116 2003/10/26 10:59:16 chriskl Exp $
+ * $Id: english.php,v 1.117 2003/10/26 12:12:28 chriskl Exp $
*/
// Language and character set
$lang['stroperatordropped'] = 'Operator dropped.';
$lang['stroperatordroppedbad'] = 'Operator drop failed.';
+ // Casts
+ $lang['strcasts'] = 'Casts';
+ $lang['strnocasts'] = 'No casts found.';
+ $lang['strsourcetype'] = 'Source type';
+ $lang['strtargettype'] = 'Target type';
+ $lang['strimplicit'] = 'Implicit';
+
// Info
$lang['strnoinfo'] = 'No information available.';
$lang['strreferringtables'] = 'Referring tables';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.68 2003/10/26 10:59:17 chriskl Exp $
+ * $Id: english.php,v 1.69 2003/10/26 12:12:29 chriskl Exp $
*/
// Language and character set
$lang['stroperatordropped'] = 'Operator dropped.';
$lang['stroperatordroppedbad'] = 'Operator drop failed.';
+ // Casts
+ $lang['strcasts'] = 'Casts';
+ $lang['strnocasts'] = 'No casts found.';
+ $lang['strsourcetype'] = 'Source type';
+ $lang['strtargettype'] = 'Target type';
+ $lang['strimplicit'] = 'Implicit';
+
// Info
$lang['strnoinfo'] = 'No information available.';
$lang['strreferringtables'] = 'Referring tables';