From: Tom Lane <tgl@sss.pgh.pa.us>
To: m.overmeyer@yahoo.ca
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
Date: Thu, 18 Aug 2016 14:51:57 -0400
Message-ID: <19568.1471546317@sss.pgh.pa.us> (raw)
In-Reply-To: <20160818174414.1529.37913@wrigleys.postgresql.org>
References: <20160818174414.1529.37913@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
m.overmeyer@yahoo.ca writes:
> I believe I may have found a bug in PL/PGSQL or dblink.
So you did. Fixed, thanks.
For the archives' sake, the test case looked like
------
create extension dblink;
create table test_table
(
username text primary key
);
INSERT INTO test_table VALUES ('test_user');
CREATE OR REPLACE FUNCTION test_assignment(primary_key_attnums int2vector)
RETURNS text AS
$BODY$
DECLARE
results text;
BEGIN
-- This doesn't work:
results := dblink_build_sql_delete('test_table', primary_key_attnums, 1, ARRAY['test_user']::text[]);
-- But this one (use value instead of parameter) does work:
--results := dblink_build_sql_delete('test_table', '1'::int2vector, 1, ARRAY['test_user']::text[]);
--And so does this one:
-- SELECT dblink_build_sql_delete('test_table', primary_key_attnums, 1, ARRAY['test_user']::text[]) INTO results;
return results;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
SELECT test_assignment('1'::int2vector);
-----
and the problem was that plpgsql thought it could convert the int2vector
argument into an "expanded array". But int2vector doesn't allow toasting
so a fortiori it can't handle being expanded.
regards, tom lane
--
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: tgl@sss.pgh.pa.us, m.overmeyer@yahoo.ca
Subject: Re: BUG #14289: Potential bug: "invalid attribute number" when dblink result is assigned in PL/PGSQL
In-Reply-To: <19568.1471546317@sss.pgh.pa.us>
References: <20160818174414.1529.37913@wrigleys.postgresql.org> <19568.1471546317@sss.pgh.pa.us>
* 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