Neil Conway <neilc@samurai.com> writes:
>         - The code for actually sorting the columns in attpos-order is
>           duplicated a few times -- this was just done for the sake of
>           convenience, I'm going to clean this up and stick it in a
>           single, shared location in the new patch.
Bruce and I were chatting about that on the phone today.  I think it
might be useful for TupleDescs to doubly index their contained attribute
rows --- that is, keep the existing array-indexed-by-attnum, but add
another pointer array indexed by attpos, containing only nondeleted
columns.  This would be easy to build, and it'd eliminate
searching/sorting for places that had access to a TupleDesc.
>         - When processing a "SELECT *", for example, the actual data
>           columns are returned in the right order, but the
>           RowDescription messages sent by libpq are not (i.e. they are
>           sent in attnum-order, not attpos).
Easy to fix given above proposal ... although actually I am not sure why
this would occur.  printtup and friends should always get a constructed
TupDesc that has no notion of deleted or renumbered columns.  This may
be a symptom of a more fundamental error somewhere.
            regards, tom lane