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

Fixed errors displayed in case of error in DPB bindings

This commit is contained in:
AlexPeshkoff 2019-11-13 21:24:59 +03:00 committed by Alexander Peshkov
parent 5b9946c199
commit 66bdb2c9c6
13 changed files with 67 additions and 18 deletions

View File

@ -1928,6 +1928,10 @@ C --
PARAMETER (GDS__odd_hex_len = 335545257) PARAMETER (GDS__odd_hex_len = 335545257)
INTEGER*4 GDS__invalid_hex_digit INTEGER*4 GDS__invalid_hex_digit
PARAMETER (GDS__invalid_hex_digit = 335545258) PARAMETER (GDS__invalid_hex_digit = 335545258)
INTEGER*4 GDS__bind_err
PARAMETER (GDS__bind_err = 335545259)
INTEGER*4 GDS__bind_statement
PARAMETER (GDS__bind_statement = 335545260)
INTEGER*4 GDS__gfix_db_name INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929) PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw INTEGER*4 GDS__gfix_invalid_sw

View File

@ -1923,6 +1923,10 @@ const
gds_odd_hex_len = 335545257; gds_odd_hex_len = 335545257;
isc_invalid_hex_digit = 335545258; isc_invalid_hex_digit = 335545258;
gds_invalid_hex_digit = 335545258; gds_invalid_hex_digit = 335545258;
isc_bind_err = 335545259;
gds_bind_err = 335545259;
isc_bind_statement = 335545260;
gds_bind_statement = 335545260;
isc_gfix_db_name = 335740929; isc_gfix_db_name = 335740929;
gds_gfix_db_name = 335740929; gds_gfix_db_name = 335740929;
isc_gfix_invalid_sw = 335740930; isc_gfix_invalid_sw = 335740930;

View File

