DBI && INSERT

From: Matthias Apitz <guru(at)unixarea(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: DBI && INSERT
Date: 2020-02-17 15:49:27
Message-ID: 20200217154927.GA2720@c720-r342378
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

I spend today some hours to nail down and insert problem into our
database with DBI like:

my $rc = $my_dbh->do($my_sqlstatement);

which returns 1 in $rc (which the following flow in our script took as an
error). If one fired up the same string in $my_sqlstatement with pgsql
the result was always

INSERT 0 1

At the end of the day I watched with strace the communication on the
network between the DBI client and the PG server:

...
13576 sendto(3, "6f7374656e20676573636872696562656e3a303a0a726561645f656469666163745f66696c65733a3a6d61696e20456e646520616d2031372e30322e3230323020756d2031363a30303a3234205568720a6c6f67206265656e6465742c206a65747a74207769726420696e7365727420646573206c6f677320696e206163715f7661726461746120766572737563687420286e757220696d207472616365207369636874626172290a', \n 1)\0", 359, MSG_NOSIGNAL, NULL, 0) = 359
13576 poll([{fd=3, events=POLLIN|POLLERR}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}])
13576 recvfrom(3, "C\0\0\0\17INSERT 0 1\0Z\0\0\0\5I", 32768, 0, NULL, NULL) = 22
13576 write(4, " <- do= ( 1 ) [1 items] at read_edifact_files.pl line 8831\n", 62) = 62
13576 write(4, " -> $DBI::errstr (&) FETCH from lasth=HASH\n", 46) = 46
13576 write(4, " <- $DBI::errstr= undef\n", 27) = 27
...

i.e. the response on the network was (always) also 'INSERT 0 1' and DBI
misinterprets this as an error condition with 'undef' $DBI::errstr
string.

matthias
--
Matthias Apitz, ✉ guru(at)unixarea(dot)de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gianni Ceccarelli 2020-02-17 16:15:40 Re: DBI && INSERT
Previous Message Jason Swails 2020-02-17 15:17:41 Re: Cannot connect to postgresql-11 from another machine after boot