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

Use DB-Library's dbdatecrack() and PostgreSQL's make_timestamp() to make changes to locales.conf unnecessary #28

Closed
GeoffMontee opened this issue Jun 19, 2015 · 6 comments

Comments

@GeoffMontee
Copy link
Collaborator

I don't really like the fact that users have to edit the default locales.conf to allow PostgreSQL to understand timestamp strings returned by FreeTDS.

It looks like it would be easy to use a DB-Library function like dbdatecrack() to pull out the individual parts of timestamp, date and time columns.. Then I could just use make_timestamp() and the other similar functions to build the timestamp, date, or time columns.

I should probably put this code in tdsConvertToCString().

I haven't ever tried to call PostgreSQL's SQL functions (like make_timestamp) from C code, but I think it would be worth it to learn how to do so.

This was referenced Jun 19, 2015
@GeoffMontee GeoffMontee changed the title Use DB-Libraries dbdatecrack() and PostgreSQL's make_timestamp() to make locales.conf unnecessary Use DB-Library's dbdatecrack() and PostgreSQL's make_timestamp() to make changes to locales.conf unnecessary Jun 19, 2015
@sumariva
Copy link

sumariva commented Jul 4, 2015

That would be nice.
I assume that freetds will receive the binary value from server, from 3 to 8 bytes as defined by the column type for date/time types.
Avoid conversion from text string to reduce network traffic if possible.
For larger results, maybe a prepared postgresql statement for date transformation could speed up successive row construction for the result.

GeoffMontee added a commit that referenced this issue Sep 20, 2015
…tamp() to make changes to locales.conf unnecessary
@GeoffMontee
Copy link
Collaborator Author

A special conversion has been added for SQL Server and Sybase's DATETIME type using DB-Library's dbdatecrack() and make_timestamp().

f4cab84

@GeoffMontee
Copy link
Collaborator Author

I just realized that the current implementation doesn't properly set the milliseconds value. I'll try to fix that tomorrow.

@GeoffMontee
Copy link
Collaborator Author

I added millisecond support, and fixed some other minor things.

5389eed

@GeoffMontee
Copy link
Collaborator Author

Fixed in v1.0.4.

@gavinwahl
Copy link

Can you do this for dates too? I'm getting errors like

invalid input syntax for type date: "Aug 25 2010 12:00:00:AM"

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

No branches or pull requests

3 participants