if ($type == 6) { # SERIAL
$result->{$col}{is_auto_increment} = 1;
}
-
- my $data_type = $result->{$col}{data_type};
-
- if (looks_like_number $data_type) {
- if ($type == 7) {
- $result->{$col}{data_type} = 'date';
- }
- elsif ($type == 10) {
- $result->{$col}{data_type} = 'datetime year to fraction(5)';
- # this doesn't work yet
+ elsif ($type == 7) {
+ $result->{$col}{data_type} = 'date';
+ }
+ elsif ($type == 10) {
+ $result->{$col}{data_type} = 'datetime year to fraction(5)';
+ # this doesn't work yet
# $result->{$col}{data_type} = 'datetime ' . $self->_informix_datetime_precision($info->{collength});
- }
- elsif ($type == 17 || $type == 52) {
- $result->{$col}{data_type} = 'bigint';
- }
- elsif ($type == 40) {
- $result->{$col}{data_type} = 'lvarchar';
- $result->{$col}{size} = $info->{collength};
- }
- elsif ($type == 12) {
- $result->{$col}{data_type} = 'text';
- }
- elsif ($type == 11) {
- $result->{$col}{data_type} = 'bytea';
- $result->{$col}{original}{data_type} = 'byte';
- }
- elsif ($type == 41) {
- # XXX no way to distinguish opaque types boolean, blob and clob
- $result->{$col}{data_type} = 'blob';
- }
- elsif ($type == 21) {
- $result->{$col}{data_type} = 'list';
- }
- elsif ($type == 20) {
- $result->{$col}{data_type} = 'multiset';
- }
- elsif ($type == 19) {
- $result->{$col}{data_type} = 'set';
- }
}
-
- if ($type == 15) {
+ elsif ($type == 17 || $type == 52) {
+ $result->{$col}{data_type} = 'bigint';
+ }
+ elsif ($type == 40) {
+ $result->{$col}{data_type} = 'lvarchar';
+ $result->{$col}{size} = $info->{collength};
+ }
+ elsif ($type == 12) {
+ $result->{$col}{data_type} = 'text';
+ }
+ elsif ($type == 11) {
+ $result->{$col}{data_type} = 'bytea';
+ $result->{$col}{original}{data_type} = 'byte';
+ }
+ elsif ($type == 41) {
+ # XXX no way to distinguish opaque types boolean, blob and clob
+ $result->{$col}{data_type} = 'blob' unless $result->{$col}{data_type} eq 'smallint';
+ }
+ elsif ($type == 21) {
+ $result->{$col}{data_type} = 'list';
+ }
+ elsif ($type == 20) {
+ $result->{$col}{data_type} = 'multiset';
+ }
+ elsif ($type == 19) {
+ $result->{$col}{data_type} = 'set';
+ }
+ elsif ($type == 15) {
$result->{$col}{data_type} = 'nchar';
}
elsif ($type == 16) {
$result->{$col}{data_type} = 'idssecuritylabel';
}
+ my $data_type = $result->{$col}{data_type};
+
+ if ($data_type !~ /^(?:[nl]?(?:var)?char|decimal)\z/i) {
+ delete $result->{$col}{size};
+ }
+
+ if (lc($data_type) eq 'decimal') {
+ no warnings 'uninitialized';
+
+ $result->{$col}{data_type} = 'numeric';
+
+ my @size = @{ $result->{$col}{size} || [] };
+
+ if ($size[0] == 16 && $size[1] == -4) {
+ delete $result->{$col}{size};
+ }
+ elsif ($size[0] == 16 && $size[1] == 2) {
+ $result->{$col}{data_type} = 'money';
+ delete $result->{$col}{size};
+ }
+ }
+ elsif (lc($data_type) eq 'smallfloat') {
+ $result->{$col}{data_type} = 'real';
+ }
+ elsif (lc($data_type) eq 'float') {
+ $result->{$col}{data_type} = 'double precision';
+ }
+ elsif ($data_type =~ /^n?(?:var)?char\z/i) {
+ $result->{$col}{size} = $result->{$col}{size}[0];
+ }
+
# XXX colmin doesn't work for min size of varchar columns, it's NULL
# if (lc($data_type) eq 'varchar') {
# $result->{$col}{size}[1] = $info->{colmin};
}
}
- # fix up data_types some more
- while (my ($col, $info) = each %$result) {
- my $data_type = $info->{data_type};
-
- if ($data_type !~ /^(?:[nl]?(?:var)?char|decimal)\z/i) {
- delete $info->{size};
- }
-
- if (lc($data_type) eq 'decimal') {
- no warnings 'uninitialized';
-
- $info->{data_type} = 'numeric';
-
- my @size = @{ $info->{size} || [] };
-
- if ($size[0] == 16 && $size[1] == -4) {
- delete $info->{size};
- }
- elsif ($size[0] == 16 && $size[1] == 2) {
- $info->{data_type} = 'money';
- delete $info->{size};
- }
- }
- elsif (lc($data_type) eq 'smallfloat') {
- $info->{data_type} = 'real';
- }
- elsif (lc($data_type) eq 'float') {
- $info->{data_type} = 'double precision';
- }
- elsif ($data_type =~ /^n?(?:var)?char\z/i) {
- $info->{size} = $info->{size}[0];
- }
- }
-
return $result;
}