Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL

From: Joe Conway <mail(at)joeconway(dot)com>
To: m(dot)overmeyer(at)yahoo(dot)ca, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
Date: 2016-08-18 18:25:27
Message-ID: ac370d6f-19eb-19b5-84a8-acc4f88546c6@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 08/18/2016 01:44 PM, m(dot)overmeyer(at)yahoo(dot)ca wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14289
> Logged by: Michael Overmeyer
> Email address: m(dot)overmeyer(at)yahoo(dot)ca
> PostgreSQL version: 9.5.4
> Operating system: CentOS 7, also Docker
> Description:
>
> I believe I may have found a bug in PL/PGSQL or dblink. When using the
> assignment operator to assign the results of dblink_build_sql_delete to a
> variable, it gives me:
>
> psql:pg_bug.sql:37: ERROR: 22023: invalid attribute number -1598
> CONTEXT: PL/pgSQL function test_assignment(int2vector) line 6 at
> assignment
> LOCATION: validate_pkattnums, dblink.c:2851

This does not have anything specific to do with dblink -- but it does
seem to be specific to plpgsql. Here is a minimal test case:

SELECT version();
version
--------------------------------------------------------------------
PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
(1 row)

CREATE OR REPLACE FUNCTION test_int2vector(pka int2vector)
RETURNS int2vector AS $$
BEGIN
return pka;
END;
$$ LANGUAGE plpgsql;

SELECT test_int2vector('1'::int2vector);
-- garbage result

CREATE OR REPLACE FUNCTION test_int2v(pka int2vector)
RETURNS int2vector AS
$$ select pka $$ LANGUAGE sql;

SELECT test_int2v('1'::int2vector);
-- works fine

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-08-18 18:51:57 Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
Previous Message m.overmeyer 2016-08-18 17:44:14 BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL