Hackers,
I've been trying to come up with a simpler way to iterate over a series of
values in pgTAP tests than by creating a table, inserting rows, and then
selecting from the table. The best I've come up with so far is:
CREATE TYPE vcmp AS ( lv semver, op text, rv semver);
SELECT cmp_ok(lv, op, rv) FROM unnest(ARRAY[
ROW('1.2.2', '=', '1.2.2')::vcmp,
ROW('1.2.23', '=', '1.2.23')::vcmp
]);
Not bad, but I was hoping that I could cast all the rows at once, without the
type, like so:
SELECT cmp_ok(lv, op, rv) FROM unnest(ARRAY[
ROW('1.2.2', '=', '1.2.2'),
ROW('1.2.23', '=', '1.2.23')
]) AS f(lv semver, op text, rv semver);
But this gives me an error (9.0b4):
psql:t/types.pg:205: ERROR: function return row and query-specified return row
do not match
DETAIL: Returned type unknown at ordinal position 1, but query expects semver.
Pity it doesn't default to casting to text there. So I tried to just cast the
first row:
SELECT cmp_ok(lv, op, rv) FROM unnest(ARRAY[
ROW('1.2.2'::semver, '='::text, '1.2.2'::semver),
ROW('1.2.23', '=', '1.2.23')
]) AS f(lv semver, op text, rv semver);
That's even worse!
psql:t/types.pg:205: ERROR: invalid memory alloc request size
18446744071604011012
Wha??
That seems like a bug.
Aside from that, might there be another way to do this without an explicit
composite type? Maybe with VALUES() or something?
Thanks,
David
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers