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