Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prXm8-0002lm-FT for pgsql-general@arkaria.postgresql.org; Wed, 26 Apr 2023 05:33:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1prXm5-0001Hx-O3 for pgsql-general@arkaria.postgresql.org; Wed, 26 Apr 2023 05:33:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prXm5-0001Ho-DA for pgsql-general@lists.postgresql.org; Wed, 26 Apr 2023 05:33:05 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1prXm2-0057Av-Me for pgsql-general@lists.postgresql.org; Wed, 26 Apr 2023 05:33:04 +0000 Received: from [188.174.58.115] (helo=pureos) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prXm0-0006ae-7M; Wed, 26 Apr 2023 07:33:00 +0200 Date: Wed, 26 Apr 2023 07:32:58 +0200 From: Matthias Apitz To: Ian Lawrence Barwick Cc: pgsql-general@lists.postgresql.org Subject: Re: DBD::Pg (version 3.16.3) returns EMPTY char columns as 'undef' Message-ID: Reply-To: Matthias Apitz References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.58.115 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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-Anzeige ist »«. testdb=# select * from adm_partab where varname='DocumentUploadSshPassw'; product | varname | varvalue ---------+------------------------+---------- 1 | DocumentUploadSshPassw | 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