From: m.overmeyer@yahoo.ca
To: pgsql-bugs@postgresql.org
Subject: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
Date: Thu, 18 Aug 2016 17:44:14 +0000
Message-ID: <20160818174414.1529.37913@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14289
Logged by: Michael Overmeyer
Email address: m.overmeyer@yahoo.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 occur if I do not pass the int2vector as a parameter, nor when
I use the SELECT...INTO syntax.
Steps to reproduce:
1. Download
https://gist.githubusercontent.com/movermeyer/cdc9c997744d97a5cf9471837dff6b4a/raw/b4e7f338834ed35a8...
to "pg_bug.sql"
1. Start a Postgres instance: `docker run -i -t --rm=true -e
POSTGRES_PASSWORD=postgres -p 5432:5432 postgres`
2. Run pg_bug.sql: `PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p
5432 -f pg_bug.sql`
Sample output:
CREATE DATABASE
You are now connected to database "test_db" as user "postgres".
CREATE EXTENSION
CREATE TABLE
INSERT 0 1
CREATE FUNCTION
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
Workaround:
Use the SELECT...INTO syntax instead.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: m.overmeyer@yahoo.ca
Subject: Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
In-Reply-To: <20160818174414.1529.37913@wrigleys.postgresql.org>
References: <20160818174414.1529.37913@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox