Text type reported incorrectly

"Ben Tilly" <[email protected]>
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <[email protected]>
Let us create a table:

  create table foo (
    bar text
  );

Let's look at it in information_schema:

  SELECT column_name
    , data_type
    , character_maximum_length
  FROM information_schema.columns
  WHERE table_name = 'foo';

It tells you that it is text and there is no character_maximum length.
 If you wish you can test this by entering a 2K string.

But in Perl:

  my $sth = $dbh->prepare("select * from foo");
  $sth->execute();
  print "TYPE: $sth->{TYPE}[0]\nPRECISION: $sth->{PRECISION}[0]\n";

you'll be told that the type is 12 (same as varchar) and the precision
is 80.  This is indistinguishable from a varchar(76), but the types
are very different.

Ben
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.