Re: Domains and Casting - Mailing list pgsql-hackers

From Rod Taylor
Subject Re: Domains and Casting
Date
Msg-id 02b801c2172c$637d9690$fe01a8c0@jester
Whole thread Raw
In response to Domains and Casting  ("Rod Taylor" <rbt@zort.ca>)
List pgsql-hackers
Erm... I suppose I didn't really intend to bring up domains at all.
I'm just playing trying to figure out how things work (easiest by
breaking them I think).

I don't understand why the below patch has such an adverse affect on
the system.
Causes:
     (p2.pronargs != 3 OR p2.proretset OR p2.proargtypes[2] !=
'int4'::regtype);
! ERROR:  Invalid type name 'int4'

or
     (p2.oprkind != 'b' OR p2.oprresult != 'bool'::regtype OR
! ERROR:  Invalid type name 'bool'



Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.314
diff -c -r2.314 gram.y
*** src/backend/parser/gram.y 2002/05/12 20:10:04 2.314
--- src/backend/parser/gram.y 2002/06/19 00:54:44
***************
*** 6424,6442 ****   * (We don't want to collapse x::type1::type2 into just x::type2.)   * Otherwise, generate a
TypeCastnode.   */
 
!  if (IsA(arg, A_Const) &&
!   ((A_Const *) arg)->typename == NULL)
!  {
!   ((A_Const *) arg)->typename = typename;
!   return arg;
!  }
!  else
!  {   TypeCast *n = makeNode(TypeCast);   n->arg = arg;   n->typename = typename;   return (Node *) n;
!  } }
 static Node *
--- 6424,6442 ----   * (We don't want to collapse x::type1::type2 into just x::type2.)   * Otherwise, generate a
TypeCastnode.   */
 
! // if (IsA(arg, A_Const) &&
! //  ((A_Const *) arg)->typename == NULL)
! // {
! //  ((A_Const *) arg)->typename = typename;
! //  return arg;
! // }
! // else
! // {   TypeCast *n = makeNode(TypeCast);   n->arg = arg;   n->typename = typename;   return (Node *) n;
! // } }
 static Node *
--
Rod
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Rod Taylor" <rbt@zort.ca>
Cc: "Hackers List" <pgsql-hackers@postgresql.org>
Sent: Tuesday, June 18, 2002 10:58 AM
Subject: Re: [HACKERS] Domains and Casting


> "Rod Taylor" <rbt@zort.ca> writes:
> > This appears to be due to makeTypeCast() in gram.y which bypasses
> > creating a TypeCast node for simple A_Const.
>
> My immediate reaction is that you've probably put the testing of
> domain constraints in the wrong place.  You didn't say exactly
> what your implementation looked like though ...
>
> regards, tom lane
>



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: [SQL] date_part
Next
From: Joe Conway
Date:
Subject: Re: [Fwd: [PATCHES] contrib/showguc (was Re: revised sample