Issue Details (XML | Word | Printable)

Key: CORE-1588
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Kovalenko Dmitry
Votes: 1
Watchers: 1

If you were logged in you would be able to see more operations.
Firebird Core

Array: Wrong work with VARCHAR elements

Created: 12/Nov/07 04:48 PM   Updated: 01/Sep/17 05:01 PM
Component/s: Engine
Affects Version/s: 1.0.3, 2.0.0, 1.5.4, 2.0.1, 2.1 Alpha 1, 2.1 Beta 1, 2.0.2, 2.0.3, 2.1 Beta 2, 2.5 RC2
Fix Version/s: None

Environment: Any

 Description  « Hide
All know servers (FB / IB) incorrect work with VARCHAR arrays - they always do not use first two bytes with length of string.

The problem exists in sdl.cpp - static const UCHAR* sdl_desc(const UCHAR* ptr, DSC* desc):
 blr_varying and blr_varying2 convert to incorrect dtype_cstring

-------- [code from FB2.1 sources]
case blr_varying2:
desc->dsc_dtype = dtype_cstring;
INTL_ASSIGN_TTYPE(desc, get_word(sdl));
desc->dsc_length = sizeof(USHORT);

case blr_varying:
desc->dsc_dtype = dtype_cstring;
INTL_ASSIGN_TTYPE(desc, ttype_dynamic);
desc->dsc_length = sizeof(USHORT);
desc->dsc_flags |= DSC_no_subtype;

I think, correction of this bug will be include
 - new ODS
 - some changes in gbak

Connection component can detect the new ODS and use true algorithms for VARCHAR arrays.

For old ODS - current cstring-algorithm

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 21/Feb/13 04:15 PM
Hmm, I do not see how is it related with ODS. On disk varchars are stored in vary format: 2 bytes length, after it string itself. It's sdl descriptor (tmp object) which contains dtype_cstring instead dtype_varying. Before touching this legacy code I wonder - what real problem does it cause to you, and certainly a kind of test to reproduce is highly desired.

Kovalenko Dmitry added a comment - 14/Mar/16 09:31 AM
I offer append to new version of protocol (FB4?) the two new API functions - xxxx_put_slice2 and xxxx_get_slice2 with correct processing of VARYING arrays.

Kovalenko Dmitry added a comment - 01/Sep/17 05:01 PM
I offer the fix this mistake in FB4 without any look to backward compatibility.