@ -1570,21 +1570,22 @@ unsigned sqlTypeToDsc(unsigned runOffset, unsigned sqlType, unsigned sqlLength,
return runOffset + sizeof(SSHORT); return runOffset + sizeof(SSHORT);
} }
bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code) const ISC_STATUS* nextArg(const ISC_STATUS* v) throw()
{ {
#ifdef DEV_BUILD
const ISC_STATUS* const origen = v;
#endif
while (v[0] == isc_arg_gds)
{
if (v[1] == code)
return true;
do do
{ {
v += (v[0] == isc_arg_cstring ? 3 : 2); v += (v[0] == isc_arg_cstring ? 3 : 2);
} while (v[0] != isc_arg_warning && v[0] != isc_arg_gds && v[0] != isc_arg_end); } while (v[0] != isc_arg_warning && v[0] != isc_arg_gds && v[0] != isc_arg_end);
fb_assert(v - origen < ISC_STATUS_LENGTH);
return v;
}
bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code)
{
for (; v[0] == isc_arg_gds; v = nextArg(v))
{
if (v[1] == code)
return true;
} }
return false; return false;

View File

@ -143,6 +143,10 @@ namespace fb_utils
unsigned int subStatus(const ISC_STATUS* in, unsigned int cin, unsigned int subStatus(const ISC_STATUS* in, unsigned int cin,
const ISC_STATUS* sub, unsigned int csub) throw(); const ISC_STATUS* sub, unsigned int csub) throw();
bool cmpStatus(unsigned int len, const ISC_STATUS* a, const ISC_STATUS* b) throw(); bool cmpStatus(unsigned int len, const ISC_STATUS* a, const ISC_STATUS* b) throw();
const ISC_STATUS* nextArg(const ISC_STATUS* v) throw();
// Check does vector contain particular code or not
bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code);
enum FetchPassResult { enum FetchPassResult {
FETCH_PASS_OK, FETCH_PASS_OK,
@ -191,9 +195,6 @@ namespace fb_utils
unsigned sqlTypeToDsc(unsigned prevOffset, unsigned sqlType, unsigned sqlLength, unsigned sqlTypeToDsc(unsigned prevOffset, unsigned sqlType, unsigned sqlLength,
unsigned* dtype, unsigned* len, unsigned* offset, unsigned* nullOffset); unsigned* dtype, unsigned* len, unsigned* offset, unsigned* nullOffset);
// Check does vector contain particular code or not
bool containsErrorCode(const ISC_STATUS* v, ISC_STATUS code);
bool inline isNetworkError(ISC_STATUS code) bool inline isNetworkError(ISC_STATUS code)
{ {
return code == isc_network_error || return code == isc_network_error ||

View File

@ -960,6 +960,8 @@ static const struct {
{"invalid_decfloat_bind", 335545256}, {"invalid_decfloat_bind", 335545256},
{"odd_hex_len", 335545257}, {"odd_hex_len", 335545257},
{"invalid_hex_digit", 335545258}, {"invalid_hex_digit", 335545258},
{"bind_err", 335545259},
{"bind_statement", 335545260},
{"gfix_db_name", 335740929}, {"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930}, {"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932}, {"gfix_incmp_sw", 335740932},

View File

@ -994,6 +994,8 @@ const ISC_STATUS isc_invalid_time_zone_bind = 335545255L;
const ISC_STATUS isc_invalid_decfloat_bind = 335545256L; const ISC_STATUS isc_invalid_decfloat_bind = 335545256L;
const ISC_STATUS isc_odd_hex_len = 335545257L; const ISC_STATUS isc_odd_hex_len = 335545257L;
const ISC_STATUS isc_invalid_hex_digit = 335545258L; 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_gfix_db_name = 335740929L; const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L; const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L; const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@ -1481,7 +1483,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
const ISC_STATUS isc_trace_switch_param_miss = 337182758L; const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L; const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L; const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
const ISC_STATUS isc_err_max = 1425; const ISC_STATUS isc_err_max = 1427;
#else /* c definitions */ #else /* c definitions */
@ -2445,6 +2447,8 @@ const ISC_STATUS isc_err_max = 1425;
#define isc_invalid_decfloat_bind 335545256L #define isc_invalid_decfloat_bind 335545256L
#define isc_odd_hex_len 335545257L #define isc_odd_hex_len 335545257L
#define isc_invalid_hex_digit 335545258L #define isc_invalid_hex_digit 335545258L
#define isc_bind_err 335545259L
#define isc_bind_statement 335545260L
#define isc_gfix_db_name 335740929L #define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L #define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L #define isc_gfix_incmp_sw 335740932L
@ -2932,7 +2936,7 @@ const ISC_STATUS isc_err_max = 1425;
#define isc_trace_switch_param_miss 337182758L #define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L #define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L #define isc_trace_mandatory_switch_miss 337182760L
#define isc_err_max 1425 #define isc_err_max 1427
#endif #endif

View File

@ -963,6 +963,8 @@ Data source : @4"}, /* eds_statement */
{335545256, "Invalid decfloat bind mode @1"}, /* invalid_decfloat_bind */ {335545256, "Invalid decfloat bind mode @1"}, /* invalid_decfloat_bind */
{335545257, "Invalid hex text length @1, should be multiple of 2"}, /* odd_hex_len */ {335545257, "Invalid hex text length @1, should be multiple of 2"}, /* odd_hex_len */
{335545258, "Invalid hex digit @1 at position @2"}, /* invalid_hex_digit */ {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 */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */ {335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */ {335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */ {335740932, "incompatible switch combination"}, /* gfix_incmp_sw */

View File

@ -959,6 +959,8 @@ static const struct {
{335545256, -901}, /* 936 invalid_decfloat_bind */ {335545256, -901}, /* 936 invalid_decfloat_bind */
{335545257, -901}, /* 937 odd_hex_len */ {335545257, -901}, /* 937 odd_hex_len */
{335545258, -901}, /* 938 invalid_hex_digit */ {335545258, -901}, /* 938 invalid_hex_digit */
{335545259, -902}, /* 939 bind_err */
{335545260, -902}, /* 940 bind_statement */
{335740929, -901}, /* 1 gfix_db_name */ {335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */ {335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */ {335740932, -901}, /* 4 gfix_incmp_sw */

View File

@ -959,6 +959,8 @@ static const struct {
{335545256, "42000"}, // 936 invalid_decfloat_bind {335545256, "42000"}, // 936 invalid_decfloat_bind
{335545257, "22023"}, // 937 odd_hex_len {335545257, "22023"}, // 937 odd_hex_len
{335545258, "22023"}, // 938 invalid_hex_digit {335545258, "22023"}, // 938 invalid_hex_digit
{335545259, "08004"}, // 939 bind_err
{335545260, "08004"}, // 940 bind_statement
{335740929, "00000"}, // 1 gfix_db_name {335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw {335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw {335740932, "00000"}, // 4 gfix_incmp_sw

View File

@ -1151,9 +1151,32 @@ namespace Jrd
{ {
rules[i].insert(0, "SET BIND OF "); rules[i].insert(0, "SET BIND OF ");
try
{
AutoPreparedStatement ps(att->prepareStatement(tdbb, nullptr, rules[i].ToString())); AutoPreparedStatement ps(att->prepareStatement(tdbb, nullptr, rules[i].ToString()));
ps->execute(tdbb, nullptr); ps->execute(tdbb, nullptr);
} }
catch (const Exception& ex)
{
FbLocalStatus status;
ex.stuffException(&status);
// strip spam messages
const ISC_STATUS* v = status->getErrors();
for (; v[0] == isc_arg_gds; v = fb_utils::nextArg(v))
{
if (v[1] != isc_dsql_error && v[1] != isc_sqlerr)
break;
}
// build and throw new vector
Arg::Gds newErr(isc_bind_err);
newErr << options.dpb_set_bind <<
Arg::Gds(isc_bind_statement) << rules[i];
newErr << Arg::StatusVector(v);
newErr.raise();
}
}
} }
if (options.dpb_decfloat_round.hasData()) if (options.dpb_decfloat_round.hasData())

View File

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

View File

@ -1046,6 +1046,8 @@ Data source : @4', NULL, NULL)
('invalid_decfloat_bind', NULL, 'jrd.cpp', NULL, 0, 936, NULL, 'Invalid decfloat bind mode @1', NULL, NULL); ('invalid_decfloat_bind', NULL, 'jrd.cpp', NULL, 0, 936, NULL, 'Invalid decfloat bind mode @1', NULL, NULL);
('odd_hex_len', NULL, 'SysFunction.cpp', NULL, 0, 937, NULL, 'Invalid hex text length @1, should be multiple of 2', NULL, NULL); ('odd_hex_len', NULL, 'SysFunction.cpp', NULL, 0, 937, NULL, 'Invalid hex text length @1, should be multiple of 2', NULL, NULL);
('invalid_hex_digit', NULL, 'SysFunction.cpp', NULL, 0, 938, NULL, 'Invalid hex digit @1 at position @2', 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);
-- QLI -- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL); (NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL); (NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);

View File

@ -945,6 +945,8 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA
(-901, '42', '000', 0, 936, 'invalid_decfloat_bind', NULL, NULL) (-901, '42', '000', 0, 936, 'invalid_decfloat_bind', NULL, NULL)
(-901, '22', '023', 0, 937, 'odd_hex_len', NULL, NULL) (-901, '22', '023', 0, 937, 'odd_hex_len', NULL, NULL)
(-901, '22', '023', 0, 938, 'invalid_hex_digit', NULL, NULL) (-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)
-- GFIX -- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL) (-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL) (-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)