summaryrefslogtreecommitdiff
path: root/includes/database/pgsql/schema.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-26 11:04:39 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-26 11:04:39 +0000
commit9120540d19b83f8686b4f4c34d9cd011f93a14a6 (patch)
tree1ccb83720c54e651271b071b19b617afdeb0efb3 /includes/database/pgsql/schema.inc
parente23a87d1f9233ed4145975fef74f85429de43513 (diff)
downloadbrdo-9120540d19b83f8686b4f4c34d9cd011f93a14a6.tar.gz
brdo-9120540d19b83f8686b4f4c34d9cd011f93a14a6.tar.bz2
- Patch #339588 by jhedstrom, Josh Waihi, mikl: remove *_unsigned types and rework their sizes. Fixes exception on PostgreSQL.
Diffstat (limited to 'includes/database/pgsql/schema.inc')
-rw-r--r--includes/database/pgsql/schema.inc26
1 files changed, 20 insertions, 6 deletions
diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc
index afad997a4..cbbf36dc9 100644
--- a/includes/database/pgsql/schema.inc
+++ b/includes/database/pgsql/schema.inc
@@ -84,12 +84,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
unset($spec['not null']);
}
if (!empty($spec['unsigned'])) {
- if ($spec['type'] == 'serial') {
- $sql .= " CHECK ($name >= 0)";
- }
- else {
- $sql .= '_unsigned';
- }
+ $sql .= " CHECK ($name >= 0)";
}
if (!empty($spec['length'])) {
@@ -125,6 +120,25 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
$map = $this->getFieldTypeMap();
$field['pgsql_type'] = $map[$field['type'] . ':' . $field['size']];
}
+ if (!empty($field['unsigned'])) {
+ // Unsigned datatypes are not supported in PostgreSQL 8.3. In MySQL,
+ // they are used to ensure a positive number is inserted and it also
+ // doubles the maximum integer size that can be stored in a field.
+ // The PostgreSQL schema in Drupal creates a check constraint
+ // to ensure that a value inserted is >= 0. To provide the extra
+ // integer capacity, here, we bump up the column field size.
+ if (!isset($map)) {
+ $map = $this->getFieldTypeMap();
+ }
+ switch ($field['pgsql_type']) {
+ case 'smallint':
+ $field['pgsql_type'] = $map['int:medium'];
+ break;
+ case 'int' :
+ $field['pgsql_type'] = $map['int:big'];
+ break;
+ }
+ }
if ($field['type'] == 'serial') {
unset($field['not null']);
}