Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIWZC-0000g2-6f for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 11:25:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIWZ8-0000XL-PF for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 11:25:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIWZ8-0000Wv-BS for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 11:25:06 +0000 Received: from smh-06.1blu.de ([178.254.0.206]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iIWZ5-0008Ar-Dl for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 11:25:05 +0000 Received: from [172.16.29.5] (helo=sh4-5.1blu.de) by smh-06.1blu.de with esmtp (Exim 4.86_2) (envelope-from ) id 1iIWZ1-0005HX-2T; Thu, 10 Oct 2019 13:24:59 +0200 Received: from ftp51246-2575596 by sh4-5.1blu.de with local (Exim 4.86_2) (envelope-from ) id 1iIWZ1-0019fG-0g; Thu, 10 Oct 2019 13:24:59 +0200 Date: Thu, 10 Oct 2019 13:24:58 +0200 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: SELECT d02name::bytea FROM ... && DBI::Pg Message-ID: <20191010112458.GA271079@sh4-5.1blu.de> Reply-To: Matthias Apitz MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Operating-System: FreeBSD 12.0-CURRENT r314251 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, I can SELECT && print a column in hex with: pos71=# select d02name::bytea from d02ben where d02bnr = '00001048313' ; ... \x50c3a46461676f67697363686520486f6368736368756c65205765696e67617274656e2020 ... but when I use the same in Perl DBI::Pg with: ... $sth=$dbh->prepare( "select d02name::bytea from d02ben where d02bnr = '00001048313'"); $sth->execute or die "exec error\n".${DBI::errstr}."\n"; while ( (@row = $sth->fetchrow_array) ) { print "$row[0]\n"; } It prints the UTF-8 string and not the hex string: ./utf8-01.pl DBI is version 1.642, DBD::Pg is version 3.8.0 client_encoding=UTF8, server_encoding=UTF8 Pädagogische Hochschule Weingarten I checked with strace that the PG server delivers to DBI:Pg the hex string, so it must be converted somewhere (or in print ...) again to UTF-8. See below. Any ideas? matthias recvfrom(3, "T\0\0\0 \0\1d02name\0\0\0\0\0\0\0\0\0\0\21\377\377\377\377\377\377\0\0D\0\0\0\376\0\1\0\0\0\364\\x50c3a46461676f67697363686520486f6368736368756c65205765696e67617274656e2020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020C\0\0\0\rSELECT 1\0Z\0\0\0\5I", 16384, 0, NULL, NULL) = 308 write(1, "P\303\244dagogische Hochschule Weingarten -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub May, 9: Спаси́бо освободители! Thank you very much, Russian liberators!