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

const correctness, bool, etc.

locksmith is harmless => root/administrator/sysdba, nothing mysterious.
This commit is contained in:
robocop 2003-09-09 11:07:19 +00:00
parent 50451feed9
commit 79e4522ffe
11 changed files with 489 additions and 627 deletions

View File

@ -42,7 +42,7 @@ extern "C" {
/* When converting non-text values to text, how many bytes to allocate
for holding the text image of the value. */
static USHORT const _DSC_convert_to_text_length[DTYPE_TYPE_MAX] =
static const USHORT _DSC_convert_to_text_length[DTYPE_TYPE_MAX] =
{
0, /* dtype_null */
0, /* dtype_text */
@ -764,7 +764,7 @@ void DLL_EXPORT DSC_make_descriptor(
USHORT blr_type,
SSHORT scale,
USHORT length,
SSHORT sub_type, SSHORT charset, SSHORT collation)
SSHORT sub_type, SSHORT charset, SSHORT collation)
{
/**************************************
*
@ -883,23 +883,23 @@ SSHORT sub_type, SSHORT charset, SSHORT collation)
}
int DLL_EXPORT DSC_string_length(DSC* desc)
int DLL_EXPORT DSC_string_length(const dsc* desc)
{
/**************************************
*
* D S C _ s t r i n g _ l e n g t h
*
**************************************
*
* Functional description
* Estimate length of string (in bytes) based on descriptor.
* Estimated length assumes representing string in
* narrow-char ASCII format.
*
* Note that this strips off the short at the
* start of dtype_varying, and the NULL for dtype_cstring.
*
**************************************/
/**************************************
*
* D S C _ s t r i n g _ l e n g t h
*
**************************************
*
* Functional description
* Estimate length of string (in bytes) based on descriptor.
* Estimated length assumes representing string in
* narrow-char ASCII format.
*
* Note that this strips off the short at the
* start of dtype_varying, and the NULL for dtype_cstring.
*
**************************************/
switch (desc->dsc_dtype) {
case dtype_text:
@ -925,16 +925,16 @@ int DLL_EXPORT DSC_string_length(DSC* desc)
const TEXT *DSC_dtype_tostring(UCHAR dtype)
{
/**************************************
*
* D S C _ d t y p e _ t o s t r i n g
*
**************************************
*
* Functional description
* Convert a datatype to its textual representation
*
**************************************/
/**************************************
*
* D S C _ d t y p e _ t o s t r i n g
*
**************************************
*
* Functional description
* Convert a datatype to its textual representation
*
**************************************/
if (dtype < FB_NELEM(DSC_dtype_names))
return DSC_dtype_names[dtype];
else
@ -942,19 +942,22 @@ const TEXT *DSC_dtype_tostring(UCHAR dtype)
}
void DLL_EXPORT DSC_get_dtype_name(DSC * desc, TEXT * buffer, USHORT len)
void DLL_EXPORT DSC_get_dtype_name(const dsc* desc, TEXT * buffer, USHORT len)
{
/**************************************
*
* D S C _ g e t _ d t y p e _ n a m e
*
**************************************
*
* Functional description
* Convert a datatype to its textual representation
*
**************************************/
/**************************************
*
* D S C _ g e t _ d t y p e _ n a m e
*
**************************************
*
* Functional description
* Convert a datatype to its textual representation
*
**************************************/
// This function didn't put a string terminator even though
// it's calling strncpy that doesn't put it if source > target.
strncpy(buffer, DSC_dtype_tostring(desc->dsc_dtype), len);
buffer[len - 1] = 0;
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _JRD_DSC_PROTO_H_
#define _JRD_DSC_PROTO_H_
#ifndef JRD_DSC_PROTO_H
#define JRD_DSC_PROTO_H
#include "../jrd/dsc.h"
@ -30,9 +30,9 @@
extern "C" {
#endif
extern int DLL_EXPORT DSC_string_length(struct dsc *);
extern int DLL_EXPORT DSC_string_length(const struct dsc*);
extern const TEXT *DSC_dtype_tostring(UCHAR);
extern void DLL_EXPORT DSC_get_dtype_name(struct dsc *, TEXT *, USHORT);
extern void DLL_EXPORT DSC_get_dtype_name(const struct dsc*, TEXT *, USHORT);
extern void DLL_EXPORT DSC_make_descriptor(struct dsc *, USHORT, SSHORT,
USHORT, SSHORT, SSHORT, SSHORT);
extern USHORT DLL_EXPORT DSC_convert_to_text_length(USHORT dsc_type);
@ -46,4 +46,5 @@ extern const BYTE DSC_multiply_blr4_result[DTYPE_TYPE_MAX][DTYPE_TYPE_MAX];
} /* extern "C" */
#endif
#endif /* _JRD_DSC_PROTO_H_ */
#endif /* JRD_DSC_PROTO_H */

View File

@ -82,12 +82,13 @@ DATABASE DB = STATIC "ODS.RDB";
static void grant(GBL, UCHAR **);
static bool grantor_can_grant_role(TDBB, GBL, TEXT *, TEXT *);
static bool grantor_can_grant(GBL, TEXT *, TEXT *, TEXT *, TEXT *, bool);
static bool grantor_can_grant_role(TDBB, GBL, const TEXT*, const TEXT*);
static bool grantor_can_grant(GBL, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, bool);
static void revoke_permission(GBL, UCHAR **);
static void store_privilege(GBL, TEXT *, TEXT *, TEXT *, TEXT *, SSHORT,
SSHORT, int);
static void set_field_class_name(GBL, TEXT *, TEXT *);
static void store_privilege(GBL, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, SSHORT, SSHORT, int);
static void set_field_class_name(GBL, const TEXT*, const TEXT*);
void DYN_ddl(ATT attachment, JRD_TRA transaction, USHORT length, UCHAR * ddl)
@ -193,11 +194,11 @@ void DYN_ddl(ATT attachment, JRD_TRA transaction, USHORT length, UCHAR * ddl)
void DYN_error(USHORT status_flag,
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)
{
/**************************************
*
@ -209,12 +210,7 @@ void DYN_error(USHORT status_flag,
* DDL failed.
*
**************************************/
TDBB tdbb;
ISC_STATUS_ARRAY local_status;
ISC_STATUS *v1, *v2, *end, arg;
tdbb = GET_THREAD_DATA;
TDBB tdbb = GET_THREAD_DATA;
if (tdbb->tdbb_status_vector[1] == gds_no_meta_update)
return;
@ -226,7 +222,8 @@ void DYN_error(USHORT status_flag,
sizeof(TEXT) * BUFFER_MEDIUM, error_buffer, arg1,
arg2, arg3, arg4, arg5);
v1 = local_status;
ISC_STATUS_ARRAY local_status;
ISC_STATUS* v1 = local_status;
*v1++ = gds_arg_gds;
*v1++ = gds_no_meta_update;
@ -237,11 +234,12 @@ void DYN_error(USHORT status_flag,
*v1++ = (ISC_STATUS) ERR_cstring(error_buffer);
}
if (status_flag) {
v2 = tdbb->tdbb_status_vector;
ISC_STATUS* v2 = tdbb->tdbb_status_vector;
/* check every other argument for end of vector */
end = local_status + sizeof(local_status) - 1;
ISC_STATUS arg;
ISC_STATUS* const end = local_status + sizeof(local_status) - 1;
while (v1 < end &&
((arg = *v2++) != gds_arg_cstring || v1 + 1 < end) &&
(*v1++ = arg)) {
@ -251,20 +249,21 @@ void DYN_error(USHORT status_flag,
}
}
*v1 = gds_arg_end;
end = v1 + 1;
ISC_STATUS* const end = v1 + 1;
for (v1 = local_status, v2 = tdbb->tdbb_status_vector; v1 < end;)
*v2++ = *v1++;
ISC_STATUS* dest;
for (v1 = local_status, dest = tdbb->tdbb_status_vector; v1 < end;)
*dest++ = *v1++;
}
void DYN_error_punt(USHORT status_flag,
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)
{
/**************************************
*
@ -282,8 +281,8 @@ void DYN_error_punt(USHORT status_flag,
}
BOOLEAN DYN_is_it_sql_role(GBL gbl,
TEXT* input_name,
bool DYN_is_it_sql_role(GBL gbl,
const TEXT* input_name,
TEXT* output_name,
TDBB tdbb)
{
@ -295,26 +294,21 @@ BOOLEAN DYN_is_it_sql_role(GBL gbl,
*
* Functional description
*
* If input_name is found in RDB$ROLES, then returns TRUE. Otherwise
* returns FALSE.
* If input_name is found in RDB$ROLES, then returns true. Otherwise
* returns false.
*
**************************************/
DBB dbb;
BLK request;
BOOLEAN found;
USHORT major_version, minor_original;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
major_version = (SSHORT) dbb->dbb_ods_version;
minor_original = (SSHORT) dbb->dbb_minor_original;
found = FALSE;
USHORT major_version = dbb->dbb_ods_version;
USHORT minor_original = dbb->dbb_minor_original;
bool found = false;
if (ENCODE_ODS(major_version, minor_original) < ODS_9_0)
return found;
request = (BLK) CMP_find_request(tdbb, drq_get_role_nm, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_get_role_nm, DYN_REQUESTS);
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
X IN RDB$ROLES WITH
@ -322,7 +316,7 @@ BOOLEAN DYN_is_it_sql_role(GBL gbl,
if (!DYN_REQUEST(drq_get_role_nm))
DYN_REQUEST(drq_get_role_nm) = request;
found = TRUE;
found = true;
DYN_terminate(X.RDB$OWNER_NAME, sizeof(X.RDB$OWNER_NAME));
strcpy(output_name, X.RDB$OWNER_NAME);
@ -641,14 +635,13 @@ USHORT DYN_get_string(TEXT ** ptr, TEXT * field, USHORT size, USHORT err_flag)
* Strings need enough space for null pad.
*
**************************************/
TEXT *p;
USHORT l, e, length;
e = 0;
p = *ptr;
length = (UCHAR) * p++;
USHORT e = 0;
TEXT* p = *ptr;
USHORT length = (UCHAR) *p++;
length |= ((USHORT) ((UCHAR) (*p++))) << 8;
if ( (l = length) ) {
USHORT l = length;
if (l) {
if (length >= size) {
if (err_flag)
DYN_error_punt(FALSE, 159, NULL, NULL, NULL, NULL, NULL);
@ -683,15 +676,10 @@ USHORT DYN_put_blr_blob(GBL gbl, UCHAR** ptr, GDS__QUAD* blob_id)
* Write out a blr blob.
*
**************************************/
TDBB tdbb;
BLB blob;
USHORT length;
UCHAR* p;
TDBB tdbb = GET_THREAD_DATA;
tdbb = GET_THREAD_DATA;
p = *ptr;
length = *p++;
UCHAR *p = *ptr;
USHORT length = *p++;
length |= (*p++) << 8;
if (!length) {
@ -700,7 +688,7 @@ USHORT DYN_put_blr_blob(GBL gbl, UCHAR** ptr, GDS__QUAD* blob_id)
}
try {
blob = BLB_create(tdbb, gbl->gbl_transaction, (BID)blob_id);
BLB blob = BLB_create(tdbb, gbl->gbl_transaction, (BID)blob_id);
BLB_put_segment(tdbb, blob, p, length);
BLB_close(tdbb, blob);
}
@ -726,24 +714,22 @@ USHORT DYN_put_text_blob(GBL gbl, UCHAR ** ptr, GDS__QUAD * blob_id)
* Write out a text blob.
*
**************************************/
TDBB tdbb;
USHORT length;
UCHAR *p, *end;
BLB blob;
TDBB tdbb = GET_THREAD_DATA;
tdbb = GET_THREAD_DATA;
p = *ptr;
length = *p++;
UCHAR* p = *ptr;
USHORT length = *p++;
length |= (*p++) << 8;
if (!length) {
*ptr = p;
return length;
}
// make the code die at some place if DYN_error_punt doesn't jump far away.
UCHAR *end = NULL;
try {
blob = BLB_create(tdbb, gbl->gbl_transaction, (BID)blob_id);
BLB blob = BLB_create(tdbb, gbl->gbl_transaction, (BID)blob_id);
for (end = p + length; p < end; p += TEXT_BLOB_LENGTH)
{
@ -805,11 +791,8 @@ USHORT DYN_skip_attribute(UCHAR ** ptr)
* size of count bytes).
*
**************************************/
UCHAR *p;
USHORT length;
p = *ptr;
length = *p++;
UCHAR* p = *ptr;
USHORT length = *p++;
length |= (*p++) << 8;
*ptr = p + length;
@ -830,10 +813,8 @@ void DYN_terminate( TEXT * string, int length)
* terminated with a NULL.
*
**************************************/
TEXT *p, *q;
q = string - 1;
for (p = string; *p && --length; p++) {
TEXT* q = string - 1;
for (TEXT* p = string; *p && --length; p++) {
if (*p != BLANK)
q = p;
}
@ -855,8 +836,6 @@ static void grant( GBL gbl, UCHAR ** ptr)
*
**************************************/
BLK request;
//volatile SSHORT err_num;
volatile SSHORT id;
TEXT privileges[16];
TEXT object[32];
@ -872,8 +851,8 @@ static void grant( GBL gbl, UCHAR ** ptr)
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
USHORT major_version = (SSHORT) dbb->dbb_ods_version;
USHORT minor_original = (SSHORT) dbb->dbb_minor_original;
USHORT major_version = dbb->dbb_ods_version;
USHORT minor_original = dbb->dbb_minor_original;
GET_STRING(ptr, privileges);
if (!strcmp(privileges, "A")) {
@ -994,6 +973,7 @@ static void grant( GBL gbl, UCHAR ** ptr)
}
}
BLK request = NULL;
try {
@ -1177,10 +1157,10 @@ do_punt: // ugly, rethink logic of this function
static bool grantor_can_grant( GBL gbl,
TEXT* grantor,
TEXT* privilege,
TEXT* relation_name,
TEXT* field_name,
const TEXT* grantor,
const TEXT* privilege,
const TEXT* relation_name,
const TEXT* field_name,
bool top_level)
{
/**************************************
@ -1194,40 +1174,28 @@ static bool grantor_can_grant( GBL gbl,
* FALSE otherwise.
*
**************************************/
TDBB tdbb;
DBB dbb;
/* Remember the grant option for non field-specific user-privileges, and the
grant option for the user-privileges for the input field.
-1 = no privilege found (yet)
0 = privilege without grant option found
1 = privilege with grant option found */
SSHORT go_rel = -1;
SSHORT go_fld = -1;
BLK request;
BOOLEAN sql_relation = FALSE;
BOOLEAN relation_exists = FALSE;
BOOLEAN field_exists = FALSE;
BOOLEAN grantor_is_owner = FALSE;
volatile USHORT err_num;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
/* Verify that the input relation exists. */
request = (BLK) CMP_find_request(tdbb, drq_gcg4, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_gcg4, DYN_REQUESTS);
try {
err_num = 182; /* for the longjump */
bool sql_relation = false;
bool relation_exists = false;
/* SELECT RDB$RELATIONS failed in grant */
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
REL IN RDB$RELATIONS WITH
REL.RDB$RELATION_NAME = relation_name relation_exists = TRUE;
REL.RDB$RELATION_NAME = relation_name
relation_exists = true;
if ((!REL.RDB$FLAGS.NULL) && (REL.RDB$FLAGS & REL_sql))
sql_relation = TRUE;
sql_relation = true;
if (!DYN_REQUEST(drq_gcg4))
DYN_REQUEST(drq_gcg4) = request;
END_FOR;
@ -1244,6 +1212,8 @@ static bool grantor_can_grant( GBL gbl,
if (field_name[0])
{
err_num = 183;
bool field_exists = false;
/* SELECT RDB$RELATION_FIELDS failed in grant */
request = (BLK) CMP_find_request(tdbb, drq_gcg5, DYN_REQUESTS);
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
@ -1251,7 +1221,7 @@ static bool grantor_can_grant( GBL gbl,
G_FLD.RDB$RELATION_NAME = relation_name AND
G_FLD.RDB$FIELD_NAME = field_name if (!DYN_REQUEST(drq_gcg5))
DYN_REQUEST(drq_gcg5) = request;
field_exists = TRUE;
field_exists = true;
END_FOR;
if (!DYN_REQUEST(drq_gcg5))
DYN_REQUEST(drq_gcg5) = request;
@ -1273,6 +1243,7 @@ static bool grantor_can_grant( GBL gbl,
entries in the rdb$user_privileges table. Give the owner of a GDML
table all privileges. */
err_num = 184;
bool grantor_is_owner = false;
/* SELECT RDB$RELATIONS/RDB$OWNER_NAME failed in grant */
request = (BLK) CMP_find_request(tdbb, drq_gcg2, DYN_REQUESTS);
@ -1282,7 +1253,7 @@ static bool grantor_can_grant( GBL gbl,
REL.RDB$OWNER_NAME = UPPERCASE(grantor)
if (!DYN_REQUEST(drq_gcg2))
DYN_REQUEST(drq_gcg2) = request;
grantor_is_owner = TRUE;
grantor_is_owner = true;
END_FOR;
if (!DYN_REQUEST(drq_gcg2))
DYN_REQUEST(drq_gcg2) = request;
@ -1290,6 +1261,15 @@ static bool grantor_can_grant( GBL gbl,
return true;
}
// Remember the grant option for non field-specific user-privileges, and
// the grant option for the user-privileges for the input field.
// -1 = no privilege found (yet)
// 0 = privilege without grant option found
// 1 = privilege with grant option found
SSHORT go_rel = -1;
SSHORT go_fld = -1;
/* Verify that the grantor has the grant option for this relation/field
in the rdb$user_privileges. If not, then we don't need to look further. */
@ -1460,8 +1440,8 @@ static bool grantor_can_grant( GBL gbl,
static bool grantor_can_grant_role( TDBB tdbb,
GBL gbl,
TEXT* grantor,
TEXT* role_name)
const TEXT* grantor,
const TEXT* role_name)
{
/**************************************
*
@ -1574,47 +1554,38 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
* 1994-August-2 Rich Damon & David Schnepper
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
//BLK old_request;
volatile USHORT old_id, id;
UCHAR verb;
SSHORT user_type, obj_type;
TEXT privileges[16], object[32], field[32], user[32], *p, *q, temp[2];
USHORT all_privs = FALSE;
int options;
USHORT grant_erased;
USR revoking_user;
TEXT privileges[16], object[32], field[32], user[32], temp[2];
TEXT revoking_user_name[32], dummy_name[32];
//TEXT grantor[32], *ptr2;
TEXT *ptr1;
USHORT major_version, minor_original;
TEXT *ptr1;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
major_version = (SSHORT) dbb->dbb_ods_version;
minor_original = (SSHORT) dbb->dbb_minor_original;
USHORT major_version = dbb->dbb_ods_version;
USHORT minor_original = dbb->dbb_minor_original;
/* Stash away a copy of the revoker's name, in uppercase form */
revoking_user = tdbb->tdbb_attachment->att_user;
for (p = revoking_user->usr_user_name, q = revoking_user_name; *p;
p++, q++)
const usr* revoking_user = tdbb->tdbb_attachment->att_user;
TEXT* q = revoking_user_name;
for (const TEXT* p = revoking_user->usr_user_name; *p; p++, q++)
*q = UPPER7(*p);
*q = 0;
GET_STRING(ptr, privileges);
if (!strcmp(privileges, "A")) {
strcpy(privileges, ALL_PRIVILEGES);
all_privs = TRUE;
}
object[0] = field[0] = user[0] = 0;
obj_type = user_type = -1;
options = 0;
int options = 0;
SSHORT user_type = -1;
SSHORT obj_type = -1;
while ((verb = *(*ptr)++) != gds_dyn_end)
switch (verb) {
@ -1718,7 +1689,7 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
DYN_unsupported_verb();
}
request = (BLK)CMP_find_request(tdbb,
BLK request = (BLK)CMP_find_request(tdbb,
(USHORT)(field[0] ? drq_e_grant1 : drq_e_grant2),
DYN_REQUESTS);
id = field[0] ? drq_e_grant1 : drq_e_grant2;
@ -1726,9 +1697,9 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
try {
temp[1] = 0;
for (p = privileges; (temp[0] = *p); p++)
for (const TEXT* pr = privileges; (temp[0] = *pr); pr++)
{
grant_erased = FALSE;
bool grant_erased = false;
if (field[0])
{
@ -1748,7 +1719,7 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
(!strcmp(PRIV.RDB$GRANTOR, revoking_user_name)))
{
ERASE PRIV;
grant_erased = TRUE;
grant_erased = true;
};
END_FOR;
@ -1778,7 +1749,7 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
if ((revoking_user->usr_flags & USR_locksmith) ||
(!strcmp(PRIV.RDB$GRANTOR, revoking_user_name))) {
ERASE PRIV;
grant_erased = TRUE;
grant_erased = true;
}
END_FOR;
if (!DYN_REQUEST(drq_e_grant2))
@ -1829,7 +1800,7 @@ static void revoke_permission(GBL gbl, UCHAR ** ptr)
}
static void set_field_class_name(GBL gbl, TEXT * relation, TEXT * field)
static void set_field_class_name(GBL gbl, const TEXT* relation, const TEXT* field)
{
/**************************************
*
@ -1842,17 +1813,13 @@ static void set_field_class_name(GBL gbl, TEXT * relation, TEXT * field)
* field has a unique class name.
*
**************************************/
BLK request, request2 = NULL;
BOOLEAN unique = FALSE;
TDBB tdbb;
DBB dbb;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_s_f_class, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_s_f_class, DYN_REQUESTS);
BLK request2 = NULL;
bool unique = false;
FOR (REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
RFR IN RDB$RELATION_FIELDS
@ -1867,12 +1834,12 @@ static void set_field_class_name(GBL gbl, TEXT * relation, TEXT * field)
DPM_gen_id(tdbb,
MET_lookup_generator(tdbb, "RDB$SECURITY_CLASS"), 0, (SINT64) 1));
unique = TRUE;
unique = true;
request2 = (BLK) CMP_find_request(tdbb, drq_s_u_class, DYN_REQUESTS);
FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction)
RFR1 IN RDB$RELATION_FIELDS
WITH RFR1.RDB$SECURITY_CLASS = RFR.RDB$SECURITY_CLASS
unique = FALSE;
unique = false;
END_FOR;
}
@ -1891,10 +1858,10 @@ static void set_field_class_name(GBL gbl, TEXT * relation, TEXT * field)
static void store_privilege(GBL gbl,
TEXT* object,
TEXT* user,
TEXT* field,
TEXT* privilege,
const TEXT* object,
const TEXT* user,
const TEXT* field,
const TEXT* privilege,
SSHORT user_type,
SSHORT obj_type,
int option)
@ -1910,14 +1877,10 @@ static void store_privilege(GBL gbl,
* routine should not.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_s_grant, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_s_grant, DYN_REQUESTS);
/* need to unwind our own request here!! SM 27-Sep-96 */
@ -1949,3 +1912,4 @@ static void store_privilege(GBL gbl,
/* msg 79: "STORE RDB$USER_PRIVILEGES failed in grant" */
}
}

View File

@ -21,8 +21,8 @@
* Contributor(s): ______________________________________.
*/
#ifndef _JRD_DYN_H_
#define _JRD_DYN_H_
#ifndef JRD_DYN_H
#define JRD_DYN_H
#define ALL_PRIVILEGES "SIUDR"
/* all applicable grant/revoke privileges */
@ -69,15 +69,17 @@ typedef struct dyn_fld {
} *DYN_FLD;
extern void DYN_error(USHORT, USHORT, TEXT *, TEXT *, TEXT *, TEXT *, TEXT *);
extern void DYN_error_punt(USHORT, USHORT, TEXT *, TEXT *, TEXT *, TEXT *,
TEXT *);
extern void DYN_error(USHORT, USHORT, const TEXT*, const TEXT*, const TEXT*,
const TEXT*, const TEXT*);
extern void DYN_error_punt(USHORT, USHORT, const TEXT*, const TEXT*,
const TEXT*, const TEXT*, const TEXT*);
extern void DYN_execute(GBL, UCHAR **, TEXT *, TEXT *, TEXT *, TEXT *,
TEXT *);
extern SLONG DYN_get_number(UCHAR **);
extern USHORT DYN_get_string(TEXT **, TEXT *, USHORT, USHORT);
extern void DYN_get_string2(TEXT **, TEXT *, USHORT);
extern BOOLEAN DYN_is_it_sql_role(GBL, TEXT *, TEXT *, TDBB);
// This function doesn't need to be exported currently.
extern bool DYN_is_it_sql_role(GBL, const TEXT*, TEXT*, TDBB);
extern USHORT DYN_put_blr_blob(GBL, UCHAR **, GDS__QUAD *);
extern USHORT DYN_put_blr_blob2(GBL, UCHAR **, GDS__QUAD *);
extern USHORT DYN_put_text_blob(GBL, UCHAR **, GDS__QUAD *);
@ -87,4 +89,5 @@ extern USHORT DYN_skip_attribute(UCHAR **);
extern USHORT DYN_skip_attribute2(UCHAR **);
extern void DYN_unsupported_verb(void);
#endif /* _JRD_DYN_H_ */
#endif /* JRD_DYN_H */

View File

@ -115,10 +115,10 @@ static const UCHAR who_blr[] =
};
static void check_unique_name(TDBB, GBL, TEXT *, BOOLEAN);
static BOOLEAN find_field_source(TDBB, GBL, TEXT *, USHORT, TEXT *, TEXT *);
static BOOLEAN get_who(TDBB, GBL, SCHAR *);
static BOOLEAN is_it_user_name(GBL, TEXT *, TDBB);
static void check_unique_name(TDBB, GBL, const TEXT*, bool);
static bool find_field_source(TDBB, GBL, const TEXT*, USHORT, const TEXT*, TEXT*);
static bool get_who(TDBB, GBL, SCHAR *);
static bool is_it_user_name(GBL, const TEXT*, TDBB);
@ -146,15 +146,13 @@ void DYN_define_cache( GBL gbl, UCHAR ** ptr)
* Define a database cache file.
*
**************************************/
TDBB tdbb;
DBB dbb;
UCHAR verb;
volatile BLK request;
USHORT found = FALSE;
volatile SSHORT id;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
try {
@ -249,10 +247,7 @@ void DYN_define_constraint(GBL gbl,
* constraint, also an index for the constraint.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
BLK old_request;
volatile SSHORT id, old_id;
UCHAR verb;
TEXT constraint_name[32], index_name[32], referred_index_name[32];
@ -263,8 +258,8 @@ void DYN_define_constraint(GBL gbl,
USHORT found, primary_flag = FALSE, foreign_flag = FALSE, not_null;
UCHAR ri_action = 0;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
constraint_name[0] = 0;
GET_STRING(ptr, constraint_name);
@ -530,6 +525,8 @@ void DYN_define_constraint(GBL gbl,
request = (BLK) CMP_find_request(tdbb, drq_s_ref_con, DYN_REQUESTS);
id = drq_s_ref_con;
BLK old_request = NULL;
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
REF IN RDB$REF_CONSTRAINTS
@ -803,8 +800,6 @@ void DYN_define_file(GBL gbl,
* Define a database or shadow file.
*
**************************************/
TDBB tdbb;
DBB dbb;
UCHAR verb;
volatile BLK request;
SLONG temp;
@ -812,8 +807,8 @@ void DYN_define_file(GBL gbl,
TEXT temp_f1[MAXPATHLEN], temp_f[MAXPATHLEN];
volatile SSHORT id;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
@ -913,14 +908,12 @@ void DYN_define_difference(GBL gbl,
* Define backup difference file.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
USHORT found = FALSE;
volatile SSHORT id;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
try {
@ -1191,13 +1184,11 @@ void DYN_define_function_arg(GBL gbl, UCHAR** ptr, TEXT* function_name)
* Define a user defined function argument.
*
**************************************/
TDBB tdbb;
DBB dbb;
UCHAR verb;
volatile BLK request = NULL;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
try {
@ -1637,7 +1628,6 @@ void DYN_define_index(GBL gbl,
**************************************/
volatile BLK request;
BLK old_request;
volatile SSHORT id, old_id;
const size_t field_name_size = 32;
TEXT index_name[32];
@ -1682,6 +1672,8 @@ void DYN_define_index(GBL gbl,
referenced_relation[0] = 0;
key_length = 0;
BLK old_request = NULL;
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
IDX IN RDB$INDICES
IDX.RDB$UNIQUE_FLAG.NULL = TRUE;
@ -2196,10 +2188,7 @@ void DYN_define_local_field(GBL gbl,
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
BLK old_request;
volatile SSHORT id, old_id;
UCHAR verb, *blr;
TEXT local_field_name[32];
@ -2211,8 +2200,8 @@ void DYN_define_local_field(GBL gbl,
TEXT *source;
SLONG fld_pos;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
local_field_name[0] = 0;
GET_STRING(ptr, local_field_name);
@ -2414,7 +2403,7 @@ void DYN_define_local_field(GBL gbl,
}
if (blr) {
old_request = request;
BLK old_request = request;
old_id = id;
request =
(BLK) CMP_find_request(tdbb, drq_s_gfields2, DYN_REQUESTS);
@ -2519,16 +2508,14 @@ void DYN_define_log_file(
* Define a database or shadow file.
*
**************************************/
TDBB tdbb;
DBB dbb;
UCHAR verb;
volatile BLK request;
USHORT found = FALSE;
volatile SSHORT id;
STR db_filename;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
id = -1;
@ -2649,8 +2636,6 @@ void DYN_define_parameter( GBL gbl, UCHAR ** ptr, TEXT * procedure_name)
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
UCHAR verb;
TEXT parameter_name[32];
volatile BLK request;
@ -2662,8 +2647,8 @@ void DYN_define_parameter( GBL gbl, UCHAR ** ptr, TEXT * procedure_name)
SSHORT f_subtype, f_scale, f_precision;
SSHORT f_charset, f_collation;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
parameter_name[0] = 0;
GET_STRING(ptr, parameter_name);
@ -2879,16 +2864,14 @@ void DYN_define_procedure( GBL gbl, UCHAR ** ptr)
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
UCHAR verb;
USHORT sql_prot;
volatile SSHORT id;
TEXT procedure_name[PROC_NAME_SIZE], owner_name[32], *p;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
procedure_name[0] = 0;
GET_STRING(ptr, procedure_name);
@ -2905,7 +2888,7 @@ void DYN_define_procedure( GBL gbl, UCHAR ** ptr)
try {
id = drq_l_prc_name;
check_unique_name(tdbb, gbl, procedure_name, TRUE);
check_unique_name(tdbb, gbl, procedure_name, true);
request = (BLK) CMP_find_request(tdbb, drq_s_prcs, DYN_REQUESTS);
id = drq_s_prcs;
@ -2975,7 +2958,7 @@ void DYN_define_procedure( GBL gbl, UCHAR ** ptr)
DYN_REQUEST(drq_s_prcs) = request;
if (sql_prot) {
if (get_who(tdbb, gbl, owner_name))
if (!get_who(tdbb, gbl, owner_name))
DYN_error_punt(TRUE, 134, NULL, NULL, NULL, NULL, NULL);
/* msg 134: "STORE RDB$PROCEDURES failed" */
@ -3039,18 +3022,15 @@ void DYN_define_relation( GBL gbl, UCHAR ** ptr)
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
BLK old_request;
UCHAR verb;
USHORT sql_prot, is_a_view, priv;
volatile SSHORT id, old_id;
ISC_STATUS *s;
TEXT relation_name[32], owner_name[32], field_name[32], *p;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
sql_prot = is_a_view = FALSE;
@ -3070,7 +3050,7 @@ void DYN_define_relation( GBL gbl, UCHAR ** ptr)
try {
id = drq_l_rel_name;
check_unique_name(tdbb, gbl, relation_name, FALSE);
check_unique_name(tdbb, gbl, relation_name, false);
request = (BLK) CMP_find_request(tdbb, drq_s_rels, DYN_REQUESTS);
id = drq_s_rels;
@ -3148,12 +3128,12 @@ void DYN_define_relation( GBL gbl, UCHAR ** ptr)
}
if (sql_prot) {
if (get_who(tdbb, gbl, owner_name))
if (!get_who(tdbb, gbl, owner_name))
DYN_error_punt(TRUE, 115, NULL, NULL, NULL, NULL, NULL);
/* msg 115: "CREATE VIEW failed" */
if (is_a_view) {
old_request = request;
BLK old_request = request;
old_id = id;
request =
(BLK) CMP_find_request(tdbb, drq_l_view_rels,
@ -3271,13 +3251,11 @@ void DYN_define_role( GBL gbl, UCHAR ** ptr)
* ROLES cannot be named the same as any existing user name
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request = NULL;
TEXT dummy_name[32], owner_name[32], role_name[32], *p;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
if (private_getODS() < ODS_9_0)
{
@ -3456,18 +3434,15 @@ void DYN_define_sql_field(GBL gbl,
* an global field name.
*
**************************************/
TDBB tdbb;
DBB dbb;
volatile BLK request;
BLK old_request;
volatile SSHORT id, old_id;
UCHAR verb;
TEXT sql_field_name[32];
USHORT dtype;
SLONG fld_pos;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
sql_field_name[0] = 0;
GET_STRING(ptr, sql_field_name);
@ -3484,6 +3459,7 @@ void DYN_define_sql_field(GBL gbl,
request = (BLK) CMP_find_request(tdbb, drq_s_sql_lfld, DYN_REQUESTS);
id = drq_s_sql_lfld;
BLK old_request = NULL;
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
RFR IN RDB$RELATION_FIELDS
@ -4158,8 +4134,8 @@ void DYN_define_view_relation( GBL gbl, UCHAR ** ptr, TEXT * view)
static void check_unique_name( TDBB tdbb,
GBL gbl,
TEXT* object_name,
BOOLEAN proc_flag)
const TEXT* object_name,
bool proc_flag)
{
/**************************************
*
@ -4234,12 +4210,12 @@ local_punt_false_132:
}
static BOOLEAN find_field_source(TDBB tdbb,
static bool find_field_source(TDBB tdbb,
GBL gbl,
TEXT* view_name,
const TEXT* view_name,
USHORT context,
TEXT* local_name,
TEXT* field_name)
const TEXT* local_name,
TEXT* output_field_name)
{
/**************************************
*
@ -4253,7 +4229,6 @@ static BOOLEAN find_field_source(TDBB tdbb,
**************************************/
volatile BLK request;
BOOLEAN found;
SET_TDBB(tdbb);
DBB dbb = tdbb->tdbb_database;
@ -4267,8 +4242,9 @@ circumstances, it will return either TRUE or FALSE. When TRUE, we found a field
for the view's name/context/field and are loading this value in the last parameter,
that can be used against rdb$fields' rdb$field_name. */
bool found = false;
try {
found = FALSE;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
VRL IN RDB$VIEW_RELATIONS CROSS
RFR IN RDB$RELATION_FIELDS OVER RDB$RELATION_NAME
@ -4280,9 +4256,9 @@ that can be used against rdb$fields' rdb$field_name. */
DYN_REQUEST(drq_l_fld_src2) = request;
}
found = TRUE;
found = true;
DYN_terminate(RFR.RDB$FIELD_SOURCE, sizeof(RFR.RDB$FIELD_SOURCE));
strcpy(field_name, RFR.RDB$FIELD_SOURCE);
strcpy(output_field_name, RFR.RDB$FIELD_SOURCE);
END_FOR;
if (!DYN_REQUEST(drq_l_fld_src2)) {
DYN_REQUEST(drq_l_fld_src2) = request;
@ -4298,7 +4274,7 @@ that can be used against rdb$fields' rdb$field_name. */
}
static BOOLEAN get_who( TDBB tdbb, GBL gbl, SCHAR * name)
static bool get_who( TDBB tdbb, GBL gbl, SCHAR* output_name)
{
/**************************************
*
@ -4322,20 +4298,20 @@ static BOOLEAN get_who( TDBB tdbb, GBL gbl, SCHAR * name)
request = (BLK) CMP_compile2(tdbb, const_cast<UCHAR*>(who_blr), TRUE);
}
EXE_start(tdbb, (JRD_REQ) request, gbl->gbl_transaction);
EXE_receive(tdbb, (JRD_REQ) request, 0, 32, (UCHAR*)name);
EXE_receive(tdbb, (JRD_REQ) request, 0, 32, (UCHAR*) output_name);
DYN_rundown_request(request, drq_l_user_name);
}
catch (const std::exception&) {
DYN_rundown_request(request, drq_l_user_name);
return FB_FAILURE;
return false;
}
return FB_SUCCESS;
return true;
}
BOOLEAN is_it_user_name(GBL gbl, TEXT* role_name, TDBB tdbb)
bool is_it_user_name(GBL gbl, const TEXT* role_name, TDBB tdbb)
{
/**************************************
*
@ -4350,11 +4326,11 @@ BOOLEAN is_it_user_name(GBL gbl, TEXT* role_name, TDBB tdbb)
**************************************/
volatile BLK request;
BOOLEAN found = FALSE;
volatile USHORT request_id;
SET_TDBB(tdbb);
DBB dbb = tdbb->tdbb_database;
bool found = false;
try {
@ -4370,7 +4346,7 @@ BOOLEAN is_it_user_name(GBL gbl, TEXT* role_name, TDBB tdbb)
(PRIV.RDB$GRANTOR EQ role_name AND
PRIV.RDB$OBJECT_TYPE = obj_relation)
found = TRUE;
found = true;
END_FOR;
@ -4391,7 +4367,7 @@ BOOLEAN is_it_user_name(GBL gbl, TEXT* role_name, TDBB tdbb)
REL IN RDB$RELATIONS WITH
REL.RDB$OWNER_NAME EQ role_name
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_get_rel_owner)) {
@ -4407,3 +4383,4 @@ BOOLEAN is_it_user_name(GBL gbl, TEXT* role_name, TDBB tdbb)
return found;
}

View File

@ -156,18 +156,15 @@ void DYN_delete_exception( GBL gbl, UCHAR ** ptr)
* deletes an exception.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
TEXT t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
GET_STRING(ptr, t);
request = (BLK) CMP_find_request(tdbb, drq_e_xcp, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_xcp, DYN_REQUESTS);
try {
@ -211,16 +208,13 @@ void DYN_delete_filter( GBL gbl, UCHAR ** ptr)
* deletes a blob filter.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
TEXT f[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_filters, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_filters, DYN_REQUESTS);
try {
@ -268,16 +262,13 @@ void DYN_delete_function( GBL gbl, UCHAR ** ptr)
* deletes a user defined function.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
volatile USHORT id, found;
TEXT f[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_func_args, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_func_args, DYN_REQUESTS);
id = drq_e_func_args;
try {
@ -348,15 +339,14 @@ void DYN_delete_generator(GBL gbl, UCHAR **ptr)
* space allocated in the page won't be released.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
TEXT t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
BLK request = NULL;
try {
GET_STRING(ptr, t);
@ -405,16 +395,13 @@ void DYN_delete_global_field( GBL gbl, UCHAR ** ptr)
* deletes a global field.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
volatile USHORT id, found;
TEXT f[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_l_fld_src, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_l_fld_src, DYN_REQUESTS);
id = drq_l_fld_src;
try {
@ -491,16 +478,13 @@ void DYN_delete_index( GBL gbl, UCHAR ** ptr)
* deletes an index.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
TEXT i[32], r[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_indices, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_indices, DYN_REQUESTS);
try {
GET_STRING(ptr, i);
@ -583,14 +567,11 @@ void DYN_delete_local_field(
* delete_f_key_constraint function for detail.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request, old_request;
volatile USHORT id, found;
TEXT tbl_nm[32], col_nm[32], constraint[32], index_name[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
GET_STRING(ptr, col_nm);
@ -603,7 +584,7 @@ void DYN_delete_local_field(
else
GET_STRING(ptr, tbl_nm);
request = (BLK) CMP_find_request(tdbb, drq_l_dep_flds, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_l_dep_flds, DYN_REQUESTS);
id = drq_l_dep_flds;
try {
@ -700,6 +681,8 @@ void DYN_delete_local_field(
request = (BLK) CMP_find_request(tdbb, drq_e_l_idx, DYN_REQUESTS);
id = drq_e_l_idx;
BLK old_request = NULL;
found = FALSE;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
@ -796,8 +779,6 @@ void DYN_delete_parameter( GBL gbl, UCHAR ** ptr, TEXT * proc_name)
* deletes a stored procedure parameter.
*
**************************************/
BLK old_request, request;
volatile USHORT old_id, id, found;
TEXT name[32];
@ -809,11 +790,12 @@ void DYN_delete_parameter( GBL gbl, UCHAR ** ptr, TEXT * proc_name)
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_prm, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_prm, DYN_REQUESTS);
id = drq_e_prms;
try {
BLK old_request = NULL;
found = FALSE;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
PP IN RDB$PROCEDURE_PARAMETERS WITH PP.RDB$PROCEDURE_NAME EQ proc_name
@ -889,15 +871,12 @@ void DYN_delete_procedure( GBL gbl, UCHAR ** ptr)
* deletes a stored procedure.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK old_request, request;
volatile USHORT old_id, id, found;
TEXT name[32];
GET_STRING(ptr, name);
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb->tdbb_flags |= TDBB_prc_being_dropped;
if (MET_lookup_procedure(tdbb, name, TRUE) == 0)
@ -909,11 +888,14 @@ void DYN_delete_procedure( GBL gbl, UCHAR ** ptr)
tdbb->tdbb_flags &= ~TDBB_prc_being_dropped;
request = (BLK) CMP_find_request(tdbb, drq_e_prms, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_prms, DYN_REQUESTS);
id = drq_e_prms;
try {
try {
BLK old_request = NULL;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
PP IN RDB$PROCEDURE_PARAMETERS WITH PP.RDB$PROCEDURE_NAME EQ name
@ -1047,21 +1029,18 @@ void DYN_delete_relation( GBL gbl, UCHAR ** ptr, TEXT * relation)
* and fields.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
volatile USHORT id, found;
TEXT relation_name[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
if (relation)
strcpy(relation_name, relation);
else
GET_STRING(ptr, relation_name);
request = (BLK) CMP_find_request(tdbb, drq_e_rel_con2, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_rel_con2, DYN_REQUESTS);
id = drq_e_rel_con2;
try {
@ -1288,22 +1267,17 @@ void DYN_delete_role( GBL gbl, UCHAR ** ptr)
* members of the role.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
volatile USHORT id;
//volatile USHORT err_num;
TEXT role_name[32], role_owner[32], user[32];
//TEXT security_class[32];
TEXT *ptr1, *ptr2;
BOOLEAN del_role_ok = TRUE;
USHORT major_version, minor_original;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
major_version = (SSHORT) dbb->dbb_ods_version;
minor_original = (SSHORT) dbb->dbb_minor_original;
const USHORT major_version = dbb->dbb_ods_version;
const USHORT minor_original = dbb->dbb_minor_original;
if (ENCODE_ODS(major_version, minor_original) < ODS_9_0) {
DYN_error(FALSE, 196, NULL, NULL, NULL, NULL, NULL);
@ -1311,6 +1285,7 @@ void DYN_delete_role( GBL gbl, UCHAR ** ptr)
return; // never reached
}
BLK request = NULL;
try {
@ -1326,6 +1301,8 @@ void DYN_delete_role( GBL gbl, UCHAR ** ptr)
request = (BLK) CMP_find_request(tdbb, drq_drop_role, DYN_REQUESTS);
id = drq_drop_role;
bool del_role_ok = true;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
XX IN RDB$ROLES WITH
@ -1335,8 +1312,6 @@ void DYN_delete_role( GBL gbl, UCHAR ** ptr)
DYN_terminate(XX.RDB$OWNER_NAME, sizeof(XX.RDB$OWNER_NAME));
strcpy(role_owner, XX.RDB$OWNER_NAME);
#pragma FB_COMPILER_MESSAGE("TMN: LOCKSMITH!")
if ((tdbb->tdbb_attachment->att_user->usr_flags & USR_locksmith) ||
(strcmp(role_owner, user) == 0))
{
@ -1344,7 +1319,7 @@ void DYN_delete_role( GBL gbl, UCHAR ** ptr)
}
else
{
del_role_ok = FALSE;
del_role_ok = false;
}
END_FOR;
@ -1449,13 +1424,10 @@ void DYN_delete_shadow( GBL gbl, UCHAR ** ptr)
* Delete a shadow.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
int shadow_number;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
/*****
the code commented out in this routine was meant to delete the
@ -1468,7 +1440,7 @@ STR file;
files = NULL;
*****/
request = (BLK) CMP_find_request(tdbb, drq_e_shadow, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_shadow, DYN_REQUESTS);
try {
@ -1525,16 +1497,13 @@ void DYN_delete_trigger( GBL gbl, UCHAR ** ptr)
* deletes an trigger.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT id, found;
TEXT r[32], t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_trg_msgs, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_trg_msgs, DYN_REQUESTS);
id = drq_e_trg_msgs;
try {
@ -1662,15 +1631,12 @@ void DYN_delete_trigger_msg( GBL gbl, UCHAR ** ptr, TEXT * trigger_name)
* deletes an trigger message.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
int number;
TEXT t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
number = DYN_get_number(ptr);
if (trigger_name)
@ -1681,7 +1647,7 @@ void DYN_delete_trigger_msg( GBL gbl, UCHAR ** ptr, TEXT * trigger_name)
DYN_error_punt(FALSE, 70, NULL, NULL, NULL, NULL, NULL);
/* msg 70: "TRIGGER NAME expected" */
request = (BLK) CMP_find_request(tdbb, drq_e_trg_msg, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_trg_msg, DYN_REQUESTS);
try {
@ -1734,15 +1700,12 @@ static BOOLEAN delete_constraint_records(GBL gbl,
* based on a constraint name.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
BOOLEAN found;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_rel_con, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_rel_con, DYN_REQUESTS);
try {
@ -1786,15 +1749,12 @@ static BOOLEAN delete_dimension_records(GBL gbl, TEXT* field_name)
* pertaining to a field.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
BOOLEAN found;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_dims, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_dims, DYN_REQUESTS);
try {
@ -1859,14 +1819,12 @@ static void delete_f_key_constraint(TDBB tdbb,
* RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME
*
**************************************/
DBB dbb;
BLK request;
BOOLEAN found;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_rel_const, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_rel_const, DYN_REQUESTS);
try {
@ -1915,13 +1873,9 @@ static void delete_gfield_for_lfield( GBL gbl, TEXT * lfield_name)
* deletes a global field for a given local field.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_l_gfld, DYN_REQUESTS);
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
BLK request = (BLK) CMP_find_request(tdbb, drq_e_l_gfld, DYN_REQUESTS);
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$FIELDS
@ -1960,15 +1914,12 @@ static BOOLEAN delete_index_segment_records( GBL gbl, TEXT * index_name)
* pertaining to an index.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
BOOLEAN found;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_e_idx_segs, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_e_idx_segs, DYN_REQUESTS);
try {
@ -2044,3 +1995,4 @@ static BOOLEAN delete_security_class2( GBL gbl, TEXT * security_class)
return found;
}

View File

@ -85,7 +85,7 @@ DATABASE DB = STATIC "ODS.RDB";
#define MAX_CHARS_DOUBLE 22 /* 15 digits + 2 signs + E + decimal + 3 digit exp */
#define MAX_CHARS_FLOAT 13 /* 7 digits + 2 signs + E + decimal + 2 digit exp */
static UCHAR alloc_info[] = { gds_info_allocation, gds_info_end };
static const UCHAR alloc_info[] = { gds_info_allocation, gds_info_end };
static void drop_cache(GBL);
static void change_backup_mode(GBL, UCHAR verb);
static void drop_log(GBL);
@ -93,16 +93,17 @@ static void drop_log(GBL);
// Function not defined in this file MOD 04-July-2002
// static void modify_lfield_type(GBL, UCHAR **, TEXT *, TEXT *);
static void modify_lfield_position(TDBB, DBB, GBL, TEXT *, TEXT *, USHORT,
USHORT);
static BOOLEAN check_view_dependency(TDBB, DBB, GBL, TEXT *, TEXT *);
static BOOLEAN check_sptrig_dependency(TDBB, DBB, GBL, TEXT *, TEXT *);
static void modify_lfield_index(TDBB, DBB, GBL, TEXT *, TEXT *, TEXT *);
static BOOLEAN field_exists(TDBB, DBB, GBL, TEXT *, TEXT *);
static BOOLEAN domain_exists(TDBB, DBB, GBL, TEXT *);
static void modify_lfield_position(TDBB, DBB, GBL, const TEXT*, const TEXT*,
USHORT, USHORT);
static bool check_view_dependency(TDBB, DBB, GBL, const TEXT*, const TEXT*);
static bool check_sptrig_dependency(TDBB, DBB, GBL, const TEXT*, const TEXT*);
static void modify_lfield_index(TDBB, DBB, GBL, const TEXT*, const TEXT*,
const TEXT*);
static bool field_exists(TDBB, DBB, GBL, const TEXT*, const TEXT*);
static bool domain_exists(TDBB, DBB, GBL, const TEXT*);
static void get_domain_type(TDBB, DBB, GBL, DYN_FLD);
static ULONG check_update_fld_type(DYN_FLD, DYN_FLD);
static void modify_err_punt(TDBB, ULONG, DYN_FLD, DYN_FLD);
static ULONG check_update_fld_type(const dyn_fld*, const dyn_fld*);
static void modify_err_punt(TDBB, ULONG, const dyn_fld*, const dyn_fld*);
void DYN_modify_database( GBL gbl, UCHAR ** ptr)
@ -117,9 +118,6 @@ void DYN_modify_database( GBL gbl, UCHAR ** ptr)
* Modify a database.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
SSHORT length;
SLONG start;
UCHAR verb, s[128];
@ -131,10 +129,10 @@ void DYN_modify_database( GBL gbl, UCHAR ** ptr)
USHORT first_log_file = TRUE;
#endif
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
BLK request = NULL;
try {
@ -278,30 +276,27 @@ void DYN_modify_exception( GBL gbl, UCHAR ** ptr)
* Modify an exception.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
UCHAR verb;
TEXT t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_m_xcp, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_xcp, DYN_REQUESTS);
bool found = false;
try {
GET_STRING(ptr, t);
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
X IN RDB$EXCEPTIONS
WITH X.RDB$EXCEPTION_NAME EQ t
if (!DYN_REQUEST(drq_m_xcp)) DYN_REQUEST(drq_m_xcp) = request;
found = TRUE;
found = true;
MODIFY X
while ((verb = *(*ptr)++) != gds_dyn_end)
switch (verb) {
@ -350,10 +345,8 @@ void DYN_modify_global_field(
* Note: a global field here is a SQL domain.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request, old_request;
USHORT found, single_validate = FALSE;
BLK old_request;
USHORT single_validate = FALSE;
UCHAR verb;
DYN_FLD orig_dom, new_dom;
BOOLEAN dtype, scale, prec, subtype, charlen, collation, fldlen, nullflg,
@ -369,8 +362,8 @@ void DYN_modify_global_field(
SSHORT field_adjusted_count = 0;
TEXT *err_one_type_change_only = "Only one data type change to the domain allowed at a time";
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
dtype = scale = prec = subtype = charlen = collation = fldlen = nullflg =
charset = FALSE;
@ -380,7 +373,8 @@ void DYN_modify_global_field(
bdeldflt = bflddftval = bflddfltsrc = FALSE;
request = (BLK) CMP_find_request(tdbb, drq_m_gfield, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_gfield, DYN_REQUESTS);
bool found = false;
try {
@ -401,14 +395,14 @@ void DYN_modify_global_field(
GET_STRING(ptr, orig_dom->dyn_fld_name);
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ orig_dom->dyn_fld_name
if (!DYN_REQUEST(drq_m_gfield))
DYN_REQUEST(drq_m_gfield) = request;
found = TRUE;
found = true;
DSC_make_descriptor(&orig_dom->dyn_dsc,
FLD.RDB$FIELD_TYPE,
@ -713,16 +707,15 @@ void DYN_modify_global_field(
*/
if (dtype) {
ULONG retval;
DSC_make_descriptor(&new_dom->dyn_dsc,
new_dom->dyn_dtype,
new_dom->dyn_dsc.dsc_scale,
new_dom->dyn_dsc.dsc_length,
new_dom->dyn_dsc.dsc_sub_type,
new_dom->dyn_charset, new_dom->dyn_collation);
if ((retval = check_update_fld_type(orig_dom, new_dom)) !=
FB_SUCCESS) modify_err_punt(tdbb, retval, orig_dom, new_dom);
ULONG retval = check_update_fld_type(orig_dom, new_dom);
if (retval != FB_SUCCESS)
modify_err_punt(tdbb, retval, orig_dom, new_dom);
}
MODIFY FLD USING
@ -897,29 +890,26 @@ void DYN_modify_index( GBL gbl, UCHAR ** ptr)
* Modify an existing index
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
UCHAR verb;
TEXT name[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_m_index, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_index, DYN_REQUESTS);
bool found = false;
try {
GET_STRING(ptr, name);
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
IDX IN RDB$INDICES WITH IDX.RDB$INDEX_NAME EQ name
if (!DYN_REQUEST(drq_m_index)) DYN_REQUEST(drq_m_index) = request;
found = TRUE;
found = true;
MODIFY IDX USING
while ((verb = *(*ptr)++) != gds_dyn_end)
switch (verb) {
@ -986,18 +976,15 @@ void DYN_modify_local_field(
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found, position, existing_position;
USHORT position, existing_position;
USHORT sfflag, qnflag, qhflag, esflag, dflag, system_flag, scflag, nnflag,
ntflag, npflag;
UCHAR verb;
TEXT f[32], r[32], *query_name, *query_header, *edit_string, *description,
*security_class, *new_name;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
GET_STRING(ptr, f);
r[0] = 0;
@ -1060,11 +1047,12 @@ void DYN_modify_local_field(
DYN_execute(gbl, ptr, relation_name, field_name, NULL, NULL, NULL);
}
request = (BLK) CMP_find_request(tdbb, drq_m_lfield, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_lfield, DYN_REQUESTS);
bool found = false;
try {
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$RELATION_FIELDS
WITH FLD.RDB$FIELD_NAME EQ f AND FLD.RDB$RELATION_NAME EQ r
@ -1072,7 +1060,7 @@ void DYN_modify_local_field(
if (!DYN_REQUEST(drq_m_lfield))
DYN_REQUEST(drq_m_lfield) = request;
found = TRUE;
found = true;
MODIFY FLD USING
if (npflag)
@ -1175,31 +1163,28 @@ void DYN_modify_procedure( GBL gbl, UCHAR ** ptr)
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
UCHAR verb;
USHORT found;
TEXT procedure_name[PROC_NAME_SIZE];
GET_STRING(ptr, procedure_name);
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = NULL;
BLK request = NULL;
bool found = false;
try {
request = (BLK) CMP_find_request(tdbb, drq_m_prcs, DYN_REQUESTS);
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
P IN RDB$PROCEDURES WITH P.RDB$PROCEDURE_NAME = procedure_name
if (!DYN_REQUEST(drq_m_prcs))
DYN_REQUEST(drq_m_prcs) = request;
found = TRUE;
found = true;
/* Set NULL flags to TRUE only for fields which must be specified in the DYN string.
Retain existing values on other fields (RDB$DESCRIPTION, RDB$SECURITY_CLASS),
@ -1285,24 +1270,21 @@ void DYN_modify_relation( GBL gbl, UCHAR ** ptr)
* Modify an existing relation
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
UCHAR verb;
TEXT name[32], field_name[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
field_name[0] = 0;
GET_STRING(ptr, name);
request = (BLK) CMP_find_request(tdbb, drq_m_relation, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_relation, DYN_REQUESTS);
bool found = false;
try {
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
REL IN RDB$RELATIONS WITH REL.RDB$RELATION_NAME EQ name
@ -1311,7 +1293,7 @@ void DYN_modify_relation( GBL gbl, UCHAR ** ptr)
if (!REL.RDB$VIEW_BLR.NULL)
DYN_error_punt(FALSE, 177, NULL, NULL, NULL, NULL, NULL);
found = TRUE;
found = true;
MODIFY REL USING
while ((verb = *(*ptr)++) != gds_dyn_end)
switch (verb) {
@ -1386,17 +1368,14 @@ void DYN_modify_trigger( GBL gbl, UCHAR ** ptr)
* Modify a trigger for a relation.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found;
UCHAR verb, *blr;
TEXT trigger_name[32], *source;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_m_trigger, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_trigger, DYN_REQUESTS);
bool found = false;
try {
@ -1404,7 +1383,7 @@ void DYN_modify_trigger( GBL gbl, UCHAR ** ptr)
source = NULL;
blr = NULL;
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
X IN RDB$TRIGGERS WITH X.RDB$TRIGGER_NAME EQ trigger_name
@ -1428,7 +1407,7 @@ void DYN_modify_trigger( GBL gbl, UCHAR ** ptr)
}
}
*/
found = TRUE;
found = true;
MODIFY X
while ((verb = *(*ptr)++) != gds_dyn_end)
switch (verb) {
@ -1521,17 +1500,14 @@ void DYN_modify_trigger_msg( GBL gbl, UCHAR ** ptr, TEXT * trigger_name)
* Modify a trigger message.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
int number;
UCHAR verb;
TEXT t[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_m_trg_msg, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_m_trg_msg, DYN_REQUESTS);
try {
@ -1594,15 +1570,11 @@ void DYN_modify_view( GBL gbl, UCHAR ** ptr)
* Execute a dynamic ddl statement.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
UCHAR verb;
USHORT found;
TEXT view_name[32];
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
view_name[0] = 0;
GET_STRING(ptr, view_name);
@ -1611,12 +1583,15 @@ void DYN_modify_view( GBL gbl, UCHAR ** ptr)
if (!view_name[0])
DYN_error_punt(FALSE, 212, NULL, NULL, NULL, NULL, NULL);
/* msg 212: "Zero length identifiers not allowed" */
BLK request = NULL;
bool found = false;
try {
request = (BLK) CMP_find_request(tdbb, drq_m_relation, DYN_REQUESTS);
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
VRL IN RDB$VIEW_RELATIONS CROSS REL IN RDB$RELATIONS
WITH VRL.RDB$VIEW_NAME EQ REL.RDB$RELATION_NAME AND
@ -1625,7 +1600,7 @@ void DYN_modify_view( GBL gbl, UCHAR ** ptr)
if (!DYN_REQUEST(drq_m_relation))
DYN_REQUEST(drq_m_relation) = request;
found = TRUE;
found = true;
MODIFY REL
REL.RDB$SYSTEM_FLAG.NULL = TRUE;
REL.RDB$VIEW_BLR.NULL = TRUE;
@ -1692,15 +1667,11 @@ static void drop_cache( GBL gbl)
* Drop the database cache
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found = FALSE;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_d_cache, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_d_cache, DYN_REQUESTS);
bool found = false;
try {
@ -1708,7 +1679,7 @@ static void drop_cache( GBL gbl)
X IN RDB$FILES WITH X.RDB$FILE_FLAGS EQ FILE_cache
ERASE X;
found = TRUE;
found = true;
END_FOR;
@ -1744,16 +1715,13 @@ static void change_backup_mode( GBL gbl, UCHAR verb)
* begin or end backup
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found = FALSE;
bool invalid_state = false;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_d_difference, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_d_difference, DYN_REQUESTS);
bool found = false;
try {
@ -1761,7 +1729,7 @@ static void change_backup_mode( GBL gbl, UCHAR verb)
X IN RDB$FILES
if (X.RDB$FILE_FLAGS & FILE_difference) {
found = TRUE;
found = true;
switch (verb) {
case gds_dyn_drop_difference:
ERASE X;
@ -1860,15 +1828,11 @@ static void drop_log( GBL gbl)
* Delete all log files
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request;
USHORT found = FALSE;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_d_log, DYN_REQUESTS);
BLK request = (BLK) CMP_find_request(tdbb, drq_d_log, DYN_REQUESTS);
bool found = false;
try {
@ -1876,7 +1840,7 @@ static void drop_log( GBL gbl)
X IN RDB$LOG_FILES
ERASE X;
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_d_log))
@ -1899,8 +1863,8 @@ static void drop_log( GBL gbl)
static void modify_lfield_position(TDBB tdbb,
DBB dbb,
GBL gbl,
TEXT * relation_name,
TEXT * field_name,
const TEXT* relation_name,
const TEXT* field_name,
USHORT new_position,
USHORT existing_position)
{
@ -1931,13 +1895,11 @@ static void modify_lfield_position(TDBB tdbb,
*
***********************************************************/
volatile BLK request = NULL;
USHORT new_pos = 0;
SLONG max_position = -1;
BOOLEAN move_down = FALSE;
try {
/* Find the position of the last field in the relation */
SLONG max_position = -1;
DYN_UTIL_generate_field_position(tdbb, gbl, relation_name, &max_position);
/* if the existing position of the field is less than the new position of
@ -1945,8 +1907,9 @@ static void modify_lfield_position(TDBB tdbb,
* increase the value in RDB$FIELD_POSITION by one
*/
bool move_down = false;
if (existing_position < new_position)
move_down = TRUE;
move_down = true;
/* Retrieve the records for the fields which have a position between the
* existing field position and the new field position
@ -1988,7 +1951,7 @@ static void modify_lfield_position(TDBB tdbb,
* duplicate field positions and no gaps in the position sequence (this can
* not be guaranteed by the query above */
new_pos = 0;
USHORT new_pos = 0;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$RELATION_FIELDS WITH FLD.RDB$RELATION_NAME EQ relation_name
SORTED BY ASCENDING FLD.RDB$FIELD_POSITION
@ -2009,10 +1972,11 @@ static void modify_lfield_position(TDBB tdbb,
}
}
static BOOLEAN check_view_dependency(TDBB tdbb,
static bool check_view_dependency(TDBB tdbb,
DBB dbb,
GBL gbl,
TEXT * relation_name, TEXT * field_name)
const TEXT* relation_name,
const TEXT* field_name)
{
/***********************************************************
*
@ -2021,12 +1985,13 @@ static BOOLEAN check_view_dependency(TDBB tdbb,
*
* Functional Description:
* Checks to see if the given field is referenced in a view. If the field
* is referenced in a view, return TRUE, else return FALSE
* is referenced in a view, return true, else return false
* CVC: The function never has a chance to return true because it punts.
*
***********************************************************/
BLK request = NULL;
BOOLEAN retval = FALSE;
TEXT *view_name;
bool retval = false;
TEXT *view_name = NULL;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FIRST 1
@ -2039,7 +2004,7 @@ static BOOLEAN check_view_dependency(TDBB tdbb,
Y.RDB$RELATION_NAME EQ Z.RDB$VIEW_NAME AND
X.RDB$RELATION_NAME EQ Z.RDB$RELATION_NAME AND
Y.RDB$VIEW_CONTEXT EQ Z.RDB$VIEW_CONTEXT
retval = TRUE;
retval = true;
view_name = Z.RDB$VIEW_NAME;
END_FOR;
@ -2054,11 +2019,11 @@ static BOOLEAN check_view_dependency(TDBB tdbb,
}
static BOOLEAN check_sptrig_dependency(TDBB tdbb,
static bool check_sptrig_dependency(TDBB tdbb,
DBB dbb,
GBL gbl,
TEXT * relation_name,
TEXT * field_name)
const TEXT* relation_name,
const TEXT* field_name)
{
/***********************************************************
*
@ -2067,19 +2032,19 @@ static BOOLEAN check_sptrig_dependency(TDBB tdbb,
*
* Functional Description:
* Checks to see if the given field is referenced in a stored procedure
* or trigger. If the field is refereneced, return TRUE, else return
* FALSE
* or trigger. If the field is refereneced, return true, else return
* false, but true causes the function to punt instead.
***********************************************************/
BLK request = NULL;
BOOLEAN retval = FALSE;
TEXT *dep_name;
bool retval = false;
TEXT *dep_name = NULL;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FIRST 1
DEP IN RDB$DEPENDENCIES WITH
DEP.RDB$DEPENDED_ON_NAME EQ relation_name AND
DEP.RDB$FIELD_NAME EQ field_name
retval = TRUE;
retval = true;
dep_name = DEP.RDB$DEPENDENT_NAME;
END_FOR;
@ -2096,9 +2061,9 @@ static BOOLEAN check_sptrig_dependency(TDBB tdbb,
static void modify_lfield_index(TDBB tdbb,
DBB dbb,
GBL gbl,
TEXT* relation_name,
TEXT* field_name,
TEXT* new_fld_name)
const TEXT* relation_name,
const TEXT* field_name,
const TEXT* new_fld_name)
{
/***********************************************************
*
@ -2133,9 +2098,11 @@ static void modify_lfield_index(TDBB tdbb,
CMP_release(tdbb, (JRD_REQ)request);
}
static BOOLEAN field_exists(TDBB tdbb,
static bool field_exists(TDBB tdbb,
DBB dbb,
GBL gbl, TEXT * relation_name, TEXT * field_name)
GBL gbl,
const TEXT* relation_name,
const TEXT* field_name)
{
/***********************************************************
*
@ -2146,20 +2113,20 @@ static BOOLEAN field_exists(TDBB tdbb,
* Checks to see if the given field already exists in a relation
***********************************************************/
BLK request = NULL;
BOOLEAN retval = FALSE;
bool retval = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$RELATION_FIELDS WITH
FLD.RDB$RELATION_NAME EQ relation_name AND
FLD.RDB$FIELD_NAME EQ field_name
retval = TRUE;
retval = true;
END_FOR;
CMP_release(tdbb, (JRD_REQ)request);
return retval;
}
static BOOLEAN domain_exists(TDBB tdbb, DBB dbb, GBL gbl, TEXT * field_name)
static bool domain_exists(TDBB tdbb, DBB dbb, GBL gbl, const TEXT* field_name)
{
/***********************************************************
*
@ -2170,11 +2137,11 @@ static BOOLEAN domain_exists(TDBB tdbb, DBB dbb, GBL gbl, TEXT * field_name)
* Checks to see if the given field already exists in a relation
***********************************************************/
BLK request = NULL;
BOOLEAN retval = FALSE;
bool retval = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ field_name
retval = TRUE;
retval = true;
END_FOR;
CMP_release(tdbb, (JRD_REQ)request);
@ -2229,11 +2196,8 @@ void DYN_modify_sql_field(GBL gbl,
* produces a warning. This condition raises an error, too.
*
**************************************/
TDBB tdbb;
DBB dbb;
BLK request = NULL, first_request;
UCHAR verb;
BOOLEAN found = FALSE, update_domain = FALSE;
BOOLEAN update_domain = FALSE;
BOOLEAN dtype, scale, prec, subtype, charlen, collation, fldlen, nullflg,
charset;
DYN_FLD orig_fld, new_fld, dom_fld;
@ -2241,8 +2205,8 @@ void DYN_modify_sql_field(GBL gbl,
SSHORT field_adjusted_count = 0;
TEXT *err_one_type_change_only = "Only one data type change to the field allowed at a time";
tdbb = GET_THREAD_DATA;
dbb = tdbb->tdbb_database;
TDBB tdbb = GET_THREAD_DATA;
DBB dbb = tdbb->tdbb_database;
try {
@ -2274,13 +2238,17 @@ void DYN_modify_sql_field(GBL gbl,
check_sptrig_dependency(tdbb, dbb, gbl, relation_name,
orig_fld->dyn_fld_name);
BLK request = NULL;
BLK first_request = NULL;
bool found = false;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
RFR IN RDB$RELATION_FIELDS WITH RFR.RDB$RELATION_NAME = relation_name
AND RFR.RDB$FIELD_NAME = orig_fld->dyn_fld_name
first_request = request;
request = NULL;
found = TRUE;
found = true;
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME = RFR.RDB$FIELD_SOURCE
@ -2447,8 +2415,6 @@ void DYN_modify_sql_field(GBL gbl,
if (update_domain) {
ULONG retval;
/* CVC: Since get_domain_type() called above already called DSC_make_descriptor,
there's no point in calling it again, since it will increment AGAIN the length
of varchar fields! This bug detected thanks to new check field dyn_charbytelen.
@ -2460,8 +2426,9 @@ void DYN_modify_sql_field(GBL gbl,
dom_fld->dyn_charset, dom_fld->dyn_collation);
*/
if ((retval = check_update_fld_type(orig_fld, dom_fld)) !=
FB_SUCCESS) modify_err_punt(tdbb, retval, orig_fld, dom_fld);
ULONG retval = check_update_fld_type(orig_fld, dom_fld);
if (retval != FB_SUCCESS)
modify_err_punt(tdbb, retval, orig_fld, dom_fld);
/* if the original definition was a base field type, remove the entries from RDB$FIELDS */
if (!strncmp(orig_fld->dyn_fld_source, "RDB$", 4)) {
@ -2482,17 +2449,15 @@ void DYN_modify_sql_field(GBL gbl,
first_request = request;
}
else {
ULONG retval;
DSC_make_descriptor(&new_fld->dyn_dsc,
new_fld->dyn_dtype,
new_fld->dyn_dsc.dsc_scale,
new_fld->dyn_dsc.dsc_length,
new_fld->dyn_dsc.dsc_sub_type,
new_fld->dyn_charset, new_fld->dyn_collation);
if ((retval = check_update_fld_type(orig_fld, new_fld)) !=
FB_SUCCESS) modify_err_punt(tdbb, retval, orig_fld, new_fld);
ULONG retval = check_update_fld_type(orig_fld, new_fld);
if (retval != FB_SUCCESS)
modify_err_punt(tdbb, retval, orig_fld, new_fld);
/* check to see if the original data type for the field was based on a domain. If it
* was (and now it isn't), remove the domain information and replace it with a generated
@ -2668,7 +2633,7 @@ void get_domain_type(TDBB tdbb, DBB dbb, GBL gbl, DYN_FLD dom_fld)
**************************************
*
* Functional description
* Retrives the type information for a domain so
* Retrieves the type information for a domain so
* that it can be compared to a local field before
* modifying the datatype of a field.
*
@ -2683,7 +2648,8 @@ void get_domain_type(TDBB tdbb, DBB dbb, GBL gbl, DYN_FLD dom_fld)
FLD.RDB$FIELD_SCALE,
FLD.RDB$FIELD_LENGTH,
FLD.RDB$FIELD_SUB_TYPE,
FLD.RDB$CHARACTER_SET_ID, FLD.RDB$COLLATION_ID);
FLD.RDB$CHARACTER_SET_ID,
FLD.RDB$COLLATION_ID);
dom_fld->dyn_charbytelen = FLD.RDB$FIELD_LENGTH;
dom_fld->dyn_dtype = FLD.RDB$FIELD_TYPE;
@ -2696,7 +2662,8 @@ void get_domain_type(TDBB tdbb, DBB dbb, GBL gbl, DYN_FLD dom_fld)
CMP_release(tdbb, (JRD_REQ)request);
}
static ULONG check_update_fld_type(DYN_FLD orig_fld, DYN_FLD new_fld)
static ULONG check_update_fld_type(const dyn_fld* orig_fld,
const dyn_fld* new_fld)
{
/**************************************
*
@ -2755,12 +2722,11 @@ static ULONG check_update_fld_type(DYN_FLD orig_fld, DYN_FLD new_fld)
case blr_varying:
case blr_cstring:
{
USHORT maxflen = 0;
/* CVC: Because our caller invoked DSC_make_descriptor() on new_fld previously,
we should have the added bytes for varchar. For cstring, we are used, since
DSC_make_descriptor(DSC_string_length) != DSC_string_length(DSC_make_descriptor). */
maxflen = DSC_string_length(&orig_fld->dyn_dsc);
USHORT maxflen = DSC_string_length(&orig_fld->dyn_dsc);
/* We can have this assertion since this case is for both string fields. */
assert(DSC_string_length(&new_fld->dyn_dsc) - maxflen
@ -2818,9 +2784,7 @@ static ULONG check_update_fld_type(DYN_FLD orig_fld, DYN_FLD new_fld)
case blr_cstring:
case blr_cstring2:
{
USHORT maxflen = 0;
maxflen = DSC_string_length(&orig_fld->dyn_dsc);
USHORT maxflen = DSC_string_length(&orig_fld->dyn_dsc);
if (new_fld->dyn_dsc.dsc_length < maxflen)
return isc_dyn_char_fld_too_small;
@ -2927,9 +2891,7 @@ static ULONG check_update_fld_type(DYN_FLD orig_fld, DYN_FLD new_fld)
case blr_varying:
case blr_cstring:
{
USHORT maxflen = 0;
maxflen = DSC_string_length(&orig_fld->dyn_dsc);
USHORT maxflen = DSC_string_length(&orig_fld->dyn_dsc);
if (new_fld->dyn_dsc.dsc_length < maxflen)
return isc_dyn_char_fld_too_small;
@ -2952,7 +2914,8 @@ static ULONG check_update_fld_type(DYN_FLD orig_fld, DYN_FLD new_fld)
static void modify_err_punt(TDBB tdbb,
ULONG errorcode,
DYN_FLD orig_fld_def, DYN_FLD new_fld_def)
const dyn_fld* orig_fld_def,
const dyn_fld* new_fld_def)
{
/**************************************
*
@ -3014,3 +2977,4 @@ static void modify_err_punt(TDBB tdbb,
/* msg 95: "MODIFY RDB$RELATION_FIELDS failed" */
}
}

View File

@ -22,16 +22,17 @@
*/
#ifndef _JRD_DYN_UT_PROTO_H_
#define _JRD_DYN_UT_PROTO_H_
#ifndef JRD_DYN_UT_PROTO_H
#define JRD_DYN_UT_PROTO_H
extern void DYN_UTIL_store_check_constraints(TDBB, GBL, TEXT *, TEXT *);
extern BOOLEAN DYN_UTIL_get_prot(TDBB, GBL, SCHAR *, SCHAR *, USHORT *);
extern void DYN_UTIL_generate_trigger_name(TDBB, GBL, TEXT *);
extern void DYN_UTIL_generate_index_name(TDBB, GBL, TEXT *, UCHAR);
extern void DYN_UTIL_generate_field_position(TDBB, GBL, TEXT *, SLONG *);
extern void DYN_UTIL_generate_field_position(TDBB, GBL, const TEXT*, SLONG *);
extern void DYN_UTIL_generate_field_name(TDBB, GBL, TEXT *);
extern void DYN_UTIL_generate_constraint_name(TDBB, GBL, TEXT *);
extern SINT64 DYN_UTIL_gen_unique_id(TDBB, GBL, SSHORT, SCHAR *, BLK *);
#endif /* _JRD_DYN_UT_PROTO_H_ */
#endif /* JRD_DYN_UT_PROTO_H */

View File

@ -119,14 +119,12 @@ SINT64 DYN_UTIL_gen_unique_id(TDBB tdbb,
* Generate a unique id using a generator.
*
**************************************/
DBB dbb;
JRD_REQ req_handle;
SINT64 value;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
req_handle = CMP_find_request(tdbb, id, DYN_REQUESTS);
JRD_REQ req_handle = CMP_find_request(tdbb, id, DYN_REQUESTS);
if (!req_handle)
{
@ -170,19 +168,19 @@ void DYN_UTIL_generate_constraint_name( TDBB tdbb, GBL gbl, TEXT * buffer)
* Generate a name unique to RDB$RELATION_CONSTRAINTS.
*
**************************************/
DBB dbb;
volatile BLK request;
USHORT found;
volatile SSHORT id;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = NULL;
id = -1;
try {
bool found = false;
do {
id = drq_g_nxt_con;
sprintf(buffer, "INTEG_%" QUADFORMAT "d",
@ -195,14 +193,14 @@ void DYN_UTIL_generate_constraint_name( TDBB tdbb, GBL gbl, TEXT * buffer)
request = (BLK) CMP_find_request(tdbb, drq_f_nxt_con, DYN_REQUESTS);
id = drq_f_nxt_con;
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request)
FIRST 1 X IN RDB$RELATION_CONSTRAINTS
WITH X.RDB$CONSTRAINT_NAME EQ buffer
if (!DYN_REQUEST(drq_f_nxt_con))
DYN_REQUEST(drq_f_nxt_con) = request;
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_f_nxt_con))
@ -231,18 +229,18 @@ void DYN_UTIL_generate_field_name( TDBB tdbb, GBL gbl, TEXT * buffer)
* Generate a name unique to RDB$FIELDS.
*
**************************************/
DBB dbb;
volatile BLK request;
USHORT found;
volatile SSHORT id;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = NULL;
id = -1;
try {
bool found = false;
do {
id = drq_g_nxt_fld;
@ -256,13 +254,13 @@ void DYN_UTIL_generate_field_name( TDBB tdbb, GBL gbl, TEXT * buffer)
request = (BLK) CMP_find_request(tdbb, drq_f_nxt_fld, DYN_REQUESTS);
id = drq_f_nxt_fld;
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request)
FIRST 1 X IN RDB$FIELDS WITH X.RDB$FIELD_NAME EQ buffer
if (!DYN_REQUEST(drq_f_nxt_fld))
DYN_REQUEST(drq_f_nxt_fld) = request;
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_f_nxt_fld))
@ -282,7 +280,8 @@ void DYN_UTIL_generate_field_name( TDBB tdbb, GBL gbl, TEXT * buffer)
void DYN_UTIL_generate_field_position(
TDBB tdbb,
GBL gbl,
TEXT * relation_name, SLONG * field_pos)
const TEXT* relation_name,
SLONG * field_pos)
{
/**************************************
*
@ -294,7 +293,6 @@ void DYN_UTIL_generate_field_position(
* Generate a field position if not specified
*
**************************************/
DBB dbb;
volatile BLK request;
SLONG field_position = -1;
@ -302,7 +300,7 @@ void DYN_UTIL_generate_field_position(
return;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = NULL;
@ -347,20 +345,20 @@ void DYN_UTIL_generate_index_name(TDBB tdbb,
* Generate a name unique to RDB$INDICES.
*
**************************************/
DBB dbb;
volatile BLK request;
USHORT found;
volatile SSHORT id;
SCHAR *format;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = NULL;
id = -1;
try {
bool found = false;
do {
if (verb == gds_dyn_def_primary_key)
format = "RDB$PRIMARY%" QUADFORMAT "d";
@ -379,13 +377,13 @@ void DYN_UTIL_generate_index_name(TDBB tdbb,
request = (BLK) CMP_find_request(tdbb, drq_f_nxt_idx, DYN_REQUESTS);
id = drq_f_nxt_idx;
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request)
FIRST 1 X IN RDB$INDICES WITH X.RDB$INDEX_NAME EQ buffer
if (!DYN_REQUEST(drq_f_nxt_idx))
DYN_REQUEST(drq_f_nxt_idx) = request;
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_f_nxt_idx))
@ -413,18 +411,18 @@ void DYN_UTIL_generate_trigger_name( TDBB tdbb, GBL gbl, TEXT * buffer)
* Generate a name unique to RDB$TRIGGERS.
*
**************************************/
DBB dbb;
volatile BLK request;
USHORT found;
volatile SSHORT id;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = NULL;
id = -1;
try {
bool found = false;
do {
id = drq_g_nxt_trg;
@ -438,13 +436,13 @@ void DYN_UTIL_generate_trigger_name( TDBB tdbb, GBL gbl, TEXT * buffer)
request = (BLK) CMP_find_request(tdbb, drq_f_nxt_trg, DYN_REQUESTS);
id = drq_f_nxt_trg;
found = FALSE;
found = false;
FOR(REQUEST_HANDLE request)
FIRST 1 X IN RDB$TRIGGERS WITH X.RDB$TRIGGER_NAME EQ buffer
if (!DYN_REQUEST(drq_f_nxt_trg))
DYN_REQUEST(drq_f_nxt_trg) = request;
found = TRUE;
found = true;
END_FOR;
if (!DYN_REQUEST(drq_f_nxt_trg))
@ -533,11 +531,10 @@ void DYN_UTIL_store_check_constraints(TDBB tdbb,
* Functional description
*
**************************************/
DBB dbb;
volatile BLK request;
SET_TDBB(tdbb);
dbb = tdbb->tdbb_database;
DBB dbb = tdbb->tdbb_database;
request = (BLK) CMP_find_request(tdbb, drq_s_chk_con, DYN_REQUESTS);
@ -560,3 +557,4 @@ void DYN_UTIL_store_check_constraints(TDBB tdbb,
/* msg 122: "STORE RDB$CHECK_CONSTRAINTS failed" */
}
}

View File

@ -759,7 +759,8 @@ static ISC_STATUS error(ISC_STATUS * status_vector,
*status_vector++ = gds_arg_string;
*status_vector++ = (ISC_STATUS) string;
*status_vector++ = gds_arg_vms;
*status_vector++ = status; *status_vector++ = gds_arg_end;
*status_vector++ = status;
*status_vector++ = gds_arg_end;
return gds__sys_request;
}
@ -974,3 +975,4 @@ static int return_ok(ISC_STATUS * status_vector)
*status_vector = gds_arg_end;
return 0;
}

View File

@ -127,9 +127,6 @@ BOOLEAN SHUT_database(DBB dbb, SSHORT flag, SSHORT delay)
/* Only platform's user locksmith can shutdown or bring online
a database. */
#pragma FB_COMPILER_MESSAGE("Locksmith?!")
// if (!attachment->att_user->usr_flags & (USR_locksmith | USR_owner)) {
if (!(attachment->att_user->usr_flags & (USR_locksmith | USR_owner))) {
return FALSE;
}