Skip to content

Commit 3dadc08

Browse files
committed
Fixed CORE-6518: Wrong message when connecting to tiny trash database file
1 parent 2102978 commit 3dadc08

12 files changed

Lines changed: 54 additions & 5 deletions

File tree

lang_helpers/gds_codes.ftn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,8 @@ C --
19561956
PARAMETER (GDS__repl_error = 335545271)
19571957
INTEGER*4 GDS__ses_reset_failed
19581958
PARAMETER (GDS__ses_reset_failed = 335545272)
1959+
INTEGER*4 GDS__block_size
1960+
PARAMETER (GDS__block_size = 335545273)
19591961
INTEGER*4 GDS__gfix_db_name
19601962
PARAMETER (GDS__gfix_db_name = 335740929)
19611963
INTEGER*4 GDS__gfix_invalid_sw

lang_helpers/gds_codes.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,8 @@
19511951
gds_repl_error = 335545271;
19521952
isc_ses_reset_failed = 335545272;
19531953
gds_ses_reset_failed = 335545272;
1954+
isc_block_size = 335545273;
1955+
gds_block_size = 335545273;
19541956
isc_gfix_db_name = 335740929;
19551957
gds_gfix_db_name = 335740929;
19561958
isc_gfix_invalid_sw = 335740930;

src/include/gen/Firebird.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5070,6 +5070,7 @@ IReplicatedSessionImpl = class(IReplicatedSession)
50705070
isc_wrong_page = 335545270;
50715071
isc_repl_error = 335545271;
50725072
isc_ses_reset_failed = 335545272;
5073+
isc_block_size = 335545273;
50735074
isc_gfix_db_name = 335740929;
50745075
isc_gfix_invalid_sw = 335740930;
50755076
isc_gfix_incmp_sw = 335740932;

src/include/gen/codetext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ static const struct {
974974
{"wrong_page", 335545270},
975975
{"repl_error", 335545271},
976976
{"ses_reset_failed", 335545272},
977+
{"block_size", 335545273},
977978
{"gfix_db_name", 335740929},
978979
{"gfix_invalid_sw", 335740930},
979980
{"gfix_incmp_sw", 335740932},

src/include/gen/iberror.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ const ISC_STATUS isc_merge_dup_update = 335545269L;
10081008
const ISC_STATUS isc_wrong_page = 335545270L;
10091009
const ISC_STATUS isc_repl_error = 335545271L;
10101010
const ISC_STATUS isc_ses_reset_failed = 335545272L;
1011+
const ISC_STATUS isc_block_size = 335545273L;
10111012
const ISC_STATUS isc_gfix_db_name = 335740929L;
10121013
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
10131014
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1500,7 +1501,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
15001501
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
15011502
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
15021503
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
1503-
const ISC_STATUS isc_err_max = 1444;
1504+
const ISC_STATUS isc_err_max = 1445;
15041505

15051506
#else /* c definitions */
15061507

@@ -2478,6 +2479,7 @@ const ISC_STATUS isc_err_max = 1444;
24782479
#define isc_wrong_page 335545270L
24792480
#define isc_repl_error 335545271L
24802481
#define isc_ses_reset_failed 335545272L
2482+
#define isc_block_size 335545273L
24812483
#define isc_gfix_db_name 335740929L
24822484
#define isc_gfix_invalid_sw 335740930L
24832485
#define isc_gfix_incmp_sw 335740932L
@@ -2970,7 +2972,7 @@ const ISC_STATUS isc_err_max = 1444;
29702972
#define isc_trace_switch_param_miss 337182758L
29712973
#define isc_trace_param_act_notcompat 337182759L
29722974
#define isc_trace_mandatory_switch_miss 337182760L
2973-
#define isc_err_max 1444
2975+
#define isc_err_max 1445
29742976

29752977
#endif
29762978

src/include/gen/msgs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ Data source : @4"}, /* eds_statement */
977977
{335545270, "RDB$PAGES written by non-system transaction, DB appears to be damaged"}, /* wrong_page */
978978
{335545271, "Replication error"}, /* repl_error */
979979
{335545272, "Reset of user session failed. Connection is shut down."}, /* ses_reset_failed */
980+
{335545273, "File size is less than expected"}, /* block_size */
980981
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
981982
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
982983
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */

src/include/gen/sql_code.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ static const struct {
973973
{335545270, -902}, /* 950 wrong_page */
974974
{335545271, -902}, /* 951 repl_error */
975975
{335545272, -902}, /* 952 ses_reset_failed */
976+
{335545273, -902}, /* 953 block_size */
976977
{335740929, -901}, /* 1 gfix_db_name */
977978
{335740930, -901}, /* 2 gfix_invalid_sw */
978979
{335740932, -901}, /* 4 gfix_incmp_sw */

src/include/gen/sql_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ static const struct {
973973
{335545270, "XX000"}, // 950 wrong_page
974974
{335545271, "HY000"}, // 951 repl_error
975975
{335545272, "08003"}, // 952 ses_reset_failed
976+
{335545273, "XX000"}, // 953 block_size
976977
{335740929, "00000"}, // 1 gfix_db_name
977978
{335740930, "00000"}, // 2 gfix_invalid_sw
978979
{335740932, "00000"}, // 4 gfix_incmp_sw

src/jrd/os/posix/unix.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static jrd_file* setup_file(Database*, const PathName&, const int, const bool, c
128128
static void lockDatabaseFile(int& desc, const bool shareMode, const bool temporary,
129129
const char* fileName, ISC_STATUS operation);
130130
static bool unix_error(const TEXT*, const jrd_file*, ISC_STATUS, FbStatusVector* = NULL);
131+
static bool block_size_error(const jrd_file*, off_t, FbStatusVector* = NULL);
131132
#if !(defined HAVE_PREAD && defined HAVE_PWRITE)
132133
static SLONG pread(int, SCHAR*, SLONG, SLONG);
133134
static SLONG pwrite(int, SCHAR*, SLONG, SLONG);
@@ -553,6 +554,8 @@ void PIO_header(thread_db* tdbb, UCHAR* address, int length)
553554
break;
554555
if (bytes < 0 && !SYSCALL_INTERRUPTED(errno))
555556
unix_error("read", file, isc_io_read_err);
557+
if (bytes >= 0)
558+
block_size_error(file, bytes);
556559
}
557560

558561
if (i == IO_RETRY)
@@ -764,6 +767,8 @@ bool PIO_read(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page,
764767
break;
765768
if (bytes < 0 && !SYSCALL_INTERRUPTED(errno))
766769
return unix_error("read", file, isc_io_read_err, status_vector);
770+
if (bytes >= 0)
771+
return block_size_error(file, offset + bytes, status_vector);
767772
}
768773

769774
if (i == IO_RETRY)
@@ -1033,16 +1038,47 @@ static bool unix_error(const TEXT* string,
10331038
Arg::Gds(operation) << Arg::Unix(errno);
10341039

10351040
if (!status_vector)
1036-
{
10371041
ERR_post(err);
1038-
}
10391042

10401043
ERR_build_status(status_vector, err);
10411044
iscLogStatus(NULL, status_vector);
10421045

10431046
return false;
10441047
}
10451048

1049+
1050+
static bool block_size_error(const jrd_file* file, off_t offset, FbStatusVector* status_vector)
1051+
{
1052+
/**************************************
1053+
*
1054+
* b l o c k _ s i z e _ e r r o r
1055+
*
1056+
**************************************
1057+
*
1058+
* Functional description
1059+
* DB block read incomplete, that may be
1060+
* due to signal caught or unexpected EOF.
1061+
*
1062+
**************************************/
1063+
struct stat st;
1064+
if (os_utils::fstat(file->fil_desc, &st) < 0)
1065+
return unix_error("fstat", file, isc_io_access_err, status_vector);
1066+
1067+
if (offset < st.st_size) // we might read more but were interupted
1068+
return true;
1069+
1070+
Arg::Gds err(isc_io_error);
1071+
err << "read" << file->fil_string << Arg::Gds(isc_block_size);
1072+
1073+
if (!status_vector)
1074+
ERR_post(err);
1075+
1076+
ERR_build_status(status_vector, err);
1077+
iscLogStatus(NULL, status_vector);
1078+
return false;
1079+
}
1080+
1081+
10461082
#if !(defined HAVE_PREAD && defined HAVE_PWRITE)
10471083

10481084
/* pread() and pwrite() behave like read() and write() except that they

src/msgs/facilities2.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
22
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
33
--
4-
('2020-11-30 12:20:00', 'JRD', 0, 953)
4+
('2021-03-18 11:20:00', 'JRD', 0, 954)
55
('2015-03-17 18:33:00', 'QLI', 1, 533)
66
('2018-03-17 12:00:00', 'GFIX', 3, 136)
77
('1996-11-07 13:39:40', 'GPRE', 4, 1)

0 commit comments

Comments
 (0)