Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A1D78B5DC4F for ; Fri, 28 Oct 2011 19:42:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 31182-04 for ; Fri, 28 Oct 2011 22:42:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from pearl.mediadesign.nl (pearl.mediadesign.nl [195.177.242.41]) by mail.postgresql.org (Postfix) with SMTP id DE053B5DC4A for ; Fri, 28 Oct 2011 19:42:28 -0300 (ADT) Received: (qmail 22500 invoked by uid 1007); 29 Oct 2011 00:42:27 +0200 Date: Sat, 29 Oct 2011 00:42:27 +0200 From: Mischa POSLAWSKY To: pgsql-bugs@postgresql.org Subject: plperl no longer provides string representations of composite values Message-ID: <20111028224227.GB4880@pearl.mediadesign.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt 1.5.20 + Vim 7.1 (Debian 5.0.9 GNU/Linux 2.6.32.25) X-URL: http://shiar.nl/ X-Accept-Language: nl, eo, en X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/295 X-Sequence-Number: 31565 Composite types are converted to and from Perl hashes since commit REL9_1_ALPHA4~146 (Convert Postgres arrays to Perl arrays on PL/perl input arguments; 2011-02-17), but are not stringified as claimed by the commit message and release notes (unless nested in an array). To illustrate: CREATE TYPE foo AS (bar INTEGER, baz TEXT); DO $$ my $val = spi_exec_query(q< SELECT ROW(42,'test')::foo AS col >)->{rows}->[0]->{col}; elog(NOTICE, "$val ".ref($val)) $$ LANGUAGE plperl; NOTICE: HASH(0xb864a744) HASH DO $$ my $val = spi_exec_query(q< SELECT ARRAY[ ROW(42,'test')::foo ] AS col >)->{rows}->[0]->{col}; elog(NOTICE, "$val ".ref($val)) $$ LANGUAGE plperl; NOTICE: {"(42,test)"} PostgreSQL::InServer::ARRAY On pg 9.0 the expected (but unblessed) strings (42,test) and {"(42,test)"} are returned respectively. To make matters worse, received values cannot be used in queries because spi_exec_prepared() simply ignores hash arguments: # DO $$ my $q = spi_prepare('SELECT $1 AS col', 'foo' ); elog(NOTICE, spi_exec_prepared($q, { bar=>42, baz=>'test' } )->{rows}->[0]->{col}) $$ LANGUAGE plperl; ERROR: spi_exec_prepared: expected 1 argument(s), 0 passed at line 1. Again except if nested in an array: # DO $$ my $q = spi_prepare('SELECT $1 AS col', 'foo[]'); elog(NOTICE, spi_exec_prepared($q, [{ bar=>42, baz=>'test' }])->{rows}->[0]->{col}) $$ LANGUAGE plperl; NOTICE: {"(42,test)"} While the intended feature would be very welcome as well, not being able to convert to text is a serious regression. Thanks and regards, -- Mischa