On 2013-12-20 21:56:42 -0500, Robert Haas wrote: > On Fri, Dec 20, 2013 at 7:51 AM, Andres Freund <and...@2ndquadrant.com> wrote: > >> I wondered that, too, but it's not well-defined for all tuples. What > >> happens if you pass in constructed tuple rather than an on-disk tuple? > > > > Those should be discernible I think, t_self/t_tableOid won't be set for > > generated tuples. > > I went looking for existing precedent for code that does things like > this and found record_out, which does this:
I think there's plenty precedent for C code, but here the problem seems to be that, when we pass a record that's originally a plain row, it's coerced (via IO functions) into a record with typeid/typemod set. So, for this to work via SQL, we'd need to add a notation that allows passing table rows to functions without being modified. That might be a good idea in general, but likely more work than it's work tackling in this context. > This appears to be a typical pattern, although interestingly I noticed > that row_to_json() doesn't bother setting t_tableOid or t_self, which > I think it's supposed to do. Yes, that seems to be a minor bug. Andrew? > Am I missing a trick? No, don't think so, I wasn't thinking on the SQL level. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers