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

OVERLAY with binary blob - data corruption [CORE5356] #5629

Open
firebird-automations opened this issue Sep 22, 2016 · 2 comments
Open

OVERLAY with binary blob - data corruption [CORE5356] #5629

firebird-automations opened this issue Sep 22, 2016 · 2 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Karel Rys (vandrovnik)

Hello,

I have a table like this:

CREATE TABLE Users
(
...
Prava blob,
...
);

Records in this table now have char_length of Prava in range 399 to 403. It stores binary zeroes and ones (user rights in our application).
When I run this:

SELECT
char_length(a.Prava) as ActualLength,
ascii_val(a.Prava) as NewValue1,
ascii_val(substring(a.Prava FROM 1 FOR 1)) as NewValue2,
ascii_val(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
)) as NewValue3,
ascii_val(substring(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
) FROM 1 FOR 1)) as NewValue4,
a.*
FROM Users a

I get:

ActualLength, NewValue1, NewValue2, NewValue3, NewValue4, ...
403, 1, 1, 46, 46, ...
402, 1, 1, 1, 1, ...
399, 0, 0, 0, 0, ...
402, 1, 1, 1, 1, ...
...

It seems that OVERLAY returns wrong data for the first record - there should not be any "46".

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

description: Hello,

I have a table like this:

CREATE TABLE Users
(
...
Prava blob,
...
);

Records in this table now have char_length of Prava in range 399 to 403. It stores binary zeroes and ones (user rights in our application).
When I run this:

SELECT
char_length(a.Prava) as ActualLength,
ascii_val(a.Prava) as NewValue1,
ascii_val(substring(a.Prava FROM 1 FOR 1)) as NewValue2,
ascii_val(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
)) as NewValue3,
ascii_val(substring(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
) FROM 1 FOR 1)) as NewValue4,
a.*
FROM Users a

I get:

ActualLength, NewValue1, NewValue2, NewValue3, NewValue4, ...
403, 1, 1, 46, 46, ...
402, 1, 1, 1, 1, ...
399, 0, 0, 0, 0, ...
402, 1, 1, 1, 1, ...
...

It seems that OVERLAY returns wrong data for the first record - there should not be any "46".

Kind regards,

Karel Rys

=>

Hello,

I have a table like this:

CREATE TABLE Users
(
...
Prava blob,
...
);

Records in this table now have char_length of Prava in range 399 to 403. It stores binary zeroes and ones (user rights in our application).
When I run this:

SELECT
char_length(a.Prava) as ActualLength,
ascii_val(a.Prava) as NewValue1,
ascii_val(substring(a.Prava FROM 1 FOR 1)) as NewValue2,
ascii_val(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
)) as NewValue3,
ascii_val(substring(OVERLAY(
a.Prava PLACING ascii_char(1) FROM 200 for 1
) FROM 1 FOR 1)) as NewValue4,
a.*
FROM Users a

I get:

ActualLength, NewValue1, NewValue2, NewValue3, NewValue4, ...
403, 1, 1, 46, 46, ...
402, 1, 1, 1, 1, ...
399, 0, 0, 0, 0, ...
402, 1, 1, 1, 1, ...
...

It seems that OVERLAY returns wrong data for the first record - there should not be any "46".

@firebird-automations
Copy link
Collaborator Author

Commented by: Karel Rys (vandrovnik)

I just tested on Firebird 2.5.5 64bit running on Centos 7, 64 bit.
The same querry returns 46 in ALL fields NewValue1, NewValue2, NewValue3, NewValue4 in ALL records.

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

1 participant