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

Add missing index depth protection during index creatiion + new error

code/message.
This commit is contained in:
Dmitry Yemanov 2016-05-15 16:07:44 +03:00
parent 08c42cb080
commit fbd7bd86da
11 changed files with 24 additions and 7 deletions

View File

@ -1630,6 +1630,8 @@ C --
PARAMETER (GDS__bad_crypt_key = 335545108)
INTEGER*4 GDS__encrypt_error
PARAMETER (GDS__encrypt_error = 335545109)
INTEGER*4 GDS__max_idx_depth
PARAMETER (GDS__max_idx_depth = 335545110)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw

View File

@ -1625,6 +1625,8 @@ const
gds_bad_crypt_key = 335545108;
isc_encrypt_error = 335545109;
gds_encrypt_error = 335545109;
isc_max_idx_depth = 335545110;
gds_max_idx_depth = 335545110;
isc_gfix_db_name = 335740929;
gds_gfix_db_name = 335740929;
isc_gfix_invalid_sw = 335740930;

View File

@ -811,6 +811,7 @@ static const struct {
{"already_opened", 335545107},
{"bad_crypt_key", 335545108},
{"encrypt_error", 335545109},
{"max_idx_depth", 335545110},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},

View File

@ -845,6 +845,7 @@ const ISC_STATUS isc_login_error = 335545106L;
const ISC_STATUS isc_already_opened = 335545107L;
const ISC_STATUS isc_bad_crypt_key = 335545108L;
const ISC_STATUS isc_encrypt_error = 335545109L;
const ISC_STATUS isc_max_idx_depth = 335545110L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@ -1316,7 +1317,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 = 1260;
const ISC_STATUS isc_err_max = 1261;
#else /* c definitions */
@ -2131,6 +2132,7 @@ const ISC_STATUS isc_err_max = 1260;
#define isc_already_opened 335545107L
#define isc_bad_crypt_key 335545108L
#define isc_encrypt_error 335545109L
#define isc_max_idx_depth 335545110L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@ -2602,7 +2604,7 @@ const ISC_STATUS isc_err_max = 1260;
#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 1260
#define isc_err_max 1261
#endif

View File

@ -814,6 +814,7 @@ Data source : @4"}, /* eds_statement */
{335545107, "Database already opened with engine instance, incompatible with current"}, /* already_opened */
{335545108, "Invalid crypt key @1"}, /* bad_crypt_key */
{335545109, "Page requires encyption but crypt plugin is missing"}, /* encrypt_error */
{335545110, "Maximum index tree depth (@1 levels) is reached"}, /* max_idx_depth */
{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

@ -810,6 +810,7 @@ static const struct {
{335545107, -902}, /* 787 already_opened */
{335545108, -902}, /* 788 bad_crypt_key */
{335545109, -901}, /* 789 encrypt_error */
{335545110, -904}, /* 790 max_idx_depth */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */

View File

@ -810,6 +810,7 @@ static const struct {
{335545107, "08006"}, // 787 already_opened
{335545108, "08006"}, // 788 bad_crypt_key
{335545109, "XX000"}, // 789 encrypt_error
{335545110, "54000"}, // 790 max_idx_depth
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw

View File

@ -1114,11 +1114,9 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion)
{
CCH_RELEASE(tdbb, root_window);
// Maximum level depth reached.
// AB: !! NEW ERROR MESSAGE ? !!
////BUGCHECK(204); // msg 204 index inconsistent
// Maximum level depth reached
status_exception::raise(Arg::Gds(isc_imp_exc) <<
Arg::Gds(isc_random) << Arg::Str("Maximum index level reached"));
Arg::Gds(isc_max_idx_depth) << Arg::Num(MAX_LEVELS));
}
// Allocate and format new bucket, this will always be a non-leaf page
@ -3620,6 +3618,13 @@ static ULONG fast_load(thread_db* tdbb,
// split upward
for (unsigned level = 1; levels[level - 1].splitPage; level++)
{
if (level == MAX_LEVELS)
{
// Maximum level depth reached
status_exception::raise(Arg::Gds(isc_imp_exc) <<
Arg::Gds(isc_max_idx_depth) << Arg::Num(MAX_LEVELS));
}
if (level == levels.getCount())
levels.resize(level + 1);

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 (?, ?, ?, ?);
--
('2016-02-03 14:51:49', 'JRD', 0, 790)
('2016-05-15 12:46:00', 'JRD', 0, 791)
('2015-03-17 18:33:00', 'QLI', 1, 533)
('2015-01-07 18:01:51', 'GFIX', 3, 134)
('1996-11-07 13:39:40', 'GPRE', 4, 1)

View File

@ -897,6 +897,7 @@ Data source : @4', NULL, NULL)
('already_opened', 'lockDatabaseFile', 'unix.cpp', NULL, 0, 787, NULL, 'Database already opened with engine instance, incompatible with current', NULL, NULL);
('bad_crypt_key', NULL, 'CryptoManager.cpp', NULL, 0, 788, NULL, 'Invalid crypt key @1', NULL, NULL);
('encrypt_error', NULL, 'CryptoManager.cpp', NULL, 0, 789, NULL, 'Page requires encyption but crypt plugin is missing', NULL, NULL);
('max_idx_depth', NULL, 'btr.cpp', NULL, 0, 790, NULL, 'Maximum index depth (@1 levels) is reached', 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

@ -796,6 +796,7 @@ set bulk_insert INSERT INTO SYSTEM_ERRORS (SQL_CODE, SQL_CLASS, SQL_SUBCLASS, FA
(-902, '08', '006', 0, 787, 'already_opened', NULL, NULL)
(-902, '08', '006', 0, 788, 'bad_crypt_key', NULL, NULL)
(-901, 'XX', '000', 0, 789, 'encrypt_error', NULL, NULL)
(-904, '54', '000', 0, 790, 'max_idx_depth', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)