Re: [HACKERS] Current sources?

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Current sources?
Дата
Msg-id 199805252230.SAA22256@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Current sources?  (dg@illustra.com (David Gould))
Ответы Re: [HACKERS] Current sources?  (t-ishii@sra.co.jp)
Список pgsql-hackers
>     --------------
>
> I do not believe that this could ever have passed regression. Do we have
> the whole patch to back out, or do we need to just "fix what we have now"?
>
> Also, perhaps we need to be more selective about checkins?

Not sure.  Marc and I reviewed it, and it looked very good.  In fact, I
would like to see more of such patches, of course, without the destroydb
problem, but many patches have little quirks the author could not have
anticipated.

>     {
>         JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
>         estate->es_junkFilter = j;
> >>>>    tupType = j->jf_cleanTupType;       /*  Added by daveh@insightdist.com  5/20/98   */
>     }
>     else
>         estate->es_junkFilter = NULL;
>
> Here is my debug transcript for "drop database regression"

Here is the original patch.  I got it with the command:

$ pgcvs diff -c -D'05/21/1998 03:00:00 GMT' -D'05/21/1998 04:00:00
GMT'

pgcvs on my machines does postgresql cvs for me.

---------------------------------------------------------------------------

Index: backend/executor/execMain.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/executor/execMain.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -c -r1.45 -r1.46
*** execMain.c    1998/02/27 08:43:52    1.45
--- execMain.c    1998/05/21 03:53:50    1.46
***************
*** 26,32 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/executor/execMain.c,v 1.45 1998/02/27 08:43:52 vadim Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 26,32 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/executor/execMain.c,v 1.46 1998/05/21 03:53:50 scrappy Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 521,534 ****
       *      NOTE: in the future we might want to initialize the junk
       *      filter for all queries.
       * ----------------
       */
      if (operation == CMD_UPDATE || operation == CMD_DELETE ||
!         operation == CMD_INSERT)
      {
-
          JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
-
          estate->es_junkFilter = j;
      }
      else
          estate->es_junkFilter = NULL;
--- 521,536 ----
       *      NOTE: in the future we might want to initialize the junk
       *      filter for all queries.
       * ----------------
+      *        SELECT added by daveh@insightdist.com  5/20/98 to allow
+      *        ORDER/GROUP BY have an identifier missing from the target.
       */
      if (operation == CMD_UPDATE || operation == CMD_DELETE ||
!         operation == CMD_INSERT || operation == CMD_SELECT)
      {
          JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
          estate->es_junkFilter = j;
+
+         tupType = j->jf_cleanTupType;       /*  Added by daveh@insightdist.com  5/20/98   */
      }
      else
          estate->es_junkFilter = NULL;
Index: backend/parser/parse_clause.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/parser/parse_clause.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -c -r1.15 -r1.16
*** parse_clause.c    1998/03/31 04:43:53    1.15
--- parse_clause.c    1998/05/21 03:53:50    1.16
***************
*** 7,13 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.15 1998/03/31 04:43:53 momjian Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 7,13 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.16 1998/05/21 03:53:50 scrappy Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 182,187 ****
--- 182,218 ----
              }
          }
      }
+
+     /*    BEGIN add missing target entry hack.
+      *
+      *    Prior to this hack, this function returned NIL if no target_result.
+      *    Thus, ORDER/GROUP BY required the attributes be in the target list.
+      *    Now it constructs a new target entry which is appended to the end of
+      *    the target list.   This target is set to be  resjunk = TRUE so that
+      *    it will not be projected into the final tuple.
+      *          daveh@insightdist.com    5/20/98
+      */
+     if ( ! target_result)  {
+         List   *p_target = tlist;
+         Ident *missingTargetId = (Ident *)makeNode(Ident);
+         TargetEntry *tent = makeNode(TargetEntry);
+
+         /*   Fill in the constructed Ident node   */
+         missingTargetId->type = T_Ident;
+         missingTargetId->name = palloc(strlen(sortgroupby->name) + 1);
+         strcpy(missingTargetId->name, sortgroupby->name);
+
+         transformTargetId(pstate, missingTargetId, tent, missingTargetId->name, TRUE);
+
+         /* Add to the end of the target list */
+         while (lnext(p_target) != NIL)  {
+             p_target = lnext(p_target);
+         }
+         lnext(p_target) = lcons(tent, NIL);
+         target_result = tent;
+     }
+     /*    END add missing target entry hack.   */
+
      return target_result;
  }

***************
*** 203,212 ****
          Resdom       *resdom;

          restarget = find_targetlist_entry(pstate, lfirst(grouplist), targetlist);
-
-         if (restarget == NULL)
-             elog(ERROR, "The field being grouped by must appear in the target list");
-
          grpcl->entry = restarget;
          resdom = restarget->resdom;
          grpcl->grpOpoid = oprid(oper("<",
--- 234,239 ----
***************
*** 262,270 ****


          restarget = find_targetlist_entry(pstate, sortby, targetlist);
-         if (restarget == NULL)
-             elog(ERROR, "The field being ordered by must appear in the target list");
-
          sortcl->resdom = resdom = restarget->resdom;
          sortcl->opoid = oprid(oper(sortby->useOp,
                                     resdom->restype,
--- 289,294 ----
Index: backend/parser/parse_target.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/parser/parse_target.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -c -r1.12 -r1.13
*** parse_target.c    1998/05/09 23:29:54    1.12
--- parse_target.c    1998/05/21 03:53:51    1.13
***************
*** 7,13 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.12 1998/05/09 23:29:54 thomas Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 7,13 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.13 1998/05/21 03:53:51 scrappy Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 52,57 ****
--- 52,102 ----
                     Oid type_id,
                     Oid attrtype);

+
+ /*
+  *   transformTargetId - transforms an Ident Node to a Target Entry
+  *   Created this a function to allow the ORDER/GROUP BY clause be able
+  *   to construct a TargetEntry from an Ident.
+  *
+  *   resjunk = TRUE will hide the target entry in the final result tuple.
+  *        daveh@insightdist.com     5/20/98
+  */
+ void
+ transformTargetId(ParseState *pstate,
+                 Ident *ident,
+                 TargetEntry *tent,
+                 char *resname,
+                 int16 resjunk)
+ {
+     Node   *expr;
+     Oid    type_id;
+     int16    type_mod;
+
+     /*
+      * here we want to look for column names only, not
+      * relation names (even though they can be stored in
+      * Ident nodes, too)
+      */
+     expr = transformIdent(pstate, (Node *) ident, EXPR_COLUMN_FIRST);
+     type_id = exprType(expr);
+     if (nodeTag(expr) == T_Var)
+         type_mod = ((Var *) expr)->vartypmod;
+     else
+         type_mod = -1;
+     tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
+                               (Oid) type_id,
+                               type_mod,
+                               resname,
+                               (Index) 0,
+                               (Oid) 0,
+                               resjunk);
+
+     tent->expr = expr;
+     return;
+ }
+
+
+
  /*
   * transformTargetList -
   *      turns a list of ResTarget's into a list of TargetEntry's
***************
*** 71,106 ****
          {
              case T_Ident:
                  {
-                     Node       *expr;
-                     Oid            type_id;
-                     int16        type_mod;
                      char       *identname;
                      char       *resname;

                      identname = ((Ident *) res->val)->name;
                      handleTargetColname(pstate, &res->name, NULL, identname);
-
-                     /*
-                      * here we want to look for column names only, not
-                      * relation names (even though they can be stored in
-                      * Ident nodes, too)
-                      */
-                     expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST);
-                     type_id = exprType(expr);
-                     if (nodeTag(expr) == T_Var)
-                         type_mod = ((Var *) expr)->vartypmod;
-                     else
-                         type_mod = -1;
                      resname = (res->name) ? res->name : identname;
!                     tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
!                                               (Oid) type_id,
!                                               type_mod,
!                                               resname,
!                                               (Index) 0,
!                                               (Oid) 0,
!                                               0);
!
!                     tent->expr = expr;
                      break;
                  }
              case T_ParamNo:
--- 116,128 ----
          {
              case T_Ident:
                  {
                      char       *identname;
                      char       *resname;

                      identname = ((Ident *) res->val)->name;
                      handleTargetColname(pstate, &res->name, NULL, identname);
                      resname = (res->name) ? res->name : identname;
!                     transformTargetId(pstate, (Ident*)res->val, tent, resname, FALSE);
                      break;
                  }
              case T_ParamNo:
Index: include/parser/parse_target.h
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/include/parser/parse_target.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** parse_target.h    1998/02/26 04:42:49    1.4
--- parse_target.h    1998/05/21 03:53:51    1.5
***************
*** 6,12 ****
   *
   * Copyright (c) 1994, Regents of the University of California
   *
!  * $Id: parse_target.h,v 1.4 1998/02/26 04:42:49 momjian Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 6,12 ----
   *
   * Copyright (c) 1994, Regents of the University of California
   *
!  * $Id: parse_target.h,v 1.5 1998/05/21 03:53:51 scrappy Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 24,28 ****
--- 24,30 ----

  extern List *transformTargetList(ParseState *pstate, List *targetlist);
  extern List *makeTargetNames(ParseState *pstate, List *cols);
+ extern void transformTargetId(ParseState *pstate, Ident *ident,
+     TargetEntry *tent, char *resname, int16 resjunk);

  #endif                            /* PARSE_TARGET_H */

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

В списке pgsql-hackers по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] Current sources?
Следующее
От: Ryan Kirkpatrick
Дата:
Сообщение: Linux/Alpha.... Progress...