column "b" is of type X but expression is of type text

From: Benedikt Grundmann <bgrundmann(at)janestreet(dot)com>
To: PostgreSQL-Dev <pgsql-hackers(at)postgresql(dot)org>
Subject: column "b" is of type X but expression is of type text
Date: 2013-07-12 13:47:38
Message-ID: CADbMkNMxET90HZ+bgq7hw8tx90szrAAi017cSX-b5XDdHrmKwQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

A third party application we use generates SQL queries. Here is query it
generated that broke today and for which I have a hard time arguing that
the postgres behavior is correct (minimally the error message is confusing):

=# create temporary table foo (b double precision );
CREATE TABLE
Time: 40.368 ms
=# insert into foo select min(NULL);
ERROR: column "b" is of type double precision but expression is of type
text
LINE 1: insert into foo select min(NULL);
^
HINT: You will need to rewrite or cast the expression.

So why does min(NULL) have type text? According to the docs it has the
type of the input. The value is itself NULL which is a valid member of all
types in SQL isn't it?

So what is going on?

Thanks,

Bene

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Johnston 2013-07-12 14:17:18 Re: column "b" is of type X but expression is of type text
Previous Message Amit kapila 2013-07-12 13:15:40 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])