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

General cleanup

This commit is contained in:
robocop 2003-12-22 10:00:59 +00:00
parent 4483854e1d
commit ad0b5c4de3
100 changed files with 3234 additions and 3497 deletions

View File

@ -24,7 +24,7 @@
//
//____________________________________________________________
//
// $Id: alice.cpp,v 1.46 2003-12-14 04:44:46 skidder Exp $
// $Id: alice.cpp,v 1.47 2003-12-22 09:59:55 robocop Exp $
//
// 2001.07.06 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
// conditionals, as the engine now fully supports
@ -418,7 +418,8 @@ int common_main(int argc,
if (!(tdgbl->ALICE_data.ua_transaction = atoi(string))) {
if (strcmp(string, "all")) {
ALICE_error(10); // msg 10: transaction number or "all" required
} else {
}
else {
switches |= sw_list;
}
}
@ -433,7 +434,8 @@ int common_main(int argc,
tdgbl->ALICE_data.ua_force = true;
} else if (!strcmp(string, ALICE_SW_ASYNC)) {
tdgbl->ALICE_data.ua_force = false;
} else {
}
else {
ALICE_error(11); // msg 11: "sync" or "async" required
}
}
@ -445,7 +447,8 @@ int common_main(int argc,
ALICE_down_case(*argv++, string, sizeof(string));
if (!strcmp(string, "full")) {
tdgbl->ALICE_data.ua_use = true;
} else if (!strcmp(string, "reserve")) {
}
else if (!strcmp(string, "reserve")) {
tdgbl->ALICE_data.ua_use = false;
} else {
ALICE_error(12); // msg 12: "full" or "reserve" required
@ -502,7 +505,8 @@ int common_main(int argc,
ALICE_down_case(*argv++, string, sizeof(string));
if (!strcmp(string, ALICE_SW_MODE_RO)) {
tdgbl->ALICE_data.ua_read_only = true;
} else if (!strcmp(string, ALICE_SW_MODE_RW)) {
}
else if (!strcmp(string, ALICE_SW_MODE_RW)) {
tdgbl->ALICE_data.ua_read_only = false;
} else {
ALICE_error(110); // msg 110: "read_only" or "read_write" required

View File

@ -37,7 +37,7 @@
*/
/*
$Id: backup.epp,v 1.46 2003-12-03 08:19:00 robocop Exp $
$Id: backup.epp,v 1.47 2003-12-22 10:00:00 robocop Exp $
*/
#include "firebird.h"
@ -87,13 +87,13 @@ inline void put(tgbl* tdgbl, UCHAR c)
MVOL_write(c, &tdgbl->io_cnt, &tdgbl->io_ptr);
}
inline const UCHAR* put_block(tgbl* tdgbl, const UCHAR *p, ULONG n)
inline const UCHAR* put_block(tgbl* tdgbl, const UCHAR* p, ULONG n)
{
return MVOL_write_block (tdgbl, p, n);
}
void compress(const UCHAR *, ULONG);
void compress(const UCHAR*, ULONG);
int copy(const TEXT *, TEXT *, ULONG);
BURP_FLD get_fields(BURP_REL);
SINT64 get_gen_id(const TEXT *, SSHORT);
@ -250,7 +250,6 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name)
*
**************************************/
ISC_STATUS_ARRAY status_vector;
ULONG l;
TEXT temp[GDS_NAME_LEN];
TGBL tdgbl = GET_THREAD_DATA;
@ -429,7 +428,7 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$SECURITY_CLASSES WITH X.RDB$SECURITY_CLASS NOT STARTING "SQL$"
put(tdgbl, rec_security_class);
l = PUT_TEXT (att_class_security_class, X.RDB$SECURITY_CLASS);
const ULONG l = PUT_TEXT (att_class_security_class, X.RDB$SECURITY_CLASS);
MISC_terminate (X.RDB$SECURITY_CLASS, temp, l, sizeof(temp));
BURP_verbose (155, temp, NULL, NULL, NULL, NULL);
// msg 155 writing security class %s
@ -481,7 +480,8 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name)
SLONG tempcount = cumul_count;
BURP_verbose(176, (void*) tempcount, NULL, NULL, NULL, NULL);
// msg 176 closing file, committing, and finishing. %ld bytes written
} else {
}
else {
char psz[64];
ib_sprintf(psz, "%" QUADFORMAT "d", cumul_count);
BURP_verbose(283, psz, NULL, NULL, NULL, NULL);
@ -509,7 +509,7 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name)
namespace // unnamed, private
{
void compress(const UCHAR * data, ULONG length)
void compress(const UCHAR* data, ULONG length)
{
/**************************************
*
@ -523,9 +523,9 @@ void compress(const UCHAR * data, ULONG length)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
const UCHAR *p = data;
const UCHAR *end = p + length;
const UCHAR *q = NULL;
const UCHAR* p = data;
const UCHAR* end = p + length;
const UCHAR* q = NULL;
while (p < end)
{
@ -566,7 +566,7 @@ void compress(const UCHAR * data, ULONG length)
}
int copy( const TEXT * from, TEXT * to, ULONG size_len)
int copy( const TEXT* from, TEXT* to, ULONG size_len)
{
/**************************************
*
@ -580,7 +580,7 @@ int copy( const TEXT * from, TEXT * to, ULONG size_len)
*
**************************************/
ULONG l = (ULONG) symbol_length (from, size_len);
const ULONG l = (ULONG) symbol_length (from, size_len);
MOVE_FAST(from, to, l);
*(to + l) = '\0';
@ -908,14 +908,11 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
*
**************************************/
UCHAR blr_buffer[100]; // enough to fit blr
SLONG read_msg0;
SINT64 read_msg1;
ISC_STATUS_ARRAY status_vector;
TGBL tdgbl = GET_THREAD_DATA;
FRBRD *gen_id_reqh = NULL;
UCHAR *blr = blr_buffer;
FRBRD* gen_id_reqh = NULL;
UCHAR* blr = blr_buffer;
/* If this is ODS 10 (IB version 6.0) or greater, build BLR to retrieve
the 64-bit value of the generator. If not, build BLR to retrieve the
@ -938,7 +935,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
stuff(&blr, name_len);
while (name_len--)
{
UCHAR c = *name++;
const UCHAR c = *name++;
stuff(&blr, c);
}
stuff(&blr, blr_literal);
@ -969,7 +966,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
stuff(&blr, name_len);
while (name_len--)
{
UCHAR c = *name++;
const UCHAR c = *name++;
stuff(&blr, c);
}
stuff(&blr, blr_literal);
@ -986,11 +983,11 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
#ifdef DEBUG
if (debug_on)
isc_print_blr((char*)blr_buffer, NULL, NULL, 0);
isc_print_blr((const char*)blr_buffer, NULL, NULL, 0);
#endif
SSHORT blr_length = blr - blr_buffer;
ISC_STATUS_ARRAY status_vector;
const SSHORT blr_length = blr - blr_buffer;
if (isc_compile_request(status_vector, &DB, &gen_id_reqh,
blr_length, (const char*) blr_buffer))
{
@ -1006,6 +1003,8 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
// msg 25 Failed in put_blr_gen_id
}
SINT64 read_msg1;
if (tdgbl->BCK_capabilities & BCK_ods10)
{
if (isc_receive(status_vector, &gen_id_reqh, 0, sizeof(read_msg1),
@ -1017,6 +1016,7 @@ SINT64 get_gen_id( const TEXT* name, SSHORT name_len)
}
else
{
SLONG read_msg0;
if (isc_receive(status_vector, &gen_id_reqh, 0, sizeof(read_msg0),
&read_msg0, 0))
{
@ -1047,7 +1047,7 @@ void get_ranges( BURP_FLD field)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
SLONG *rp = field->fld_ranges;
SLONG* rp = field->fld_ranges;
USHORT count = 0;
/* Get the array dimensions in the rdb$field_dimensions */
@ -1087,7 +1087,6 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
* Write out an array. If, however, it's null, don't even bother.
*
**************************************/
ISC_STATUS_ARRAY status_vector;
SLONG range_buffer[16]; // enough for 16 dimensions
UCHAR blr_buffer[200]; // enough for a sdl with 16 dimensions
@ -1101,8 +1100,8 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
LSTRING xdr_buffer;
xdr_buffer.lstr_allocated = 0;
UCHAR *blr = blr_buffer;
SLONG *end_ranges = field->fld_ranges + 2 * field->fld_dimensions;
UCHAR* blr = blr_buffer;
const SLONG* const end_ranges = field->fld_ranges + 2 * field->fld_dimensions;
USHORT field_length = field->fld_length;
if (tdgbl->gbl_sw_transportable)
@ -1137,7 +1136,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
stuff_word(&blr, field->fld_id);
USHORT count;
SLONG *range;
const SLONG* range; // used in multiple loops.
for (range = field->fld_ranges, count = 0; range < end_ranges;
range += 2, count++)
{
@ -1168,7 +1167,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
PRETTY_print_sdl(blr_buffer, NULL, NULL, 0);
#endif
USHORT blr_length = blr - blr_buffer;
const USHORT blr_length = blr - blr_buffer;
/* compute the range size for each dimension = high_range - low_range */
@ -1189,6 +1188,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
xdr_buffer.lstr_allocated = xdr_buffer.lstr_length;
}
ISC_STATUS_ARRAY status_vector;
ULONG return_length = 0;
if (isc_get_slice(status_vector, &DB, &gds_trans, blob_id,
blr_length, (const char*) blr_buffer,
@ -1212,7 +1212,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
if (return_length != slice_length)
{
int divisor, i1, i2, i3;
int i1, i3;
/* Ugh. The full array wasn't returned. We must recompute the top
element to backup. */
@ -1222,11 +1222,13 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
for (i1 = 0, i3 = 0, range = end_ranges - 2;
range >= field->fld_ranges; range -= 2, returned_range++, i1++)
{
divisor = 1;
for (i2 = (2 * (i1 + 1) + 1); i2 <= field->fld_dimensions * 2;
int divisor = 1;
for (int i2 = (2 * (i1 + 1) + 1); i2 <= field->fld_dimensions * 2;
i2 += 2)
{
divisor *=
(field->fld_ranges[i2] - field->fld_ranges[i2 - 1] + 1);
}
*returned_range =
(returned_elements - 1) / divisor + field->fld_ranges[i3];
returned_elements -=
@ -1285,7 +1287,7 @@ void put_array( BURP_FLD field, BURP_REL relation, ISC_QUAD * blob_id)
}
void put_asciz( const SCHAR attribute, const TEXT * string)
void put_asciz( const SCHAR attribute, const TEXT* string)
{
/**************************************
*
@ -1304,7 +1306,7 @@ void put_asciz( const SCHAR attribute, const TEXT * string)
put(tdgbl, (UCHAR) (attribute));
put(tdgbl, (UCHAR) (l));
if (l)
put_block(tdgbl, (UCHAR*) string, l);
put_block(tdgbl, (const UCHAR*) string, l);
}
@ -1467,14 +1469,14 @@ bool put_blr_blob( SCHAR attribute, ISC_QUAD * blob_id)
ULONG length = 0;
USHORT max_segment = 0;
UCHAR *p = blob_info;
const UCHAR* p = blob_info;
UCHAR item;
while ((item = *p++) != isc_info_end)
{
USHORT l = (USHORT) isc_vax_integer((char*) p, 2);
const USHORT l = (USHORT) isc_vax_integer((const char*) p, 2);
p += 2;
USHORT n = (USHORT) isc_vax_integer((char*) p, l);
const USHORT n = (USHORT) isc_vax_integer((const char*) p, l);
p += l;
switch (item)
{
@ -1552,7 +1554,6 @@ void put_data(BURP_REL relation)
*
**************************************/
BURP_FLD field;
UCHAR *p, *blr, *blr_buffer;
ISC_STATUS_ARRAY status_vector;
TGBL tdgbl = GET_THREAD_DATA;
@ -1573,8 +1574,8 @@ void put_data(BURP_REL relation)
/* Time to generate blr to fetch data. Make sure we allocate a BLR buffer
large enough to handle the per field overhead */
blr = blr_buffer = BURP_alloc(200 + field_count * 9);
UCHAR* const blr_buffer = BURP_alloc(200 + field_count * 9);
UCHAR* blr = blr_buffer;
stuff(&blr, blr_version4);
stuff(&blr, blr_begin);
stuff(&blr, blr_message);
@ -1755,20 +1756,20 @@ void put_data(BURP_REL relation)
#ifdef DEBUG
if (debug_on)
isc_print_blr((char*)blr_buffer, NULL, NULL, 0);
isc_print_blr((const char*)blr_buffer, NULL, NULL, 0);
#endif
// Compile request
FRBRD *request = NULL;
FRBRD* request = NULL;
SSHORT blr_length = blr - blr_buffer;
if (isc_compile_request(status_vector, &DB, &request,
blr_length, (const SCHAR*) blr_buffer))
{
BURP_error_redirect(status_vector, 27, NULL, NULL);
// msg 27 isc_compile_request failed
isc_print_blr((char*) blr_buffer, (isc_callback)NULL, NULL, 0);
isc_print_blr((const char*) blr_buffer, NULL, NULL, 0);
}
BURP_free(blr_buffer);
@ -1785,8 +1786,8 @@ void put_data(BURP_REL relation)
/* Here is the crux of the problem -- writing data. All this work
for the following small loop. */
UCHAR *buffer = BURP_alloc(length);
SSHORT *eof = (SSHORT *) (buffer + eof_offset);
UCHAR* buffer = BURP_alloc(length);
SSHORT* eof = (SSHORT *) (buffer + eof_offset);
// the XDR representation may be even fluffier
LSTRING xdr_buffer;
@ -1816,6 +1817,7 @@ void put_data(BURP_REL relation)
put(tdgbl, (UCHAR) (rec_data));
put_numeric(att_data_length, record_length);
const UCHAR* p;
if (tdgbl->gbl_sw_transportable)
{
record_length =
@ -1885,7 +1887,7 @@ void put_index( BURP_REL relation)
* index exist.
*
**************************************/
ULONG l, count;
ULONG count;
TEXT temp[GDS_NAME_LEN];
TGBL tdgbl = GET_THREAD_DATA;
@ -1927,7 +1929,7 @@ void put_index( BURP_REL relation)
}
put(tdgbl, rec_index);
l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
const ULONG l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
MISC_terminate (X.RDB$INDEX_NAME, temp, l, sizeof(temp));
BURP_verbose (151, temp, NULL, NULL, NULL, NULL);
// msg 151 writing index %s
@ -2004,7 +2006,7 @@ void put_index( BURP_REL relation)
}
put(tdgbl, rec_index);
l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
const ULONG l = PUT_TEXT (att_index_name, X.RDB$INDEX_NAME);
MISC_terminate (X.RDB$INDEX_NAME, temp, l, sizeof(temp));
BURP_verbose (151, temp, NULL, NULL, NULL, NULL);
// msg 151 writing index %s
@ -2062,7 +2064,7 @@ void put_index( BURP_REL relation)
}
int put_message( SCHAR attribute, const TEXT * text, ULONG length)
int put_message( SCHAR attribute, const TEXT* text, ULONG length)
{
/**************************************
*
@ -2084,7 +2086,7 @@ int put_message( SCHAR attribute, const TEXT * text, ULONG length)
TGBL tdgbl = GET_THREAD_DATA;
ULONG l = 0;
for (const TEXT *p = text; *p && l < length; p++)
for (const TEXT* p = text; *p && l < length; p++)
l++;
l = length = MIN(l, length);
@ -2112,11 +2114,11 @@ void put_numeric( SCHAR attribute, SLONG value)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
SLONG vax_value = (SLONG) isc_vax_integer((char*) &value, sizeof(value));
const SLONG vax_value = (SLONG) isc_vax_integer((const char*) &value, sizeof(value));
put(tdgbl, (UCHAR) (attribute));
put(tdgbl, (UCHAR) sizeof(value));
put_block(tdgbl, (UCHAR *) &vax_value, sizeof(vax_value));
put_block(tdgbl, (const UCHAR*) &vax_value, sizeof(vax_value));
}
@ -2137,12 +2139,12 @@ void put_int64( SCHAR attribute, SINT64 value)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
UINT64 le_value =
(UINT64) isc_portable_integer((UCHAR*) &value, sizeof(value));
const UINT64 le_value =
(UINT64) isc_portable_integer((const UCHAR*) &value, sizeof(value));
put(tdgbl, (UCHAR) (attribute));
put(tdgbl, (UCHAR) (sizeof(value)));
put_block(tdgbl, (UCHAR *) &le_value, sizeof(le_value));
put_block(tdgbl, (const UCHAR*) &le_value, sizeof(le_value));
}
@ -2159,7 +2161,6 @@ void put_relation( BURP_REL relation)
*
**************************************/
TEXT temp[GDS_NAME_LEN];
USHORT l;
TGBL tdgbl = GET_THREAD_DATA;
@ -2176,7 +2177,7 @@ void put_relation( BURP_REL relation)
for (field = fields; field = fields;)
{
fields = field->fld_next;
l = field->fld_length;
USHORT l = field->fld_length;
if (field->fld_type == blr_varying)
l += sizeof(USHORT);
if (!(l & 7))
@ -2238,7 +2239,7 @@ void put_relation( BURP_REL relation)
for (field = relation->rel_fields; field; field = field->fld_next)
{
put(tdgbl, (UCHAR) (rec_field));
l = PUT_TEXT(att_field_name, field->fld_name);
const USHORT l = PUT_TEXT(att_field_name, field->fld_name);
MISC_terminate(field->fld_name, temp, l, sizeof(temp));
BURP_verbose(144, temp, NULL, NULL, NULL, NULL);
// msg 144 writing field %s
@ -2285,7 +2286,7 @@ void put_relation( BURP_REL relation)
if (field->fld_flags & FLD_array)
{
put_numeric(att_field_dimensions, field->fld_dimensions);
SLONG *rp = field->fld_ranges;
const SLONG* rp = field->fld_ranges;
for (USHORT n = field->fld_dimensions; n; rp += 2, n--)
{
put_numeric(att_field_range_low, *rp);
@ -2379,14 +2380,14 @@ bool put_source_blob(SCHAR attribute,
SLONG length = 0;
USHORT max_segment = 0, num_seg = 0;
UCHAR *p = blob_info;
const UCHAR* p = blob_info;
UCHAR item;
while ((item = *p++) != isc_info_end)
{
USHORT l = (USHORT) isc_vax_integer((SCHAR*) p, 2);
const USHORT l = (USHORT) isc_vax_integer((const SCHAR*) p, 2);
p += 2;
USHORT n = (USHORT) isc_vax_integer((SCHAR*) p, l);
const USHORT n = (USHORT) isc_vax_integer((const SCHAR*) p, l);
p += l;
switch (item)
{
@ -2456,7 +2457,7 @@ bool put_source_blob(SCHAR attribute,
}
int put_text( SCHAR attribute, const TEXT * text, SSHORT size_len)
int put_text( SCHAR attribute, const TEXT* text, SSHORT size_len)
{
/**************************************
*
@ -2474,12 +2475,12 @@ int put_text( SCHAR attribute, const TEXT * text, SSHORT size_len)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
SSHORT l = (SSHORT) symbol_length (text, (ULONG) size_len);
const SSHORT l = (SSHORT) symbol_length (text, (ULONG) size_len);
put(tdgbl, (UCHAR) (attribute));
put(tdgbl, (UCHAR) (l));
if (l)
put_block(tdgbl, (UCHAR*) text, l);
put_block(tdgbl, (const UCHAR*) text, l);
return l;
}
@ -2502,7 +2503,7 @@ void set_capabilities(void)
**************************************/
TGBL tdgbl = GET_THREAD_DATA;
FRBRD *req = NULL;
FRBRD* req = NULL;
// Look for desireable fields in system relations
@ -2545,7 +2546,7 @@ int symbol_length( const TEXT * symbol, ULONG size_len)
--size_len;
const TEXT* p = symbol;
const TEXT* q = p + size_len;
const TEXT* const q = p + size_len;
while (*p && p < q) { // find end of string (null or end).
p++;
@ -2711,11 +2712,12 @@ void write_database( const TEXT* dbb_file)
}
USHORT page_size = 0, forced_writes, no_reserve,
length, SQL_dialect, db_read_only;
SQL_dialect, db_read_only;
ULONG sweep_interval, page_buffers;
for (SCHAR *d = buffer; *d != isc_info_end; d += length)
USHORT length = 0;
for (const SCHAR* d = buffer; *d != isc_info_end; d += length)
{
SCHAR item = *d++;
const SCHAR item = *d++;
length = (USHORT) isc_vax_integer(d, 2);
d += 2;
switch (item)
@ -2749,7 +2751,7 @@ void write_database( const TEXT* dbb_file)
break;
case isc_info_error: // old server does not understand new isc_info
break; // parametere and returns isc_info_error. skip it
break; // parameter and returns isc_info_error. skip it
case isc_info_db_sql_dialect:
SQL_dialect = (USHORT) isc_vax_integer(d, length);
@ -2868,7 +2870,7 @@ void write_exceptions(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$EXCEPTIONS
put(tdgbl, rec_exception);
SSHORT l = PUT_TEXT (att_exception_name, X.RDB$EXCEPTION_NAME);
const SSHORT l = PUT_TEXT (att_exception_name, X.RDB$EXCEPTION_NAME);
MISC_terminate (X.RDB$EXCEPTION_NAME, temp, l, sizeof(temp));
BURP_verbose (198, temp, NULL, NULL, NULL, NULL);
// msg 198 writing exception %s
@ -2938,7 +2940,7 @@ void write_filters(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$FILTERS
put(tdgbl, rec_filter);
SSHORT l = PUT_TEXT (att_filter_name, X.RDB$FUNCTION_NAME);
const SSHORT l = PUT_TEXT (att_filter_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (145, temp, NULL, NULL, NULL, NULL);
// msg 145 writing filter %s
@ -2978,7 +2980,7 @@ void write_functions(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$FUNCTIONS
put(tdgbl, rec_function);
SSHORT l = PUT_TEXT (att_function_name, X.RDB$FUNCTION_NAME);
const SSHORT l = PUT_TEXT (att_function_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (147, temp, NULL, NULL, NULL, NULL);
/* msg 147 writing function %.*s */
@ -3029,7 +3031,7 @@ void write_function_args( GDS_NAME funcptr)
X.RDB$FUNCTION_NAME EQ funcptr
put(tdgbl, rec_function_arg);
SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
const SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (141, temp, NULL, NULL, NULL, NULL);
// msg 141 writing argument for function %s
@ -3057,7 +3059,7 @@ void write_function_args( GDS_NAME funcptr)
X.RDB$FUNCTION_NAME EQ funcptr
put(tdgbl, rec_function_arg);
SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
const SSHORT l = PUT_TEXT (att_functionarg_name, X.RDB$FUNCTION_NAME);
MISC_terminate (X.RDB$FUNCTION_NAME, temp, l, sizeof(temp));
BURP_verbose (141, temp, NULL, NULL, NULL, NULL);
// msg 141 writing argument for function %s
@ -3116,7 +3118,7 @@ void write_generators(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$GENERATORS WITH X.RDB$SYSTEM_FLAG MISSING OR X.RDB$SYSTEM_FLAG NE 1
put(tdgbl, rec_generator);
SSHORT l = PUT_TEXT (att_gen_generator, X.RDB$GENERATOR_NAME);
const SSHORT l = PUT_TEXT (att_gen_generator, X.RDB$GENERATOR_NAME);
SINT64 value = 0;
if (!tdgbl->gbl_sw_meta) {
value = get_gen_id (X.RDB$GENERATOR_NAME, l);
@ -3171,7 +3173,7 @@ void write_global_fields(void)
X.RDB$SYSTEM_FLAG MISSING
put(tdgbl, rec_global_field);
SSHORT l = PUT_TEXT (att_field_name, X.RDB$FIELD_NAME);
const SSHORT l = PUT_TEXT (att_field_name, X.RDB$FIELD_NAME);
MISC_terminate (X.RDB$FIELD_NAME, temp, l, sizeof(temp));
BURP_verbose (149, temp, NULL, NULL, NULL, NULL);
/* msg 149 writing global field %.*s */
@ -3235,7 +3237,7 @@ void write_global_fields(void)
X.RDB$SYSTEM_FLAG MISSING
put(tdgbl, rec_global_field);
SSHORT l = PUT_TEXT (att_field_name, X.RDB$FIELD_NAME);
const SSHORT l = PUT_TEXT (att_field_name, X.RDB$FIELD_NAME);
MISC_terminate (X.RDB$FIELD_NAME, temp, l, sizeof(temp));
BURP_verbose (149, temp, NULL, NULL, NULL, NULL);
/* msg 149 writing global field %.*s */
@ -3346,7 +3348,7 @@ void write_procedures(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$PROCEDURES
put(tdgbl, rec_procedure);
SSHORT l = PUT_TEXT (att_procedure_name, X.RDB$PROCEDURE_NAME);
const SSHORT l = PUT_TEXT (att_procedure_name, X.RDB$PROCEDURE_NAME);
MISC_terminate (X.RDB$PROCEDURE_NAME, temp, l, sizeof(temp));
BURP_verbose (193, temp, NULL, NULL, NULL, NULL);
/* msg 193 writing stored procedure %.*s */
@ -3391,7 +3393,7 @@ void write_procedure_prms( GDS_NAME procptr)
FOR (REQUEST_HANDLE tdgbl->handles_write_procedure_prms_req_handle1)
X IN RDB$PROCEDURE_PARAMETERS WITH X.RDB$PROCEDURE_NAME EQ procptr
put(tdgbl, rec_procedure_prm);
SSHORT l = PUT_TEXT (att_procedureprm_name, X.RDB$PARAMETER_NAME);
const SSHORT l = PUT_TEXT (att_procedureprm_name, X.RDB$PARAMETER_NAME);
MISC_terminate (X.RDB$PARAMETER_NAME, temp, l, sizeof(temp));
BURP_verbose (194, temp, NULL, NULL, NULL, NULL);
// msg 194 writing parameter %s for stored procedure
@ -3462,7 +3464,7 @@ void write_rel_constraints(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$RELATION_CONSTRAINTS
put(tdgbl, rec_rel_constraint);
SSHORT l = PUT_TEXT (att_rel_constraint_name, X.RDB$CONSTRAINT_NAME);
const SSHORT l = PUT_TEXT (att_rel_constraint_name, X.RDB$CONSTRAINT_NAME);
MISC_terminate (X.RDB$CONSTRAINT_NAME, temp, l, sizeof(temp));
BURP_verbose (207, temp, NULL, NULL, NULL, NULL);
// msg 207 writing constraint %s
@ -3516,13 +3518,13 @@ void write_relations(void)
SSHORT flags = 0;
put(tdgbl, rec_relation);
SSHORT l = PUT_TEXT (att_relation_name, X.RDB$RELATION_NAME);
const SSHORT l = PUT_TEXT (att_relation_name, X.RDB$RELATION_NAME);
MISC_terminate (X.RDB$RELATION_NAME, temp, l, sizeof(temp));
BURP_verbose (153, temp, NULL, NULL, NULL, NULL);
/* msg 153 writing relation %.*s */
/* RDB$VIEW_BLR must be the first blob field in the backup file.
* RESTORE.E makes this assumption in get_relation().
* RESTORE.EPP makes this assumption in get_relation().
*/
if (put_blr_blob (att_relation_view_blr, (ISC_QUAD *)&X.RDB$VIEW_BLR))
@ -3567,7 +3569,7 @@ void write_relations(void)
SSHORT flags = 0;
put(tdgbl, rec_relation);
SSHORT l = PUT_TEXT(att_relation_name, X.RDB$RELATION_NAME);
const SSHORT l = PUT_TEXT(att_relation_name, X.RDB$RELATION_NAME);
MISC_terminate (X.RDB$RELATION_NAME, temp, l, sizeof(temp));
BURP_verbose (153, temp, NULL, NULL, NULL, NULL);
/* msg 153 writing relation %.*s */
@ -3666,7 +3668,7 @@ void write_shadow_files(void)
WITH X.RDB$SHADOW_NUMBER NOT MISSING
AND X.RDB$SHADOW_NUMBER NE 0
put(tdgbl, rec_files);
SSHORT l = PUT_TEXT (att_file_filename, X.RDB$FILE_NAME);
const SSHORT l = PUT_TEXT (att_file_filename, X.RDB$FILE_NAME);
MISC_terminate (X.RDB$FILE_NAME, temp, l, sizeof(temp));
BURP_verbose (163, temp, NULL, NULL, NULL, NULL);
// msg 163 writing shadow file %s
@ -3706,7 +3708,7 @@ void write_sql_roles(void)
X IN RDB$ROLES
put(tdgbl, rec_sql_roles);
SSHORT l = PUT_TEXT(att_role_name, X.RDB$ROLE_NAME);
const SSHORT l = PUT_TEXT(att_role_name, X.RDB$ROLE_NAME);
PUT_TEXT (att_role_owner_name, X.RDB$OWNER_NAME);
put(tdgbl, att_end);
MISC_terminate (X.RDB$ROLE_NAME, temp, l, sizeof(temp));
@ -3752,7 +3754,7 @@ void write_triggers(void)
X.RDB$SYSTEM_FLAG MISSING
put(tdgbl, rec_trigger);
SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
const SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
MISC_terminate (X.RDB$TRIGGER_NAME, temp, l, sizeof(temp));
BURP_verbose (156, temp, NULL, NULL, NULL, NULL);
// msg 156 writing trigger %s
@ -3784,7 +3786,7 @@ void write_triggers(void)
X.RDB$SYSTEM_FLAG MISSING
put(tdgbl, rec_trigger);
SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
const SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME);
MISC_terminate (X.RDB$TRIGGER_NAME, temp, l, sizeof(temp));
BURP_verbose (156, temp, NULL, NULL, NULL, NULL);
// msg 156 writing trigger %s
@ -3850,7 +3852,7 @@ void write_trigger_messages(void)
WITH T.RDB$SYSTEM_FLAG NE 1 OR T.RDB$SYSTEM_FLAG MISSING;
put(tdgbl, rec_trigger_message);
SSHORT l = PUT_TEXT (att_trigmsg_name, X.RDB$TRIGGER_NAME);
const SSHORT l = PUT_TEXT (att_trigmsg_name, X.RDB$TRIGGER_NAME);
MISC_terminate (X.RDB$TRIGGER_NAME, temp, l, sizeof(temp));
BURP_verbose (157, temp, NULL, NULL, NULL, NULL);
/* msg 157 writing trigger message for *s */
@ -3927,7 +3929,7 @@ void write_user_privileges(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$USER_PRIVILEGES
put(tdgbl, rec_user_privilege);
SSHORT l = PUT_TEXT (att_priv_user, X.RDB$USER);
const SSHORT l = PUT_TEXT (att_priv_user, X.RDB$USER);
MISC_terminate (X.RDB$USER, temp, l, sizeof(temp));
BURP_verbose (152, temp, NULL, NULL, NULL, NULL);
// msg 152 writing privilege for user %s
@ -3950,7 +3952,7 @@ void write_user_privileges(void)
FOR (REQUEST_HANDLE req_handle1)
X IN RDB$USER_PRIVILEGES
put(tdgbl, rec_user_privilege);
SSHORT l = PUT_TEXT (att_priv_user, X.RDB$USER);
const SSHORT l = PUT_TEXT (att_priv_user, X.RDB$USER);
MISC_terminate (X.RDB$USER, temp, l, sizeof(temp));
BURP_verbose (152, temp, NULL, NULL, NULL, NULL);
// msg 152 writing privilege for user %s

View File

@ -156,7 +156,7 @@ static inline void exit_local(int code, TGBL tdgbl)
Firebird::status_exception::raise(1);
}
static int output_svc(svc* output_data, const UCHAR * output_buf)
static int output_svc(svc* output_data, const UCHAR* output_buf)
{
/**************************************
*
@ -186,7 +186,7 @@ int BURP_main(svc* service)
* Entrypoint for GBAK via services manager.
*
**************************************/
int exit_code = common_main(service->svc_argc, service->svc_argv,
const int exit_code = common_main(service->svc_argc, service->svc_argv,
SVC_output, service);
service->svc_handle = 0;
@ -215,18 +215,19 @@ int CLIB_ROUTINE main(int argc, char* argv[])
* Parse and interpret command line, then "do the right thing."
*
**************************************/
TEXT *sw_user, *sw_password, *sw_service;
TEXT *d_user, *d_password, *d_service;
// If a "-service" switch is specified then use Admin APIs
TEXT **argvp = argv;
TEXT **end = argvp + argc;
// If a "-service" switch is specified then use Admin APIs
// The code will alter the command line.
TEXT** argvp = argv;
const TEXT* const* const end = argvp + argc;
argvp++;
// Initialize data
USHORT total = 0;
bool flag_restore, flag_verbose, err;
flag_restore = flag_verbose = err = false;
TEXT *sw_user, *sw_password, *sw_service;
TEXT *d_user, *d_password, *d_service;
sw_user = sw_password = sw_service = d_user = d_password = d_service = NULL;
/* Parse the command line for the -USER, -PASSWORD, -SERVICE,
@ -235,7 +236,7 @@ int CLIB_ROUTINE main(int argc, char* argv[])
while (argvp < end && !err)
{
TEXT *string = *argvp++;
TEXT* string = *argvp++;
if (*string != '-') {
total += strlen(string) + 1;
continue;
@ -279,7 +280,8 @@ int CLIB_ROUTINE main(int argc, char* argv[])
case IN_SW_BURP_SE: // service name
if (argvp >= end) {
err = true;
} else {
}
else {
sw_service = string;
d_service = *argvp++;
}
@ -301,7 +303,7 @@ int CLIB_ROUTINE main(int argc, char* argv[])
* To make this more efficiently the isc_spb_options is used.
* This allows us to skip a conversion from the gbak command line
* switches to service parameter block in here as well as vice versa
* conversion within svc.c
* conversion within svc.cpp
*
* If -USER and -PASSWORD switches are used by the user within
* the gbak command line then we have to eliminate them from there. The
@ -310,6 +312,7 @@ int CLIB_ROUTINE main(int argc, char* argv[])
* the -SERVER switch because the switch has already been processed.
*/
// Warning: altering command line.
if (sw_user)
*sw_user = '\0';
if (sw_password)
@ -344,11 +347,11 @@ static int output_main(svc* output_data, const UCHAR* output_buf)
}
static int api_gbak(int argc,
char *argv[],
char* argv[],
USHORT length,
TEXT * password,
TEXT * user,
TEXT * service,
TEXT* password,
TEXT* user,
TEXT* service,
bool restore,
bool verbose)
{
@ -362,22 +365,19 @@ static int api_gbak(int argc,
* Run gbak using services APIs
*
**********************************************/
ISC_STATUS_ARRAY status;
char sendbuf[] = { isc_info_svc_line };
char respbuf[1024];
tgbl ldgbl;
tgbl* tdgbl = &ldgbl;
SET_THREAD_DATA;
memset((void *) tdgbl, 0, sizeof(tgbl));
tdgbl->output_proc = output_main;
TEXT *usr, *pswd;
const TEXT* usr;
if (!user)
usr = getenv("ISC_USER");
else
usr = user;
const TEXT* pswd;
if (!password)
pswd = getenv("ISC_PASSWORD");
else
@ -397,6 +397,8 @@ static int api_gbak(int argc,
'isc_spb_options'
'length'
"options" */
ISC_STATUS_ARRAY status;
if (spb == NULL) {
status[0] = isc_arg_gds;
status[1] = isc_virmemexh;
@ -406,7 +408,7 @@ static int api_gbak(int argc,
return FINI_ERROR;
}
char *spb_ptr = spb;
char* spb_ptr = spb;
*spb_ptr++ = isc_spb_version;
*spb_ptr++ = isc_spb_current_version;
@ -513,7 +515,9 @@ static int api_gbak(int argc,
return FINI_ERROR;
}
const char *sl;
const char sendbuf[] = { isc_info_svc_line };
char respbuf[1024];
const char* sl;
do {
if (isc_service_query(status, (&svc_handle), NULL, 0, NULL,
sizeof(sendbuf), sendbuf,
@ -528,7 +532,7 @@ static int api_gbak(int argc,
return FINI_ERROR;
}
char *p = respbuf;
char* p = respbuf;
sl = p;
if (*p++ == isc_info_svc_line)
@ -704,10 +708,10 @@ int common_main(int argc,
++argv;
while (argv < end) {
TEXT *string = *argv;
TEXT* string = *argv;
int temp = strlen(string) - 1;
if (string[temp] == ',')
string[temp] = '\0';
string[temp] = '\0'; // Modifying argv elements
if (*string != '-') {
if (!file || file->fil_length || !get_size(*argv, file)) {
@ -913,7 +917,7 @@ int common_main(int argc,
}
// Initialize 'dpb' and 'dpb_length'
// Initialize 'dpb' and 'dpb_length' and cast away volatile
UCHAR* dpb = const_cast<UCHAR*>(tdgbl->dpb_string);
*dpb++ = isc_dpb_version1;
*dpb++ = isc_dpb_gbak_attach;
@ -1421,7 +1425,7 @@ void BURP_msg_get( USHORT number,
}
void BURP_output_version( const TEXT * arg1, TEXT * arg2)
void BURP_output_version(void* arg1, const TEXT* arg2)
{
/**************************************
*
@ -1436,7 +1440,7 @@ void BURP_output_version( const TEXT * arg1, TEXT * arg2)
*
**************************************/
burp_output(arg1, arg2);
burp_output(reinterpret_cast<const char*>(arg1), arg2);
}
@ -1479,10 +1483,10 @@ void BURP_print_status(const ISC_STATUS* status_vector)
*
**************************************/
if (status_vector) {
const ISC_STATUS *vector = status_vector;
const ISC_STATUS* vector = status_vector;
#ifdef SUPERSERVER
TGBL tdgbl = GET_THREAD_DATA;
ISC_STATUS *status = tdgbl->service_blk->svc_status;
ISC_STATUS* status = tdgbl->service_blk->svc_status;
if (status != status_vector) {
int i = 0;
while (*status && (++i < ISC_STATUS_LENGTH))
@ -1614,7 +1618,7 @@ static void close_out_transaction(volatile gbak_action action,
}
static SLONG get_number( const SCHAR * string)
static SLONG get_number( const SCHAR* string)
{
/**************************************
*
@ -1630,7 +1634,7 @@ static SLONG get_number( const SCHAR * string)
SCHAR c;
SLONG value = 0;
for (const SCHAR *p = string; c = *p++;) {
for (const SCHAR* p = string; c = *p++;) {
if (c < '0' || c > '9')
return 0;
value *= 10;
@ -1685,9 +1689,7 @@ static gbak_action open_files(const TEXT* file1,
if (tdgbl->gbl_sw_version) {
// msg 139 Version(s) for database "%s"
BURP_print(139, file1, 0, 0, 0, 0);
isc_version(&tdgbl->db_handle,
reinterpret_cast<void (*)()>(BURP_output_version),
(void*) "\t%s\n");
isc_version(&tdgbl->db_handle, BURP_output_version, "\t%s\n");
}
if (sw_verbose)
BURP_print(166, file1, 0, 0, 0, 0);

View File

@ -63,7 +63,7 @@ static inline void BURP_free(void* block)
}
const int GDS_NAME_LEN = 32;
typedef TEXT GDS_NAME [GDS_NAME_LEN];
typedef TEXT GDS_NAME[GDS_NAME_LEN];
enum redirect_vals {
NOREDIRECT = 0,

View File

@ -40,7 +40,7 @@ void BURP_msg_put(USHORT, const void*, const void*, const void*,
const void*, const void*);
void BURP_msg_get(USHORT, TEXT*, const void*, const void*, const void*,
const void*, const void*);
void BURP_output_version(const TEXT*, TEXT*);
void BURP_output_version(void*, const TEXT*);
void BURP_print(USHORT, const void*, const void*, const void*, const void*, const void*);
void BURP_print_warning(const ISC_STATUS*);
void BURP_verbose(USHORT, const void*, const void*, const void*, const void*, const void*);

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: vector.h,v 1.5 2003-12-05 10:35:29 robocop Exp $
* $Id: vector.h,v 1.6 2003-12-22 10:00:04 robocop Exp $
*
*/
@ -55,11 +55,11 @@ public:
return data[index];
}
T* begin() { return data; }
T* end() { return data+count; }
T* end() { return data + count; }
void insert(int index, const T& item) {
fb_assert(index >= 0 && index <= count);
fb_assert(count < Capacity);
memmove(data+index+1, data+index, sizeof(T)*(count++-index));
memmove(data + index + 1, data + index, sizeof(T) * (count++ - index));
data[index] = item;
}
@ -70,15 +70,15 @@ public:
};
void remove(int index) {
fb_assert(index >= 0 && index < count);
memmove(data+index, data+index+1, sizeof(T)*(--count-index));
memmove(data + index, data + index + 1, sizeof(T) * (--count - index));
}
void shrink(int newCount) {
fb_assert(newCount <= count);
count = newCount;
};
void join(Vector<T,Capacity>& L) {
void join(Vector<T, Capacity>& L) {
fb_assert(count + L.count <= Capacity);
memcpy(data + count, L.data, sizeof(T)*L.count);
memcpy(data + count, L.data, sizeof(T) * L.count);
count += L.count;
}
int getCount() const { return count; }
@ -101,7 +101,7 @@ public:
template <typename T>
class DefaultKeyValue {
public:
static const T& generate(void *sender, const T& Item) { return Item; }
static const T& generate(void* sender, const T& Item) { return Item; }
};
// Fast sorted array of simple objects
@ -113,22 +113,22 @@ class SortedVector : public Vector<Value, Capacity> {
public:
SortedVector() : Vector<Value, Capacity>() {}
bool find(const Key& item, int& pos) {
int highBound=count, lowBound=0;
int highBound = count, lowBound = 0;
while (highBound > lowBound) {
int temp = (highBound + lowBound) >> 1;
if (Cmp::greaterThan(item, KeyOfValue::generate(this,data[temp])))
lowBound = temp+1;
const int temp = (highBound + lowBound) >> 1;
if (Cmp::greaterThan(item, KeyOfValue::generate(this, data[temp])))
lowBound = temp + 1;
else
highBound = temp;
}
pos = lowBound;
return highBound != count &&
!Cmp::greaterThan(KeyOfValue::generate(this,data[lowBound]), item);
!Cmp::greaterThan(KeyOfValue::generate(this, data[lowBound]), item);
}
int add(const Value& item) {
int pos;
find(KeyOfValue::generate(this,item),pos);
insert(pos,item);
find(KeyOfValue::generate(this, item), pos);
insert(pos, item);
return pos;
}
};
@ -136,3 +136,4 @@ public:
};
#endif

View File

@ -84,10 +84,10 @@ static inline ISC_STATUS stuff_sdl_long(gen_t* gen, int word)
}
ISC_STATUS API_ROUTINE isc_array_gen_sdl(ISC_STATUS * status,
ISC_ARRAY_DESC * desc,
SSHORT * sdl_buffer_length,
UCHAR * sdl_buffer, SSHORT * sdl_length)
ISC_STATUS API_ROUTINE isc_array_gen_sdl(ISC_STATUS* status,
const ISC_ARRAY_DESC* desc,
SSHORT* sdl_buffer_length,
UCHAR* sdl_buffer, SSHORT* sdl_length)
{
/**************************************
*
@ -595,20 +595,22 @@ static ISC_STATUS stuff_args(gen_t* gen, SSHORT count, ...)
va_list ptr;
if (gen->gen_sdl + count >= gen->gen_end) {
if (gen->gen_internal < 0)
if (gen->gen_internal < 0) {
return error(gen->gen_status, 3, (ISC_STATUS) isc_misc_interpreted,
(ISC_STATUS) isc_arg_string,
(ISC_STATUS) "SDL buffer overflow");
}
// The sdl buffer is too small. Allocate a larger one.
const SSHORT new_len = gen->gen_end - *gen->gen_sdl_ptr + 512 + count;
UCHAR* const new_sdl = (UCHAR*) gds__alloc(new_len);
if (!new_sdl)
if (!new_sdl) {
return error(gen->gen_status, 5, (ISC_STATUS) isc_misc_interpreted,
(ISC_STATUS) isc_arg_string,
(ISC_STATUS) "SDL buffer overflow", (ISC_STATUS) isc_arg_gds,
(ISC_STATUS) isc_virmemexh);
}
const SSHORT current_len = gen->gen_sdl - *gen->gen_sdl_ptr;
memcpy(new_sdl, *gen->gen_sdl_ptr, current_len);

View File

@ -24,8 +24,8 @@
#ifndef DSQL_ARRAY_PROTO_H
#define DSQL_ARRAY_PROTO_H
ISC_STATUS API_ROUTINE isc_array_gen_sdl(ISC_STATUS *, ISC_ARRAY_DESC *,
SSHORT *, UCHAR *, SSHORT *);
ISC_STATUS API_ROUTINE isc_array_gen_sdl(ISC_STATUS*, const ISC_ARRAY_DESC*,
SSHORT*, UCHAR*, SSHORT*);
ISC_STATUS API_ROUTINE isc_array_get_slice(ISC_STATUS*, void**, void**,
ISC_QUAD*, const ISC_ARRAY_DESC*,
void*, SLONG*);

View File

@ -4730,7 +4730,7 @@ static dsql_req* prepare(
#ifdef DSQL_DEBUG
if (DSQL_debug & 64) {
dsql_trace("Resulting BLR code for DSQL:");
gds__print_blr(reinterpret_cast<UCHAR*>(request->req_blr_string->str_data),
gds__print_blr(reinterpret_cast<const UCHAR*>(request->req_blr_string->str_data),
gds__trace_printer, 0, 0);
}
#endif

View File

@ -133,9 +133,6 @@ dsql_nod* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag)
alignment of node->nod_arg, which is now only guaranteed
4-byte alignment. -- ChrisJ 1999-02-20 */
UINT64 value = 0;
const char* p = constant->str_data;
node->nod_desc.dsc_dtype = dtype_int64;
node->nod_desc.dsc_length = sizeof(SINT64);
node->nod_desc.dsc_scale = 0;
@ -149,6 +146,9 @@ dsql_nod* MAKE_constant(dsql_str* constant, dsql_constant_type numeric_flag)
only if preceded by a '-', but that issue is handled in GEN_expr,
and need not be addressed here. */
UINT64 value = 0;
const char* p = constant->str_data;
while (isdigit(*p))
value = 10 * value + (*(p++) - '0');
if (*p++ == '.') {
@ -488,9 +488,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
dtype = MAX(dtype1, dtype2);
if (DTYPE_IS_BLOB(dtype))
if (DTYPE_IS_BLOB(dtype)) {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607,
isc_arg_gds, isc_dsql_no_blob_array, 0);
}
desc->dsc_flags = (desc1.dsc_flags | desc2.dsc_flags) & DSC_nullable;
switch (dtype) {
@ -528,12 +529,17 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
dtype = dtype1;
else if ((dtype1 == dtype_timestamp) &&
(dtype2 == dtype_sql_date))
{
dtype = dtype_timestamp;
}
else if ((dtype2 == dtype_timestamp) &&
(dtype1 == dtype_sql_date))
{
dtype = dtype_timestamp;
else
}
else {
ERRD_post(isc_expression_eval_err, 0);
}
if (dtype == dtype_sql_date) {
desc->dsc_dtype = dtype_long;
@ -559,9 +565,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
desc->dsc_length = type_lengths[dtype_timestamp];
desc->dsc_scale = 0;
}
else
else {
/* <date> + <date> */
ERRD_post(isc_expression_eval_err, 0);
}
}
else if (DTYPE_IS_DATE(desc1.dsc_dtype) ||
/* <date> +/- <non-date> */
@ -610,9 +617,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
dtype2 = desc2.dsc_dtype;
// Arrays and blobs can never partipate in addition/subtraction
if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype))
if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype)) {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607,
isc_arg_gds, isc_dsql_no_blob_array, 0);
}
/* In Dialect 2 or 3, strings can never partipate in addition / sub
(Use a specific cast instead) */
@ -629,7 +637,8 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
if (DTYPE_IS_EXACT(desc1.dsc_dtype)
&& DTYPE_IS_EXACT(desc2.dsc_dtype)) dtype = dtype_int64;
else if (DTYPE_IS_NUMERIC(desc1.dsc_dtype)
&& DTYPE_IS_NUMERIC(desc2.dsc_dtype)) {
&& DTYPE_IS_NUMERIC(desc2.dsc_dtype))
{
fb_assert(DTYPE_IS_APPROX(desc1.dsc_dtype) ||
DTYPE_IS_APPROX(desc2.dsc_dtype));
dtype = dtype_double;
@ -655,8 +664,9 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
case dtype_sql_date:
case dtype_timestamp:
if ((DTYPE_IS_DATE(dtype1) || (dtype1 == dtype_null)) &&
(DTYPE_IS_DATE(dtype2) || (dtype2 == dtype_null))) {
if ((DTYPE_IS_DATE(dtype1) || (dtype1 == dtype_unknown)) &&
(DTYPE_IS_DATE(dtype2) || (dtype2 == dtype_unknown)))
{
if (node->nod_type == nod_subtract2) {
/* <any date> - <any date> */
/* Legal permutations are:
@ -670,12 +680,17 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
dtype = dtype1;
else if ((dtype1 == dtype_timestamp) &&
(dtype2 == dtype_sql_date))
{
dtype = dtype_timestamp;
}
else if ((dtype2 == dtype_timestamp) &&
(dtype1 == dtype_sql_date))
{
dtype = dtype_timestamp;
else
}
else {
ERRD_post(isc_expression_eval_err, 0);
}
if (dtype == dtype_sql_date) {
desc->dsc_dtype = dtype_long;
@ -701,9 +716,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
desc->dsc_length = type_lengths[dtype_timestamp];
desc->dsc_scale = 0;
}
else
else {
/* <date> + <date> */
ERRD_post(isc_expression_eval_err, 0);
}
}
else if (DTYPE_IS_DATE(desc1.dsc_dtype) ||
/* <date> +/- <non-date> */
@ -763,9 +779,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
MAKE_desc(&desc2, node->nod_arg[1]);
dtype = DSC_multiply_blr4_result[desc1.dsc_dtype][desc2.dsc_dtype];
if (dtype_null == dtype)
if (dtype_unknown == dtype) {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607,
isc_arg_gds, isc_dsql_no_blob_array, 0);
}
desc->dsc_flags = (desc1.dsc_flags | desc2.dsc_flags) & DSC_nullable;
switch (dtype) {
@ -839,9 +856,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
dtype = MAX(dtype1, dtype2);
if (!DTYPE_CAN_DIVIDE(dtype))
if (!DTYPE_CAN_DIVIDE(dtype)) {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607,
isc_arg_gds, isc_dsql_no_blob_array, 0);
}
desc->dsc_dtype = dtype_double;
desc->dsc_length = sizeof(double);
desc->dsc_scale = 0;
@ -877,9 +895,10 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
case nod_negate:
MAKE_desc(desc, node->nod_arg[0]);
if (!DTYPE_CAN_NEGATE(desc->dsc_dtype))
if (!DTYPE_CAN_NEGATE(desc->dsc_dtype)) {
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607,
isc_arg_gds, isc_dsql_no_blob_array, 0);
}
return;
case nod_alias:
@ -1005,7 +1024,8 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
desc->dsc_scale = 0;
desc->dsc_flags = (desc1.dsc_flags & DSC_nullable);
if (*(ULONG *) node->nod_arg[e_extract_part]->nod_desc.dsc_address
== blr_extract_second) {
== blr_extract_second)
{
/* QUADDATE - maybe this should be DECIMAL(6,4) */
desc->dsc_dtype = dtype_long;
desc->dsc_scale = ISC_TIME_SECONDS_PRECISION_SCALE;
@ -1034,9 +1054,9 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
* CHAR(1) CHARACTER SET NONE type.
* No value will ever be sent back, as the value of the select
* will be NULL - this is only for purposes of DESCRIBING
* the statement. Note that this mapping could be done in dsql.c
* the statement. Note that this mapping could be done in dsql.cpp
* as part of the DESCRIBE statement - but I suspect other areas
* of the code would break if this is declared dtype_null.
* of the code would break if this is declared dtype_unknown.
*/
desc->dsc_dtype = dtype_text;
desc->dsc_length = 1;
@ -1066,7 +1086,7 @@ void MAKE_desc(dsc* desc, dsql_nod* node)
* to the type of the existing domain to which a CHECK constraint
* is being added.
*/
fb_assert(node->nod_desc.dsc_dtype != dtype_null);
fb_assert(node->nod_desc.dsc_dtype != dtype_unknown);
if (desc != &node->nod_desc)
*desc = node->nod_desc;
return;
@ -1185,7 +1205,7 @@ void MAKE_desc_from_list(dsc* desc, dsql_nod* node, const TEXT* expression_name)
DTYPE_IS_DATE(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc1.dsc_dtype)))
{
// ERROR !!!!
// Unknown datetype
// Unknown datatype
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804,
isc_arg_gds, isc_dsql_datatype_err, 0);
}
@ -1240,7 +1260,7 @@ void MAKE_desc_from_list(dsc* desc, dsql_nod* node, const TEXT* expression_name)
// currently we can't
//
{
dsc* ptr = &desc1;
const dsc* ptr = &desc1;
const USHORT cnvlength = TEXT_LEN(ptr);
if (cnvlength > maxtextlength) {
maxtextlength = cnvlength;
@ -1567,8 +1587,10 @@ par* MAKE_parameter(dsql_msg* message, bool sqlda_flag, bool null_flag,
if (sqlda_flag) {
if (sqlda_index && !Config::getOldParameterOrdering()) {
parameter->par_index = sqlda_index;
if (message->msg_index < sqlda_index) message->msg_index = sqlda_index;
} else {
if (message->msg_index < sqlda_index)
message->msg_index = sqlda_index;
}
else {
parameter->par_index = ++message->msg_index;
}
}

View File

@ -1885,7 +1885,7 @@ static void convert_dtype( dsql_fld* field, SSHORT field_type)
field->fld_dtype = gds_cvt_blr_dtype[field_type];
field->fld_length = type_lengths[field->fld_dtype];
fb_assert(field->fld_dtype != dtype_null);
fb_assert(field->fld_dtype != dtype_unknown);
}
}

View File

@ -4097,7 +4097,7 @@ static void store_blr( DUDLEY_NOD node, SLONG * blob_id, DUDLEY_REL relation)
GENERATE_blr(&blr, node);
#ifdef DEBUG
gds__print_blr((UCHAR*)blr.str_start, 0, 0, 0);
gds__print_blr((const UCHAR*)blr.str_start, 0, 0, 0);
#endif
handle = create_blob(blob_id, 0, NULL);
length = blr.str_current - blr.str_start;

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: cme.cpp,v 1.20 2003-11-28 06:48:11 robocop Exp $
// $Id: cme.cpp,v 1.21 2003-12-22 10:00:14 robocop Exp $
//
#include "firebird.h"
@ -413,7 +413,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
* will be NULL - this is only for purposes of allocating
* values in the message DESCRIBING
* the statement.
* Other parts of gpre aren't too happy with a dtype_null datatype
* Other parts of gpre aren't too happy with a dtype_unknown datatype
*/
f->fld_dtype = dtype_text;
f->fld_length = 1;
@ -571,7 +571,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
{
dtype_max =
DSC_multiply_result[field1.fld_dtype][field2.fld_dtype];
if (dtype_max == dtype_null)
if (dtype_max == dtype_unknown)
{
CPR_error("Invalid operand used in multiplication");
} else if (dtype_max == DTYPE_CANNOT)
@ -670,7 +670,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
else
dtype_max =
DSC_sub_result[field1.fld_dtype][field2.fld_dtype];
if (dtype_max == dtype_null)
if (dtype_max == dtype_unknown)
CPR_error("Illegal operands used in addition");
else if (dtype_max == DTYPE_CANNOT)
CPR_error("expression evaluation not supported");
@ -766,7 +766,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
{
dtype_max =
DSC_multiply_result[field1.fld_dtype][field2.fld_dtype];
if (dtype_max == dtype_null)
if (dtype_max == dtype_unknown)
CPR_error("Illegal operands used in division");
else if (dtype_max == DTYPE_CANNOT)
CPR_error("expression evaluation not supported");

View File

@ -26,7 +26,7 @@
*
*____________________________________________________________
*
* $Id: gpre_meta_boot.cpp,v 1.35 2003-11-28 06:48:12 robocop Exp $
* $Id: gpre_meta_boot.cpp,v 1.36 2003-12-22 10:00:14 robocop Exp $
*/
#include "firebird.h"
@ -876,11 +876,12 @@ static int upcase(const TEXT* from, TEXT* to)
}
#endif // NOT_USED_OR_REPLACED
ISC_STATUS API_ROUTINE isc_print_blr(SCHAR* blr,
void (*callback) (), void* callback_argument, SSHORT language)
// CVC: Not sure why it's defined here, probably to not depend on jrd/alt.cpp?
ISC_STATUS API_ROUTINE isc_print_blr(const SCHAR* blr,
FPTR_PRINT_CALLBACK callback, void* callback_argument, SSHORT language)
{
return gds__print_blr((UCHAR*) blr,
reinterpret_cast<FPTR_PRINT_CALLBACK>(callback),
return gds__print_blr((const UCHAR*) blr,
callback,
callback_argument, language);
}

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: pretty.cpp,v 1.20 2003-11-28 06:48:12 robocop Exp $
// $Id: pretty.cpp,v 1.21 2003-12-22 10:00:14 robocop Exp $
//
#include "firebird.h"
@ -560,18 +560,16 @@ static int print_char( CTL control, SSHORT offset)
static int print_dyn_verb( CTL control, SSHORT level)
{
int offset, length, size;
UCHAR operator_;
const char *p;
int offset = control->ctl_blr - control->ctl_blr_start;
UCHAR operator_ = BLR_BYTE;
offset = control->ctl_blr - control->ctl_blr_start;
operator_ = BLR_BYTE;
size = FB_NELEM(dyn_table);
if (operator_ > size || operator_ <= 0 || !(p = dyn_table[operator_]))
const char* p;
const int size = FB_NELEM(dyn_table);
if (operator_ > size || operator_ <= 0 || !(p = dyn_table[operator_])) {
return error(control, offset,
"*** dyn operator %d is undefined ***\n",
(int) operator_);
}
indent(control, level);
blr_format(control, p);
@ -579,7 +577,8 @@ static int print_dyn_verb( CTL control, SSHORT level)
PUT_BYTE(' ');
++level;
int length;
switch (operator_) {
case isc_dyn_drop_difference:
case isc_dyn_begin_backup:
@ -604,7 +603,7 @@ static int print_dyn_verb( CTL control, SSHORT level)
PRINT_LINE;
if (length) {
control->ctl_level = level;
gds__print_blr((UCHAR *) control->ctl_blr,
gds__print_blr((const UCHAR*) control->ctl_blr,
print_blr_line, control,
control->ctl_language);
control->ctl_blr += length;
@ -637,9 +636,9 @@ static int print_dyn_verb( CTL control, SSHORT level)
case isc_dyn_del_exception:
if (length = PRINT_WORD)
do
do {
PRINT_CHAR;
while (--length);
} while (--length);
return 0;
case isc_dyn_fld_not_null:
@ -670,9 +669,9 @@ static int print_dyn_verb( CTL control, SSHORT level)
}
if (length = PRINT_WORD)
do
do {
PRINT_CHAR;
while (--length);
} while (--length);
PRINT_LINE;
@ -760,12 +759,10 @@ static int print_line( CTL control, SSHORT offset)
static SLONG print_long( CTL control, SSHORT offset)
{
UCHAR v1, v2, v3, v4;
v1 = BLR_BYTE;
v2 = BLR_BYTE;
v3 = BLR_BYTE;
v4 = BLR_BYTE;
const UCHAR v1 = BLR_BYTE;
const UCHAR v2 = BLR_BYTE;
const UCHAR v3 = BLR_BYTE;
const UCHAR v4 = BLR_BYTE;
sprintf(control->ctl_ptr,
(control->
ctl_language) ? "chr(%d),chr(%d),chr(%d),chr(%d) " :

View File

@ -25,7 +25,7 @@
//
//____________________________________________________________
//
// $Id: sql.cpp,v 1.36 2003-11-28 06:48:12 robocop Exp $
// $Id: sql.cpp,v 1.37 2003-12-22 10:00:14 robocop Exp $
//
#include "firebird.h"
@ -6002,7 +6002,7 @@ static USHORT resolve_dtypes(KWWORDS typ,
"Encountered column type DATE which is ambiguous in dialect %d\n",
sw_sql_dialect);
PAR_error(err_mesg);
return dtype_null; // TMN: FIX FIX
return dtype_unknown; // TMN: FIX FIX
/* return; */
default:
sprintf(err_mesg,
@ -6022,7 +6022,7 @@ static USHORT resolve_dtypes(KWWORDS typ,
"Encountered column type DATE which is ambiguous in dialect %d\n",
sw_sql_dialect);
PAR_error(err_mesg);
return dtype_null; // TMN: FIX FIX
return dtype_unknown; // TMN: FIX FIX
/* return; */
default:
return dtype_sql_date;
@ -6035,7 +6035,7 @@ static USHORT resolve_dtypes(KWWORDS typ,
sprintf(err_mesg,
"Encountered column type TIME which is not supported by pre 6.0 Servers\n");
PAR_error(err_mesg);
return dtype_null; // TMN: FIX FIX
return dtype_unknown; // TMN: FIX FIX
/* return; */
}
else
@ -6052,10 +6052,10 @@ static USHORT resolve_dtypes(KWWORDS typ,
break;
}
//
// TMN: FIX FIX Added "return dtype_null;" to silence compiler, but
// TMN: FIX FIX Added "return dtype_unknown;" to silence compiler, but
// this is really a logic error we have to fix.
//
return dtype_null;
return dtype_unknown;
}

View File

@ -27,7 +27,7 @@
* Mark O'Donohue <mark.odonohue@ludwig.edu.au>
*
*
* $Id: fb_types.h,v 1.34 2003-12-14 04:23:39 skidder Exp $
* $Id: fb_types.h,v 1.35 2003-12-22 10:00:19 robocop Exp $
*
* 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "OS/2" port
*
@ -124,11 +124,11 @@ typedef struct lstring LSTRING;
typedef unsigned char BOOLEAN;
typedef char TEXT; // To be expunged over time
//typedef unsigned char STEXT; Signed text - not used
//typedef unsigned char UTEXT; Unsigned text - not used
typedef unsigned char BYTE; // Unsigned byte - common
//typedef char SBYTE; Signed byte - not used
typedef char TEXT; /* To be expunged over time */
/*typedef unsigned char STEXT; Signed text - not used
typedef unsigned char UTEXT; Unsigned text - not used */
typedef unsigned char BYTE; /* Unsigned byte - common */
/*typedef char SBYTE; Signed byte - not used */
typedef long ISC_STATUS;
typedef long IPTR;
typedef unsigned long U_IPTR;
@ -137,10 +137,10 @@ typedef void (*FPTR_VOID_PTR) (void*);
typedef int (*FPTR_INT) ();
typedef int (*FPTR_INT_VOID_PTR) (void*);
typedef void (*FPTR_PRINT_CALLBACK) (void*, SSHORT, const char*);
#ifdef __cplusplus
// SORT_init uses this signature for a callback
typedef bool (*FPTR_REJECT_DUP_CALLBACK)(const UCHAR*, const UCHAR*, void*);
#endif
/* Used for isc_version */
typedef void (*FPTR_VERSION_CALLBACK)(void*, const char*);
/* Used for isc_que_events and internal functions */
typedef void (*FPTR_EVENT_CALLBACK)(void*, USHORT, const UCHAR*);
// The type of JRD's ERR_post, DSQL's ERRD_post & post_error,
// REMOTE's move_error & GPRE's post_error.

View File

@ -32,3 +32,4 @@ namespace Firebird
};
#endif // FB_VECTOR_H

View File

@ -75,7 +75,8 @@ ISC_STATUS IPI_put_slice(ISC_STATUS*, struct idb**, struct itr**,
struct bid*, USHORT, const UCHAR*, USHORT,
const UCHAR*, SLONG, UCHAR*);
ISC_STATUS IPI_que_events(ISC_STATUS*, struct idb**, SLONG*,
USHORT, const UCHAR*, FPTR_VOID, void*);
USHORT, const UCHAR*,
FPTR_EVENT_CALLBACK, void*);
ISC_STATUS IPI_receive(ISC_STATUS *, struct irq **, SSHORT, USHORT,
UCHAR *, SSHORT
#ifdef SCROLLABLE_CURSORS

View File

@ -271,8 +271,8 @@ typedef struct ivnt {
struct blk ivnt_header;
struct ivnt *ivnt_next;
struct idb *ivnt_idb;
void (*ivnt_ast) ();
void *ivnt_arg;
FPTR_EVENT_CALLBACK ivnt_ast;
void* ivnt_arg;
HWND ivnt_window;
SLONG ivnt_id;
SLONG ivnt_handle;
@ -522,8 +522,8 @@ typedef struct {
UCHAR *ips_db_handle; /* database handle */
ULONG ips_event_id; /* returned event id */
HWND ips_event_hwnd; /* window handle to return to */
UCHAR *ips_ast; /* ast address */
UCHAR *ips_arg; /* ast arg */
FPTR_EVENT_CALLBACK ips_ast; /* ast address */
UCHAR* ips_arg; /* ast arg */
} ips_que_events;
#define IPS_QUEUE_EVENT 0 /* use controller 0 for event */
@ -647,7 +647,7 @@ typedef struct eventq {
struct eventq *evq_next; /* next event */
SLONG evq_id; /* event ID */
USHORT evq_length; /* event length */
TEXT evq_string[1]; /* event string */
UCHAR evq_string[1]; /* event string */
} *EVENTQ;
/* interprocess database thread structure */

View File

@ -2321,7 +2321,8 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
IDB* handle,
SLONG* id,
USHORT length,
const UCHAR* events, void (*ast) (), void* arg)
const UCHAR* events,
FPTR_EVENT_CALLBACK ast, void* arg)
{
/**************************************
*
@ -2355,7 +2356,7 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
comm->ips_operation = op_que_events;
ips = &comm->ips_operations.ips_op_que_evnt;
ips->ips_db_handle = (UCHAR *) (idb->idb_handle);
ips->ips_ast = (UCHAR *) ast;
ips->ips_ast = ast;
ips->ips_arg = (UCHAR *) arg;
IPS_C_IN(comm, ips_event, IPS_QUEUE_EVENT, events, length);
@ -3653,10 +3654,9 @@ static void event_thread(void)
}
if (event) {
if (event->ivnt_ast) {
reinterpret_cast < void (*) (...) >
(*event->ivnt_ast) (event->ivnt_arg,
queued->evq_length,
queued->evq_string);
(*event->ivnt_ast) (event->ivnt_arg,
queued->evq_length,
queued->evq_string);
event->ivnt_id = 0;
}
}

View File

@ -54,7 +54,7 @@ static void end_database(ICC);
static void end_request(ICC);
static void end_statement(ICC);
static void end_transaction(ICC, P_OP);
static void event_ast(IVNT, USHORT, UCHAR *);
static void event_ast(void*, USHORT, const UCHAR*);
static void execute_immediate(ICC, P_OP);
static void execute_statement(ICC, P_OP);
static void fetch(ICC);
@ -1532,7 +1532,7 @@ static void end_transaction( ICC icc, P_OP operation)
}
static void event_ast( IVNT event, USHORT length, UCHAR * data)
static void event_ast(void* event_void, USHORT length, const UCHAR* data)
{
/**************************************
*
@ -1546,7 +1546,7 @@ static void event_ast( IVNT event, USHORT length, UCHAR * data)
**************************************/
COPYDATASTRUCT cpdata;
ULONG result;
IVNT event = reinterpret_cast<IVNT>(event_void);
if (!event->ivnt_ast)
return;
@ -2797,7 +2797,7 @@ static void que_events( ICC icc)
event->ivnt_window = ips->ips_event_hwnd;
event->ivnt_id = ips->ips_event_id;
event->ivnt_ast = (void (*)()) ips->ips_ast;
event->ivnt_ast = ips->ips_ast;
event->ivnt_arg = (void *) ips->ips_arg;
if (!transfer_buffers(icc, comm))
return;
@ -2806,7 +2806,7 @@ static void que_events( ICC icc)
result = GDS_QUE_EVENTS(status_vector, &idb->idb_handle, &event->ivnt_handle,
length, reinterpret_cast<const char*>(events),
reinterpret_cast < void (*)() > (event_ast),
event_ast,
event);
if (!result)
ips->ips_event_id = event->ivnt_handle;

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: show.epp,v 1.30 2003-12-03 08:19:13 robocop Exp $
* $Id: show.epp,v 1.31 2003-12-22 10:00:29 robocop Exp $
* Revision 1.2 2000/11/19 07:02:49 fsg
* Change in show.e to use CHARACTER_LENGTH instead of FIELD_LENGTH in
* SHOW PROCEDURE
@ -68,7 +68,7 @@ extern USHORT minor_ods;
extern bool V4;
extern bool V33;
static void local_fprintf(const char*, const char*);
static void local_fprintf(void*, const char*);
static void remove_delimited_double_quotes(TEXT*);
static void make_priv_string(USHORT, char*);
static processing_state show_all_tables(SSHORT);
@ -1062,7 +1062,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd,
msg_string, FB_VERSION, NULL, NULL, NULL, NULL);
sprintf(Print_buffer, "%s%s", msg_string, NEWLINE);
ISQL_printf(Out, Print_buffer);
isc_version(&DB, (FPTR_VOID) local_fprintf, NULL);
isc_version(&DB, local_fprintf, NULL);
}
else if (!strcmp(cmd[1], "SQL")) {
if (!strcmp(cmd[2], "DIALECT"))
@ -1398,7 +1398,7 @@ processing_state SHOW_metadata(const SCHAR* const* cmd,
}
static void local_fprintf(const char* format,
static void local_fprintf(void* format_ignored,
const char* string)
{
/**************************************

View File

@ -41,10 +41,15 @@
#include "../journal/rebui_proto.h"
#include "../journal/serve_proto.h"
#include "../jrd/gds_proto.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef WIN_NT
#include <io.h>
#endif
bool sw_service_gjrn;
FILE* msg_file;

View File

@ -46,7 +46,7 @@ static struct {
SSHORT SqlType;
SSHORT DataLength;
} DscType2SqlType[] = {
/* dtype_null */ {-1, 0},
/* dtype_unknown */ {-1, 0},
/* dtype_text */ {SQL_TEXT, 0},
/* dtype_cstring */ {-1, 0},
/* dtype_varying */ {SQL_VARYING, 0},

View File

@ -79,7 +79,7 @@ static BOOLEAN get_walinfo(TEXT *);
static void initialize_wal(TDBB, const TEXT*, WIN*, log_info_page*, SSHORT, bool, SBM*);
#ifdef NOT_USED_OR_REPLACED
static void process_log_updater(log_info_page*);
static void process_recovery(TDBB, const TEXT*, WIN*, log_info_page*,
static void process_recovery(TDBB, const TEXT*, WIN*, log_info_page**,
SSHORT, bool, SBM*);
static void set_first_user(LGFILE **, log_info_page*, TEXT *);
#endif
@ -165,7 +165,7 @@ void AIL_checkpoint_finish(
PIO_write(dbb->dbb_file, window.win_bdb, window.win_buffer,
status_vector);
CCH_write_all_shadows(tdbb, 0, window.win_bdb, status_vector, 1, FALSE);
CCH_write_all_shadows(tdbb, 0, window.win_bdb, status_vector, 1, false);
PIO_flush(dbb->dbb_file);
if (dbb->dbb_shadow) {
PIO_flush(dbb->dbb_shadow->sdw_file);
@ -441,11 +441,6 @@ void AIL_enable(
* journal descriptor in ret_journal.
*
**************************************/
LGFILE *log_files[MAX_LOG_FILES];
LGFILE *log_ovflow;
ULONG number;
USHORT jd_len;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
@ -456,6 +451,7 @@ void AIL_enable(
/* check if journal is already enabled */
UCHAR journal_dir[MAXPATHLEN];
USHORT jd_len;
if (PAG_get_clump(HEADER_PAGE, HDR_journal_server, &jd_len, journal_dir)) {
ERR_post(isc_jrn_present, 0);
}
@ -466,6 +462,9 @@ void AIL_enable(
*/
if (!archive) {
LGFILE* log_files[MAX_LOG_FILES];
LGFILE* log_ovflow;
ULONG number;
MET_get_walinfo(tdbb, log_files, &number, &log_ovflow);
for (ULONG i = 0; i < number; i++) {
@ -540,12 +539,8 @@ void AIL_fini()
* Sign off with WAL substem and journal server (if needed).
*
**************************************/
TDBB tdbb;
DBB dbb;
SLONG ret_val;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
if (!dbb->dbb_wal)
return;
@ -557,8 +552,11 @@ void AIL_fini()
if (!dbb->dbb_journal)
return;
if ((ret_val = JRN_fini(tdbb->tdbb_status_vector, &dbb->dbb_journal)) !=
FB_SUCCESS) AIL_process_jrn_error(ret_val);
const SLONG ret_val = JRN_fini(tdbb->tdbb_status_vector, &dbb->dbb_journal);
if (ret_val != FB_SUCCESS)
{
AIL_process_jrn_error(ret_val);
}
dbb->dbb_journal = 0;
}
@ -576,31 +574,11 @@ void AIL_get_file_list(LLS * stack)
* Get list of WAL files to drop
*
**************************************/
DBB dbb;
WALS WAL_segment;
ISC_STATUS_ARRAY status_vector;
SCHAR *curr_name;
SLONG curr_log_partition_offset;
SCHAR *prev_name;
SLONG prev_log_partition_offset;
SLONG log_flags;
SCHAR log_name1[MAXPATHLEN];
SCHAR log_name2[MAXPATHLEN];
SCHAR *temp_name;
SLONG log_seqno;
SLONG log_length;
STR fname;
SCHAR *temp_fname;
SSHORT count;
SSHORT fname_term_length;
LOGF *logf;
dbb = GET_DBB;
DBB dbb = GET_DBB;
if (!dbb->dbb_wal)
return;
WALS WAL_segment;
WALC_acquire(dbb->dbb_wal, &WAL_segment);
/*
@ -608,15 +586,15 @@ void AIL_get_file_list(LLS * stack)
** If yes then put them on stack of files
** to be deleted.
*/
if ((count = WAL_segment->wals_max_logfiles) > 0) {
SSHORT count = WAL_segment->wals_max_logfiles;
if (count > 0) {
while (--count >= 0) {
logf = LOGF_INFO(count);
LOGF* logf = LOGF_INFO(count);
if (logf->logf_flags & LOGF_RAW)
continue;
temp_fname = LOGF_NAME(logf);
fname_term_length = strlen(temp_fname) + 1;
fname = FB_NEW_RPT(*dbb->dbb_permanent, fname_term_length) str();
const char* temp_fname = LOGF_NAME(logf);
const SSHORT fname_term_length = strlen(temp_fname) + 1;
str* fname = FB_NEW_RPT(*dbb->dbb_permanent, fname_term_length) str();
MOVE_FAST(temp_fname, (SCHAR*)fname->str_data, fname_term_length);
LLS_PUSH(fname, stack);
}
@ -628,16 +606,23 @@ void AIL_get_file_list(LLS * stack)
*/
/* WAL_segment->wals_logname is the current log file */
curr_name = log_name1;
prev_name = log_name2;
SCHAR log_name1[MAXPATHLEN];
SCHAR log_name2[MAXPATHLEN] = "";
SCHAR* curr_name = log_name1;
SCHAR* prev_name = log_name2;
strcpy(curr_name, WAL_segment->wals_logname);
curr_log_partition_offset = WAL_segment->wals_log_partition_offset;
SLONG curr_log_partition_offset = WAL_segment->wals_log_partition_offset;
WALC_release(dbb->dbb_wal);
SLONG log_flags;
SLONG log_seqno;
SLONG log_length;
ISC_STATUS_ARRAY status_vector;
if (WALF_get_log_info(status_vector, dbb->dbb_file->fil_string, curr_name,
curr_log_partition_offset, &log_seqno, &log_length,
&log_flags) != FB_SUCCESS) {
&log_flags) != FB_SUCCESS)
{
gds__free((SLONG *) log_name1);
gds__free((SLONG *) log_name2);
return;
@ -645,19 +630,23 @@ void AIL_get_file_list(LLS * stack)
while (true) {
if (!(log_flags & WALFH_RAW)) {
fname_term_length = strlen(curr_name) + 1;
fname = FB_NEW_RPT(*dbb->dbb_permanent, fname_term_length) str();
const SSHORT fname_term_length = strlen(curr_name) + 1;
str* fname = FB_NEW_RPT(*dbb->dbb_permanent, fname_term_length) str();
MOVE_FAST(curr_name, (SCHAR*)fname->str_data, fname_term_length);
LLS_PUSH(fname, stack);
}
SLONG prev_log_partition_offset;
if (WALF_get_next_log_info(status_vector, dbb->dbb_file->fil_string,
curr_name, curr_log_partition_offset,
prev_name, &prev_log_partition_offset,
&log_seqno, &log_length, &log_flags,
-1) != FB_SUCCESS) break;
-1) != FB_SUCCESS)
{
break;
}
temp_name = prev_name;
char* temp_name = prev_name;
prev_name = curr_name;
curr_name = temp_name;
curr_log_partition_offset = prev_log_partition_offset;
@ -683,22 +672,16 @@ void AIL_init(
* If WAL has never been used for the database, do some set up work.
* Perform short term recovery if required.
**************************************/
TDBB tdbb;
DBB dbb;
log_info_page* logp;
TEXT dbname[MAXPATHLEN];
/* null out the sparse bit map */
// null out the sparse bit map
*sbm_rec = (SBM) 0;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
/* Get WAL file name */
dbb->dbb_wal = 0;
TEXT dbname[MAXPATHLEN];
if (file_len) {
MOVE_FAST(filename, dbname, file_len);
dbname[file_len] = 0;
@ -713,6 +696,7 @@ void AIL_init(
WIN window(LOG_PAGE);
WIN* win;
log_info_page* logp;
if (in_win) {
win = in_win;
win->win_flags = 0;
@ -776,16 +760,13 @@ void AIL_init_log_page(log_info_page* logp, SLONG seqno)
* Set all parameters to 0 except the log file
* sequence number which is set to the passed value.
**************************************/
UCHAR *p;
SLONG len;
/* First zero out the whole structure except for the page header portion */
len = sizeof(log_info_page) - sizeof(pag);
p = (UCHAR *) logp + sizeof(pag);
do
SLONG len = sizeof(log_info_page) - sizeof(pag);
UCHAR* p = (UCHAR *) logp + sizeof(pag);
do {
*p++ = 0;
while (--len);
} while (--len);
/* Now set individual fields as appropriate */
@ -799,27 +780,27 @@ void AIL_init_log_page(log_info_page* logp, SLONG seqno)
*p++ = LOG_ctrl_file1;
*p++ = CTRL_FILE_LEN;
len = CTRL_FILE_LEN;
do
do {
*p++ = 0;
while (--len);
} while (--len);
/* Set control point 2 file name */
*p++ = LOG_ctrl_file2;
*p++ = CTRL_FILE_LEN;
len = CTRL_FILE_LEN;
do
do {
*p++ = 0;
while (--len);
} while (--len);
/* Set current log file */
*p++ = LOG_logfile;
*p++ = CTRL_FILE_LEN;
len = CTRL_FILE_LEN;
do
do {
*p++ = 0;
while (--len);
} while (--len);
*p = LOG_end;
@ -839,8 +820,6 @@ void AIL_journal_tid()
* Journal the next transaction id on the header page.
* This will be used at WAL_init and control point time.
**************************************/
JRNDH journal;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
@ -858,6 +837,7 @@ void AIL_journal_tid()
hdr->hdr_bumped_transaction = fake_tid;
JRNDH journal;
journal.jrndh_type = JRNP_DB_HEADER;
journal.jrndh_nti = fake_tid;
journal.jrndh_oit = hdr->hdr_oldest_transaction;
@ -885,7 +865,6 @@ void AIL_process_jrn_error(SLONG ret_val)
* Handle error from a journal call.
*
**************************************/
if (ret_val == FB_FAILURE)
ERR_punt();
else if (ret_val < 0)
@ -1121,18 +1100,14 @@ void AIL_upd_cntrl_pt(
* :: All control point entries are contiguous.
*
**************************************/
log_info_page* logp;
UCHAR *p1, *p2, *p3, *p;
USHORT len;
TDBB tdbb;
tdbb = GET_THREAD_DATA;
TDBB tdbb = GET_THREAD_DATA;
WIN window(LOG_PAGE);
logp = (log_info_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_log);
log_info_page* logp =
(log_info_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_log);
CCH_MARK_MUST_WRITE(tdbb, &window);
UCHAR *p1, *p2, *p3, *p;
p1 = p2 = p3 = 0;
for (p = logp->log_data; (*p != LOG_end); p += 2 + p[1]) {
@ -1168,7 +1143,8 @@ void AIL_upd_cntrl_pt(
*p++ = LOG_ctrl_file2;
p++;
const UCHAR* q = reinterpret_cast<const UCHAR*>(walname);
if ( (len = w_len) )
USHORT len = w_len;
if (len)
do {
*p++ = *q++;
} while (--len);
@ -1182,7 +1158,8 @@ void AIL_upd_cntrl_pt(
p = p3 + 2;
q = reinterpret_cast<const UCHAR*>(walname);
if ( (len = w_len) ) {
len = w_len;
if (len) {
do {
*p++ = *q++;
} while (--len);
@ -1349,17 +1326,13 @@ static BOOLEAN get_walinfo(TEXT * walname)
* FALSE otherwise
*
**************************************/
TDBB tdbb = GET_THREAD_DATA;
WIN window(LOG_PAGE);
log_info_page* logp =
(log_info_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_log);
USHORT len;
WIN window;
log_info_page* logp;
TDBB tdbb;
tdbb = GET_THREAD_DATA;
window.win_page = LOG_PAGE;
window.win_flags = 0;
logp = (log_info_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_log);
if (!PAG_get_clump
(LOG_PAGE, LOG_logfile, &len,
reinterpret_cast < UCHAR * >(walname))) {
@ -1432,13 +1405,9 @@ static void process_log_updater(log_info_page* logp)
* Fixup the log_flags appropriately.
*
**************************************/
SSHORT state;
TDBB tdbb;
TDBB tdbb = GET_THREAD_DATA;
tdbb = GET_THREAD_DATA;
state = TRA_get_state(tdbb, logp->log_mod_tid);
const SSHORT state = TRA_get_state(tdbb, logp->log_mod_tid);
logp->log_mod_tid = 0;
logp->log_mod_tip = 0;
@ -1462,7 +1431,7 @@ static void process_recovery(
TDBB tdbb,
const TEXT* dbname,
WIN* window,
log_info_page* logpp,
log_info_page** logpp,
SSHORT release,
bool activate_shadow, SBM* sbm_rec)
{
@ -1480,23 +1449,19 @@ static void process_recovery(
* user will run in exclusive mode.
*
**************************************/
TEXT root_db[MAXPATHLEN], rwal[MAXPATHLEN];
CP cp1;
log_info_page* logp;
UCHAR *p;
WIN win;
HDR hdr;
SET_TDBB(tdbb);
logp = *logpp;
log_info_page* logp = *logpp;
CP cp1;
cp1.cp_seqno = logp->log_cp_1.cp_seqno;
cp1.cp_offset = logp->log_cp_1.cp_offset;
cp1.cp_p_offset = logp->log_cp_1.cp_p_offset;
UCHAR* p;
for (p = logp->log_data; (*p != LOG_ctrl_file1); p += 2 + p[1]);
TEXT rwal[MAXPATHLEN];
MOVE_FAST((SCHAR*)(p + 2), rwal, logp->log_cp_1.cp_fn_length);
rwal[logp->log_cp_1.cp_fn_length] = 0;
@ -1509,10 +1474,10 @@ static void process_recovery(
if (activate_shadow) {
/* If activating shadow, recovery needs root file name */
win.win_page = HEADER_PAGE;
win.win_flags = 0;
hdr = (HDR) CCH_FETCH(tdbb, &win, LCK_read, pag_header);
WIN win(HEADER_PAGE);
HRD hdr = (HDR) CCH_FETCH(tdbb, &win, LCK_read, pag_header);
for (p = hdr->hdr_data; (*p != HDR_root_file_name); p += 2 + p[1]);
TEXT root_db[MAXPATHLEN];
MOVE_FAST((SCHAR*)(p + 2), root_db, p[1]);
root_db[p[1]] = 0;
CCH_RELEASE(tdbb, &win);
@ -1555,9 +1520,6 @@ static void set_first_user(LGFILE ** log_files, log_info_page* logp, TEXT * waln
* Initialize log page when using the WAL for the first time.
*
**************************************/
SSHORT len;
UCHAR *p;
logp->log_flags &= ~log_add;
logp->log_flags &= ~log_no_ail;
logp->log_file.cp_seqno++;
@ -1571,10 +1533,10 @@ static void set_first_user(LGFILE ** log_files, log_info_page* logp, TEXT * waln
else
strcpy(walname, log_files[0]->lg_name);
len = strlen(walname);
const SSHORT len = strlen(walname);
logp->log_file.cp_fn_length = len;
for (p = logp->log_data; (*p != LOG_end); p += 2 + p[1]) {
for (UCHAR* p = logp->log_data; (*p != LOG_end); p += 2 + p[1]) {
switch (*p) {
case LOG_ctrl_file1:
MOVE_FAST(walname, (SCHAR*)(p + 2), len);

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: all.c
* MODULE: all.cpp
* DESCRIPTION: Internal block allocator
*
* The contents of this file are subject to the Interbase Public
@ -93,9 +93,6 @@ void ALL_check_memory()
* executed.
*
**************************************/
Firebird::vector<JrdMemoryPool*>::iterator itr;
DBB Dbb = GET_DBB;
#ifdef V4_THREADING
@ -103,6 +100,7 @@ void ALL_check_memory()
#endif
// walk through all the pools in the database
Firebird::vector<JrdMemoryPool*>::iterator itr;
for (itr = Dbb->dbb_pools.begin(); itr < Dbb->dbb_pools.end(); ++itr)
{
JrdMemoryPool* pool = *itr;
@ -121,7 +119,7 @@ void ALL_check_memory()
JrdMemoryPool *JrdMemoryPool::createPool(int *cur_mem, int *max_mem) {
DBB dbb = GET_DBB;
JrdMemoryPool *result = (JrdMemoryPool *)internal_create(sizeof(JrdMemoryPool),
JrdMemoryPool* result = (JrdMemoryPool *)internal_create(sizeof(JrdMemoryPool),
cur_mem, max_mem);
result->plb_buckets = NULL;
result->plb_segments = NULL;
@ -134,7 +132,7 @@ JrdMemoryPool *JrdMemoryPool::createPool(int *cur_mem, int *max_mem) {
JrdMemoryPool *JrdMemoryPool::createPool() {
DBB dbb = GET_DBB;
#ifdef SUPERSERVER
JrdMemoryPool *result = (JrdMemoryPool *)internal_create(sizeof(JrdMemoryPool),
JrdMemoryPool* result = (JrdMemoryPool *)internal_create(sizeof(JrdMemoryPool),
(int*)&dbb->dbb_current_memory, (int*)&dbb->dbb_max_memory);
#else
JrdMemoryPool *result = (JrdMemoryPool *)internal_create(sizeof(JrdMemoryPool));
@ -161,7 +159,7 @@ void JrdMemoryPool::noDbbDeletePool(JrdMemoryPool* pool) {
MemoryPool::deletePool(pool);
}
TEXT* ALL_cstring(TEXT* in_string)
TEXT* ALL_cstring(const TEXT* in_string)
{
/**************************************
*
@ -175,14 +173,10 @@ TEXT* ALL_cstring(TEXT* in_string)
* return to the user or where ever.
*
**************************************/
TDBB tdbb;
JrdMemoryPool *pool;
TEXT *p;
size_t length;
TDBB tdbb = GET_THREAD_DATA;
tdbb = GET_THREAD_DATA;
if (!(pool = tdbb->tdbb_default)) {
JrdMemoryPool* pool = tdbb->tdbb_default;
if (!pool) {
if (tdbb->tdbb_transaction)
pool = tdbb->tdbb_transaction->tra_pool;
else if (tdbb->tdbb_request)
@ -194,9 +188,9 @@ TEXT* ALL_cstring(TEXT* in_string)
return NULL;
}
length = strlen(in_string);
p = FB_NEW(*pool) TEXT[length+1];
strcpy(p,in_string);
const size_t length = strlen(in_string);
TEXT* p = FB_NEW(*pool) TEXT[length + 1];
strcpy(p, in_string);
return p;
}
@ -219,9 +213,7 @@ void ALL_fini(void)
* released at the top of this routine.
*
**************************************/
DBB dbb;
dbb = GET_DBB;
DBB dbb = GET_DBB;
/* Don't know if we even need to do this, so it is commented out */
//delete dbb;
@ -243,21 +235,17 @@ void ALL_init(void)
* have been locked before entry.
*
**************************************/
TDBB tdbb;
DBB dbb;
JrdMemoryPool* pool;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
pool = tdbb->tdbb_default = dbb->dbb_permanent;
JrdMemoryPool* pool = tdbb->tdbb_default = dbb->dbb_permanent;
// dbb->dbb_permanent->setExtendSize(PERM_EXTEND_SIZE);
dbb->dbb_pools[0] = pool;
dbb->dbb_bufferpool = JrdMemoryPool::createPool();
// FB_NEW(*pool) JrdMemoryPool(CACH_EXTEND_SIZE);
}
void JrdMemoryPool::ALL_push(BLK object, LLS * stack)
void JrdMemoryPool::ALL_push(BLK object, LLS* stack)
{
/**************************************
*
@ -269,21 +257,17 @@ void JrdMemoryPool::ALL_push(BLK object, LLS * stack)
* Push an object on an LLS stack.
*
**************************************/
TDBB tdbb;
LLS node;
JrdMemoryPool* pool;
TDBB tdbb = GET_THREAD_DATA;
tdbb = GET_THREAD_DATA;
pool = tdbb->tdbb_default;
node = pool->lls_cache.newBlock();
JrdMemoryPool* pool = tdbb->tdbb_default;
lls* node = pool->lls_cache.newBlock();
node->lls_object = object;
node->lls_next = *stack;
*stack = node;
}
BLK JrdMemoryPool::ALL_pop(LLS *stack)
BLK JrdMemoryPool::ALL_pop(LLS* stack)
{
/**************************************
*
@ -296,15 +280,11 @@ BLK JrdMemoryPool::ALL_pop(LLS *stack)
* further use.
*
**************************************/
LLS node;
JrdMemoryPool* pool;
BLK object;
node = *stack;
lls* node = *stack;
*stack = node->lls_next;
object = node->lls_object;
blk* object = node->lls_object;
pool = (JrdMemoryPool*)MemoryPool::blk_pool(node);
JrdMemoryPool* pool = (JrdMemoryPool*)MemoryPool::blk_pool(node);
pool->lls_cache.returnBlock(node);
return object;

View File

@ -29,7 +29,7 @@
#include "../jrd/block_cache.h"
#include "../jrd/lls.h"
TEXT* ALL_cstring(TEXT* in_string);
TEXT* ALL_cstring(const TEXT* in_string);
void ALL_fini(void);
void ALL_init(void);
//void ALL_push(BLK , LLS *);

View File

@ -51,7 +51,7 @@
#if !defined(BOOT_BUILD)
bool is_valid_server(ISC_STATUS* status, const TEXT* server);
#endif
FRBRD *open_security_db(ISC_STATUS*, const TEXT*, const TEXT*, int, const TEXT*);
FRBRD* open_security_db(ISC_STATUS*, const TEXT*, const TEXT*, int, const TEXT*);
void get_security_error(ISC_STATUS*, int);
SLONG API_ROUTINE_VARARG isc_event_block(SCHAR** event_buffer,
@ -127,7 +127,7 @@ SLONG API_ROUTINE_VARARG isc_event_block(SCHAR** event_buffer,
*p++ = 0;
}
return (int) (p - *event_buffer);
return static_cast<SLONG>(p - *event_buffer);
}
@ -489,7 +489,8 @@ ISC_STATUS API_ROUTINE gds__que_events(ISC_STATUS* status_vector,
SLONG* event_id,
SSHORT events_length,
const SCHAR* events,
void (*ast_address) (), void* ast_argument)
FPTR_EVENT_CALLBACK ast_address,
void* ast_argument)
{
return isc_que_events(status_vector, db_handle, event_id, events_length,
events, ast_address, (int *) ast_argument);
@ -642,11 +643,11 @@ int API_ROUTINE gds__get_client_minor_version()
}
ISC_STATUS API_ROUTINE isc_print_blr(const SCHAR* blr,
void (*callback) (),
FPTR_PRINT_CALLBACK callback,
void* callback_argument, SSHORT language)
{
return gds__print_blr(reinterpret_cast<const UCHAR*>(blr),
reinterpret_cast<FPTR_PRINT_CALLBACK>(callback),
callback,
callback_argument, language);
}
@ -722,8 +723,9 @@ SLONG API_ROUTINE isc_interprete_cpp(SCHAR* const buffer,
}
int API_ROUTINE gds__version(
FRBRD **db_handle,
void (*callback) (), void *callback_argument)
FRBRD** db_handle,
FPTR_VERSION_CALLBACK callback,
void* callback_argument)
{
return isc_version(db_handle, callback, callback_argument);
}
@ -814,7 +816,10 @@ int API_ROUTINE isc_blob_edit(
name_length);
}
int API_ROUTINE isc_add_user(ISC_STATUS* status, USER_SEC_DATA* user_data)
// CVC: Who was the genius that named the input param "user_data" when the
// function uses "struct user_data userInfo" to define a different variable type
// only few lines below? Same for the other two isc_*_user functions.
ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* input_user_data)
{
/**************************************
*
@ -833,24 +838,23 @@ int API_ROUTINE isc_add_user(ISC_STATUS* status, USER_SEC_DATA* user_data)
#ifdef BOOT_BUILD
return 1;
#else
USHORT retval = 0, l;
struct user_data userInfo;
FRBRD *db_handle;
internal_user_data userInfo;
userInfo.operation = ADD_OPER;
if (user_data->user_name) {
if (strlen(user_data->user_name) > 31) {
if (input_user_data->user_name) {
if (strlen(input_user_data->user_name) > 31) {
status[0] = isc_arg_gds;
status[1] = isc_usrname_too_long;
status[2] = isc_arg_end;
return status[1];
}
int l;
for (l = 0;
user_data->user_name[l] != ' '
&& l < strlen(user_data->user_name); l++)
userInfo.user_name[l] = UPPER(user_data->user_name[l]);
input_user_data->user_name[l] != ' '
&& l < strlen(input_user_data->user_name); l++)
{
userInfo.user_name[l] = UPPER(input_user_data->user_name[l]);
}
userInfo.user_name[l] = '\0';
userInfo.user_name_entered = true;
@ -862,18 +866,20 @@ return 1;
return status[1];
}
if (user_data->password) {
if (strlen(user_data->password) > 8) {
if (input_user_data->password) {
if (strlen(input_user_data->password) > 8) {
status[0] = isc_arg_gds;
status[1] = isc_password_too_long;
status[2] = isc_arg_end;
return status[1];
}
int l;
for (l = 0;
l < strlen(user_data->password) && user_data->password[l] != ' ';
l < strlen(input_user_data->password) && input_user_data->password[l] != ' ';
l++)
userInfo.password[l] = user_data->password[l];
{
userInfo.password[l] = input_user_data->password[l];
}
userInfo.password[l] = '\0';
userInfo.password_entered = true;
@ -887,9 +893,10 @@ return 1;
}
if ((user_data->sec_flags & sec_uid_spec)
&& (userInfo.uid_entered = (user_data->uid))) {
userInfo.uid = user_data->uid;
if ((input_user_data->sec_flags & sec_uid_spec)
&& (userInfo.uid_entered = (input_user_data->uid)))
{
userInfo.uid = input_user_data->uid;
userInfo.uid_specified = true;
}
else {
@ -897,9 +904,10 @@ return 1;
userInfo.uid_entered = false;
}
if ((user_data->sec_flags & sec_gid_spec)
&& (userInfo.gid_entered = (user_data->gid))) {
userInfo.gid = user_data->gid;
if ((input_user_data->sec_flags & sec_gid_spec)
&& (userInfo.gid_entered = (input_user_data->gid)))
{
userInfo.gid = input_user_data->gid;
userInfo.gid_specified = true;
}
else {
@ -907,9 +915,9 @@ return 1;
userInfo.gid_entered = false;
}
if ((user_data->sec_flags & sec_group_name_spec) && user_data->group_name) {
int l = MIN(ALT_NAME_LEN - 1, strlen(user_data->group_name));
strncpy(userInfo.group_name, user_data->group_name, l);
if ((input_user_data->sec_flags & sec_group_name_spec) && input_user_data->group_name) {
int l = MIN(ALT_NAME_LEN - 1, strlen(input_user_data->group_name));
strncpy(userInfo.group_name, input_user_data->group_name, l);
userInfo.group_name[l] = '\0';
userInfo.group_name_entered = true;
userInfo.group_name_specified = true;
@ -919,9 +927,9 @@ return 1;
userInfo.group_name_specified = false;
}
if ((user_data->sec_flags & sec_first_name_spec) && user_data->first_name) {
int l = MIN(NAME_LEN - 1, strlen(user_data->first_name));
strncpy(userInfo.first_name, user_data->first_name, l);
if ((input_user_data->sec_flags & sec_first_name_spec) && input_user_data->first_name) {
int l = MIN(NAME_LEN - 1, strlen(input_user_data->first_name));
strncpy(userInfo.first_name, input_user_data->first_name, l);
userInfo.first_name[l] = '\0';
userInfo.first_name_entered = true;
userInfo.first_name_specified = true;
@ -931,10 +939,11 @@ return 1;
userInfo.first_name_specified = false;
}
if ((user_data->sec_flags & sec_middle_name_spec)
&& user_data->middle_name) {
int l = MIN(NAME_LEN - 1, strlen(user_data->middle_name));
strncpy(userInfo.middle_name, user_data->middle_name, l);
if ((input_user_data->sec_flags & sec_middle_name_spec)
&& input_user_data->middle_name)
{
int l = MIN(NAME_LEN - 1, strlen(input_user_data->middle_name));
strncpy(userInfo.middle_name, input_user_data->middle_name, l);
userInfo.middle_name[l] = '\0';
userInfo.middle_name_entered = true;
userInfo.middle_name_specified = true;
@ -944,9 +953,9 @@ return 1;
userInfo.middle_name_specified = false;
}
if ((user_data->sec_flags & sec_last_name_spec) && user_data->last_name) {
int l = MIN(NAME_LEN - 1, strlen(user_data->last_name));
strncpy(userInfo.last_name, user_data->last_name, l);
if ((input_user_data->sec_flags & sec_last_name_spec) && input_user_data->last_name) {
int l = MIN(NAME_LEN - 1, strlen(input_user_data->last_name));
strncpy(userInfo.last_name, input_user_data->last_name, l);
userInfo.last_name[l] = '\0';
userInfo.last_name_entered = true;
userInfo.last_name_specified = true;
@ -956,13 +965,14 @@ return 1;
userInfo.last_name_specified = false;
}
db_handle = open_security_db(status,
user_data->dba_user_name,
user_data->dba_password,
user_data->protocol, user_data->server);
FRBRD* db_handle = open_security_db(status,
input_user_data->dba_user_name,
input_user_data->dba_password,
input_user_data->protocol, input_user_data->server);
if (db_handle) {
ISC_STATUS_ARRAY user_status;
retval = SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
const USHORT retval =
SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
/* if retval != 0 then there was a gsec error */
if (retval)
get_security_error(status, retval);
@ -999,7 +1009,7 @@ int API_ROUTINE isc_blob_load(
name_length);
}
int API_ROUTINE isc_delete_user(ISC_STATUS * status, USER_SEC_DATA * user_data)
ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS* status, const USER_SEC_DATA* input_user_data)
{
/**************************************
*
@ -1018,24 +1028,23 @@ int API_ROUTINE isc_delete_user(ISC_STATUS * status, USER_SEC_DATA * user_data)
#ifdef BOOT_BUILD
return 1;
#else
USHORT retval = 0, l;
FRBRD *db_handle;
struct user_data userInfo;
internal_user_data userInfo;
userInfo.operation = DEL_OPER;
if (user_data->user_name) {
if (strlen(user_data->user_name) > 32) {
if (input_user_data->user_name) {
if (strlen(input_user_data->user_name) > 32) {
status[0] = isc_arg_gds;
status[1] = isc_usrname_too_long;
status[2] = isc_arg_end;
return status[1];
}
int l;
for (l = 0;
user_data->user_name[l] != ' '
&& l < strlen(user_data->user_name); l++)
userInfo.user_name[l] = UPPER(user_data->user_name[l]);
input_user_data->user_name[l] != ' '
&& l < strlen(input_user_data->user_name); l++)
{
userInfo.user_name[l] = UPPER(input_user_data->user_name[l]);
}
userInfo.user_name[l] = '\0';
userInfo.user_name_entered = true;
@ -1047,13 +1056,14 @@ return 1;
return status[1];
}
db_handle = open_security_db(status,
user_data->dba_user_name,
user_data->dba_password,
user_data->protocol, user_data->server);
FRBRD* db_handle = open_security_db(status,
input_user_data->dba_user_name,
input_user_data->dba_password,
input_user_data->protocol, input_user_data->server);
if (db_handle) {
ISC_STATUS_ARRAY user_status;
retval = SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
const USHORT retval =
SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
/* if retval != 0 then there was a gsec error */
if (retval)
get_security_error(status, retval);
@ -1064,7 +1074,7 @@ return 1;
#endif
}
int API_ROUTINE isc_modify_user(ISC_STATUS * status, USER_SEC_DATA * user_data)
ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA* input_user_data)
{
/**************************************
*
@ -1083,24 +1093,23 @@ int API_ROUTINE isc_modify_user(ISC_STATUS * status, USER_SEC_DATA * user_data)
#ifdef BOOT_BUILD
return 1;
#else
USHORT retval = 0, l;
struct user_data userInfo;
FRBRD *db_handle;
internal_user_data userInfo;
userInfo.operation = MOD_OPER;
if (user_data->user_name) {
if (strlen(user_data->user_name) > 32) {
if (input_user_data->user_name) {
if (strlen(input_user_data->user_name) > 32) {
status[0] = isc_arg_gds;
status[1] = isc_usrname_too_long;
status[2] = isc_arg_end;
return status[1];
}
int l;
for (l = 0;
user_data->user_name[l] != ' '
&& l < strlen(user_data->user_name); l++)
userInfo.user_name[l] = UPPER(user_data->user_name[l]);
input_user_data->user_name[l] != ' '
&& l < strlen(input_user_data->user_name); l++)
{
userInfo.user_name[l] = UPPER(input_user_data->user_name[l]);
}
userInfo.user_name[l] = '\0';
userInfo.user_name_entered = true;
@ -1112,18 +1121,20 @@ return 1;
return status[1];
}
if (user_data->sec_flags & sec_password_spec) {
if (strlen(user_data->password) > 8) {
if (input_user_data->sec_flags & sec_password_spec) {
if (strlen(input_user_data->password) > 8) {
status[0] = isc_arg_gds;
status[1] = isc_password_too_long;
status[2] = isc_arg_end;
return status[1];
}
int l;
for (l = 0;
l < strlen(user_data->password) && user_data->password[l] != ' ';
l < strlen(input_user_data->password) && input_user_data->password[l] != ' ';
l++)
userInfo.password[l] = user_data->password[l];
{
userInfo.password[l] = input_user_data->password[l];
}
userInfo.password[l] = '\0';
userInfo.password_entered = true;
@ -1135,8 +1146,8 @@ return 1;
}
if (user_data->sec_flags & sec_uid_spec) {
userInfo.uid = user_data->uid;
if (input_user_data->sec_flags & sec_uid_spec) {
userInfo.uid = input_user_data->uid;
userInfo.uid_specified = true;
userInfo.uid_entered = true;
}
@ -1145,8 +1156,8 @@ return 1;
userInfo.uid_entered = false;
}
if (user_data->sec_flags & sec_gid_spec) {
userInfo.gid = user_data->gid;
if (input_user_data->sec_flags & sec_gid_spec) {
userInfo.gid = input_user_data->gid;
userInfo.gid_specified = true;
userInfo.gid_entered = true;
}
@ -1155,9 +1166,9 @@ return 1;
userInfo.gid_entered = false;
}
if (user_data->sec_flags & sec_group_name_spec) {
int l = MIN(ALT_NAME_LEN - 1, strlen(user_data->group_name));
strncpy(userInfo.group_name, user_data->group_name, l);
if (input_user_data->sec_flags & sec_group_name_spec) {
int l = MIN(ALT_NAME_LEN - 1, strlen(input_user_data->group_name));
strncpy(userInfo.group_name, input_user_data->group_name, l);
userInfo.group_name[l] = '\0';
userInfo.group_name_entered = true;
userInfo.group_name_specified = true;
@ -1167,9 +1178,9 @@ return 1;
userInfo.group_name_specified = false;
}
if (user_data->sec_flags & sec_first_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(user_data->first_name));
strncpy(userInfo.first_name, user_data->first_name, l);
if (input_user_data->sec_flags & sec_first_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(input_user_data->first_name));
strncpy(userInfo.first_name, input_user_data->first_name, l);
userInfo.first_name[l] = '\0';
userInfo.first_name_entered = true;
userInfo.first_name_specified = true;
@ -1179,9 +1190,9 @@ return 1;
userInfo.first_name_specified = false;
}
if (user_data->sec_flags & sec_middle_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(user_data->middle_name));
strncpy(userInfo.middle_name, user_data->middle_name, l);
if (input_user_data->sec_flags & sec_middle_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(input_user_data->middle_name));
strncpy(userInfo.middle_name, input_user_data->middle_name, l);
userInfo.middle_name[l] = '\0';
userInfo.middle_name_entered = true;
userInfo.middle_name_specified = true;
@ -1191,9 +1202,9 @@ return 1;
userInfo.middle_name_specified = false;
}
if (user_data->sec_flags & sec_last_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(user_data->last_name));
strncpy(userInfo.last_name, user_data->last_name, l);
if (input_user_data->sec_flags & sec_last_name_spec) {
int l = MIN(NAME_LEN - 1, strlen(input_user_data->last_name));
strncpy(userInfo.last_name, input_user_data->last_name, l);
userInfo.last_name[l] = '\0';
userInfo.last_name_entered = true;
userInfo.last_name_specified = true;
@ -1203,13 +1214,14 @@ return 1;
userInfo.last_name_specified = false;
}
db_handle = open_security_db(status,
user_data->dba_user_name,
user_data->dba_password,
user_data->protocol, user_data->server);
FRBRD* db_handle = open_security_db(status,
input_user_data->dba_user_name,
input_user_data->dba_password,
input_user_data->protocol, input_user_data->server);
if (db_handle) {
ISC_STATUS_ARRAY user_status;
retval = SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
const USHORT retval =
SECURITY_exec_line(status, db_handle, &userInfo, NULL, NULL);
/* if retval != 0 then there was a gsec error */
if (retval)
get_security_error(status, retval);
@ -1239,7 +1251,7 @@ bool is_valid_server(ISC_STATUS* status, const TEXT* server)
#endif
FRBRD *open_security_db(
FRBRD* open_security_db(
ISC_STATUS* status,
const TEXT* username,
const TEXT* password, int protocol, const TEXT* server)
@ -1260,12 +1272,9 @@ FRBRD *open_security_db(
#ifdef BOOT_BUILD
return 0;
#else
char dpb_buffer[256];
TEXT default_security_db[MAXPATHLEN], connect_string[1024];
TEXT sec_server[256];
FRBRD* db_handle = NULL;
switch (protocol) {
case sec_protocol_tcpip:
if (!is_valid_server(status, server))
@ -1294,6 +1303,7 @@ return 0;
}
TEXT* database = connect_string;
char dpb_buffer[256];
char* dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
@ -1311,8 +1321,9 @@ return 0;
*dpb++ = *p++;
}
SSHORT dpb_length = dpb - dpb_buffer;
const SSHORT dpb_length = dpb - dpb_buffer;
FRBRD* db_handle = NULL;
if (isc_attach_database(status, 0, database, &db_handle, dpb_length,
dpb_buffer))
{

View File

@ -82,7 +82,7 @@ ISC_STATUS API_ROUTINE gds__put_slice(ISC_STATUS*, FRBRD**, FRBRD**, GDS_QUAD*,
SSHORT, const SCHAR*, SSHORT, const SLONG*,
SLONG, void*);
ISC_STATUS API_ROUTINE gds__que_events(ISC_STATUS*, FRBRD**, SLONG*, SSHORT, const SCHAR*,
void(*)(), void*);
FPTR_EVENT_CALLBACK, void*);
ISC_STATUS API_ROUTINE gds__receive(ISC_STATUS*, FRBRD**, SSHORT, SSHORT,
void*, SSHORT);
ISC_STATUS API_ROUTINE gds__reconnect_transaction(ISC_STATUS*, FRBRD**, FRBRD**,
@ -104,7 +104,7 @@ ISC_STATUS API_ROUTINE gds__unwind_request(ISC_STATUS*, FRBRD**, SSHORT);
ISC_STATUS API_ROUTINE gds__ddl(ISC_STATUS*, FRBRD**, FRBRD**, SSHORT, const SCHAR*);
void API_ROUTINE gds__decode_date(const GDS_QUAD*, void*);
void API_ROUTINE gds__encode_date(const void*, GDS_QUAD*);
int API_ROUTINE gds__version(FRBRD**, void(*) (), void*);
int API_ROUTINE gds__version(FRBRD**, FPTR_VERSION_CALLBACK, void*);
void API_ROUTINE gds__set_debug(int);
// isc_ functions which are not mapped to gds_ functions (the gds_ ones are in utl.cpp)
@ -118,7 +118,7 @@ void API_ROUTINE isc_event_block_s(SCHAR**, SCHAR**, USHORT, TEXT**, USHORT*);
//
SLONG API_ROUTINE isc_free(SCHAR*);
SLONG API_ROUTINE isc_ftof(const SCHAR*, const USHORT, SCHAR*, const USHORT);
ISC_STATUS API_ROUTINE isc_print_blr(const SCHAR*, void (*) (), void*, SSHORT);
ISC_STATUS API_ROUTINE isc_print_blr(const SCHAR*, FPTR_PRINT_CALLBACK, void*, SSHORT);
ISC_STATUS API_ROUTINE isc_print_status(const ISC_STATUS*);
void API_ROUTINE isc_qtoq(const ISC_QUAD*, ISC_QUAD*);
SLONG API_ROUTINE isc_sqlcode(const ISC_STATUS*);
@ -131,9 +131,9 @@ SLONG API_ROUTINE isc_interprete_cpp(SCHAR* const, const ISC_STATUS**);
// isc_ functions with no gds_ equivalence
//
int API_ROUTINE isc_add_user(ISC_STATUS*, USER_SEC_DATA*);
int API_ROUTINE isc_delete_user(ISC_STATUS*, USER_SEC_DATA*);
int API_ROUTINE isc_modify_user(ISC_STATUS*, USER_SEC_DATA*);
ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS*, const USER_SEC_DATA*);
ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS*, const USER_SEC_DATA*);
ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS*, const USER_SEC_DATA*);
} // extern "C"

View File

@ -33,7 +33,7 @@
*
*/
/*
$Id: blb.cpp,v 1.44 2003-12-11 10:33:24 robocop Exp $
$Id: blb.cpp,v 1.45 2003-12-22 10:00:45 robocop Exp $
*/
#include "firebird.h"
@ -447,7 +447,7 @@ USHORT BLB_get_segment(TDBB tdbb,
#ifdef SUPERSERVER
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit)
JRD_reschedule(tdbb, 0, TRUE);
JRD_reschedule(tdbb, 0, true);
#endif
@ -1732,6 +1732,7 @@ static ISC_STATUS blob_filter( USHORT action,
return FB_SUCCESS;
case ACTION_alloc:
// pointer to ISC_STATUS!!!
return (ISC_STATUS) FB_NEW(*transaction->tra_pool) ctl();
case ACTION_free:

View File

@ -88,26 +88,21 @@ ISC_STATUS BLF_close_blob(TDBB tdbb, CTL * filter_handle)
* Close a blob and close all the intermediate filters.
*
**************************************/
CTL control, next;
FPTR_BFILTER_CALLBACK callback;
ISC_STATUS status;
ISC_STATUS *user_status;
user_status = tdbb->tdbb_status_vector;
ISC_STATUS* user_status = tdbb->tdbb_status_vector;
/* Walk the chain of filters to find the ultimate source */
CTL next;
for (next = *filter_handle; next->ctl_to_sub_type;
next = next->ctl_source_handle);
callback = next->ctl_source;
status = FB_SUCCESS;
FPTR_BFILTER_CALLBACK callback = next->ctl_source;
START_CHECK_FOR_EXCEPTIONS( (TEXT*) next->ctl_exception_message)
/* Sign off from filter */
/* Walk the chain again, telling each filter stage to close */
for (next = *filter_handle; (control = next);) {
CTL control;
for (next = *filter_handle; (control = next);) {
/* Close this stage of the filter */
control->ctl_status = user_status;
@ -128,7 +123,7 @@ ISC_STATUS BLF_close_blob(TDBB tdbb, CTL * filter_handle)
END_CHECK_FOR_EXCEPTIONS((TEXT*)next->ctl_exception_message)
return 0;
return FB_SUCCESS;
}
@ -175,17 +170,15 @@ ISC_STATUS BLF_get_segment(TDBB tdbb,
* Get segment from a blob filter.
*
**************************************/
ISC_STATUS* user_status = tdbb->tdbb_status_vector;
CTL control;
ISC_STATUS status;
ISC_STATUS *user_status;
user_status = tdbb->tdbb_status_vector;
control = *filter_handle;
control->ctl_status = user_status;
control->ctl_buffer = buffer;
control->ctl_buffer_length = buffer_length;
ISC_STATUS status;
START_CHECK_FOR_EXCEPTIONS((TEXT*) control->ctl_exception_message)
user_status[0] = isc_arg_gds;
@ -222,21 +215,17 @@ BLF BLF_lookup_internal_filter(TDBB tdbb, SSHORT from, SSHORT to)
* Lookup blob filter in data structures.
*
**************************************/
BLF result;
STR exception_msg;
DBB dbb;
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
/* Check for system defined filter */
if (to == BLOB_text && from >= 0 && from < FB_NELEM(filters)) {
result = FB_NEW(*dbb->dbb_permanent) blf;
blf* result = FB_NEW(*dbb->dbb_permanent) blf;
result->blf_next = NULL;
result->blf_from = from;
result->blf_to = to;
result->blf_filter = filters[from];
exception_msg = FB_NEW_RPT(*dbb->dbb_permanent, 100) str;
str* exception_msg = FB_NEW_RPT(*dbb->dbb_permanent, 100) str;
// SIGN ISSUE, arg 1
sprintf((char*)exception_msg->str_data,
"Exception occurred in system provided internal filters for filtering internal subtype %d to text.",
@ -295,12 +284,9 @@ ISC_STATUS BLF_put_segment(TDBB tdbb,
* Get segment from a blob filter.
*
**************************************/
ISC_STATUS* user_status = tdbb->tdbb_status_vector;
CTL control;
ISC_STATUS status;
ISC_STATUS *user_status;
user_status = tdbb->tdbb_status_vector;
control = *filter_handle;
control->ctl_status = user_status;
// If the filter is ill behaved, it won't respect the constness
@ -309,6 +295,7 @@ ISC_STATUS BLF_put_segment(TDBB tdbb,
control->ctl_buffer = const_cast<UCHAR*>(buffer);
control->ctl_buffer_length = length;
ISC_STATUS status;
START_CHECK_FOR_EXCEPTIONS( (TEXT*) control->ctl_exception_message)
user_status[0] = isc_arg_gds;
@ -348,17 +335,11 @@ static ISC_STATUS open_blob(
* Open a blob and invoke a filter.
*
**************************************/
ISC_STATUS status;
CTL prior, control;
DBB dbb = tdbb->tdbb_database;
ISC_STATUS* user_status = tdbb->tdbb_status_vector;
SSHORT from, to;
USHORT from_charset, to_charset;
ctl temp;
DBB dbb;
ISC_STATUS *user_status;
dbb = tdbb->tdbb_database;
user_status = tdbb->tdbb_status_vector;
gds__parse_bpb2(bpb_length, bpb, &from, &to, &from_charset, &to_charset);
if ((!filter) || (!filter->blf_filter)) {
@ -380,13 +361,13 @@ static ISC_STATUS open_blob(
/* utilize a temporary control block just to pass the three
necessary internal parameters to the filter */
ctl temp;
temp.ctl_internal[0] = dbb;
temp.ctl_internal[1] = tra_handle;
temp.ctl_internal[2] = NULL;
// CVC: Using ISC_STATUS (SLONG) to return a pointer!!!
// If we change the function signature, we'll change the public API.
prior = (CTL) (*callback) (ACTION_alloc, &temp);
ctl* prior = (CTL) (*callback) (ACTION_alloc, &temp); // ISC_STATUS to pointer!
prior->ctl_source = callback;
prior->ctl_status = user_status;
@ -398,7 +379,7 @@ static ISC_STATUS open_blob(
return user_status[1];
}
control = (CTL) (*callback) (ACTION_alloc, &temp);
ctl* control = (CTL) (*callback) (ACTION_alloc, &temp); // ISC_STATUS to pointer!
control->ctl_source = filter->blf_filter;
control->ctl_source_handle = prior;
control->ctl_status = user_status;
@ -425,17 +406,17 @@ static ISC_STATUS open_blob(
control->ctl_bpb = bpb;
control->ctl_bpb_length = bpb_length;
ISC_STATUS status;
START_CHECK_FOR_EXCEPTIONS( (TEXT*) control->ctl_exception_message)
/* Initialize filter */
status = (*filter->blf_filter) (action, control);
status = (*filter->blf_filter) (action, control);
END_CHECK_FOR_EXCEPTIONS((TEXT*)control->ctl_exception_message)
if (status) {
if (status) {
ISC_STATUS_ARRAY local_status;
ISC_STATUS *tmp_status;
tmp_status = tdbb->tdbb_status_vector;
ISC_STATUS* tmp_status = tdbb->tdbb_status_vector;
tdbb->tdbb_status_vector = local_status;
/* This is OK to do since we know that we will return
* from BLF_close_blob, and get a chance to set the

View File

@ -158,3 +158,4 @@ static const struct
{"nullslast", zero}, /* 180 */
{0, 0}
};

View File

@ -48,25 +48,17 @@ BKM BKM_allocate(RSB rsb, USHORT length)
* Allocate and initialize a bookmark structure.
*
**************************************/
TDBB tdbb;
DBB dbb;
ATT attachment;
BKM bookmark;
JRD_REQ request;
IRSB impure;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = tdbb->tdbb_request;
impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
jrd_req* request = tdbb->tdbb_request;
irsb* impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
/* allocate the bookmark and link it into the
linked list hanging off the attachment block */
bookmark = FB_NEW_RPT(*dbb->dbb_permanent, length) bkm();
bkm* bookmark = FB_NEW_RPT(*dbb->dbb_permanent, length) bkm();
attachment = tdbb->tdbb_attachment;
att* attachment = tdbb->tdbb_attachment;
bookmark->bkm_next = attachment->att_bookmarks;
attachment->att_bookmarks = bookmark;
@ -81,8 +73,6 @@ BKM BKM_allocate(RSB rsb, USHORT length)
bookmark->bkm_handle = (ULONG) bookmark;
#else
{
ULONG slot;
/* The bookmark pointer can't be stored in a ULONG. Therefore
we must generate a ULONG value that can be used to retrieve
the pointer. Basically we will keep a vector of active bookmarks
@ -90,7 +80,7 @@ BKM BKM_allocate(RSB rsb, USHORT length)
a bookmark, its slot in the vector is zeroed and it becomes available
for reuse. */
slot =
const ULONG slot =
ALL_get_free_object(dbb->dbb_permanent,
&attachment->att_bkm_quick_ref, 50);
attachment->att_bkm_quick_ref->vec_object[slot] = (BLK) bookmark;
@ -134,19 +124,15 @@ BKM BKM_lookup(NOD node)
bookmark = (BKM) MOV_get_long(EVL_expr(tdbb, node), 0);
#else
{
TDBB tdbb;
ATT attachment;
ULONG slot;
VEC vector;
tdbb = GET_THREAD_DATA;
attachment = tdbb->tdbb_attachment;
TDBB tdbb = GET_THREAD_DATA;
att* attachment = tdbb->tdbb_attachment;
bookmark = NULL;
slot = MOV_get_long(EVL_expr(tdbb, node), 0);
if ((vector = attachment->att_bkm_quick_ref) &&
slot < vector->vec_count)
const ULONG slot = MOV_get_long(EVL_expr(tdbb, node), 0);
vec* vector = attachment->att_bkm_quick_ref;
if (vector && slot < vector->vec_count) {
bookmark = (BKM) vector->vec_object[slot];
}
}
#endif
@ -171,29 +157,25 @@ void BKM_release(NOD node)
* Release a bookmark using a user supplied value.
*
**************************************/
TDBB tdbb;
ATT attachment;
BKM bookmark, *bptr;
ULONG slot;
TDBB tdbb = GET_THREAD_DATA;
att* attachment = tdbb->tdbb_attachment;
tdbb = GET_THREAD_DATA;
attachment = tdbb->tdbb_attachment;
bookmark = BKM_lookup(node);
bkm* bookmark = BKM_lookup(node);
/* unlink the bookmark from the attachment linked list */
for (bptr = &attachment->att_bookmarks; *bptr; bptr = &(*bptr)->bkm_next)
for (bkm** bptr = &attachment->att_bookmarks; *bptr; bptr = &(*bptr)->bkm_next)
if (*bptr == bookmark) {
*bptr = bookmark->bkm_next;
break;
}
#if SIZEOF_VOID_P == 8
slot = MOV_get_long(EVL_expr(tdbb, node), 0);
const ULONG slot = MOV_get_long(EVL_expr(tdbb, node), 0);
attachment->att_bkm_quick_ref->vec_object[slot] = NULL;
#endif
ALL_release(bookmark);
}
#endif

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: btr.c
* MODULE: btr.cpp
* DESCRIPTION: B-tree management code
*
* The contents of this file are subject to the Interbase Public
@ -164,15 +164,15 @@ static SLONG add_node(TDBB, WIN *, IIB *, KEY *, SLONG *, SLONG *, SLONG *);
static void complement_key(KEY *);
static void compress(TDBB, DSC *, KEY *, USHORT, bool, bool, USHORT);
static USHORT compress_root(TDBB, IRT);
static void copy_key(KEY *, KEY *);
static void copy_key(const KEY*, KEY*);
static CONTENTS delete_node(TDBB, WIN *, UCHAR *);
static void delete_tree(TDBB, USHORT, USHORT, SLONG, SLONG);
static DSC *eval(TDBB, JRD_NOD, DSC *, bool *);
static SLONG fast_load(TDBB, JRD_REL, IDX *, USHORT, SCB, SelectivityList&);
static IRT fetch_root(TDBB, WIN *, JRD_REL);
static UCHAR *find_node_start_point(BTR, KEY *, UCHAR *, USHORT *, bool, bool, bool = false, SLONG = NO_VALUE);
static UCHAR *find_area_start_point(BTR, KEY *, UCHAR *, USHORT *, bool, bool, SLONG = NO_VALUE);
static SLONG find_page(BTR, KEY *, UCHAR, SLONG = NO_VALUE, bool = false);
static UCHAR* find_area_start_point(BTR, const KEY*, UCHAR *, USHORT *, bool, bool, SLONG = NO_VALUE);
static SLONG find_page(BTR, const KEY*, UCHAR, SLONG = NO_VALUE, bool = false);
static CONTENTS garbage_collect(TDBB, WIN *, SLONG);
static void generate_jump_nodes(TDBB, BTR, jumpNodeList*, USHORT, USHORT*, USHORT*, USHORT*);
static SLONG insert_node(TDBB, WIN *, IIB *, KEY *, SLONG *, SLONG *, SLONG *);
@ -376,10 +376,10 @@ bool BTR_description(JRD_REL relation, IRT root, IDX * idx, SSHORT id)
idx->idx_expression_request = NULL;
// pick up field ids and type descriptions for each of the fields
UCHAR* ptr = (UCHAR*) root + irt_desc->irt_desc;
const UCHAR* ptr = (UCHAR*) root + irt_desc->irt_desc;
idx::idx_repeat* idx_desc = idx->idx_rpt;
for (int i = 0; i < idx->idx_count; i++, idx_desc++) {
irtd* key_descriptor = (irtd*) ptr;
const irtd* key_descriptor = (irtd*) ptr;
idx_desc->idx_field = key_descriptor->irtd_field;
idx_desc->idx_itype = key_descriptor->irtd_itype;
// dimitr: adjust the ODS stuff accurately
@ -536,18 +536,20 @@ BTR BTR_find_page(TDBB tdbb,
copy_key(retrieval->irb_key, upper);
}
else {
if (retrieval->irb_upper_count)
if (retrieval->irb_upper_count) {
BTR_make_key(tdbb, retrieval->irb_upper_count,
retrieval->irb_value +
retrieval->irb_desc.idx_count,
&retrieval->irb_desc, upper,
(USHORT) (retrieval->irb_generic & irb_starting));
}
if (retrieval->irb_lower_count)
if (retrieval->irb_lower_count) {
BTR_make_key(tdbb, retrieval->irb_lower_count,
retrieval->irb_value,
&retrieval->irb_desc, lower,
(USHORT) (retrieval->irb_generic & irb_starting));
}
}
window->win_page = retrieval->irb_relation->rel_index_root;
@ -587,8 +589,8 @@ BTR BTR_find_page(TDBB tdbb,
}
else {
IndexNode node;
UCHAR *pointer;
while (page->btr_level > 0) {
UCHAR* pointer;
#ifdef SCROLLABLE_CURSORS
if (backwards) {
pointer = BTR_last_node(page, NAV_expand_index(window, 0), 0);
@ -634,9 +636,8 @@ void BTR_insert(TDBB tdbb, WIN * root_window, IIB * insertion)
SET_TDBB(tdbb);
DBB dbb = tdbb->tdbb_database;
IDX *idx;
idx = insertion->iib_descriptor;
IDX* idx = insertion->iib_descriptor;
WIN window(idx->idx_root);
BTR bucket = (BTR) CCH_FETCH(tdbb, &window, LCK_read, pag_index);
@ -686,7 +687,7 @@ void BTR_insert(TDBB tdbb, WIN * root_window, IIB * insertion)
}
// Allocate and format new bucket, this will always be a non-leaf page
SCHAR flags = bucket->btr_header.pag_flags;
const SCHAR flags = bucket->btr_header.pag_flags;
new_bucket = (BTR) DPM_allocate(tdbb, &new_window);
CCH_precedence(tdbb, &new_window, window.win_page);
new_bucket->btr_header.pag_type = pag_index;
@ -780,13 +781,9 @@ IDX_E BTR_key(TDBB tdbb, JRD_REL relation, REC record, IDX * idx, KEY * key, idx
KEY temp;
DSC desc;
DSC* desc_ptr;
UCHAR* p;
UCHAR* q;
SSHORT stuff_count;
USHORT n, l;
IDX_E result;
idx::idx_repeat* tail;
bool isNull;
int missing_unique_segments = 0;
SET_TDBB(tdbb);
@ -801,6 +798,7 @@ IDX_E BTR_key(TDBB tdbb, JRD_REL relation, REC record, IDX * idx, KEY * key, idx
// Special case single segment indices
if (idx->idx_count == 1) {
bool isNull;
#ifdef EXPRESSION_INDICES
// for expression indices, compute the value of the expression
if (idx->idx_expression) {
@ -835,9 +833,9 @@ IDX_E BTR_key(TDBB tdbb, JRD_REL relation, REC record, IDX * idx, KEY * key, idx
(idx->idx_flags & idx_descending), (USHORT) FALSE);
}
else {
p = key->key_data;
UCHAR* p = key->key_data;
stuff_count = 0;
for (n = 0; n < idx->idx_count; n++, tail++) {
for (USHORT n = 0; n < idx->idx_count; n++, tail++) {
for (; stuff_count; --stuff_count) {
*p++ = 0;
}
@ -846,7 +844,8 @@ IDX_E BTR_key(TDBB tdbb, JRD_REL relation, REC record, IDX * idx, KEY * key, idx
// In order to "map a null to a default" value (in EVL_field()),
// the relation block is referenced.
// Reference: Bug 10116, 10424
isNull = !EVL_field(relation, record, tail->idx_field, desc_ptr);
const bool isNull =
!EVL_field(relation, record, tail->idx_field, desc_ptr);
if (isNull && (idx->idx_flags & idx_unique)) {
missing_unique_segments++;
}
@ -854,9 +853,8 @@ IDX_E BTR_key(TDBB tdbb, JRD_REL relation, REC record, IDX * idx, KEY * key, idx
compress(tdbb, desc_ptr, &temp, tail->idx_itype, isNull,
(idx->idx_flags & idx_descending), (USHORT) FALSE);
for (q = temp.key_data, l = temp.key_length; l;
--l, --stuff_count)
{
const UCHAR* q = temp.key_data;
for (USHORT l = temp.key_length; l; --l, --stuff_count) {
if (stuff_count == 0) {
*p++ = idx->idx_count - n;
stuff_count = STUFF_COUNT;
@ -1568,8 +1566,7 @@ void BTR_selectivity(TDBB tdbb, JRD_REL relation, USHORT id, SelectivityList& se
SCHAR flags = bucket->btr_header.pag_flags;
// go down the left side of the index to leaf level
UCHAR *pointer;
pointer = BTreeNode::getPointerFirstNode(bucket);
UCHAR* pointer = BTreeNode::getPointerFirstNode(bucket);
while (bucket->btr_level) {
IndexNode pageNode;
BTreeNode::readNode(&pageNode, pointer, flags, false);
@ -1585,11 +1582,9 @@ void BTR_selectivity(TDBB tdbb, JRD_REL relation, USHORT id, SelectivityList& se
KEY key;
key.key_length = 0;
SSHORT l;
UCHAR *p, *q;
bool firstNode = true;
const USHORT segments = root->irt_rpt[id].irt_keys;
UCHAR *p1, *p2, *p1_end, *p2_end;
SSHORT count, stuff_count, pos, i;
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(tdbb->tdbb_default);
duplicatesList.grow(segments);
@ -1617,10 +1612,10 @@ void BTR_selectivity(TDBB tdbb, JRD_REL relation, USHORT id, SelectivityList& se
// Initialize variables for segment duplicate check.
// count holds the current checking segment (starting by
// the maximum segment number to 1).
p1 = key.key_data;
p1_end = key.key_data + key.key_length;
p2 = node.data;
p2_end = node.data + node.length;
const UCHAR* p1 = key.key_data;
const UCHAR* const p1_end = p1 + key.key_length;
const UCHAR* p2 = node.data;
const UCHAR* const p2_end = p2 + node.length;
if (node.prefix == 0) {
count = *p2;
pos = 0;
@ -1690,8 +1685,8 @@ void BTR_selectivity(TDBB tdbb, JRD_REL relation, USHORT id, SelectivityList& se
key.key_length = l;
l = node.length;
if (l) {
p = key.key_data + node.prefix;
q = node.data;
UCHAR* p = key.key_data + node.prefix;
const UCHAR* q = node.data;
do {
*p++ = *q++;
} while (--l);
@ -1908,7 +1903,7 @@ static void compress(TDBB tdbb,
if (isNull && dbb->dbb_ods_version >= ODS_VERSION7) {
pad = 0;
// AB: NULL should be threated as lowest value possible.
// Therefore don't complement pad when we have a
// Therefore don't complement pad when we have an
// ascending index.
if (dbb->dbb_ods_version < ODS_VERSION11) {
if (!descending) {
@ -2248,7 +2243,7 @@ static USHORT compress_root(TDBB tdbb, IRT page)
}
static void copy_key(KEY * in, KEY * out)
static void copy_key(const KEY* in, KEY* out)
{
/**************************************
*
@ -2260,13 +2255,10 @@ static void copy_key(KEY * in, KEY * out)
* Copy a key.
*
**************************************/
USHORT l;
l = out->key_length = in->key_length;
USHORT l = out->key_length = in->key_length;
if (l) {
UCHAR *p, *q;
p = out->key_data;
q = in->key_data;
UCHAR* p = out->key_data;
const UCHAR* q = in->key_data;
do {
*p++ = *q++;
} while (--l);
@ -2601,7 +2593,7 @@ static SLONG fast_load(TDBB tdbb,
**************************************/
KEY keys[MAX_LEVELS];
btr *buckets[MAX_LEVELS];
btr* buckets[MAX_LEVELS];
win_for_array windows[MAX_LEVELS];
ULONG split_pages[MAX_LEVELS];
SLONG split_record_numbers[MAX_LEVELS];
@ -2615,8 +2607,8 @@ static SLONG fast_load(TDBB tdbb,
// leaf-page and pointer-page size limits, we always need to
// leave room for the END_LEVEL node.
USHORT lp_fill_limit = dbb->dbb_page_size - BTN_LEAF_SIZE;
USHORT pp_fill_limit = dbb->dbb_page_size - BTN_PAGE_SIZE;
const USHORT lp_fill_limit = dbb->dbb_page_size - BTN_LEAF_SIZE;
const USHORT pp_fill_limit = dbb->dbb_page_size - BTN_PAGE_SIZE;
USHORT flags = 0;
if (idx->idx_flags & idx_descending) {
flags |= btr_descending;
@ -2645,13 +2637,12 @@ static SLONG fast_load(TDBB tdbb,
jumpInfo.jumpers = 0;
jumpInfo.keyLength = key_length;
UCHAR *pointer;
if (useJumpInfo) {
// AB: Let's try to determine to size between the jumps to speed up
// index search. Ofcourse the size depends on the key_length. How
// index search. Of course the size depends on the key_length. The
// bigger the key, the less jumps we can make. (Although we must
// not forget that mostly the keys are compressed and much smaller
// as the maximum possible key!).
// than the maximum possible key!).
// These values can easily change without effect on previous created
// indices, cause this value is stored on each page.
// Remember, the lower the value how more jumpkeys are generated and
@ -2697,6 +2688,7 @@ static SLONG fast_load(TDBB tdbb,
bucket->btr_length = BTR_SIZE;
bucket->btr_header.pag_flags |= flags;
UCHAR* pointer;
if (useJumpInfo) {
pointer = BTreeNode::writeJumpInfo(bucket, &jumpInfo);
jumpInfo.firstNodeOffset = (USHORT)(pointer - (UCHAR*)bucket);
@ -2720,7 +2712,6 @@ static SLONG fast_load(TDBB tdbb,
ULONG count = 0;
ULONG duplicates = 0;
const USHORT segments = idx->idx_count;
UCHAR *p1, *p2, *p1_end, *p2_end;
SSHORT segment, stuff_count, pos, i;
Firebird::HalfStaticArray<ULONG, 4> duplicatesList(tdbb->tdbb_default);
duplicatesList.grow(segments);
@ -2743,8 +2734,8 @@ static SLONG fast_load(TDBB tdbb,
dynKey* jumpKey = (*jumpKeys)[0];
jumpNodeList* leafJumpNodes = (*jumpNodes)[0];
bool duplicate = false;
USHORT level, prefix, l;
UCHAR *record, *p, *q;
USHORT level, prefix;
UCHAR* record;
totalJumpSize[0] = 0;
USHORT headerSize = (pointer - (UCHAR*)bucket);
@ -2796,9 +2787,12 @@ static SLONG fast_load(TDBB tdbb,
if (useJumpInfo && totalJumpSize[0]) {
// Slide down current nodes;
l = bucket->btr_length - headerSize;
p = (UCHAR*)bucket + bucket->btr_length;
q = p + totalJumpSize[0];
// CVC: Warning, this may overlap. It seems better to use
// memmove or to ensure manually that totalJumpSize[0] > l
// Also, "sliding down" here is moving contents higher in memory.
USHORT l = bucket->btr_length - headerSize;
UCHAR* p = (UCHAR*)bucket + bucket->btr_length;
UCHAR* q = p + totalJumpSize[0];
while (l) {
*--q = *--p;
l--;
@ -2891,10 +2885,10 @@ static SLONG fast_load(TDBB tdbb,
// Initialize variables for segment duplicate check.
// count holds the current checking segment (starting by
// the maximum segment number to 1).
p1 = key->key_data;
p1_end = key->key_data + key->key_length;
p2 = newNode.data;
p2_end = newNode.data + newNode.length;
const UCHAR* p1 = key->key_data;
const UCHAR* const p1_end = p1 + key->key_length;
const UCHAR* p2 = newNode.data;
const UCHAR* const p2_end = p2 + newNode.length;
if (newNode.prefix == 0) {
segment = *p2;
pos = 0;
@ -3069,9 +3063,12 @@ static SLONG fast_load(TDBB tdbb,
if (useJumpInfo && totalJumpSize[level]) {
// Slide down current nodes;
l = bucket->btr_length - headerSize;
p = (UCHAR*)bucket + bucket->btr_length;
q = p + totalJumpSize[level];
// CVC: Warning, this may overlap. It seems better to use
// memmove or to ensure manually that totalJumpSize[0] > l
// Also, "sliding down" here is moving contents higher in memory.
USHORT l = bucket->btr_length - headerSize;
UCHAR* p = (UCHAR*)bucket + bucket->btr_length;
UCHAR* q = p + totalJumpSize[level];
while (l) {
*--q = *--p;
l--;
@ -3192,7 +3189,7 @@ static SLONG fast_load(TDBB tdbb,
#ifdef SUPERSERVER
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit) {
error = JRD_reschedule(tdbb, 0, FALSE);
error = JRD_reschedule(tdbb, 0, false);
}
#endif
}
@ -3216,9 +3213,12 @@ static SLONG fast_load(TDBB tdbb,
jumpNodeList* pageJumpNodes = (*jumpNodes)[level];
if (useJumpInfo && totalJumpSize[level]) {
// Slide down current nodes;
l = bucket->btr_length - headerSize;
p = (UCHAR*)bucket + bucket->btr_length;
q = p + totalJumpSize[level];
// CVC: Warning, this may overlap. It seems better to use
// memmove or to ensure manually that totalJumpSize[0] > l
// Also, "sliding down" here is moving contents higher in memory.
USHORT l = bucket->btr_length - headerSize;
UCHAR* p = (UCHAR*)bucket + bucket->btr_length;
UCHAR* q = p + totalJumpSize[level];
while (l) {
*--q = *--p;
l--;
@ -3371,11 +3371,10 @@ static UCHAR *find_node_start_point(BTR bucket, KEY * key, UCHAR * value,
*
**************************************/
SCHAR flags = bucket->btr_header.pag_flags;
const SCHAR flags = bucket->btr_header.pag_flags;
register UCHAR *p, *q, *r;
USHORT prefix = 0;
UCHAR *key_end = key->key_data + key->key_length;
UCHAR *nodeEnd;
const UCHAR* const key_end = key->key_data + key->key_length;
if (!(flags & btr_all_record_number)) {
find_record_number = NO_VALUE;
}
@ -3383,7 +3382,7 @@ static UCHAR *find_node_start_point(BTR bucket, KEY * key, UCHAR * value,
bool leafPage = (bucket->btr_level == 0);
// Find point where we can start search.
UCHAR *pointer;
UCHAR* pointer;
if (flags & btr_jump_info) {
pointer = find_area_start_point(bucket, key, value,
&prefix, descending, retrieval, find_record_number);
@ -3436,7 +3435,7 @@ static UCHAR *find_node_start_point(BTR bucket, KEY * key, UCHAR * value,
// it is a duplicate, and can also be skipped.
if (node.prefix == prefix) {
q = node.data;
nodeEnd = q + node.length;
const UCHAR* const nodeEnd = q + node.length;
if (descending) {
while (true) {
if (q == nodeEnd || (retrieval && p == key_end)) {
@ -3537,7 +3536,7 @@ static UCHAR *find_node_start_point(BTR bucket, KEY * key, UCHAR * value,
// it is a duplicate, and can also be skipped.
if (node->btn_prefix == prefix) {
q = node->btn_data;
nodeEnd = q + node->btn_length;
const UCHAR* const nodeEnd = q + node->btn_length;
if (descending) {
while (true) {
if (q == nodeEnd || retrieval && p == key_end) {
@ -3594,7 +3593,7 @@ static UCHAR *find_node_start_point(BTR bucket, KEY * key, UCHAR * value,
}
static UCHAR *find_area_start_point(BTR bucket, KEY * key, UCHAR * value,
static UCHAR* find_area_start_point(BTR bucket, const KEY* key, UCHAR * value,
USHORT * return_prefix, bool descending,
bool retrieval, SLONG find_record_number)
{
@ -3622,8 +3621,8 @@ static UCHAR *find_area_start_point(BTR bucket, KEY * key, UCHAR * value,
bool useFindRecordNumber = (find_record_number != NO_VALUE);
bool leafPage = (bucket->btr_level == 0);
UCHAR *q, *nodeEnd;
UCHAR *keyPointer = key->key_data;
UCHAR *keyEnd = keyPointer + key->key_length;
const UCHAR* keyPointer = key->key_data;
const UCHAR* const keyEnd = keyPointer + key->key_length;
IndexJumpInfo jumpInfo;
IndexJumpNode jumpNode, prevJumpNode;
IndexNode node;
@ -3799,7 +3798,7 @@ static UCHAR *find_area_start_point(BTR bucket, KEY * key, UCHAR * value,
}
static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record_number,
static SLONG find_page(BTR bucket, const KEY* key, UCHAR idx_flags, SLONG find_record_number,
bool retrieval)
{
/**************************************
@ -3817,7 +3816,7 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
*
**************************************/
SCHAR flags = bucket->btr_header.pag_flags;
const SCHAR flags = bucket->btr_header.pag_flags;
bool leafPage = (bucket->btr_level == 0);
bool firstPass = true;
bool descending = (idx_flags & idx_descending);
@ -3827,10 +3826,10 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
find_record_number = NO_VALUE;
}
UCHAR* p; // pointer on key
UCHAR* q; // pointer on processing node
UCHAR* keyEnd; // pointer on end of key
UCHAR* nodeEnd; // pointer on end of processing node
// UCHAR* p; // pointer on key
// UCHAR* q; // pointer on processing node
// UCHAR* keyEnd; // pointer on end of key
// UCHAR* nodeEnd; // pointer on end of processing node
UCHAR* pointer; // pointer where to start reading next node
USHORT prefix = 0; // last computed prefix against processed node
@ -3863,8 +3862,8 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
pointer = BTreeNode::readNode(&node, pointer, flags, leafPage);
}
}
p = key->key_data + prefix;
keyEnd = key->key_data + key->key_length;
const UCHAR* p = key->key_data + prefix; // pointer on key
const UCHAR* const keyEnd = key->key_data + key->key_length; // pointer on end of key
while (true) {
@ -3880,8 +3879,8 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
// If the node prefix is greater than current prefix , it must be less
// than the key, so we can skip it. If it has zero length, then
// it is a duplicate, and can also be skipped.
q = node.data;
nodeEnd = q + node.length;
const UCHAR* q = node.data; // pointer on processing node
const UCHAR* const nodeEnd = q + node.length; // pointer on end of processing node
if (node.prefix == prefix) {
if (descending) {
// Descending indexes
@ -3980,8 +3979,8 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
}
}
}
p = key->key_data + prefix;
keyEnd = key->key_data + key->key_length;
const UCHAR* p = key->key_data + prefix;
const UCHAR* const keyEnd = key->key_data + key->key_length;
while (true) {
@ -3999,8 +3998,8 @@ static SLONG find_page(BTR bucket, KEY * key, UCHAR idx_flags, SLONG find_record
// If the node prefix is greater than current prefix , it must be less
// than the key, so we can skip it. If it has zero length, then
// it is a duplicate, and can also be skipped.
q = node->btn_data;
nodeEnd = q + node->btn_length;
const UCHAR* q = node->btn_data;
const UCHAR* const nodeEnd = q + node->btn_length;
if (node->btn_prefix == prefix) {
if (descending) {
while (true) {
@ -4211,7 +4210,7 @@ static CONTENTS garbage_collect(TDBB tdbb, WIN * window, SLONG parent_number)
}
}
SCHAR flags = gc_page->btr_header.pag_flags;
const SCHAR flags = gc_page->btr_header.pag_flags;
// Check if flags are valid.
if ((parent_page->btr_header.pag_flags & BTR_FLAG_COPY_MASK) !=
(flags & BTR_FLAG_COPY_MASK))
@ -4288,7 +4287,6 @@ static CONTENTS garbage_collect(TDBB tdbb, WIN * window, SLONG parent_number)
bool useJumpInfo = (flags & btr_jump_info);
bool leafPage = (gc_page->btr_level == 0);
UCHAR* leftPointer;
UCHAR* p;
KEY lastKey;
leftPointer = BTreeNode::getPointerFirstNode(left_page);
@ -4334,7 +4332,7 @@ static CONTENTS garbage_collect(TDBB tdbb, WIN * window, SLONG parent_number)
}
// Save data
if (leftNode.length) {
p = lastKey.key_data + leftNode.prefix;
UCHAR* p = lastKey.key_data + leftNode.prefix;
MOVE_FASTER(leftNode.data, p, leftNode.length);
lastKey.key_length = leftNode.prefix + leftNode.length;
}
@ -4377,7 +4375,7 @@ static CONTENTS garbage_collect(TDBB tdbb, WIN * window, SLONG parent_number)
BTR newBucket = (BTR) scratchPage;
IndexJumpInfo jumpInfo;
UCHAR *pointer = BTreeNode::getPointerFirstNode(left_page, &jumpInfo);
UCHAR* pointer = BTreeNode::getPointerFirstNode(left_page, &jumpInfo);
USHORT headerSize = (pointer - (UCHAR*)left_page);
USHORT jumpersOriginalSize = jumpInfo.firstNodeOffset - headerSize;
@ -4585,7 +4583,7 @@ static CONTENTS garbage_collect(TDBB tdbb, WIN * window, SLONG parent_number)
leftPointer = BTreeNode::writeNode(&leftNode, leftPointer, flags, leafPage);
// copy over the remainder of the page to be garbage-collected
USHORT l = gc_page->btr_length - (gcPointer - (UCHAR*)(gc_page));
const USHORT l = gc_page->btr_length - (gcPointer - (UCHAR*)(gc_page));
MOVE_FASTER(gcPointer, leftPointer, l);
leftPointer += l;
// update page size
@ -4708,7 +4706,6 @@ static void generate_jump_nodes(TDBB tdbb, BTR page, jumpNodeList* jumpNodes,
UCHAR *endpoint = ((UCHAR*)page + page->btr_length);
UCHAR *halfpoint = ((UCHAR*)page + (dbb->dbb_page_size / 2));
UCHAR *excludePointer = ((UCHAR*)page + excludeOffset);
UCHAR *q;
IndexJumpNode jumpNode;
if (flags & btr_large_keys) {
@ -4716,7 +4713,7 @@ static void generate_jump_nodes(TDBB tdbb, BTR page, jumpNodeList* jumpNodes,
while (pointer < endpoint) {
pointer = BTreeNode::readNode(&node, pointer, flags, leafPage);
if (node.length) {
q = currentData + node.prefix;
UCHAR* q = currentData + node.prefix;
MOVE_FAST(node.data, q, node.length);
}
@ -4738,7 +4735,7 @@ static void generate_jump_nodes(TDBB tdbb, BTR page, jumpNodeList* jumpNodes,
jumpNode.length = node.prefix - jumpNode.prefix;
if (jumpNode.length) {
jumpNode.data = FB_NEW(*tdbb->tdbb_default) UCHAR[jumpNode.length];
q = currentData + jumpNode.prefix;
const UCHAR* const q = currentData + jumpNode.prefix;
MOVE_FAST(q, jumpNode.data, jumpNode.length);
}
else {
@ -4771,7 +4768,7 @@ static void generate_jump_nodes(TDBB tdbb, BTR page, jumpNodeList* jumpNodes,
pointer = (UCHAR*)NEXT_NODE(node);
}
if (node->btn_length) {
q = currentData + node->btn_prefix;
UCHAR* q = currentData + node->btn_prefix;
MOVE_FAST(node->btn_data, q, node->btn_length);
}
@ -4792,7 +4789,7 @@ static void generate_jump_nodes(TDBB tdbb, BTR page, jumpNodeList* jumpNodes,
jumpNode.length = node->btn_prefix - jumpNode.prefix;
if (jumpNode.length) {
jumpNode.data = FB_NEW(*tdbb->tdbb_default) UCHAR[jumpNode.length];
q = currentData + jumpNode.prefix;
const UCHAR* const q = currentData + jumpNode.prefix;
MOVE_FAST(q, jumpNode.data, jumpNode.length);
}
else {
@ -4848,9 +4845,8 @@ static SLONG insert_node(TDBB tdbb,
// find the insertion point for the specified key
BTR bucket = (BTR) window->win_buffer;
SCHAR flags = bucket->btr_header.pag_flags;
KEY* key;
key = insertion->iib_key;
const SCHAR flags = bucket->btr_header.pag_flags;
KEY* key = insertion->iib_key;
bool unique = (insertion->iib_descriptor->idx_flags & idx_unique);
bool leafPage = (bucket->btr_level == 0);
@ -4875,8 +4871,6 @@ static SLONG insert_node(TDBB tdbb,
// loop through the equivalent nodes until the correct insertion
// point is found; for leaf level this will be the first node
UCHAR* p;
UCHAR* q;
USHORT newPrefix, newLength;
USHORT nodeOffset, l;
while (true) {
@ -4886,8 +4880,8 @@ static SLONG insert_node(TDBB tdbb,
// update the newPrefix and newLength against the node (key) that will
// be inserted before it.
p = key->key_data + newPrefix;
q = beforeInsertNode.data;
const UCHAR* p = key->key_data + newPrefix;
const UCHAR* q = beforeInsertNode.data;
l = MIN(key->key_length - newPrefix, newLength);
while (l) {
if (*p++ != *q++) {
@ -4951,8 +4945,8 @@ static SLONG insert_node(TDBB tdbb,
// Update the values for the next node after our new node.
// First, store needed data for beforeInsertNode into tempData.
UCHAR *tempData = FB_NEW(*tdbb->tdbb_default) UCHAR[newLength];
p = beforeInsertNode.data + newPrefix - beforeInsertNode.prefix;
UCHAR* tempData = FB_NEW(*tdbb->tdbb_default) UCHAR[newLength];
const UCHAR* p = beforeInsertNode.data + newPrefix - beforeInsertNode.prefix;
MOVE_FASTER(p, tempData, newLength);
beforeInsertNode.prefix = newPrefix;
@ -5172,7 +5166,7 @@ static SLONG insert_node(TDBB tdbb,
// Copy data from inserted key and this key will we the END_BUCKET marker
// as the first key on the next page.
p = key->key_data;
q = new_key->key_data;
UCHAR* q = new_key->key_data;
l = new_key->key_length = key->key_length;
MOVE_FAST(p, q, l);
prefix_total = newBucket->btr_prefix_total - beforeInsertNode.prefix;
@ -5192,7 +5186,7 @@ static SLONG insert_node(TDBB tdbb,
IndexJumpNode* walkJumpNode = jumpNodes->begin();
int i;
for (i = 0; i < jumpNodes->getCount(); i++, index++) {
q = new_key->key_data + walkJumpNode[i].prefix;
UCHAR* q = new_key->key_data + walkJumpNode[i].prefix;
MOVE_FAST(walkJumpNode[i].data, q, walkJumpNode[i].length);
if (index == splitJumpNodeIndex) {
jn = &walkJumpNode[i];
@ -5203,7 +5197,7 @@ static SLONG insert_node(TDBB tdbb,
// Get data from node.
splitpoint = (UCHAR*)newBucket + jn->offset;
splitpoint = BTreeNode::readNode(&node, splitpoint, flags, leafPage);
q = new_key->key_data + node.prefix;
UCHAR* q = new_key->key_data + node.prefix;
MOVE_FAST(node.data, q, node.length);
new_key->key_length = node.prefix + node.length;
prefix_total = newPrefixTotalBySplit;
@ -5243,7 +5237,7 @@ static SLONG insert_node(TDBB tdbb,
}
}
else {
UCHAR *midpoint = NULL;
UCHAR* midpoint = NULL;
splitpoint = BTreeNode::readNode(&newNode, newNode.nodePointer, flags, leafPage);
if (endOfPage && ((UCHAR*) splitpoint <= (UCHAR*)newBucket + dbb->dbb_page_size)){
midpoint = splitpoint;
@ -5258,7 +5252,7 @@ static SLONG insert_node(TDBB tdbb,
while (splitpoint < midpoint) {
splitpoint = BTreeNode::readNode(&node, splitpoint, flags, leafPage);
prefix_total += node.prefix;
q = new_key->key_data + node.prefix;
UCHAR* q = new_key->key_data + node.prefix;
new_key->key_length = node.prefix + node.length;
MOVE_FASTER(node.data, q, node.length);
}
@ -5529,16 +5523,14 @@ static void print_int64_key(SINT64 value, SSHORT scale, INT64_KEY key)
* quantify.
*
**************************************/
UCHAR *p;
USHORT n;
ib_fprintf(ib_stderr,
"%20" QUADFORMAT
"d %4d %.15e %6d ", value, scale, key.d_part, key.s_part);
p = (UCHAR*) &key;
for (n = 10; n--; n > 0)
const UCHAR* p = (UCHAR*) &key;
for (int n = 10; n--; n > 0) {
ib_fprintf(ib_stderr, "%02x ", *p++);
}
ib_fprintf(ib_stderr, "\n");
return;
@ -5751,7 +5743,7 @@ static CONTENTS remove_leaf_node(TDBB tdbb, IIB * insertion, WIN * window)
// Until deletion of duplicate nodes becomes efficient, limit
// leaf level traversal by rescheduling.
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit) {
if (JRD_reschedule(tdbb, 0, FALSE)) {
if (JRD_reschedule(tdbb, 0, false)) {
CCH_RELEASE(tdbb, window);
ERR_punt();
}

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: InterBase Access Method
* MODULE: builtin.c
* MODULE: builtin.cpp
* DESCRIPTION: Entry points for builtin UDF library
*
*
@ -20,7 +20,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: builtin.cpp,v 1.7 2003-11-26 11:15:32 aafemt Exp $
* $Id: builtin.cpp,v 1.8 2003-12-22 10:00:46 robocop Exp $
*/
#include "firebird.h"
@ -31,12 +31,12 @@
#include "../jrd/gds_proto.h"
typedef struct {
TEXT *fn_module;
TEXT *fn_entrypoint;
const TEXT* fn_module;
const TEXT* fn_entrypoint;
FPTR_INT fn_function;
} FN;
static FN isc_builtin_functions[] = {
static const FN isc_builtin_functions[] = {
/* Internal functions available for QA testing only */
/* "DEBUG_CRASH_TESTS", "TEST1", QATEST_entrypoint,
@ -51,7 +51,7 @@ FSG 18.Dez.2000
};
FPTR_INT BUILTIN_entrypoint(TEXT * module, TEXT * entrypoint)
FPTR_INT BUILTIN_entrypoint(const TEXT* module, const TEXT* entrypoint)
{
/**************************************
*
@ -68,21 +68,20 @@ FPTR_INT BUILTIN_entrypoint(TEXT * module, TEXT * entrypoint)
* location. The module name may be prefixed with $INTERBASE.
*
**************************************/
FN *function;
TEXT *p, temp[MAXPATHLEN], *ep;
TEXT *modname;
/* Strip off any preceeding $INTERBASE path location from the
* requested module name.
*/
modname = module;
const TEXT* modname = module;
TEXT temp[MAXPATHLEN];
gds__prefix(temp, "");
p = temp;
for (p = temp; *p; p++, modname++)
TEXT* p = temp;
for (p = temp; *p; p++, modname++) {
if (*p != *modname)
break;
}
if (!*p)
module = modname;
@ -98,7 +97,7 @@ FPTR_INT BUILTIN_entrypoint(TEXT * module, TEXT * entrypoint)
/* Strip off any trailing spaces from entrypoint name */
ep = p;
const TEXT* ep = p;
while (*entrypoint && *entrypoint != ' ')
*p++ = *entrypoint++;
@ -107,10 +106,14 @@ FPTR_INT BUILTIN_entrypoint(TEXT * module, TEXT * entrypoint)
/* Scan the list for a matching (module, entrypoint) name */
for (function = isc_builtin_functions; function->fn_module; ++function)
for (const FN* function = isc_builtin_functions; function->fn_module; ++function) {
if (!strcmp(temp, function->fn_module)
&& !strcmp(ep, function->fn_entrypoint))
{
return function->fn_function;
}
}
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -56,12 +56,12 @@ void CCH_release(TDBB, win*, BOOLEAN);
void CCH_release_and_free(win*);
void CCH_release_exclusive(TDBB);
void CCH_release_journal(TDBB, SLONG);
BOOLEAN CCH_rollover_to_shadow(dbb*, fil*, BOOLEAN);
bool CCH_rollover_to_shadow(dbb*, fil*, const bool);
void CCH_unwind(TDBB, BOOLEAN);
BOOLEAN CCH_validate(win*);
void CCH_flush_database(TDBB tdbb);
BOOLEAN CCH_write_all_shadows(TDBB, sdw*, bdb*,
ISC_STATUS *, USHORT, BOOLEAN);
bool CCH_write_all_shadows(TDBB, sdw*, bdb*,
ISC_STATUS*, USHORT, const bool);
/* macros for dealing with cache pages */

View File

@ -167,16 +167,16 @@ inline static int strcmp_null(const char* s1, const char* s2) {
inline static char* clone_cstring(JrdMemoryPool* pool, const char* source) {
if (!source) return NULL;
char *result = FB_NEW(*pool) char[strlen(source)+1];
char* result = FB_NEW(*pool) char[strlen(source) + 1];
strcpy(result, source);
return result;
}
bool CMP_clone_active(JRD_REQ request)
bool CMP_clone_is_active(const jrd_req* request)
{
/**************************************
*
* C M P _ c l o n e _ a c t i v e
* C M P _ c l o n e _ i s _ a c t i v e
*
**************************************
*
@ -184,19 +184,21 @@ bool CMP_clone_active(JRD_REQ request)
* Determine if a request or any of its clones are active.
*
**************************************/
VEC vector;
vec::iterator sub_req, end;
DEV_BLKCHK(request, type_req);
if (request->req_flags & req_in_use)
return true;
if ( (vector = request->req_sub_requests) )
for (sub_req = vector->begin(), end = vector->end();
sub_req < end; sub_req++)
if (*sub_req && ((JRD_REQ)(*sub_req))->req_flags & req_in_use)
// This should be const, but the iterator won't work then.
vec* vector = request->req_sub_requests;
if (vector) {
for (vec::const_iterator sub_req = vector->begin(), end = vector->end();
sub_req < end; ++sub_req)
{
if (*sub_req && ((const jrd_req*)(*sub_req))->req_flags & req_in_use)
return true;
}
}
return false;
}
@ -606,8 +608,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
node->nod_scale = 0;
desc->dsc_sub_type = 0;
@ -669,8 +671,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
node->nod_scale = 0;
desc->dsc_sub_type = 0;
@ -758,7 +760,7 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
const fmt* format =
CMP_format(tdbb, csb, (USHORT) (ULONG) node->nod_arg[e_fld_stream]);
if (id >= format->fmt_count) {
desc->dsc_dtype = dtype_null;
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -793,12 +795,12 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
// text types for division in blr_version4 (dialect <= 1) only
if (!(DTYPE_CAN_DIVIDE(desc1.dsc_dtype) ||
DTYPE_IS_TEXT(desc1.dsc_dtype))) {
if (desc1.dsc_dtype != dtype_null)
if (desc1.dsc_dtype != dtype_unknown)
break; // error, dtype not supported by arithmetic
}
if (!(DTYPE_CAN_DIVIDE(desc2.dsc_dtype) ||
DTYPE_IS_TEXT(desc2.dsc_dtype))) {
if (desc2.dsc_dtype != dtype_null)
if (desc2.dsc_dtype != dtype_unknown)
break; // error, dtype not supported by arithmetic
}
}
@ -817,7 +819,7 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
if (node->nod_type == nod_average)
CMP_get_desc(tdbb, csb, node->nod_arg[e_stat_value], desc);
if (!DTYPE_CAN_AVERAGE(desc->dsc_dtype)) {
if (desc->dsc_dtype != dtype_null)
if (desc->dsc_dtype != dtype_unknown)
break;
}
desc->dsc_dtype = DEFAULT_DOUBLE;
@ -847,8 +849,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
node->nod_scale = desc->dsc_scale;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -1023,8 +1025,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -1108,8 +1110,9 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
fb_assert(DTYPE_IS_DATE(desc1.dsc_dtype) ||
DTYPE_IS_DATE(desc2.dsc_dtype));
if ((DTYPE_IS_DATE(dtype1) || (dtype1 == dtype_null)) &&
(DTYPE_IS_DATE(dtype2) || (dtype2 == dtype_null))) {
if ((DTYPE_IS_DATE(dtype1) || (dtype1 == dtype_unknown)) &&
(DTYPE_IS_DATE(dtype2) || (dtype2 == dtype_unknown)))
{
if (node->nod_type == nod_subtract2) {
// <any date> - <any date>
@ -1120,9 +1123,9 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
<date> - <timestamp>
<time> - <time> */
if (dtype1 == dtype_null)
if (dtype1 == dtype_unknown)
dtype1 = dtype2;
else if (dtype2 == dtype_null)
else if (dtype2 == dtype_unknown)
dtype2 = dtype1;
if (dtype1 == dtype2)
dtype = dtype1;
@ -1152,7 +1155,7 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
}
else {
fb_assert(dtype == dtype_timestamp
|| dtype == dtype_null);
|| dtype == dtype_unknown);
desc->dsc_dtype = DEFAULT_DOUBLE;
desc->dsc_length = type_lengths[desc->dsc_dtype];
desc->dsc_scale = 0;
@ -1220,8 +1223,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -1283,8 +1286,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -1331,8 +1334,8 @@ void CMP_get_desc(TDBB tdbb, CSB csb, JRD_NOD node, DSC * desc)
desc->dsc_flags = 0;
return;
case dtype_null:
desc->dsc_dtype = dtype_null;
case dtype_unknown:
desc->dsc_dtype = dtype_unknown;
desc->dsc_length = 0;
desc->dsc_scale = 0;
desc->dsc_sub_type = 0;
@ -5482,7 +5485,7 @@ static void process_map(TDBB tdbb, CSB csb, JRD_NOD map, FMT * input_format)
desc->dsc_sub_type = 0;
desc->dsc_flags = 0;
}
else if (!min) // eg: dtype_null
else if (!min) // eg: dtype_unknown
*desc = desc2;
else if (min <= dtype_any_text) { // either field a text field?
USHORT len1, len2;

View File

@ -26,7 +26,7 @@
#include "../jrd/req.h"
bool CMP_clone_active(jrd_req*);
bool CMP_clone_is_active(const jrd_req*);
jrd_nod* CMP_clone_node(TDBB, Csb*, jrd_nod*);
jrd_req* CMP_clone_request(TDBB, jrd_req*, USHORT, bool);
jrd_req* CMP_compile(USHORT, const UCHAR*, USHORT);

View File

@ -194,7 +194,7 @@ static const SQUAD quad_max_int = { LONG_MAX, -1 };
#endif
#endif
static const TEXT *const months[] = {
static const TEXT* const months[] = {
"JANUARY",
"FEBRUARY",
"MARCH",
@ -229,7 +229,6 @@ double CVT_date_to_double(const dsc* desc, FPTR_ERROR err)
*
**************************************/
SLONG temp[2], *date;
volatile double retval;
/* If the input descriptor is not in date form, convert it. */
@ -269,7 +268,7 @@ statement, am assigning the value to a local volatile double
variable and returning that. This is to prevent a specific kind of
precision error caused on Intel platforms (SCO and Linux) due
to FPU register being 80 bits long and double being 64 bits long */
volatile double retval;
retval =
date[0] +
(double) date[1] / (24. * 60. * 60. * ISC_TIME_SECONDS_PRECISION);
@ -314,7 +313,6 @@ double CVT_get_double(const dsc* desc, FPTR_ERROR err)
double value;
SSHORT scale;
switch (desc->dsc_dtype) {
case dtype_short:
value = *((SSHORT *) desc->dsc_address);
@ -664,17 +662,19 @@ SLONG CVT_get_long(const dsc* desc, SSHORT scale, FPTR_ERROR err)
else if (fraction < -4)
value--;
}
else
else {
do {
value /= 10;
} while (--scale);
}
}
else if (scale < 0)
else if (scale < 0) {
do {
if (value > LONG_LIMIT || value < -LONG_LIMIT)
(*err) (isc_arith_except, 0);
value *= 10;
} while (++scale);
}
return value;
}
@ -764,7 +764,8 @@ UCHAR CVT_get_numeric(const UCHAR* string,
conversion_error(&desc, err);
if ((p < end) || /* there is an exponent */
((value < 0) && (sign != -1))) { /* MAX_SINT64+1 wrapped around */
((value < 0) && (sign != -1))) /* MAX_SINT64+1 wrapped around */
{
/* convert to double */
*ptr = CVT_get_double(&desc, err);
return dtype_double;
@ -916,7 +917,8 @@ SQUAD CVT_get_quad(const dsc* desc, SSHORT scale, FPTR_ERROR err)
#else
if (scale > 0) {
if (desc->dsc_dtype == dtype_short ||
desc->dsc_dtype == dtype_long || desc->dsc_dtype == dtype_quad) {
desc->dsc_dtype == dtype_long || desc->dsc_dtype == dtype_quad)
{
fraction = 0;
do {
if (scale == 1)
@ -934,17 +936,19 @@ SQUAD CVT_get_quad(const dsc* desc, SSHORT scale, FPTR_ERROR err)
else if (fraction < -4)
value--;
}
else
else {
do {
value /= 10;
} while (--scale);
}
}
else
else {
do {
if (value > QUAD_LIMIT || value < -QUAD_LIMIT)
(*err) (isc_arith_except, 0);
value *= 10;
} while (++scale);
}
#endif
return value;
@ -1063,7 +1067,8 @@ SINT64 CVT_get_int64(const dsc* desc, SSHORT scale, FPTR_ERROR err)
if (scale > 0) {
if (desc->dsc_dtype == dtype_short ||
desc->dsc_dtype == dtype_long || desc->dsc_dtype == dtype_int64) {
desc->dsc_dtype == dtype_long || desc->dsc_dtype == dtype_int64)
{
fraction = 0;
do {
if (scale == 1)
@ -1081,17 +1086,19 @@ SINT64 CVT_get_int64(const dsc* desc, SSHORT scale, FPTR_ERROR err)
else if (fraction < -4)
value--;
}
else
else {
do {
value /= 10;
} while (--scale);
}
}
else if (scale < 0)
else if (scale < 0) {
do {
if (value > INT64_LIMIT || value < -INT64_LIMIT)
(*err) (isc_arith_except, 0);
value *= 10;
} while (++scale);
}
return value;
}
@ -1180,12 +1187,11 @@ GDS_DATE CVT_get_sql_date(const dsc* desc, FPTR_ERROR err)
* Convert something arbitrary to a SQL date value
*
**************************************/
DSC temp_desc;
GDS_DATE value;
if (desc->dsc_dtype == dtype_sql_date)
return *((GDS_DATE *) desc->dsc_address);
DSC temp_desc;
GDS_DATE value;
memset(&temp_desc, 0, sizeof(temp_desc));
temp_desc.dsc_dtype = dtype_sql_date;
temp_desc.dsc_address = (UCHAR *) &value;
@ -1206,12 +1212,11 @@ GDS_TIME CVT_get_sql_time(const dsc* desc, FPTR_ERROR err)
* Convert something arbitrary to a SQL time value
*
**************************************/
DSC temp_desc;
GDS_TIME value;
if (desc->dsc_dtype == dtype_sql_time)
return *((GDS_TIME *) desc->dsc_address);
DSC temp_desc;
GDS_TIME value;
memset(&temp_desc, 0, sizeof(temp_desc));
temp_desc.dsc_dtype = dtype_sql_time;
temp_desc.dsc_address = (UCHAR *) &value;
@ -1232,12 +1237,11 @@ GDS_TIMESTAMP CVT_get_timestamp(const dsc* desc, FPTR_ERROR err)
* Convert something arbitrary to a SQL timestamp
*
**************************************/
DSC temp_desc;
GDS_TIMESTAMP value;
if (desc->dsc_dtype == dtype_timestamp)
return *((GDS_TIMESTAMP *) desc->dsc_address);
DSC temp_desc;
GDS_TIMESTAMP value;
memset(&temp_desc, 0, sizeof(temp_desc));
temp_desc.dsc_dtype = dtype_timestamp;
temp_desc.dsc_address = (UCHAR *) &value;
@ -1777,16 +1781,15 @@ static void conversion_error(const dsc* desc, FPTR_ERROR err)
*
**************************************/
const char* p;
const char* string;
TEXT s[40];
USHORT length;
if (desc->dsc_dtype == dtype_blob)
p = "BLOB";
else if (desc->dsc_dtype == dtype_array)
p = "ARRAY";
else {
length =
const char* string;
const USHORT length =
CVT_make_string(desc, ttype_ascii, &string,
(VARY *) s, sizeof(s), err);
#if (defined REQUESTER || defined SUPERCLIENT)
@ -1863,16 +1866,17 @@ static void datetime_to_text(const dsc* from, dsc* to, FPTR_ERROR err)
if (from->dsc_dtype != dtype_sql_time) {
if (from->dsc_dtype == dtype_sql_date || !version4)
if (from->dsc_dtype == dtype_sql_date || !version4) {
sprintf(p, "%4.4d-%2.2d-%2.2d",
times.tm_year + 1900, times.tm_mon + 1, times.tm_mday);
else
}
else {
/* Prior to BLR version 5 - timestamps where converted to
text in the dd-Mon-yyyy format */
sprintf(p, "%d-%.3s-%d",
times.tm_mday,
months[times.tm_mon], times.tm_year + 1900);
}
while (*p)
p++;
};
@ -1885,19 +1889,22 @@ static void datetime_to_text(const dsc* from, dsc* to, FPTR_ERROR err)
/* Add the time part for data types that include it */
if (from->dsc_dtype != dtype_sql_date) {
if (from->dsc_dtype == dtype_sql_time || !version4)
if (from->dsc_dtype == dtype_sql_time || !version4) {
sprintf(p, "%2.2d:%2.2d:%2.2d.%4.4d",
times.tm_hour, times.tm_min, times.tm_sec,
(USHORT) (date.timestamp_time %
ISC_TIME_SECONDS_PRECISION));
}
else if (times.tm_hour || times.tm_min || times.tm_sec
|| date.timestamp_time)
{
/* Timestamp formating prior to BLR Version 5 is slightly
different */
sprintf(p, " %d:%.2d:%.2d.%.4d",
times.tm_hour, times.tm_min, times.tm_sec,
(USHORT) (date.timestamp_time %
ISC_TIME_SECONDS_PRECISION));
}
while (*p)
p++;
};
@ -1911,13 +1918,12 @@ static void datetime_to_text(const dsc* from, dsc* to, FPTR_ERROR err)
desc.dsc_ttype = ttype_ascii;
desc.dsc_length = (p - temp);
if (from->dsc_dtype == dtype_timestamp && version4) {
USHORT l;
/* Prior to BLR Version5, when a timestamp is converted to a string it
is silently truncated if the destination string is not large enough */
fb_assert(to->dsc_dtype <= dtype_any_text);
l = (to->dsc_dtype == dtype_cstring) ? 1 :
const USHORT l = (to->dsc_dtype == dtype_cstring) ? 1 :
(to->dsc_dtype == dtype_varying) ? sizeof(USHORT) : 0;
desc.dsc_length = MIN(desc.dsc_length, (to->dsc_length - l));
}
@ -2340,10 +2346,11 @@ static void integer_to_text(const dsc* from, dsc* to, FPTR_ERROR err)
(varying string) */
if (to->dsc_dtype == dtype_text) {
if ((l = to->dsc_length - length) > 0)
if ((l = to->dsc_length - length) > 0) {
do {
*q++ = ' ';
} while (--l);
}
return;
}
@ -2414,8 +2421,7 @@ static void string_to_datetime(
* components.
*
**************************************/
USHORT n, components[7];
SSHORT description[7];
/* Values inside of description
> 0 is number of digits
0 means missing
@ -2440,6 +2446,8 @@ static void string_to_datetime(
const char* p = string;
const char* const end = p + length;
USHORT n, components[7];
SSHORT description[7];
memset(components, 0, sizeof(components));
memset(description, 0, sizeof(description));
@ -2472,11 +2480,9 @@ static void string_to_datetime(
description[i] = precision;
}
else if (LETTER7(c) && !have_english_month) {
TEXT temp[sizeof(YESTERDAY) + 1], *t;
const TEXT *const * month_ptr;
const TEXT *m;
TEXT temp[sizeof(YESTERDAY) + 1];
t = temp;
TEXT* t = temp;
while ((p < end) && (t < &temp[sizeof(temp) - 1])) {
c = UPPER7(*p);
if (!LETTER7(c))
@ -2492,12 +2498,16 @@ static void string_to_datetime(
return;
}
month_ptr = months;
const TEXT* const* month_ptr = months;
while (true) {
/* Month names are only allowed in first 2 positions */
if (*month_ptr && i < 2) {
for (t = temp, m = *month_ptr++; *t && *t == *m;
t++, m++);
t = temp;
const TEXT* m = *month_ptr++;
while (*t && *t == *m) {
++t;
++m;
}
if (!*t)
break;
}
@ -2632,7 +2642,8 @@ static void string_to_datetime(
description[position_month] > 2
|| description[position_month] == 0
|| description[position_day] > 2
|| description[position_day] <= 0) {
|| description[position_day] <= 0)
{
conversion_error(desc, err);
return;
}

View File

@ -76,7 +76,7 @@ double MTH$CVT_D_G(), MTH$CVT_G_D();
returns the relative priority of types for use when different types
are compared.
*/
static const BYTE compare_priority[] = { dtype_null, /* dtype_null through dtype_varying */
static const BYTE compare_priority[] = { dtype_unknown, /* dtype_unknown through dtype_varying */
dtype_text, /* have their natural values stored */
dtype_cstring, /* in the table. */
dtype_varying,

View File

@ -2700,7 +2700,7 @@ static bool delete_procedure( TDBB tdbb,
procedure->prc_flags |= PRC_obsolete;
if (procedure->prc_request)
{
if (CMP_clone_active(procedure->prc_request))
if (CMP_clone_is_active(procedure->prc_request))
{
procedure->prc_flags = old_flags;
ERR_post(isc_no_meta_update,
@ -4061,7 +4061,7 @@ static bool modify_procedure( TDBB tdbb,
procedure->prc_flags |= PRC_being_altered;
if (procedure->prc_request)
{
if (CMP_clone_active(procedure->prc_request))
if (CMP_clone_is_active(procedure->prc_request))
ERR_post(isc_no_meta_update,
isc_arg_gds, isc_obj_in_use,
isc_arg_string, ERR_cstring(work->dfw_name),

View File

@ -42,7 +42,7 @@
static const USHORT _DSC_convert_to_text_length[DTYPE_TYPE_MAX] =
{
0, /* dtype_null */
0, /* dtype_unknown */
0, /* dtype_text */
0, /* dtype_cstring */
0, /* dtype_varying */
@ -90,7 +90,7 @@ static const USHORT DSC_blr_type_mapping[] = {
/* Unimplemented names are in lowercase & <brackets> */
/* Datatypes that represent a range of SQL datatypes are in lowercase */
static const TEXT *const DSC_dtype_names[] = {
"<dtype_null>",
"<dtype_unknown>",
"CHAR",
"CSTRING",
"VARCHAR",
@ -115,42 +115,42 @@ static const TEXT *const DSC_dtype_names[] = {
/* The result of adding two datatypes in blr_version5 semantics
Note: DTYPE_CANNOT as the result means that the operation cannot be done.
dtype_null as the result means that we do not yet know the type of one of
dtype_unknown as the result means that we do not yet know the type of one of
the operands, so we cannot decide the type of the result. */
const BYTE DSC_add_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/*
dtype_null dtype_text dtype_cstring dtype_varying
dtype_unknown dtype_text dtype_cstring dtype_varying
4 (unused) 5 (unused) dtype_packed dtype_byte
dtype_short dtype_long dtype_quad dtype_real
dtype_double dtype_d_float dtype_sql_date dtype_sql_time
dtype_timestamp dtype_blob dtype_array dtype_int64
*/
/* dtype_null */
{dtype_null, dtype_null, dtype_null, dtype_null,
/* dtype_unknown */
{dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_null, dtype_null, DTYPE_CANNOT, dtype_null,
dtype_null, dtype_null, dtype_null, dtype_null,
dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, dtype_null},
dtype_unknown, dtype_unknown, DTYPE_CANNOT, dtype_unknown,
dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, dtype_unknown},
/* dtype_text */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_cstring */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_varying */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -185,14 +185,14 @@ const BYTE DSC_add_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_short */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, dtype_sql_date, dtype_sql_time,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_int64},
/* dtype_long */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, dtype_sql_date, dtype_sql_time,
@ -206,42 +206,42 @@ const BYTE DSC_add_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_real */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, dtype_sql_date, dtype_sql_time,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_double */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, dtype_sql_date, dtype_sql_time,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_d_float -- VMS deprecated */
{dtype_null, dtype_d_float, dtype_d_float, dtype_d_float,
{dtype_unknown, dtype_d_float, dtype_d_float, dtype_d_float,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, dtype_d_float,
dtype_d_float, dtype_d_float, dtype_sql_date, dtype_sql_time,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_d_float},
/* dtype_sql_date */
{dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
{dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_sql_date, dtype_sql_date, DTYPE_CANNOT, dtype_sql_date,
dtype_sql_date, dtype_sql_date, DTYPE_CANNOT, dtype_timestamp,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_sql_date},
/* dtype_sql_time */
{dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
{dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_sql_time, dtype_sql_time, DTYPE_CANNOT, dtype_sql_time,
dtype_sql_time, dtype_sql_time, dtype_timestamp, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_sql_time},
/* dtype_timestamp */
{dtype_null, dtype_timestamp, dtype_timestamp, dtype_timestamp,
{dtype_unknown, dtype_timestamp, dtype_timestamp, dtype_timestamp,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, dtype_timestamp, DTYPE_CANNOT, dtype_timestamp,
dtype_timestamp, dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT,
@ -262,7 +262,7 @@ const BYTE DSC_add_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_int64 */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, dtype_sql_date, dtype_sql_time,
@ -272,42 +272,42 @@ const BYTE DSC_add_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/* The result of subtracting two datatypes in blr_version5 semantics
Note: DTYPE_CANNOT as the result means that the operation cannot be done.
dtype_null as the result means that we do not yet know the type of one of
dtype_unknown as the result means that we do not yet know the type of one of
the operands, so we cannot decide the type of the result. */
const BYTE DSC_sub_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/*
dtype_null dtype_text dtype_cstring dtype_varying
dtype_unknown dtype_text dtype_cstring dtype_varying
4 (unused) 5 (unused) dtype_packed dtype_byte
dtype_short dtype_long dtype_quad dtype_real
dtype_double dtype_d_float dtype_sql_date dtype_sql_time
dtype_timestamp dtype_blob dtype_array dtype_int64
*/
/* dtype_null */
{dtype_null, dtype_null, dtype_null, dtype_null,
/* dtype_unknown */
{dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_null, dtype_null, DTYPE_CANNOT, dtype_null,
dtype_null, dtype_null, dtype_null, dtype_null,
dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, dtype_null},
dtype_unknown, dtype_unknown, DTYPE_CANNOT, dtype_unknown,
dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, dtype_unknown},
/* dtype_text */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_cstring */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_varying */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -342,14 +342,14 @@ const BYTE DSC_sub_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_short */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_int64},
/* dtype_long */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -363,42 +363,42 @@ const BYTE DSC_sub_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_real */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_double */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_d_float -- VMS deprecated */
{dtype_null, dtype_d_float, dtype_d_float, dtype_d_float,
{dtype_unknown, dtype_d_float, dtype_d_float, dtype_d_float,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, dtype_d_float,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_d_float},
/* dtype_sql_date */
{dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
{dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_sql_date, dtype_sql_date, DTYPE_CANNOT, dtype_sql_date,
dtype_sql_date, dtype_sql_date, dtype_long, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_sql_date},
/* dtype_sql_time */
{dtype_null, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
{dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_sql_time, dtype_sql_time, DTYPE_CANNOT, dtype_sql_time,
dtype_sql_time, dtype_sql_time, DTYPE_CANNOT, dtype_long,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_sql_time},
/* dtype_timestamp */
{dtype_null, dtype_timestamp, dtype_timestamp, dtype_timestamp,
{dtype_unknown, dtype_timestamp, dtype_timestamp, dtype_timestamp,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_timestamp, dtype_timestamp, DTYPE_CANNOT, dtype_timestamp,
dtype_timestamp, dtype_timestamp, DTYPE_CANNOT, DTYPE_CANNOT,
@ -419,7 +419,7 @@ const BYTE DSC_sub_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_int64 */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -429,42 +429,42 @@ const BYTE DSC_sub_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/* The result of multiplying or dividing two datatypes in blr_version5 semantics
Note: DTYPE_CANNOT as the result means that the operation cannot be done.
dtype_null as the result means that we do not yet know the type of one of
dtype_unknown as the result means that we do not yet know the type of one of
the operands, so we cannot decide the type of the result. */
const BYTE DSC_multiply_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/*
dtype_null dtype_text dtype_cstring dtype_varying
dtype_unknown dtype_text dtype_cstring dtype_varying
4 (unused) 5 (unused) dtype_packed dtype_byte
dtype_short dtype_long dtype_quad dtype_real
dtype_double dtype_d_float dtype_sql_date dtype_sql_time
dtype_timestamp dtype_blob dtype_array dtype_int64
*/
/* dtype_null */
{dtype_null, dtype_null, dtype_null, dtype_null,
/* dtype_unknown */
{dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_null, dtype_null, DTYPE_CANNOT, dtype_null,
dtype_null, dtype_null, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_null},
dtype_unknown, dtype_unknown, DTYPE_CANNOT, dtype_unknown,
dtype_unknown, dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_unknown},
/* dtype_text */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_cstring */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_varying */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -499,14 +499,14 @@ const BYTE DSC_multiply_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_short */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_int64},
/* dtype_long */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -520,21 +520,21 @@ const BYTE DSC_multiply_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_real */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_double */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_d_float -- VMS deprecated */
{dtype_null, dtype_d_float, dtype_d_float, dtype_d_float,
{dtype_unknown, dtype_d_float, dtype_d_float, dtype_d_float,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, dtype_d_float,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -576,7 +576,7 @@ const BYTE DSC_multiply_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_int64 */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_int64, dtype_int64, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -586,42 +586,42 @@ const BYTE DSC_multiply_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/* The result of multiplying two datatypes in blr_version4 semantics.
Note: DTYPE_CANNOT as the result means that the operation cannot be done.
dtype_null as the result means that we do not yet know the type of one of
dtype_unknown as the result means that we do not yet know the type of one of
the operands, so we cannot decide the type of the result. */
const BYTE DSC_multiply_blr4_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
/*
dtype_null dtype_text dtype_cstring dtype_varying
dtype_unknown dtype_text dtype_cstring dtype_varying
4 (unused) 5 (unused) dtype_packed dtype_byte
dtype_short dtype_long dtype_quad dtype_real
dtype_double dtype_d_float dtype_sql_date dtype_sql_time
dtype_timestamp dtype_blob dtype_array dtype_int64
*/
/* dtype_null */
{dtype_null, dtype_null, dtype_null, dtype_null,
/* dtype_unknown */
{dtype_unknown, dtype_unknown, dtype_unknown, dtype_unknown,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_null, dtype_null, DTYPE_CANNOT, dtype_null,
dtype_null, dtype_null, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_null},
dtype_unknown, dtype_unknown, DTYPE_CANNOT, dtype_unknown,
dtype_unknown, dtype_unknown, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_unknown},
/* dtype_text */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_long, dtype_long, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_cstring */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_long, dtype_long, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_varying */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_long, dtype_long, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -656,14 +656,14 @@ const BYTE DSC_multiply_blr4_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_short */
{dtype_null, dtype_long, dtype_long, dtype_long,
{dtype_unknown, dtype_long, dtype_long, dtype_long,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_long, dtype_long, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_long */
{dtype_null, dtype_long, dtype_long, dtype_long,
{dtype_unknown, dtype_long, dtype_long, dtype_long,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_long, dtype_long, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -677,21 +677,21 @@ const BYTE DSC_multiply_blr4_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_real */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_double */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, dtype_double},
/* dtype_d_float -- VMS deprecated */
{dtype_null, dtype_d_float, dtype_d_float, dtype_d_float,
{dtype_unknown, dtype_d_float, dtype_d_float, dtype_d_float,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, dtype_d_float,
dtype_d_float, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -733,7 +733,7 @@ const BYTE DSC_multiply_blr4_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX] = {
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT},
/* dtype_int64 */
{dtype_null, dtype_double, dtype_double, dtype_double,
{dtype_unknown, dtype_double, dtype_double, dtype_double,
DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT, DTYPE_CANNOT,
dtype_double, dtype_double, DTYPE_CANNOT, dtype_double,
dtype_double, dtype_d_float, DTYPE_CANNOT, DTYPE_CANNOT,
@ -757,7 +757,7 @@ USHORT DSC_convert_to_text_length(USHORT dsc_type)
}
void DSC_make_descriptor(DSC * desc,
void DSC_make_descriptor(DSC* desc,
USHORT blr_type,
SSHORT scale,
USHORT length,
@ -779,9 +779,9 @@ void DSC_make_descriptor(DSC * desc,
#ifdef DEV_BUILD
{
/* Execute this validation code once per server startup only */
static BOOLEAN been_here = FALSE;
static bool been_here = false;
if (!been_here) {
been_here = TRUE;
been_here = true;
fb_assert(validate_dsc_tables());
}
}
@ -876,7 +876,7 @@ void DSC_make_descriptor(DSC * desc,
default:
fb_assert(FALSE);
desc->dsc_dtype = dtype_null;
desc->dsc_dtype = dtype_unknown;
break;
}
}
@ -982,9 +982,8 @@ static BOOLEAN validate_dsc_tables(void)
* so it won't detach from its controlling terminal.
*
**************************************/
BYTE op1, op2;
for (op1 = dtype_null; op1 < DTYPE_TYPE_MAX; op1++)
for (op2 = dtype_null; op2 < DTYPE_TYPE_MAX; op2++) {
for (BYTE op1 = dtype_unknown; op1 < DTYPE_TYPE_MAX; op1++) {
for (BYTE op2 = dtype_unknown; op2 < DTYPE_TYPE_MAX; op2++) {
if ((DSC_add_result[op1][op2] >= DTYPE_TYPE_MAX) &&
(DSC_add_result[op1][op2] != DTYPE_CANNOT)) {
@ -1042,6 +1041,7 @@ static BOOLEAN validate_dsc_tables(void)
return FALSE;
}
}
}
return TRUE;
}

View File

@ -96,8 +96,9 @@ typedef struct alt_dsc {
/* Note that dtype_null actually means that we do not yet know the
dtype for this descriptor. A nice cleanup item would be to globally
change it to dtype_unknown. --chrisj 1999-02-17 */
// Name changed on 2003.12.17 by CVC.
#define dtype_null 0
#define dtype_unknown 0
#define dtype_text 1
#define dtype_cstring 2
#define dtype_varying 3

View File

@ -48,7 +48,7 @@
/*
* TMN: Equally important: Don't add a compiler directive like
* extern "C" { } to this file since it's included to be the body
* of an array (!) from why.c.
* of an array (!) from why.cpp.
*/
#if defined(NOT_USED_OR_REPLACED) && defined(__cplusplus)
@ -409,18 +409,18 @@ ENTRYPOINT("gds_commit_retaining",
(ISC_STATUS *, class jrd_tra **))
ENTRYPOINT("gds_que_events",
jrd8_que_events,
"jrd5_que_events",
REM_que_events,
"_REM_que_events",
CSI_que_events,
jrd8_que_events,
"jrd5_que_events",
REM_que_events,
"_REM_que_events",
CSI_que_events,
/**** RDB_que_events ***/ y_valve_no_entrypoint,
PSI_que_events,
PSI5_que_events,
"_jrd8_que_events",
IPI_que_events,
(ISC_STATUS*, struct att**, SLONG*, SSHORT, const UCHAR*, FPTR_VOID,
void*))
(ISC_STATUS*, struct att**, SLONG*, SSHORT, const UCHAR*,
FPTR_EVENT_CALLBACK, void*))
ENTRYPOINT("gds_cancel_events",
jrd8_cancel_events,

View File

@ -401,7 +401,8 @@ SLONG EVENT_que(ISC_STATUS* status_vector,
USHORT string_length,
const TEXT* string,
USHORT events_length,
const UCHAR* events, FPTR_VOID ast_routine, void* ast_arg)
const UCHAR* events,
FPTR_EVENT_CALLBACK ast_routine, void* ast_arg)
{
/**************************************
*
@ -1004,10 +1005,9 @@ static void deliver_request(EVT_REQ request)
* Clean up request.
*
**************************************/
void (*ast) ();
UCHAR buffer[512];
ast = request->req_ast;
FPTR_EVENT_CALLBACK ast = request->req_ast;
void* arg = request->req_ast_arg;
UCHAR* event_buffer = buffer;
UCHAR* p = buffer;

View File

@ -155,7 +155,7 @@ typedef struct evt_req {
PTR req_process; /* Parent process block */
PTR req_session; /* Parent session block */
PTR req_interests; /* First interest in request */
void (*req_ast) (); /* Asynchronous routine */
FPTR_EVENT_CALLBACK req_ast; /* Asynchronous routine */
void *req_ast_arg; /* Argument for ast */
SLONG req_request_id; /* Request id, dummy */
} *EVT_REQ;

View File

@ -34,7 +34,7 @@ void EVENT_deliver();
struct evh* EVENT_init(ISC_STATUS*, USHORT);
int EVENT_post(ISC_STATUS*, USHORT, TEXT*, USHORT, TEXT*, USHORT);
SLONG EVENT_que(ISC_STATUS*, SLONG, USHORT, const TEXT*, USHORT, const UCHAR*,
FPTR_VOID, void*);
FPTR_EVENT_CALLBACK, void*);
#endif // JRD_EVENT_PROTO_H

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: evl.cpp,v 1.52 2003-12-11 10:33:24 robocop Exp $
* $Id: evl.cpp,v 1.53 2003-12-22 10:00:46 robocop Exp $
*/
/*
@ -130,35 +130,35 @@ double MTH$CVT_D_G(), MTH$CVT_G_D();
* The order should be made to agree as part of the next code cleanup.
*/
static DSC *add(const dsc*, JRD_NOD, VLU);
static DSC *add2(const dsc*, JRD_NOD, VLU);
static DSC *add_datetime(const dsc*, JRD_NOD, VLU);
static DSC *add_sql_date(const dsc*, JRD_NOD, VLU);
static DSC *add_sql_time(const dsc*, JRD_NOD, VLU);
static DSC *add_timestamp(const dsc*, JRD_NOD, VLU);
static DSC *binary_value(TDBB, JRD_NOD, VLU);
static DSC *cast(TDBB, const dsc*, const jrd_nod*, VLU);
static void compute_agg_distinct(TDBB, JRD_NOD);
static DSC *concatenate(TDBB, JRD_NOD, VLU);
static DSC *dbkey(TDBB, const jrd_nod*, VLU);
static DSC *eval_statistical(TDBB, JRD_NOD, VLU);
static dsc* add(const dsc*, const jrd_nod*, VLU);
static dsc* add2(const dsc*, const jrd_nod*, VLU);
static dsc* add_datetime(const dsc*, const jrd_nod*, VLU);
static dsc* add_sql_date(const dsc*, const jrd_nod*, VLU);
static dsc* add_sql_time(const dsc*, const jrd_nod*, VLU);
static dsc* add_timestamp(const dsc*, const jrd_nod*, VLU);
static dsc* binary_value(TDBB, const jrd_nod*, VLU);
static dsc* cast(TDBB, const dsc*, const jrd_nod*, VLU);
static void compute_agg_distinct(TDBB, jrd_nod*);
static dsc* concatenate(TDBB, jrd_nod*, VLU);
static dsc* dbkey(TDBB, const jrd_nod*, VLU);
static dsc* eval_statistical(TDBB, JRD_NOD, VLU);
static SINT64 get_day_fraction(const dsc* d);
static DSC *get_mask(TDBB, JRD_NOD, VLU);
static dsc* get_mask(TDBB, JRD_NOD, VLU);
static SINT64 get_timestamp_to_isc_ticks(const dsc* d);
static void init_agg_distinct(TDBB, const jrd_nod*);
#ifdef PC_ENGINE
static DSC *lock_record(TDBB, JRD_NOD, VLU);
static DSC *lock_relation(TDBB, JRD_NOD, VLU);
static dsc* lock_record(TDBB, JRD_NOD, VLU);
static dsc* lock_relation(TDBB, JRD_NOD, VLU);
#endif
static DSC *lock_state(TDBB, JRD_NOD, VLU);
static DSC *multiply(const dsc*, VLU, JRD_NOD);
static DSC *multiply2(const dsc*, VLU, JRD_NOD);
static DSC *divide2(const dsc*, VLU, JRD_NOD);
static DSC *negate_dsc(TDBB, const dsc*, VLU);
static DSC *record_version(TDBB, const jrd_nod*, VLU);
static dsc* lock_state(TDBB, JRD_NOD, VLU);
static dsc* multiply(const dsc*, VLU, const jrd_nod*);
static dsc* multiply2(const dsc*, VLU, const jrd_nod*);
static dsc* divide2(const dsc*, VLU, const jrd_nod*);
static dsc* negate_dsc(TDBB, const dsc*, VLU);
static dsc* record_version(TDBB, const jrd_nod*, VLU);
static bool reject_duplicate(const UCHAR*, const UCHAR*, void*);
static DSC *scalar(TDBB, JRD_NOD, VLU);
static SSHORT sleuth(TDBB, JRD_NOD, DSC *, DSC *);
static dsc* scalar(TDBB, JRD_NOD, VLU);
static SSHORT sleuth(TDBB, JRD_NOD, dsc*, dsc*);
static BOOLEAN nc_sleuth_check(TextType, USHORT, const UCHAR*, const UCHAR*,
const UCHAR*, const UCHAR*);
static BOOLEAN nc_sleuth_class(TextType, USHORT, const UCHAR*, const UCHAR*, UCHAR);
@ -166,11 +166,11 @@ static BOOLEAN wc_sleuth_check(TextType, USHORT, const UCS2_CHAR*, const UCS2_CH
const UCS2_CHAR*, const UCS2_CHAR*);
static BOOLEAN wc_sleuth_class(TextType, USHORT, const UCS2_CHAR*, const UCS2_CHAR*,
UCS2_CHAR);
static SSHORT string_boolean(TDBB, JRD_NOD, DSC *, DSC *);
static SSHORT string_boolean(TDBB, JRD_NOD, dsc*, dsc*);
static SSHORT string_function(TDBB, JRD_NOD, SSHORT, const UCHAR*, SSHORT, const UCHAR*, USHORT);
static DSC *substring(TDBB, VLU, DSC *, SLONG, SLONG);
static DSC *upcase(TDBB, const dsc*, VLU);
static DSC *internal_info(TDBB, const dsc*, VLU);
static dsc* substring(TDBB, VLU, dsc*, SLONG, SLONG);
static dsc* upcase(TDBB, const dsc*, VLU);
static dsc* internal_info(TDBB, const dsc*, VLU);
static const UCHAR special[256] = {
@ -208,7 +208,7 @@ static const RSE_GET_MODE g_RSE_get_mode = RSE_get_forward;
DSC* EVL_assign_to(TDBB tdbb, JRD_NOD node)
dsc* EVL_assign_to(TDBB tdbb, JRD_NOD node)
{
/**************************************
*
@ -221,7 +221,7 @@ DSC* EVL_assign_to(TDBB tdbb, JRD_NOD node)
* destination node of an assignment.
*
**************************************/
DSC *desc;
dsc* desc;
FMT format;
JRD_NOD message;
REC record;
@ -256,7 +256,7 @@ DSC* EVL_assign_to(TDBB tdbb, JRD_NOD node)
(INTL_GET_CHARSET(desc) == CS_dynamic))) {
/* Value is a text value, we're assigning it back to the user
process, user process has not specified a subtype, user
process specified dynamic translation and the DSC isn't from
process specified dynamic translation and the dsc isn't from
a 3.3 type request (blr_cstring2 instead of blr_cstring) so
convert the charset to the declared charset of the process. */
@ -348,14 +348,13 @@ SBM* EVL_bitmap(TDBB tdbb, JRD_NOD node)
case nod_bit_dbkey:
{
SLONG rel_dbkey;
inv* impure = (INV) ((SCHAR *) tdbb->tdbb_request + node->nod_impure);
SBM_reset(&impure->inv_bitmap);
const dsc* desc = EVL_expr(tdbb, node->nod_arg[0]);
const USHORT id = 1 + 2 * (USHORT)(ULONG) node->nod_arg[1];
const UCHAR* numbers = desc->dsc_address;
numbers += id * sizeof(SLONG);
SLONG rel_dbkey;
MOVE_FAST(numbers, &rel_dbkey, sizeof(SLONG));
rel_dbkey -= 1;
SBM_set(tdbb, &impure->inv_bitmap, rel_dbkey);
@ -392,7 +391,7 @@ BOOLEAN EVL_boolean(TDBB tdbb, JRD_NOD node)
*
**************************************/
DSC* desc[2];
dsc* desc[2];
USHORT value;
SSHORT comparison;
VLU impure;
@ -751,7 +750,7 @@ BOOLEAN EVL_boolean(TDBB tdbb, JRD_NOD node)
}
DSC* EVL_expr(TDBB tdbb, JRD_NOD node)
dsc* EVL_expr(TDBB tdbb, JRD_NOD node)
{
/**************************************
*
@ -1193,7 +1192,7 @@ DSC* EVL_expr(TDBB tdbb, JRD_NOD node)
}
BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
bool EVL_field(JRD_REL relation, REC record, USHORT id, dsc* desc)
{
/**************************************
*
@ -1210,7 +1209,7 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
if (!record) {
ERR_warning(isc_no_cur_rec, 0);
return FALSE;
return false;
}
fmt* format = record->rec_format;
@ -1275,7 +1274,7 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
(UCHAR *) relation->rel_owner_name;
desc->dsc_length =
strlen(reinterpret_cast<const char*>(desc->dsc_address));
return TRUE;
return true;
}
if (temp_nod_type == nod_current_date ||
@ -1290,7 +1289,7 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
reinterpret_cast<UCHAR*>(
const_cast<ISC_TIMESTAMP*>(&temp_timestamp));
desc->dsc_length = sizeof(temp_timestamp);
return TRUE;
return true;
}
else
{
@ -1314,7 +1313,7 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
desc->dsc_sub_type = default_desc->dsc_sub_type;
desc->dsc_flags = default_desc->dsc_flags;
desc->dsc_address = default_desc->dsc_address;
return TRUE;
return true;
}
}
else
@ -1325,7 +1324,7 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
desc->dsc_scale = 0;
desc->dsc_ttype = ttype_ascii;
desc->dsc_address = (UCHAR *) " ";
return FALSE;
return false;
}
}
}
@ -1337,25 +1336,25 @@ BOOLEAN EVL_field(JRD_REL relation, REC record, USHORT id, DSC * desc)
desc->dsc_scale = 0;
desc->dsc_ttype = ttype_ascii;
desc->dsc_address = (UCHAR *) " ";
return FALSE;
return false;
}
}
/* If the offset of the field is 0, the field can't possible exist */
if (!desc->dsc_address) {
return FALSE;
return false;
}
desc->dsc_address = record->rec_data + (int) desc->dsc_address;
if (TEST_NULL(record, id)) {
desc->dsc_flags |= DSC_null;
return FALSE;
return false;
}
else {
desc->dsc_flags &= ~DSC_null;
return TRUE;
return true;
}
}
@ -2314,7 +2313,7 @@ USHORT EVL_wc_contains(TDBB tdbb_dumm,
static DSC *add(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2394,7 +2393,7 @@ static DSC *add(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *add2(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add2(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2498,7 +2497,7 @@ static DSC *add2(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *add_datetime(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add_datetime(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2563,7 +2562,7 @@ static DSC *add_datetime(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *add_sql_date(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add_sql_date(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2579,8 +2578,6 @@ static DSC *add_sql_date(const dsc* desc, JRD_NOD node, VLU value)
* NUMERIC +/- TIME Numeric is interpreted as days DECIMAL(*,0).
*
**************************************/
SINT64 d1, d2;
DEV_BLKCHK(node, type_nod);
fb_assert(node->nod_type == nod_add ||
node->nod_type == nod_subtract ||
@ -2591,6 +2588,7 @@ static DSC *add_sql_date(const dsc* desc, JRD_NOD node, VLU value)
fb_assert(value->vlu_desc.dsc_dtype == dtype_sql_date ||
desc->dsc_dtype == dtype_sql_date);
SINT64 d1;
/* Coerce operand1 to a count of days */
bool op1_is_date = false;
if (value->vlu_desc.dsc_dtype == dtype_sql_date) {
@ -2600,6 +2598,7 @@ static DSC *add_sql_date(const dsc* desc, JRD_NOD node, VLU value)
else
d1 = MOV_get_int64(&value->vlu_desc, 0);
SINT64 d2;
/* Coerce operand2 to a count of days */
bool op2_is_date = false;
if (desc->dsc_dtype == dtype_sql_date) {
@ -2667,7 +2666,7 @@ static DSC *add_sql_date(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *add_sql_time(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add_sql_time(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2683,8 +2682,6 @@ static DSC *add_sql_time(const dsc* desc, JRD_NOD node, VLU value)
* NUMERIC +/- TIME Numeric is interpreted as seconds DECIMAL(*,4).
*
**************************************/
SINT64 d1, d2;
DEV_BLKCHK(node, type_nod);
fb_assert(node->nod_type == nod_add ||
node->nod_type == nod_subtract ||
@ -2695,6 +2692,7 @@ static DSC *add_sql_time(const dsc* desc, JRD_NOD node, VLU value)
fb_assert(value->vlu_desc.dsc_dtype == dtype_sql_time ||
desc->dsc_dtype == dtype_sql_time);
SINT64 d1;
/* Coerce operand1 to a count of seconds */
bool op1_is_time = false;
if (value->vlu_desc.dsc_dtype == dtype_sql_time) {
@ -2706,6 +2704,7 @@ static DSC *add_sql_time(const dsc* desc, JRD_NOD node, VLU value)
d1 =
MOV_get_int64(&value->vlu_desc, ISC_TIME_SECONDS_PRECISION_SCALE);
SINT64 d2;
/* Coerce operand2 to a count of seconds */
bool op2_is_time = false;
if (desc->dsc_dtype == dtype_sql_time) {
@ -2764,7 +2763,7 @@ static DSC *add_sql_time(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *add_timestamp(const dsc* desc, JRD_NOD node, VLU value)
static dsc* add_timestamp(const dsc* desc, const jrd_nod* node, VLU value)
{
/**************************************
*
@ -2809,7 +2808,8 @@ static DSC *add_timestamp(const dsc* desc, JRD_NOD node, VLU value)
else if (desc->dsc_dtype == dtype_sql_date) {
/* TIME + DATE */
if ((value->vlu_desc.dsc_dtype == dtype_sql_time) &&
((node->nod_type == nod_add) || (node->nod_type == nod_add2))) {
((node->nod_type == nod_add) || (node->nod_type == nod_add2)))
{
value->vlu_misc.vlu_timestamp.timestamp_time =
value->vlu_misc.vlu_sql_time;
value->vlu_misc.vlu_timestamp.timestamp_date =
@ -3007,7 +3007,7 @@ static DSC *add_timestamp(const dsc* desc, JRD_NOD node, VLU value)
}
static DSC *binary_value(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* binary_value(TDBB tdbb, const jrd_nod* node, VLU impure)
{
/**************************************
*
@ -3084,7 +3084,7 @@ static DSC *binary_value(TDBB tdbb, JRD_NOD node, VLU impure)
}
static DSC *cast(TDBB tdbb, const dsc* value, const jrd_nod* node, VLU impure)
static dsc* cast(TDBB tdbb, const dsc* value, const jrd_nod* node, VLU impure)
{
/**************************************
*
@ -3141,7 +3141,7 @@ static DSC *cast(TDBB tdbb, const dsc* value, const jrd_nod* node, VLU impure)
}
static void compute_agg_distinct(TDBB tdbb, JRD_NOD node)
static void compute_agg_distinct(TDBB tdbb, jrd_nod* node)
{
/**************************************
*
@ -3218,7 +3218,7 @@ static void compute_agg_distinct(TDBB tdbb, JRD_NOD node)
}
static DSC *concatenate(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* concatenate(TDBB tdbb, jrd_nod* node, VLU impure)
{
/**************************************
*
@ -3312,7 +3312,7 @@ static DSC *concatenate(TDBB tdbb, JRD_NOD node, VLU impure)
}
static DSC *dbkey(TDBB tdbb, const jrd_nod* node, VLU impure)
static dsc* dbkey(TDBB tdbb, const jrd_nod* node, VLU impure)
{
/**************************************
*
@ -3358,7 +3358,7 @@ static DSC *dbkey(TDBB tdbb, const jrd_nod* node, VLU impure)
}
static DSC *eval_statistical(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* eval_statistical(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -3591,7 +3591,7 @@ static SINT64 get_day_fraction(const dsc* d)
* count of days. Convert it to a count of microseconds.
*
**************************************/
DSC result;
dsc result;
double result_days;
result.dsc_dtype = dtype_double;
@ -3611,7 +3611,7 @@ static SINT64 get_day_fraction(const dsc* d)
static DSC *get_mask(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* get_mask(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -3674,7 +3674,7 @@ static SINT64 get_timestamp_to_isc_ticks(const dsc* d)
* ISC_TIME_SECONDS_PRECISION.
*
**************************************/
DSC result;
dsc result;
GDS_TIMESTAMP result_timestamp;
result.dsc_dtype = dtype_timestamp;
@ -3725,7 +3725,7 @@ static void init_agg_distinct(TDBB tdbb, const jrd_nod* node)
#ifdef PC_ENGINE
static DSC *lock_record(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* lock_record(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -3739,7 +3739,7 @@ static DSC *lock_record(TDBB tdbb, JRD_NOD node, VLU impure)
*
**************************************/
JRD_REQ request;
DSC *desc;
dsc* desc;
USHORT lock_level;
RSB rsb;
RPB *rpb;
@ -3803,7 +3803,7 @@ static DSC *lock_record(TDBB tdbb, JRD_NOD node, VLU impure)
#ifdef PC_ENGINE
static DSC *lock_relation(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* lock_relation(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -3816,7 +3816,7 @@ static DSC *lock_relation(TDBB tdbb, JRD_NOD node, VLU impure)
* pointing to the lock handle.
*
**************************************/
DSC *desc;
dsc* desc;
USHORT lock_level;
JRD_NOD relation_node;
JRD_REL relation;
@ -3878,7 +3878,7 @@ static DSC *lock_relation(TDBB tdbb, JRD_NOD node, VLU impure)
#endif
static DSC *lock_state(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* lock_state(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -3944,7 +3944,7 @@ static DSC *lock_state(TDBB tdbb, JRD_NOD node, VLU impure)
}
static DSC *multiply(const dsc* desc, VLU value, JRD_NOD node)
static dsc* multiply(const dsc* desc, VLU value, const jrd_nod* node)
{
/**************************************
*
@ -4037,7 +4037,7 @@ static DSC *multiply(const dsc* desc, VLU value, JRD_NOD node)
}
static DSC *multiply2(const dsc* desc, VLU value, JRD_NOD node)
static dsc* multiply2(const dsc* desc, VLU value, const jrd_nod* node)
{
/**************************************
*
@ -4056,8 +4056,8 @@ static DSC *multiply2(const dsc* desc, VLU value, JRD_NOD node)
if (node->nod_flags & nod_double)
{
double d1 = MOV_get_double(desc);
double d2 = MOV_get_double(&value->vlu_desc);
const double d1 = MOV_get_double(desc);
const double d2 = MOV_get_double(&value->vlu_desc);
value->vlu_misc.vlu_double = DOUBLE_MULTIPLY(d1, d2);
value->vlu_desc.dsc_dtype = DEFAULT_DOUBLE;
value->vlu_desc.dsc_length = sizeof(double);
@ -4071,8 +4071,8 @@ static DSC *multiply2(const dsc* desc, VLU value, JRD_NOD node)
if (node->nod_flags & nod_quad)
{
const SSHORT scale = NUMERIC_SCALE(value->vlu_desc);
SQUAD q1 = MOV_get_quad(desc, node->nod_scale - scale);
SQUAD q2 = MOV_get_quad(&value->vlu_desc, scale);
const SQUAD q1 = MOV_get_quad(desc, node->nod_scale - scale);
const SQUAD q2 = MOV_get_quad(&value->vlu_desc, scale);
value->vlu_desc.dsc_dtype = dtype_quad;
value->vlu_desc.dsc_length = sizeof(SQUAD);
value->vlu_desc.dsc_scale = node->nod_scale;
@ -4132,7 +4132,7 @@ static DSC *multiply2(const dsc* desc, VLU value, JRD_NOD node)
}
static DSC *divide2(const dsc* desc, VLU value, JRD_NOD node)
static dsc* divide2(const dsc* desc, VLU value, const jrd_nod* node)
{
/**************************************
*
@ -4271,7 +4271,7 @@ static DSC *divide2(const dsc* desc, VLU value, JRD_NOD node)
}
static DSC *negate_dsc(TDBB tdbb, const dsc* desc, VLU value)
static dsc* negate_dsc(TDBB tdbb, const dsc* desc, VLU value)
{
/**************************************
*
@ -4340,7 +4340,7 @@ static DSC *negate_dsc(TDBB tdbb, const dsc* desc, VLU value)
}
static DSC* record_version(TDBB tdbb, const jrd_nod* node, VLU impure)
static dsc* record_version(TDBB tdbb, const jrd_nod* node, VLU impure)
{
/**************************************
*
@ -4422,7 +4422,7 @@ static bool reject_duplicate(const UCHAR* data1, const UCHAR* data2, void* user_
}
static DSC* scalar(TDBB tdbb, JRD_NOD node, VLU impure)
static dsc* scalar(TDBB tdbb, JRD_NOD node, VLU impure)
{
/**************************************
*
@ -4469,7 +4469,7 @@ static DSC* scalar(TDBB tdbb, JRD_NOD node, VLU impure)
}
static SSHORT sleuth(TDBB tdbb, JRD_NOD node, DSC * desc1, DSC * desc2)
static SSHORT sleuth(TDBB tdbb, JRD_NOD node, dsc* desc1, dsc* desc2)
{
/**************************************
*
@ -4568,7 +4568,7 @@ static SSHORT sleuth(TDBB tdbb, JRD_NOD node, DSC * desc1, DSC * desc2)
}
static SSHORT string_boolean(TDBB tdbb, JRD_NOD node, DSC * desc1, DSC * desc2)
static SSHORT string_boolean(TDBB tdbb, JRD_NOD node, dsc* desc1, dsc* desc2)
{
/**************************************
*
@ -4732,9 +4732,9 @@ static SSHORT string_function(
}
static DSC *substring(
static dsc* substring(
TDBB tdbb,
VLU impure, DSC * value, SLONG offset_arg, SLONG length_arg)
VLU impure, dsc* value, SLONG offset_arg, SLONG length_arg)
{
/**************************************
*
@ -4900,7 +4900,7 @@ static DSC *substring(
}
static DSC *upcase(TDBB tdbb, const dsc* value, VLU impure)
static dsc* upcase(TDBB tdbb, const dsc* value, VLU impure)
{
/**************************************
*
@ -4941,7 +4941,7 @@ static DSC *upcase(TDBB tdbb, const dsc* value, VLU impure)
}
static DSC *internal_info(TDBB tdbb, const dsc* value, VLU impure)
static dsc* internal_info(TDBB tdbb, const dsc* value, VLU impure)
{
/**************************************
*

View File

@ -30,7 +30,7 @@ dsc* EVL_assign_to(TDBB tdbb, jrd_nod*);
sbm** EVL_bitmap(TDBB tdbb, jrd_nod*);
BOOLEAN EVL_boolean(TDBB tdbb, jrd_nod*);
dsc* EVL_expr(TDBB tdbb, jrd_nod*);
BOOLEAN EVL_field(jrd_rel*, rec*, USHORT, DSC*);
bool EVL_field(jrd_rel*, rec*, USHORT, DSC*);
USHORT EVL_group(TDBB tdbb, Rsb*, jrd_nod*, USHORT);
USHORT EVL_mb_contains(TDBB tdbb, TextType, const UCHAR*, USHORT, const UCHAR*, USHORT);
USHORT EVL_mb_like(TDBB tdbb, TextType, const UCHAR*, SSHORT, const UCHAR*, SSHORT, USHORT);

View File

@ -1888,7 +1888,7 @@ static JRD_NOD looper(TDBB tdbb, JRD_REQ request, JRD_NOD in_node)
if (request->req_operation == jrd_req::req_evaluate &&
(--tdbb->tdbb_quantum < 0) && !tdbb->tdbb_inhibit)
JRD_reschedule(tdbb, 0, TRUE);
JRD_reschedule(tdbb, 0, true);
#endif

View File

@ -41,11 +41,11 @@
#include "../jrd/intl_proto.h"
#include "../jrd/thd_proto.h"
static ISC_STATUS caller(USHORT, CTL, USHORT, UCHAR*, USHORT*);
static ISC_STATUS caller(USHORT, ctl*, USHORT, UCHAR*, USHORT*);
static void dump_blr(void*, SSHORT, const char*);
static void move(const char*, char*, USHORT);
static ISC_STATUS string_filter(USHORT, CTL);
static void string_put(CTL, const char*);
static ISC_STATUS string_filter(USHORT, ctl*);
static void string_put(ctl*, const char*);
/* Note: This table is used to indicate which bytes could represent
* ASCII characters - and is used to filter "untyped" blobs
@ -74,9 +74,9 @@ typedef struct tmp {
} *TMP;
#ifdef VMS
#define WILD_CARD_UIC "<*,*>"
const char* const WILD_CARD_UIC = "<*,*>";
#else
#define WILD_CARD_UIC "(*.*)"
const char* const WILD_CARD_UIC = "(*.*)";
#endif
/* TXNN: Used on filter of internal data structure to text */
@ -121,7 +121,7 @@ static const TEXT dtypes[][36] = {
};
ISC_STATUS filter_acl(USHORT action, CTL control)
ISC_STATUS filter_acl(USHORT action, ctl* control)
{
/**************************************
*
@ -133,39 +133,39 @@ ISC_STATUS filter_acl(USHORT action, CTL control)
* Get next segment from a access control list.
*
**************************************/
UCHAR *p, *temp, c, buffer[512];
TEXT line[256], *out;
SLONG l;
USHORT length;
ISC_STATUS status;
BOOLEAN all_wild;
if (action != ACTION_open)
return string_filter(action, control);
/* Initialize for retrieval */
l = control->ctl_source_handle->ctl_total_length;
p = temp =
UCHAR buffer[512];
const SLONG l = control->ctl_source_handle->ctl_total_length;
UCHAR* const temp =
(l <= (SLONG) sizeof(buffer)) ? buffer : (UCHAR*) gds__alloc((SLONG) l);
/* FREE: at procedure exit */
UCHAR* p = temp;
if (!p) /* NOMEM: */
return isc_virmemexh;
status = caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
USHORT length;
const ISC_STATUS status =
caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
TEXT line[256];
if (!status) {
sprintf(line, "ACL version %d", (int) *p++);
string_put(control, line);
out = line;
TEXT* out = line;
bool all_wild;
UCHAR c;
while (c = *p++)
switch (c) {
case ACL_id_list:
all_wild = TRUE;
all_wild = true;
*out++ = '\t';
while ((c = *p++) != 0) {
all_wild = FALSE;
all_wild = false;
sprintf(out, "%s%.*s, ", acl_ids[c], *p, p + 1);
p += *p + 1;
while (*out)
@ -201,7 +201,7 @@ ISC_STATUS filter_acl(USHORT action, CTL control)
}
ISC_STATUS filter_blr(USHORT action, CTL control)
ISC_STATUS filter_blr(USHORT action, ctl* control)
{
/**************************************
*
@ -216,23 +216,21 @@ ISC_STATUS filter_blr(USHORT action, CTL control)
* doesn't complain.
*
**************************************/
UCHAR *temp, buffer[512];
USHORT length;
SLONG l;
ISC_STATUS status;
if (action != ACTION_open)
return string_filter(action, control);
/* Initialize for retrieval */
l = 1 + control->ctl_source_handle->ctl_total_length;
temp = (l <=(SLONG) sizeof(buffer)) ? buffer : (UCHAR*) gds__alloc((SLONG) l);
UCHAR buffer[512];
const SLONG l = 1 + control->ctl_source_handle->ctl_total_length;
UCHAR* const temp =
(l <=(SLONG) sizeof(buffer)) ? buffer : (UCHAR*) gds__alloc((SLONG) l);
/* FREE: at procedure exit */
if (!temp) /* NOMEM: */
return isc_virmemexh;
status = caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
USHORT length;
const ISC_STATUS status =
caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
if (!status) {
if ((l > length) && (temp[length - 1] != blr_eoc))
@ -249,7 +247,7 @@ ISC_STATUS filter_blr(USHORT action, CTL control)
}
ISC_STATUS filter_format(USHORT action, CTL control)
ISC_STATUS filter_format(USHORT action, ctl* control)
{
/**************************************
*
@ -261,21 +259,16 @@ ISC_STATUS filter_format(USHORT action, CTL control)
* Get next segment from a record format blob.
*
**************************************/
USHORT length;
ISC_STATUS status;
int value;
DSC desc;
TEXT *p, temp1[64], temp2[64];
/* Unless this is a get segment call, just return success */
if (action != ACTION_get_segment)
return FB_SUCCESS;
/* Loop thru descriptors looking for one with a data type */
dsc desc;
for (;;) {
status = caller(ACTION_get_segment,
USHORT length;
const ISC_STATUS status = caller(ACTION_get_segment,
control,
sizeof(desc),
reinterpret_cast<UCHAR*>(&desc), &length);
@ -286,8 +279,8 @@ ISC_STATUS filter_format(USHORT action, CTL control)
++control->ctl_data[0];
}
value = desc.dsc_scale;
p = const_cast < char *>(dtypes[desc.dsc_dtype]);
int value = desc.dsc_scale;
const TEXT* p = dtypes[desc.dsc_dtype];
if (desc.dsc_dtype == dtype_text)
value = desc.dsc_length;
@ -298,6 +291,7 @@ ISC_STATUS filter_format(USHORT action, CTL control)
value = desc.dsc_dtype;
}
TEXT temp1[64], temp2[64];
if ((desc.dsc_dtype <= dtype_any_text) && (desc.dsc_ttype != 0)) {
sprintf(temp2, p, value);
sprintf(temp1, "%s, sub-type %d", temp2, INTL_TTYPE(&desc));
@ -307,7 +301,8 @@ ISC_STATUS filter_format(USHORT action, CTL control)
sprintf(temp2, "%ld: %s", control->ctl_data[0]++, temp1);
if ((length = strlen(temp2)) > control->ctl_buffer_length)
USHORT length = strlen(temp2);
if (length > control->ctl_buffer_length)
length = control->ctl_buffer_length;
control->ctl_segment_length = length;
@ -317,7 +312,7 @@ ISC_STATUS filter_format(USHORT action, CTL control)
}
ISC_STATUS filter_runtime(USHORT action, CTL control)
ISC_STATUS filter_runtime(USHORT action, ctl* control)
{
/**************************************
*
@ -329,13 +324,6 @@ ISC_STATUS filter_runtime(USHORT action, CTL control)
* Get next segment from a relation runtime summary blob.
*
**************************************/
USHORT length, buff_len, n, blr;
ISC_STATUS status;
TEXT *q, line[128];
UCHAR* p;
UCHAR temp[256];
UCHAR* buff;
if (action == ACTION_close)
return string_filter(action, control);
@ -347,19 +335,21 @@ ISC_STATUS filter_runtime(USHORT action, CTL control)
/* If there is a string filter active, use it first */
if (control->ctl_data[0]) {
status = string_filter(action, control);
if (status != isc_segstr_eof)
return status;
const ISC_STATUS astatus = string_filter(action, control);
if (astatus != isc_segstr_eof)
return astatus;
string_filter(ACTION_close, control);
}
/* Loop thru descriptors looking for one with a data type */
buff = temp;
buff_len = sizeof(temp);
UCHAR temp[256];
UCHAR* buff = temp;
const USHORT buff_len = sizeof(temp);
control->ctl_data[3] = 8;
status = caller(ACTION_get_segment, control, buff_len, buff, &length);
USHORT length;
const ISC_STATUS status =
caller(ACTION_get_segment, control, buff_len, buff, &length);
if (status == isc_segment)
return isc_segstr_eof;
@ -368,12 +358,14 @@ ISC_STATUS filter_runtime(USHORT action, CTL control)
return status;
buff[length] = 0;
p = buff + 1;
q = (TEXT *) & n;
UCHAR* p = buff + 1;
USHORT n;
UCHAR* q = (UCHAR*) &n;
q[0] = p[0];
q[1] = p[1];
blr = FALSE;
bool blr = false;
TEXT line[128];
switch ((RSR_T) buff[0]) {
case RSR_field_name:
sprintf(line, " name: %s", p);
@ -401,22 +393,22 @@ ISC_STATUS filter_runtime(USHORT action, CTL control)
case RSR_computed_blr:
sprintf(line, " computed_blr:");
blr = TRUE;
blr = true;
break;
case RSR_missing_value:
sprintf(line, " missing_value:");
blr = TRUE;
blr = true;
break;
case RSR_default_value:
sprintf(line, " default_value:");
blr = TRUE;
blr = true;
break;
case RSR_validation_blr:
sprintf(line, " validation_blr:");
blr = TRUE;
blr = true;
break;
case RSR_security_class:
@ -459,7 +451,7 @@ ISC_STATUS filter_runtime(USHORT action, CTL control)
}
ISC_STATUS filter_text(USHORT action, CTL control)
ISC_STATUS filter_text(USHORT action, ctl* control)
{
/**************************************
*
@ -479,10 +471,7 @@ ISC_STATUS filter_text(USHORT action, CTL control)
* ctl_data [3] length of temp space
*
**************************************/
CTL source;
TEXT *p, *left_over;
USHORT length, l, left_length, buffer_used;
ISC_STATUS status;
ctl* source;
switch (action) {
case ACTION_open:
@ -520,14 +509,15 @@ ISC_STATUS filter_text(USHORT action, CTL control)
/* Drop thru for ACTION_get_segment. */
left_over = 0;
left_length = 0;
buffer_used = 0;
const TEXT* left_over = 0;
USHORT left_length = 0;
USHORT buffer_used = 0;
/* if there was any data left over from previous get, use as much as
user's buffer will hold */
if (length = control->ctl_data[0]) {
const USHORT length = control->ctl_data[0];
if (length) {
buffer_used = MIN(length, control->ctl_buffer_length);
MOVE_FAST((void *) control->ctl_data[1], control->ctl_buffer,
buffer_used);
@ -547,12 +537,11 @@ ISC_STATUS filter_text(USHORT action, CTL control)
/* if there was no data left over from previous get or all the data
left from previous get was used and there is still more of that segment
not read, do a get segment */
if ((buffer_used == 0) || (control->ctl_data[2] &&
((l = (control->ctl_buffer_length - buffer_used)) > 0)))
(control->ctl_buffer_length - buffer_used > 0)))
{
l = control->ctl_buffer_length - buffer_used;
status = caller(ACTION_get_segment, control, l,
USHORT l = control->ctl_buffer_length - buffer_used;
const ISC_STATUS status = caller(ACTION_get_segment, control, l,
control->ctl_buffer + buffer_used, &l);
if (status == isc_segment)
control->ctl_data[2] = isc_segment;
@ -565,19 +554,21 @@ ISC_STATUS filter_text(USHORT action, CTL control)
/* Search data for unprintable data or EOL */
for (p = reinterpret_cast < char *>(control->ctl_buffer), l = buffer_used;
l; p++, --l) {
if (*p == '\n') {
USHORT l = buffer_used;
for (UCHAR* p = control->ctl_buffer; l; p++, --l)
{
if (*p == (UCHAR) '\n') {
/* Found a newline. First save what comes after the newline. */
control->ctl_segment_length = (UCHAR *) p - control->ctl_buffer;
control->ctl_segment_length = p - control->ctl_buffer;
control->ctl_data[0] = l - 1;
/* if control buffer cannot accommodate what needs to be saved, free
the control buffer */
if (control->ctl_data[1]
&& (control->ctl_data[0] > control->ctl_data[3])) {
&& (control->ctl_data[0] > control->ctl_data[3]))
{
gds__free((SLONG *) control->ctl_data[1]);
control->ctl_data[1] = (IPTR) NULL;
control->ctl_data[3] = 0;
@ -607,7 +598,7 @@ ISC_STATUS filter_text(USHORT action, CTL control)
control buffer before what was left over. */
if (left_over) {
p = (TEXT *) control->ctl_data[1] + l - 1;
p = reinterpret_cast<UCHAR*>(control->ctl_data[1]) + l - 1;
MOVE_FAST(left_over, p, left_length);
control->ctl_data[0] += left_length;
}
@ -616,7 +607,7 @@ ISC_STATUS filter_text(USHORT action, CTL control)
/* replace unprintable characters */
if (*(UCHAR *) p >= sizeof(char_tab) || !char_tab[*p])
if (*p >= sizeof(char_tab) || !char_tab[*p])
*p = '.';
}
@ -637,7 +628,7 @@ ISC_STATUS filter_text(USHORT action, CTL control)
}
ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
ISC_STATUS filter_transliterate_text(USHORT action, ctl* control)
{
/**************************************
*
@ -653,35 +644,30 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
* ctl_data [0] Pointer to ctlaux structure below,
*
**************************************/
CTL source;
USHORT length;
USHORT unused_len;
ISC_STATUS status;
SSHORT err_code;
USHORT err_position;
SSHORT can_use_more;
USHORT bytes_read_from_source;
SSHORT source_cs, dest_cs;
SSHORT i;
USHORT result_length;
typedef struct ctlaux {
struct ctlaux {
CsConvert ctlaux_obj1; /* Intl object that does tx for us */
BYTE *ctlaux_buffer1; /* Temporary buffer for transliteration */
CTL ctlaux_subfilter; /* For chaining transliterate filters */
ctl* ctlaux_subfilter; /* For chaining transliterate filters */
ISC_STATUS ctlaux_source_blob_status; /* marks when source is EOF, etc */
USHORT ctlaux_buffer1_len; /* size of ctlaux_buffer1 in bytes */
USHORT ctlaux_expansion_factor; /* factor for text expand/contraction */
USHORT ctlaux_buffer1_unused; /* unused bytes in ctlaux_buffer1 */
} *CTLAUX;
};
CTLAUX aux;
TDBB tdbb = NULL;
/* Note: Cannot pass tdbb without API change to user filters */
#define EXP_SCALE 128 /* to keep expansion non-floating */
aux = (CTLAUX) control->ctl_data[0];
ctlaux* aux = (ctlaux*) control->ctl_data[0];
ctl* source;
ISC_STATUS status;
SSHORT err_code;
USHORT err_position;
SSHORT source_cs, dest_cs;
SSHORT i;
USHORT result_length;
switch (action) {
case ACTION_open:
@ -696,7 +682,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
source_cs = control->ctl_from_sub_type;
dest_cs = control->ctl_to_sub_type;
aux = (CTLAUX) gds__alloc((SLONG) sizeof(*aux));
aux = (ctlaux*) gds__alloc((SLONG) sizeof(*aux));
/* FREE: on ACTION_close in this routine */
if (!aux) /* NOMEM: */
return isc_virmemexh;
@ -737,8 +723,9 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
return isc_text_subtype;
}
// ISC_STATUS to pointer!
aux->ctlaux_subfilter =
(CTL) caller(ACTION_alloc, control, 0, NULL, NULL);
(ctl*) caller(ACTION_alloc, control, 0, NULL, NULL);
/* This is freed in BLF_close_filter */
@ -790,15 +777,12 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
(80 * aux->ctlaux_expansion_factor) / EXP_SCALE);
}
else { /* ACTION_create */
USHORT tmp;
/* In a create, the source->ctl_max_segment size isn't set (as
* nothing has been written!). Therefore, take a best guess
* for an appropriate buffer size, allocate that, and re-allocate
* later if we guess wrong.
*/
tmp = aux->ctlaux_obj1.convert( NULL, 0, NULL,
const USHORT tmp = aux->ctlaux_obj1.convert( NULL, 0, NULL,
128, &err_code, &err_position);
aux->ctlaux_expansion_factor = (EXP_SCALE * tmp) / 128;
@ -906,21 +890,22 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
/* Do we already have enough bytes in temp buffer to fill output buffer? */
length = aux->ctlaux_buffer1_unused;
bool can_use_more;
USHORT length = aux->ctlaux_buffer1_unused;
if (length) {
if (control->ctl_buffer_length <
(length * aux->ctlaux_expansion_factor / EXP_SCALE)) {
/* No need to fetch more bytes, we have enough pending */
can_use_more = FALSE;
can_use_more = false;
}
else
can_use_more = TRUE;
can_use_more = true;
/* Always keep a minimal count of bytes in the input buffer,
* to prevent the case of truncated characters.
*/
if (length < 3)
can_use_more = TRUE;
can_use_more = true;
}
/* Load data into the temporary buffer if,
@ -931,16 +916,17 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
already have more than we can use) */
if (!length || can_use_more
&& (aux->ctlaux_source_blob_status == isc_segment)) {
/* Get a segment, or partial segment, from the source
* into the temporary buffer
*/
&& (aux->ctlaux_source_blob_status == isc_segment))
{
// Get a segment, or partial segment, from the source
// into the temporary buffer
USHORT bytes_read_from_source = 0;
status = caller(ACTION_get_segment,
control,
(USHORT) (aux->ctlaux_buffer1_len - length),
aux->ctlaux_buffer1 + length,
(USHORT *) & bytes_read_from_source);
&bytes_read_from_source);
if (status == isc_segment) /* source has more segment bytes */
aux->ctlaux_source_blob_status = status;
else if (status == isc_segstr_eof) { /* source blob is finished */
@ -972,14 +958,13 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
if (err_position == 0)
return isc_transliteration_failed;
}
if (err_code == 0)
unused_len = 0;
else
unused_len = length - err_position;
const USHORT unused_len = (err_code == 0) ? 0 : length - err_position;
control->ctl_segment_length = result_length;
if (unused_len)
if (unused_len) {
move((TEXT *) (aux->ctlaux_buffer1 + err_position),
(TEXT *) aux->ctlaux_buffer1, unused_len);
}
aux->ctlaux_buffer1_unused = unused_len;
/* update local control variables for segment length */
@ -999,12 +984,12 @@ ISC_STATUS filter_transliterate_text(USHORT action, CTL control)
* from the source?
*/
return (aux->ctlaux_source_blob_status ==
isc_segment) ? isc_segment : FB_SUCCESS;
return (aux->ctlaux_source_blob_status == isc_segment) ?
isc_segment : FB_SUCCESS;
}
ISC_STATUS filter_trans(USHORT action, CTL control)
ISC_STATUS filter_trans(USHORT action, ctl* control)
{
/**************************************
*
@ -1016,34 +1001,32 @@ ISC_STATUS filter_trans(USHORT action, CTL control)
* Pretty print a transaction description.
*
**************************************/
UCHAR *p, *end, *temp, c, buffer[512];
TEXT *out, line[256];
USHORT length;
ISC_STATUS status;
SLONG id, l;
if (action != ACTION_open)
return string_filter(action, control);
/* Initialize for retrieval */
l = control->ctl_source_handle->ctl_total_length;
p = temp =
UCHAR buffer[512];
const SLONG l = control->ctl_source_handle->ctl_total_length;
UCHAR* const temp =
(l <= (SLONG) sizeof(buffer)) ? buffer : (UCHAR*) gds__alloc((SLONG) l);
UCHAR* p = temp;
/* FREE: at procedure exit */
if (!p) /* NOMEM: */
return isc_virmemexh;
status = caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
USHORT length;
const ISC_STATUS status =
caller(ACTION_get_segment, control, (USHORT) l, temp, &length);
if (!status) {
TEXT line[256];
sprintf(line, "Transaction description version: %d", (int) *p++);
string_put(control, line);
out = line;
end = temp + length;
TEXT* out = line;
const UCHAR* const end = temp + length;
while (p < end) {
c = *p++;
const UCHAR c = *p++;
length = *p++;
switch (c) {
case TDR_HOST_SITE:
@ -1059,10 +1042,11 @@ ISC_STATUS filter_trans(USHORT action, CTL control)
break;
case TDR_TRANSACTION_ID:
id =
gds__vax_integer(p, length);
sprintf(out, " Transaction id: %ld", id);
break;
{
const SLONG id = gds__vax_integer(p, length);
sprintf(out, " Transaction id: %ld", id);
break;
}
default:
sprintf(out, "item %d not understood", (int) p[-1]);
@ -1086,7 +1070,7 @@ ISC_STATUS filter_trans(USHORT action, CTL control)
static ISC_STATUS caller(
USHORT action,
CTL control,
ctl* control,
USHORT buffer_length,
UCHAR* buffer, USHORT* return_length)
{
@ -1100,15 +1084,13 @@ static ISC_STATUS caller(
* Call next source filter.
*
**************************************/
ISC_STATUS status;
CTL source;
source = control->ctl_source_handle;
ctl* source = control->ctl_source_handle;
source->ctl_status = control->ctl_status;
source->ctl_buffer = buffer;
source->ctl_buffer_length = buffer_length;
status = (*source->ctl_source) (action, source);
// Warning: it will be pointer to ISC_STATUS when action == ACTION_alloc.
const ISC_STATUS status = (*source->ctl_source) (action, source);
if (return_length)
*return_length = source->ctl_segment_length;
@ -1129,12 +1111,12 @@ static void dump_blr(void* arg, SSHORT offset, const char* line)
* Callback routine for BLR dumping.
*
**************************************/
CTL control = reinterpret_cast<CTL>(arg);
SLONG l;
TEXT *p, *end, *temp, buffer[256];
ctl* control = reinterpret_cast<ctl*>(arg);
TEXT buffer[256];
l = (USHORT) control->ctl_data[3] + strlen(line);
temp = (l < (SLONG) sizeof(buffer)) ? buffer : (TEXT *) gds__alloc((SLONG) l);
const SLONG l = (USHORT) control->ctl_data[3] + strlen(line);
TEXT* const temp = (l < (SLONG) sizeof(buffer)) ?
buffer : (TEXT*) gds__alloc((SLONG) l);
/* FREE: at procedure exit */
if (!temp) { /* NOMEM: */
/* No memory left - ignore the padding spaces and put the data */
@ -1143,7 +1125,8 @@ static void dump_blr(void* arg, SSHORT offset, const char* line)
}
/* Pad out to indent length with spaces */
for (p = temp, end = p + (USHORT) control->ctl_data[3]; p < end;)
TEXT* p = temp;
for (const TEXT* const end = p + (USHORT) control->ctl_data[3]; p < end;)
*p++ = ' ';
sprintf(p, "%s", line);
@ -1166,7 +1149,6 @@ static void move(const char* from, char* to, USHORT length)
* Move some bytes.
*
**************************************/
if (length)
do {
*to++ = *from++;
@ -1174,7 +1156,7 @@ static void move(const char* from, char* to, USHORT length)
}
static ISC_STATUS string_filter(USHORT action, CTL control)
static ISC_STATUS string_filter(USHORT action, ctl* control)
{
/**************************************
*
@ -1231,7 +1213,7 @@ static ISC_STATUS string_filter(USHORT action, CTL control)
}
static void string_put(CTL control, const char* line)
static void string_put(ctl* control, const char* line)
{
/**************************************
*
@ -1243,11 +1225,8 @@ static void string_put(CTL control, const char* line)
* Add a line of string to a string formatted blob.
*
**************************************/
TMP string, prior;
USHORT l;
l = strlen(line);
string = (TMP) gds__alloc((SLONG) (sizeof(tmp) + l));
const USHORT l = strlen(line);
TMP string = (TMP) gds__alloc((SLONG) (sizeof(tmp) + l));
/* FREE: on ACTION_close in string_filter() */
if (!string) { /* NOMEM: */
fb_assert(FALSE); /* out of memory */
@ -1257,6 +1236,7 @@ static void string_put(CTL control, const char* line)
string->tmp_length = l;
move(line, string->tmp_string, l);
TMP prior;
if (prior = (TMP) control->ctl_data[1])
prior->tmp_next = string;
else

View File

@ -31,9 +31,12 @@ extern "C" {
mod* FLU_lookup_module(TEXT*);
void FLU_unregister_module(mod*);
int (*ISC_lookup_entrypoint(TEXT*, TEXT*, const TEXT*, bool)) (void);
int (*FUNCTIONS_entrypoint(TEXT*, TEXT*)) (void);
int (*BUILTIN_entrypoint(TEXT*, TEXT*)) (void);
// int (*ISC_lookup_entrypoint(TEXT*, TEXT*, const TEXT*, bool)) (void);
// int (*FUNCTIONS_entrypoint(TEXT*, TEXT*)) (void);
// int (*BUILTIN_entrypoint(TEXT*, TEXT*)) (void);
FPTR_INT ISC_lookup_entrypoint(TEXT*, TEXT*, const TEXT*, bool);
FPTR_INT FUNCTIONS_entrypoint(char*, char*);
FPTR_INT BUILTIN_entrypoint(const TEXT*, const TEXT*);
/*
This shouldn't be in a production server,
@ -52,3 +55,4 @@ int (*BUILTIN_entrypoint(TEXT*, TEXT*)) (void);
#endif
#endif // JRD_FLU_PROTO_H

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: InterBase Access Method
* MODULE: functions.c
* MODULE: functions.cpp
* DESCRIPTION: External entrypoint definitions
*
* The contents of this file are subject to the Interbase Public
@ -33,21 +33,20 @@ extern "C" {
typedef struct {
char *fn_module;
char *fn_entrypoint;
const char* fn_module;
const char* fn_entrypoint;
FPTR_INT fn_function;
} FN;
FPTR_INT FUNCTIONS_entrypoint(char *, char *);
static int test(long, char *);
// FPTR_INT FUNCTIONS_entrypoint(char*, char*);
static int test(long, char*);
static DSC* ni(DSC*, DSC*);
#pragma FB_COMPILER_MESSAGE("Fix! function pointer cast!")
static FN isc_functions[] = {
static const FN isc_functions[] = {
{"test_module", "test_function", (int (*)()) test},
{"test_module", "ni", (int (*)()) ni},
{"test_module", "ns", (int (*)()) ni},
@ -56,7 +55,7 @@ static FN isc_functions[] = {
};
FPTR_INT FUNCTIONS_entrypoint(char *module, char *entrypoint)
FPTR_INT FUNCTIONS_entrypoint(char* module, char* entrypoint)
{
/**************************************
*
@ -70,26 +69,28 @@ FPTR_INT FUNCTIONS_entrypoint(char *module, char *entrypoint)
* insignificant trailing blanks.
*
**************************************/
FN *function;
char *p, temp[MAXPATHLEN + 128], *ep; /* Bug #126614 Fix */
char temp[MAXPATHLEN + 128]; /* Bug #126614 Fix */
p = temp;
char* p = temp;
while (*module && *module != ' ')
*p++ = *module++;
*p++ = 0;
ep = p;
const char* ep = p;
while (*entrypoint && *entrypoint != ' ')
*p++ = *entrypoint++;
*p = 0;
for (function = isc_functions; function->fn_module; ++function)
for (const FN* function = isc_functions; function->fn_module; ++function) {
if (!strcmp(temp, function->fn_module)
&& !strcmp(ep, function->fn_entrypoint))
{
return function->fn_function;
}
}
return 0;
}
@ -113,7 +114,7 @@ static int test(long n, char *result)
**************************************/
sprintf(result, "%ld is a number", n);
const char *end = result + 20;
const char* const end = result + 20;
while (*result)
result++;
@ -125,7 +126,7 @@ static int test(long n, char *result)
}
static DSC* ni(DSC* v, DSC* v2)
static dsc* ni(dsc* v, dsc* v2)
{
if (v)
return v;
@ -134,3 +135,4 @@ static DSC* ni(DSC* v, DSC* v2)
}
} // extern "C"

View File

@ -968,7 +968,7 @@ SLONG API_ROUTINE gds__interprete(char* s, ISC_STATUS** vector)
while (*end)
end++;
return end - s;
return static_cast<SLONG>(end - s);
}
@ -3642,7 +3642,7 @@ void gds__trace_printer(void* arg, SSHORT offset, const TEXT* line)
gds__ulstr(p, offset, 4, ' ');
p += strlen(p);
*p++ = ' ';
strcpy(p, line); p+=strlen(p);
strcpy(p, line); p += strlen(p);
*p++ = '\n';
*p = 0;
gds__trace_raw(buffer);

View File

@ -259,9 +259,9 @@ void GDS_EXPORT gds__vtof(const char*,
void GDS_EXPORT gds__vtov(const SCHAR*, char*, SSHORT);
int GDS_EXPORT gds__version(FRBRD **,
FPTR_VOID,
void *);
int GDS_EXPORT gds__version(FRBRD**,
FPTR_VERSION_CALLBACK,
void*);
int GDS_EXPORT gds__disable_subsystem(char *);
@ -288,7 +288,7 @@ ISC_STATUS GDS_EXPORT gds__que_events(ISC_STATUS*,
SLONG*,
short,
const char*,
void (*) (),
FPTR_EVENT_CALLBACK,
void*);
ISC_STATUS GDS_EXPORT gds__cancel_events(ISC_STATUS *,

View File

@ -33,7 +33,7 @@
*
*/
/*
$Id: ibase.h,v 1.61 2003-12-21 23:54:24 skidder Exp $
$Id: ibase.h,v 1.62 2003-12-22 10:00:47 robocop Exp $
*/
#ifndef JRD_IBASE_H
@ -267,8 +267,10 @@ typedef struct paramvary {
/* Note that dtype_null actually means that we do not yet know the
dtype for this descriptor. A nice cleanup item would be to globally
change it to dtype_unknown. --chrisj 1999-02-17 */
/* Name changed on 2003.12.17 by CVC. */
#define dtype_null 0
/* #define dtype_null 0 Enable it if some apps use the old name */
#define dtype_unknown 0
#define dtype_text 1
#define dtype_cstring 2
#define dtype_varying 3
@ -363,11 +365,11 @@ ISC_STATUS ISC_EXPORT isc_attach_database(ISC_STATUS*,
short,
const char*);
ISC_STATUS ISC_EXPORT isc_array_gen_sdl(ISC_STATUS *,
ISC_ARRAY_DESC *,
short *,
char *,
short *);
ISC_STATUS ISC_EXPORT isc_array_gen_sdl(ISC_STATUS*,
const ISC_ARRAY_DESC*,
short*,
char*,
short*);
ISC_STATUS ISC_EXPORT isc_array_get_slice(ISC_STATUS*,
isc_db_handle*,
@ -692,7 +694,7 @@ ISC_STATUS ISC_EXPORT isc_que_events(ISC_STATUS*,
ISC_LONG*,
short,
const char*,
isc_callback,
FPTR_EVENT_CALLBACK,
void*);
ISC_STATUS ISC_EXPORT isc_rollback_retaining(ISC_STATUS *,
@ -775,11 +777,11 @@ typedef struct {
char *dba_password; /* the dba password */
} USER_SEC_DATA;
int ISC_EXPORT isc_add_user(ISC_STATUS*, USER_SEC_DATA*);
ISC_STATUS ISC_EXPORT isc_add_user(ISC_STATUS*, const USER_SEC_DATA*);
int ISC_EXPORT isc_delete_user(ISC_STATUS*, USER_SEC_DATA*);
ISC_STATUS ISC_EXPORT isc_delete_user(ISC_STATUS*, const USER_SEC_DATA*);
int ISC_EXPORT isc_modify_user(ISC_STATUS*, USER_SEC_DATA*);
ISC_STATUS ISC_EXPORT isc_modify_user(ISC_STATUS*, const USER_SEC_DATA*);
/**********************************/
/* Other OSRI functions */
@ -1145,7 +1147,7 @@ ISC_LONG ISC_EXPORT isc_ftof(const char*,
const unsigned short);
ISC_STATUS ISC_EXPORT isc_print_blr(const char*,
isc_callback,
FPTR_PRINT_CALLBACK,
void*,
short);
@ -1162,9 +1164,9 @@ void ISC_EXPORT isc_vtov(const char*,
char*,
short);
int ISC_EXPORT isc_version(isc_db_handle *,
isc_callback,
void *);
int ISC_EXPORT isc_version(isc_db_handle*,
FPTR_VERSION_CALLBACK,
void*);
ISC_LONG ISC_EXPORT isc_reset_fpe(unsigned short);

View File

@ -84,7 +84,7 @@ static bool duplicate_key(const UCHAR*, const UCHAR*, void*);
static SLONG get_root_page(TDBB, JRD_REL);
static int index_block_flush(void *ast_object);
static IDX_E insert_key(TDBB, JRD_REL, REC, JRD_TRA, WIN *, IIB *, JRD_REL *, USHORT *);
static BOOLEAN key_equal(KEY *, KEY *);
static bool key_equal(const KEY*, const KEY*);
static void signal_index_deletion(TDBB, JRD_REL, USHORT);
@ -104,15 +104,9 @@ void IDX_check_access(TDBB tdbb, CSB csb, JRD_REL view, JRD_REL relation, JRD_FL
* ain't there.
*
**************************************/
IDX idx, referenced_idx;
JRD_REL referenced_relation;
JRD_FLD referenced_field;
IRT referenced_root;
USHORT index_id, i;
idx::idx_repeat * idx_desc;
SET_TDBB(tdbb);
IDX idx;
idx.idx_id = (USHORT) -1;
WIN window(-1);
WIN referenced_window(-1);
@ -124,18 +118,19 @@ void IDX_check_access(TDBB tdbb, CSB csb, JRD_REL view, JRD_REL relation, JRD_FL
if (!MET_lookup_partner(tdbb, relation, &idx, &NULL_STR)) {
continue;
}
referenced_relation =
jrd_rel* referenced_relation =
MET_relation(tdbb, idx.idx_primary_relation);
MET_scan_relation(tdbb, referenced_relation);
index_id = (USHORT) idx.idx_primary_index;
const USHORT index_id = (USHORT) idx.idx_primary_index;
/* get the description of the primary key index */
referenced_window.win_page =
get_root_page(tdbb, referenced_relation);
referenced_window.win_flags = 0;
referenced_root =
irt* referenced_root =
(IRT) CCH_FETCH(tdbb, &referenced_window, LCK_read, pag_root);
IDX referenced_idx;
if (!BTR_description
(referenced_relation, referenced_root, &referenced_idx,
index_id))
@ -145,9 +140,9 @@ void IDX_check_access(TDBB tdbb, CSB csb, JRD_REL view, JRD_REL relation, JRD_FL
/* post references access to each field in the index */
idx_desc = referenced_idx.idx_rpt;
for (i = 0; i < referenced_idx.idx_count; i++, idx_desc++) {
referenced_field =
const idx::idx_repeat* idx_desc = referenced_idx.idx_rpt;
for (USHORT i = 0; i < referenced_idx.idx_count; i++, idx_desc++) {
const jrd_fld* referenced_field =
MET_get_field(referenced_relation, idx_desc->idx_field);
CMP_post_access(tdbb, csb,
referenced_relation->rel_security_name,
@ -184,27 +179,16 @@ void IDX_create_index(
* Create and populate index.
*
**************************************/
ATT attachment;
USHORT key_length, l;
RPB primary, secondary;
LLS stack;
REC record, gc_record;
ISR isr;
KEY key;
SCB sort_handle;
UCHAR *p, *q, pad;
JRD_REL partner_relation;
USHORT partner_index_id;
BOOLEAN cancel = FALSE;
IDX_E result = idx_e_ok;
struct ifl ifl_data;
SET_TDBB(tdbb);
DBB dbb = tdbb->tdbb_database;
if (relation->rel_file)
if (relation->rel_file) {
ERR_post(isc_no_meta_update, isc_arg_gds, isc_extfile_uns_op,
isc_arg_string, ERR_cstring(relation->rel_name), 0);
}
BTR_reserve_slot(tdbb, relation, transaction, idx);
@ -212,12 +196,13 @@ void IDX_create_index(
*index_id = idx->idx_id;
}
RPB primary, secondary;
secondary.rpb_relation = relation;
primary.rpb_relation = relation;
primary.rpb_number = -1;
primary.rpb_window.win_flags = secondary.rpb_window.win_flags = 0;
key_length = ROUNDUP(BTR_key_length(relation, idx), sizeof(SLONG));
const USHORT key_length = ROUNDUP(BTR_key_length(relation, idx), sizeof(SLONG));
USHORT max_key_size = MAX_KEY_LIMIT;
if (dbb->dbb_ods_version < ODS_VERSION11) {
@ -231,8 +216,8 @@ void IDX_create_index(
ERR_cstring(index_name), 0);
}
stack = NULL;
pad = (idx->idx_flags & idx_descending) ? -1 : 0;
lls* stack = NULL;
const UCHAR pad = (idx->idx_flags & idx_descending) ? -1 : 0;
ifl_data.ifl_duplicates = 0;
ifl_data.ifl_key_length = key_length;
@ -251,7 +236,7 @@ void IDX_create_index(
void* callback_arg =
(idx->idx_flags & idx_unique) ? &ifl_data : NULL;
sort_handle = SORT_init(tdbb->tdbb_status_vector,
SCB sort_handle = SORT_init(tdbb->tdbb_status_vector,
key_length + sizeof(struct isr),
1, &key_desc, callback, callback_arg,
tdbb->tdbb_attachment, 0);
@ -259,6 +244,8 @@ void IDX_create_index(
if (!sort_handle)
ERR_punt();
jrd_rel* partner_relation = 0;
USHORT partner_index_id = 0;
if (idx->idx_flags & idx_foreign) {
if (!MET_lookup_partner(tdbb, relation, idx, index_name)) {
BUGCHECK(173); /* msg 173 referenced index description not found */
@ -269,15 +256,17 @@ void IDX_create_index(
/* Checkout a garbage collect record block for fetching data. */
gc_record = VIO_gc_record(tdbb, relation);
REC gc_record = VIO_gc_record(tdbb, relation);
/* Unless this is the only attachment or a database restore, worry about
preserving the page working sets of other attachments. */
if ((attachment = tdbb->tdbb_attachment) &&
(attachment != dbb->dbb_attachments || attachment->att_next)) {
att* attachment = tdbb->tdbb_attachment;
if ((attachment) &&
(attachment != dbb->dbb_attachments || attachment->att_next))
{
if (attachment->att_flags & ATT_gbak_attachment ||
DPM_data_pages(tdbb, relation) > (SLONG) dbb->dbb_bcb->bcb_count) {
DPM_data_pages(tdbb, relation) > (SLONG) dbb->dbb_bcb->bcb_count)
{
primary.rpb_window.win_flags = secondary.rpb_window.win_flags =
WIN_large_scan;
primary.rpb_org_scans = secondary.rpb_org_scans =
@ -287,7 +276,8 @@ void IDX_create_index(
/* Loop thru the relation computing index keys. If there are old versions,
find them, too. */
BOOLEAN cancel = FALSE;
KEY key;
while (!cancel && DPM_next(tdbb, &primary, LCK_read, FALSE, FALSE)) {
if (transaction && !VIO_garbage_collect(tdbb, &primary, transaction))
continue;
@ -315,7 +305,7 @@ void IDX_create_index(
}
while (stack) {
record = (REC) LLS_POP(&stack);
rec* record = (REC) LLS_POP(&stack);
/* If foreign key index is being defined, make sure foreign
key definition will not be violated */
@ -375,6 +365,7 @@ void IDX_create_index(
BUGCHECK(174); /* msg 174 index key too big */
}
UCHAR* p;
SORT_put(tdbb->tdbb_status_vector, sort_handle,
reinterpret_cast<ULONG**>(&p));
@ -393,10 +384,10 @@ void IDX_create_index(
ERR_cstring(index_name), 0);
}
l = key.key_length;
q = key.key_data;
USHORT l = key.key_length;
if (l > 0) {
const UCHAR* q = key.key_data;
do {
*p++ = *q++;
} while (--l);
@ -406,7 +397,7 @@ void IDX_create_index(
*p++ = pad;
} while (--l);
}
isr = (ISR) p;
ISR isr = (ISR) p;
isr->isr_key_length = key.key_length;
isr->isr_record_number = primary.rpb_number;
isr->isr_flags = (stack ? ISR_secondary : 0) | (key_is_null ? ISR_null : 0);
@ -416,7 +407,7 @@ void IDX_create_index(
#ifdef SUPERSERVER
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit)
cancel = JRD_reschedule(tdbb, 0, FALSE);
cancel = JRD_reschedule(tdbb, 0, false);
#endif
}
@ -458,15 +449,13 @@ IDB IDX_create_index_block(TDBB tdbb, JRD_REL relation, USHORT id)
* lock block for the specified index.
*
**************************************/
DBB dbb;
IDB index_block;
LCK lock;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
CHECK_DBB(dbb);
index_block = FB_NEW(*dbb->dbb_permanent) idb();
IDB index_block = FB_NEW(*dbb->dbb_permanent) idb();
index_block->idb_id = id;
/* link the block in with the relation linked list */
@ -528,13 +517,12 @@ void IDX_delete_indices(TDBB tdbb, JRD_REL relation)
* complete relation.
*
**************************************/
IRT root;
SSHORT i;
SET_TDBB(tdbb);
WIN window(relation->rel_index_root);
root = (IRT) CCH_FETCH(tdbb, &window, LCK_write, pag_root);
IRT root = (IRT) CCH_FETCH(tdbb, &window, LCK_write, pag_root);
for (i = 0; i < root->irt_count; i++) {
BTR_delete_index(tdbb, &window, i);
@ -562,11 +550,10 @@ IDX_E IDX_erase(TDBB tdbb,
*
**************************************/
IDX idx;
IDX_E error_code;
SET_TDBB(tdbb);
error_code = idx_e_ok;
IDX_E error_code = idx_e_ok;
idx.idx_id = (USHORT) -1;
WIN window(-1);
@ -599,13 +586,9 @@ void IDX_garbage_collect(TDBB tdbb, RPB * rpb, LLS going, LLS staying)
* each.
*
**************************************/
LLS stack1, stack2;
REC rec1, rec2;
IIB insertion;
IDX idx;
KEY key1, key2;
IRT root;
USHORT i;
SET_TDBB(tdbb);
@ -615,18 +598,19 @@ void IDX_garbage_collect(TDBB tdbb, RPB * rpb, LLS going, LLS staying)
insertion.iib_key = &key1;
WIN window(rpb->rpb_relation->rel_index_root);
root = (IRT) CCH_FETCH(tdbb, &window, LCK_read, pag_root);
IRT root = (IRT) CCH_FETCH(tdbb, &window, LCK_read, pag_root);
for (i = 0; i < root->irt_count; i++)
for (USHORT i = 0; i < root->irt_count; i++) {
if (BTR_description(rpb->rpb_relation, root, &idx, i)) {
for (stack1 = going; stack1; stack1 = stack1->lls_next) {
rec1 = (REC) stack1->lls_object;
for (lls* stack1 = going; stack1; stack1 = stack1->lls_next) {
REC rec1 = (REC) stack1->lls_object;
BTR_key(tdbb, rpb->rpb_relation, rec1, &idx, &key1, 0);
/* Cancel index if there are duplicates in the remaining records */
for (stack2 = stack1->lls_next; stack2; stack2 = stack2->lls_next) {
rec2 = (REC) stack2->lls_object;
lls* stack2;
for(stack2 = stack1->lls_next; stack2; stack2 = stack2->lls_next) {
REC rec2 = (REC) stack2->lls_object;
if (rec2->rec_number == rec1->rec_number) {
BTR_key(tdbb, rpb->rpb_relation, rec2, &idx, &key2, 0);
if (key_equal(&key1, &key2))
@ -639,7 +623,7 @@ void IDX_garbage_collect(TDBB tdbb, RPB * rpb, LLS going, LLS staying)
/* Make sure the index doesn't exist in any record remaining */
for (stack2 = staying; stack2; stack2 = stack2->lls_next) {
rec2 = (REC) stack2->lls_object;
REC rec2 = (REC) stack2->lls_object;
BTR_key(tdbb, rpb->rpb_relation, rec2, &idx, &key2, 0);
if (key_equal(&key1, &key2))
break;
@ -655,6 +639,7 @@ void IDX_garbage_collect(TDBB tdbb, RPB * rpb, LLS going, LLS staying)
BTR_description(rpb->rpb_relation, root, &idx, i);
}
}
}
CCH_RELEASE(tdbb, &window);
}
@ -680,7 +665,6 @@ IDX_E IDX_modify(TDBB tdbb,
IDX idx;
IIB insertion;
KEY key1, key2;
IDX_E error_code;
SET_TDBB(tdbb);
@ -689,7 +673,7 @@ IDX_E IDX_modify(TDBB tdbb,
insertion.iib_key = &key1;
insertion.iib_descriptor = &idx;
insertion.iib_transaction = transaction;
error_code = idx_e_ok;
IDX_E error_code = idx_e_ok;
idx.idx_id = (USHORT) -1;
WIN window(-1);
@ -735,11 +719,10 @@ IDX_E IDX_modify_check_constraints(TDBB tdbb,
**************************************/
IDX idx;
KEY key1, key2;
IDX_E error_code;
SET_TDBB(tdbb);
error_code = idx_e_ok;
IDX_E error_code = idx_e_ok;
idx.idx_id = (USHORT) -1;
WIN window(-1);
@ -773,7 +756,8 @@ IDX_E IDX_modify_check_constraints(TDBB tdbb,
&key1, 0))
|| (error_code =
BTR_key(tdbb, org_rpb->rpb_relation, org_rpb->rpb_record,
&idx, &key2, 0))) {
&idx, &key2, 0)))
{
CCH_RELEASE(tdbb, &window);
break;
}
@ -832,7 +816,6 @@ IDX_E IDX_store(TDBB tdbb,
IDX idx;
IIB insertion;
KEY key;
IDX_E error_code;
SET_TDBB(tdbb);
@ -842,7 +825,7 @@ IDX_E IDX_store(TDBB tdbb,
insertion.iib_descriptor = &idx;
insertion.iib_transaction = transaction;
error_code = idx_e_ok;
IDX_E error_code = idx_e_ok;
idx.idx_id = (USHORT) -1;
WIN window(-1);
@ -886,23 +869,19 @@ static IDX_E check_duplicates(
* a unique index or a foreign key.
*
**************************************/
IDX_E result;
RPB rpb;
IDX *insertion_idx;
DSC desc1, desc2;
USHORT field_id, flag, i, flag_2;
JRD_REL relation_1;
SET_TDBB(tdbb);
result = idx_e_ok;
insertion_idx = insertion->iib_descriptor;
IDX_E result = idx_e_ok;
IDX* insertion_idx = insertion->iib_descriptor;
rpb.rpb_number = -1;
rpb.rpb_relation = insertion->iib_relation;
rpb.rpb_record = NULL;
rpb.rpb_window.win_flags = 0;
relation_1 = insertion->iib_relation;
JRD_REL relation_1 = insertion->iib_relation;
while (SBM_next
(insertion->iib_duplicates, &rpb.rpb_number, RSE_get_forward))
@ -927,7 +906,7 @@ static IDX_E check_duplicates(
// but for sure let's keep the old one as well.
// 2003.05.27
bool lock_error =
const bool lock_error =
(tdbb->tdbb_status_vector[1] == isc_deadlock ||
tdbb->tdbb_status_vector[1] == isc_lock_conflict ||
tdbb->tdbb_status_vector[1] == isc_lock_timeout);
@ -944,17 +923,17 @@ static IDX_E check_duplicates(
bool all_nulls = true;
for (i = 0; i < insertion_idx->idx_count; i++) {
field_id = insertion_idx->idx_rpt[i].idx_field;
for (USHORT i = 0; i < insertion_idx->idx_count; i++) {
USHORT field_id = insertion_idx->idx_rpt[i].idx_field;
/* In order to "map a null to a default" value (in EVL_field()),
* the relation block is referenced.
* Reference: Bug 10116, 10424
*/
flag =
const bool flag =
EVL_field(relation_1, rpb.rpb_record, field_id, &desc1);
field_id = record_idx->idx_rpt[i].idx_field;
flag_2 = EVL_field(relation_2, record, field_id, &desc2);
const bool flag_2 = EVL_field(relation_2, record, field_id, &desc2);
if (flag != flag_2 || MOV_compare(&desc1, &desc2) != 0)
break;
@ -995,19 +974,18 @@ JRD_REL * bad_relation, USHORT * bad_index)
* record appears in the partner index.
*
**************************************/
IDX_E result;
int index_number;
JRD_REL partner_relation;
USHORT index_id;
SET_TDBB(tdbb);
result = idx_e_ok;
IDX_E result = idx_e_ok;
if (!MET_lookup_partner(tdbb, relation, idx, &NULL_STR)) {
return result;
}
USHORT index_id = 0;
if (idx->idx_flags & idx_foreign) {
partner_relation = MET_relation(tdbb, idx->idx_primary_relation);
index_id = (USHORT) idx->idx_primary_index;
@ -1015,12 +993,16 @@ JRD_REL * bad_relation, USHORT * bad_index)
check_partner_index(tdbb, relation, record, transaction, idx,
partner_relation, index_id);
}
else if (idx->idx_flags & (idx_primary | idx_unique))
else if (idx->idx_flags & (idx_primary | idx_unique)) {
for (index_number = 0;
index_number < (int) idx->idx_foreign_primaries->count();
index_number++) {
index_number++)
{
if (idx->idx_id !=
(UCHAR)(ULONG) (*idx->idx_foreign_primaries)[index_number]) continue;
(UCHAR)(ULONG) (*idx->idx_foreign_primaries)[index_number])
{
continue;
}
partner_relation =
MET_relation(tdbb,
(int) (*idx->idx_foreign_relations)[index_number]);
@ -1031,6 +1013,7 @@ JRD_REL * bad_relation, USHORT * bad_index)
partner_relation, index_id)) )
break;
}
}
if (result) {
if (idx->idx_flags & idx_foreign) {
@ -1053,7 +1036,7 @@ static IDX_E check_partner_index(
REC record,
JRD_TRA transaction,
IDX * idx,
JRD_REL partner_relation, SSHORT index_id)
JRD_REL partner_relation, SSHORT index_id)
{
/**************************************
*
@ -1067,22 +1050,19 @@ JRD_REL partner_relation, SSHORT index_id)
* record appears in the partner index.
*
**************************************/
IDX_E result;
IRT root;
IDX partner_idx;
IIB insertion;
KEY key;
SBM bitmap;
struct irb retrieval;
SET_TDBB(tdbb);
result = idx_e_ok;
IDX_E result = idx_e_ok;
/* get the index root page for the partner relation */
WIN window(get_root_page(tdbb, partner_relation));
root = (IRT) CCH_FETCH(tdbb, &window, LCK_read, pag_root);
IRT root = (IRT) CCH_FETCH(tdbb, &window, LCK_read, pag_root);
/* get the description of the partner index */
@ -1100,7 +1080,7 @@ JRD_REL partner_relation, SSHORT index_id)
/* fill out a retrieval block for the purpose of
generating a bitmap of duplicate records */
bitmap = NULL;
sbm* bitmap = NULL;
MOVE_CLEAR(&retrieval, sizeof(struct irb));
//retrieval.blk_type = type_irb;
retrieval.irb_index = partner_idx.idx_id;
@ -1183,11 +1163,10 @@ static SLONG get_root_page(TDBB tdbb, JRD_REL relation)
* Find the root page for a relation.
*
**************************************/
SLONG page;
SET_TDBB(tdbb);
if (!(page = relation->rel_index_root)) {
SLONG page = relation->rel_index_root;
if (!page) {
DPM_scan_pages(tdbb);
page = relation->rel_index_root;
}
@ -1212,7 +1191,6 @@ static int index_block_flush(void *ast_object)
*
**************************************/
IDB index_block = reinterpret_cast<IDB>(ast_object);
LCK lock;
struct tdbb thd_context, *tdbb;
/* Since this routine will be called asynchronously, we must establish
@ -1220,7 +1198,7 @@ static int index_block_flush(void *ast_object)
SET_THREAD_DATA;
lock = index_block->idb_lock;
LCK lock = index_block->idb_lock;
if (lock->lck_attachment)
tdbb->tdbb_database = lock->lck_attachment->att_database;
@ -1272,14 +1250,10 @@ static IDX_E insert_key(
* primary key index.
*
**************************************/
IDX_E result;
IDX *idx;
KEY key;
SET_TDBB(tdbb);
result = idx_e_ok;
idx = insertion->iib_descriptor;
IDX_E result = idx_e_ok;
IDX* idx = insertion->iib_descriptor;
/* Insert the key into the index. If the index is unique, BTR
will keep track of duplicates. */
@ -1298,14 +1272,14 @@ static IDX_E insert_key(
/* if we are dealing with a foreign key index,
check for an insert into the corresponding
primary key index */
if (idx->idx_flags & idx_foreign) {
/* find out if there is a null segment by faking uniqueness --
if there is one, don't bother to check the primary key */
idx_null_state null_state;
idx->idx_flags |= idx_unique;
CCH_FETCH(tdbb, window_ptr, LCK_read, pag_root);
KEY key;
idx_null_state null_state;
result = BTR_key(tdbb, relation, record, idx, &key, &null_state);
CCH_RELEASE(tdbb, window_ptr);
idx->idx_flags &= ~idx_unique;
@ -1320,7 +1294,7 @@ static IDX_E insert_key(
}
static BOOLEAN key_equal(KEY * key1, KEY * key2)
static bool key_equal(const KEY* key1, const KEY* key2)
{
/**************************************
*
@ -1332,22 +1306,20 @@ static BOOLEAN key_equal(KEY * key1, KEY * key2)
* Compare two keys for equality.
*
**************************************/
SSHORT l;
UCHAR *p, *q;
USHORT l = key1->key_length;
if (l != key2->key_length)
return false;
if ((l = key1->key_length) != key2->key_length)
return FALSE;
p = key1->key_data;
q = key2->key_data;
if (l)
do
if (l) {
const UCHAR* p = key1->key_data;
const UCHAR* q = key2->key_data;
do {
if (*p++ != *q++)
return FALSE;
while (--l);
return false;
} while (--l);
}
return TRUE;
return true;
}

View File

@ -83,7 +83,7 @@ typedef struct gfld
static const struct gfld gfields[] = {
#include "../jrd/fields.h"
{ 0, 0, dtype_null, 0, 0, 0, NULL, 0 }
{ 0, 0, dtype_unknown, 0, 0, 0, NULL, 0 }
};
#undef FIELD

View File

@ -77,6 +77,8 @@
#include "../jrd/iberr.h"
#include "../jrd/jrd_time.h"
#include "../intl/charsets.h"
#include "../jrd/sort.h"
#include "../jrd/all_proto.h"
#include "../jrd/blb_proto.h"
#include "../jrd/cch_proto.h"
@ -137,7 +139,7 @@ typedef struct dbf {
TEXT dbf_data[2];
} *DBF;
#include "../jrd/sort.h"
//#include "../jrd/sort.h"
#endif /* SERVER_SHUTDOWN */
#define WAIT_PERIOD -1
@ -263,7 +265,7 @@ void trig::compile(tdbb* _tdbb)
BOOLEAN trig::release(tdbb* _tdbb)
{
if (!blr/*sys_trigger*/ || !request || CMP_clone_active(request)) {
if (!blr/*sys_trigger*/ || !request || CMP_clone_is_active(request)) {
return FALSE;
}
@ -357,7 +359,7 @@ static ISC_STATUS commit(ISC_STATUS*, JRD_TRA*, const bool);
static STR copy_string(const TEXT*, const USHORT);
static bool drop_files(const fil*);
static ISC_STATUS error(ISC_STATUS*);
static void find_intl_charset(TDBB, ATT, DPB*);
static void find_intl_charset(TDBB, ATT, const DPB*);
static JRD_TRA find_transaction(TDBB, JRD_TRA, ISC_STATUS);
static void get_options(const UCHAR*, USHORT, TEXT**, ULONG, DPB*);
static SLONG get_parameter(const UCHAR**);
@ -2916,7 +2918,7 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
SLONG* id,
SSHORT length,
const UCHAR* items,
FPTR_VOID ast,
FPTR_EVENT_CALLBACK ast,
void* arg)
{
/**************************************
@ -4367,7 +4369,7 @@ void JRD_print_procedure_info(TDBB tdbb, const char* mesg)
#ifdef MULTI_THREAD
BOOLEAN JRD_reschedule(TDBB tdbb, SLONG quantum, BOOLEAN punt)
BOOLEAN JRD_reschedule(TDBB tdbb, SLONG quantum, bool punt)
{
/**************************************
*
@ -4931,7 +4933,7 @@ static ISC_STATUS error(ISC_STATUS* user_status)
}
static void find_intl_charset(TDBB tdbb, ATT attachment, DPB * options)
static void find_intl_charset(TDBB tdbb, ATT attachment, const DPB* options)
{
/**************************************
*
@ -4960,7 +4962,7 @@ static void find_intl_charset(TDBB tdbb, ATT attachment, DPB * options)
if (MET_get_char_subtype(tdbb,
&id,
reinterpret_cast<UCHAR*>(options->dpb_lc_ctype),
reinterpret_cast<const UCHAR*>(options->dpb_lc_ctype),
len) &&
INTL_defined_type(tdbb, local_status, id) &&
(id != CS_BINARY))

View File

@ -690,12 +690,14 @@ class vec_base : protected pool_alloc<TYPE>
{
public:
typedef typename Firebird::vector<T>::iterator iterator;
typedef typename Firebird::vector<T>::const_iterator const_iterator;
static vec_base* newVector(MemoryPool& p, int len)
{ return FB_NEW(p) vec_base<T,TYPE>(p, len); }
static vec_base* newVector(MemoryPool& p, const vec_base& base)
{ return FB_NEW(p) vec_base<T,TYPE>(p, base); }
// CVC: THis should be size_t instead of ULONG for maximum portability.
ULONG count() const { return vector.size(); }
T& operator[](size_t index) { return vector[index]; }
const T& operator[](size_t index) const { return vector[index]; }
@ -711,7 +713,7 @@ public:
void resize(size_t n, T val = T()) { vector.resize(n, val); }
void operator delete(void *mem) { MemoryPool::globalFree(mem); }
void operator delete(void* mem) { MemoryPool::globalFree(mem); }
protected:
vec_base(MemoryPool& p, int len)

View File

@ -95,7 +95,8 @@ ISC_STATUS jrd8_put_slice(ISC_STATUS*, struct att**,
const UCHAR*, USHORT, const UCHAR*, SLONG,
UCHAR*);
ISC_STATUS jrd8_que_events(ISC_STATUS*, struct att**, SLONG*,
SSHORT, const UCHAR*, FPTR_VOID, void*);
SSHORT, const UCHAR*,
FPTR_EVENT_CALLBACK, void*);
ISC_STATUS jrd8_receive(ISC_STATUS *, struct jrd_req **, USHORT, USHORT,
SCHAR *, SSHORT);
ISC_STATUS jrd8_reconnect_transaction(ISC_STATUS*, struct att**,
@ -151,7 +152,7 @@ void JRD_set_cache_default(ULONG *);
void JRD_blocked(struct att *, struct btb **);
void JRD_mutex_lock(struct mutx_t *);
void JRD_mutex_unlock(struct mutx_t *);
BOOLEAN JRD_reschedule(struct tdbb *, SLONG, BOOLEAN);
BOOLEAN JRD_reschedule(struct tdbb*, SLONG, bool);
void JRD_restore_context(void);
void JRD_set_context(struct tdbb *);
void JRD_unblock(struct btb **);

File diff suppressed because it is too large Load Diff

View File

@ -29,32 +29,32 @@
#include "../jrd/blob_filter.h"
void MET_activate_shadow(TDBB);
ULONG MET_align(struct dsc *, USHORT);
ULONG MET_align(const struct dsc*, USHORT);
void MET_change_fields(TDBB, class jrd_tra *, struct dsc *);
struct fmt* MET_current(TDBB, struct jrd_rel *);
void MET_delete_dependencies(TDBB, TEXT *, USHORT);
void MET_delete_shadow(TDBB, USHORT);
void MET_error(TEXT *, ...);
SCHAR* MET_exact_name(TEXT *);
void MET_error(const TEXT*, ...);
SCHAR* MET_exact_name(TEXT*);
struct fmt* MET_format(TDBB, struct jrd_rel *, USHORT);
BOOLEAN MET_get_char_subtype(TDBB, SSHORT *, UCHAR *, USHORT);
BOOLEAN MET_get_char_subtype(TDBB, SSHORT*, const UCHAR*, USHORT);
struct jrd_nod* MET_get_dependencies(TDBB, struct jrd_rel*, TEXT*,
class Csb*, SLONG[2], struct jrd_req**,
class Csb **, const TEXT*, USHORT);
struct jrd_fld* MET_get_field(struct jrd_rel *, USHORT);
void MET_get_shadow_files(TDBB, bool);
int MET_get_walinfo(TDBB, struct logfiles **, ULONG *, struct logfiles **);
ULONG MET_get_walinfo(TDBB, struct logfiles **, ULONG *, struct logfiles **);
void MET_load_trigger(TDBB, struct jrd_rel*, const TEXT*, TRIG_VEC*);
void MET_lookup_cnstrt_for_index(TDBB, TEXT* constraint, const TEXT* index_name);
void MET_lookup_cnstrt_for_trigger(TDBB, TEXT*, TEXT*, const TEXT*);
void MET_lookup_exception(TDBB, SLONG, /* INOUT */ TEXT*, /* INOUT */ TEXT*);
SLONG MET_lookup_exception_number(TDBB, TEXT*);
SLONG MET_lookup_exception_number(TDBB, const TEXT*);
int MET_lookup_field(TDBB, struct jrd_rel*, const TEXT*, const TEXT*);
BLF MET_lookup_filter(TDBB, SSHORT, SSHORT);
SLONG MET_lookup_generator(TDBB, TEXT *);
SLONG MET_lookup_generator(TDBB, const TEXT*);
void MET_lookup_generator_id(TDBB, SLONG, TEXT *);
void MET_lookup_index(TDBB, TEXT *, TEXT *, USHORT);
SLONG MET_lookup_index_name(TDBB, TEXT *, SLONG *, SSHORT *);
void MET_lookup_index(TDBB, TEXT*, const TEXT*, USHORT);
SLONG MET_lookup_index_name(TDBB, const TEXT*, SLONG*, SSHORT*);
int MET_lookup_partner(TDBB, struct jrd_rel*, struct idx*, const TEXT*);
struct jrd_prc* MET_lookup_procedure(TDBB, SCHAR *, BOOLEAN);
struct jrd_prc* MET_lookup_procedure_id(TDBB, SSHORT, BOOLEAN, BOOLEAN, USHORT);
@ -67,8 +67,8 @@ int MET_post_existence(TDBB, struct jrd_rel *);
void MET_prepare(TDBB, class jrd_tra*, USHORT, const UCHAR*);
struct jrd_prc* MET_procedure(TDBB, int, BOOLEAN, USHORT);
struct jrd_rel* MET_relation(TDBB, USHORT);
BOOLEAN MET_relation_owns_trigger (TDBB, const TEXT *, const TEXT *);
BOOLEAN MET_relation_default_class (TDBB, const TEXT *, const TEXT *);
BOOLEAN MET_relation_owns_trigger (TDBB, const TEXT*, const TEXT*);
BOOLEAN MET_relation_default_class (TDBB, const TEXT*, const TEXT*);
void MET_release_existence(struct jrd_rel *);
void MET_release_triggers(TDBB, TRIG_VEC *);
#ifdef DEV_BUILD
@ -82,7 +82,7 @@ TEXT* MET_save_name(TDBB, const TEXT*);
void MET_scan_relation(TDBB, struct jrd_rel *);
const TEXT* MET_trigger_msg(TDBB, const TEXT*, USHORT);
void MET_update_shadow(TDBB, struct sdw *, USHORT);
void MET_update_transaction(TDBB, class jrd_tra *, USHORT);
void MET_update_transaction(TDBB, class jrd_tra*, const bool);
void MET_update_partners(TDBB);
#endif // JRD_MET_PROTO_H

View File

@ -32,7 +32,7 @@
* Contributor(s):
*
*
* $Id: nbak.cpp,v 1.15 2003-12-11 10:33:25 robocop Exp $
* $Id: nbak.cpp,v 1.16 2003-12-22 10:00:47 robocop Exp $
*
*/
@ -1052,7 +1052,7 @@ bool BackupManager::actualize_state() throw() {
temp_bdb.bdb_buffer = reinterpret_cast<PAG>(header);
FIL file = database->dbb_file;
while (!PIO_read(file, &temp_bdb, temp_bdb.bdb_buffer, status)) {
if (!CCH_rollover_to_shadow(database, file, FALSE)) {
if (!CCH_rollover_to_shadow(database, file, false)) {
NBAK_TRACE(("Shadow change error"));
return false;
}

View File

@ -211,7 +211,7 @@ static int opt_debug_flag = DEBUG_NONE;
/* enumeration of sort datatypes */
static const UCHAR sort_dtypes[] = {
0, /* dtype_null */
0, /* dtype_unknown */
SKD_text, /* dtype_text */
SKD_cstring, /* dtype_cstring */
SKD_varying, /* dtype_varying */
@ -6633,7 +6633,8 @@ static void set_rse_inactive(CSB csb, RSE rse)
JRD_NOD node, *ptr, *end;
SSHORT stream;
for (ptr = rse->rse_relation, end = ptr + rse->rse_count;
ptr < end; ptr++) {
ptr < end; ptr++)
{
node = *ptr;
if (node->nod_type != nod_rse) {
stream = (USHORT)(ULONG) node->nod_arg[STREAM_INDEX(node)];

View File

@ -90,7 +90,7 @@ public:
static bool comparePaths(const Firebird::string& path1,
const Firebird::string& path2);
/** Concatinates the two paths given in the second and third parameters,
/** Concatenates the two paths given in the second and third parameters,
and writes the resulting path into the first parameter. The
two path input arguments (arg 2 and 3) are concatinated in the order
arg2 arg3. The concatination is done is such a way as to remove
@ -111,14 +111,14 @@ public:
static void splitLastComponent(Firebird::string&, Firebird::string&,
const Firebird::string&);
/** This is the factory method for allocting dir_iterator objects.
/** This is the factory method for allocating dir_iterator objects.
It takes a reference to a memory pool to use for all heap allocations,
and the path of the directory to iterate (in that order). It is the
responsibility of the caller to delete the object when they are done with it.
All errors result in either exceptions being thrown, or a valid empty
dir_iterator being returned.
**/
static dir_iterator *newDirItr(MemoryPool&, const Firebird::string&);
static dir_iterator* newDirItr(MemoryPool&, const Firebird::string&);
};
#endif

View File

@ -71,7 +71,7 @@ typedef struct vms_req {
struct vms_req *req_next; /* Next request in session */
struct ses *req_session; /* Parent session */
struct rint *req_interests; /* Request interests */
int (*req_ast) (); /* Associated AST (zero is fired) */
FPTR_EVENT_CALLBACK req_ast; /* Associated AST (zero is fired) */
void *req_ast_arg; /* Argument for ast */
SLONG req_request_id; /* Request id */
} *VMS_REQ;
@ -330,7 +330,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector,
TEXT * string,
USHORT events_length,
UCHAR * events,
void (*ast_routine) (),
FPTR_EVENT_CALLBACK ast_routine,
void *ast_arg)
{
/**************************************

File diff suppressed because it is too large Load Diff

View File

@ -188,7 +188,8 @@ LCK RLCK_lock_record_implicit(JRD_TRA transaction,
if (interest_lock_level
&& !obtain_lock(transaction, lock->lck_parent, interest_lock_level)
|| !obtain_lock(transaction, lock, lock_level)) {
|| !obtain_lock(transaction, lock, lock_level))
{
RLCK_unlock_record_implicit(lock, rpb);
return NULL;
}

View File

@ -1,6 +1,6 @@
/*
* PROGRAM: JRD Access Method
* MODULE: rse.c
* MODULE: rse.cpp
* DESCRIPTION: Run time record fetching
*
* The contents of this file are subject to the Interbase Public
@ -20,7 +20,7 @@
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* $Id: rse.cpp,v 1.45 2003-12-11 10:33:25 robocop Exp $
* $Id: rse.cpp,v 1.46 2003-12-22 10:00:47 robocop Exp $
*
* 2001.07.28: John Bellardo: Implemented rse_skip and made rse_first work with
* seekable streams.
@ -84,8 +84,8 @@
static void close_merge(TDBB, RSB, IRSB_MRG);
static void close_procedure(TDBB, RSB);
static SSHORT compare(TDBB, JRD_NOD, JRD_NOD);
static SSHORT compare_longs(SLONG *, SLONG *, USHORT);
static SSHORT compare(TDBB, jrd_nod*, jrd_nod*);
static SSHORT compare_longs(const SLONG*, const SLONG*, USHORT);
#ifdef SCROLLABLE_CURSORS
static BOOLEAN fetch_record(TDBB, RSB, SSHORT, RSE_GET_MODE);
static BOOLEAN get_merge_join(TDBB, RSB, IRSB_MRG, RSE_GET_MODE);
@ -144,12 +144,10 @@ void RSE_close(TDBB tdbb, RSB rsb)
* Functional description
*
**************************************/
IRSB_SORT impure;
SET_TDBB(tdbb);
while (true) {
impure = (IRSB_SORT) ((UCHAR *) tdbb->tdbb_request + rsb->rsb_impure);
IRSB_SORT impure = (IRSB_SORT) ((UCHAR *) tdbb->tdbb_request + rsb->rsb_impure);
if (!(impure->irsb_flags & irsb_open))
return;
@ -162,11 +160,8 @@ void RSE_close(TDBB tdbb, RSB rsb)
case rsb_sequential:
{
JRD_REQ request;
RPB *rpb;
request = tdbb->tdbb_request;
rpb = &request->req_rpb[rsb->rsb_stream];
JRD_REQ request = tdbb->tdbb_request;
RPB* rpb = &request->req_rpb[rsb->rsb_stream];
if (rpb->rpb_window.win_flags & WIN_large_scan &&
rpb->rpb_relation->rel_scan_count)
--rpb->rpb_relation->rel_scan_count;
@ -182,11 +177,12 @@ void RSE_close(TDBB tdbb, RSB rsb)
case rsb_cross:
{
RSB *ptr, *end;
for (ptr = rsb->rsb_arg, end = ptr + rsb->rsb_count;
RSB* ptr = rsb->rsb_arg;
for (RSB* const end = ptr + rsb->rsb_count;
ptr < end; ptr++)
{
RSE_close(tdbb, *ptr);
}
return;
}
@ -211,9 +207,7 @@ void RSE_close(TDBB tdbb, RSB rsb)
case rsb_union:
{
USHORT i;
i = ((IRSB) impure)->irsb_count;
const USHORT i = ((IRSB) impure)->irsb_count;
if (i >= rsb->rsb_count)
return;
rsb = rsb->rsb_arg[i];
@ -248,19 +242,18 @@ BOOLEAN RSE_find_dbkey(TDBB tdbb, RSB rsb, JRD_NOD find_key, JRD_NOD record_vers
* check for a record version also.
*
**************************************/
JRD_REQ request;
RPB *rpb;
DSC *desc, desc2;
ULONG dbkey[2], version_number;
IRSB_INDEX impure;
SBM *bitmap;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
JRD_REQ request = tdbb->tdbb_request;
/* get the record number from the passed dbkey */
desc = EVL_expr(tdbb, find_key);
const dsc* desc = EVL_expr(tdbb, find_key);
dsc desc2;
desc2.dsc_address = (UCHAR *) dbkey;
desc2.dsc_length = sizeof(dbkey);
desc2.dsc_dtype = dtype_text;
@ -306,7 +299,10 @@ BOOLEAN RSE_find_dbkey(TDBB tdbb, RSB rsb, JRD_NOD find_key, JRD_NOD record_vers
if (!VIO_get
(tdbb, rpb, rsb, request->req_transaction,
request->req_pool)) return FALSE;
request->req_pool))
{
return FALSE;
}
if (record_version && version_number != rpb->rpb_transaction)
return FALSE;
@ -326,7 +322,9 @@ BOOLEAN RSE_find_dbkey(TDBB tdbb, RSB rsb, JRD_NOD find_key, JRD_NOD record_vers
if (VIO_get
(tdbb, rpb, rsb, request->req_transaction, request->req_pool)
&& (!record_version || version_number == rpb->rpb_transaction))
{
return TRUE;
}
RSE_MARK_CRACK(tdbb, rsb, irsb_crack);
return FALSE;
@ -341,7 +339,10 @@ BOOLEAN RSE_find_dbkey(TDBB tdbb, RSB rsb, JRD_NOD find_key, JRD_NOD record_vers
VIO_get(tdbb, rpb, rsb, request->req_transaction,
request->req_pool) && (!record_version
|| version_number ==
rpb->rpb_transaction)) return TRUE;
rpb->rpb_transaction))
{
return TRUE;
}
RSE_MARK_CRACK(tdbb, rsb, irsb_crack);
return FALSE;
@ -417,13 +418,9 @@ BOOLEAN RSE_get_record(TDBB tdbb, RSB rsb, RSE_GET_MODE mode)
* retrieved at the top level of the rsb tree.
*
**************************************/
JRD_REQ request;
BOOLEAN result, count;
IRSB impure;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
JRD_REQ request = tdbb->tdbb_request;
IRSB impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
#ifdef SCROLLABLE_CURSORS
/* The mode RSE_get_next is a generic mode which requests that
@ -440,9 +437,10 @@ BOOLEAN RSE_get_record(TDBB tdbb, RSB rsb, RSE_GET_MODE mode)
/* Turn off the flag so that records at a
lower level will not be counted. */
count = (request->req_flags & req_count_records) != 0;
const bool count = (request->req_flags & req_count_records) != 0;
request->req_flags &= ~req_count_records;
BOOLEAN result;
while ( (result = get_record(tdbb, rsb, NULL, mode)) )
{
if (rsb->rsb_flags & rsb_writelock)
@ -608,21 +606,18 @@ void RSE_open(TDBB tdbb, RSB rsb)
* record source block (rsb).
*
**************************************/
JRD_REQ request;
IRSB_INDEX impure;
RPB *rpb;
SINT64 first_records = -1, skip_records = 0;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
JRD_REQ request = tdbb->tdbb_request;
while (true) {
impure = (IRSB_INDEX) ((SCHAR *) request + rsb->rsb_impure);
IRSB_INDEX impure = (IRSB_INDEX) ((SCHAR *) request + rsb->rsb_impure);
impure->irsb_flags |= irsb_first | irsb_open;
impure->irsb_flags &=
~(irsb_singular_processed | irsb_checking_singular);
rpb = &request->req_rpb[rsb->rsb_stream];
RPB* rpb = &request->req_rpb[rsb->rsb_stream];
rpb->rpb_window.win_flags = 0;
switch (rsb->rsb_type) {
@ -639,20 +634,18 @@ void RSE_open(TDBB tdbb, RSB rsb)
}
#endif
if (rsb->rsb_type == rsb_sequential) {
ATT attachment;
BCB bcb;
DBB dbb;
dbb = tdbb->tdbb_database;
bcb = dbb->dbb_bcb;
DBB dbb = tdbb->tdbb_database;
BCB bcb = dbb->dbb_bcb;
/* Unless this is the only attachment, limit the cache flushing
effect of large sequential scans on the page working sets of
other attachments. */
if ((attachment = tdbb->tdbb_attachment) &&
ATT attachment = tdbb->tdbb_attachment;
if (attachment &&
(attachment != dbb->dbb_attachments
|| attachment->att_next)) {
|| attachment->att_next))
{
/* If the relation has more data pages than the number of
pages in the buffer cache then mark the input window
block as a large scan so that a data page is released
@ -729,16 +722,15 @@ void RSE_open(TDBB tdbb, RSB rsb)
case rsb_union:
{
RSB *ptr, *end;
((IRSB) impure)->irsb_count = 0;
VIO_record(tdbb, rpb, rsb->rsb_format, tdbb->tdbb_default);
/* Initialize the record number of each stream in the union */
ptr = &rsb->rsb_arg[rsb->rsb_count];
for (end = ptr + (USHORT)(ULONG) * ptr; ++ptr <= end;)
RSB* ptr = &rsb->rsb_arg[rsb->rsb_count];
for (RSB* const end = ptr + (USHORT)(ULONG) * ptr; ++ptr <= end;) {
request->req_rpb[(USHORT)(ULONG) * ptr].rpb_number = -1;
}
rsb = rsb->rsb_arg[0];
}
@ -761,9 +753,6 @@ void RSE_open(TDBB tdbb, RSB rsb)
case rsb_left_cross:
{
LLS stack;
RSB right_rsbs;
RSE_open(tdbb, rsb->rsb_arg[RSB_LEFT_outer]);
impure->irsb_flags &=
~(irsb_first | irsb_in_opened | irsb_join_full);
@ -773,10 +762,10 @@ void RSE_open(TDBB tdbb, RSB rsb)
stream in the right sub-stream. The block will be needed
if we join to nulls before opening the rsbs */
for (stack = (LLS) rsb->rsb_arg[RSB_LEFT_rsbs]; stack;
for (lls* stack = (LLS) rsb->rsb_arg[RSB_LEFT_rsbs]; stack;
stack = stack->lls_next)
{
right_rsbs = (RSB) stack->lls_object;
RSB right_rsbs = (RSB) stack->lls_object;
VIO_record(tdbb,
&request->req_rpb[right_rsbs->rsb_stream],
right_rsbs->rsb_format, tdbb->tdbb_default);
@ -927,17 +916,14 @@ static void close_merge(TDBB tdbb, RSB rsb, IRSB_MRG impure)
* and cleaning up after any prior sort-merge retrieval.
*
**************************************/
RSB *ptr, *end;
MFB mfb;
SFB sfb;
irsb_mrg::irsb_mrg_repeat * tail;
SET_TDBB(tdbb);
/* do two simultaneous but unrelated things in one loop */
for (ptr = rsb->rsb_arg, end = ptr + rsb->rsb_count * 2, tail =
impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++) {
irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt;
RSB* ptr = rsb->rsb_arg;
for (RSB* const end = ptr + rsb->rsb_count * 2;
ptr < end; ptr += 2, tail++)
{
/* close all the substreams for the sort-merge */
RSE_close(tdbb, *ptr);
@ -946,8 +932,9 @@ static void close_merge(TDBB tdbb, RSB rsb, IRSB_MRG impure)
and the sort file block. Also delete the merge file
if one exists. */
mfb = &tail->irsb_mrg_file;
if ( (sfb = mfb->mfb_sfb) ) {
MFB mfb = &tail->irsb_mrg_file;
SFB sfb = mfb->mfb_sfb;
if (sfb) {
if (sfb->sfb_file_name) {
close(sfb->sfb_file);
unlink(sfb->sfb_file_name);
@ -977,14 +964,12 @@ static void close_procedure(TDBB tdbb, RSB rsb)
* Shut down a procedural view.
*
**************************************/
JRD_REQ request, proc_request;
IRSB_PROCEDURE impure;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
impure = (IRSB_PROCEDURE) ((UCHAR *) request + rsb->rsb_impure);
if ( (proc_request = impure->irsb_req_handle) ) {
JRD_REQ request = tdbb->tdbb_request;
IRSB_PROCEDURE impure = (IRSB_PROCEDURE) ((UCHAR *) request + rsb->rsb_impure);
JRD_REQ proc_request = impure->irsb_req_handle;
if (proc_request) {
/* bug #7884: at this point the transaction could already have
been released, so null it out so as not to dereference it */
@ -1002,7 +987,9 @@ static void close_procedure(TDBB tdbb, RSB rsb)
}
static SSHORT compare(TDBB tdbb, JRD_NOD node1, JRD_NOD node2)
// It seems strange this function doesn't take two const nodes,
// but EVL_expr can change node1 and node2' args.
static SSHORT compare(TDBB tdbb, jrd_nod* node1, jrd_nod* node2)
{
/**************************************
*
@ -1018,13 +1005,14 @@ static SSHORT compare(TDBB tdbb, JRD_NOD node1, JRD_NOD node2)
SET_TDBB(tdbb);
JRD_REQ request = tdbb->tdbb_request;
JRD_NOD *ptr1, *ptr2, *end;
for (ptr1 = node1->nod_arg, end = ptr1 + node1->nod_count, ptr2 =
node2->nod_arg; ptr1 < end; ptr1++, ptr2++)
jrd_nod* const* ptr1 = node1->nod_arg;
jrd_nod* const* ptr2 = node2->nod_arg;
for (const jrd_nod* const* const end = ptr1 + node1->nod_count;
ptr1 < end; ptr1++, ptr2++)
{
dsc* desc1 = EVL_expr(tdbb, *ptr1);
ULONG flags = request->req_flags;
dsc* desc2 = EVL_expr(tdbb, *ptr2);
const dsc* desc1 = EVL_expr(tdbb, *ptr1);
const ULONG flags = request->req_flags;
const dsc* desc2 = EVL_expr(tdbb, *ptr2);
if (flags & req_null) {
if (!(request->req_flags & req_null)) {
return -1;
@ -1043,8 +1031,8 @@ static SSHORT compare(TDBB tdbb, JRD_NOD node1, JRD_NOD node2)
return 1;
}
// AB: MOV_compare can't handle NULL parameters
// therefor check before passing all null flags.
SSHORT result = MOV_compare(desc1, desc2);
// therefore check before passing all null flags.
const SSHORT result = MOV_compare(desc1, desc2);
if (result != 0) {
return result;
}
@ -1054,7 +1042,7 @@ static SSHORT compare(TDBB tdbb, JRD_NOD node1, JRD_NOD node2)
}
static SSHORT compare_longs(SLONG * p, SLONG * q, USHORT count)
static SSHORT compare_longs(const SLONG* p, const SLONG* q, USHORT count)
{
/**************************************
*
@ -1097,11 +1085,9 @@ static BOOLEAN fetch_record(TDBB tdbb, RSB rsb, SSHORT n
* return FALSE.
*
**************************************/
RSB sub_rsb;
SET_TDBB(tdbb);
sub_rsb = rsb->rsb_arg[n];
RSB sub_rsb = rsb->rsb_arg[n];
if (get_record(tdbb, sub_rsb, NULL
#ifdef SCROLLABLE_CURSORS
@ -1166,8 +1152,6 @@ static BOOLEAN fetch_left(TDBB tdbb, RSB rsb, IRSB impure, RSE_GET_MODE mode)
* the outer join is finished, so return FALSE.
*
**************************************/
RSB full;
SET_TDBB(tdbb);
/* loop through the outer join in either the forward or the backward direction;
@ -1242,17 +1226,15 @@ static BOOLEAN fetch_left(TDBB tdbb, RSB rsb, IRSB impure, RSE_GET_MODE mode)
{
/* Continue with a full outer join. */
full = rsb->rsb_arg[RSB_LEFT_inner];
RSB full = rsb->rsb_arg[RSB_LEFT_inner];
full = (full->rsb_type == rsb_boolean) ? full->rsb_next : full;
if (impure->irsb_flags & irsb_in_opened)
{
USHORT found;
/* The inner stream was opened at some point. If it doesn't have a
boolean, then all of its records have been returned. Otherwise,
find the records that haven't been. */
BOOLEAN found;
do {
if (!get_record(tdbb, full, NULL, mode)) {
if (mode == RSE_get_forward)
@ -1334,8 +1316,6 @@ static BOOLEAN fetch_left(TDBB tdbb, RSB rsb, IRSB impure)
* the outer join is finished, so return FALSE.
*
**************************************/
RSB full;
SET_TDBB(tdbb);
if (!(impure->irsb_flags & irsb_join_full))
@ -1397,17 +1377,15 @@ static BOOLEAN fetch_left(TDBB tdbb, RSB rsb, IRSB impure)
/* Continue with a full outer join. */
full = rsb->rsb_arg[RSB_LEFT_inner];
RSB full = rsb->rsb_arg[RSB_LEFT_inner];
full = (full->rsb_type == rsb_boolean) ? full->rsb_next : full;
if (impure->irsb_flags & irsb_in_opened)
{
USHORT found;
/* The inner stream was opened at some point. If it doesn't have a
boolean, then all of its records have been returned. Otherwise,
find the records that haven't been. */
BOOLEAN found;
do {
if (!get_record(tdbb, full, NULL, RSE_get_forward))
return FALSE;
@ -1460,16 +1438,14 @@ static UCHAR *get_merge_data(TDBB tdbb, MFB mfb, SLONG record)
* equivalence file.
*
**************************************/
ULONG merge_block, merge_offset;
fb_assert(record >= 0 && record < (SLONG) mfb->mfb_equal_records);
merge_block = record / mfb->mfb_blocking_factor;
const ULONG merge_block = record / mfb->mfb_blocking_factor;
if (merge_block != mfb->mfb_current_block) {
mfb->mfb_current_block = read_merge_block(tdbb, mfb, merge_block);
}
merge_offset = (record % mfb->mfb_blocking_factor) * mfb->mfb_record_size;
const ULONG merge_offset = (record % mfb->mfb_blocking_factor) * mfb->mfb_record_size;
return (mfb->mfb_block_data + merge_offset);
}
@ -1512,7 +1488,9 @@ static BOOLEAN get_merge_fetch(
if (((mode == RSE_get_backward) && !(impure->irsb_flags & irsb_backwards))
|| ((mode == RSE_get_forward)
&& (impure->irsb_flags & irsb_backwards)))
{
--record;
}
else
++record;
}
@ -1536,7 +1514,9 @@ if (record < tail->irsb_mrg_equal || record > tail->irsb_mrg_equal_end) {
&& !(impure->irsb_flags & irsb_backwards))
|| ((mode == RSE_get_forward)
&& (impure->irsb_flags & irsb_backwards)))
{
resynch_merge(tdbb, rsb, impure, mode);
}
return FALSE;
}
@ -1554,7 +1534,9 @@ if (record < tail->irsb_mrg_equal || record > tail->irsb_mrg_equal_end) {
if (((mode == RSE_get_backward) && !(impure->irsb_flags & irsb_backwards))
|| ((mode == RSE_get_forward)
&& (impure->irsb_flags & irsb_backwards)))
{
record = tail->irsb_mrg_equal_end;
}
else
record = tail->irsb_mrg_equal;
}
@ -1586,22 +1568,15 @@ static BOOLEAN get_merge_fetch(TDBB tdbb, RSB rsb, SSHORT stream)
* record group.
*
**************************************/
RSB sub_rsb;
IRSB_MRG impure;
SLONG record;
MFB mfb;
SSHORT m;
irsb_mrg::irsb_mrg_repeat * tail;
SET_TDBB(tdbb);
impure = (IRSB_MRG) ((UCHAR *) tdbb->tdbb_request + rsb->rsb_impure);
tail = impure->irsb_mrg_rpt + stream;
m = tail->irsb_mrg_order;
IRSB_MRG impure = (IRSB_MRG) ((UCHAR *) tdbb->tdbb_request + rsb->rsb_impure);
irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt + stream;
SSHORT m = tail->irsb_mrg_order;
tail = impure->irsb_mrg_rpt + m;
sub_rsb = rsb->rsb_arg[m + m];
RSB sub_rsb = rsb->rsb_arg[m + m];
record = tail->irsb_mrg_equal_current;
SLONG record = tail->irsb_mrg_equal_current;
++record;
if (record > tail->irsb_mrg_equal_end) {
@ -1612,7 +1587,7 @@ static BOOLEAN get_merge_fetch(TDBB tdbb, RSB rsb, SSHORT stream)
tail->irsb_mrg_equal_current = record;
mfb = &tail->irsb_mrg_file;
MFB mfb = &tail->irsb_mrg_file;
map_sort_data(tdbb->tdbb_request, (SMB) sub_rsb->rsb_arg[0],
get_merge_data(tdbb, mfb, record));
@ -1636,20 +1611,15 @@ static BOOLEAN get_merge_join(
* Get the next tuple from a sort/merge join.
*
**************************************/
JRD_REQ request;
RSB sort_rsb, *ptr, *highest_ptr, *end;
SMB map;
RSB* ptr;
SLONG record;
int result;
UCHAR *first_data, *last_data;
MFB mfb;
LLS best_tails;
irsb_mrg::irsb_mrg_repeat * tail, *tail_end;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
end = rsb->rsb_arg + rsb->rsb_count * 2;
JRD_REQ request = tdbb->tdbb_request;
RSB* const end = rsb->rsb_arg + rsb->rsb_count * 2;
/* If there is a group of equivalent records already formed,
fetch the next record from it */
@ -1674,14 +1644,14 @@ static BOOLEAN get_merge_join(
/* Increment (or decrement) each stream one record. If any comes
up dry, we are at the end. */
highest_ptr = rsb->rsb_arg;
RSB* highest_ptr = rsb->rsb_arg;
irsb_mrg::irsb_mrg_repeat *tail, *tail_end;
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end;
ptr += 2, tail++)
{
sort_rsb = *ptr;
map = (SMB) sort_rsb->rsb_arg[0];
mfb = &tail->irsb_mrg_file;
RSB sort_rsb = *ptr;
SMB map = (SMB) sort_rsb->rsb_arg[0];
MFB mfb = &tail->irsb_mrg_file;
/* reset equality group record positions */
@ -1744,8 +1714,8 @@ static BOOLEAN get_merge_join(
highest_ptr = ptr;
goto recycle;
}
sort_rsb = *ptr;
mfb = &tail->irsb_mrg_file;
RSB sort_rsb = *ptr;
MFB mfb = &tail->irsb_mrg_file;
mfb->mfb_current_block = 0;
mfb->mfb_equal_records = 0;
@ -1771,13 +1741,12 @@ static BOOLEAN get_merge_join(
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end;
ptr += 2, tail++)
{
ULONG key_length;
ULONG key[32];
sort_rsb = *ptr;
map = (SMB) sort_rsb->rsb_arg[0];
mfb = &tail->irsb_mrg_file;
key_length = map->smb_key_length * sizeof(ULONG);
RSB sort_rsb = *ptr;
SMB map = (SMB) sort_rsb->rsb_arg[0];
MFB mfb = &tail->irsb_mrg_file;
const ULONG key_length = map->smb_key_length * sizeof(ULONG);
if (key_length > sizeof(key))
first_data = (UCHAR *) gds__alloc(key_length);
else
@ -1808,18 +1777,16 @@ static BOOLEAN get_merge_join(
of merge blocks. This ordering will vary for each set of equivalence
groups and cannot be statically assigned by the optimizer. */
best_tails = 0;
lls* best_tails = 0;
for (tail = impure->irsb_mrg_rpt, tail_end = tail + rsb->rsb_count;
tail < tail_end; tail++)
{
irsb_mrg::irsb_mrg_repeat * tail2, *best_tail;
ULONG blocks, most_blocks;
LLS stack;
most_blocks = 0;
ULONG most_blocks = 0;
irsb_mrg::irsb_mrg_repeat *tail2, *best_tail;
for (tail2 = impure->irsb_mrg_rpt; tail2 < tail_end; tail2++)
{
lls* stack;
for (stack = best_tails; stack; stack = stack->lls_next)
{
if (stack->lls_object == (BLK) tail2)
@ -1831,7 +1798,7 @@ static BOOLEAN get_merge_join(
continue;
}
mfb = &tail2->irsb_mrg_file;
blocks = mfb->mfb_equal_records / mfb->mfb_blocking_factor;
ULONG blocks = mfb->mfb_equal_records / mfb->mfb_blocking_factor;
if (++blocks > most_blocks) {
most_blocks = blocks;
best_tail = tail2;
@ -1861,8 +1828,7 @@ static BOOLEAN get_merge_join(TDBB tdbb, RSB rsb, IRSB_MRG impure)
* Get the next tuple from a sort/merge join.
*
**************************************/
JRD_REQ request;
RSB sort_rsb, *ptr, *highest_ptr, *end;
RSB sort_rsb, *ptr;
SMB map;
SLONG record;
int result;
@ -1873,8 +1839,8 @@ static BOOLEAN get_merge_join(TDBB tdbb, RSB rsb, IRSB_MRG impure)
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
end = rsb->rsb_arg + rsb->rsb_count * 2;
JRD_REQ request = tdbb->tdbb_request;
RSB* const end = rsb->rsb_arg + rsb->rsb_count * 2;
/* If there is a record group already formed, fetch the next combination */
@ -1884,7 +1850,7 @@ static BOOLEAN get_merge_join(TDBB tdbb, RSB rsb, IRSB_MRG impure)
/* Assuming we are done with the current value group, advance each
stream one record. If any comes up dry, we're done. */
highest_ptr = rsb->rsb_arg;
RSB* highest_ptr = rsb->rsb_arg;
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end;
ptr += 2, tail++)
@ -2121,35 +2087,27 @@ static BOOLEAN get_procedure(TDBB tdbb,
* Get the next record from a procedural view.
*
**************************************/
JRD_PRC procedure;
JRD_REQ request, proc_request;
REC record;
FMT rec_format, msg_format;
USHORT oml, eos, i;
SLONG size;
UCHAR *om;
DSC desc, eos_desc;
SET_TDBB(tdbb);
procedure = rsb->rsb_procedure;
request = tdbb->tdbb_request;
JRD_PRC procedure = rsb->rsb_procedure;
JRD_REQ request = tdbb->tdbb_request;
impure = (IRSB_PROCEDURE) ((UCHAR *) request + rsb->rsb_impure);
proc_request = impure->irsb_req_handle;
rec_format = procedure->prc_format;
JRD_REQ proc_request = impure->irsb_req_handle;
fmt* rec_format = procedure->prc_format;
msg_format = (FMT) procedure->prc_output_msg->nod_arg[e_msg_format];
fmt* msg_format = (FMT) procedure->prc_output_msg->nod_arg[e_msg_format];
if (!impure->irsb_message)
{
size = msg_format->fmt_length + ALIGNMENT;
const SLONG size = msg_format->fmt_length + ALIGNMENT;
impure->irsb_message = FB_NEW_RPT(*tdbb->tdbb_default, size) str();
impure->irsb_message->str_length = size;
}
om =
UCHAR* om =
(UCHAR *) FB_ALIGN((U_IPTR) impure->irsb_message->str_data,
ALIGNMENT);
oml = impure->irsb_message->str_length - ALIGNMENT;
USHORT oml = impure->irsb_message->str_length - ALIGNMENT;
REC record;
if (!rpb->rpb_record) {
record = rpb->rpb_record =
FB_NEW_RPT(*tdbb->tdbb_default, rec_format->fmt_length) rec();
@ -2161,8 +2119,10 @@ static BOOLEAN get_procedure(TDBB tdbb,
EXE_receive(tdbb, proc_request, 1, oml, om);
desc = msg_format->fmt_desc[msg_format->fmt_count - 1];
dsc desc = msg_format->fmt_desc[msg_format->fmt_count - 1];
desc.dsc_address = (UCHAR *) (om + (int) desc.dsc_address);
USHORT eos;
dsc eos_desc;
eos_desc.dsc_dtype = dtype_short;
eos_desc.dsc_scale = 0;
eos_desc.dsc_length = sizeof(SSHORT);
@ -2173,7 +2133,7 @@ static BOOLEAN get_procedure(TDBB tdbb,
if (!eos)
return FALSE;
for (i = 0; i < rec_format->fmt_count; i++)
for (int i = 0; i < rec_format->fmt_count; i++)
{
proc_assignment(&msg_format->fmt_desc[2 * i],
&msg_format->fmt_desc[2 * i + 1],
@ -2205,24 +2165,20 @@ static BOOLEAN get_record(TDBB tdbb,
* record, or fetch the current record.
*
**************************************/
JRD_REQ request;
IRSB impure;
RPB *rpb;
SET_TDBB(tdbb);
#ifdef SUPERSERVER
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit)
{
JRD_reschedule(tdbb, 0, TRUE);
JRD_reschedule(tdbb, 0, true);
}
#endif
/* check request flags for special processing */
request = tdbb->tdbb_request;
JRD_REQ request = tdbb->tdbb_request;
if (request->req_flags & req_abort)
{
return FALSE;
@ -2231,13 +2187,13 @@ static BOOLEAN get_record(TDBB tdbb,
{
return FALSE;
}
impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
IRSB impure = (IRSB) ((UCHAR *) request + rsb->rsb_impure);
if (impure->irsb_flags & irsb_singular_processed)
{
return FALSE;
}
rpb = request->req_rpb + rsb->rsb_stream;
RPB* rpb = request->req_rpb + rsb->rsb_stream;
#ifdef SCROLLABLE_CURSORS
/* do bof and eof handling for streams which may be navigated */
@ -2251,7 +2207,9 @@ static BOOLEAN get_record(TDBB tdbb,
||((mode == RSE_get_current)
&& (impure->irsb_flags & (irsb_bof | irsb_eof)))
#endif
{
return FALSE;
}
}
#endif
@ -2291,10 +2249,10 @@ static BOOLEAN get_record(TDBB tdbb,
case rsb_indexed:
{
SBM *bitmap;
int result = FALSE;
if ( (bitmap = ((IRSB_INDEX) impure)->irsb_bitmap) )
SBM* bitmap = ((IRSB_INDEX) impure)->irsb_bitmap;
if (bitmap)
{
while (SBM_next(*bitmap, &rpb->rpb_number, mode))
{
@ -3414,7 +3372,8 @@ static void pop_rpbs(JRD_REQ request, RSB rsb)
end = rsb->rsb_arg + rsb->rsb_count * 2;
impure = (IRSB_MRG) ((UCHAR *) request + rsb->rsb_impure);
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt;
ptr < end; ptr += 2, tail++) {
ptr < end; ptr += 2, tail++)
{
sort_rsb = *ptr;
map = (SMB) sort_rsb->rsb_arg[0];
end_item = map->smb_rpt + map->smb_count;
@ -3445,7 +3404,9 @@ static void pop_rpbs(JRD_REQ request, RSB rsb)
*/
for (ptr = rsb->rsb_arg, end = ptr + rsb->rsb_count; ptr < end;
ptr++)
{
pop_rpbs(request, *ptr);
}
return;
}
@ -3502,11 +3463,12 @@ static void push_rpbs(TDBB tdbb, JRD_REQ request, RSB rsb)
end_item = map->smb_rpt + map->smb_count;
for (item = map->smb_rpt; item < end_item; item++)
streams[item->smb_stream] = 1;
for (i = 0; i < (SSHORT) request->req_count; i++)
for (i = 0; i < (SSHORT) request->req_count; i++) {
if (streams[i]) {
rpb = request->req_rpb + i;
save_record(tdbb, rpb);
}
}
return;
}
@ -3523,7 +3485,8 @@ static void push_rpbs(TDBB tdbb, JRD_REQ request, RSB rsb)
end = rsb->rsb_arg + rsb->rsb_count * 2;
impure = (IRSB_MRG) ((UCHAR *) request + rsb->rsb_impure);
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt;
ptr < end; ptr += 2, tail++) {
ptr < end; ptr += 2, tail++)
{
sort_rsb = *ptr;
map = (SMB) sort_rsb->rsb_arg[0];
end_item = map->smb_rpt + map->smb_count;
@ -3554,7 +3517,9 @@ static void push_rpbs(TDBB tdbb, JRD_REQ request, RSB rsb)
*/
for (ptr = rsb->rsb_arg, end = ptr + rsb->rsb_count; ptr < end;
ptr++)
{
push_rpbs(tdbb, request, *ptr);
}
return;
}
@ -3681,7 +3646,8 @@ static void resynch_merge(
end = rsb->rsb_arg + rsb->rsb_count * 2;
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end;
ptr += 2, tail++) {
ptr += 2, tail++)
{
sort_rsb = *ptr;
mfb = &tail->irsb_mrg_file;
@ -3770,13 +3736,10 @@ static void unget_sort(TDBB tdbb, RSB rsb, UCHAR * data)
* data is destructive to the sort data (diddles it).
*
**************************************/
IRSB_SORT impure;
JRD_REQ request;
SET_TDBB(tdbb);
request = tdbb->tdbb_request;
JRD_REQ request = tdbb->tdbb_request;
impure = (IRSB_SORT) ((UCHAR *) request + rsb->rsb_impure);
IRSB_SORT impure = (IRSB_SORT) ((UCHAR *) request + rsb->rsb_impure);
SORT_diddle_key(data, impure->irsb_sort_handle, true);
}
@ -3796,9 +3759,8 @@ static void write_merge_block(TDBB tdbb, MFB mfb, ULONG block)
* the file doesn't exist, by all means, create one.
*
**************************************/
SFB sfb_;
if (!(sfb_ = mfb->mfb_sfb)) {
SFB sfb_ = mfb->mfb_sfb;
if (!sfb_) {
sfb_ = mfb->mfb_sfb = FB_NEW(*getDefaultMemoryPool()) sfb;
memset(sfb_, 0, sizeof(struct sfb));
}
@ -3821,3 +3783,4 @@ static void write_merge_block(TDBB tdbb, MFB mfb, ULONG block)
reinterpret_cast<char*>(mfb->mfb_block_data),
mfb->mfb_block_size);
}

View File

@ -108,7 +108,7 @@ void SDW_add(TEXT * file_name, USHORT shadow_number, USHORT file_flags)
CCH_FETCH(tdbb, &window, LCK_write, pag_header);
CCH_MARK_MUST_WRITE(tdbb, &window);
CCH_write_all_shadows(tdbb, 0, window.win_bdb,
tdbb->tdbb_status_vector, 1, FALSE);
tdbb->tdbb_status_vector, 1, false);
CCH_RELEASE(tdbb, &window);
if (file_flags & FILE_conditional)
shadow->sdw_flags |= SDW_conditional;
@ -508,7 +508,8 @@ void SDW_dump_pages(void)
CCH_FETCH_NO_CHECKSUM(tdbb, &window, LCK_read, pag_undefined);
if (!CCH_write_all_shadows(tdbb, shadow, window.win_bdb,
tdbb->tdbb_status_vector, 1,
FALSE)) {
false))
{
CCH_RELEASE(tdbb, &window);
ERR_punt();
}
@ -753,7 +754,7 @@ void SDW_notify(void)
}
BOOLEAN SDW_rollover_to_shadow(FIL file, BOOLEAN inAst)
bool SDW_rollover_to_shadow(FIL file, const bool inAst)
{
/**************************************
*
@ -776,7 +777,7 @@ BOOLEAN SDW_rollover_to_shadow(FIL file, BOOLEAN inAst)
dbb = GET_DBB;
if (file != dbb->dbb_file)
return TRUE;
return true;
update_lock = &temp_lock;
update_lock->lck_dbb = dbb;
@ -804,7 +805,7 @@ BOOLEAN SDW_rollover_to_shadow(FIL file, BOOLEAN inAst)
if (update_lock->lck_physical == LCK_SR)
LCK_release(tdbb, update_lock);
return TRUE;
return true;
}
/* check the various status flags to see if there
@ -819,12 +820,12 @@ BOOLEAN SDW_rollover_to_shadow(FIL file, BOOLEAN inAst)
if (!shadow) {
LCK_release(tdbb, update_lock);
return FALSE;
return false;
}
if (file != dbb->dbb_file) {
LCK_release(tdbb, update_lock);
return TRUE;
return true;
}
/* close the main database file if possible
@ -871,7 +872,7 @@ BOOLEAN SDW_rollover_to_shadow(FIL file, BOOLEAN inAst)
ERR_post(isc_deadlock, 0);
}
return TRUE;
return true;
}

View File

@ -34,7 +34,7 @@ void SDW_get_shadows(void);
void SDW_init(bool, bool, struct sbm*);
BOOLEAN SDW_lck_update(SLONG);
void SDW_notify(void);
BOOLEAN SDW_rollover_to_shadow(struct fil *, BOOLEAN);
bool SDW_rollover_to_shadow(struct fil *, const bool);
void SDW_shutdown_shadow(struct sdw *);
void SDW_start(const TEXT*, USHORT, USHORT, bool);
int SDW_start_shadowing(void* ast_object);

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: sort.cpp,v 1.50 2003-12-11 10:33:25 robocop Exp $
* $Id: sort.cpp,v 1.51 2003-12-22 10:00:47 robocop Exp $
*
* 2001-09-24 SJL - Temporary fix for large sort file bug
*
@ -510,8 +510,8 @@ void SORT_diddle_key(UCHAR* record, SCB scb, bool direction)
#endif
void SORT_error(ISC_STATUS * status_vector,
SFB sfb, TEXT * string, ISC_STATUS operation, int errcode)
void SORT_error(ISC_STATUS* status_vector,
SFB sfb, TEXT* string, ISC_STATUS operation, int errcode)
{
/**************************************
*
@ -529,6 +529,7 @@ void SORT_error(ISC_STATUS * status_vector,
*status_vector++ = isc_arg_gds;
*status_vector++ = isc_io_error;
*status_vector++ = isc_arg_string;
// CVC: Warning, converting pointer to ISC_STATUS => SLONG in 32 bits.
*status_vector++ = (ISC_STATUS) string;
*status_vector++ = isc_arg_string;
*status_vector++ = (ISC_STATUS) ERR_cstring(sfb->sfb_file_name);

View File

@ -240,6 +240,9 @@ typedef struct sfb
/* Sort Context Block */
// Used by SORT_init
typedef bool (*FPTR_REJECT_DUP_CALLBACK)(const UCHAR*, const UCHAR*, void*);
typedef struct scb
{
struct scb *scb_next; /* Next known sort in system */

View File

@ -24,6 +24,7 @@
#include "../common/config/config.h"
#include "../jrd/gds_proto.h"
#include "../jrd/sort.h"
#include "../jrd/sort_proto.h"
#include "../jrd/gdsassert.h"
#include "../jrd/sort_mem.h"
@ -340,3 +341,4 @@ size_t SortMem::write(ISC_STATUS *status, size_t position, char *address, size_t
// New seek value
return position + copied;
}

View File

@ -379,7 +379,7 @@ void TRA_commit(TDBB tdbb, JRD_TRA transaction, const bool retaining_flag)
DFW_perform_work(transaction);
if (transaction->tra_flags & (TRA_prepare2 | TRA_reconnected))
MET_update_transaction(tdbb, transaction, TRUE);
MET_update_transaction(tdbb, transaction, true);
/* Check in with external file system */
@ -1153,7 +1153,7 @@ void TRA_rollback(TDBB tdbb, JRD_TRA transaction, const bool retaining_flag)
/* If no writes have been made, commit the transaction instead. */
if (transaction->tra_flags & (TRA_prepare2 | TRA_reconnected))
MET_update_transaction(tdbb, transaction, FALSE);
MET_update_transaction(tdbb, transaction, false);
/* Find out if there is a transaction savepoint we can use to rollback our transaction */
BOOLEAN tran_sav = FALSE;

View File

@ -1216,7 +1216,7 @@ void API_ROUTINE isc_set_single_user(const UCHAR** dpb,
int API_ROUTINE isc_version(FRBRD** handle,
FPTR_VOID routine, void* user_arg)
FPTR_VERSION_CALLBACK routine, void* user_arg)
{
/**************************************
*
@ -1229,7 +1229,7 @@ int API_ROUTINE isc_version(FRBRD** handle,
*
**************************************/
if (!routine) {
routine = (FPTR_VOID) ib_printf;
routine = (FPTR_VERSION_CALLBACK) ib_printf;
user_arg = (void*)"\t%s\n";
}
@ -1320,8 +1320,7 @@ int API_ROUTINE isc_version(FRBRD** handle,
sprintf(s, "%s (%s), version \"%.*s\"",
implementation_string, class_string, l, versions);
#pragma FB_COMPILER_MESSAGE("Fix! Bad function ptr type cast!")
reinterpret_cast<void (*)(...)>(*routine)(user_arg, s);
(*routine)(user_arg, s);
versions += l;
}
@ -1334,7 +1333,7 @@ int API_ROUTINE isc_version(FRBRD** handle,
sprintf(s, "on disk structure version %d.%d", ods_version,
ods_minor_version);
reinterpret_cast<void (*)(...)>(*routine)(user_arg, s);
(*routine)(user_arg, s);
return FB_SUCCESS;
}

View File

@ -53,7 +53,7 @@ void API_ROUTINE isc_set_debug(int);
void API_ROUTINE isc_set_login(const UCHAR**, SSHORT*);
BOOLEAN API_ROUTINE isc_set_path(TEXT*, USHORT, TEXT*);
void API_ROUTINE isc_set_single_user(const UCHAR**, SSHORT*, const TEXT*);
int API_ROUTINE isc_version(FRBRD **, FPTR_VOID, void *);
int API_ROUTINE isc_version(FRBRD**, FPTR_VERSION_CALLBACK, void*);
void API_ROUTINE isc_format_implementation(USHORT, USHORT, TEXT *,
USHORT, USHORT, TEXT *);
U_IPTR API_ROUTINE isc_baddress(SCHAR*);

View File

@ -648,7 +648,7 @@ static RTN corrupt(TDBB, VDR, USHORT, JRD_REL, ...);
static FETCH_CODE fetch_page(TDBB, VDR, SLONG, USHORT, WIN *, void *);
static void garbage_collect(TDBB, VDR);
#ifdef DEBUG_VAL_VERBOSE
static void print_rhd(USHORT, RHD);
static void print_rhd(USHORT, const rhd*);
#endif
static RTN walk_blob(TDBB, VDR, JRD_REL, BLH, USHORT, SLONG);
static RTN walk_chain(TDBB, VDR, JRD_REL, RHD, SLONG);
@ -681,13 +681,11 @@ BOOLEAN VAL_validate(TDBB tdbb, USHORT switches)
**************************************/
struct vdr control;
JrdMemoryPool *val_pool, *old_pool;
ATT att;
USHORT i;
DBB dbb;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
att = tdbb->tdbb_attachment;
DBB dbb = tdbb->tdbb_database;
ATT att = tdbb->tdbb_attachment;
try {
@ -813,15 +811,13 @@ static FETCH_CODE fetch_page(TDBB tdbb,
* use.
*
**************************************/
DBB dbb;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
CHECK_DBB(dbb);
#ifdef SUPERSERVER
if (--tdbb->tdbb_quantum < 0 && !tdbb->tdbb_inhibit)
JRD_reschedule(tdbb, 0, TRUE);
JRD_reschedule(tdbb, 0, true);
#endif
window->win_page = page_number;
@ -939,7 +935,7 @@ static void garbage_collect(TDBB tdbb, VDR control)
}
#ifdef DEBUG_VAL_VERBOSE
static void print_rhd(USHORT length, RHD header)
static void print_rhd(USHORT length, const rhd* header)
{
/**************************************
*
@ -1127,26 +1123,22 @@ static void walk_database(TDBB tdbb, VDR control)
* Functional description
*
**************************************/
DBB dbb;
HDR page;
VEC vector;
JRD_REL relation;
USHORT i;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
#ifdef DEBUG_VAL_VERBOSE
if (VAL_debug_level)
if (VAL_debug_level) {
ib_fprintf(ib_stdout,
"walk_database: %s\nODS: %d.%d (creation ods %d)\nPage size %d\n",
dbb->dbb_attachment->att_filename->str_data, dbb->dbb_ods_version,
dbb->dbb_minor_version, dbb->dbb_minor_original,
dbb->dbb_page_size);
}
#endif
DPM_scan_pages(tdbb);
WIN window(-1);
hdr* page;
fetch_page(tdbb, control, (SLONG) HEADER_PAGE, pag_header, &window,
&page);
control->vdr_max_transaction = page->hdr_next_transaction;
@ -1157,12 +1149,14 @@ static void walk_database(TDBB tdbb, VDR control)
walk_tip(tdbb, control, page->hdr_next_transaction);
walk_generators(tdbb, control);
for (i = 0; (vector = dbb->dbb_relations) && i < vector->count(); i++) {
VEC vector;
for (USHORT i = 0; (vector = dbb->dbb_relations) && i < vector->count(); i++) {
#ifdef DEBUG_VAL_VERBOSE
if (i >= 32 /* rel_MAX */ )
if (i >= 32 /* rel_MAX */ ) // Why not system flag instead?
VAL_debug_level = 2;
#endif
if ( (relation = (JRD_REL) (*vector)[i]) )
jrd_rel* relation = (JRD_REL) (*vector)[i];
if (relation)
walk_relation(tdbb, control, relation);
}
@ -1183,31 +1177,29 @@ static RTN walk_data_page(TDBB tdbb,
* Walk a single data page.
*
**************************************/
DBB dbb;
DPG page;
RHD header;
RTN result;
UCHAR *end_page;
SLONG number;
int state;
dpg::dpg_repeat * line, *end;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
WIN window(-1);
dpg* page;
fetch_page(tdbb, control, page_number, pag_data, &window, &page);
#ifdef DEBUG_VAL_VERBOSE
if (VAL_debug_level)
if (VAL_debug_level) {
ib_fprintf(ib_stdout,
"walk_data_page: page %d rel %d seq %d count %d\n",
page_number, page->dpg_relation, page->dpg_sequence,
page->dpg_count);
}
#endif
if (page->dpg_relation != relation->rel_id
|| page->dpg_sequence != sequence) {
|| page->dpg_sequence != sequence)
{
++control->vdr_errors;
CCH_RELEASE(tdbb, &window);
return corrupt(tdbb, control, VAL_DATA_PAGE_CONFUSED,
@ -1216,31 +1208,35 @@ static RTN walk_data_page(TDBB tdbb,
/* Walk records */
end_page = (UCHAR *) page + dbb->dbb_page_size;
end = page->dpg_rpt + page->dpg_count;
const UCHAR* const end_page = (UCHAR *) page + dbb->dbb_page_size;
const dpg::dpg_repeat* const end = page->dpg_rpt + page->dpg_count;
number = sequence * dbb->dbb_max_records;
for (line = page->dpg_rpt; line < end; line++, number++) {
for (const dpg::dpg_repeat* line = page->dpg_rpt; line < end; line++, number++) {
#ifdef DEBUG_VAL_VERBOSE
if (VAL_debug_level)
if (VAL_debug_level) {
ib_fprintf(ib_stdout, "Slot %02d (%d,%d): ",
line - page->dpg_rpt,
line->dpg_offset, line->dpg_length);
}
#endif
if (line->dpg_length) {
header = (RHD) ((UCHAR *) page + line->dpg_offset);
rhd* header = (RHD) ((UCHAR *) page + line->dpg_offset);
if ((UCHAR *) header < (UCHAR *) end ||
(UCHAR *) header + line->dpg_length > end_page)
{
return corrupt(tdbb, control, VAL_DATA_PAGE_LINE_ERR,
relation, page_number, sequence,
(SLONG) (line - page->dpg_rpt));
}
if (header->rhd_flags & rhd_chain)
control->vdr_rel_backversion_counter++;
/* Record the existance of a primary version of a record */
if ((control->vdr_flags & vdr_records) &&
!(header->rhd_flags & (rhd_chain | rhd_fragment | rhd_blob))) {
!(header->rhd_flags & (rhd_chain | rhd_fragment | rhd_blob)))
{
/* Only set committed (or limbo) records in the bitmap. If there
is a backversion then at least one of the record versions is
committed. If there's no backversion then check transaction
@ -1271,7 +1267,8 @@ static RTN walk_data_page(TDBB tdbb,
#endif
if (!(header->rhd_flags & rhd_chain) &&
((header->rhd_flags & rhd_large) ||
(control->vdr_flags & vdr_records))) {
(control->vdr_flags & vdr_records)))
{
result = (header->rhd_flags & rhd_blob) ?
walk_blob(tdbb, control, relation, (BLH) header,
line->dpg_length, number) :
@ -1312,17 +1309,15 @@ static void walk_generators(TDBB tdbb, VDR control)
* Walk the page inventory pages.
*
**************************************/
DBB dbb;
VCL vector;
PPG page;
vcl::iterator ptr, end;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
CHECK_DBB(dbb);
WIN window(-1);
if ( (vector = dbb->dbb_gen_id_pages) ) {
vcl* vector = dbb->dbb_gen_id_pages;
if (vector) {
vcl::iterator ptr, end;
for (ptr = vector->begin(), end = vector->end(); ptr < end; ptr++) {
if (*ptr) {
#ifdef DEBUG_VAL_VERBOSE
@ -1787,6 +1782,7 @@ static RTN walk_pointer_page( TDBB tdbb,
for (pages = page->ppg_page, slot = 0; slot < page->ppg_count;
slot++, pages++, seq++)
{
if (*pages) {
result = walk_data_page(tdbb, control, relation, *pages, seq);
if (result != rtn_ok && (control->vdr_flags & vdr_repair)) {
@ -1794,6 +1790,7 @@ static RTN walk_pointer_page( TDBB tdbb,
*pages = 0;
}
}
}
/* If this is the last pointer page in the relation, we're done */
@ -1987,7 +1984,9 @@ static RTN walk_relation(TDBB tdbb, VDR control, JRD_REL relation)
if (!(relation->rel_flags & REL_scanned) ||
(relation->rel_flags & REL_being_scanned))
MET_scan_relation(tdbb, relation);
{
MET_scan_relation(tdbb, relation);
}
#ifdef DEBUG_VAL_VERBOSE
if (VAL_debug_level)
@ -2011,8 +2010,7 @@ static RTN walk_relation(TDBB tdbb, VDR control, JRD_REL relation)
SBM_reset(&control->vdr_rel_records);
}
for (SLONG sequence = 0; true; sequence++) {
RTN result;
result = walk_pointer_page(tdbb, control, relation, sequence);
RTN result = walk_pointer_page(tdbb, control, relation, sequence);
if (result == rtn_eof) {
break;
}
@ -2040,9 +2038,9 @@ static RTN walk_relation(TDBB tdbb, VDR control, JRD_REL relation)
} // try
catch (const std::exception&) {
TEXT s[64];
TEXT* msg = (relation->rel_name) ?
(TEXT*)"bugcheck during scan of table %d (%s)" :
(TEXT*)"bugcheck during scan of table %d";
const char* msg = (relation->rel_name) ?
"bugcheck during scan of table %d (%s)" :
"bugcheck during scan of table %d";
sprintf(s, msg, relation->rel_id, relation->rel_name);
gds__log(s);
#ifdef DEBUG_VAL_VERBOSE

View File

@ -65,6 +65,7 @@ public:
USHORT fmt_version;
Firebird::vector<dsc> fmt_desc;
typedef Firebird::vector<dsc>::iterator fmt_desc_iterator;
typedef Firebird::vector<dsc>::const_iterator fmt_desc_const_iterator;
};
typedef fmt* FMT;
#endif /* REQUESTER */

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ void VIO_erase(TDBB, struct rpb *, class jrd_tra *);
#ifdef GARBAGE_THREAD
void VIO_fini(TDBB);
#endif
int VIO_garbage_collect(TDBB, struct rpb *, class jrd_tra *);
bool VIO_garbage_collect(TDBB, struct rpb *, class jrd_tra *);
struct rec* VIO_gc_record(TDBB, struct jrd_rel *);
int VIO_get(TDBB, struct rpb *, class Rsb *, class jrd_tra *, struct blk *);
int VIO_get_current(TDBB, struct rpb *, class jrd_tra *, struct blk *, USHORT);

View File

@ -42,7 +42,7 @@
*
*/
/*
$Id: why.cpp,v 1.45 2003-12-03 08:19:18 robocop Exp $
$Id: why.cpp,v 1.46 2003-12-22 10:00:48 robocop Exp $
*/
#include "firebird.h"
@ -216,7 +216,7 @@ static void check_status_vector(ISC_STATUS *, ISC_STATUS);
static void cleanup_transaction(WHY_TRA);
static ISC_STATUS error(ISC_STATUS *, ISC_STATUS *);
static ISC_STATUS error2(ISC_STATUS *, ISC_STATUS *);
static void event_ast(UCHAR *, USHORT, UCHAR *);
static void event_ast(void*, USHORT, const UCHAR*);
static void exit_handler(EVENT);
static WHY_TRA find_transaction(WHY_DBB, WHY_TRA);
static void free_block(void*);
@ -1595,7 +1595,8 @@ ISC_STATUS API_ROUTINE GDS_DDL(ISC_STATUS* user_status,
((entrypoint = (PTR) ISC_lookup_entrypoint(image, DYN_ddl, NULL, false)) !=
NULL ||
FALSE) &&
!((*entrypoint) (status, db_handle, tra_handle, length, ddl))) {
!((*entrypoint) (status, db_handle, tra_handle, length, ddl)))
{
CHECK_STATUS_SUCCESS(status);
return FB_SUCCESS;
}
@ -1620,7 +1621,6 @@ ISC_STATUS API_ROUTINE GDS_DETACH(ISC_STATUS * user_status,
**************************************/
ISC_STATUS *status;
ISC_STATUS_ARRAY local;
WHY_ATT dbb;
WHY_REQ request;
WHY_STMT statement;
WHY_BLB blob;
@ -1628,7 +1628,7 @@ ISC_STATUS API_ROUTINE GDS_DETACH(ISC_STATUS * user_status,
GET_STATUS;
dbb = *handle;
WHY_ATT dbb = *handle;
#ifdef WIN_NT
/* This code was added to fix an IDAPI problem where our DLL exit handler
@ -1725,10 +1725,8 @@ int API_ROUTINE gds__disable_subsystem(TEXT * subsystem)
* has been explicitly disabled, all are available.
*
**************************************/
const IMAGE* sys;
const IMAGE* end;
for (sys = images, end = sys + SUBSYSTEMS; sys < end; sys++)
const IMAGE* sys = images;
for (const IMAGE* const end = sys + SUBSYSTEMS; sys < end; sys++)
{
if (!strcmp(sys->name, subsystem)) {
if (!why_enabled)
@ -1757,14 +1755,13 @@ ISC_STATUS API_ROUTINE GDS_DROP_DATABASE(ISC_STATUS * user_status,
**************************************/
ISC_STATUS *status;
ISC_STATUS_ARRAY local;
WHY_ATT dbb;
WHY_REQ request;
WHY_STMT statement;
WHY_BLB blob;
CLEAN clean;
GET_STATUS;
dbb = *handle;
WHY_ATT dbb = *handle;
CHECK_HANDLE(dbb, HANDLE_database, isc_bad_db_handle);
#ifdef SUPERSERVER
@ -1890,21 +1887,15 @@ ISC_STATUS API_ROUTINE GDS_DSQL_ALLOCATE(ISC_STATUS * user_status,
* Allocate a statement handle.
*
**************************************/
ISC_STATUS s, *status;
ISC_STATUS* status;
ISC_STATUS_ARRAY local;
WHY_STMT statement;
WHY_ATT dbb;
UCHAR flag;
PTR entry;
#ifndef NO_LOCAL_DSQL
dsql_req *dstatement = 0;
#endif
GET_STATUS;
/* check the statement handle to make sure it's NULL and then initialize it. */
NULL_CHECK(stmt_handle, isc_bad_stmt_handle, HANDLE_statement);
dbb = *db_handle;
WHY_ATT dbb = *db_handle;
CHECK_HANDLE(dbb, HANDLE_database, isc_bad_db_handle);
/* Attempt to have the implementation which processed the database attach
@ -1913,15 +1904,16 @@ ISC_STATUS API_ROUTINE GDS_DSQL_ALLOCATE(ISC_STATUS * user_status,
something) in which case, execute the functionality locally (and hence
remotely through the original Y-valve). */
s = isc_unavailable;
entry = get_entrypoint(PROC_DSQL_ALLOCATE, dbb->implementation);
ISC_STATUS s = isc_unavailable;
PTR entry = get_entrypoint(PROC_DSQL_ALLOCATE, dbb->implementation);
if (entry != no_entrypoint) {
subsystem_enter();
s = (*entry) (status, &dbb->handle, stmt_handle);
subsystem_exit();
}
flag = 0;
UCHAR flag = 0;
#ifndef NO_LOCAL_DSQL
dsql_req* dstatement = 0;
if (s == isc_unavailable) {
/* if the entry point didn't exist or if the routine said the server
didn't support the protocol... do it locally */
@ -3837,7 +3829,7 @@ ISC_STATUS API_ROUTINE GDS_QUE_EVENTS(ISC_STATUS* user_status,
SLONG* id,
USHORT length,
const UCHAR* events,
event_ast_routine* ast,
FPTR_EVENT_CALLBACK ast,
void* arg)
{
/**************************************
@ -5248,9 +5240,9 @@ static ISC_STATUS error2(ISC_STATUS * user_status,
#ifndef REQUESTER
static void event_ast(UCHAR * buffer,
static void event_ast(void* buffer_void,
USHORT length,
UCHAR * items)
const UCHAR* items)
{
/**************************************
*
@ -5262,9 +5254,10 @@ static void event_ast(UCHAR * buffer,
* We're had an event complete.
*
**************************************/
while (length--)
UCHAR* buffer = static_cast<UCHAR*>(buffer_void);
while (length--) {
*buffer++ = *items++;
}
ISC_event_post(why_event);
}
#endif
@ -5598,21 +5591,18 @@ static ISC_STATUS open_blob(ISC_STATUS* user_status,
ISC_STATUS *status;
ISC_STATUS_ARRAY local;
WHY_TRA transaction;
WHY_ATT dbb;
WHY_BLB blob;
USHORT from, to;
USHORT flags;
GET_STATUS;
NULL_CHECK(blob_handle, isc_bad_segstr_handle, HANDLE_blob);
dbb = *db_handle;
WHY_ATT dbb = *db_handle;
CHECK_HANDLE(dbb, HANDLE_database, isc_bad_db_handle);
transaction = find_transaction(dbb, *tra_handle);
CHECK_HANDLE(transaction, HANDLE_transaction, isc_bad_trans_handle);
subsystem_enter();
flags = 0;
USHORT flags = 0;
USHORT from, to;
gds__parse_bpb(bpb_length, bpb, &from, &to);
if (get_entrypoint(proc2, dbb->implementation) != no_entrypoint &&
@ -5636,7 +5626,7 @@ static ISC_STATUS open_blob(ISC_STATUS* user_status,
return error(status, local);
}
blob = allocate_handle(dbb->implementation, *blob_handle, HANDLE_blob);
WHY_BLB blob = allocate_handle(dbb->implementation, *blob_handle, HANDLE_blob);
if (!blob)
{
/* No memory. Make a half-hearted attempt to cancel the blob. */
@ -5684,25 +5674,23 @@ static ISC_STATUS open_marker_file(ISC_STATUS * status,
* otherwise.
*
*************************************/
int fd, i, j;
TEXT marker_filename[MAXPATHLEN], marker_contents[MAXPATHLEN],
fildes_str[5], *p;
TEXT *err_routine, buffer[80];
SLONG bytes, size;
TEXT buffer[80];
/* Create the marker file name and see if it exists. If not,
don't sweat it. */
TEXT marker_filename[MAXPATHLEN], marker_contents[MAXPATHLEN];
strcpy(marker_filename, expanded_filename);
strcat(marker_filename, "_m");
if (access(marker_filename, F_OK)) /* Marker file doesn't exist. */
return FB_SUCCESS;
const TEXT* err_routine = 0;
/* Ensure that writes are ok on the marker file for lockf(). */
TEXT fildes_str[5];
if (!access(marker_filename, W_OK)) {
for (i = 0; i < IO_RETRY; i++) {
if ((fd = open(marker_filename, O_RDWR)) == -1) {
for (int i = 0; i < IO_RETRY; i++) {
const int fd = open(marker_filename, O_RDWR);
if (fd == -1) {
sprintf(buffer,
"Couldn't open marker file %s\n", marker_filename);
gds__log(buffer);
@ -5716,9 +5704,10 @@ static ISC_STATUS open_marker_file(ISC_STATUS * status,
#else
if (lockf(fd, F_TLOCK, 0) != -1) {
#endif
size = sizeof(marker_contents);
for (j = 0; j < IO_RETRY; j++) {
if ((bytes = read(fd, marker_contents, size)) != -1)
const SLONG size = sizeof(marker_contents);
for (int j = 0; j < IO_RETRY; j++) {
const SLONG bytes = read(fd, marker_contents, size);
if (bytes != -1)
break;
if ((bytes == -1) && (!SYSCALL_INTERRUPTED(errno))) {
@ -5728,22 +5717,23 @@ static ISC_STATUS open_marker_file(ISC_STATUS * status,
}
} /* for (j < IO_RETRY ) */
p = strchr(marker_contents, '\n');
TEXT* p = strchr(marker_contents, '\n');
*p = 0;
if (strcmp(expanded_filename, marker_contents))
close(fd);
else {
sprintf(fildes_str, "%d\n", fd);
strcpy(single_user, "YES");
size = strlen(fildes_str);
for (j = 0; j < IO_RETRY; j++) {
const SLONG size2 = strlen(fildes_str);
for (int j2 = 0; j2 < IO_RETRY; j2++) {
if (lseek(fd, LSEEK_OFFSET_CAST 0L, SEEK_END) == -1) {
err_routine = "lseek";
close(fd);
fd = -1;
}
if ((bytes = write(fd, fildes_str, size)) == size)
const SLONG bytes = write(fd, fildes_str, size2);
if (bytes == size2)
break;
if ((bytes == -1) && (!SYSCALL_INTERRUPTED(errno))) {
@ -5751,7 +5741,7 @@ static ISC_STATUS open_marker_file(ISC_STATUS * status,
close(fd);
fd = -1;
}
} /* for (j < IO_RETRY ) */
} /* for (j2 < IO_RETRY ) */
}
}
else
@ -5794,7 +5784,9 @@ static ISC_STATUS open_marker_file(ISC_STATUS * status,
if (marker_failures_ptr + strlen(marker_filename) + 1 >
marker_failures + sizeof(marker_failures) - 1)
{
marker_failures_ptr = marker_failures;
}
*status++ = isc_arg_gds;
*status++ = isc_io_error;
@ -5852,23 +5844,21 @@ static ISC_STATUS prepare(ISC_STATUS * status,
*
**************************************/
WHY_TRA sub;
TEXT *p, *description;
TEXT tdr_buffer[1024];
USHORT length = 0;
for (sub = transaction->next; sub; sub = sub->next)
length += 256;
description =
(length >
sizeof(tdr_buffer)) ? (TEXT *) gds__alloc((SLONG) length) :
tdr_buffer;
TEXT* const description = (length > sizeof(tdr_buffer)) ?
(TEXT *) gds__alloc((SLONG) length) : tdr_buffer;
/* build a transaction description record containing
the host site and database/transaction
information for the target databases. */
if (!(p = description)) {
TEXT* p = description;
if (!p) {
status[0] = isc_arg_gds;
status[1] = isc_virmemexh;
status[2] = isc_arg_end;
@ -5933,15 +5923,12 @@ static void release_dsql_support(DASUP dasup)
* Release some memory.
*
**************************************/
struct dasup::dasup_clause* pClauses;
if (!dasup) {
return;
}
/* for C++, add "dasup::" before "dasup_clause" */
pClauses = dasup->dasup_clauses;
struct dasup::dasup_clause* pClauses = dasup->dasup_clauses;
why_priv_gds__free_if_set(pClauses[DASUP_CLAUSE_bind].dasup_blr);
why_priv_gds__free_if_set(pClauses[DASUP_CLAUSE_select].dasup_blr);
@ -5963,7 +5950,6 @@ static void release_handle(WHY_HNDL handle)
* Release unused and unloved handle.
*
**************************************/
handle->type = HANDLE_invalid;
free_block(handle);
}
@ -5987,16 +5973,14 @@ static void save_error_string(ISC_STATUS * status)
* a standard <Unknown> string.
*
**************************************/
TEXT *p;
ULONG l, len;
fb_assert(status != NULL);
p = glbstr1;
len = sizeof(glbstr1) - 1;
TEXT* p = glbstr1;
ULONG len = sizeof(glbstr1) - 1;
while (*status != isc_arg_end)
{
ULONG l;
switch (*status++)
{
case isc_arg_cstring:

View File

@ -103,9 +103,11 @@ ISC_STATUS API_ROUTINE isc_dsql_sql_info(ISC_STATUS*, FRBRD**, SSHORT,
const SCHAR*, SSHORT, SCHAR*);
//ISC_STATUS API_ROUTINE isc_prepare_transaction2(ISC_STATUS*, FRBRD**, USHORT,
// UCHAR*);
typedef void event_ast_routine(UCHAR*, USHORT, UCHAR*);
// Deprecated in favor of FPTR_EVENT_CALLBACK
//typedef void event_ast_routine(UCHAR*, USHORT, UCHAR*);
//ISC_STATUS API_ROUTINE isc_que_events(ISC_STATUS*, FRBRD**, SLONG*,
// USHORT, const UCHAR*, event_ast_routine*, void*);
// USHORT, const UCHAR*,
// FPTR_EVENT_CALLBACK, void*);
//#ifdef SCROLLABLE_CURSORS
//ISC_STATUS API_ROUTINE isc_receive2(ISC_STATUS*, FRBRD**, USHORT,
// USHORT, SCHAR*, SSHORT, USHORT,
@ -183,7 +185,8 @@ ISC_STATUS API_ROUTINE isc_put_slice(ISC_STATUS*, FRBRD**, FRBRD**, SLONG*,
SLONG, UCHAR*);
ISC_STATUS API_ROUTINE isc_que_events(ISC_STATUS*, FRBRD**, SLONG*, USHORT,
const UCHAR*, event_ast_routine*, void*);
const UCHAR*,
FPTR_EVENT_CALLBACK, void*);
ISC_STATUS API_ROUTINE isc_receive(ISC_STATUS*, FRBRD**, USHORT, USHORT,
SCHAR*, SSHORT);

View File

@ -1001,7 +1001,7 @@ int MET_get_datatype( USHORT blr_datatype)
retvalue = dtype_int64;
break;
default:
retvalue = dtype_null;
retvalue = dtype_unknown;
break;
}

View File

@ -40,8 +40,8 @@ static void mover_error(int, USHORT, USHORT);
static void now_to_date(const tm*, SLONG[2]);
static void numeric_to_text(const dsc*, dsc*);
static void string_to_date(const TEXT*, USHORT, SLONG[2]);
static void string_to_time(TEXT *, USHORT, SLONG[2]);
static TEXT *type_name(USHORT);
static void string_to_time(const TEXT*, USHORT, SLONG[2]);
static const TEXT* type_name(USHORT);
@ -76,7 +76,7 @@ struct dtypes_t {
};
static const dtypes_t dtypes_table[] = {
{ dtype_null, "NULL" },
{ dtype_unknown, "NULL" },
{ dtype_text, "character string" },
{ dtype_cstring, "character string" },
{ dtype_varying, "varying string" },
@ -1156,19 +1156,19 @@ static void mover_error( int pattern, USHORT in_type, USHORT out_type)
ERRQ_msg_get(504, msg_unknown); // Msg504 unknown datatype %d
TEXT* in = type_name(in_type);
const TEXT* in = type_name(in_type);
if (!in) {
in = in_name;
sprintf(in_name, msg_unknown, in_type);
}
TEXT* out = type_name(out_type);
const TEXT* out = type_name(out_type);
if (!out) {
out = out_name;
sprintf(out, msg_unknown, out_type);
sprintf(out_name, msg_unknown, out_type);
}
ERRQ_error(pattern, (TEXT *) in, (TEXT *) out, NULL, NULL, NULL);
ERRQ_error(pattern, in, out, NULL, NULL, NULL);
}
@ -1482,7 +1482,7 @@ static void string_to_date(const TEXT* string, USHORT length, SLONG date[2])
}
static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
static void string_to_time(const TEXT* string, USHORT length, SLONG date[2])
{
/**************************************
*
@ -1491,7 +1491,7 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
**************************************
*
* Functional description
* Convert an arbitrary string to a t i m e.
* Convert an arbitrary string to a time.
*
**************************************/
if (!length) {
@ -1587,7 +1587,7 @@ static void string_to_time( TEXT * string, USHORT length, SLONG date[2])
}
static TEXT *type_name( USHORT dtype)
static const TEXT* type_name( USHORT dtype)
{
/**************************************
*
@ -1599,9 +1599,10 @@ static TEXT *type_name( USHORT dtype)
* Return the name of a data type.
*
**************************************/
for (const dtypes_t* names = dtypes_table; names->description; names++)
for (const dtypes_t* names = dtypes_table; names->description; names++) {
if (names->type == dtype)
return names->description;
}
return NULL;
}

View File

@ -76,7 +76,8 @@ ISC_STATUS REM_prepare_transaction(ISC_STATUS *, struct rtr **, USHORT, UCHAR *)
ISC_STATUS REM_put_segment(ISC_STATUS*, struct rbl**, USHORT, const UCHAR*);
ISC_STATUS REM_put_slice(ISC_STATUS*, struct rdb**, struct rtr**, BID, USHORT,
const UCHAR*, USHORT, const UCHAR*, SLONG, UCHAR*);
ISC_STATUS REM_que_events(ISC_STATUS*, struct rdb**, SLONG*, SSHORT, const UCHAR*, void (*)(void*, USHORT, UCHAR*), void*);
ISC_STATUS REM_que_events(ISC_STATUS*, struct rdb**, SLONG*, SSHORT,
const UCHAR*, FPTR_EVENT_CALLBACK, void*);
ISC_STATUS REM_query_service(ISC_STATUS *, struct rdb **, USHORT, SCHAR *, USHORT, SCHAR *, USHORT, SCHAR *);
ISC_STATUS REM_receive(ISC_STATUS *, struct rrq **, USHORT, USHORT, UCHAR *, SSHORT);
ISC_STATUS REM_reconnect_transaction(ISC_STATUS*, struct rdb**, struct rtr**,

View File

@ -3049,7 +3049,7 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
SLONG* id,
SSHORT length,
const UCHAR* items,
void (*ast) (void*, USHORT, UCHAR*), void* arg)
FPTR_EVENT_CALLBACK ast, void* arg)
{
/**************************************
*
@ -3133,7 +3133,7 @@ ISC_STATUS GDS_QUE_EVENTS(ISC_STATUS* user_status,
event->p_event_database = rdb->rdb_id;
event->p_event_items.cstr_length = length;
event->p_event_items.cstr_address = const_cast<UCHAR*>(items);
event->p_event_ast = (SLONG) ast;
event->p_event_ast = ast;
event->p_event_arg = (SLONG) arg;
event->p_event_rid = rem_event->rvnt_id;
@ -6964,7 +6964,7 @@ static void send_cancel_event(RVNT event)
if (event->rvnt_id)
{
THREAD_EXIT;
(*event->rvnt_ast)(event->rvnt_arg, (SSHORT) 0, NULL);
(*event->rvnt_ast)(event->rvnt_arg, (USHORT) 0, NULL);
THREAD_ENTER;
event->rvnt_id = 0;
}
@ -7065,7 +7065,7 @@ static void server_death(PORT port)
if (event->rvnt_id)
{
THREAD_EXIT;
(*event->rvnt_ast) (event->rvnt_arg, (SSHORT) 0, NULL);
(*event->rvnt_ast) (event->rvnt_arg, (USHORT) 0, NULL);
THREAD_ENTER;
event->rvnt_id = 0;
}

View File

@ -526,15 +526,19 @@ bool_t xdr_protocol(XDR* xdrs, PACKET* p)
case op_que_events:
case op_event:
event = &p->p_event;
MAP(xdr_short,
reinterpret_cast < SSHORT & >(event->p_event_database));
MAP(xdr_cstring, event->p_event_items);
MAP(xdr_long, event->p_event_ast);
MAP(xdr_long, event->p_event_arg);
MAP(xdr_long, event->p_event_rid);
DEBUG_PRINTSIZE(p->p_operation);
return P_TRUE;
{
event = &p->p_event;
MAP(xdr_short,
reinterpret_cast<SSHORT&>(event->p_event_database));
MAP(xdr_cstring, event->p_event_items);
#pragma FB_COMPILER_MESSAGE("p_event_ast is a pointer to function forced to SLONG!")
MAP(xdr_long, reinterpret_cast<SLONG&>(event->p_event_ast));
#pragma FB_COMPILER_MESSAGE("p_event_arg is a void* stored as SLONG!")
MAP(xdr_long, event->p_event_arg);
MAP(xdr_long, event->p_event_rid);
DEBUG_PRINTSIZE(p->p_operation);
return P_TRUE;
}
case op_cancel_events:
event = &p->p_event;

View File

@ -32,7 +32,7 @@
*
*/
/*
$Id: protocol.h,v 1.16 2003-11-05 09:02:31 robocop Exp $
$Id: protocol.h,v 1.17 2003-12-22 10:00:56 robocop Exp $
*/
#ifndef REMOTE_PROTOCOL_H
#define REMOTE_PROTOCOL_H
@ -479,7 +479,7 @@ typedef struct p_info {
typedef struct p_event {
OBJCT p_event_database; /* Database object id */
CSTRING p_event_items; /* Event description block */
SLONG p_event_ast; /* Address of ast routine */
FPTR_EVENT_CALLBACK p_event_ast; /* Address of ast routine */
SLONG p_event_arg; /* Argument to ast routine */
SLONG p_event_rid; /* Client side id of remote event */
} P_EVENT;

View File

@ -139,7 +139,7 @@ typedef struct rvnt
struct blk rvnt_header;
struct rvnt*rvnt_next;
RDB rvnt_rdb;
void (*rvnt_ast)(void*, USHORT, UCHAR*);
FPTR_EVENT_CALLBACK rvnt_ast;
void* rvnt_arg;
SLONG rvnt_id;
SLONG rvnt_rid; /* used by server to store client-side id */

View File

@ -158,7 +158,7 @@ static void release_transaction(RTR);
static REM_MSG scroll_cache(rrq::rrq_repeat*, USHORT *, ULONG *);
#endif
static void server_ast(RVNT, USHORT, UCHAR*);
static void server_ast(void*, USHORT, const UCHAR*);
static void success(ISC_STATUS *);
#ifdef MULTI_THREAD
static int THREAD_ROUTINE thread(void *);
@ -943,7 +943,7 @@ static ISC_STATUS cancel_events( PORT port, P_EVENT * stuff, PACKET* send)
event->rvnt_id = 0L;
event->rvnt_rid = 0L;
event->rvnt_ast = 0L;
event->rvnt_ast = 0;
/* return response */
@ -3373,8 +3373,8 @@ ISC_STATUS port::que_events(P_EVENT * stuff, PACKET* send)
rdb->rdb_events = event;
}
event->rvnt_ast =
reinterpret_cast<void(*)(void*, USHORT, UCHAR*)>(stuff->p_event_ast);
event->rvnt_ast = stuff->p_event_ast;
// CVC: Going from SLONG to void*, problems when sizeof(void*) > 4
event->rvnt_arg = (void *) stuff->p_event_arg;
event->rvnt_rid = stuff->p_event_rid;
event->rvnt_rdb = rdb;
@ -3383,7 +3383,7 @@ ISC_STATUS port::que_events(P_EVENT * stuff, PACKET* send)
isc_que_events(status_vector, &rdb->rdb_handle, &event->rvnt_id,
stuff->p_event_items.cstr_length,
reinterpret_cast<const char*>(stuff->p_event_items.cstr_address),
reinterpret_cast<void (*)()>(server_ast),
server_ast,
event);
THREAD_ENTER;
@ -4226,7 +4226,7 @@ ISC_STATUS port::send_response( PACKET* send,
}
static void server_ast( RVNT event, USHORT length, UCHAR * items)
static void server_ast(void* event_void, USHORT length, const UCHAR* items)
{
/**************************************
*
@ -4238,6 +4238,7 @@ static void server_ast( RVNT event, USHORT length, UCHAR * items)
* Send an asynchrous event packet back to client.
*
**************************************/
RVNT event = reinterpret_cast<RVNT>(event_void);
RDB rdb;
PORT port;
PACKET packet;
@ -4256,8 +4257,10 @@ static void server_ast( RVNT event, USHORT length, UCHAR * items)
p_event = &packet.p_event;
p_event->p_event_database = rdb->rdb_id;
p_event->p_event_items.cstr_length = length;
p_event->p_event_items.cstr_address = items;
p_event->p_event_ast = (SLONG) event->rvnt_ast;
// Probalby should define this item with CSTRING_CONST instead.
p_event->p_event_items.cstr_address = const_cast<UCHAR*>(items);
p_event->p_event_ast = event->rvnt_ast;
// CVC: Using SLONG to keep pointer!
p_event->p_event_arg = (SLONG) event->rvnt_arg;
p_event->p_event_rid = event->rvnt_rid;

View File

@ -67,10 +67,10 @@ struct tsec *gdsec;
static int common_main(int, char**, pfn_svc_output, svc*);
static void util_output(const SCHAR*, ...);
static void data_print(void *, USER_DATA, bool);
static bool get_line(int *, SCHAR **, TEXT *, TSEC);
static bool get_switches(int, TEXT **, IN_SW_TAB, TSEC, bool *);
static SSHORT parse_cmd_line(int, TEXT **, TSEC);
static void data_print(void*, const internal_user_data*, bool);
static bool get_line(int*, SCHAR**, TEXT*, tsec*);
static bool get_switches(int, const TEXT* const*, IN_SW_TAB, tsec*, bool*);
static SSHORT parse_cmd_line(int, const TEXT* const*, tsec*);
static void printhelp(void);
#ifndef SUPERSERVER
static int output_main(svc*, const UCHAR*);
@ -94,9 +94,7 @@ int GSEC_main(svc* service)
* Functional Description:
* Entrypoint for GSEC via the services manager
**********************************************/
int exit_code;
exit_code = common_main(service->svc_argc, service->svc_argv,
const int exit_code = common_main(service->svc_argc, service->svc_argv,
SVC_output, service);
service->svc_handle = 0;
@ -165,24 +163,15 @@ int common_main(int argc,
* the specified argc/argv to SECURITY_exec_line (see below).
*
**************************************/
ISC_STATUS *status;
FRBRD *db_handle = NULL; /* user info database handle */
int local_argc;
SCHAR *local_argv[MAXARGS];
DebugBreak();
TEXT stuff[MAXSTUFF]; /* a place to put stuff */
SSHORT ret;
char dpb_buffer[256], *dpb, *p;
short dpb_length;
TSEC tdsec;
USER_DATA user_data;
JMP_BUF env;
#ifdef VMS
int argc;
argc = VMS_parse(&argv, argc);
#endif
tdsec = (struct tsec *) gds__alloc(sizeof(*tdsec));
tsec* tdsec = (struct tsec *) gds__alloc(sizeof(struct tsec));
/* NOMEM: return error, FREE: during function exit in the SETJMP */
if (tdsec == NULL) {
gsec_exit(FINI_ERROR, tdsec);
@ -193,13 +182,13 @@ int common_main(int argc,
memset((void *) tdsec, 0, sizeof(*tdsec));
tdsec->tsec_user_data =
(struct user_data *) gds__alloc(sizeof(*user_data));
(internal_user_data*) gds__alloc(sizeof(internal_user_data));
/* NOMEM: return error, FREE: during function exit in the SETJMP */
if (tdsec->tsec_user_data == NULL) {
gsec_exit(FINI_ERROR, tdsec);
}
memset((void *) tdsec->tsec_user_data, 0, sizeof(*user_data));
memset((void *) tdsec->tsec_user_data, 0, sizeof(internal_user_data));
try {
@ -215,7 +204,7 @@ int common_main(int argc,
tdsec->tsec_service_thd = false;
tdsec->tsec_service_blk = NULL;
tdsec->tsec_status = tdsec->tsec_status_vector;
user_data = tdsec->tsec_user_data;
internal_user_data* user_data = tdsec->tsec_user_data;
if (argc > 1 && !strcmp(argv[1], "-svc")) {
tdsec->tsec_service_gsec = true;
@ -233,7 +222,8 @@ int common_main(int argc,
}
#endif
else if (argc > 4 && !strcmp(argv[1], "-svc_re")) {
tdsec->tsec_service_gsec = TRUE;
tdsec->tsec_service_gsec = true;
// tdsec->output_proc = output_svc;
long redir_in = atol(argv[2]);
long redir_out = atol(argv[3]);
long redir_err = atol(argv[4]);
@ -255,8 +245,8 @@ int common_main(int argc,
argc -= 4;
}
status = tdsec->tsec_status;
ret = parse_cmd_line(argc, argv, tdsec);
ISC_STATUS* status = tdsec->tsec_status;
SSHORT ret = parse_cmd_line(argc, argv, tdsec);
TEXT user_info_name[MAXPATHLEN]; /* user info database name */
const TEXT* u;
@ -273,13 +263,14 @@ int common_main(int argc,
u = user_info_name;
}
dpb = dpb_buffer;
char dpb_buffer[256];
char* dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
if (user_data->dba_user_name_entered) {
*dpb++ = isc_dpb_user_name;
*dpb++ = strlen(user_data->dba_user_name);
for (p = user_data->dba_user_name; *p;)
for (const char* p = user_data->dba_user_name; *p;)
*dpb++ = *p++;
}
@ -289,18 +280,19 @@ int common_main(int argc,
else
*dpb++ = isc_dpb_password;
*dpb++ = strlen(user_data->dba_password);
for (p = user_data->dba_password; *p;)
for (const char* p = user_data->dba_password; *p;)
*dpb++ = *p++;
}
if (user_data->sql_role_name_entered) {
*dpb++ = isc_dpb_sql_role_name;
*dpb++ = strlen(user_data->sql_role_name);
for (p = user_data->sql_role_name; *p;)
for (const char* p = user_data->sql_role_name; *p;)
*dpb++ = *p++;
}
dpb_length = dpb - dpb_buffer;
const SSHORT dpb_length = dpb - dpb_buffer;
FRBRD* db_handle = NULL; /* user info database handle */
if (isc_attach_database(status, 0, u, &db_handle, dpb_length, dpb_buffer))
GSEC_error_redirect(status, GsecMsg15, NULL, NULL);
@ -326,9 +318,11 @@ int common_main(int argc,
}
}
else {
int local_argc;
SCHAR* local_argv[MAXARGS];
for (;;) {
/* Clear out user data each time through this loop. */
MOVE_CLEAR(tdsec->tsec_user_data, sizeof(struct user_data));
MOVE_CLEAR(tdsec->tsec_user_data, sizeof(internal_user_data));
if (get_line(&local_argc, local_argv, stuff, tdsec))
break;
if (local_argc > 1) {
@ -352,8 +346,9 @@ int common_main(int argc,
if (db_handle) {
ISC_STATUS_ARRAY loc_status;
if (isc_detach_database(loc_status, &db_handle))
if (isc_detach_database(loc_status, &db_handle)) {
GSEC_error_redirect(loc_status, 0, NULL, NULL);
}
}
gsec_exit(FINI_OK, tdsec);
return 0; // silence compiler warning
@ -377,7 +372,7 @@ int common_main(int argc,
}
static void data_print( void *arg, USER_DATA data, bool first)
static void data_print(void* arg, const internal_user_data* data, bool first)
{
/**************************************
*
@ -390,15 +385,13 @@ static void data_print( void *arg, USER_DATA data, bool first)
* if first is TRUE print the header then the data
*
**************************************/
TSEC tdsec;
tdsec = GET_THREAD_DATA;
tsec* tdsec = GET_THREAD_DATA;
#ifdef SUPERSERVER
#define STUFF_USER(item) SVC_putc(tdsec->tsec_service_blk, item)
#else
#define STUFF_USER(item) ib_fputc(item, ib_stderr)
#endif
if (tdsec->tsec_service_gsec) {
int i, len;
/* Send the username */
@ -446,7 +439,8 @@ static void data_print( void *arg, USER_DATA data, bool first)
STUFF_USER((UCHAR) (data->gid >> 8));
STUFF_USER((UCHAR) (data->gid >> 16));
STUFF_USER((UCHAR) (data->gid >> 24));
} else {
}
else {
if (first) {
GSEC_print(GsecMsg26, NULL, NULL, NULL, NULL, NULL);
GSEC_print(GsecMsg27, NULL, NULL, NULL, NULL, NULL);
@ -461,7 +455,7 @@ static void data_print( void *arg, USER_DATA data, bool first)
}
static bool get_line( int *argc, SCHAR ** argv, TEXT * stuff, TSEC tdsec)
static bool get_line(int* argc, SCHAR** argv, TEXT* stuff, tsec* tdsec)
{
/**************************************
*
@ -475,22 +469,18 @@ static bool get_line( int *argc, SCHAR ** argv, TEXT * stuff, TSEC tdsec)
* unused), and a max of MAXSTUFF characters, at which point
*
**************************************/
USHORT count;
TEXT *cursor, c;
bool first;
GSEC_print_partial(GsecMsg1, NULL, NULL, NULL, NULL, NULL);
*argc = 1;
cursor = stuff;
count = MAXSTUFF - 1;
first = true;
TEXT* cursor = stuff;
USHORT count = MAXSTUFF - 1;
bool first = true;
/* for each input character, if it's white space (or any non-printable,
non-newline for that matter), ignore it; if it's a newline, we're
done; otherwise, put it in the current argument */
while (*argc < MAXARGS && count > 0) {
c = ib_getc(ib_stdin);
TEXT c = ib_getc(ib_stdin);
if (c > ' ' && c <= '~') {
/* note that the first argument gets a '-' appended to the front to fool
the switch checker into thinking it came from the command line */
@ -530,9 +520,9 @@ static bool get_line( int *argc, SCHAR ** argv, TEXT * stuff, TSEC tdsec)
static bool get_switches(
int argc,
TEXT ** argv,
const TEXT* const* argv,
IN_SW_TAB in_sw_table,
TSEC tdsec, bool * quitflag)
tsec* tdsec, bool* quitflag)
{
/**************************************
*
@ -545,13 +535,9 @@ static bool get_switches(
* interesting switches in a switch table.
*
**************************************/
TEXT *p, *q, *string, msg[MSG_LENGTH];
IN_SW_TAB in_sw_tab;
USHORT in_sw;
USHORT last_sw;
TEXT msg[MSG_LENGTH];
int l;
SSHORT err_msg_no;
USER_DATA user_data;
/* look at each argument. it's either a switch or a parameter.
parameters must always follow a switch, but not all switches
@ -559,12 +545,12 @@ static bool get_switches(
cleared (like a -fname switch followed by no first name
parameter). */
user_data = tdsec->tsec_user_data;
internal_user_data* user_data = tdsec->tsec_user_data;
*quitflag = false;
last_sw = IN_SW_GSEC_0;
USHORT last_sw = IN_SW_GSEC_0;
tdsec->tsec_sw_version = false;
for (--argc; argc > 0; argc--) {
string = *++argv;
const TEXT* string = *++argv;
if (*string == '?')
user_data->operation = HELP_OPER;
else if (*string != '-') {
@ -659,10 +645,13 @@ static bool get_switches(
else {
/* iterate through the switch table, looking for matches */
in_sw = IN_SW_GSEC_0;
for (in_sw_tab = in_sw_table; q = in_sw_tab->in_sw_name;
in_sw_tab++) {
p = string + 1;
USHORT in_sw = IN_SW_GSEC_0;
{ // scope
const TEXT* q;
for (const in_sw_tab_t* in_sw_tab = in_sw_table;
q = in_sw_tab->in_sw_name; in_sw_tab++)
{
const TEXT* p = string + 1;
/* handle orphaned hyphen case */
@ -689,6 +678,7 @@ static bool get_switches(
if (!*p)
break;
}
} // scope
/* this checks to make sure that the switch is not a duplicate. if
it is a duplicate, it's an error. if it's not a duplicate, the
@ -882,6 +872,7 @@ static bool get_switches(
user_data->sys_user_entered || user_data->group_name_entered ||
user_data->password_entered || user_data->first_name_entered ||
user_data->middle_name_entered || user_data->last_name_entered)
{
switch (user_data->operation) {
case 0:
GSEC_error(GsecMsg42, NULL, NULL, NULL, NULL, NULL);
@ -899,6 +890,7 @@ static bool get_switches(
/* gsec - no parameters allowed for this operation */
return false;
}
}
if (*quitflag)
break;
@ -1074,7 +1066,7 @@ static void printhelp(void)
}
static SSHORT parse_cmd_line( int argc, TEXT ** argv, TSEC tdsec)
static SSHORT parse_cmd_line(int argc, const TEXT* const* argv, tsec* tdsec)
{
/**************************************
*
@ -1089,16 +1081,13 @@ static SSHORT parse_cmd_line( int argc, TEXT ** argv, TSEC tdsec)
* -1 on error or if user asks for help
*
**************************************/
SSHORT ret;
bool quitflag = false;
USER_DATA user_data;
user_data = tdsec->tsec_user_data;
memset(user_data, 0, sizeof(USER_DATA));
internal_user_data* user_data = tdsec->tsec_user_data;
memset(user_data, 0, sizeof(internal_user_data));
/* Call a subroutine to process the input line. */
ret = 0;
SSHORT ret = 0;
if (!get_switches(argc, argv, gsec_in_sw_table, tdsec, &quitflag)) {
#ifdef SUPERSERVER
GSEC_error(GsecMsg16, NULL, NULL, NULL, NULL, NULL);
@ -1115,7 +1104,8 @@ static SSHORT parse_cmd_line( int argc, TEXT ** argv, TSEC tdsec)
}
else if (user_data->operation != DIS_OPER &&
user_data->operation != QUIT_OPER &&
!user_data->user_name_entered) {
!user_data->user_name_entered)
{
GSEC_error(GsecMsg18, NULL, NULL, NULL, NULL, NULL);
/* gsec - no user name specified */
ret = -1;
@ -1181,19 +1171,17 @@ static void util_output( const SCHAR* format, ...)
* Platform independent output routine.
*
**************************************/
va_list arglist;
UCHAR buf[1000];
int exit_code;
TSEC tdsec;
tdsec = GET_THREAD_DATA;
tsec* tdsec = GET_THREAD_DATA;
if (format[0] == '\0') {
exit_code =
tdsec->tsec_output_proc(tdsec->tsec_output_data,
exit_code = tdsec->tsec_output_proc(tdsec->tsec_output_data,
(UCHAR * )(""));
}
else {
UCHAR buf[1000];
va_list arglist;
VA_START(arglist, format);
vsprintf((char *) buf, format, arglist);
va_end(arglist);
@ -1205,11 +1193,11 @@ static void util_output( const SCHAR* format, ...)
}
void GSEC_error_redirect(const ISC_STATUS* status_vector,
USHORT errcode, TEXT * arg1, TEXT * arg2)
USHORT errcode, const TEXT* arg1, const TEXT* arg2)
{
/**************************************
*
* U T I L _ e r r o r _ r e d i r e c t
* G S E C _ e r r o r _ r e d i r e c t
*
**************************************
*
@ -1224,12 +1212,13 @@ void GSEC_error_redirect(const ISC_STATUS* status_vector,
void GSEC_error(
USHORT errcode,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2, const TEXT* arg3,
const TEXT* arg4, const TEXT* arg5)
{
/**************************************
*
* U T I L _ e r r o r
* G S E C _ e r r o r
*
**************************************
*
@ -1238,11 +1227,8 @@ void GSEC_error(
*
**************************************/
#ifdef SUPERSERVER
TSEC tdsec;
ISC_STATUS *status;
tdsec = GET_THREAD_DATA;
status = tdsec->tsec_service_blk->svc_status;
tsec* tdsec = GET_THREAD_DATA;
ISC_STATUS* status = tdsec->tsec_service_blk->svc_status;
CMD_UTIL_put_svc_status(status, GSEC_MSG_FAC, errcode,
isc_arg_string, arg1,
@ -1251,8 +1237,7 @@ void GSEC_error(
isc_arg_string, arg4, isc_arg_string, arg5);
SVC_STARTED(tdsec->tsec_service_blk);
#else
TSEC tdsec;
tdsec = GET_THREAD_DATA;
tsec* tdsec = GET_THREAD_DATA;
#endif
GSEC_print(errcode, arg1, arg2, arg3, arg4, arg5);
@ -1261,8 +1246,9 @@ void GSEC_error(
void GSEC_print(
USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2, const TEXT* arg3,
const TEXT* arg4, const TEXT* arg5)
{
/**************************************
*
@ -1284,8 +1270,9 @@ void GSEC_print(
void GSEC_print_partial(
USHORT number,
TEXT * arg1,
TEXT * arg2, TEXT * arg3, TEXT * arg4, TEXT * arg5)
const TEXT* arg1,
const TEXT* arg2, const TEXT* arg3,
const TEXT* arg4, const TEXT* arg5)
{
/**************************************
*

View File

@ -79,7 +79,7 @@
#define RESTORE_THREAD_DATA
#endif
typedef struct user_data {
struct internal_user_data {
int operation; /* what's to be done */
TEXT user_name [USER_NAME_LEN]; /* the user's name */
bool user_name_entered; /* user name entered flag */
@ -120,11 +120,11 @@ typedef struct user_data {
bool database_entered; /* database entered flag */
bool database_specified; /* database specified flag */
} *USER_DATA;
};
typedef struct tsec {
struct thdd tsec_thd_data;
struct user_data* tsec_user_data;
internal_user_data* tsec_user_data;
int tsec_exit_code;
jmp_buf* tsec_env;
ISC_STATUS* tsec_status;

View File

@ -7,10 +7,13 @@ int GSEC_main(SVC service);
// Output reporting utilities
void GSEC_print_status(const ISC_STATUS*);
void GSEC_error_redirect(const ISC_STATUS*, USHORT, TEXT *, TEXT *);
void GSEC_error(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
void GSEC_print(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
void GSEC_print_partial(USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
void GSEC_error_redirect(const ISC_STATUS*, USHORT, const TEXT*, const TEXT*);
void GSEC_error(USHORT, const TEXT*, const TEXT*, const TEXT*, const TEXT*,
const TEXT*);
void GSEC_print(USHORT, const TEXT*, const TEXT*, const TEXT*, const TEXT*,
const TEXT*);
void GSEC_print_partial(USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
#endif // GSEC_PROTO_H

View File

@ -1,7 +1,7 @@
/*
* PROGRAM: Security data base manager
* MODULE: secur_proto.h
* DESCRIPTION: Prototype header file for security.e
* DESCRIPTION: Prototype header file for security.epp
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
@ -24,9 +24,11 @@
#ifndef UTILITIES_SECUR_PROTO_H
#define UTILITIES_SECUR_PROTO_H
SSHORT SECURITY_exec_line (ISC_STATUS *, FRBRD *, struct user_data *,
void (*)(void *, USER_DATA, bool), void *);
void SECURITY_msg_get (USHORT, TEXT *);
void SECURITY_get_db_path (TEXT *, TEXT *);
typedef void (*FPTR_SECURITY_CALLBACK)(void*, const internal_user_data*, bool);
SSHORT SECURITY_exec_line (ISC_STATUS*, FRBRD*, internal_user_data*,
FPTR_SECURITY_CALLBACK, void*);
void SECURITY_msg_get (USHORT, TEXT*);
void SECURITY_get_db_path (const TEXT*, TEXT*);
#endif // UTILITIES_SECUR_PROTO_H

View File

@ -43,11 +43,11 @@ DATABASE DB = STATIC FILENAME "security.fdb";
#define SYSDBA_USER_NAME "SYSDBA"
SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
FRBRD *DB,
USER_DATA user_data,
void (*display_func) (void *, USER_DATA, bool),
void *callback_arg)
SSHORT SECURITY_exec_line(ISC_STATUS* isc_status,
FRBRD* DB,
internal_user_data* io_user_data,
FPTR_SECURITY_CALLBACK display_func,
void* callback_arg)
{
/*************************************
*
@ -117,7 +117,7 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
SSHORT ret = 0;
// check for non-printable characters in user name
for (const TEXT *p = user_data->user_name; *p; p++) {
for (const TEXT *p = io_user_data->user_name; *p; p++) {
if (! isprint(*p)) {
return GsecMsg75; // Add special error message for this case ?
}
@ -128,54 +128,54 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
return GsecMsg75; /* gsec error */
END_ERROR;
switch (user_data->operation) {
switch (io_user_data->operation) {
case ADD_OPER:
/* this checks the "entered" flags for each parameter (except the name)
and makes all non-entered parameters null valued */
STORE U IN USERS USING
strcpy(U.USER_NAME, user_data->user_name);
if (user_data->uid_entered) {
U.UID = user_data->uid;
strcpy(U.USER_NAME, io_user_data->user_name);
if (io_user_data->uid_entered) {
U.UID = io_user_data->uid;
U.UID.NULL = ISC_FALSE;
}
else
U.UID.NULL = ISC_TRUE;
if (user_data->gid_entered) {
U.GID = user_data->gid;
if (io_user_data->gid_entered) {
U.GID = io_user_data->gid;
U.GID.NULL = ISC_FALSE;
}
else
U.GID.NULL = ISC_TRUE;
if (user_data->group_name_entered) {
strcpy(U.GROUP_NAME, user_data->group_name);
if (io_user_data->group_name_entered) {
strcpy(U.GROUP_NAME, io_user_data->group_name);
U.GROUP_NAME.NULL = ISC_FALSE;
}
else
U.GROUP_NAME.NULL = ISC_TRUE;
if (user_data->password_entered) {
if (io_user_data->password_entered) {
strcpy(encrypted1,
ENC_crypt(user_data->password, PASSWORD_SALT));
ENC_crypt(io_user_data->password, PASSWORD_SALT));
strcpy(encrypted2, ENC_crypt(&encrypted1[2], PASSWORD_SALT));
strcpy(U.PASSWD, &encrypted2[2]);
U.PASSWD.NULL = ISC_FALSE;
}
else
U.PASSWD.NULL = ISC_TRUE;
if (user_data->first_name_entered) {
strcpy(U.FIRST_NAME, user_data->first_name);
if (io_user_data->first_name_entered) {
strcpy(U.FIRST_NAME, io_user_data->first_name);
U.FIRST_NAME.NULL = ISC_FALSE;
}
else
U.FIRST_NAME.NULL = ISC_TRUE;
if (user_data->middle_name_entered) {
strcpy(U.MIDDLE_NAME, user_data->middle_name);
if (io_user_data->middle_name_entered) {
strcpy(U.MIDDLE_NAME, io_user_data->middle_name);
U.MIDDLE_NAME.NULL = ISC_FALSE;
}
else
U.MIDDLE_NAME.NULL = ISC_TRUE;
if (user_data->last_name_entered) {
strcpy(U.LAST_NAME, user_data->last_name);
if (io_user_data->last_name_entered) {
strcpy(U.LAST_NAME, io_user_data->last_name);
U.LAST_NAME.NULL = ISC_FALSE;
}
else
@ -192,54 +192,54 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
changes the current value to the null value */
found = false;
FOR U IN USERS WITH U.USER_NAME EQ user_data->user_name
FOR U IN USERS WITH U.USER_NAME EQ io_user_data->user_name
found = true;
MODIFY U USING
if (user_data->uid_entered) {
U.UID = user_data->uid;
if (io_user_data->uid_entered) {
U.UID = io_user_data->uid;
U.UID.NULL = ISC_FALSE;
}
else if (user_data->uid_specified)
else if (io_user_data->uid_specified)
U.UID.NULL = ISC_TRUE;
if (user_data->gid_entered) {
U.GID = user_data->gid;
if (io_user_data->gid_entered) {
U.GID = io_user_data->gid;
U.GID.NULL = ISC_FALSE;
}
else if (user_data->gid_specified)
else if (io_user_data->gid_specified)
U.GID.NULL = ISC_TRUE;
if (user_data->group_name_entered) {
strcpy(U.GROUP_NAME, user_data->group_name);
if (io_user_data->group_name_entered) {
strcpy(U.GROUP_NAME, io_user_data->group_name);
U.GROUP_NAME.NULL = ISC_FALSE;
}
else if (user_data->group_name_specified)
else if (io_user_data->group_name_specified)
U.GROUP_NAME.NULL = ISC_TRUE;
if (user_data->password_entered) {
if (io_user_data->password_entered) {
strcpy(encrypted1,
ENC_crypt(user_data->password, PASSWORD_SALT));
ENC_crypt(io_user_data->password, PASSWORD_SALT));
strcpy(encrypted2,
ENC_crypt(&encrypted1[2], PASSWORD_SALT));
strcpy(U.PASSWD, &encrypted2[2]);
U.PASSWD.NULL = ISC_FALSE;
}
else if (user_data->password_specified)
else if (io_user_data->password_specified)
U.PASSWD.NULL = ISC_TRUE;
if (user_data->first_name_entered) {
strcpy(U.FIRST_NAME, user_data->first_name);
if (io_user_data->first_name_entered) {
strcpy(U.FIRST_NAME, io_user_data->first_name);
U.FIRST_NAME.NULL = ISC_FALSE;
}
else if (user_data->first_name_specified)
else if (io_user_data->first_name_specified)
U.FIRST_NAME.NULL = ISC_TRUE;
if (user_data->middle_name_entered) {
strcpy(U.MIDDLE_NAME, user_data->middle_name);
if (io_user_data->middle_name_entered) {
strcpy(U.MIDDLE_NAME, io_user_data->middle_name);
U.MIDDLE_NAME.NULL = ISC_FALSE;
}
else if (user_data->middle_name_specified)
else if (io_user_data->middle_name_specified)
U.MIDDLE_NAME.NULL = ISC_TRUE;
if (user_data->last_name_entered) {
strcpy(U.LAST_NAME, user_data->last_name);
if (io_user_data->last_name_entered) {
strcpy(U.LAST_NAME, io_user_data->last_name);
U.LAST_NAME.NULL = ISC_FALSE;
}
else if (user_data->last_name_specified)
else if (io_user_data->last_name_specified)
U.LAST_NAME.NULL = ISC_TRUE;
END_MODIFY
ON_ERROR
@ -259,17 +259,17 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
found = false;
/* Do not allow SYSDBA user to be deleted */
#ifdef HAVE_STRCASECMP
if (!strcasecmp(user_data->user_name, SYSDBA_USER_NAME))
if (!strcasecmp(io_user_data->user_name, SYSDBA_USER_NAME))
#else
#ifdef HAVE_STRICMP
if (!stricmp(user_data->user_name, SYSDBA_USER_NAME))
if (!stricmp(io_user_data->user_name, SYSDBA_USER_NAME))
#else
#error dont know how to compare strings case insensitive on this system
#endif /* HAVE_STRICMP */
#endif /* HAVE_STRCASECMP */
ret = GsecMsg23;
else {
FOR U IN USERS WITH U.USER_NAME EQ user_data->user_name
FOR U IN USERS WITH U.USER_NAME EQ io_user_data->user_name
found = true;
ERASE U
ON_ERROR
@ -289,18 +289,18 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
/* gets either the desired record, or all records, and displays them */
found = false;
if (!user_data->user_name_entered) {
if (!io_user_data->user_name_entered) {
FOR U IN USERS
user_data->uid = U.UID;
user_data->gid = U.GID;
*(user_data->sys_user_name) = '\0';
strcpy(user_data->user_name, U.USER_NAME);
strcpy(user_data->group_name, U.GROUP_NAME);
strcpy(user_data->password, U.PASSWD);
strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_NAME);
strcpy(user_data->last_name, U.LAST_NAME);
display_func(callback_arg, user_data, !found);
io_user_data->uid = U.UID;
io_user_data->gid = U.GID;
*(io_user_data->sys_user_name) = '\0';
strcpy(io_user_data->user_name, U.USER_NAME);
strcpy(io_user_data->group_name, U.GROUP_NAME);
strcpy(io_user_data->password, U.PASSWD);
strcpy(io_user_data->first_name, U.FIRST_NAME);
strcpy(io_user_data->middle_name, U.MIDDLE_NAME);
strcpy(io_user_data->last_name, U.LAST_NAME);
display_func(callback_arg, io_user_data, !found);
found = true;
END_FOR
@ -309,17 +309,17 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
END_ERROR;
}
else {
FOR U IN USERS WITH U.USER_NAME EQ user_data->user_name
user_data->uid = U.UID;
user_data->gid = U.GID;
*(user_data->sys_user_name) = '\0';
strcpy(user_data->user_name, U.USER_NAME);
strcpy(user_data->group_name, U.GROUP_NAME);
strcpy(user_data->password, U.PASSWD);
strcpy(user_data->first_name, U.FIRST_NAME);
strcpy(user_data->middle_name, U.MIDDLE_NAME);
strcpy(user_data->last_name, U.LAST_NAME);
display_func(callback_arg, user_data, !found);
FOR U IN USERS WITH U.USER_NAME EQ io_user_data->user_name
io_user_data->uid = U.UID;
io_user_data->gid = U.GID;
*(io_user_data->sys_user_name) = '\0';
strcpy(io_user_data->user_name, U.USER_NAME);
strcpy(io_user_data->group_name, U.GROUP_NAME);
strcpy(io_user_data->password, U.PASSWD);
strcpy(io_user_data->first_name, U.FIRST_NAME);
strcpy(io_user_data->middle_name, U.MIDDLE_NAME);
strcpy(io_user_data->last_name, U.LAST_NAME);
display_func(callback_arg, io_user_data, !found);
found = true;
END_FOR
@ -349,7 +349,7 @@ SSHORT SECURITY_exec_line(ISC_STATUS * isc_status,
return ret;
}
void SECURITY_get_db_path( TEXT * server, TEXT * buffer)
void SECURITY_get_db_path(const TEXT* server, TEXT* buffer)
{
/**************************************
*
@ -415,7 +415,7 @@ void SECURITY_get_db_path( TEXT * server, TEXT * buffer)
isc_service_detach(status, &svc_handle);
}
void SECURITY_msg_get( USHORT number, TEXT * msg)
void SECURITY_msg_get(USHORT number, TEXT* msg)
{
/**************************************
*