Re: sorting table columns - Mailing list pgsql-hackers

From Tom Lane
Subject Re: sorting table columns
Date
Msg-id 23156.1324430616@sss.pgh.pa.us
Whole thread Raw
In response to Re: sorting table columns  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: sorting table columns  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Excerpts from Tom Lane's message of mar dic 20 18:24:29 -0300 2011:
>> You do *not* want to store either of the latter two numbers in
>> parse-time Var nodes, because then you can't rearrange columns without
>> having to update stored rules.  But it might be useful to decree that
>> one thing setrefs.c does is renumber Vars in scan nodes to use the
>> physical column numbers instead of the permanent IDs.

> Hmm, having the numbers in Var nodes seems a fundamental part of the way
> I'm attacking the problem.  Hopefully after I give setrefs.c a read I
> will have a clearer picture of the way to do it without that.

To clarify a bit: one thing that setrefs.c already does is to renumber
Var nodes above the scan level, so that their attnums refer not to
original table column attnums but to column numbers in the output of the
next plan level down.  Vars in scan nodes currently don't need any
renumbering, but it'd be easy enough to extend the logic to do something
to them as well.  I'm visualizing the run-time transformation from
physical to logical column ordering as a sort of projection, much like
the mapping that happens in a join node.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: RangeVarGetRelid()
Next
From: "David E. Wheeler"
Date:
Subject: Re: JSON for PG 9.2