Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e57FmxW72711 for ; Wed, 7 Jun 2000 11:48:59 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id LAA03915; Wed, 7 Jun 2000 11:48:38 -0400 (EDT) To: Niall Smart cc: pgsql-sql@postgresql.org Subject: Re: Problem with subquery in CHECK constraint. In-reply-to: <393E6940.E3CDD1BD@ebeon.com> References: <393E6940.E3CDD1BD@ebeon.com> Comments: In-reply-to Niall Smart message dated "Wed, 07 Jun 2000 16:24:49 +0100" Date: Wed, 07 Jun 2000 11:48:38 -0400 Message-ID: <3912.960392918@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200006/71 Niall Smart writes: > However when trying to insert into CUST I get the following error: > ERROR: ExecEvalExpr: unknown expression type 108 > Is this a bug in PostGreSQL? Yup. Looks like the subquery is not getting expanded into a subplan. Could be a little messy to fix, unless we redo the planning on every execution of the check constraint ... which doesn't sound appetizing. For now I'd suggest putting the subquery into an SQL or plpgsql function that you invoke from the constraint expression. regards, tom lane