mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
Misc
This commit is contained in:
parent
6a7e34c6d6
commit
cc5b689eda
@ -107,13 +107,12 @@ class BaseStream;
|
|||||||
|
|
||||||
// This is the main class that does the magic of receiving a chain of type-safe
|
// This is the main class that does the magic of receiving a chain of type-safe
|
||||||
// parameters. All parameters should be appended to it using the << operator.
|
// parameters. All parameters should be appended to it using the << operator.
|
||||||
// Only basic data types are supported, with the exception of length counted strings.
|
// Only basic data types are supported.
|
||||||
// The allowed types are char, UCHAR, all lengths of signed/unsigned integral values,
|
// The allowed types are char, UCHAR, all lengths of signed/unsigned integral values,
|
||||||
// the SINT128 fake type (a struct, really), double, strings, UCHAR strings,
|
// the SINT128 fake type (a struct, really), double, strings, UCHAR strings and the
|
||||||
// counted string and the (non-const) void pointer. Care should be taken to not
|
// (non-const) void pointer. Care should be taken to not pass something by address
|
||||||
// pass something by address (except char* and UCHAR* types) because the compiler
|
// (except char* and UCHAR* types) because the compiler may route it to the overload
|
||||||
// may route it to the overload for the void pointer and it will be printed as an
|
// for the void pointer and it will be printed as an address in hex.
|
||||||
// address in hex.
|
|
||||||
// An object of this class can be created, filled and passed later to the printing
|
// An object of this class can be created, filled and passed later to the printing
|
||||||
// routines, cleaned with clear(), refilled and passed again to the printing routines
|
// routines, cleaned with clear(), refilled and passed again to the printing routines
|
||||||
// or simply constructed as an anonymous object and being filled at the same time
|
// or simply constructed as an anonymous object and being filled at the same time
|
||||||
|
@ -41,7 +41,7 @@ char* dupStringTemp2(const char* s)
|
|||||||
|
|
||||||
ISC_STATUS dupStringTemp(const char* s)
|
ISC_STATUS dupStringTemp(const char* s)
|
||||||
{
|
{
|
||||||
return (ISC_STATUS)(IPTR)(dupStringTemp2(s));
|
return (ISC_STATUS)(IPTR) dupStringTemp2(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_status(ISC_STATUS* ptr, const ISC_STATUS* orig_status)
|
void fill_status(ISC_STATUS* ptr, const ISC_STATUS* orig_status)
|
||||||
|
@ -281,15 +281,13 @@ static void internal_post(const ISC_STATUS* tmp_status)
|
|||||||
i = err_status_len + tmp_status_len;
|
i = err_status_len + tmp_status_len;
|
||||||
if (i < ISC_STATUS_LENGTH)
|
if (i < ISC_STATUS_LENGTH)
|
||||||
{
|
{
|
||||||
memcpy(&status_vector[err_status_len], tmp_status,
|
memcpy(&status_vector[err_status_len], tmp_status, sizeof(ISC_STATUS) * tmp_status_len);
|
||||||
sizeof(ISC_STATUS) * tmp_status_len);
|
|
||||||
ERR_make_permanent(&status_vector[err_status_len]);
|
ERR_make_permanent(&status_vector[err_status_len]);
|
||||||
// copy current warning(s) to the status_vector
|
// copy current warning(s) to the status_vector
|
||||||
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH)
|
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH)
|
||||||
{
|
{
|
||||||
memcpy(&status_vector[i - 1], warning_status,
|
memcpy(&status_vector[i - 1], warning_status,
|
||||||
sizeof(ISC_STATUS) * warning_count);
|
sizeof(ISC_STATUS) * warning_count);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ERRD_punt();
|
ERRD_punt();
|
||||||
|
@ -56,7 +56,8 @@ public:
|
|||||||
CircularStringsBuffer() throw() { init(); }
|
CircularStringsBuffer() throw() { init(); }
|
||||||
explicit CircularStringsBuffer(MemoryPool&) throw() { init(); }
|
explicit CircularStringsBuffer(MemoryPool&) throw() { init(); }
|
||||||
|
|
||||||
virtual char* alloc(const char* string, size_t& length) {
|
virtual char* alloc(const char* string, size_t& length)
|
||||||
|
{
|
||||||
// if string too long, truncate it
|
// if string too long, truncate it
|
||||||
if (length > BUFFER_SIZE / 4)
|
if (length > BUFFER_SIZE / 4)
|
||||||
length = BUFFER_SIZE / 4;
|
length = BUFFER_SIZE / 4;
|
||||||
|
@ -943,8 +943,8 @@ void Statement::preprocess(const string& sql, string& ret)
|
|||||||
passAsIs = false;
|
passAsIs = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
passAsIs = !(ident == "INSERT" || ident == "UPDATE" || ident == "DELETE"
|
passAsIs = !(ident == "INSERT" || ident == "UPDATE" || ident == "DELETE" ||
|
||||||
|| ident == "MERGE" || ident == "SELECT" || ident == "WITH");
|
ident == "MERGE" || ident == "SELECT" || ident == "WITH");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passAsIs)
|
if (passAsIs)
|
||||||
|
@ -118,7 +118,7 @@ using namespace Firebird;
|
|||||||
|
|
||||||
static jrd_file* seek_file(jrd_file*, BufferDesc*, FB_UINT64*, ISC_STATUS*);
|
static jrd_file* seek_file(jrd_file*, BufferDesc*, FB_UINT64*, ISC_STATUS*);
|
||||||
static jrd_file* setup_file(Database*, const PathName&, int, bool);
|
static jrd_file* setup_file(Database*, const PathName&, int, bool);
|
||||||
static bool unix_error(const TEXT*, const jrd_file*, ISC_STATUS, ISC_STATUS* = 0);
|
static bool unix_error(const TEXT*, const jrd_file*, ISC_STATUS, ISC_STATUS* = NULL);
|
||||||
#if !(defined HAVE_PREAD && defined HAVE_PWRITE)
|
#if !(defined HAVE_PREAD && defined HAVE_PWRITE)
|
||||||
static SLONG pread(int, SCHAR *, SLONG, SLONG);
|
static SLONG pread(int, SCHAR *, SLONG, SLONG);
|
||||||
static SLONG pwrite(int, SCHAR *, SLONG, SLONG);
|
static SLONG pwrite(int, SCHAR *, SLONG, SLONG);
|
||||||
@ -1099,24 +1099,32 @@ static bool raw_devices_validate_database(int desc, const PathName& file_name)
|
|||||||
|
|
||||||
/* Read in database header. Code lifted from PIO_header. */
|
/* Read in database header. Code lifted from PIO_header. */
|
||||||
if (desc == -1)
|
if (desc == -1)
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("raw_devices_validate_database") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("raw_devices_validate_database") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < IO_RETRY; i++)
|
for (int i = 0; i < IO_RETRY; i++)
|
||||||
{
|
{
|
||||||
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
|
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
||||||
|
}
|
||||||
|
|
||||||
const ssize_t bytes = read (desc, header, sizeof(header));
|
const ssize_t bytes = read (desc, header, sizeof(header));
|
||||||
if (bytes == sizeof(header))
|
if (bytes == sizeof(header))
|
||||||
goto read_finished;
|
goto read_finished;
|
||||||
|
|
||||||
if (bytes == -1 && !SYSCALL_INTERRUPTED(errno))
|
if (bytes == -1 && !SYSCALL_INTERRUPTED(errno))
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read_retry") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read_retry") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
@ -1125,9 +1133,11 @@ static bool raw_devices_validate_database(int desc, const PathName& file_name)
|
|||||||
read_finished:
|
read_finished:
|
||||||
/* Rewind file pointer */
|
/* Rewind file pointer */
|
||||||
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
|
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
|
||||||
|
}
|
||||||
|
|
||||||
/* Validate database header. Code lifted from PAG_header. */
|
/* Validate database header. Code lifted from PAG_header. */
|
||||||
if (hp->hdr_header.pag_type != pag_header /*|| hp->hdr_sequence*/)
|
if (hp->hdr_header.pag_type != pag_header /*|| hp->hdr_sequence*/)
|
||||||
@ -1164,11 +1174,14 @@ static int raw_devices_unlink_database(const PathName& file_name)
|
|||||||
{
|
{
|
||||||
if ((desc = open (file_name.c_str(), O_RDWR | O_BINARY)) != -1)
|
if ((desc = open (file_name.c_str(), O_RDWR | O_BINARY)) != -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!SYSCALL_INTERRUPTED(errno))
|
if (!SYSCALL_INTERRUPTED(errno))
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("open") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("open") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_open_err) << Arg::Unix(errno));
|
Arg::Gds(isc_io_open_err) << Arg::Unix(errno));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memset(header, 0xa5, sizeof(header));
|
memset(header, 0xa5, sizeof(header));
|
||||||
|
|
||||||
|
@ -571,12 +571,14 @@ jrd_file* PIO_open(Database* dbb,
|
|||||||
FILE_ATTRIBUTE_NORMAL |
|
FILE_ATTRIBUTE_NORMAL |
|
||||||
g_dwExtraFlags, 0);
|
g_dwExtraFlags, 0);
|
||||||
|
|
||||||
if (desc == INVALID_HANDLE_VALUE) {
|
if (desc == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("CreateFile (open)") <<
|
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("CreateFile (open)") <<
|
||||||
Arg::Str(file_name) <<
|
Arg::Str(file_name) <<
|
||||||
Arg::Gds(isc_io_open_err) << Arg::Windows(GetLastError()));
|
Arg::Gds(isc_io_open_err) << Arg::Windows(GetLastError()));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
/* If this is the primary file, set Database flag to indicate that it is
|
/* If this is the primary file, set Database flag to indicate that it is
|
||||||
* being opened ReadOnly. This flag will be used later to compare with
|
* being opened ReadOnly. This flag will be used later to compare with
|
||||||
* the Header Page flag setting to make sure that the database is set
|
* the Header Page flag setting to make sure that the database is set
|
||||||
@ -1123,7 +1125,8 @@ static bool nt_error(TEXT* string,
|
|||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
if (status_vector) {
|
if (status_vector)
|
||||||
|
{
|
||||||
ERR_build_status(status_vector, Arg::Gds(isc_io_error) << Arg::Str(string) <<
|
ERR_build_status(status_vector, Arg::Gds(isc_io_error) << Arg::Str(string) <<
|
||||||
Arg::Str(file->fil_string) <<
|
Arg::Str(file->fil_string) <<
|
||||||
Arg::Gds(operation) << Arg::Windows(GetLastError()));
|
Arg::Gds(operation) << Arg::Windows(GetLastError()));
|
||||||
|
Loading…
Reference in New Issue
Block a user