Small fix for _equalValue() - Mailing list pgsql-patches

From Fernando Nasser
Subject Small fix for _equalValue()
Date
Msg-id 3C875F42.58F73A68@redhat.com
Whole thread Raw
Responses Re: Small fix for _equalValue()
List pgsql-patches
Avoid problems when one of the pointer values is NULL (or both).

_equalVariableSetStmt() dumps core without this one.


--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9Index: src/backend/nodes/equalfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v
retrieving revision 1.114
diff -c -p -r1.114 equalfuncs.c
*** src/backend/nodes/equalfuncs.c    2002/03/06 20:34:48    1.114
--- src/backend/nodes/equalfuncs.c    2002/03/07 12:39:13
*************** _equalValue(Value *a, Value *b)
*** 1771,1777 ****
          case T_Float:
          case T_String:
          case T_BitString:
!             return strcmp(a->val.str, b->val.str) == 0;
          default:
              break;
      }
--- 1771,1780 ----
          case T_Float:
          case T_String:
          case T_BitString:
!             if ((a->val.str != NULL) && (b->val.str != NULL))
!                 return strcmp(a->val.str, b->val.str) == 0;
!             else
!                 return a->val.ival == b->val.ival;  /* true if both are NULL */
          default:
              break;
      }

pgsql-patches by date:

Previous
From: Fernando Nasser
Date:
Subject: Small fix for _copyGrantStmt
Next
From: Fernando Nasser
Date:
Subject: Small fix for _copySetConstraintsStmt