Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C29847731D for ; Thu, 7 Nov 2002 14:51:49 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 5230E477583 for ; Thu, 7 Nov 2002 14:35:56 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8A70DD613; Thu, 7 Nov 2002 11:35:56 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 801D55C03; Thu, 7 Nov 2002 11:35:56 -0800 (PST) Date: Thu, 7 Nov 2002 11:35:56 -0800 (PST) From: Stephan Szabo To: Tom Lane Cc: Ludwig Lim , PostgreSQL Mailing List Subject: Re: Weird NULL behavior In-Reply-To: <28164.1036696164@sss.pgh.pa.us> Message-ID: <20021107113216.S99207-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/118 X-Sequence-Number: 10260 On Thu, 7 Nov 2002, Tom Lane wrote: > Stephan Szabo writes: > > On Thu, 7 Nov 2002, Ludwig Lim wrote: > >> SELECT CAST ( (NULL*NULL) AS NUMERIC(2,0)); > >> Cannot cast type '"char"' to '"numeric"' > > > It seems to me that it's trying to decide on a type > > for the expression NULL * NULL. It's a NULL, but a > > NULL of what type? > > Yeah, and it's picking "char" (the single-byte datatype), because > (a) the NULLs are initially regarded as type UNKNOWN, and (b) if we > don't have any other way to make a decision we try assuming that > UNKNOWNs are of string category, and (c) the only datatype in string > category that has a "*" operator is "char". > > I am kind of inclined to remove the arithmetic operators on "char" > (+,-,*,/) in 7.4 --- they don't seem to have any real-world uses, > and as this example illustrates, they are perfectly positioned to > capture cases that probably ought to be errors. That seems to make sense. I assume that they were there so that someone could treat it as a 1 byte integer?