Re: How to extract a value from a record using attnum or attname?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Kevin Grittner <kevin(dot)grittner(at)wicourts(dot)gov>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to extract a value from a record using attnum or attname?
Date: 2011-02-23 19:48:22
Message-ID: 1298490226-sup-4369@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Excerpts from Kevin Grittner's message of mié feb 23 16:20:16 -0300 2011:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>
> > Why not use quote_identifier and quote_literal_cstr instead of
> > this new strcpy thing?
>
> We've got various types of software that will be parsing these
> payloads, and it's a little easier to parse if the quoting is
> unconditional. If that's a barrier to acceptance we could use
> the functions which quote conditionally and adjust our regular
> expressions.

No strong opinion on this, really, but your strcpy should use a
StringInfo buffer instead of the char[200]. That's going to bite
someone.

> Probably one reason we had a bias toward quoting is that every
> single application table name we use has at least on uppercase
> letter and about 95% of our column names do.

Makes sense.

> > Also, you don't really need spi.h do you?
>
> It's using these functions:
>
> SPI_getrelname
> SPI_fname
> SPI_getvalue
>
> If there's a better way to get the info, I'm game.

I think you could get away without the first two (in particular get rid
of the memleak with SPI_getrelname), but the last one would require
something more involved. No strong opinion, I just failed to see those
calls in there.

Is this intended for 9.1?

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-02-23 19:55:05 Re: Deadlock on the same select for update
Previous Message Michael Glaesemann 2011-02-23 19:40:22 Re: Data types for IP address.

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-02-23 19:48:57 Re: Binary in/out for aclitem
Previous Message Andrew Chernow 2011-02-23 19:21:08 Re: Correctly producing array literals for prepared statements