OT - (was Re: Data types mapping)

From: Doug Silver <dsilver(at)urchin(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: OT - (was Re: Data types mapping)
Date: 2003-04-10 18:45:37
Message-ID: 200304101145.15588.dsilver@urchin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thursday 10 April 2003 11:19 am, you wrote:
> Doug Silver <dsilver(at)urchin(dot)com> writes:
> > I have a partial mapping of some of the fields with their internal type,
> > e.g.: integer 4
> > smallint 5
>
> Some of these are wrong ... from memory, int4 is 23.
>
> > What internal table has the complete mapping?
>
> SELECT oid, typname FROM pg_type
>
> This will give you a lot of things you did not realize were types, too.
> You might prefer to ignore rows with typtype != 'b'.
>
> regards, tom lane

Hi Tom -

That's what I thought too, but when I run the following perl script I get
this:
\d test
Table "public.test"
Column | Type | Modifiers
--------+----------------------+-----------
a | smallint |
b | integer |
c | bigint |
d | numeric(8,2) |
e | character varying(5) |
f | text |
g | character(1) |
h | boolean |

>cat test.pl
use strict;
use warnings;
use DBI;
[snip setting up connection]
my $sth = $dbh->prepare("select * from test where 1=2");
my $rc=$sth->execute;
my @field_name = @{$sth->{NAME}};
my @field_type = @{$sth->{TYPE}};
for (my $i=0;$i<@field_name;$i++){
print "Field $field_name[$i] = $field_type[$i]\n";
}
> ./test.pl

Field a = 5
Field b = 4
Field c = 8
Field d = 1700 (correct)
Field e = 12
Field f = 25 (correct)
Field g = 1
Field h = 16 (correct)

So would you think this a problem with the perl module DBI or DBD-Pg (or
both)?

-doug

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-04-10 18:49:11 Re: OT - (was Re: Data types mapping)
Previous Message Delao, Darryl W 2003-04-10 18:33:09 Remote logging in postgres