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 1h2KyE-0006cI-B2 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2019 19:15:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h2KyD-0002HN-1t for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Mar 2019 19:15:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2KyC-0002HD-Rk for pgsql-bugs@lists.postgresql.org; Fri, 08 Mar 2019 19:15:48 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2KyA-0008Nb-QV for pgsql-bugs@lists.postgresql.org; Fri, 08 Mar 2019 19:15:48 +0000 Received: from [192.168.127.1] (port=10538 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1h2Ky8-0002z9-Lw; Fri, 08 Mar 2019 19:15:44 +0000 Received: from [127.0.0.1] (port=20625 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1h2Ky7-000GpB-VZ; Fri, 08 Mar 2019 19:15:44 +0000 From: Andrew Gierth To: gmail Vladimir =?utf-8?Q?Kokovi=C4=87?= Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15653: pg_detoast_datum_packed problem In-Reply-To: <13b4fc8a-b790-ddec-bf02-fe99ed793a5b@gmail.com> ("gmail Vladimir \=\?utf-8\?Q\?Kokovi\=C4\=87\=22's\?\= message of "Fri, 8 Mar 2019 19:47:41 +0100") Message-ID: <87a7i5b2ok.fsf@news-spur.riddles.org.uk> References: <15653-a9979a97bd11577d@postgresql.org> <8a0d54a5-1c94-aa00-7e22-7d16566839b4@gmail.com> <13b4fc8a-b790-ddec-bf02-fe99ed793a5b@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 08 Mar 2019 19:15:43 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "gmail" =3D=3D gmail Vladimir Kokovi=C4=87 writes: gmail> =C2=A0 VarChar *arg =3D PG_GETARG_VARCHAR_PP(0); The _PP there means that this is allowed to return either a packed (short) varlena or a normal one... gmail> =C2=A0=C2=A0=C2=A0 len =3D VARSIZE( arg ) - VARHDRSZ; ...but VARSIZE is only allowed on unpacked varlenas, you need to use VARSIZE_ANY_EXHDR instead (and VARDATA_ANY rather than VARDATA). --=20 Andrew (irc:RhodiumToad)