FAQ
I just spent an hour banging my head against the wall before I figured
out two annoying things about the COPY support in DBD::Pg.

1. In the call to pg_getline, do NOT pass in an undefined variable in.
You will get warnings. So instead of something like:

while ($dbd->pg_getline(my $line, $size)) {
# do stuff
}

write

my $line = "";
while ($dbd->pg_getline($line, $size)) {
# do stuff
}

(I would complain about the $size part, but googling on the topic
suggests that a future release will remove that parameter, and take
care of the related potential for buffer overflows.)

2. You don't want to call pg_endcopy on a handle that you are using
pg_getline with. Because pg_getline will do and end copy for you on
your last line. Which means that your call to pg_endcopy will blow up
in a most annoying fashion.

Cheers,
Ben

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbd-pg @
categoriesperl
postedAug 6, '07 at 9:02p
activeAug 6, '07 at 9:02p
posts1
users1
websiteperl.org

1 user in discussion

Ben Tilly: 1 post

People

Translate

site design / logo © 2022 Grokbase