What is the name pseudo column

Поиск
Список
Период
Сортировка
Искать

What is the name pseudo column

От:
Jack Christensen <jackc@hylesanderson.edu>
Дата:
I was just surprised when accidentally selecting a non-existent name 
column there was no error -- instead something came back.

select accounts.name from accounts limit 1 -> 
(1,65522,1,0.00,,"2010-07-22 09:57:26.281172-05",2)

It appears it tries to return the entire row in an array (but longer 
rows get truncated).

I've searched Google and the PG docs but I haven't had any luck.

-- 
Jack Christensen
jackc@hylesanderson.edu

Re: What is the name pseudo column

От:
David Fetter <david@fetter.org>
Дата:
On Wed, Dec 15, 2010 at 01:50:54PM -0600, Jack Christensen wrote:
> I was just surprised when accidentally selecting a non-existent name
> column there was no error -- instead something came back.
> 
> select accounts.name from accounts limit 1 ->
> (1,65522,1,0.00,,"2010-07-22 09:57:26.281172-05",2)
> 
> It appears it tries to return the entire row in an array (but longer
> rows get truncated).
> 
> I've searched Google and the PG docs but I haven't had any luck.

What happened here is that you ran into PostgreSQL's "charming" habit
of using the argument.function notation, so you called the "name"
function, i.e. the one that casts to name, on the entire row from your
accounts table.

Cheers,
David.
-- 
David Fetter  http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Re: What is the name pseudo column

От:
Adrian Klaver <adrian.klaver@gmail.com>
Дата:
On Wednesday 15 December 2010 1:27:19 pm David Fetter wrote:
> On Wed, Dec 15, 2010 at 01:50:54PM -0600, Jack Christensen wrote:
> > I was just surprised when accidentally selecting a non-existent name
> > column there was no error -- instead something came back.
> >
> > select accounts.name from accounts limit 1 ->
> > (1,65522,1,0.00,,"2010-07-22 09:57:26.281172-05",2)
> >
> > It appears it tries to return the entire row in an array (but longer
> > rows get truncated).
> >
> > I've searched Google and the PG docs but I haven't had any luck.
>
> What happened here is that you ran into PostgreSQL's "charming" habit
> of using the argument.function notation, so you called the "name"
> function, i.e. the one that casts to name, on the entire row from your
> accounts table.
>
> Cheers,
> David.
>

In the for what is worth department that behavior is going away in 9.1. See here 
for a detailed explanation:
http://www.depesz.com/index.php/2010/11/08/waiting-for-9-1-removed-autocast-footgun/#more-1908
-- 
Adrian Klaver
adrian.klaver@gmail.com

Re: What is the name pseudo column

От:
David Fetter <david@fetter.org>
Дата:
On Wed, Dec 15, 2010 at 03:43:45PM -0800, Adrian Klaver wrote:
> On Wednesday 15 December 2010 1:27:19 pm David Fetter wrote:
> > On Wed, Dec 15, 2010 at 01:50:54PM -0600, Jack Christensen wrote:
> > > I was just surprised when accidentally selecting a non-existent name
> > > column there was no error -- instead something came back.
> > >
> > > select accounts.name from accounts limit 1 ->
> > > (1,65522,1,0.00,,"2010-07-22 09:57:26.281172-05",2)
> > >
> > > It appears it tries to return the entire row in an array (but longer
> > > rows get truncated).
> > >
> > > I've searched Google and the PG docs but I haven't had any luck.
> >
> > What happened here is that you ran into PostgreSQL's "charming" habit
> > of using the argument.function notation, so you called the "name"
> > function, i.e. the one that casts to name, on the entire row from your
> > accounts table.
> >
> > Cheers,
> > David.
> >
> 
> In the for what is worth department that behavior is going away in 9.1. See here 
> for a detailed explanation:
> http://www.depesz.com/index.php/2010/11/08/waiting-for-9-1-removed-autocast-footgun/#more-1908

I'd missed this bit of good news :)

Cheers,
David.
-- 
David Fetter  http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Re: What is the name pseudo column

От:
Jack Christensen <jackc@hylesanderson.edu>
Дата:
On 12/15/2010 5:43 PM, Adrian Klaver wrote:
> On Wednesday 15 December 2010 1:27:19 pm David Fetter wrote:
>> On Wed, Dec 15, 2010 at 01:50:54PM -0600, Jack Christensen wrote:
>>> I was just surprised when accidentally selecting a non-existent name
>>> column there was no error -- instead something came back.
>>>
>>> select accounts.name from accounts limit 1 ->
>>> (1,65522,1,0.00,,"2010-07-22 09:57:26.281172-05",2)
>>>
>>> It appears it tries to return the entire row in an array (but longer
>>> rows get truncated).
>>>
>>> I've searched Google and the PG docs but I haven't had any luck.
>> What happened here is that you ran into PostgreSQL's "charming" habit
>> of using the argument.function notation, so you called the "name"
>> function, i.e. the one that casts to name, on the entire row from your
>> accounts table.
>>
>> Cheers,
>> David.
>>
> In the for what is worth department that behavior is going away in 9.1. See here
> for a detailed explanation:
> http://www.depesz.com/index.php/2010/11/08/waiting-for-9-1-removed-autocast-footgun/#more-1908
It makes sense now what's happening -- but glad to see that "feature" is 
going away.

Thanks.

-- 
Jack Christensen
jackc@hylesanderson.edu

FAQ