Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1baSTg-0004me-6J for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Aug 2016 18:55:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1baSTf-0004cx-HW for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Aug 2016 18:55:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1baSQ5-0002JC-QD for pgsql-bugs@postgresql.org; Thu, 18 Aug 2016 18:52:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1baSQ3-00012g-8s for pgsql-bugs@postgresql.org; Thu, 18 Aug 2016 18:52:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u7IIpvJR019569; Thu, 18 Aug 2016 14:51:57 -0400 From: Tom Lane 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 In-reply-to: <20160818174414.1529.37913@wrigleys.postgresql.org> References: <20160818174414.1529.37913@wrigleys.postgresql.org> Comments: In-reply-to m.overmeyer@yahoo.ca message dated "Thu, 18 Aug 2016 17:44:14 -0000" Date: Thu, 18 Aug 2016 14:51:57 -0400 Message-ID: <19568.1471546317@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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