* Add CACHE and CYCLE parameters in sequence creation
* View, add, edit and delete comments on views, schemas and columns (Dan Boren)
* Allow creating array columns in tables
+* Allow adding array columns to tables
+* Allow creating domains with type length and arrays
Bugs
* Fix pg_dump output for PostgreSQL 7.0.x and 7.1.x
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.91 2004/03/12 08:56:54 chriskl Exp $
+ * $Id: Postgres73.php,v 1.92 2004/03/31 07:46:39 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* Creates a domain
* @param $domain The name of the domain to create
* @param $type The base type for the domain
+ * @param $length Optional type length
+ * @param $array True for array type, false otherwise
* @param $notnull True for NOT NULL, false otherwise
* @param $default Default value for domain
* @param $check A CHECK constraint if there is one
* @return 0 success
*/
- function createDomain($domain, $type, $notnull, $default, $check) {
+ function createDomain($domain, $type, $length, $array, $notnull, $default, $check) {
$this->fieldClean($domain);
- $sql = "CREATE DOMAIN \"{$domain}\" AS {$type}";
+ $sql = "CREATE DOMAIN \"{$domain}\" AS ";
+
+ if ($length == '')
+ $sql .= $type;
+ else {
+ switch ($type) {
+ // Have to account for weird placing of length for with/without
+ // time zone types
+ case 'timestamp with time zone':
+ case 'timestamp without time zone':
+ $qual = substr($type, 9);
+ $sql .= "timestamp({$length}){$qual}";
+ break;
+ case 'time with time zone':
+ case 'time without time zone':
+ $qual = substr($type, 4);
+ $sql .= "time({$length}){$qual}";
+ break;
+ default:
+ $sql .= "{$type}({$length})";
+ }
+ }
+
+ // Add array qualifier, if requested
+ if ($array) $sql .= '[]';
+
if ($notnull) $sql .= ' NOT NULL';
if ($default != '') $sql .= " DEFAULT {$default}";
if ($this->hasDomainConstraints() && $check != '') $sql .= " CHECK ({$check})";
/**
* Manage domains in a database
*
- * $Id: domains.php,v 1.8 2003/12/30 03:09:29 chriskl Exp $
+ * $Id: domains.php,v 1.9 2004/03/31 07:46:39 chriskl Exp $
*/
// Include application functions
if (!isset($_POST['domname'])) $_POST['domname'] = '';
if (!isset($_POST['domtype'])) $_POST['domtype'] = '';
+ if (!isset($_POST['domlength'])) $_POST['domlength'] = '';
+ if (!isset($_POST['domarray'])) $_POST['domarray'] = '';
if (!isset($_POST['domdefault'])) $_POST['domdefault'] = '';
if (!isset($_POST['domcheck'])) $_POST['domcheck'] = '';
$misc->printVal($types->f[$data->typFields['typname']]), "</option>\n";
$types->moveNext();
}
- echo "</select>\n";
- echo "</td></tr>\n";
+ echo "</select>\n";
+
+ // Type length
+ echo "<input type=\"text\" size=\"4\" name=\"domlength\" value=\"", htmlspecialchars($_POST['domlength']), "\" />";
+
+ // Output array type selector
+ echo "<select name=\"domarray\">\n";
+ echo "<option value=\"\"", ($_POST['domarray'] == '') ? ' selected="selected"' : '', "></option>\n";
+ echo "<option value=\"[]\"", ($_POST['domarray'] == '[]') ? ' selected="selected"' : '', ">[ ]</option>\n";
+ echo "</select></td></tr>\n";
+
echo "<tr><th class=\"data left\">{$lang['strnotnull']}</th>\n";
echo "<td class=\"data1\"><input type=\"checkbox\" name=\"domnotnull\"",
(isset($_POST['domnotnull']) ? ' checked="checked"' : ''), " /></td></tr>\n";
// Check that they've given a name and a definition
if ($_POST['domname'] == '') doCreate($lang['strdomainneedsname']);
else {
- $status = $data->createDomain($_POST['domname'], $_POST['domtype'],
+ $status = $data->createDomain($_POST['domname'], $_POST['domtype'], $_POST['domlength'], $_POST['domarray'] != '',
isset($_POST['domnotnull']), $_POST['domdefault'], $_POST['domcheck']);
if ($status == 0)
doDefault($lang['strdomaincreated']);