From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | mail(at)eaden(dot)net |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #13919: Cast error when table is empty. |
Date: | 2016-02-09 04:46:38 |
Message-ID: | 20633.1454993198@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
mail(at)eaden(dot)net writes:
> When trying to change the type of column I received the error :
> PG::DatatypeMismatch: ERROR: column "date_of_birth" cannot be cast
> automatically to type date
> HINT: Specify a USING expression to perform the conversion.
> I totally understand the error. However, there are no rows in the table, so
> it IS possible to automatically to cast 0 strings into 0 dates.
> If there are no rows, can the column type just be changed?
I do not see a good reason to create a special case for this. If there's
no data in the table, and you don't feel like creating a fully valid
ALTER command, why don't you just drop and recreate the table? Or for
that matter you could just make up some useless USING expression,
say USING NULL::date.
(Also, I believe we apply the USING expression to the column's default
value, and also to indexes if any, so "there are no rows" is far from
a complete statement of the restrictions that would have to apply before
ignoring the lack of a datatype transform could work.)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2016-02-09 05:24:52 | Re: Re: BUG #13685: Archiving while idle every archive_timeout with wal_level hot_standby |
Previous Message | Tom Lane | 2016-02-09 04:17:52 | Re: BUG #13918: Simple query with Having clause returns incorrect results |