| From: | Richard Neill <rjn(at)richardneill(dot)org> |
|---|---|
| To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
| Cc: | Richard Neill <rn214(at)richardneill(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Richard Neill <postgresql(at)richardneill(dot)org>, pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #5867: wish: plpgsql print table for debug |
| Date: | 2011-03-03 18:35:56 |
| Message-ID: | 4D6FDF8C.1020508@richardneill.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Dear Pavel,
Thanks for your help.
>> Do you not think it would be really amazingly useful? After all, in C, the
>> single most useful debugging tool is "fprintf(stderr,...)", and yet
>> postgresql doesn't have an equivalent that can operate on the most common
>> data format. [I'm stretching the analogy a bit here, but it seems to me that
>> a multi-row table is to postgresql as int is to C.]
>
> it's nonsense - PL/pgSQL is procedural language - so there are same -
> similar types like C
Sorry - I perhaps over-stretched the analogy. What I meant was that, at
least apparently, SQL "types" include anything that can result from an
SQL statement, including an individual "record" or an entire temporary
table. I know that strictly speaking this isn't true, but it seems to me
that one should be able to do:
RAISE NOTICE (SELECT ....)
> CREATE OR REPLACE FUNCTION debug_query(text)
> RETURNS void AS $$
> DECLARE r record;
> BEGIN
> FOR r IN EXECUTE $1 LOOP
> RAISE NOTICE r;
> END;
> END;
> $$ LANGUAGE plpgsql;
Thanks for your help - but I'm afraid this doesn't actually work. psql
rejects the line "RAISE NOTICE r;"
Raise notice expects a format string and some variables, very similar to
printf(). This means that we'd have to write something like:
RAISE NOTICE ('first %, second %, third %', col1, col2, col3;
except that our debug_query function doesn't know in advance how many
columns there are, (or the types and their names).
Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Neill | 2011-03-03 18:37:33 | Re: BUG #5867: wish: plpgsql print table for debug |
| Previous Message | Tom Lane | 2011-03-03 18:32:29 | Re: BUG #5867: wish: plpgsql print table for debug |