Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id ECCDCB5D90E for ; Mon, 23 May 2011 17:59:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 38079-09 for ; Mon, 23 May 2011 20:59:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.endcrypt.com (mail.endcrypt.com [74.205.105.202]) by mail.postgresql.org (Postfix) with ESMTP id B0FE5B5D8BD for ; Mon, 23 May 2011 17:59:34 -0300 (ADT) Received: from core.home (pool-96-227-80-201.phlapa.fios.verizon.net [96.227.80.201]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.endcrypt.com (Postfix) with ESMTP id E1CF831C13; Mon, 23 May 2011 20:59:33 +0000 (UTC) Date: Mon, 23 May 2011 16:59:32 -0400 From: Greg Sabino Mullane To: pgsql-bugs@postgresql.org Subject: 9.1 plperlu bug with null rows in trigger hash Message-ID: <20110523205931.GM4253@core.home> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-ripemd160; protocol="application/pgp-signature"; boundary="tDYGg60iReQ7u8wj" Content-Disposition: inline X-PGP-Key: http://www.gtsm.com/Greg_Sabino_Mullane.key.html User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/169 X-Sequence-Number: 30308 --tDYGg60iReQ7u8wj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've not been able to duplicate this in a standalone script yet,=20 but in the guts of Bucardo is a trigger function called validate_goat()=20 that is giving this error on 9.1 HEAD, but not on previous versions: "Failed to add table "public.pgbench_tellers": DBD::Pg::st execute=20 failed: ERROR: Modification of non-creatable hash value attempted,=20 subscript "pkey" at line 4." I was able to simplify the function to just this and still produce=20 the error: CREATE OR REPLACE FUNCTION bucardo.validate_goat() RETURNS TRIGGER LANGUAGE plperlu AS $bc$ my $new =3D $_TD->{new}; $new->{pkey} =3D 'foobar'; return 'MODIFY'; $bc$; It's used like this: CREATE TRIGGER validate_goat BEFORE INSERT OR UPDATE ON bucardo.goat FOR EACH ROW EXECUTE PROCEDURE bucardo.validate_goat(); The goat table has many text fields, of which one is=20 pkey. Setting it to any of those other columns will cause the error.=20 However, setting it to a text field that is NOT NULL DEFAULT will=20 *not* produce the error, so obviously something is setting=20 $_TD->{new}{somecol} to undef in the wrong way. I'm baffled as=20 to why I cannot reproduce it standalone, but wanted to get the=20 bug out there so I don't forget about it and in case anyone=20 wants to take a swing at it. Some Googling suggests it might=20 be because we are using &PL_sv_undef instead of a proper=20 newSV(0). --=20 Greg Sabino Mullane greg@endpoint.com End Point Corporation PGP Key: 0x14964AC8 --tDYGg60iReQ7u8wj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- iEYEAREDAAYFAk3ayrMACgkQvJuQZxSWSsg9jwCeN2qElDn5K5Eey8aEjGO33I73 CVAAniyBM/Hv4gTlzT8ZrnqFkSBn6BcA =IS3P -----END PGP SIGNATURE----- --tDYGg60iReQ7u8wj--