You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we use numeric instead of decimal in either table column definition or in sp_prepare
second argument (parameters definition) - then Babelfish correctly returns 123.46,
both following examples work correctly on Babelfish:
The problem happens on insert, the scale value 2 included in column type modifier is ignored
if column is declared as decimal. I can see that sys.decimal is defined as a DOMAIN and
AFAIU Postgres does not support type modifiers for domains.
The problem with sp_prepare + sp_execute happens the same way for both T-SQL and TDS RPC invocations.
The problem also happens with sp_executesql when it is called in T-SQL:
But it does NOT happen when sp_executesql is called with TDS RPC. This code path is used with prepared statements in mssql-jdbc driver. Because, unlike sp_prepare + sp_execute calls, with sp_executesql actual parameter values are passed in the same call, their type ID is set to numeric instead of decimal and this type ID is preserved in pltsql_declare_variable() and then is made available to executor from exec_eval_datum().
As a workaround, it is possible to rewrite decimal to numeric in read_param_def() before passing type names to type IDs lookup. This fixes the problem for jTDS driver (that uses sp_prepare + sp_execute RPC for prepared statements). But I assume the problem requires more general solution so do not propose it as a fix.
Version
BABEL_4_X_DEV (Default)
Extension
babelfishpg_tsql (Default)
Which flavor of Linux are you using when you see the bug?
Fedora
Relevant log output
No response
Code of Conduct
I agree to follow this project's Code of Conduct.
The text was updated successfully, but these errors were encountered:
What happened?
The following snippet returns
123.45
on Babelfish and123.46
on MSSQL:If we use
numeric
instead ofdecimal
in either table column definition or insp_prepare
second argument (parameters definition) - then Babelfish correctly returns
123.46
,both following examples work correctly on Babelfish:
The problem happens on insert, the scale value
2
included in column type modifier is ignoredif column is declared as
decimal
. I can see thatsys.decimal
is defined as a DOMAIN andAFAIU Postgres does not support type modifiers for domains.
The problem with
sp_prepare
+sp_execute
happens the same way for both T-SQL and TDS RPC invocations.The problem also happens with
sp_executesql
when it is called in T-SQL:But it does NOT happen when
sp_executesql
is called with TDS RPC. This code path is used with prepared statements inmssql-jdbc
driver. Because, unlikesp_prepare
+sp_execute
calls, withsp_executesql
actual parameter values are passed in the same call, their type ID is set tonumeric
instead ofdecimal
and this type ID is preserved in pltsql_declare_variable() and then is made available to executor from exec_eval_datum().As a workaround, it is possible to rewrite
decimal
tonumeric
in read_param_def() before passing type names to type IDs lookup. This fixes the problem forjTDS
driver (that usessp_prepare
+sp_execute
RPC for prepared statements). But I assume the problem requires more general solution so do not propose it as a fix.Version
BABEL_4_X_DEV (Default)
Extension
babelfishpg_tsql (Default)
Which flavor of Linux are you using when you see the bug?
Fedora
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: