Re: [HACKERS] IS OF - Mailing list pgsql-patches

From Joe Conway
Subject Re: [HACKERS] IS OF
Date
Msg-id 3F341837.70203@joeconway.com
Whole thread Raw
In response to Re: [HACKERS] IS OF  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: [HACKERS] IS OF
Re: [HACKERS] IS OF
List pgsql-patches
Peter Eisentraut wrote:
> I suggest I should not be documented until it's fixed.
>
>>Doc patch attached for IS OF. Please apply.
>
> That is not the right place for it.  IS OF is an operator, not an SQL
> command.
>

OK. If the attached patch is acceptable/applied, I'll fix and resend the
doc patch.

Joe
Index: src/backend/parser/parse_expr.c
===================================================================
RCS file: /opt/src/cvs/pgsql-server/src/backend/parser/parse_expr.c,v
retrieving revision 1.160
diff -c -r1.160 parse_expr.c
*** src/backend/parser/parse_expr.c    4 Aug 2003 02:40:01 -0000    1.160
--- src/backend/parser/parse_expr.c    8 Aug 2003 21:53:25 -0000
***************
*** 45,51 ****
  static Node *transformColumnRef(ParseState *pstate, ColumnRef *cref);
  static Node *transformIndirection(ParseState *pstate, Node *basenode,
                       List *indirection);
!

  /*
   * Initialize for parsing a new query.
--- 44,50 ----
  static Node *transformColumnRef(ParseState *pstate, ColumnRef *cref);
  static Node *transformIndirection(ParseState *pstate, Node *basenode,
                       List *indirection);
! static bool exprIsNullConstantTypeCast(Node *arg);

  /*
   * Initialize for parsing a new query.
***************
*** 394,421 ****
                              Node       *lexpr = transformExpr(pstate,
                                                                a->lexpr);

-                             ltype = exprType(lexpr);
-                             foreach(telem, (List *) a->rexpr)
-                             {
-                                 rtype = LookupTypeName(lfirst(telem));
-                                 matched = (rtype == ltype);
-                                 if (matched)
-                                     break;
-                             }
-
-                             /*
-                              * Expect two forms: equals or not equals.
-                              * Flip the sense of the result for not
-                              * equals.
-                              */
-                             if (strcmp(strVal(lfirst(a->name)), "!=") == 0)
-                                 matched = (!matched);
-
                              n = makeNode(A_Const);
                              n->val.type = T_String;
-                             n->val.val.str = (matched ? "t" : "f");
                              n->typename = SystemTypeName("bool");

                              result = transformExpr(pstate, (Node *) n);
                          }
                          break;
--- 393,426 ----
                              Node       *lexpr = transformExpr(pstate,
                                                                a->lexpr);

                              n = makeNode(A_Const);
                              n->val.type = T_String;
                              n->typename = SystemTypeName("bool");

+                             if (exprIsNullConstantTypeCast(a->lexpr))
+                                 n->val.val.str = "f";
+                             else
+                             {
+                                 ltype = exprType(lexpr);
+                                 foreach(telem, (List *) a->rexpr)
+                                 {
+                                     rtype = LookupTypeName(lfirst(telem));
+                                     matched = (rtype == ltype);
+                                     if (matched)
+                                         break;
+                                 }
+
+                                 /*
+                                  * Expect two forms: equals or not equals.
+                                  * Flip the sense of the result for not
+                                  * equals.
+                                  */
+                                 if (strcmp(strVal(lfirst(a->name)), "!=") == 0)
+                                     matched = (!matched);
+
+                                 n->val.val.str = (matched ? "t" : "f");
+                             }
+
                              result = transformExpr(pstate, (Node *) n);
                          }
                          break;
***************
*** 1567,1570 ****
--- 1572,1588 ----
                          format_type_be(targetType))));

      return expr;
+ }
+
+
+ /* exprIsNullConstantTypeCast()
+  * Recursively test whether an a_expr is a typecast NULL constant or not.
+  */
+ static bool
+ exprIsNullConstantTypeCast(Node *arg)
+ {
+     if (arg && IsA(arg, TypeCast))
+         return exprIsNullConstantTypeCast(((TypeCast *) arg)->arg);
+
+     return exprIsNullConstant(arg);
  }

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: libpg sv.po
Next
From: Euler Taveira de Oliveira
Date:
Subject: Translation to Brazilian Portuguese