Greg, et al,

Having found a case where PostgreSQL's composite types might be useful
here, I wonder if support for them could be added to DBD::Pg. 

What comes to mind at the moment would be converting the composite types
between a field/value hash and the string constant representation. 
Something along the lines of the following.

create type comp as (
  a int,
  b text,
  c text
);

create table t1 as (
  id int4,
  ct1 comp,
  ct2 comp
);

$dbh->do('insert into t1 (id, ct1, ct2) values (?,?,?)', undef, 10,
{a=>1,b=>'test',c=>'1 2 3'}, {a=>2,b=>'more text', c=>'stuff'});

# results in the placeholders being replaced by
#  10
#  '(1, "test", "1 2 3")'
#  '(2, "more text", "stuff")'


$fields = $dbh->selectrow_arrayref('select id, ct1, ct2 from t1');

# would set $fields to
# [
#  10,
#  { a=> 1, b=>'test', c=>'1 2 3' },
#  { a=> 2, b=>'more text', c=>'stuff'},
# ]


Does this make sense?

Mike

Reply via email to