babelfish_extensions icon indicating copy to clipboard operation
babelfish_extensions copied to clipboard

[Bug]: sql_variant always uses max scale with time and datetime2 types

Open staticlibs opened this issue 1 year ago • 0 comments

What happened?

With a table like this:

create table tab1(col1 sql_variant)
insert into tab1 values(cast('12:45:37.123' as time(2)))
insert into tab1 values(cast('2016-10-23 12:45:37.123' as datetime2(2)))
select * from tab1

MSSQL returns:

12:45:37.12
2016-10-23 12:45:37.12

And Babelfish returns:

12:45:37.1200000
2016-10-23 12:45:37.1200000

It seems that data is stored with a correct scale, but this scale is not available when tuples are printed out. Scale values read in TdsGetMetaData does not return correct scale and resulting garbage values are treated as max scale.

I've stumbled upon this when fixing remaining test failures for #2320 , I don't intend to try to address this scale problem now, so filing the issue for the record.

Version

BABEL_4_X_DEV (Default)

Extension

babelfishpg_common

Which flavor of Linux are you using when you see the bug?

Fedora

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct.

staticlibs avatar May 31 '24 10:05 staticlibs