Hi,

    while  writing some documentation for the rule system I found
    this little bug. Causes crashing backend.

    Please apply.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #


diff -cr rewrite.orig/rewriteHandler.c rewrite/rewriteHandler.c
*** rewrite.orig/rewriteHandler.c	Tue Oct 20 18:59:24 1998
--- rewrite/rewriteHandler.c	Tue Oct 20 18:55:19 1998
***************
*** 1789,1799 ****
  						return;
  					}
  
  					if (var->varlevelsup > 0 &&
  							nodeTag(exp) == T_Var) {
- 						exp = copyObject(exp);
  						((Var *)exp)->varlevelsup = var->varlevelsup;
! 					}
  					*nodePtr = exp;
  					*modified = TRUE;
  				}
--- 1789,1799 ----
  						return;
  					}
  
+ 					exp = copyObject(exp);
  					if (var->varlevelsup > 0 &&
  							nodeTag(exp) == T_Var) {
  						((Var *)exp)->varlevelsup = var->varlevelsup;
! 					} 
  					*nodePtr = exp;
  					*modified = TRUE;
  				}
diff -cr rewrite.orig/rewriteManip.c rewrite/rewriteManip.c
*** rewrite.orig/rewriteManip.c	Tue Oct 20 18:59:24 1998
--- rewrite/rewriteManip.c	Tue Oct 20 18:58:18 1998
***************
*** 418,431 ****
  					{
  						if (info->event == CMD_UPDATE)
  						{
! 							((Var *) node)->varno = info->current_varno;
! 							((Var *) node)->varnoold = info->current_varno;
  						}
  						else
  							*nodePtr = make_null(((Var *) node)->vartype);
  					}
  					else
! 						*nodePtr = n;
  				}
  				break;
  			}
--- 418,432 ----
  					{
  						if (info->event == CMD_UPDATE)
  						{
! 							*nodePtr = n = copyObject(node);
! 							((Var *) n)->varno = info->current_varno;
! 							((Var *) n)->varnoold = info->current_varno;
  						}
  						else
  							*nodePtr = make_null(((Var *) node)->vartype);
  					}
  					else
! 						*nodePtr = copyObject(n);
  				}
  				break;
  			}

Tue, 20 Oct 1998 19:02:17 +0200 (MET DST)
jwieck@debis.com (Jan Wieck)
Bugfix for rule system
Applied. CVS is working for me.

> Hi,
> 
>     while  writing some documentation for the rule system I found
>     this little bug. Causes crashing backend.
> 
>     Please apply.
> 
> 
> Jan
> 
> --
> 
> #======================================================================#
> # It's easier to get forgiveness for being wrong than for being right. #
> # Let's break this rule - forgive me.                                  #
> #======================================== jwieck@debis.com (Jan Wieck) #
> 
> 
> diff -cr rewrite.orig/rewriteHandler.c rewrite/rewriteHandler.c
> *** rewrite.orig/rewriteHandler.c	Tue Oct 20 18:59:24 1998
> --- rewrite/rewriteHandler.c	Tue Oct 20 18:55:19 1998
> ***************
> *** 1789,1799 ****
>   						return;
>   					}
>   
>   					if (var->varlevelsup > 0 &&
>   							nodeTag(exp) == T_Var) {
> - 						exp = copyObject(exp);
>   						((Var *)exp)->varlevelsup = var->varlevelsup;
> ! 					}
>   					*nodePtr = exp;
>   					*modified = TRUE;
>   				}
> --- 1789,1799 ----
>   						return;
>   					}
>   
> + 					exp = copyObject(exp);
>   					if (var->varlevelsup > 0 &&
>   							nodeTag(exp) == T_Var) {
>   						((Var *)exp)->varlevelsup = var->varlevelsup;
> ! 					} 
>   					*nodePtr = exp;
>   					*modified = TRUE;
>   				}
> diff -cr rewrite.orig/rewriteManip.c rewrite/rewriteManip.c
> *** rewrite.orig/rewriteManip.c	Tue Oct 20 18:59:24 1998
> --- rewrite/rewriteManip.c	Tue Oct 20 18:58:18 1998
> ***************
> *** 418,431 ****
>   					{
>   						if (info->event == CMD_UPDATE)
>   						{
> ! 							((Var *) node)->varno = info->current_varno;
> ! 							((Var *) node)->varnoold = info->current_varno;
>   						}
>   						else
>   							*nodePtr = make_null(((Var *) node)->vartype);
>   					}
>   					else
> ! 						*nodePtr = n;
>   				}
>   				break;
>   			}
> --- 418,432 ----
>   					{
>   						if (info->event == CMD_UPDATE)
>   						{
> ! 							*nodePtr = n = copyObject(node);
> ! 							((Var *) n)->varno = info->current_varno;
> ! 							((Var *) n)->varnoold = info->current_varno;
>   						}
>   						else
>   							*nodePtr = make_null(((Var *) node)->vartype);
>   					}
>   					else
> ! 						*nodePtr = copyObject(n);
>   				}
>   				break;
>   			}
> 
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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

Tue, 20 Oct 1998 13:22:30 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Bugfix for rule system