Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASTing a DATE literal without time part to TIME datatype fails #125

Open
wants to merge 1 commit into
base: BABEL_3_X_DEV__PG_15_X
Choose a base branch
from

Conversation

bsatarupa
Copy link
Contributor

@bsatarupa bsatarupa commented Apr 10, 2023

Description

For time datatype PG considers only date value(ex.- '2012-02-23') as bad i/p format. so, above testcase is throwing error from engine code time_in() much before coming to TDS side.

However, SQL Server allows casting a date literal string to a TIME datatype when the time component in the string is missing: o/p becomes 00:00:00.0000000

Fix is to add change in time_in() so that it considers date format with missing time info like above one, as valid input when the dialect is TSQL.

Task: BABEL-1528
Signed-off-by: Satarupa Biswas [email protected]

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

For time datatype PG considers only date value(ex.- '2012-02-23') as bad i/p format. so, above testcase is throwing error from engine code time_in() much before coming to TDS side.

However, SQL Server allows casting a date literal string to a TIME datatype when the time component in the string is missing: o/p becomes 00:00:00.0000000

Fix is to add change in time_in() so that it considers date format with missing time info like above one, as valid input when the dialect is TSQL.

Task: BABEL-1528
Signed-off-by: Satarupa Biswas [email protected]
* instead of marking it as invalid time format
*/
else if (sql_dialect == SQL_DIALECT_TSQL && nf == 1 && ftype[nf - 1] == DTK_DATE)
return 0;
/* otherwise, this is a time and/or time zone */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nf = numField (parsed and calculated based on delimiter ' ' and . in any input date)
Ex.
'08-04-1978 13:56:32.125431' has nf count = 3 (08-04-1978, 13:56:32, 125431)
'08-04-1978 13:56:32' has nf count = 2 (08-04-1978, 13:56:32)
'08-04-1978' has nf count = 1 (08-04-1978)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant