Re: ERROR: invalid input syntax for type date: IS IT A BUG here?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ERROR: invalid input syntax for type date: IS IT A BUG here?
Date: 2015-08-21 22:09:04
Message-ID: 8301.1440194944@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

AI Rumman <rummandba(at)gmail(dot)com> writes:
> But when I run the following one, it gives me error:
> *SQL 2: *

>> select * as ts
>> from
>> (
>> select relname, pg_total_relation_size(relname::text) as s,
>> substr(relname,18)::date as dt from pg_stat_user_tables where schemaname =
>> 'partitions' and relname not like '%overflow' order by
>> pg_total_relation_size(relname::text) desc
>> ) as q
>> where dt = '2015-01-01'::date;
>> *ERROR: invalid input syntax for type date: ""*

I don't find that especially astonishing: there are certainly rows in
pg_stat_user_tables for which "substr(relname,18)::date" will fail.

Your first query managed to dodge that with WHERE restrictions, but here
you've added a WHERE restriction that depends on being able to evaluate
that very expression. And no, there is no guarantee about the order of
evaluation of WHERE clauses. (An OFFSET 0 in the sub-select might help
though.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-08-21 22:13:17 Re: ERROR: invalid input syntax for type date: IS IT A BUG here?
Previous Message AI Rumman 2015-08-21 21:32:01 ERROR: invalid input syntax for type date: IS IT A BUG here?