8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Added check for correctness of data coercion requested in SET BIND

This commit is contained in:
AlexPeshkoff 2019-11-29 19:32:44 +03:00 committed by Alexander Peshkov
parent 7175cfc910
commit 938bbee174
11 changed files with 33 additions and 4 deletions

View File

@ -1932,6 +1932,8 @@ C --
PARAMETER (GDS__bind_err = 335545259)
INTEGER*4 GDS__bind_statement
PARAMETER (GDS__bind_statement = 335545260)
INTEGER*4 GDS__bind_convert
PARAMETER (GDS__bind_convert = 335545261)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw

View File

@ -1927,6 +1927,8 @@ const
gds_bind_err = 335545259;
isc_bind_statement = 335545260;
gds_bind_statement = 335545260;
isc_bind_convert = 335545261;
gds_bind_convert = 335545261;
isc_gfix_db_name = 335740929;
gds_gfix_db_name = 335740929;
isc_gfix_invalid_sw = 335740930;

View File

@ -962,6 +962,7 @@ static const struct {
{"invalid_hex_digit", 335545258},
{"bind_err", 335545259},
{"bind_statement", 335545260},
{"bind_convert", 335545261},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},

View File

@ -996,6 +996,7 @@ const ISC_STATUS isc_odd_hex_len = 335545257L;
const ISC_STATUS isc_invalid_hex_digit = 335545258L;
const ISC_STATUS isc_bind_err = 335545259L;
const ISC_STATUS isc_bind_statement = 335545260L;
const ISC_STATUS isc_bind_convert = 335545261L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@ -1483,7 +1484,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
const ISC_STATUS isc_err_max = 1427;
const ISC_STATUS isc_err_max = 1428;
#else /* c definitions */
@ -2449,6 +2450,7 @@ const ISC_STATUS isc_err_max = 1427;
#define isc_invalid_hex_digit 335545258L
#define isc_bind_err 335545259L
#define isc_bind_statement 335545260L
#define isc_bind_convert 335545261L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@ -2936,7 +2938,7 @@ const ISC_STATUS isc_err_max = 1427;
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
#define isc_err_max 1427
#define isc_err_max 1428
#endif

View File

@ -965,6 +965,7 @@ Data source : @4"}, /* eds_statement */
{335545258, "Invalid hex digit @1 at position @2"}, /* invalid_hex_digit */
{335545259, "Error processing isc_dpb_set_bind clumplet \"@1\""}, /* bind_err */
{335545260, "The following statement failed: @1"}, /* bind_statement */
{335545261, "Can not convert @1 to @2"}, /* bind_convert */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */

View File

@ -961,6 +961,7 @@ static const struct {
{335545258, -901}, /* 938 invalid_hex_digit */
{335545259, -902}, /* 939 bind_err */
{335545260, -902}, /* 940 bind_statement */
{335545261, -901}, /* 941 bind_convert */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */

View File

@ -961,6 +961,7 @@ static const struct {
{335545258, "22023"}, // 938 invalid_hex_digit
{335545259, "08004"}, // 939 bind_err
{335545260, "08004"}, // 940 bind_statement
{335545261, "22000"}, // 941 bind_convert
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw

View File

@ -27,6 +27,7 @@
#include "firebird.h"
#include "../jrd/Coercion.h"
#include "../jrd/cvt_proto.h"
#include "../dsql/dsql.h"
#include "../dsql/make_proto.h"
@ -60,7 +61,6 @@ void CoercionArray::setRule(const TypeClause* from, const TypeClause *to)
if (getElement(n) == newRule)
{
remove(n);
printf("Remove rule %d\n", n);
break;
}
}
@ -75,6 +75,23 @@ void CoercionRule::setRule(const TypeClause* from, const TypeClause *to)
toMask = to->flags & TO_MASK;
DsqlDescMaker::fromField(&toDsc, to);
// Check for datatype compatibility
const unsigned DATASIZE = 256;
UCHAR buf[DATASIZE * 2 + FB_ALIGNMENT];
memset(buf, 0, sizeof buf);
toDsc.dsc_address = FB_ALIGN(buf, FB_ALIGNMENT);
fromDsc.dsc_address = toDsc.dsc_address + DATASIZE;
try
{
CVT_move(&fromDsc, &toDsc, 0);
}
catch(const Exception&)
{
// Do not use ERR_post here - old error to be overwritten
(Arg::Gds(isc_bind_convert) << fromDsc.typeToText() << toDsc.typeToText()).raise();
}
}
dsc* CoercionRule::makeLegacy(USHORT mask)

View File

@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
('2019-11-13 17:10:00', 'JRD', 0, 941)
('2019-11-29 17:08:00', 'JRD', 0, 942)
('2015-03-17 18:33:00', 'QLI', 1, 533)
('2018-03-17 12:00:00', 'GFIX', 3, 136)
('1996-11-07 13:39:40', 'GPRE', 4, 1)

View File

@ -1048,6 +1048,7 @@ Data source : @4', NULL, NULL)
('invalid_hex_digit', NULL, 'SysFunction.cpp', NULL, 0, 938, NULL, 'Invalid hex digit @1 at position @2', NULL, NULL);
('bind_err', NULL, 'jrd.cpp', NULL, 0, 939, NULL, 'Error processing isc_dpb_set_bind clumplet "@1"', NULL, NULL);
('bind_statement', NULL, 'jrd.cpp', NULL, 0, 940, NULL, 'The following statement failed: @1', NULL, NULL);
('bind_convert', NULL, 'Coercion.cpp', NULL, 0, 941, NULL, 'Can not convert @1 to @2', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);

View File

@ -947,6 +947,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA
(-901, '22', '023', 0, 938, 'invalid_hex_digit', NULL, NULL)
(-902, '08', '004', 0, 939, 'bind_err', NULL, NULL)
(-902, '08', '004', 0, 940, 'bind_statement', NULL, NULL)
(-901, '22', '000', 0, 941, 'bind_convert', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)