From: | Brendan Jurd <direvus(at)gmail(dot)com> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: row_to_array function |
Date: | 2015-06-19 01:12:14 |
Message-ID: | CADxJZo3cOJbQ0GW+Vf2SHGqKGcRA6P6G21RXodsuEkRMU5H-Pw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 2 Apr 2015 at 05:00 Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Sun, Mar 29, 2015 at 1:27 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > While I don't have a problem with hstore_to_array, I don't think that
> > row_to_array is a very good idea; it's basically encouraging people to
> > throw away SQL datatypes altogether and imagine that everything is text.
>
...
> >
> > (In any case, those who insist can get there through row_to_json, no?)
>
> You have a point. What does attached do that to_json does not do
> besides completely discard type information?
>
FWIW, I think row_to_array is nice, and I would make use of it. If you
have a record, and you want to iterate over its fields in a generic way, at
least IMO converting to a text array is an obvious thing to reach for, and
it makes for very clearly intentioned code. While it's true that you could
go through JSON or hstore to achieve much the same thing, it is a bit of a
circumlocution.
I get Tom's point that smashing to text should not be done frivolously, but
there are circumstances when it's a reasonable move. Is it possible that
it might be used unwisely? Yes, but then you could say that about pretty
much everything.
Would it alleviate your concerns at all if the function was named
row_to_text_array, to stress the fact that you are throwing away data types?
If the patch was invasive, I would probably not support it, but from what I
can see it's a pretty cheap add.
Cheers,
BJ
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-06-19 04:14:57 | Re: pg_rewind failure by file deletion in source server |
Previous Message | Eric Ridge | 2015-06-19 00:20:49 | Re: Weirdness using Executor Hooks |