From 23906efcff457234386e373b8048555c6cc1c7bc Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Tue, 21 Jul 2020 19:07:04 +0300 Subject: [PATCH] Fixed CORE-6303: Error writing to TIMESTAMP/TIME WITH TIME ZONE array --- doc/sql.extensions/README.set_bind.md | 3 +++ src/common/sdl.cpp | 36 +++++++++++++++++++++------ src/yvalve/array.epp | 12 +++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/doc/sql.extensions/README.set_bind.md b/doc/sql.extensions/README.set_bind.md index 585e669128..7c11a123ed 100644 --- a/doc/sql.extensions/README.set_bind.md +++ b/doc/sql.extensions/README.set_bind.md @@ -64,6 +64,9 @@ of particular SQL functions. The following types will be described in legacy for DECFLOAT, INT128 and TIME(STAMP) WITH TIME ZONE. When `DataTypeCompatibility=2.5` in addition to this list BOOLEAN will be described as legacy type as well. +Only fields returned by database engine in regular messages are modified according to SET BIND rules. +Variables returned by getting slice of an array are not affected by SET BIND statement. + ### SQL Samples: diff --git a/src/common/sdl.cpp b/src/common/sdl.cpp index 89151b8537..0059a6bda3 100644 --- a/src/common/sdl.cpp +++ b/src/common/sdl.cpp @@ -828,6 +828,11 @@ static const UCHAR* sdl_desc(const UCHAR* ptr, DSC* desc) desc->dsc_length = sizeof(SINT64); break; + case blr_int128: + desc->dsc_dtype = dtype_int128; + desc->dsc_length = sizeof(Int128); + break; + case blr_quad: desc->dsc_dtype = dtype_quad; desc->dsc_length = sizeof(ISC_QUAD); @@ -854,24 +859,39 @@ static const UCHAR* sdl_desc(const UCHAR* ptr, DSC* desc) desc->dsc_length = sizeof(Decimal128); break; - case blr_int128: - desc->dsc_dtype = dtype_int128; - desc->dsc_length = sizeof(Int128); - break; - case blr_timestamp: desc->dsc_dtype = dtype_timestamp; - desc->dsc_length = sizeof(ISC_QUAD); + desc->dsc_length = sizeof(ISC_TIMESTAMP); + break; + + case blr_timestamp_tz: + desc->dsc_dtype = dtype_timestamp_tz; + desc->dsc_length = sizeof(ISC_TIMESTAMP_TZ); + break; + + case blr_ex_timestamp_tz: + desc->dsc_dtype = dtype_ex_timestamp_tz; + desc->dsc_length = sizeof(ISC_TIMESTAMP_TZ_EX); break; case blr_sql_date: desc->dsc_dtype = dtype_sql_date; - desc->dsc_length = sizeof(SLONG); + desc->dsc_length = sizeof(ISC_DATE); break; case blr_sql_time: desc->dsc_dtype = dtype_sql_time; - desc->dsc_length = sizeof(ULONG); + desc->dsc_length = sizeof(ISC_TIME); + break; + + case blr_sql_time_tz: + desc->dsc_dtype = dtype_sql_time_tz; + desc->dsc_length = sizeof(ISC_TIME_TZ); + break; + + case blr_ex_time_tz: + desc->dsc_dtype = dtype_ex_time_tz; + desc->dsc_length = sizeof(ISC_TIME_TZ_EX); break; case blr_bool: diff --git a/src/yvalve/array.epp b/src/yvalve/array.epp index 477e6222fc..449de9806a 100644 --- a/src/yvalve/array.epp +++ b/src/yvalve/array.epp @@ -297,12 +297,24 @@ ISC_STATUS API_ROUTINE isc_array_set_desc(ISC_STATUS* status, case SQL_TIMESTAMP: desc->array_desc_dtype = blr_timestamp; break; + case SQL_TIMESTAMP_TZ: + desc->array_desc_dtype = blr_timestamp_tz; + break; + case SQL_TIMESTAMP_TZ_EX: + desc->array_desc_dtype = blr_ex_timestamp_tz; + break; case SQL_TYPE_DATE: desc->array_desc_dtype = blr_sql_date; break; case SQL_TYPE_TIME: desc->array_desc_dtype = blr_sql_time; break; + case SQL_TIME_TZ: + desc->array_desc_dtype = blr_sql_time_tz; + break; + case SQL_TIME_TZ_EX: + desc->array_desc_dtype = blr_ex_time_tz; + break; case SQL_LONG: desc->array_desc_dtype = blr_long; break;