diff --git a/lang_helpers/gds_codes.ftn b/lang_helpers/gds_codes.ftn index 97352261e9..6f815ce2aa 100644 --- a/lang_helpers/gds_codes.ftn +++ b/lang_helpers/gds_codes.ftn @@ -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 diff --git a/lang_helpers/gds_codes.pas b/lang_helpers/gds_codes.pas index a9d869c1bb..9597584dfd 100644 --- a/lang_helpers/gds_codes.pas +++ b/lang_helpers/gds_codes.pas @@ -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; diff --git a/src/include/gen/codetext.h b/src/include/gen/codetext.h index 9735dbf190..f04f55ea4c 100644 --- a/src/include/gen/codetext.h +++ b/src/include/gen/codetext.h @@ -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}, diff --git a/src/include/gen/iberror.h b/src/include/gen/iberror.h index 50a58219b1..b0530996a6 100644 --- a/src/include/gen/iberror.h +++ b/src/include/gen/iberror.h @@ -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 diff --git a/src/include/gen/msgs.h b/src/include/gen/msgs.h index f330f2a314..fc99023298 100644 --- a/src/include/gen/msgs.h +++ b/src/include/gen/msgs.h @@ -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 */ diff --git a/src/include/gen/sql_code.h b/src/include/gen/sql_code.h index d4c3800c50..8599085e95 100644 --- a/src/include/gen/sql_code.h +++ b/src/include/gen/sql_code.h @@ -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 */ diff --git a/src/include/gen/sql_state.h b/src/include/gen/sql_state.h index 26984b624e..660548f694 100644 --- a/src/include/gen/sql_state.h +++ b/src/include/gen/sql_state.h @@ -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 diff --git a/src/jrd/Coercion.cpp b/src/jrd/Coercion.cpp index ab5381ba50..8563059f2f 100644 --- a/src/jrd/Coercion.cpp +++ b/src/jrd/Coercion.cpp @@ -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) diff --git a/src/msgs/facilities2.sql b/src/msgs/facilities2.sql index 7505c9944e..05eef0e16a 100644 --- a/src/msgs/facilities2.sql +++ b/src/msgs/facilities2.sql @@ -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) diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index d9bb7ab933..47c07ec523 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -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); diff --git a/src/msgs/system_errors2.sql b/src/msgs/system_errors2.sql index 397c8588fa..604569fceb 100644 --- a/src/msgs/system_errors2.sql +++ b/src/msgs/system_errors2.sql @@ -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)