pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #13919: Cast error when table is empty. 2+ messages / 2 participants [nested] [flat]
* BUG #13919: Cast error when table is empty. @ 2016-02-05 11:35 mail@eaden.net 2016-02-09 04:46 ` Re: BUG #13919: Cast error when table is empty. Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: mail@eaden.net @ 2016-02-05 11:35 UTC (permalink / raw) To: pgsql-bugs The following bug has been logged on the website: Bug reference: 13919 Logged by: Eaden McKee Email address: mail@eaden.net PostgreSQL version: 9.4.1 Operating system: Any Description: 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? -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #13919: Cast error when table is empty. 2016-02-05 11:35 BUG #13919: Cast error when table is empty. mail@eaden.net @ 2016-02-09 04:46 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2016-02-09 04:46 UTC (permalink / raw) To: mail@eaden.net; +Cc: pgsql-bugs mail@eaden.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-02-09 04:46 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-02-05 11:35 BUG #13919: Cast error when table is empty. mail@eaden.net 2016-02-09 04:46 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox