pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Apitz <guru@unixarea.de>
To: Ian Lawrence Barwick <barwick@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: DBD::Pg (version 3.16.3) returns EMPTY char columns as 'undef'
Date: Wed, 26 Apr 2023 07:32:58 +0200
Message-ID: <ZEi3iqLJMSoMkXfx@pureos> (raw)
In-Reply-To: <CAB8KJ=hp2HdjT46jX067T4LxoE7YuPG3c4hBoiT5_W1WnpkQJw@mail.gmail.com>
References: <ZEfKic3n/58EOpoa@pureos>
	<CAB8KJ=hp2HdjT46jX067T4LxoE7YuPG3c4hBoiT5_W1WnpkQJw@mail.gmail.com>

El día martes, abril 25, 2023 a las 09:58:10 +0900, Ian Lawrence Barwick escribió:

> "eq undef" looks very wrong there:
> 
>     $ perl -e "printf(qq|%i\n|, '' eq undef);"
>     1
>     $ perl -e "printf(qq|%i\n|, defined '');"
>     1
> 
> You probably want "if (!defined $row_ary[$i])". And possibly warnings enabled:
> 
> ...

Ian,

Thanks for this hint. It fixed it. I modified the code to:

    ...
    foreach my $i (0..$#row_ary) {
        if (!defined $row_ary[$i])  {
           printf $row_ary[0] . " | " . $row_ary[1] . " | " . $row_ary[2] . "\n";
           next;
        }

set one row to have a NULL value (others have '' or a real string for
the column varvalue):

testdb=# update adm_partab set varvalue = NULL where varname='DocumentUploadSshPassw';
UPDATE 1

testdb=# \pset null '<null>'
Null-Anzeige ist »<null>«.

testdb=# select * from adm_partab  where varname='DocumentUploadSshPassw';
 product |        varname         | varvalue
---------+------------------------+----------
       1 | DocumentUploadSshPassw | <null>

and run the modiefied code which prints only the row with the NULL
value, exports everything fine and the NULL value as '\N':

~sisis/sc/dbtool < unl 2>&1 | more
connected to Pg:testdb
begin operation: UNLOAD (adm_partab)
1 | DocumentUploadSshPassw |
366 rows unloaded...

grep -C3 '|\\N' adm_partab.load
2|CIR_auto_idm_informieren|N
2|CIR_GebMahn_SO|N
2|CIR_BR_Immer_Benachrichtigen|N
1|DocumentUploadSshPassw|\N         <***************
2|CIR_AutoTempMedien|N
2|CIR_PrintCmd_List_Ascii|/opt/lib/sisis/bin/AsciiPrint.sh
2|CIR_Such_Kategorie_4|902 Schlagwort

even the warning is printed for this perl line 1196:

~sisis/sc/dbtool < unl 2>&1 | grep 1196
Use of uninitialized value $row_ary[2] in concatenation (.) or string at /home/sisis/sc/dbtool.pl line 1196.

Thanks again and

Kind Regards

	matthias

-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub





view thread (4+ messages)

Message-ID: <ZEi3iqLJMSoMkXfx@pureos>
Permalink:  ../ZEi3iqLJMSoMkXfx@pureos/
Also on:    postgresql.org/message-id/ZEi3iqLJMSoMkXfx@pureos

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guru@unixarea.de, barwick@gmail.com
  Subject: Re: DBD::Pg (version 3.16.3) returns EMPTY char columns as 'undef'
  In-Reply-To: <ZEi3iqLJMSoMkXfx@pureos>
  References: <ZEfKic3n/58EOpoa@pureos> <CAB8KJ=hp2HdjT46jX067T4LxoE7YuPG3c4hBoiT5_W1WnpkQJw@mail.gmail.com> <ZEi3iqLJMSoMkXfx@pureos>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox