-
Notifications
You must be signed in to change notification settings - Fork 8
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
datetime2 column width #5
Comments
Hmm, on further investigation it may not be quite so straightforward to fix as it appears sqsh does understand the Newer FreeTDS releases may have a decimicrosecond field; so let me see if I can build sqsh against that. |
Haven’t looked at the code in a long time, but I think dsp_datetime_strip is responsible and is used in dsp_conv.c. I’d give it a try. Perhaps try patching line 455 and 461 there first. I’m reluctant to change the default code for the precision of CS_BIGDATETIME_TYPE, but would consider an env var to specify it, similar to the way length and precision are configurable for floats. Would that meet your requirements? |
I think it depends what else But if sqsh knows it is definitely fetching the Microsoft If there isn't a way for sqsh to know the real precision of the database type, or you're adamant that the default should stay at 6 decimal places, then I think setting the format string will be better than an environment variable. If |
It appears that current stable FreeTDS (1.4.10) does not pass through the higher precision to the
Note that I think if sqsh took account of |
Sounds good. I think that this would need changes to dsp_datetime_conv and dsp_datetime_len. IIRC this would still need you to set the datetime variable or the default server conversion will be used. |
Drat, I thought I had a fix for this but it turns out the full precision is not reaching that FreeTDS code. When it divides by ten, that's because |
I suspect this may not be possible. I'll see what the FreeTDS developers say in response to FreeTDS/freetds#519 |
Recent versions of MSSQL add a
datetime2
type with greater precision than the olddatetime
. For older clients it is returned as a string, so sqsh can still run queries returning this type. But there's a subtle problem. The type supports fractional seconds with 7 decimal places of precision, but sqsh displays only 6 d.p. So for exampleBy explicitly converting to a wide enough
char
, you can see the full precision, but sqsh has discarded the last digit. (It appears to have truncated rather than rounded.)While an approximate result is often good enough, if you wanted to copy and paste into another query you need the full precision, since the truncated value usually won't be equal to the original. For example
Huh, how did I find the date and time but then there were no rows matching it? It's because the
datetime2
value was actually one digit longer but sqsh truncated.Since you show six d.p. currently, displaying one more wouldn't be unreasonable and it would make the output a lot more useful, by showing the exact value.
The text was updated successfully, but these errors were encountered: