Re: Fix for tablename in targetlist - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Fix for tablename in targetlist
Date
Msg-id 200105191720.f4JHKQU26711@candle.pha.pa.us
Whole thread Raw
In response to Re: Fix for tablename in targetlist  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Fix for tablename in targetlist
List pgsql-hackers
> No; the auto-star would only happen if the thing is marked isRel.
> So it would just cover the case of "select tab from tab".  It seems
> reasonable to me --- what other possible interpretation of the meaning
> is there?
>
> I tend to agree that we should not change the code to make "select tab"
> work, on the grounds of error-proneness.

OK, here is another patch that does this:

    test=> select test from test;
     test
    ------
        1
    (1 row)

It is small to I am attaching it here.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/backend/parser/parse_target.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_target.c,v
retrieving revision 1.66
diff -c -r1.66 parse_target.c
*** src/backend/parser/parse_target.c    2001/03/22 03:59:41    1.66
--- src/backend/parser/parse_target.c    2001/05/19 17:18:11
***************
*** 154,166 ****
          }
          else
          {
!             /* Everything else but Attr */
!             p_target = lappend(p_target,
!                                transformTargetEntry(pstate,
!                                                     res->val,
!                                                     NULL,
!                                                     res->name,
!                                                     false));
          }

          targetlist = lnext(targetlist);
--- 154,183 ----
          }
          else
          {
!             Node       *rteorjoin;
!             int            sublevels_up;
!
!             if (IsA(res->val, Ident) &&
!                 (rteorjoin = refnameRangeOrJoinEntry(pstate,
!                                                 ((Ident *) res->val)->name,
!                                                 &sublevels_up)) != NULL &&
!                 IsA(rteorjoin, RangeTblEntry))
!             {
!                 /* Expand SELECT tab FROM tab; to SELECT tab.* FROM tab; */
!                 p_target = nconc(p_target,
!                             expandRelAttrs(pstate,
!                                (RangeTblEntry *) rteorjoin));
!             }
!             else
!             {
!                 /* Everything else */
!                 p_target = lappend(p_target,
!                                    transformTargetEntry(pstate,
!                                                         res->val,
!                                                         NULL,
!                                                         res->name,
!                                                         false));
!             }
          }

          targetlist = lnext(targetlist);

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: C++ Headers
Next
From: Peter Eisentraut
Date:
Subject: Re: Fix for tablename in targetlist