Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 6303B650123 for ; Wed, 20 Aug 2008 09:55:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48145-02 for ; Wed, 20 Aug 2008 09:54:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 966DC65010B for ; Wed, 20 Aug 2008 09:54:27 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m7KCsOO9027258; Wed, 20 Aug 2008 08:54:24 -0400 (EDT) To: Sergey Hripchenko cc: "pgsql-performance@postgresql.org" Subject: Re: pgsql do not handle NULL constants in the view In-reply-to: <99EB298E5D3A2C46BD744630B3FD093E9515D604B7@EXVMBX-1.intermedia-inc.net> References: <99EB298E5D3A2C46BD744630B3FD093E9515D604B7@EXVMBX-1.intermedia-inc.net> Comments: In-reply-to Sergey Hripchenko message dated "Wed, 20 Aug 2008 02:17:24 -0700" Date: Wed, 20 Aug 2008 08:54:24 -0400 Message-ID: <27257.1219236864@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/215 X-Sequence-Number: 31096 Sergey Hripchenko writes: > CREATE OR REPLACE VIEW bar AS > SELECT * > FROM ( > ( > SELECT calldate, duration, billsec, get_asterisk_cdr_caller_id(accountcode) AS caller_id > FROM asterisk_cdr > ) UNION ALL ( > SELECT start_time, get_interval_seconds(completed_time-start_time), get_interval_seconds(answered_time-start_time), NULL > FROM asterisk_huntgroups_calls > ) > ) AS foo; Try casting the NULL to integer (or whatever the datatype of the other union arm is) explicitly. regards, tom lane