/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.40 2003/08/11 04:52:32 chriskl Exp $
+ * $Id: Misc.php,v 1.41 2003/08/12 08:18:53 chriskl Exp $
*/
class Misc {
case 'money':
case 'numeric':
case 'oid':
+ case 'xid':
+ case 'cid':
+ case 'tid':
return "<div align=\"right\">" . nl2br(htmlspecialchars($str)) . "</div>";
break;
case 'bool':
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: BaseDB.php,v 1.23 2003/08/06 07:04:44 chriskl Exp $
+ * $Id: BaseDB.php,v 1.24 2003/08/12 08:18:54 chriskl Exp $
*/
include_once('classes/database/ADODB_base.php');
function hasAlterTrigger() { return false; }
function hasWithoutOIDs() { return false; }
function hasAlterTableOwner() { return false; }
+ function hasPartialIndexes() { return false; }
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.137 2003/08/11 09:15:32 chriskl Exp $
+ * $Id: Postgres.php,v 1.138 2003/08/12 08:18:54 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
break;
case 'text':
case 'bytea':
+ // addCSlashes converts all weird ASCII characters to octal representation,
+ // EXCEPT the 'special' ones like \r \n \t, etc.
+ if ($type == 'bytea') $value = addCSlashes($value, "\0..\37\177..\377");
echo "<textarea name=\"", htmlspecialchars($name), "\" rows=\"5\" cols=\"28\" wrap=\"virtual\">\n";
echo htmlspecialchars($value);
echo "</textarea>\n";
* @param $table The table on which to add the index
* @param $columns An array of columns that form the index
* @param $type The index type
+ * @param $unique True if unique, false otherwise
+ * @param $where Index predicate ('' for none)
* @return 0 success
*/
- function createIndex($name, $table, $columns, $type) {
+ function createIndex($name, $table, $columns, $type, $unique, $where) {
$this->fieldClean($name);
$this->fieldClean($table);
$this->arrayClean($columns);
- $sql = "CREATE INDEX \"{$name}\" ON \"{$table}\" USING {$type} ";
+ $sql = "CREATE";
+ if ($unique) $sql .= " UNIQUE";
+ $sql .= " INDEX \"{$name}\" ON \"{$table}\" USING {$type} ";
$sql .= "(\"" . implode('","', $columns) . "\")";
-
+
+ if ($this->hasPartialIndexes() && trim($where) != '') {
+ $sql .= " WHERE ({$where})";
+ }
return $this->execute($sql);
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres72.php,v 1.47 2003/08/04 08:27:27 chriskl Exp $
+ * $Id: Postgres72.php,v 1.48 2003/08/12 08:18:54 chriskl Exp $
*/
// Capabilities
function hasWithoutOIDs() { return true; }
+ function hasPartialIndexes() { return true; }
}
/**
* List indexes on a table
*
- * $Id: indexes.php,v 1.16 2003/08/12 08:11:08 chriskl Exp $
+ * $Id: indexes.php,v 1.17 2003/08/12 08:18:53 chriskl Exp $
*/
// Include application functions
echo "<th class=\"data\">{$lang['strunique']}</th>";
echo "<td class=\"data1\"><input type=\"checkbox\" name=\"formUnique\"", (isset($_POST['formUnique']) ? 'checked="checked"' : ''), " /></td>";
echo "</tr>";
- echo "<tr>";
- echo "<th class=\"data\">{$lang['strwhere']}</th>";
- echo "<td class=\"data1\">(<input name=\"formWhere\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
- htmlspecialchars($_POST['formWhere']), "\" />)</td>";
- echo "</tr>";
+ if ($data->hasPartialIndexes()) {
+ echo "<tr>";
+ echo "<th class=\"data\">{$lang['strwhere']}</th>";
+ echo "<td class=\"data1\">(<input name=\"formWhere\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
+ htmlspecialchars($_POST['formWhere']), "\" />)</td>";
+ echo "</tr>";
+ }
echo "</table>";
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create_index\" />\n";
global $localData;
global $lang;
+ // Handle databases that don't have partial indexes
+ if (!isset($_POST['formWhere'])) $_POST['formWhere'] = '';
+
// Check that they've given a name and at least one column
if ($_POST['formIndexName'] == '') doCreateIndex($lang['strindexneedsname']);
elseif (!isset($_POST['IndexColumnList']) || $_POST['IndexColumnList'] == '') doCreateIndex($lang['strindexneedscols']);