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
When sp_executesql is called through RPC and parameter of type binary(8) is supplied, then this parameter PgType is determined as rowversion instead of binary(8). There is no typmodin registered for rowversion, so zero Oid is returned for it and query fails with cache lookup failed for function 0.
It seems to happen only with RPC calls, can be reproduced with the following C# program:
usingSystem.Data;usingSystem.Text;usingMicrosoft.Data.SqlClient;classProgram{staticvoidMain(){stringcstr="Data Source=192.168.122.1,1433;Initial Catalog=master;User ID=jdbc_user;Password=12345678;Trust Server Certificate=yes;Connection Timeout=600";usingSqlConnectionconn=new(cstr);conn.Open();stringsql="select 'foo' where @P1 is not null";usingSqlCommandcmd=newSqlCommand(sql,conn);cmd.Parameters.Add("@P1",SqlDbType.Binary,8).Value=Encoding.ASCII.GetBytes("foo");usingSqlDataReaderreader=cmd.ExecuteReader();while(reader.Read()){Console.WriteLine("{0}",reader.GetString(0));}}}
> dotnet run
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): cache lookup failed for function 0
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
...
This happens because rowversionis registered as binary with maxLen 8, and if PgOid is looked up by TDS binary type with maxLen 8 - then rowversion is returned for it.
There is an easy workaround - to not supply maxLen to lookup call when the type is binary. But I wonder if there should be a more general solution to this.
Version
BABEL_4_X_DEV (Default)
Extension
babelfishpg_tds
Which flavor of Linux are you using when you see the bug?
What happened?
When
sp_executesql
is called through RPC and parameter of typebinary(8)
is supplied, then this parameter PgType is determined asrowversion
instead ofbinary(8)
. There is notypmodin
registered forrowversion
, so zero Oid is returned for it and query fails withcache lookup failed for function 0
.It seems to happen only with RPC calls, can be reproduced with the following C# program:
This happens because
rowversion
is registered asbinary
withmaxLen
8, and if PgOid is looked up by TDSbinary
type withmaxLen
8 - thenrowversion
is returned for it.There is an easy workaround - to not supply
maxLen
to lookup call when the type isbinary
. But I wonder if there should be a more general solution to this.Version
BABEL_4_X_DEV (Default)
Extension
babelfishpg_tds
Which flavor of Linux are you using when you see the bug?
Fedora
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: