8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 20:03:03 +01:00
This commit is contained in:
asfernandes 2008-08-29 02:18:50 +00:00
parent 6a7e34c6d6
commit cc5b689eda
8 changed files with 33 additions and 19 deletions

View File

@ -107,13 +107,12 @@ class BaseStream;
// 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.
// 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 SINT128 fake type (a struct, really), double, strings, UCHAR strings,
// counted string and the (non-const) void pointer. Care should be taken to not
// pass something by address (except char* and UCHAR* types) because the compiler
// may route it to the overload for the void pointer and it will be printed as an
// address in hex.
// the SINT128 fake type (a struct, really), double, strings, UCHAR strings and the
// (non-const) void pointer. Care should be taken to not pass something by address
// (except char* and UCHAR* types) because the compiler may route it to the overload
// for the void pointer and it will be printed as an address in hex.
// 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
// or simply constructed as an anonymous object and being filled at the same time

View File

@ -41,7 +41,7 @@ char* dupStringTemp2(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)

View File

@ -281,15 +281,13 @@ static void internal_post(const ISC_STATUS* tmp_status)
i = err_status_len + tmp_status_len;
if (i < ISC_STATUS_LENGTH)
{
memcpy(&status_vector[err_status_len], tmp_status,
sizeof(ISC_STATUS) * tmp_status_len);
memcpy(&status_vector[err_status_len], tmp_status, sizeof(ISC_STATUS) * tmp_status_len);
ERR_make_permanent(&status_vector[err_status_len]);
// copy current warning(s) to the status_vector
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH)
{
memcpy(&status_vector[i - 1], warning_status,
sizeof(ISC_STATUS) * warning_count);
}
}
ERRD_punt();

View File

@ -56,7 +56,8 @@ public:
CircularStringsBuffer() 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 (length > BUFFER_SIZE / 4)
length = BUFFER_SIZE / 4;

View File

@ -943,8 +943,8 @@ void Statement::preprocess(const string& sql, string& ret)
passAsIs = false;
}
else {
passAsIs = !(ident == "INSERT" || ident == "UPDATE" || ident == "DELETE"
|| ident == "MERGE" || ident == "SELECT" || ident == "WITH");
passAsIs = !(ident == "INSERT" || ident == "UPDATE" || ident == "DELETE" ||
ident == "MERGE" || ident == "SELECT" || ident == "WITH");
}
if (passAsIs)

View File

@ -118,7 +118,7 @@ using namespace Firebird;
static jrd_file* seek_file(jrd_file*, BufferDesc*, FB_UINT64*, ISC_STATUS*);
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)
static SLONG pread(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. */
if (desc == -1)
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("raw_devices_validate_database") <<
Arg::Str(file_name) <<
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
}
for (int i = 0; i < IO_RETRY; i++)
{
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
Arg::Str(file_name) <<
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
}
const ssize_t bytes = read (desc, header, sizeof(header));
if (bytes == sizeof(header))
goto read_finished;
if (bytes == -1 && !SYSCALL_INTERRUPTED(errno))
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read") <<
Arg::Str(file_name) <<
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
}
}
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("read_retry") <<
Arg::Str(file_name) <<
@ -1125,9 +1133,11 @@ static bool raw_devices_validate_database(int desc, const PathName& file_name)
read_finished:
/* Rewind file pointer */
if (lseek (desc, LSEEK_OFFSET_CAST 0, 0) == (off_t) -1)
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lseek") <<
Arg::Str(file_name) <<
Arg::Gds(isc_io_read_err) << Arg::Unix(errno));
}
/* Validate database header. Code lifted from PAG_header. */
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)
break;
if (!SYSCALL_INTERRUPTED(errno))
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("open") <<
Arg::Str(file_name) <<
Arg::Gds(isc_io_open_err) << Arg::Unix(errno));
}
}
memset(header, 0xa5, sizeof(header));

View File

@ -571,12 +571,14 @@ jrd_file* PIO_open(Database* dbb,
FILE_ATTRIBUTE_NORMAL |
g_dwExtraFlags, 0);
if (desc == INVALID_HANDLE_VALUE) {
if (desc == INVALID_HANDLE_VALUE)
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("CreateFile (open)") <<
Arg::Str(file_name) <<
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
* 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
@ -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) <<
Arg::Str(file->fil_string) <<
Arg::Gds(operation) << Arg::Windows(GetLastError()));