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

exception when using a boolean parameter with an embedded v2.5 server [DNET683] #636

Closed
firebird-automations opened this issue May 25, 2016 · 18 comments

Comments

@firebird-automations
Copy link

Submitted by: livioc (livioc)

executing a query with an explicit typed boolean parameter will generate this exception

FirebirdSql.Data.FirebirdClient.FbException: Dynamic SQL Error
SQL error code = -804
Incorrect values within SQLDA structure ---> FirebirdSql.Data.Common.IscException: Dynamic SQL Error
SQL error code = -804
Incorrect values within SQLDA structure
at FirebirdSql.Data.Client.Native.FesDatabase.ProcessStatusVector(IntPtr[] statusVector) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Native\FesDatabase.cs:line 365
at FirebirdSql.Data.Client.Native.FesStatement.Execute() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Native\FesStatement.cs:line 384
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:line 1221
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:line 527

note:with expicit typed parameter i mean:
cmd.Parameters.Add("@value", FbDbType.Boolean);
cmd.Parameters[0].Value = true;

note2:i'm sending a pull request to github with a failing test for that

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Are you using 3.0 embedded?

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

no, v2.5, in the environment field i cutted the version, sorry

this is the pull request
cincuranet/FirebirdSql.Data.FirebirdClient#57

the failing test is FbBooleanSupportV2_5Tests.ParametrizedSelectTest(false)

@firebird-automations
Copy link
Author

Modified by: livioc (livioc)

environment: .net 4.6.1 application on windows x32 with embedded v.5 => .net 4.6.1 application on windows x32 with embedded v2.5

@firebird-automations
Copy link
Author

Commented by: @cincuranet

In 2.5 it should fail as that version does not support bool column. Why do you think it should be other way?

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

the column type is smallint, the tests are for the conversion boolean to smallint done internally by the firebird provider,

i have some queries in my application with boolean parameters that were working with the provider < v5 but now don't (with that exception)

@firebird-automations
Copy link
Author

Commented by: @cincuranet

If the datatype is explicit, the provider does not go to database to get the real datatypes and trusts developer. That's why it fails. There wasn't bool column in Firebird before and it was just a "lucky coincidence" it worked.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

but why with the server process (not embedded) it still works?

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Server via wire protocol processes the messages differently.

@firebird-automations
Copy link
Author

Commented by: Hennadii Zabula (zabulus)

Jiri, I should disagree.
<2.5 don't have bool type, but it is perfectly imitated by smallint field with 0/1 value. BTW there were even some checks for bool field that value belongs to 0 or 1.
For example:
https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/5a17a58a520a4fb6ccee102be4990acbe2bbeca3/Provider/src/EntityFramework.Firebird/FbMigrationSqlGenerator.cs#L207
I now the code is from old version, and not relates to the issue but still.
Now you are breaking existing code, because it is not right to use bool type in v 2.5.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

But that still works, unless you explicitly specify the parameter type. Then it's plain wrong code. And now it shows. BTW that's also why the major version got incremented.

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

jiri can we add a switch for the server version from the connection to keep the old behaviour when it's < 3.0.0.0?

i'm using nhibernate (i don't know if also entity framework uses the explicit typed parameter constructor) and it uses it so i can't change the code that generates the exception

@firebird-automations
Copy link
Author

Commented by: @cincuranet

You mean checking the server version when sending the data to server?

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

yes to send different isc code for boolean parameters (boolean if >= 3.0.0.0 or smallint)

i don't know if it's a complicated thing to implement

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Can you post a minimal NHibernate repro?

@firebird-automations
Copy link
Author

Commented by: livioc (livioc)

https://github.com/livioc/MixedProjects

i did a simple console app for vs2015, with the provider v5.0.5 it fails, downgrading the nuget package to v4.10 it works

the embedded server is v2.5.5 for x86

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Looking at it, you can of course change it. Simple mapping:
map.Property(x => x.BoolData, pMap =>
{
pMap.Type(new Int16Type());
pMap.NotNullable(true);
});

It is expected that you have to change some code if you update major versions of libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants