Thread: pg_user problem

pg_user problem

From
Tatsuo Ishii
Date:
Hi, please apply following patches to rewrite/rewriteManip.c.
This seems to fix the "pg_user problem." (I am not very familiar
with the rule/rewrite area, so my understanding may be wrong)
The original code sets varlevelsup even if the node is not
variable node. This assumption is not always correct, for example
with the password column of pg_user view.
Anyway, with the patch the select_view test is now ok on my LiuxPPC
box.

*** rewriteManip.c.orig    Fri Sep 11 21:24:04 1998
--- rewriteManip.c    Fri Sep 11 22:18:33 1998
***************
*** 633,639 ****
                              *nodePtr = copyObject(n);
                          else
                              *nodePtr = n;
!                         ((Var *) *nodePtr)->varlevelsup = this_varlevelsup;
                      }
                      *modified = TRUE;
                  }
--- 633,640 ----
                              *nodePtr = copyObject(n);
                          else
                              *nodePtr = n;
!                         if (nodeTag(*nodePtr) == T_Var)
!                                 ((Var *) *nodePtr)->varlevelsup = this_varlevelsup;
                      }
                      *modified = TRUE;
                  }

--
Tatsuo Ishii
t-ishii@sra.co.jp


Re: [HACKERS] pg_user problem

From
"Thomas G. Lockhart"
Date:
> Hi, please apply following patches to rewrite/rewriteManip.c.
> This seems to fix the "pg_user problem." (I am not very familiar
> with the rule/rewrite area, so my understanding may be wrong)
> The original code sets varlevelsup even if the node is not
> variable node. This assumption is not always correct, for example
> with the password column of pg_user view.
> Anyway, with the patch the select_view test is now ok on my LiuxPPC
> box.

I haven't tried it yet, but great work! That fits in with the
observation that the password column seemed to trigger the failure.

Will report on success this evening...

                    - Tom

pgrewrite: was Re: [HACKERS] pg_user problem

From
Bruce Momjian
Date:
Nice job Tatsuo.

Looks like electric fence was properly pointing to the problem.  I am
going to get electric fence working on my machine here.

I have modified your patch, and I would like Jan to confirm the fix.
Instead of only processing target list Var's, I am doing Var's as you
suggested, and non-Vars by re-calling the function to process the
non-var node.  This appears to be more in keeping with the rest of the
function.  I am committing this patch.

Let me know if you or Jan see any problems with this.

> Hi, please apply following patches to rewrite/rewriteManip.c.
> This seems to fix the "pg_user problem." (I am not very familiar
> with the rule/rewrite area, so my understanding may be wrong)
> The original code sets varlevelsup even if the node is not
> variable node. This assumption is not always correct, for example
> with the password column of pg_user view.
> Anyway, with the patch the select_view test is now ok on my LiuxPPC
> box.

Index: src/backend/rewrite/rewriteManip.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v
retrieving revision 1.17
diff -c -r1.17 rewriteManip.c
*** rewriteManip.c    1998/09/01 04:31:35    1.17
--- rewriteManip.c    1998/09/11 16:16:20
***************
*** 614,622 ****
                                                       var->varattno));
                      if (n == NULL)
                          *nodePtr = make_null(((Var *) node)->vartype);
-
                      else
!
                          /*
                           * This is a hack: The varlevelsup of the orignal
                           * variable and the new one should be the same.
--- 614,621 ----
                                                       var->varattno));
                      if (n == NULL)
                          *nodePtr = make_null(((Var *) node)->vartype);
                      else
!                     {
                          /*
                           * This is a hack: The varlevelsup of the orignal
                           * variable and the new one should be the same.
***************
*** 628,639 ****
                           * before! (Maybe this will cause troubles with
                           * some sophisticated queries on views?)
                           */
-                     {
                          if (this_varlevelsup > 0)
                              *nodePtr = copyObject(n);
                          else
                              *nodePtr = n;
!                         ((Var *) *nodePtr)->varlevelsup = this_varlevelsup;
                      }
                      *modified = TRUE;
                  }
--- 627,642 ----
                           * before! (Maybe this will cause troubles with
                           * some sophisticated queries on views?)
                           */
                          if (this_varlevelsup > 0)
                              *nodePtr = copyObject(n);
                          else
                              *nodePtr = n;
!
!                         if (nodeTag(nodePtr) == T_Var)
!                             ((Var *) *nodePtr)->varlevelsup = this_varlevelsup;
!                         else
!                             nodeHandleViewRule(&n, rtable, targetlist,
!                                            rt_index, modified, sublevels_up);
                      }
                      *modified = TRUE;
                  }


--
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)

Re: pgrewrite: was Re: [HACKERS] pg_user problem

From
t-ishii@sra.co.jp (Tatsuo Ishii)
Date:
At 0:38 PM 98.9.11 -0400, Bruce Momjian wrote:
>Nice job Tatsuo.
>
>Looks like electric fence was properly pointing to the problem.  I am
>going to get electric fence working on my machine here.
>
>I have modified your patch, and I would like Jan to confirm the fix.
>Instead of only processing target list Var's, I am doing Var's as you
>suggested, and non-Vars by re-calling the function to process the
>non-var node.  This appears to be more in keeping with the rest of the
>function.  I am committing this patch.
>
>Let me know if you or Jan see any problems with this.

Thank you for correction to my patches. I have tested your
patches on my LinuxPPC box and it works great!
--
Tatsuo Ishii
t-ishii@sra.co.jp


Re: [HACKERS] pg_user problem

From
"Thomas G. Lockhart"
Date:
> > Hi, please apply following patches to rewrite/rewriteManip.c.
> > This seems to fix the "pg_user problem."
> I haven't tried it yet
> Will report on success this evening...

Seems to have fixed the problem on my Linux/i686 machine. Great job,
Tatsuo.

Marc, I've got a small set of patches for the parser to allow more SQL92
syntax for cursors. Will put them in tomorrow so they will be in place
for a Sunday build.

                     - Tom