diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 9f20f4dcff..d39efb3908 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -125,12 +125,12 @@ static ISC_STATUS error(); static void execute_blob(DSQL_REQ, USHORT, UCHAR*, USHORT, UCHAR*, USHORT, UCHAR*, USHORT, UCHAR*); static ISC_STATUS execute_request(DSQL_REQ, FRBRD**, USHORT, UCHAR*, USHORT, UCHAR*, - USHORT, UCHAR*, USHORT, UCHAR*, USHORT); + USHORT, UCHAR*, USHORT, UCHAR*, bool); static SSHORT filter_sub_type(DSQL_REQ, DSQL_NOD); -static BOOLEAN get_indices(SSHORT*, SCHAR**, SSHORT*, SCHAR**); +static bool get_indices(SSHORT*, SCHAR**, SSHORT*, SCHAR**); static USHORT get_plan_info(DSQL_REQ, SSHORT, SCHAR**); static USHORT get_request_info(DSQL_REQ, SSHORT, SCHAR*); -static BOOLEAN get_rsb_item(SSHORT*, SCHAR**, SSHORT*, SCHAR**, USHORT*, +static bool get_rsb_item(SSHORT*, SCHAR**, SSHORT*, SCHAR**, USHORT*, USHORT*); static DBB init(FRBRD**); static void map_in_out(DSQL_REQ, DSQL_MSG, USHORT, UCHAR*, USHORT, UCHAR*); @@ -139,7 +139,7 @@ static USHORT parse_blr(USHORT, UCHAR*, USHORT, PAR); static DSQL_REQ prepare(DSQL_REQ, USHORT, TEXT*, USHORT, USHORT); static void punt(void); static UCHAR* put_item(UCHAR, USHORT, UCHAR*, UCHAR*, UCHAR*); -static void release_request(DSQL_REQ, USHORT); +static void release_request(DSQL_REQ, bool); static ISC_STATUS return_success(void); static UCHAR* var_info(DSQL_MSG, const UCHAR*, const UCHAR*, UCHAR*, UCHAR*, USHORT); @@ -170,7 +170,7 @@ static const UCHAR sql_records_info[] = { #ifdef ANY_THREADING static MUTX_T databases_mutex; static MUTX_T cursors_mutex; -static USHORT mutex_inited = 0; +static bool mutex_inited = false; #endif @@ -537,7 +537,7 @@ ISC_STATUS DLL_EXPORT GDS_DSQL_EXECUTE_CPP(ISC_STATUS* user_status, OPN open_cursor; ISC_STATUS_ARRAY local_status; struct tsql thd_context, *tdsql; - USHORT singleton; + bool singleton; ISC_STATUS sing_status; SET_THREAD_DATA; @@ -584,25 +584,17 @@ ISC_STATUS DLL_EXPORT GDS_DSQL_EXECUTE_CPP(ISC_STATUS* user_status, /* A select with a non zero output length is a singleton select */ if (request->req_type == REQ_SELECT && out_msg_length != 0) { - singleton = TRUE; + singleton = true; } else { - singleton = FALSE; + singleton = false; } if (request->req_type != REQ_EMBED_SELECT) { - sing_status = - execute_request(request, - trans_handle, - in_blr_length, - in_blr, - in_msg_length, - in_msg, - out_blr_length, - out_blr, - out_msg_length, - out_msg, - singleton); + sing_status = execute_request(request, trans_handle, in_blr_length, + in_blr, in_msg_length, in_msg, + out_blr_length, out_blr, + out_msg_length, out_msg, singleton); } /* If the output message length is zero on a REQ_SELECT then we must @@ -753,23 +745,15 @@ static ISC_STATUS dsql8_execute_immediate_common(ISC_STATUS* user_status, gds_arg_string, string, gds_arg_end); } - execute_request(request, - trans_handle, - in_blr_length, - in_blr, - in_msg_length, - in_msg, - out_blr_length, - out_blr, - out_msg_length, - out_msg, - FALSE); + execute_request(request, trans_handle, in_blr_length, in_blr, + in_msg_length, in_msg, out_blr_length, out_blr, + out_msg_length, out_msg, false); - release_request(request, TRUE); + release_request(request, true); } // try catch (const std::exception&) { status = error(); - release_request(request, TRUE); + release_request(request, true); RESTORE_THREAD_DATA; return status; } @@ -1219,7 +1203,7 @@ ISC_STATUS GDS_DSQL_FREE_CPP(ISC_STATUS* user_status, if (option & DSQL_drop) { /* Release everything associate with the request. */ - release_request(request, TRUE); + release_request(request, true); *req_handle = NULL; } else if (option & DSQL_close) { @@ -1459,7 +1443,7 @@ ISC_STATUS GDS_DSQL_PREPARE_CPP(ISC_STATUS* user_status, /* Now that we know that the new request exists, zap the old one. */ tdsql->tsql_default = old_request->req_pool; - release_request(old_request, TRUE); + release_request(old_request, true); tdsql->tsql_default = NULL; /* The request was sucessfully prepared, and the old request was @@ -1479,7 +1463,7 @@ ISC_STATUS GDS_DSQL_PREPARE_CPP(ISC_STATUS* user_status, } // try catch(const std::exception&) { status = error(); - release_request(request, TRUE); + release_request(request, true); RESTORE_THREAD_DATA; return status; } @@ -1722,19 +1706,20 @@ ISC_STATUS GDS_DSQL_SQL_INFO_CPP( ISC_STATUS* user_status, } else if (item == isc_info_sql_batch_fetch) { if (request->req_flags & REQ_no_batch) - number = FALSE; + number = 0; else - number = TRUE; + number = 1; length = convert((SLONG) number, buffer); if (!(info = put_item(item, length, buffer, info, end_info))) { return return_success(); } } else if (item == gds_info_sql_records) { - length = - get_request_info(request, (SSHORT) sizeof(buffer), reinterpret_cast(buffer)); - if (length - && !(info = put_item(item, length, buffer, info, end_info))) { + length = get_request_info(request, (SSHORT) sizeof(buffer), + reinterpret_cast(buffer)); + if (length && !(info = put_item(item, length, buffer, info, + end_info))) + { return return_success(); } } @@ -2861,16 +2846,16 @@ static void execute_blob( DSQL_REQ request, **/ static ISC_STATUS execute_request(DSQL_REQ request, - WHY_TRA* trans_handle, - USHORT in_blr_length, - UCHAR* in_blr, - USHORT in_msg_length, - UCHAR* in_msg, - USHORT out_blr_length, - UCHAR* out_blr, - USHORT out_msg_length, - UCHAR* out_msg, - USHORT singleton) + WHY_TRA* trans_handle, + USHORT in_blr_length, + UCHAR* in_blr, + USHORT in_msg_length, + UCHAR* in_msg, + USHORT out_blr_length, + UCHAR* out_blr, + USHORT out_msg_length, + UCHAR* out_msg, + bool singleton) { DSQL_MSG message; USHORT use_msg_length; @@ -3002,7 +2987,7 @@ static ISC_STATUS execute_request(DSQL_REQ request, default: /* Catch invalid request types */ - assert(FALSE); + assert(false); /* Fall into ... */ case REQ_SELECT: @@ -3203,7 +3188,7 @@ static SSHORT filter_sub_type( DSQL_REQ request, DSQL_NOD node) @brief Retrieve the indices from the index tree in the request info buffer, and print them out - in the plan buffer. + in the plan buffer. Return false on success and true on failure @param explain_length_ptr @@ -3212,7 +3197,7 @@ static SSHORT filter_sub_type( DSQL_REQ request, DSQL_NOD node) @param plan_ptr **/ -static BOOLEAN get_indices( +static bool get_indices( SSHORT * explain_length_ptr, SCHAR ** explain_ptr, SSHORT * plan_length_ptr, SCHAR ** plan_ptr) @@ -3234,9 +3219,9 @@ static BOOLEAN get_indices( case gds_info_rsb_and: case gds_info_rsb_or: if (get_indices(&explain_length, &explain, &plan_length, &plan)) - return FB_FAILURE; + return true; if (get_indices(&explain_length, &explain, &plan_length, &plan)) - return FB_FAILURE; + return true; break; case gds_info_rsb_dbkey: @@ -3250,21 +3235,21 @@ static BOOLEAN get_indices( if (plan[-1] != '(' && plan[-1] != ' ') { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ','; } /* now put out the index name */ if ((plan_length -= length) < 0) - return FB_FAILURE; + return true; explain_length -= length; while (length--) *plan++ = *explain++; break; default: - return FB_FAILURE; + return true; } *explain_length_ptr = explain_length; @@ -3272,7 +3257,7 @@ static BOOLEAN get_indices( *plan_length_ptr = plan_length; *plan_ptr = plan; - return FB_SUCCESS; + return false; } @@ -3466,7 +3451,8 @@ static USHORT get_request_info( get_rsb_item @brief Use recursion to print out a reverse-polish - access plan of joins and join types. + access plan of joins and join types. Return true on failure + and false if succeed @param explain_length_ptr @@ -3477,7 +3463,7 @@ static USHORT get_request_info( @param level_ptr **/ -static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, +static bool get_rsb_item(SSHORT* explain_length_ptr, SCHAR ** explain_ptr, SSHORT* plan_length_ptr, SCHAR** plan_ptr, @@ -3502,7 +3488,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, p = "\nPLAN "; if ((plan_length -= strlen(p)) < 0) - return FB_FAILURE; + return true; while (*p) *plan++ = *p++; } @@ -3524,7 +3510,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (!*parent_join_count) { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = '('; } @@ -3532,7 +3518,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (plan[-1] != '(') { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ','; } @@ -3541,7 +3527,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, explain_length--; explain_length -= (length = (UCHAR) * explain++); if ((plan_length -= length) < 0) - return FB_FAILURE; + return true; while (length--) *plan++ = *explain++; break; @@ -3564,10 +3550,12 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, union_level = *level_ptr; union_join_count = 0; - while (TRUE) { - if (get_rsb_item - (&explain_length, &explain, &plan_length, &plan, - &union_join_count, &union_level)) return FB_FAILURE; + while (true) { + if (get_rsb_item(&explain_length, &explain, &plan_length, &plan, + &union_join_count, &union_level)) + { + return true; + } if (union_level == *level_ptr) break; } @@ -3578,10 +3566,12 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, while (union_count) { union_join_count = 0; union_level = 0; - while (TRUE) { - if (get_rsb_item - (&explain_length, &explain, &plan_length, &plan, - &union_join_count, &union_level)) return FB_FAILURE; + while (true) { + if (get_rsb_item(&explain_length, &explain, &plan_length, + &plan, &union_join_count, &union_level)) + { + return true; + } if (!union_level) break; } @@ -3598,7 +3588,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (*parent_join_count && plan[-1] != '(') { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ','; } @@ -3613,7 +3603,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, } if ((plan_length -= strlen(p)) < 0) - return FB_FAILURE; + return true; while (*p) *plan++ = *p++; @@ -3624,18 +3614,20 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, while (join_count) { if (get_rsb_item(&explain_length, &explain, &plan_length, &plan, &join_count, level_ptr)) - return FB_FAILURE; - /* CVC: Here's the additional stop condition. */ - if (!*level_ptr) { - break; - } - } + { + return true; + } + /* CVC: Here's the additional stop condition. */ + if (!*level_ptr) { + break; + } + } /* put out the final parenthesis for the join */ if (--plan_length < 0) - return FB_FAILURE; + return true; else *plan++ = ')'; @@ -3651,14 +3643,17 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, case gds_info_rsb_ext_sequential: case gds_info_rsb_ext_indexed: if (rsb_type == gds_info_rsb_indexed || - rsb_type == gds_info_rsb_ext_indexed) p = " INDEX ("; + rsb_type == gds_info_rsb_ext_indexed) + { + p = " INDEX ("; + } else if (rsb_type == gds_info_rsb_navigate) p = " ORDER "; else p = " NATURAL"; if ((plan_length -= strlen(p)) < 0) - return FB_FAILURE; + return true; while (*p) *plan++ = *p++; @@ -3667,15 +3662,14 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (rsb_type == gds_info_rsb_indexed || rsb_type == gds_info_rsb_navigate || rsb_type == gds_info_rsb_ext_indexed) { - if (get_indices - (&explain_length, &explain, &plan_length, - &plan)) return FB_FAILURE; + if (get_indices(&explain_length, &explain, &plan_length, &plan)) + return true; } if (rsb_type == gds_info_rsb_indexed || rsb_type == gds_info_rsb_ext_indexed) { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ')'; } @@ -3683,7 +3677,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (!*parent_join_count) if (--plan_length < 0) - return FB_FAILURE; + return true; else *plan++ = ')'; @@ -3703,20 +3697,23 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, if (explain_length > 2 && (explain[0] == gds_info_rsb_begin) && (explain[1] == gds_info_rsb_type) && - (explain[2] == gds_info_rsb_union)) break; + (explain[2] == gds_info_rsb_union)) + { + break; + } /* if this isn't the first item in the list, put out a comma */ if (*parent_join_count && plan[-1] != '(') { if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ','; } p = "SORT ("; if ((plan_length -= strlen(p)) < 0) - return FB_FAILURE; + return true; while (*p) *plan++ = *p++; @@ -3727,13 +3724,13 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, while (explain_length > 0 && plan_length > 0) { if (get_rsb_item(&explain_length, &explain, &plan_length, &plan, parent_join_count, level_ptr)) - return FB_FAILURE; + return true; if (*level_ptr == save_level) break; } if (--plan_length < 0) - return FB_FAILURE; + return true; *plan++ = ')'; break; @@ -3751,7 +3748,7 @@ static BOOLEAN get_rsb_item(SSHORT* explain_length_ptr, *plan_length_ptr = plan_length; *plan_ptr = plan; - return FB_SUCCESS; + return false; } @@ -3770,7 +3767,7 @@ static DBB init(FRBRD** db_handle) #ifdef ANY_THREADING if (!mutex_inited) { - mutex_inited = TRUE; + mutex_inited = true; THD_MUTEX_INIT(&databases_mutex); THD_MUTEX_INIT(&cursors_mutex); } @@ -3822,10 +3819,7 @@ static DBB init(FRBRD** db_handle) ISC_STATUS_ARRAY user_status; THREAD_EXIT; - gds__database_cleanup(user_status, - db_handle, - cleanup_database, - (SLONG) FALSE); + gds__database_cleanup(user_status, db_handle, cleanup_database, (SLONG) 0); THREAD_ENTER; /* Determine if the database is V3 or V4 */ @@ -4540,7 +4534,7 @@ static UCHAR* put_item( UCHAR item, @param top_level **/ -static void release_request(DSQL_REQ request, USHORT top_level) +static void release_request(DSQL_REQ request, bool top_level) { ISC_STATUS_ARRAY status_vector; @@ -4555,7 +4549,7 @@ static void release_request(DSQL_REQ request, USHORT top_level) child->req_parent = NULL; DsqlMemoryPool *save_default = tdsql->tsql_default; tdsql->tsql_default = child->req_pool; - release_request(child, FALSE); + release_request(child, false); tdsql->tsql_default = save_default; } diff --git a/src/dsql/hsh.cpp b/src/dsql/hsh.cpp index 6d8ebd3a28..9eb9127af0 100644 --- a/src/dsql/hsh.cpp +++ b/src/dsql/hsh.cpp @@ -40,8 +40,8 @@ extern "C" { ASSERT_FILENAME #define HASH_SIZE 211 static SSHORT hash(SCHAR *, USHORT); -static BOOLEAN remove_symbol(struct sym **, struct sym *); -static BOOLEAN scompare(TEXT *, USHORT, TEXT *, USHORT); +static bool remove_symbol(struct sym **, struct sym *); +static bool scompare(TEXT *, USHORT, TEXT *, USHORT); static SYM *hash_table; @@ -240,7 +240,8 @@ void HSHD_insert(SYM symbol) for (old = hash_table[h]; old; old = old->sym_collision) if ((!database || (database == old->sym_dbb)) && scompare(symbol->sym_string, symbol->sym_length, old->sym_string, - old->sym_length)) { + old->sym_length)) + { symbol->sym_homonym = old->sym_homonym; old->sym_homonym = symbol; UNLOCK_HASH; @@ -327,11 +328,13 @@ void HSHD_remove( SYM symbol) h = hash(symbol->sym_string, symbol->sym_length); for (collision = &hash_table[h]; *collision; - collision = - &(*collision)->sym_collision) if (remove_symbol(collision, symbol)) { + collision = &(*collision)->sym_collision) + { + if (remove_symbol(collision, symbol)) { UNLOCK_HASH; return; } + } UNLOCK_HASH; IBERROR(-1, "HSHD_remove failed"); @@ -462,7 +465,7 @@ static SSHORT hash(SCHAR * string, USHORT length) @param symbol **/ -static BOOLEAN remove_symbol( SYM * collision, SYM symbol) +static bool remove_symbol( SYM * collision, SYM symbol) { SYM *ptr, homonym; @@ -474,16 +477,16 @@ static BOOLEAN remove_symbol( SYM * collision, SYM symbol) else *collision = symbol->sym_collision; - return TRUE; + return true; } for (ptr = &(*collision)->sym_homonym; *ptr; ptr = &(*ptr)->sym_homonym) if (symbol == *ptr) { *ptr = symbol->sym_homonym; - return TRUE; + return true; } - return FALSE; + return false; } @@ -504,20 +507,20 @@ static BOOLEAN remove_symbol( SYM * collision, SYM symbol) @param length2 **/ -static BOOLEAN scompare(TEXT * string1, +static bool scompare(TEXT * string1, USHORT length1, TEXT * string2, USHORT length2) { if (length1 != length2) - return FALSE; + return false; while (length1--) { if ((*string1++) != (*string2++)) - return FALSE; + return false; } - return TRUE; + return true; } diff --git a/src/dsql/parse.cpp b/src/dsql/parse.cpp index e7546c7493..f62ad53bf9 100644 --- a/src/dsql/parse.cpp +++ b/src/dsql/parse.cpp @@ -46,7 +46,7 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; * 2001.10.01 Claudio Valderrama: enable explicit GRANT...to ROLE role_name. * 2001.10.06 Claudio Valderrama: Honor explicit USER keyword in GRANTs and REVOKEs. * 2002.07.05 Mark O'Donohue: change keyword DEBUG to KW_DEBUG to avoid - * clashes with normal DEBUG macro. + * clashes with normal DEBUG macro. * 2002.07.30 Arno Brinkman: * 2002.07.30 Let IN predicate handle value_expressions * 2002.07.30 tokens CASE, NULLIF, COALESCE added @@ -61,8 +61,8 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; * 2002.08.31 Dmitry Yemanov: allowed user-defined index names for PK/FK/UK constraints * 2002.09.01 Dmitry Yemanov: RECREATE VIEW * 2002.09.28 Dmitry Yemanov: Reworked internal_info stuff, enhanced - * exception handling in SPs/triggers, - * implemented ROWS_AFFECTED system variable + * exception handling in SPs/triggers, + * implemented ROWS_AFFECTED system variable * 2002.10.21 Nickolay Samofatov: Added support for explicit pessimistic locks * 2002.10.29 Nickolay Samofatov: Added support for savepoints * 2002.12.03 Dmitry Yemanov: Implemented ORDER BY clause in subqueries. @@ -75,7 +75,7 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; * 2003.06.13 Nickolay Samofatov: Make INSERTING/UPDATING/DELETING non-reserved keywords * 2003.07.01 Blas Rodriguez Somoza: Change DEBUG and IN to avoid conflicts in win32 build/bison * 2003.08.11 Arno Brinkman: Changed GROUP BY to support all expressions and added "AS" support - * with table alias. Also removed group_by_function and ordinal. + * with table alias. Also removed group_by_function and ordinal. * 2003.08.14 Arno Brinkman: Added support for derived tables. */ @@ -130,8 +130,8 @@ static void yyerror (TEXT *); #define NEGATIVE 1 #define UNSIGNED 2 -#define MIN_CACHE_BUFFERS 250 -#define DEF_CACHE_BUFFERS 1000 +#define MIN_CACHE_BUFFERS 250 +#define DEF_CACHE_BUFFERS 1000 /* Fix 69th procedure problem - solution from Oleg Loa */ #define YYSTACKSIZE 2048 @@ -166,16 +166,16 @@ static void yyerror (TEXT *); #define MAX_TOKEN_LEN 256 #define CHECK_BOUND(to)\ - {\ - if ((to - string) >= MAX_TOKEN_LEN) \ + {\ + if ((to - string) >= MAX_TOKEN_LEN) \ yyabandon (-104, isc_token_too_long); \ - } + } #define CHECK_COPY_INCR(to,ch){CHECK_BOUND(to); *to++=ch;} static TEXT *lex_position (void); #ifdef NOT_USED_OR_REPLACED -static BOOLEAN long_int (DSQL_NOD, SLONG *); +static bool long_int(DSQL_NOD, SLONG *); #endif static DSQL_FLD make_field (DSQL_NOD); static FIL make_file (void); @@ -185,7 +185,7 @@ static DSQL_NOD make_parameter (void); static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...); static void prepare_console_debug (int, int *); #ifdef NOT_USED_OR_REPLACED -static BOOLEAN short_int (DSQL_NOD, SLONG *, SSHORT); +static bool short_int(DSQL_NOD, SLONG *, SSHORT); #endif static void stack_nodes (DSQL_NOD, DLLS *); inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *); @@ -195,7 +195,7 @@ static void check_log_file_attrs (void); struct LexerState { /* This is, in fact, parser state. Not used in lexer itself */ DSQL_FLD g_field; - FIL g_file; + FIL g_file; DSQL_NOD g_field_name; SSHORT log_defined, cache_defined; int dsql_debug; @@ -5164,9 +5164,9 @@ void LEX_dsql_init (void) void LEX_string ( - TEXT *string, - USHORT length, - SSHORT character_set) + TEXT *string, + USHORT length, + SSHORT character_set) { /************************************** * @@ -5179,12 +5179,12 @@ void LEX_string ( * **************************************/ - lex.line_start = lex.ptr = string; - lex.end = string + length; - lex.lines = 1; - lex.att_charset = character_set; - lex.line_start_bk = lex.line_start; - lex.lines_bk = lex.lines; + lex.line_start = lex.ptr = string; + lex.end = string + length; + lex.lines = 1; + lex.att_charset = character_set; + lex.line_start_bk = lex.line_start; + lex.lines_bk = lex.lines; lex.param_number = 1; lex.prev_keyword = -1; lex.prev_prev_keyword = -1; @@ -5192,8 +5192,8 @@ void LEX_string ( lex.first_detection = false; lex.brace_analysis = false; #ifdef DEV_BUILD - if (DSQL_debug & 32) - printf("%.*s\n", (int)length, string); + if (DSQL_debug & 32) + printf("%.*s\n", (int)length, string); #endif } @@ -5211,23 +5211,23 @@ static void check_log_file_attrs (void) * *********************************************/ - if (lex.g_file->fil_partitions) { - if (!lex.g_file->fil_length) { - yyabandon (-261, isc_log_length_spec); - /* Total length of a partitioned log must be specified */ - } - - if (PARTITION_SIZE (OneK * lex.g_file->fil_length, lex.g_file->fil_partitions) < - (OneK*MIN_LOG_LENGTH)) { - yyabandon (-239, isc_partition_too_small); - /* Log partition size too small */ - } - } - else { - if ((lex.g_file->fil_length) && (lex.g_file->fil_length < MIN_LOG_LENGTH)) { - yyabandon (-239, isc_log_too_small); /* Log size too small */ - } - } + if (lex.g_file->fil_partitions) { + if (!lex.g_file->fil_length) { + yyabandon (-261, isc_log_length_spec); + /* Total length of a partitioned log must be specified */ + } + + if (PARTITION_SIZE (OneK * lex.g_file->fil_length, lex.g_file->fil_partitions) < + (OneK*MIN_LOG_LENGTH)) { + yyabandon (-239, isc_partition_too_small); + /* Log partition size too small */ + } + } + else { + if ((lex.g_file->fil_length) && (lex.g_file->fil_length < MIN_LOG_LENGTH)) { + yyabandon (-239, isc_log_too_small); /* Log size too small */ + } + } } @@ -5245,14 +5245,13 @@ static TEXT *lex_position (void) * **************************************/ -return lex.ptr; + return lex.ptr; } #ifdef NOT_USED_OR_REPLACED -static BOOLEAN long_int ( - DSQL_NOD string, - SLONG *long_value) +static bool long_int(DSQL_NOD string, + SLONG *long_value) { /************************************* * @@ -5269,18 +5268,17 @@ static BOOLEAN long_int ( for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) { if (!(classes [*p] & CHR_DIGIT)) { - return FALSE; + return false; } } *long_value = atol ((char *)((STR) string)->str_data); - return TRUE; + return true; } #endif -static DSQL_FLD make_field ( - DSQL_NOD field_name) +static DSQL_FLD make_field (DSQL_NOD field_name) { /************************************** * @@ -5292,23 +5290,23 @@ static DSQL_FLD make_field ( * Make a field block of given name. * **************************************/ -DSQL_FLD field; -STR string; -TSQL tdsql; + DSQL_FLD field; + STR string; + TSQL tdsql; -tdsql = GET_THREAD_DATA; - -if (field_name == NULL) - { - field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; - strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); - return field; - } -string = (STR) field_name->nod_arg [1]; -field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; -strcpy (field->fld_name, (TEXT*) string->str_data); + tdsql = GET_THREAD_DATA; -return field; + if (field_name == NULL) + { + field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; + strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); + return field; + } + string = (STR) field_name->nod_arg [1]; + field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; + strcpy (field->fld_name, (TEXT*) string->str_data); + + return field; } @@ -5324,19 +5322,18 @@ static FIL make_file (void) * Make a file block * **************************************/ -FIL temp_file; -TSQL tdsql; + FIL temp_file; + TSQL tdsql; -tdsql = GET_THREAD_DATA; - -temp_file = FB_NEW(*tdsql->tsql_default) fil; + tdsql = GET_THREAD_DATA; + + temp_file = FB_NEW(*tdsql->tsql_default) fil; -return temp_file; + return temp_file; } -static DSQL_NOD make_list ( - DSQL_NOD node) +static DSQL_NOD make_list (DSQL_NOD node) { /************************************** * @@ -5348,33 +5345,33 @@ static DSQL_NOD make_list ( * Collapse nested list nodes into single list. * **************************************/ -DSQL_NOD *ptr; -DLLS stack, temp; -USHORT l; -DSQL_NOD old; -TSQL tdsql; + DSQL_NOD *ptr; + DLLS stack, temp; + USHORT l; + DSQL_NOD old; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -if (!node) - return node; + if (!node) + return node; -stack = 0; -stack_nodes (node, &stack); -for (l = 0, temp = stack; temp; temp = temp->lls_next) - l++; + stack = 0; + stack_nodes (node, &stack); + for (l = 0, temp = stack; temp; temp = temp->lls_next) + l++; -old = node; -node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; -node->nod_count = l; -node->nod_type = nod_list; -node->nod_flags = old->nod_flags; -ptr = node->nod_arg + node->nod_count; + old = node; + node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; + node->nod_count = l; + node->nod_type = nod_list; + node->nod_flags = old->nod_flags; + ptr = node->nod_arg + node->nod_count; -while (stack) - *--ptr = (DSQL_NOD) LLS_POP (&stack); + while (stack) + *--ptr = (DSQL_NOD) LLS_POP (&stack); -return node; + return node; } @@ -5391,26 +5388,25 @@ static DSQL_NOD make_parameter (void) * Any change should also be made to function below * **************************************/ -DSQL_NOD node; -TSQL tdsql; + DSQL_NOD node; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; -node->nod_type = nod_parameter; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = 1; -node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; + node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; + node->nod_type = nod_parameter; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = 1; + node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; -return node; + return node; } -static DSQL_NOD make_node ( - NOD_TYPE type, - int count, - ...) +static DSQL_NOD make_node (NOD_TYPE type, + int count, + ...) { /************************************** * @@ -5423,32 +5419,31 @@ static DSQL_NOD make_node ( * Any change should also be made to function below * **************************************/ -DSQL_NOD node, *p; -va_list ptr; -TSQL tdsql; + DSQL_NOD node, *p; + va_list ptr; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; -node->nod_type = type; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = count; -p = node->nod_arg; -VA_START (ptr, count); + node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; + node->nod_type = type; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = count; + p = node->nod_arg; + VA_START (ptr, count); -while (--count >= 0) - *p++ = va_arg (ptr, DSQL_NOD); + while (--count >= 0) + *p++ = va_arg (ptr, DSQL_NOD); -return node; + return node; } -static DSQL_NOD make_flag_node ( - NOD_TYPE type, - SSHORT flag, - int count, - ...) +static DSQL_NOD make_flag_node (NOD_TYPE type, + SSHORT flag, + int count, + ...) { /************************************** * @@ -5460,25 +5455,25 @@ static DSQL_NOD make_flag_node ( * Make a node of given type. Set flag field * **************************************/ -DSQL_NOD node, *p; -va_list ptr; -TSQL tdsql; + DSQL_NOD node, *p; + va_list ptr; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; -node->nod_type = type; -node->nod_flags = flag; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = count; -p = node->nod_arg; -VA_START (ptr, count); + node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; + node->nod_type = type; + node->nod_flags = flag; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = count; + p = node->nod_arg; + VA_START (ptr, count); -while (--count >= 0) - *p++ = va_arg (ptr, DSQL_NOD); + while (--count >= 0) + *p++ = va_arg (ptr, DSQL_NOD); -return node; + return node; } @@ -5497,35 +5492,34 @@ static void prepare_console_debug (int level, int *yydeb) * *************************************/ #if defined(DEV_BUILD) - DSQL_debug = level; + DSQL_debug = level; #endif - if (level >> 8) - *yydeb = level >> 8; - /* CVC: I added this code form Mike Nordell to see the output from internal - operations that's generated in DEV build when DEBUG is typed into isql.exe. - When n>0, the output console is activated; otherwise it's closed. */ + if (level >> 8) + *yydeb = level >> 8; + /* CVC: I added this code form Mike Nordell to see the output from internal + operations that's generated in DEV build when DEBUG is typed into isql.exe. + When n>0, the output console is activated; otherwise it's closed. */ #if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER) -static FILE* redirected_output; - if (level > 0) { - /* Console debug code inside this scope */ - if (AllocConsole()) { - redirected_output = freopen("CONOUT$", "wt", stdout); - printf("DebugConsole - Yes, it's working.\n"); - } - } - else if (level <= 0 && redirected_output) { - fclose (redirected_output); - redirected_output = 0; - FreeConsole(); - } + static FILE* redirected_output; + if (level > 0) { + /* Console debug code inside this scope */ + if (AllocConsole()) { + redirected_output = freopen("CONOUT$", "wt", stdout); + printf("DebugConsole - Yes, it's working.\n"); + } + } + else if (level <= 0 && redirected_output) { + fclose (redirected_output); + redirected_output = 0; + FreeConsole(); + } #endif } #ifdef NOT_USED_OR_REPLACED -static BOOLEAN short_int ( - DSQL_NOD string, - SLONG *long_value, - SSHORT range) +static bool short_int(DSQL_NOD string, + SLONG *long_value, + SSHORT range) { /************************************* * @@ -5540,20 +5534,20 @@ static BOOLEAN short_int ( *************************************/ if (((STR) string)->str_length > 5) { - return FALSE; + return false; } for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) { if (!(classes [*p] & CHR_DIGIT)) { - return FALSE; + return false; } } /* there are 5 or fewer digits, it's value may still be greater * than 32767... */ - SCHAR buf[10]; + SCHAR buf[10]; buf [0] = ((STR) string)->str_data[0]; buf [1] = ((STR) string)->str_data[1]; buf [2] = ((STR) string)->str_data[2]; @@ -5563,27 +5557,26 @@ static BOOLEAN short_int ( *long_value = atoi (buf); - BOOLEAN return_value; + bool return_value; switch (range) { case POSITIVE: - return_value = *long_value > SHRT_POS_MAX; + return_value = *long_value > SHRT_POS_MAX; break; case NEGATIVE: return_value = *long_value > SHRT_NEG_MAX; break; case UNSIGNED: - return_value = *long_value > SHRT_UNSIGNED_MAX; + return_value = *long_value > SHRT_UNSIGNED_MAX; break; } return !return_value; } #endif -static void stack_nodes ( - DSQL_NOD node, - DLLS *stack) +static void stack_nodes (DSQL_NOD node, + DLLS *stack) { /************************************** * @@ -5595,78 +5588,78 @@ static void stack_nodes ( * Assist in turning a tree of misc nodes into a clean list. * **************************************/ -DSQL_NOD *ptr, *end; -DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; + DSQL_NOD *ptr, *end; + DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; -if (node->nod_type != nod_list) - { - LLS_PUSH (node, stack); - return; - } + if (node->nod_type != nod_list) + { + LLS_PUSH (node, stack); + return; + } -/* To take care of cases where long lists of nodes are in a chain - of list nodes with exactly one entry, this algorithm will look - for a pattern of repeated list nodes with two entries, the first - being a list node and the second being a non-list node. Such - a list will be reverse linked, and then re-reversed, stacking the - non-list nodes in the process. The purpose of this is to avoid - massive recursion of this function. */ + /* To take care of cases where long lists of nodes are in a chain + of list nodes with exactly one entry, this algorithm will look + for a pattern of repeated list nodes with two entries, the first + being a list node and the second being a non-list node. Such + a list will be reverse linked, and then re-reversed, stacking the + non-list nodes in the process. The purpose of this is to avoid + massive recursion of this function. */ -start_chain = node; -end_chain = NULL; -curr_node = node; -next_node = node->nod_arg[0]; -while ( curr_node->nod_count == 2 && - curr_node->nod_arg[0]->nod_type == nod_list && - curr_node->nod_arg[1]->nod_type != nod_list && - next_node->nod_arg[0]->nod_type == nod_list && - next_node->nod_arg[1]->nod_type != nod_list) - { + start_chain = node; + end_chain = NULL; + curr_node = node; + next_node = node->nod_arg[0]; + while ( curr_node->nod_count == 2 && + curr_node->nod_arg[0]->nod_type == nod_list && + curr_node->nod_arg[1]->nod_type != nod_list && + next_node->nod_arg[0]->nod_type == nod_list && + next_node->nod_arg[1]->nod_type != nod_list) + { - /* pattern was found so reverse the links and go to next node */ + /* pattern was found so reverse the links and go to next node */ - save_link = next_node->nod_arg[0]; - next_node->nod_arg[0] = curr_node; - curr_node = next_node; - next_node = save_link; - end_chain = curr_node; - } + save_link = next_node->nod_arg[0]; + next_node->nod_arg[0] = curr_node; + curr_node = next_node; + next_node = save_link; + end_chain = curr_node; + } -/* see if any chain was found */ + /* see if any chain was found */ -if ( end_chain) - { + if ( end_chain) + { - /* first, handle the rest of the nodes */ - /* note that next_node still points to the first non-pattern node */ + /* first, handle the rest of the nodes */ + /* note that next_node still points to the first non-pattern node */ - stack_nodes( next_node, stack); + stack_nodes( next_node, stack); - /* stack the non-list nodes and reverse the chain on the way back */ - - curr_node = end_chain; - while ( TRUE) - { - LLS_PUSH( curr_node->nod_arg[1], stack); - if ( curr_node == start_chain) - break; - save_link = curr_node->nod_arg[0]; - curr_node->nod_arg[0] = next_node; - next_node = curr_node; - curr_node = save_link; - } - return; - } + /* stack the non-list nodes and reverse the chain on the way back */ + + curr_node = end_chain; + while (true) + { + LLS_PUSH( curr_node->nod_arg[1], stack); + if ( curr_node == start_chain) + break; + save_link = curr_node->nod_arg[0]; + curr_node->nod_arg[0] = next_node; + next_node = curr_node; + curr_node = save_link; + } + return; + } -for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) - stack_nodes (*ptr, stack); + for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) + stack_nodes (*ptr, stack); } inline static int yylex ( - USHORT client_dialect, - USHORT db_dialect, - USHORT parser_version, - BOOLEAN *stmt_ambiguous) + USHORT client_dialect, + USHORT db_dialect, + USHORT parser_version, + BOOLEAN *stmt_ambiguous) { int temp = lex.yylex(client_dialect, db_dialect, parser_version, stmt_ambiguous); lex.prev_prev_keyword = lex.prev_keyword; @@ -5675,10 +5668,10 @@ inline static int yylex ( } int LexerState::yylex ( - USHORT client_dialect, - USHORT db_dialect, - USHORT parser_version, - BOOLEAN *stmt_ambiguous) + USHORT client_dialect, + USHORT db_dialect, + USHORT parser_version, + BOOLEAN *stmt_ambiguous) { /************************************** * @@ -5689,179 +5682,179 @@ int LexerState::yylex ( * Functional description: lexer. * **************************************/ -UCHAR tok_class; -char string[MAX_TOKEN_LEN]; -char* p; -char* buffer; -char* buffer_end; -char* new_buffer; -SYM sym; -SSHORT c; -USHORT buffer_len; + UCHAR tok_class; + char string[MAX_TOKEN_LEN]; + char* p; + char* buffer; + char* buffer_end; + char* new_buffer; + SYM sym; + SSHORT c; + USHORT buffer_len; -STR delimited_id_str; + STR delimited_id_str; -/* Find end of white space and skip comments */ + /* Find end of white space and skip comments */ -for (;;) - { - if (ptr >= end) - return -1; - - c = *ptr++; - - /* Process comments */ - - if (c == '\n') { - lines++; - line_start = ptr; - continue; - } - - if ((c == '-') && (*ptr == '-')) { - - /* single-line */ - - ptr++; - while (ptr < end) { - if ((c = *ptr++) == '\n') { - lines++; - line_start = ptr /* + 1*/; /* CVC: +1 left out. */ - break; - } - } + for (;;) + { if (ptr >= end) return -1; - continue; - } - else if ((c == '/') && (*ptr == '*')) { - - /* multi-line */ - - ptr++; - while (ptr < end) { - if ((c = *ptr++) == '*') { - if (*ptr == '/') + + c = *ptr++; + + /* Process comments */ + + if (c == '\n') { + lines++; + line_start = ptr; + continue; + } + + if ((c == '-') && (*ptr == '-')) { + + /* single-line */ + + ptr++; + while (ptr < end) { + if ((c = *ptr++) == '\n') { + lines++; + line_start = ptr /* + 1*/; /* CVC: +1 left out. */ break; + } } - if (c == '\n') { - lines++; - line_start = ptr /* + 1*/; /* CVC: +1 left out. */ + if (ptr >= end) + return -1; + continue; + } + else if ((c == '/') && (*ptr == '*')) { + + /* multi-line */ + + ptr++; + while (ptr < end) { + if ((c = *ptr++) == '*') { + if (*ptr == '/') + break; + } + if (c == '\n') { + lines++; + line_start = ptr /* + 1*/; /* CVC: +1 left out. */ + } } - } + if (ptr >= end) + return -1; + ptr++; + continue; + } + + tok_class = classes [c]; + + if (!(tok_class & CHR_WHITE)) + break; + } + + /* Depending on tok_class of token, parse token */ + + last_token = ptr - 1; + + if (tok_class & CHR_INTRODUCER) + { + /* The Introducer (_) is skipped, all other idents are copied + * to become the name of the character set + */ + p = string; + for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) + { if (ptr >= end) return -1; - ptr++; - continue; - } - - tok_class = classes [c]; - - if (!(tok_class & CHR_WHITE)) - break; - } - -/* Depending on tok_class of token, parse token */ - -last_token = ptr - 1; - -if (tok_class & CHR_INTRODUCER) - { - /* The Introducer (_) is skipped, all other idents are copied - * to become the name of the character set - */ - p = string; - for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) - { - if (ptr >= end) - return -1; - CHECK_COPY_INCR(p, UPPER7(*ptr)); - } - - CHECK_BOUND(p); - *p = 0; - - /* make a string value to hold the name, the name - * is resolved in pass1_constant */ - - yylval = (DSQL_NOD) (MAKE_string(string, p - string))->str_data; - - return INTRODUCER; - } - -/* parse a quoted string, being sure to look for double quotes */ - -if (tok_class & CHR_QUOTE) - { - buffer = string; - buffer_len = sizeof (string); - buffer_end = buffer + buffer_len - 1; - for (p = buffer; ; p++) - { - if (ptr >= end) - { - if (buffer != string) - gds__free (buffer); - return -1; - } - /* *ptr is quote - if next != quote we're at the end */ - if ((*ptr == c) && ((++ptr == end) || (*ptr != c))) - break; - if (p > buffer_end) - { - new_buffer = (char*)gds__alloc (2 * buffer_len); - /* FREE: at outer block */ - if (!new_buffer) /* NOMEM: */ - { - if (buffer != string) - gds__free (buffer); - return -1; + CHECK_COPY_INCR(p, UPPER7(*ptr)); } - memcpy (new_buffer, buffer, buffer_len); - if (buffer != string) - gds__free (buffer); - buffer = new_buffer; - p = buffer + buffer_len; - buffer_len = 2 * buffer_len; - buffer_end = buffer + buffer_len - 1; - } - *p = *ptr++; - } - if (c == '"') - { - *stmt_ambiguous = TRUE; /* string delimited by double quotes could be - ** either a string constant or a SQL delimited - ** identifier, therefore marks the SQL - ** statement as ambiguous */ - if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - if (buffer != string) - gds__free (buffer); - yyabandon (-104, isc_invalid_string_constant); - } - else if (client_dialect >= SQL_DIALECT_V6) - { - if ((p - buffer) >= MAX_TOKEN_LEN) - { - if (buffer != string) - gds__free (buffer); - yyabandon (-104, isc_token_too_long); + + CHECK_BOUND(p); + *p = 0; + + /* make a string value to hold the name, the name + * is resolved in pass1_constant */ + + yylval = (DSQL_NOD) (MAKE_string(string, p - string))->str_data; + + return INTRODUCER; } - yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); - delimited_id_str = (STR) yylval; - delimited_id_str->str_flags |= STR_delimited_id; - if (buffer != string) + + /* parse a quoted string, being sure to look for double quotes */ + + if (tok_class & CHR_QUOTE) + { + buffer = string; + buffer_len = sizeof (string); + buffer_end = buffer + buffer_len - 1; + for (p = buffer; ; p++) + { + if (ptr >= end) + { + if (buffer != string) + gds__free (buffer); + return -1; + } + /* *ptr is quote - if next != quote we're at the end */ + if ((*ptr == c) && ((++ptr == end) || (*ptr != c))) + break; + if (p > buffer_end) + { + new_buffer = (char*)gds__alloc (2 * buffer_len); + /* FREE: at outer block */ + if (!new_buffer) /* NOMEM: */ + { + if (buffer != string) + gds__free (buffer); + return -1; + } + memcpy (new_buffer, buffer, buffer_len); + if (buffer != string) + gds__free (buffer); + buffer = new_buffer; + p = buffer + buffer_len; + buffer_len = 2 * buffer_len; + buffer_end = buffer + buffer_len - 1; + } + *p = *ptr++; + } + if (c == '"') + { + *stmt_ambiguous = TRUE; /* string delimited by double quotes could be + ** either a string constant or a SQL delimited + ** identifier, therefore marks the SQL + ** statement as ambiguous */ + if (client_dialect == SQL_DIALECT_V6_TRANSITION) + { + if (buffer != string) + gds__free (buffer); + yyabandon (-104, isc_invalid_string_constant); + } + else if (client_dialect >= SQL_DIALECT_V6) + { + if ((p - buffer) >= MAX_TOKEN_LEN) + { + if (buffer != string) + gds__free (buffer); + yyabandon (-104, isc_token_too_long); + } + yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); + delimited_id_str = (STR) yylval; + delimited_id_str->str_flags |= STR_delimited_id; + if (buffer != string) + gds__free (buffer); + return SYMBOL; + } + } + yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); + if (buffer != string) gds__free (buffer); - return SYMBOL; - } - } - yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); - if (buffer != string) - gds__free (buffer); - return STRING; - } - + return STRING; + } + /* * Check for a numeric constant, which starts either with a digit or with * a decimal point followed by a digit. @@ -5888,344 +5881,344 @@ if (tok_class & CHR_QUOTE) * ptr points to the next character. */ -assert(ptr <= end); + assert(ptr <= end); -if ((tok_class & CHR_DIGIT) || - ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) - { - /* The following variables are used to recognize kinds of numbers. */ - - BOOLEAN have_error = FALSE; /* syntax error or value too large */ - BOOLEAN have_digit = FALSE; /* we've seen a digit */ - BOOLEAN have_decimal = FALSE; /* we've seen a '.' */ - BOOLEAN have_exp = FALSE; /* digit ... [eE] */ - BOOLEAN have_exp_sign = FALSE; /* digit ... [eE] {+-] */ - BOOLEAN have_exp_digit = FALSE; /* digit ... [eE] ... digit */ - UINT64 number = 0; - UINT64 limit_by_10 = MAX_SINT64 / 10; - - for (--ptr ; ptr < end ; ptr++) - { - c = *ptr; - if (have_exp_digit && (! (classes [c] & CHR_DIGIT))) - /* First non-digit after exponent and digit terminates - the token. */ - break; - else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) - { - /* only digits can be accepted after "1E-" */ - have_error = TRUE; - break; - } - else if (have_exp) - { - /* We've seen e or E, but nothing beyond that. */ - if ( ('-' == c) || ('+' == c) ) - have_exp_sign = TRUE; - else if ( classes [c] & CHR_DIGIT ) - /* We have a digit: we haven't seen a sign yet, - but it's too late now. */ - have_exp_digit = have_exp_sign = TRUE; - else - { - /* end of the token */ - have_error = TRUE; - break; - } - } - else if ('.' == c) - { - if (!have_decimal) - have_decimal = TRUE; - else - { - have_error = TRUE; - break; - } - } - else if (classes [c] & CHR_DIGIT) - { - /* Before computing the next value, make sure there will be - no overflow. */ - - have_digit = TRUE; - - if (number >= limit_by_10) - /* possibility of an overflow */ - if ((number > limit_by_10) || (c > '8')) - { - have_error = TRUE; - break; - } - number = number * 10 + (c - '0'); - } - else if ( (('E' == c) || ('e' == c)) && have_digit ) - have_exp = TRUE; - else - /* Unexpected character: this is the end of the number. */ - break; - } - - /* We're done scanning the characters: now return the right kind - of number token, if any fits the bill. */ - - if (!have_error) + if ((tok_class & CHR_DIGIT) || + ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) { - assert(have_digit); + /* The following variables are used to recognize kinds of numbers. */ - if (have_exp_digit) - { - yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; + bool have_error = false; /* syntax error or value too large */ + bool have_digit = false; /* we've seen a digit */ + bool have_decimal = false; /* we've seen a '.' */ + bool have_exp = false; /* digit ... [eE] */ + bool have_exp_sign = false; /* digit ... [eE] {+-] */ + bool have_exp_digit = false; /* digit ... [eE] ... digit */ + UINT64 number = 0; + UINT64 limit_by_10 = MAX_SINT64 / 10; - return FLOAT_NUMBER; - } - else if (!have_exp) - { - - /* We should return some kind (scaled-) integer type - except perhaps in dialect 1. */ - - if (!have_decimal && (number <= MAX_SLONG)) + for (--ptr ; ptr < end ; ptr++) { - yylval = (DSQL_NOD) (ULONG) number; - return NUMBER; - } - else - { - /* We have either a decimal point with no exponent - or a string of digits whose value exceeds MAX_SLONG: - the returned type depends on the client dialect, - so warn of the difference if the client dialect is - SQL_DIALECT_V6_TRANSITION. - */ - - if (SQL_DIALECT_V6_TRANSITION == client_dialect) - { - /* Issue a warning about the ambiguity of the numeric - * numeric literal. There are multiple calls because - * the message text exceeds the 119-character limit - * of our message database. - */ - ERRD_post_warning( isc_dsql_warning_number_ambiguous, - gds_arg_string, - ERR_string( last_token, - ptr - last_token ), - gds_arg_end ); - ERRD_post_warning( isc_dsql_warning_number_ambiguous1, - gds_arg_end ); - } - - yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); - - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - - if (client_dialect < SQL_DIALECT_V6_TRANSITION) - return FLOAT_NUMBER; - else if (have_decimal) - return SCALEDINT; - else - return NUMBER64BIT; - } - } /* else if (!have_exp) */ - } /* if (!have_error) */ - - /* we got some kind of error or overflow, so don't recognize this - * as a number: just pass it through to the next part of the lexer. - */ - } - -/* Restore the status quo ante, before we started our unsuccessful - attempt to recognize a number. */ -ptr = last_token; -c = *ptr++; -/* We never touched tok_class, so it doesn't need to be restored. */ - -/* end of number-recognition code */ - - -if (tok_class & CHR_LETTER) -{ - p = string; - CHECK_COPY_INCR(p, UPPER (c)); - for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) - { - if (ptr >= end) - return -1; - CHECK_COPY_INCR(p, UPPER (*ptr)); - } - - CHECK_BOUND(p); - *p = 0; - sym = HSHD_lookup (NULL, (TEXT *) string, (SSHORT)(p - string), SYM_keyword, parser_version); - if (sym) - { - /* 13 June 2003. Nickolay Samofatov - * Detect INSERTING/UPDATING/DELETING as non-reserved keywords. - * We need to help parser from lexer because our grammar is not LARL(1) in this case - */ - if (prev_keyword == '(' && !brace_analysis && - (sym->sym_keyword == INSERTING || - sym->sym_keyword == UPDATING || - sym->sym_keyword == DELETING - ) && - /* Produce special_trigger_action_predicate only where we can handle it - - in search conditions */ - (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || - prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || - prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) - { - LexerState savedState = lex; - int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - lex = savedState; - if (nextToken==OR || nextToken==AND) { - switch(sym->sym_keyword) { - case INSERTING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_INSERTING; - case UPDATING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_UPDATING; - case DELETING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_DELETING; + c = *ptr; + if (have_exp_digit && (! (classes [c] & CHR_DIGIT))) + /* First non-digit after exponent and digit terminates + the token. */ + break; + else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) + { + /* only digits can be accepted after "1E-" */ + have_error = true; + break; + } + else if (have_exp) + { + /* We've seen e or E, but nothing beyond that. */ + if ( ('-' == c) || ('+' == c) ) + have_exp_sign = true; + else if ( classes [c] & CHR_DIGIT ) + /* We have a digit: we haven't seen a sign yet, + but it's too late now. */ + have_exp_digit = have_exp_sign = true; + else + { + /* end of the token */ + have_error = true; + break; } } - } - /* 23 May 2003. Nickolay Samofatov - * Detect FIRST/SKIP as non-reserved keywords - * 1. We detect FIRST or SKIP as keywords if they appear just after SELECT and - * immediately before parameter mark ('?'), opening brace ('(') or number - * 2. We detect SKIP as a part of FIRST/SKIP clause the same way - * 3. We detect FIRST if we are explicitly asked for (such as in NULLS FIRST/LAST clause) - * 4. In all other cases we return them as SYMBOL - */ - if ((sym->sym_keyword == FIRST && !first_detection) || sym->sym_keyword == SKIP) { - if (prev_keyword == SELECT || limit_clause) { - LexerState savedState = lex; - int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - lex = savedState; - if (nextToken != NUMBER && nextToken != '?' && nextToken != '(') { - yylval = (DSQL_NOD) MAKE_string(string, p - string); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return SYMBOL; - } else { - yylval = (DSQL_NOD) sym->sym_object; - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return sym->sym_keyword; + else if ('.' == c) + { + if (!have_decimal) + have_decimal = true; + else + { + have_error = true; + break; } - } /* else fall down and return token as SYMBOL */ - } else { - yylval = (DSQL_NOD) sym->sym_object; - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return sym->sym_keyword; + } + else if (classes [c] & CHR_DIGIT) + { + /* Before computing the next value, make sure there will be + no overflow. */ + + have_digit = true; + + if (number >= limit_by_10) + /* possibility of an overflow */ + if ((number > limit_by_10) || (c > '8')) + { + have_error = true; + break; + } + number = number * 10 + (c - '0'); + } + else if ( (('E' == c) || ('e' == c)) && have_digit ) + have_exp = true; + else + /* Unexpected character: this is the end of the number. */ + break; } - } - yylval = (DSQL_NOD) MAKE_string(string, p - string); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return SYMBOL; -} -/* Must be punctuation -- test for double character punctuation */ + /* We're done scanning the characters: now return the right kind + of number token, if any fits the bill. */ -if (last_token + 1 < end) - { - sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); - if (sym) - { - ++ptr; - return sym->sym_keyword; - } - } - -/* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ -/* This algorithm is not perfect, but it is ok for now. - It should be dropped when BOOLEAN datatype is introduced in Firebird */ -if ( c == '(' && !brace_analysis && - /* 1) We need to swallow braces in all boolean expressions - 2) We may swallow braces in ordinary expressions - 3) We should not swallow braces after special tokens - like IF, FIRST, SKIP, VALUES and 30 more other - */ - (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || - prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) -{ - LexerState savedState = lex; - brace_analysis = true; - int openCount = 0; - int nextToken; - do { - openCount++; - nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - } while (nextToken == '('); - DSQL_NOD temp_val = yylval; - if (nextToken == INSERTING || nextToken == UPDATING || nextToken == DELETING) - { - /* Skip closing braces. */ - while ( openCount && - yylex(client_dialect,db_dialect, - parser_version,stmt_ambiguous) == ')') + if (!have_error) { - openCount--; + assert(have_digit); + + if (have_exp_digit) + { + yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + + return FLOAT_NUMBER; + } + else if (!have_exp) + { + + /* We should return some kind (scaled-) integer type + except perhaps in dialect 1. */ + + if (!have_decimal && (number <= MAX_SLONG)) + { + yylval = (DSQL_NOD) (ULONG) number; + return NUMBER; + } + else + { + /* We have either a decimal point with no exponent + or a string of digits whose value exceeds MAX_SLONG: + the returned type depends on the client dialect, + so warn of the difference if the client dialect is + SQL_DIALECT_V6_TRANSITION. + */ + + if (SQL_DIALECT_V6_TRANSITION == client_dialect) + { + /* Issue a warning about the ambiguity of the numeric + * numeric literal. There are multiple calls because + * the message text exceeds the 119-character limit + * of our message database. + */ + ERRD_post_warning( isc_dsql_warning_number_ambiguous, + gds_arg_string, + ERR_string( last_token, + ptr - last_token ), + gds_arg_end ); + ERRD_post_warning( isc_dsql_warning_number_ambiguous1, + gds_arg_end ); + } + + yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); + + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + + if (client_dialect < SQL_DIALECT_V6_TRANSITION) + return FLOAT_NUMBER; + else if (have_decimal) + return SCALEDINT; + else + return NUMBER64BIT; + } + } /* else if (!have_exp) */ + } /* if (!have_error) */ + + /* we got some kind of error or overflow, so don't recognize this + * as a number: just pass it through to the next part of the lexer. + */ + } + + /* Restore the status quo ante, before we started our unsuccessful + attempt to recognize a number. */ + ptr = last_token; + c = *ptr++; + /* We never touched tok_class, so it doesn't need to be restored. */ + + /* end of number-recognition code */ + + + if (tok_class & CHR_LETTER) + { + p = string; + CHECK_COPY_INCR(p, UPPER (c)); + for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) + { + if (ptr >= end) + return -1; + CHECK_COPY_INCR(p, UPPER (*ptr)); } - if (openCount) { - /* Not enough closing braces. Restore status quo. */ - lex = savedState; - } - else { - /* Cool! We successfully swallowed braces ! */ - brace_analysis = false; - yylval = temp_val; - /* Check if we need to handle LR(2) grammar case */ - if (prev_keyword == '(' && + + CHECK_BOUND(p); + *p = 0; + sym = HSHD_lookup (NULL, (TEXT *) string, (SSHORT)(p - string), SYM_keyword, parser_version); + if (sym) + { + /* 13 June 2003. Nickolay Samofatov + * Detect INSERTING/UPDATING/DELETING as non-reserved keywords. + * We need to help parser from lexer because our grammar is not LARL(1) in this case + */ + if (prev_keyword == '(' && !brace_analysis && + (sym->sym_keyword == INSERTING || + sym->sym_keyword == UPDATING || + sym->sym_keyword == DELETING + ) && /* Produce special_trigger_action_predicate only where we can handle it - in search conditions */ (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) { - savedState = lex; - int token = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + LexerState savedState = lex; + int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); lex = savedState; - if (token==OR || token==AND) { - switch(nextToken) { + if (nextToken==OR || nextToken==AND) { + switch(sym->sym_keyword) { case INSERTING: + yylval = (DSQL_NOD) sym->sym_object; return KW_INSERTING; case UPDATING: + yylval = (DSQL_NOD) sym->sym_object; return KW_UPDATING; case DELETING: + yylval = (DSQL_NOD) sym->sym_object; return KW_DELETING; } } } - return nextToken; + /* 23 May 2003. Nickolay Samofatov + * Detect FIRST/SKIP as non-reserved keywords + * 1. We detect FIRST or SKIP as keywords if they appear just after SELECT and + * immediately before parameter mark ('?'), opening brace ('(') or number + * 2. We detect SKIP as a part of FIRST/SKIP clause the same way + * 3. We detect FIRST if we are explicitly asked for (such as in NULLS FIRST/LAST clause) + * 4. In all other cases we return them as SYMBOL + */ + if ((sym->sym_keyword == FIRST && !first_detection) || sym->sym_keyword == SKIP) { + if (prev_keyword == SELECT || limit_clause) { + LexerState savedState = lex; + int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + lex = savedState; + if (nextToken != NUMBER && nextToken != '?' && nextToken != '(') { + yylval = (DSQL_NOD) MAKE_string(string, p - string); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return SYMBOL; + } else { + yylval = (DSQL_NOD) sym->sym_object; + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return sym->sym_keyword; + } + } /* else fall down and return token as SYMBOL */ + } else { + yylval = (DSQL_NOD) sym->sym_object; + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return sym->sym_keyword; + } } - } else { - /* Restore status quo. */ - lex = savedState; + yylval = (DSQL_NOD) MAKE_string(string, p - string); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return SYMBOL; } -} -/* Single character punctuation are simply passed on */ + /* Must be punctuation -- test for double character punctuation */ -return c; + if (last_token + 1 < end) + { + sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); + if (sym) + { + ++ptr; + return sym->sym_keyword; + } + } + + /* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ + /* This algorithm is not perfect, but it is ok for now. + It should be dropped when BOOLEAN datatype is introduced in Firebird */ + if ( c == '(' && !brace_analysis && + /* 1) We need to swallow braces in all boolean expressions + 2) We may swallow braces in ordinary expressions + 3) We should not swallow braces after special tokens + like IF, FIRST, SKIP, VALUES and 30 more other + */ + (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || + prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) + { + LexerState savedState = lex; + brace_analysis = true; + int openCount = 0; + int nextToken; + do { + openCount++; + nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + } while (nextToken == '('); + DSQL_NOD temp_val = yylval; + if (nextToken == INSERTING || nextToken == UPDATING || nextToken == DELETING) + { + /* Skip closing braces. */ + while ( openCount && + yylex(client_dialect,db_dialect, + parser_version,stmt_ambiguous) == ')') + { + openCount--; + } + if (openCount) { + /* Not enough closing braces. Restore status quo. */ + lex = savedState; + } + else { + /* Cool! We successfully swallowed braces ! */ + brace_analysis = false; + yylval = temp_val; + /* Check if we need to handle LR(2) grammar case */ + if (prev_keyword == '(' && + /* Produce special_trigger_action_predicate only where we can handle it - + in search conditions */ + (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || + prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || + prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) + { + savedState = lex; + int token = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + lex = savedState; + if (token==OR || token==AND) { + switch(nextToken) { + case INSERTING: + return KW_INSERTING; + case UPDATING: + return KW_UPDATING; + case DELETING: + return KW_DELETING; + } + } + } + return nextToken; + } + } else { + /* Restore status quo. */ + lex = savedState; + } + } + + /* Single character punctuation are simply passed on */ + + return c; } static void yyerror ( - TEXT *error_string) + TEXT *error_string) { /************************************** * @@ -6238,27 +6231,25 @@ static void yyerror ( * **************************************/ -if (DSQL_yychar < 1) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ - 0); -else - { - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, gds_dsql_token_unk_err, - gds_arg_number, (SLONG) lex.lines, - gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ - /* Token unknown - line %d, char %d */ - gds_arg_gds, gds_random, - gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, - 0); - } + if (DSQL_yychar < 1) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ + 0); + else + { + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, gds_dsql_token_unk_err, + gds_arg_number, (SLONG) lex.lines, + gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ + /* Token unknown - line %d, char %d */ + gds_arg_gds, gds_random, + gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, 0); + } } -static void yyabandon ( - SSHORT sql_code, - ISC_STATUS error_symbol) +static void yyabandon (SSHORT sql_code, + ISC_STATUS error_symbol) { /************************************** * @@ -6271,8 +6262,8 @@ static void yyabandon ( * **************************************/ -ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, - gds_arg_gds, error_symbol, 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, + gds_arg_gds, error_symbol, 0); } #define YYABORT goto yyabort #define YYREJECT goto yyabort @@ -6610,7 +6601,7 @@ case 84: break; case 85: { yyval = make_node (nod_udf_param, (int) e_udf_param_count, - yyvsp[-1], NULL); } + yyvsp[-1], NULL); } break; case 86: { yyval = make_node (nod_udf_param, (int) e_udf_param_count, @@ -6637,7 +6628,7 @@ case 92: break; case 93: { yyval = make_node (nod_udf_return_value, (int) 2, - NULL, MAKE_constant ((STR) yyvsp[0], CONSTANT_SLONG));} + NULL, MAKE_constant ((STR) yyvsp[0], CONSTANT_SLONG));} break; case 94: { yyval = make_node (nod_def_filter, (int) e_filter_count, @@ -6716,7 +6707,7 @@ case 118: break; case 119: { yyval = make_node (nod_def_shadow, (int) e_shadow_count, - yyvsp[-5], yyvsp[-4], yyvsp[-3], yyvsp[-2], yyvsp[-1], make_list (yyvsp[0])); } + yyvsp[-5], yyvsp[-4], yyvsp[-3], yyvsp[-2], yyvsp[-1], make_list (yyvsp[0])); } break; case 120: { yyval = MAKE_constant ((STR) 1, CONSTANT_SLONG); } @@ -6747,7 +6738,7 @@ case 130: break; case 131: { yyval = make_node (nod_def_domain, (int) e_dom_count, - yyvsp[-7], yyvsp[-3], yyvsp[-2], make_list (yyvsp[-1]), yyvsp[0]); } + yyvsp[-7], yyvsp[-3], yyvsp[-2], make_list (yyvsp[-1]), yyvsp[0]); } break; case 132: { yyval = NULL; } @@ -6842,27 +6833,27 @@ case 172: break; case 173: { if (lex.log_defined) - yyabandon (-260, isc_log_redef); /* Log redefined */ + yyabandon (-260, isc_log_redef); /* Log redefined */ lex.log_defined = TRUE; yyval = yyvsp[0]; } break; case 174: { if (lex.log_defined) - yyabandon (-260, isc_log_redef); + yyabandon (-260, isc_log_redef); lex.log_defined = TRUE; yyval = yyvsp[0]; } break; case 175: { lex.g_file->fil_flags |= LOG_serial | LOG_overflow; if (lex.g_file->fil_partitions) - yyabandon (-261, isc_partition_not_supp); + yyabandon (-261, isc_partition_not_supp); /* Partitions not supported in series of log file specification */ yyval = make_node (nod_list, 2, yyvsp[-3], yyvsp[0]); } break; case 176: { lex.g_file->fil_flags |= LOG_serial; if (lex.g_file->fil_partitions) - yyabandon (-261, isc_partition_not_supp); + yyabandon (-261, isc_partition_not_supp); yyval = yyvsp[0]; } break; case 177: @@ -6881,9 +6872,9 @@ case 180: break; case 181: { - check_log_file_attrs(); + check_log_file_attrs(); yyval = (DSQL_NOD) make_node (nod_log_file_desc, (int) 1, - (DSQL_NOD) lex.g_file); } + (DSQL_NOD) lex.g_file); } break; case 182: { lex.g_file = make_file(); @@ -6927,11 +6918,11 @@ case 208: break; case 209: { yyval = make_node (nod_def_field, (int) e_dfl_count, - yyvsp[-2], NULL, NULL, NULL, NULL, NULL, yyvsp[0]); } + yyvsp[-2], NULL, NULL, NULL, NULL, NULL, yyvsp[0]); } break; case 210: { yyval = make_node (nod_def_field, (int) e_dfl_count, - yyvsp[-1], NULL, NULL, NULL, NULL, NULL, yyvsp[0]); } + yyvsp[-1], NULL, NULL, NULL, NULL, NULL, yyvsp[0]); } break; case 211: { @@ -6943,7 +6934,7 @@ case 214: break; case 215: { yyval = make_node (nod_def_domain, (int) e_dom_count, - yyvsp[-1], NULL, NULL, NULL, NULL); } + yyvsp[-1], NULL, NULL, NULL, NULL); } break; case 216: { yyval = yyvsp[0]; } @@ -6996,7 +6987,7 @@ case 235: break; case 236: { yyval = make_node (nod_foreign, e_for_count, - make_node (nod_list, (int) 1, lex.g_field_name), yyvsp[-3], yyvsp[-2], yyvsp[-1], yyvsp[0]); } + make_node (nod_list, (int) 1, lex.g_field_name), yyvsp[-3], yyvsp[-2], yyvsp[-1], yyvsp[0]); } break; case 238: { yyval = make_node (nod_unique, 2, NULL, yyvsp[0]); } @@ -7021,7 +7012,7 @@ case 248: break; case 249: { yyval = make_node (nod_foreign, e_for_count, yyvsp[-5], yyvsp[-3], - yyvsp[-2], yyvsp[-1], yyvsp[0]); } + yyvsp[-2], yyvsp[-1], yyvsp[0]); } break; case 250: { yyval = make_node (nod_def_index, (int) e_idx_count, @@ -7076,22 +7067,22 @@ break; case 264: { yyval = make_node (nod_def_procedure, (int) e_prc_count, - yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } + yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } break; case 265: { yyval = make_node (nod_redef_procedure, (int) e_prc_count, - yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } + yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } break; case 266: { yyval = make_node (nod_replace_procedure, (int) e_prc_count, - yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } + yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } break; case 267: { yyval = make_node (nod_mod_procedure, (int) e_prc_count, - yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } + yyvsp[-7], yyvsp[-6], yyvsp[-5], yyvsp[-2], yyvsp[-1], yyvsp[0], NULL); } break; case 268: { yyval = make_list (yyvsp[-1]); } @@ -7321,8 +7312,8 @@ case 369: break; case 370: { yyval = (DSQL_NOD) MAKE_string(lex.beginning, - (lex_position() == lex.end) ? - lex_position()-lex.beginning : lex.last_token-lex.beginning);} + (lex_position() == lex.end) ? + lex_position()-lex.beginning : lex.last_token-lex.beginning);} break; case 371: { lex.beginning = lex.last_token; } @@ -7442,11 +7433,11 @@ case 406: break; case 407: { yyval = make_node (nod_mod_domain, (int) e_alt_count, - yyvsp[-1], make_list (yyvsp[0])); } + yyvsp[-1], make_list (yyvsp[0])); } break; case 408: { yyval = make_node (nod_mod_index, - (int) e_mod_idx_count, yyvsp[0]); } + (int) e_mod_idx_count, yyvsp[0]); } break; case 409: { yyval = yyvsp[0]; } @@ -7461,7 +7452,7 @@ case 412: break; case 413: { yyval = make_node (nod_def_default, (int) e_dft_count, - yyvsp[-1], yyvsp[0]); } + yyvsp[-1], yyvsp[0]); } break; case 414: { yyval = yyvsp[0]; } @@ -7521,7 +7512,7 @@ case 455: break; case 456: { yyval = make_node (nod_def_domain, (int) e_dom_count, - yyvsp[-1], NULL, NULL, NULL, NULL); } + yyvsp[-1], NULL, NULL, NULL, NULL); } break; case 457: { lex.g_field_name = yyvsp[0]; @@ -7629,26 +7620,26 @@ case 493: break; case 498: { lex.g_field->fld_ranges = make_list (yyvsp[-1]); - lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; - lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; - yyval = yyvsp[-3]; } + lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; + lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; + yyval = yyvsp[-3]; } break; case 499: { lex.g_field->fld_ranges = make_list (yyvsp[-2]); - lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; - lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; - yyval = yyvsp[-4]; } + lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; + lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; + yyval = yyvsp[-4]; } break; case 501: { yyval = make_node (nod_list, (int) 2, yyvsp[-2], yyvsp[0]); } break; case 502: { if ((SLONG) yyvsp[0] < 1) - yyval = make_node (nod_list, (int) 2, + yyval = make_node (nod_list, (int) 2, MAKE_constant ((STR) yyvsp[0], CONSTANT_SLONG), MAKE_constant ((STR) 1, CONSTANT_SLONG)); - else - yyval = make_node (nod_list, (int) 2, + else + yyval = make_node (nod_list, (int) 2, MAKE_constant ((STR) 1, CONSTANT_SLONG), MAKE_constant ((STR) yyvsp[0], CONSTANT_SLONG) ); } break; @@ -7660,17 +7651,17 @@ break; case 509: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "BIGINT", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "BIGINT", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "BIGINT", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "BIGINT", + 0); lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); } @@ -7691,36 +7682,36 @@ case 512: { *stmt_ambiguous = TRUE; if (client_dialect <= SQL_DIALECT_V5) - { - /* Post warning saying that DATE is equivalent to TIMESTAMP */ - ERRD_post_warning (isc_sqlwarn, gds_arg_number, (SLONG) 301, - isc_arg_warning, isc_dtype_renamed, 0); - lex.g_field->fld_dtype = dtype_timestamp; - lex.g_field->fld_length = sizeof (GDS_TIMESTAMP); - } + { + /* Post warning saying that DATE is equivalent to TIMESTAMP */ + ERRD_post_warning (isc_sqlwarn, gds_arg_number, (SLONG) 301, + isc_arg_warning, isc_dtype_renamed, 0); + lex.g_field->fld_dtype = dtype_timestamp; + lex.g_field->fld_length = sizeof (GDS_TIMESTAMP); + } else if (client_dialect == SQL_DIALECT_V6_TRANSITION) - yyabandon (-104, isc_transitional_date); + yyabandon (-104, isc_transitional_date); else - { - lex.g_field->fld_dtype = dtype_sql_date; - lex.g_field->fld_length = sizeof (ULONG); - } + { + lex.g_field->fld_dtype = dtype_sql_date; + lex.g_field->fld_length = sizeof (ULONG); + } } break; case 513: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); lex.g_field->fld_dtype = dtype_sql_time; lex.g_field->fld_length = sizeof (SLONG); } @@ -7844,122 +7835,122 @@ break; case 544: { lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); + lex.g_field->fld_length = sizeof (SLONG); lex.g_field->fld_precision = 9; - } + } break; case 545: -{ +{ if ( ((SLONG) yyvsp[-1] < 1) || ((SLONG) yyvsp[-1] > 18) ) - yyabandon (-842, isc_precision_err); + yyabandon (-842, isc_precision_err); /* Precision most be between 1 and 18. */ if ((SLONG) yyvsp[-1] > 9) - { - if ( ( (client_dialect <= SQL_DIALECT_V5) && - (db_dialect > SQL_DIALECT_V5) ) || + { + if ( ( (client_dialect <= SQL_DIALECT_V5) && + (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && - (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (gds_sqlerr, + (db_dialect <= SQL_DIALECT_V5) ) ) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -817, gds_arg_gds, isc_ddl_not_allowed_by_db_sql_dial, gds_arg_number, (SLONG) db_dialect, 0); - if (client_dialect <= SQL_DIALECT_V5) - { + if (client_dialect <= SQL_DIALECT_V5) + { lex.g_field->fld_dtype = dtype_double; lex.g_field->fld_length = sizeof (double); - } - else - { + } + else + { if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - ERRD_post_warning ( + { + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous1, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous2, gds_arg_end ); - } + } lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); - } - } + } + } else - if ((SLONG) yyvsp[-1] < 5) - { - lex.g_field->fld_dtype = dtype_short; - lex.g_field->fld_length = sizeof (SSHORT); - } - else - { - lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); - } + if ((SLONG) yyvsp[-1] < 5) + { + lex.g_field->fld_dtype = dtype_short; + lex.g_field->fld_length = sizeof (SSHORT); + } + else + { + lex.g_field->fld_dtype = dtype_long; + lex.g_field->fld_length = sizeof (SLONG); + } lex.g_field->fld_precision = (USHORT)(ULONG) yyvsp[-1]; } break; case 546: { if ( ((SLONG) yyvsp[-3] < 1) || ((SLONG) yyvsp[-3] > 18) ) - yyabandon (-842, isc_precision_err); + yyabandon (-842, isc_precision_err); /* Precision should be between 1 and 18 */ if (((SLONG) yyvsp[-1] > (SLONG) yyvsp[-3]) || ((SLONG) yyvsp[-1] < 0)) - yyabandon (-842, isc_scale_nogt); + yyabandon (-842, isc_scale_nogt); /* Scale must be between 0 and precision */ if ((SLONG) yyvsp[-3] > 9) - { - if ( ( (client_dialect <= SQL_DIALECT_V5) && - (db_dialect > SQL_DIALECT_V5) ) || + { + if ( ( (client_dialect <= SQL_DIALECT_V5) && + (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && - (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (gds_sqlerr, + (db_dialect <= SQL_DIALECT_V5) ) ) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -817, gds_arg_gds, isc_ddl_not_allowed_by_db_sql_dial, gds_arg_number, (SLONG) db_dialect, 0); - if (client_dialect <= SQL_DIALECT_V5) - { + if (client_dialect <= SQL_DIALECT_V5) + { lex.g_field->fld_dtype = dtype_double; lex.g_field->fld_length = sizeof (double); - } - else - { + } + else + { if (client_dialect == SQL_DIALECT_V6_TRANSITION) { - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous1, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous2, gds_arg_end ); } /* client_dialect >= SQL_DIALECT_V6 */ lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); - } - } + } + } else - { - if ((SLONG) yyvsp[-3] < 5) - { - lex.g_field->fld_dtype = dtype_short; - lex.g_field->fld_length = sizeof (SSHORT); - } - else - { - lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); - } - } + { + if ((SLONG) yyvsp[-3] < 5) + { + lex.g_field->fld_dtype = dtype_short; + lex.g_field->fld_length = sizeof (SSHORT); + } + else + { + lex.g_field->fld_dtype = dtype_long; + lex.g_field->fld_length = sizeof (SLONG); + } + } lex.g_field->fld_precision = (USHORT)(ULONG) yyvsp[-3]; lex.g_field->fld_scale = - (SSHORT)(SLONG) yyvsp[-1]; } @@ -7967,15 +7958,15 @@ break; case 549: { if ((SLONG) yyvsp[0] > 7) - { - lex.g_field->fld_dtype = dtype_double; - lex.g_field->fld_length = sizeof (double); - } + { + lex.g_field->fld_dtype = dtype_double; + lex.g_field->fld_length = sizeof (double); + } else - { - lex.g_field->fld_dtype = dtype_real; - lex.g_field->fld_length = sizeof (float); - } + { + lex.g_field->fld_dtype = dtype_real; + lex.g_field->fld_length = sizeof (float); + } } break; case 550: @@ -8011,14 +8002,14 @@ break; case 559: { yyval = make_node (nod_set_generator2,e_gen_id_count,yyvsp[-2], - MAKE_constant((STR)yyvsp[0], CONSTANT_SINT64)); + MAKE_constant((STR)yyvsp[0], CONSTANT_SINT64)); } break; case 560: { yyval = make_node (nod_set_generator2, e_gen_id_count, yyvsp[-3], make_node(nod_negate, 1, - MAKE_constant((STR)yyvsp[0], CONSTANT_SINT64))); + MAKE_constant((STR)yyvsp[0], CONSTANT_SINT64))); } break; case 564: @@ -8437,7 +8428,7 @@ case 738: break; case 739: { yyval = make_node (nod_update, e_upd_count, - yyvsp[-3], make_list (yyvsp[-1]), NULL, yyvsp[0]); } + yyvsp[-3], make_list (yyvsp[-1]), NULL, yyvsp[0]); } break; case 741: { yyval = make_node (nod_list, 2, yyvsp[-2], yyvsp[0]); } @@ -8718,9 +8709,9 @@ break; case 863: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_add2, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_add2, 2, yyvsp[-2], yyvsp[0]); else - yyval = make_node (nod_add, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_add, 2, yyvsp[-2], yyvsp[0]); } break; case 864: @@ -8732,25 +8723,25 @@ break; case 866: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_subtract2, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_subtract2, 2, yyvsp[-2], yyvsp[0]); else - yyval = make_node (nod_subtract, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_subtract, 2, yyvsp[-2], yyvsp[0]); } break; case 867: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_multiply2, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_multiply2, 2, yyvsp[-2], yyvsp[0]); else - yyval = make_node (nod_multiply, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_multiply, 2, yyvsp[-2], yyvsp[0]); } break; case 868: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_divide2, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_divide2, 2, yyvsp[-2], yyvsp[0]); else - yyval = make_node (nod_divide, 2, yyvsp[-2], yyvsp[0]); + yyval = make_node (nod_divide, 2, yyvsp[-2], yyvsp[0]); } break; case 869: @@ -8768,7 +8759,7 @@ break; case 876: { yyval = make_node (nod_dom_value, 0, NULL); - } + } break; case 877: { yyval = yyvsp[0]; } @@ -8776,34 +8767,34 @@ break; case 878: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "DATE", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "DATE", + 0); yyval = make_node (nod_current_date, 0, NULL); } break; case 879: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); yyval = make_node (nod_current_time, 0, NULL); } break; @@ -8840,34 +8831,34 @@ break; case 893: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "DATE", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "DATE", + 0); yyval = MAKE_constant ((STR) yyvsp[0], CONSTANT_DATE); } break; case 894: { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); yyval = MAKE_constant ((STR) yyvsp[0], CONSTANT_TIME); } break; @@ -8918,25 +8909,25 @@ case 908: break; case 909: { if ((SLONG) yyvsp[0] > SHRT_POS_MAX) - yyabandon (-842, isc_expec_short); + yyabandon (-842, isc_expec_short); /* Short integer expected */ yyval = yyvsp[0];} break; case 910: { if ((SLONG) yyvsp[0] > SHRT_NEG_MAX) - yyabandon (-842, isc_expec_short); + yyabandon (-842, isc_expec_short); /* Short integer expected */ yyval = yyvsp[0];} break; case 911: { if ((SLONG) yyvsp[0] == 0) - yyabandon (-842, isc_expec_positive); + yyabandon (-842, isc_expec_positive); /* Positive number expected */ yyval = yyvsp[0];} break; case 912: { if ((SLONG) yyvsp[0] > SHRT_UNSIGNED_MAX) - yyabandon (-842, isc_expec_ushort); + yyabandon (-842, isc_expec_ushort); /* Unsigned short integer expected */ yyval = yyvsp[0];} break; @@ -8954,41 +8945,41 @@ case 921: break; case 922: { yyval = make_flag_node (nod_agg_count, - NOD_AGG_DISTINCT, 1, yyvsp[-1]); } + NOD_AGG_DISTINCT, 1, yyvsp[-1]); } break; case 923: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_agg_total2, 1, yyvsp[-1]); + yyval = make_node (nod_agg_total2, 1, yyvsp[-1]); else - yyval = make_node (nod_agg_total, 1, yyvsp[-1]); + yyval = make_node (nod_agg_total, 1, yyvsp[-1]); } break; case 924: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_flag_node (nod_agg_total2, + yyval = make_flag_node (nod_agg_total2, NOD_AGG_DISTINCT, 1, yyvsp[-1]); else - yyval = make_flag_node (nod_agg_total, + yyval = make_flag_node (nod_agg_total, NOD_AGG_DISTINCT, 1, yyvsp[-1]); } break; case 925: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_agg_average2, 1, yyvsp[-1]); + yyval = make_node (nod_agg_average2, 1, yyvsp[-1]); else - yyval = make_node (nod_agg_average, 1, yyvsp[-1]); + yyval = make_node (nod_agg_average, 1, yyvsp[-1]); } break; case 926: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_flag_node (nod_agg_average2, + yyval = make_flag_node (nod_agg_average2, NOD_AGG_DISTINCT, 1, yyvsp[-1]); else - yyval = make_flag_node (nod_agg_average, + yyval = make_flag_node (nod_agg_average, NOD_AGG_DISTINCT, 1, yyvsp[-1]); } break; @@ -9007,7 +8998,7 @@ break; case 931: { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - yyval = make_node (nod_gen_id2, 2, yyvsp[-3], yyvsp[-1]); + yyval = make_node (nod_gen_id2, 2, yyvsp[-3], yyvsp[-1]); else yyval = make_node (nod_gen_id, 2, yyvsp[-3], yyvsp[-1]); } diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 51d233728a..0dad82adf7 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -37,7 +37,7 @@ * 2001.10.01 Claudio Valderrama: enable explicit GRANT...to ROLE role_name. * 2001.10.06 Claudio Valderrama: Honor explicit USER keyword in GRANTs and REVOKEs. * 2002.07.05 Mark O'Donohue: change keyword DEBUG to KW_DEBUG to avoid - * clashes with normal DEBUG macro. + * clashes with normal DEBUG macro. * 2002.07.30 Arno Brinkman: * 2002.07.30 Let IN predicate handle value_expressions * 2002.07.30 tokens CASE, NULLIF, COALESCE added @@ -52,8 +52,8 @@ * 2002.08.31 Dmitry Yemanov: allowed user-defined index names for PK/FK/UK constraints * 2002.09.01 Dmitry Yemanov: RECREATE VIEW * 2002.09.28 Dmitry Yemanov: Reworked internal_info stuff, enhanced - * exception handling in SPs/triggers, - * implemented ROWS_AFFECTED system variable + * exception handling in SPs/triggers, + * implemented ROWS_AFFECTED system variable * 2002.10.21 Nickolay Samofatov: Added support for explicit pessimistic locks * 2002.10.29 Nickolay Samofatov: Added support for savepoints * 2002.12.03 Dmitry Yemanov: Implemented ORDER BY clause in subqueries. @@ -66,7 +66,7 @@ * 2003.06.13 Nickolay Samofatov: Make INSERTING/UPDATING/DELETING non-reserved keywords * 2003.07.01 Blas Rodriguez Somoza: Change DEBUG and IN to avoid conflicts in win32 build/bison * 2003.08.11 Arno Brinkman: Changed GROUP BY to support all expressions and added "AS" support - * with table alias. Also removed group_by_function and ordinal. + * with table alias. Also removed group_by_function and ordinal. * 2003.08.14 Arno Brinkman: Added support for derived tables. */ @@ -121,8 +121,8 @@ static void yyerror (TEXT *); #define NEGATIVE 1 #define UNSIGNED 2 -#define MIN_CACHE_BUFFERS 250 -#define DEF_CACHE_BUFFERS 1000 +#define MIN_CACHE_BUFFERS 250 +#define DEF_CACHE_BUFFERS 1000 /* Fix 69th procedure problem - solution from Oleg Loa */ #define YYSTACKSIZE 2048 @@ -157,16 +157,16 @@ static void yyerror (TEXT *); #define MAX_TOKEN_LEN 256 #define CHECK_BOUND(to)\ - {\ - if ((to - string) >= MAX_TOKEN_LEN) \ + {\ + if ((to - string) >= MAX_TOKEN_LEN) \ yyabandon (-104, isc_token_too_long); \ - } + } #define CHECK_COPY_INCR(to,ch){CHECK_BOUND(to); *to++=ch;} static TEXT *lex_position (void); #ifdef NOT_USED_OR_REPLACED -static BOOLEAN long_int (DSQL_NOD, SLONG *); +static bool long_int(DSQL_NOD, SLONG *); #endif static DSQL_FLD make_field (DSQL_NOD); static FIL make_file (void); @@ -176,7 +176,7 @@ static DSQL_NOD make_parameter (void); static DSQL_NOD make_flag_node (NOD_TYPE, SSHORT, int, ...); static void prepare_console_debug (int, int *); #ifdef NOT_USED_OR_REPLACED -static BOOLEAN short_int (DSQL_NOD, SLONG *, SSHORT); +static bool short_int(DSQL_NOD, SLONG *, SSHORT); #endif static void stack_nodes (DSQL_NOD, DLLS *); inline static int yylex (USHORT, USHORT, USHORT, BOOLEAN *); @@ -186,7 +186,7 @@ static void check_log_file_attrs (void); struct LexerState { /* This is, in fact, parser state. Not used in lexer itself */ DSQL_FLD g_field; - FIL g_file; + FIL g_file; DSQL_NOD g_field_name; SSHORT log_defined, cache_defined; int dsql_debug; @@ -519,9 +519,9 @@ static struct LexerState lex; /* The same issue exists with ALTER COLUMN now that keywords can be used in order to change their names. The syntax which shows the issue is: - ALTER COLUMN where column is part of the alter statement - or - ALTER COLUMN where column is the name of the column in the relation + ALTER COLUMN where column is part of the alter statement + or + ALTER COLUMN where column is the name of the column in the relation */ %nonassoc ALTER %nonassoc COLUMN @@ -546,7 +546,7 @@ statement : alter | grant | insert | invoke_procedure - | recreate + | recreate | replace | revoke | rollback @@ -581,7 +581,7 @@ grant : GRANT privileges ON prot_table_name | GRANT role_name_list TO role_grantee_list role_admin_option { $$ = make_node (nod_grant, (int) e_grant_count, make_list($2), make_list($4), NULL, $5); } - ; + ; prot_table_name : simple_table_name | TABLE simple_table_name @@ -624,10 +624,10 @@ grant_option : WITH GRANT OPTION ; role_admin_option : WITH ADMIN OPTION - { $$ = make_node (nod_grant_admin, (int) 0, NULL); } - | - { $$ = 0; } - ; + { $$ = make_node (nod_grant_admin, (int) 0, NULL); } + | + { $$ = 0; } + ; simple_proc_name: symbol_procedure_name { $$ = make_node (nod_procedure_name, (int) 1, $1); } @@ -670,7 +670,7 @@ revoke : REVOKE rev_grant_option privileges ON prot_table_name { $$ = make_node (nod_revoke, (int) e_grant_count, make_list($2), make_list($4), NULL, NULL); } - ; + ; rev_grant_option : GRANT OPTION FOR { $$ = make_node (nod_grant, (int) 0, NULL); } @@ -692,7 +692,7 @@ grantee : PROCEDURE symbol_procedure_name | VIEW symbol_view_name { $$ = make_node (nod_view_obj, (int) 1, $2); } | ROLE symbol_role_name - { $$ = make_node (nod_role_name, (int) 1, $2); } + { $$ = make_node (nod_role_name, (int) 1, $2); } ; user_grantee_list : user_grantee @@ -706,30 +706,30 @@ explicit grant/revoke for both USER and ROLE keywords & object types. */ user_grantee : symbol_user_name { $$ = make_node (nod_user_name, (int) 1, $1); } | USER symbol_user_name - { $$ = make_node (nod_user_name, (int) 2, $2, NULL); } + { $$ = make_node (nod_user_name, (int) 2, $2, NULL); } | GROUP symbol_user_name { $$ = make_node (nod_user_group, (int) 1, $2); } ; role_name_list : role_name - | role_name_list ',' role_name - { $$ = make_node (nod_list, (int) 2, $1, $3); } - ; + | role_name_list ',' role_name + { $$ = make_node (nod_list, (int) 2, $1, $3); } + ; role_name : symbol_role_name - { $$ = make_node (nod_role_name, (int) 1, $1); } - ; + { $$ = make_node (nod_role_name, (int) 1, $1); } + ; role_grantee_list : role_grantee - | role_grantee_list ',' role_grantee - { $$ = make_node (nod_list, (int) 2, $1, $3); } - ; + | role_grantee_list ',' role_grantee + { $$ = make_node (nod_list, (int) 2, $1, $3); } + ; role_grantee : symbol_user_name - { $$ = make_node (nod_user_name, (int) 1, $1); } - | USER symbol_user_name - { $$ = make_node (nod_user_name, (int) 1, $2); } - ; + { $$ = make_node (nod_user_name, (int) 1, $1); } + | USER symbol_user_name + { $$ = make_node (nod_user_name, (int) 1, $2); } + ; /* DECLARE operations */ @@ -747,7 +747,7 @@ declare_clause : FILTER filter_decl_clause udf_decl_clause : symbol_UDF_name arg_desc_list1 RETURNS return_value1 ENTRY_POINT sql_string MODULE_NAME sql_string - { $$ = make_node (nod_def_udf, (int) e_udf_count, + { $$ = make_node (nod_def_udf, (int) e_udf_count, $1, $6, $8, make_list ($2), $4); } ; @@ -775,8 +775,8 @@ arg_desc_list : arg_desc /*arg_desc : init_data_type udf_data_type { $$ = $1; } */ arg_desc : init_data_type udf_data_type - { $$ = make_node (nod_udf_param, (int) e_udf_param_count, - $1, NULL); } + { $$ = make_node (nod_udf_param, (int) e_udf_param_count, + $1, NULL); } | init_data_type udf_data_type BY KW_DESCRIPTOR { $$ = make_node (nod_udf_param, (int) e_udf_param_count, $1, MAKE_constant ((STR) FUN_descriptor, CONSTANT_SLONG)); } @@ -793,7 +793,7 @@ return_value : init_data_type udf_data_type | init_data_type udf_data_type FREE_IT { $$ = make_node (nod_udf_return_value, (int) 2, $1, MAKE_constant ((STR) (-1 * FUN_reference), CONSTANT_SLONG));} - /* FUN_refrence with FREE_IT is -ve */ + /* FUN_refrence with FREE_IT is -ve */ | init_data_type udf_data_type BY KW_VALUE { $$ = make_node (nod_udf_return_value, (int) 2, $1, MAKE_constant ((STR) FUN_value, CONSTANT_SLONG));} @@ -803,12 +803,12 @@ return_value : init_data_type udf_data_type MAKE_constant ((STR) FUN_descriptor, CONSTANT_SLONG));} | PARAMETER pos_short_integer { $$ = make_node (nod_udf_return_value, (int) 2, - NULL, MAKE_constant ((STR) $2, CONSTANT_SLONG));} + NULL, MAKE_constant ((STR) $2, CONSTANT_SLONG));} ; filter_decl_clause : symbol_filter_name INPUT_TYPE blob_subtype OUTPUT_TYPE blob_subtype ENTRY_POINT sql_string MODULE_NAME sql_string - { $$ = make_node (nod_def_filter, (int) e_filter_count, + { $$ = make_node (nod_def_filter, (int) e_filter_count, $1, $3, $5, $7, $9); } ; @@ -817,7 +817,7 @@ filter_decl_clause : symbol_filter_name INPUT_TYPE blob_subtype OUTPUT_TYPE blob create : CREATE create_clause { $$ = $2; } - ; + ; create_clause : EXCEPTION symbol_exception_name sql_string { $$ = make_node (nod_def_exception, (int) e_xcp_count, @@ -838,9 +838,9 @@ create_clause : EXCEPTION symbol_exception_name sql_string | DATABASE db_clause { $$ = $2; } | DOMAIN domain_clause - { $$ = $2; } + { $$ = $2; } | SHADOW shadow_clause - { $$ = $2; } + { $$ = $2; } | ROLE role_clause { $$ = $2; } ; @@ -860,7 +860,7 @@ recreate_clause : PROCEDURE rprocedure_clause | TRIGGER def_trigger_clause { $$ = $2; } | DOMAIN rdomain_clause - { $$ = $2; } + { $$ = $2; } */ ; @@ -899,7 +899,7 @@ index_definition : column_list shadow_clause : pos_short_integer manual_auto conditional sql_string first_file_length sec_shadow_files { $$ = make_node (nod_def_shadow, (int) e_shadow_count, - $1, $2, $3, $4, $5, make_list ($6)); } + $1, $2, $3, $4, $5, make_list ($6)); } ; manual_auto : MANUAL @@ -927,7 +927,7 @@ sec_shadow_files : | db_file_list ; -db_file_list : db_file +db_file_list : db_file | db_file_list db_file { $$ = make_node (nod_list, (int) 2, $1, $2); } ; @@ -936,28 +936,28 @@ db_file_list : db_file /* CREATE DOMAIN */ domain_clause : column_def_name - as_opt - data_type - begin_trigger - domain_default_opt - end_trigger - domain_constraint_clause - collate_clause + as_opt + data_type + begin_trigger + domain_default_opt + end_trigger + domain_constraint_clause + collate_clause { $$ = make_node (nod_def_domain, (int) e_dom_count, - $1, $5, $6, make_list ($7), $8); } - ; + $1, $5, $6, make_list ($7), $8); } + ; /* rdomain_clause : DOMAIN alter_column_name alter_domain_ops - { $$ = make_node (nod_mod_domain, (int) e_alt_count, - $2, make_list ($3)); } + { $$ = make_node (nod_mod_domain, (int) e_alt_count, + $2, make_list ($3)); } */ as_opt : AS - { $$ = NULL; } - | - { $$ = NULL; } - ; + { $$ = NULL; } + | + { $$ = NULL; } + ; domain_default_opt : DEFAULT begin_trigger default_value { $$ = $3; } @@ -966,32 +966,32 @@ domain_default_opt : DEFAULT begin_trigger default_value ; domain_constraint_clause : - { $$ = NULL; } + { $$ = NULL; } | domain_constraint_list - ; + ; domain_constraint_list : domain_constraint_def | domain_constraint_list domain_constraint_def - { $$ = make_node (nod_list, (int) 2, $1, $2); } - ; + { $$ = make_node (nod_list, (int) 2, $1, $2); } + ; domain_constraint_def : domain_constraint { $$ = make_node (nod_rel_constraint, (int) 2, NULL, $1);} - ; + ; domain_constraint : null_constraint | domain_check_constraint - ; - + ; + null_constraint : NOT KW_NULL - { $$ = make_node (nod_null, (int) 0, NULL); } - ; + { $$ = make_node (nod_null, (int) 0, NULL); } + ; domain_check_constraint : begin_trigger CHECK '(' search_condition ')' end_trigger { $$ = make_node (nod_def_constraint, (int) e_cnstr_count, MAKE_string(NULL_STRING, 0), NULL, NULL, NULL, $4, NULL, $6, NULL, NULL); } - ; + ; /* CREATE GENERATOR */ @@ -1082,12 +1082,12 @@ db_log_option : GROUP_COMMIT_WAIT equals long_integer db_log : db_default_log_spec { if (lex.log_defined) - yyabandon (-260, isc_log_redef); /* Log redefined */ + yyabandon (-260, isc_log_redef); /* Log redefined */ lex.log_defined = TRUE; $$ = $1; } | db_rem_log_spec { if (lex.log_defined) - yyabandon (-260, isc_log_redef); + yyabandon (-260, isc_log_redef); lex.log_defined = TRUE; $$ = $1; } ; @@ -1095,13 +1095,13 @@ db_log : db_default_log_spec db_rem_log_spec : LOGFILE '(' logfiles ')' OVERFLOW logfile_desc { lex.g_file->fil_flags |= LOG_serial | LOG_overflow; if (lex.g_file->fil_partitions) - yyabandon (-261, isc_partition_not_supp); + yyabandon (-261, isc_partition_not_supp); /* Partitions not supported in series of log file specification */ $$ = make_node (nod_list, 2, $3, $6); } | LOGFILE BASENAME logfile_desc { lex.g_file->fil_flags |= LOG_serial; if (lex.g_file->fil_partitions) - yyabandon (-261, isc_partition_not_supp); + yyabandon (-261, isc_partition_not_supp); $$ = $3; } ; @@ -1122,7 +1122,7 @@ db_file : file1 sql_string file_desc1 db_cache : CACHE sql_string cache_length { if (lex.cache_defined) - yyabandon (-260, isc_cache_redef); + yyabandon (-260, isc_cache_redef); */ /* Cache redefined */ /* lex.g_file = make_file(); lex.g_file->fil_length = (SLONG) $3; @@ -1138,10 +1138,10 @@ cache_length : { $$ = (DSQL_NOD) (SLONG) DEF_CACHE_BUFFERS; } | LENGTH equals long_integer page_noise { if ((SLONG) $3 < MIN_CACHE_BUFFERS) - yyabandon (-239, isc_cache_too_small); + yyabandon (-239, isc_cache_too_small); */ /* Cache length too small */ /* else - $$ = (DSQL_NOD) $3; } + $$ = (DSQL_NOD) $3; } ; */ @@ -1151,9 +1151,9 @@ logfiles : logfile_desc ; logfile_desc : logfile_name logfile_attrs { - check_log_file_attrs(); + check_log_file_attrs(); $$ = (DSQL_NOD) make_node (nod_log_file_desc, (int) 1, - (DSQL_NOD) lex.g_file); } + (DSQL_NOD) lex.g_file); } ; logfile_name : sql_string { lex.g_file = make_file(); @@ -1239,13 +1239,13 @@ column_def : column_def_name data_type_or_domain default_opt $1, $3, $4, make_list ($5), $6, $2, NULL); } | column_def_name non_array_type def_computed { $$ = make_node (nod_def_field, (int) e_dfl_count, - $1, NULL, NULL, NULL, NULL, NULL, $3); } + $1, NULL, NULL, NULL, NULL, NULL, $3); } | column_def_name def_computed { $$ = make_node (nod_def_field, (int) e_dfl_count, - $1, NULL, NULL, NULL, NULL, NULL, $2); } + $1, NULL, NULL, NULL, NULL, NULL, $2); } ; - + /* value does allow parens around it, but there is a problem getting the * source text */ @@ -1261,11 +1261,11 @@ computed_by : COMPUTED BY ; data_type_or_domain : data_type begin_trigger - { $$ = NULL; } + { $$ = NULL; } | simple_column_name begin_string - { $$ = make_node (nod_def_domain, (int) e_dom_count, - $1, NULL, NULL, NULL, NULL); } - ; + { $$ = make_node (nod_def_domain, (int) e_dom_count, + $1, NULL, NULL, NULL, NULL); } + ; collate_clause : COLLATE symbol_collation_name { $$ = $2; } @@ -1316,48 +1316,48 @@ default_value : constant | datetime_value_expression { $$ = $1; } ; - + column_constraint_clause : { $$ = NULL; } | column_constraint_list ; column_constraint_list : column_constraint_def - | column_constraint_list column_constraint_def + | column_constraint_list column_constraint_def { $$ = make_node (nod_list, (int) 2, $1, $2); } - ; + ; column_constraint_def : constraint_name_opt column_constraint - { $$ = make_node (nod_rel_constraint, (int) 2, $1, $2);} + { $$ = make_node (nod_rel_constraint, (int) 2, $1, $2);} ; column_constraint : NOT KW_NULL - { $$ = make_node (nod_null, (int) 1, NULL); } - | REFERENCES simple_table_name column_parens_opt + { $$ = make_node (nod_null, (int) 1, NULL); } + | REFERENCES simple_table_name column_parens_opt referential_trigger_action constraint_index_opt - { $$ = make_node (nod_foreign, e_for_count, - make_node (nod_list, (int) 1, lex.g_field_name), $2, $3, $4, $5); } + { $$ = make_node (nod_foreign, e_for_count, + make_node (nod_list, (int) 1, lex.g_field_name), $2, $3, $4, $5); } - | check_constraint - | UNIQUE constraint_index_opt - { $$ = make_node (nod_unique, 2, NULL, $2); } - | PRIMARY KEY constraint_index_opt - { $$ = make_node (nod_primary, e_pri_count, NULL, $3); } + | check_constraint + | UNIQUE constraint_index_opt + { $$ = make_node (nod_unique, 2, NULL, $2); } + | PRIMARY KEY constraint_index_opt + { $$ = make_node (nod_primary, e_pri_count, NULL, $3); } ; - + /* table constraints */ table_constraint_definition : constraint_name_opt table_constraint - { $$ = make_node (nod_rel_constraint, (int) 2, $1, $2);} - ; + { $$ = make_node (nod_rel_constraint, (int) 2, $1, $2);} + ; constraint_name_opt : CONSTRAINT symbol_constraint_name - { $$ = $2; } - | { $$ = NULL ;} - ; + { $$ = $2; } + | { $$ = NULL ;} + ; table_constraint : unique_constraint | primary_constraint @@ -1377,7 +1377,7 @@ referential_constraint : FOREIGN KEY column_parens REFERENCES simple_table_name column_parens_opt referential_trigger_action constraint_index_opt { $$ = make_node (nod_foreign, e_for_count, $3, $5, - $6, $7, $8); } + $6, $7, $8); } ; constraint_index_opt : USING order_direction INDEX symbol_index_name @@ -1421,7 +1421,7 @@ delete_rule : ON KW_DELETE referential_action referential_action: CASCADE { $$ = make_flag_node (nod_ref_trig_action, REF_ACTION_CASCADE, e_ref_trig_action_count, NULL);} - | SET DEFAULT + | SET DEFAULT { $$ = make_flag_node (nod_ref_trig_action, REF_ACTION_SET_DEFAULT, e_ref_trig_action_count, NULL);} | SET KW_NULL @@ -1437,49 +1437,49 @@ referential_action: CASCADE procedure_clause : symbol_procedure_name input_parameters - output_parameters - AS begin_string + output_parameters + AS begin_string var_declaration_list full_proc_block end_trigger { $$ = make_node (nod_def_procedure, (int) e_prc_count, - $1, $2, $3, $6, $7, $8, NULL); } - ; + $1, $2, $3, $6, $7, $8, NULL); } + ; rprocedure_clause : symbol_procedure_name input_parameters - output_parameters - AS begin_string + output_parameters + AS begin_string var_declaration_list full_proc_block end_trigger { $$ = make_node (nod_redef_procedure, (int) e_prc_count, - $1, $2, $3, $6, $7, $8, NULL); } - ; + $1, $2, $3, $6, $7, $8, NULL); } + ; replace_procedure_clause : symbol_procedure_name input_parameters - output_parameters - AS begin_string + output_parameters + AS begin_string var_declaration_list full_proc_block end_trigger { $$ = make_node (nod_replace_procedure, (int) e_prc_count, - $1, $2, $3, $6, $7, $8, NULL); } - ; + $1, $2, $3, $6, $7, $8, NULL); } + ; alter_procedure_clause : symbol_procedure_name input_parameters - output_parameters - AS begin_string + output_parameters + AS begin_string var_declaration_list full_proc_block end_trigger { $$ = make_node (nod_mod_procedure, (int) e_prc_count, - $1, $2, $3, $6, $7, $8, NULL); } - ; + $1, $2, $3, $6, $7, $8, NULL); } + ; input_parameters : '(' proc_parameters ')' { $$ = make_list ($2); } @@ -1586,7 +1586,7 @@ excp_statement : EXCEPTION symbol_exception_name ';' raise_statement : EXCEPTION ';' { $$ = make_node (nod_exception_stmt, e_xcp_count, NULL, NULL); } - ; + ; exec_procedure : EXECUTE PROCEDURE symbol_procedure_name proc_inputs proc_outputs ';' { $$ = make_node (nod_exec_procedure, e_exe_count, $3, @@ -1723,33 +1723,33 @@ invoke_procedure : EXECUTE PROCEDURE symbol_procedure_name proc_inputs /* CREATE VIEW */ view_clause : symbol_view_name column_parens_opt AS begin_string union_view - check_opt end_string + check_opt end_string { $$ = make_node (nod_def_view, (int) e_view_count, $1, $2, $5, $6, $7); } - ; + ; rview_clause : symbol_view_name column_parens_opt AS begin_string union_view - check_opt end_string + check_opt end_string { $$ = make_node (nod_redef_view, (int) e_view_count, $1, $2, $5, $6, $7); } - ; + ; /* replace_view_clause : symbol_view_name column_parens_opt AS begin_string union_view - check_opt end_string + check_opt end_string { $$ = make_node (nod_replace_view, (int) e_view_count, $1, $2, $5, $6, $7); } - ; + ; alter_view_clause : symbol_view_name column_parens_opt AS begin_string union_view - check_opt end_string + check_opt end_string { $$ = make_node (nod_mod_view, (int) e_view_count, $1, $2, $5, $6, $7); } - ; + ; */ -union_view : union_view_expr +union_view : union_view_expr { $$ = make_node (nod_select, (int) 2, $1, NULL); } ; @@ -1757,12 +1757,12 @@ union_view_expr : select_view_expr { $$ = make_node (nod_list, (int) 1, $1); } | union_view_expr UNION select_view_expr { $$ = make_node (nod_list, 2, $1, $3); } - | union_view_expr UNION ALL select_view_expr - { $$ = make_flag_node (nod_list, NOD_UNION_ALL, 2, $1, $4); } + | union_view_expr UNION ALL select_view_expr + { $$ = make_flag_node (nod_list, NOD_UNION_ALL, 2, $1, $4); } ; select_view_expr: SELECT - distinct_clause + distinct_clause select_list from_view_clause where_clause @@ -1770,7 +1770,7 @@ select_view_expr: SELECT having_clause { $$ = make_node (nod_select_expr, e_sel_count, NULL, $2, $3, $4, $5, $6, $7, NULL, NULL); } - ; + ; from_view_clause : FROM from_view_list { $$ = make_list ($2); } @@ -1782,7 +1782,7 @@ from_view_list : view_table ; view_table : joined_view_table - | table_name + | table_name | derived_table ; @@ -1801,8 +1801,8 @@ begin_string : end_string : { $$ = (DSQL_NOD) MAKE_string(lex.beginning, - (lex_position() == lex.end) ? - lex_position()-lex.beginning : lex.last_token-lex.beginning);} + (lex_position() == lex.end) ? + lex_position()-lex.beginning : lex.last_token-lex.beginning);} ; begin_trigger : @@ -1913,7 +1913,7 @@ trigger_action : AS begin_trigger var_declaration_list full_proc_block alter : ALTER alter_clause { $$ = $2; } - ; + ; alter_clause : EXCEPTION symbol_exception_name sql_string { $$ = make_node (nod_mod_exception, (int) e_xcp_count, @@ -1932,12 +1932,12 @@ alter_clause : EXCEPTION symbol_exception_name sql_string | DATABASE init_alter_db alter_db { $$ = make_node (nod_mod_database, (int) e_adb_count, make_list ($3)); } - | DOMAIN alter_column_name alter_domain_ops - { $$ = make_node (nod_mod_domain, (int) e_alt_count, - $2, make_list ($3)); } + | DOMAIN alter_column_name alter_domain_ops + { $$ = make_node (nod_mod_domain, (int) e_alt_count, + $2, make_list ($3)); } | INDEX alter_index_clause - { $$ = make_node (nod_mod_index, - (int) e_mod_idx_count, $2); } + { $$ = make_node (nod_mod_index, + (int) e_mod_idx_count, $2); } ; domain_default_opt2 : DEFAULT begin_trigger default_value @@ -1948,7 +1948,7 @@ domain_check_constraint2 : CHECK begin_trigger '(' search_condition ')' end_tri { $$ = make_node (nod_def_constraint, (int) e_cnstr_count, MAKE_string(NULL_STRING, 0), NULL, NULL, NULL, $4, NULL, $6, NULL, NULL); } - ; + ; alter_domain_ops : alter_domain_op | alter_domain_ops alter_domain_op @@ -1956,24 +1956,24 @@ alter_domain_ops : alter_domain_op ; alter_domain_op : SET begin_trigger domain_default_opt2 end_trigger - { $$ = make_node (nod_def_default, (int) e_dft_count, - $3, $4); } + { $$ = make_node (nod_def_default, (int) e_dft_count, + $3, $4); } /* SET begin_string default_opt end_trigger - { $$ = make_node (nod_def_default, (int) e_dft_count, - $3, $4); } - | begin_trigger default_opt end_trigger - { $$ = make_node (nod_def_default, (int) e_dft_count, - $2, $3); } */ - | ADD CONSTRAINT domain_check_constraint2 - { $$ = $3; } -/* | ADD CONSTRAINT domain_check_constraint - { $$ = $3; } */ - | ADD domain_check_constraint - { $$ = $2; } + { $$ = make_node (nod_def_default, (int) e_dft_count, + $3, $4); } + | begin_trigger default_opt end_trigger + { $$ = make_node (nod_def_default, (int) e_dft_count, + $2, $3); } */ + | ADD CONSTRAINT domain_check_constraint2 + { $$ = $3; } +/* | ADD CONSTRAINT domain_check_constraint + { $$ = $3; } */ + | ADD domain_check_constraint + { $$ = $2; } | DROP DEFAULT - {$$ = make_node (nod_del_default, (int) 0, NULL); } + {$$ = make_node (nod_del_default, (int) 0, NULL); } | DROP CONSTRAINT - { $$ = make_node (nod_delete_rel_constraint, (int) 1, NULL); } + { $$ = make_node (nod_delete_rel_constraint, (int) 1, NULL); } | TO simple_column_name { $$ = $2; } | TYPE init_data_type non_array_type @@ -1987,16 +1987,16 @@ alter_ops : alter_op alter_op : DROP simple_column_name drop_behaviour { $$ = make_node (nod_del_field, 2, $2, $3); } - | DROP CONSTRAINT symbol_constraint_name - { $$ = make_node (nod_delete_rel_constraint, (int) 1, $3);} + | DROP CONSTRAINT symbol_constraint_name + { $$ = make_node (nod_delete_rel_constraint, (int) 1, $3);} | ADD column_def { $$ = $2; } - | ADD table_constraint_definition - { $$ = $2; } + | ADD table_constraint_definition + { $$ = $2; } /* CVC: From SQL, field positions start at 1, not zero. Think in ORDER BY, for example. | col_opt simple_column_name POSITION nonneg_short_integer { $$ = make_node (nod_mod_field_pos, 2, $2, - MAKE_constant ((STR) $4, CONSTANT_SLONG)); } */ + MAKE_constant ((STR) $4, CONSTANT_SLONG)); } */ | col_opt simple_column_name POSITION pos_short_integer { $$ = make_node (nod_mod_field_pos, 2, $2, MAKE_constant ((STR) $4, CONSTANT_SLONG)); } @@ -2040,16 +2040,16 @@ keyword_or_column : valid_symbol_name ; col_opt : ALTER - { $$ = NULL; } + { $$ = NULL; } | ALTER COLUMN - { $$ = NULL; } + { $$ = NULL; } ; alter_data_type_or_domain : non_array_type begin_trigger - { $$ = NULL; } + { $$ = NULL; } | simple_column_name begin_string - { $$ = make_node (nod_def_domain, (int) e_dom_count, - $1, NULL, NULL, NULL, NULL); } + { $$ = make_node (nod_def_domain, (int) e_dom_count, + $1, NULL, NULL, NULL, NULL); } ; alter_col_name : simple_column_name @@ -2083,7 +2083,7 @@ init_alter_db : alter_db : db_alter_clause | alter_db db_alter_clause - { $$ = make_node (nod_list, (int) 2, $1, $2); } + { $$ = make_node (nod_list, (int) 2, $1, $2); } ; db_alter_clause : ADD db_file_list @@ -2091,7 +2091,7 @@ db_alter_clause : ADD db_file_list /* | ADD db_cache { $$ = $2; } - | DROP CACHE + | DROP CACHE { $$ = make_node (nod_drop_cache, (int) 0, NULL); } */ | DROP LOGFILE @@ -2112,7 +2112,7 @@ db_alter_clause : ADD db_file_list db_log_option_list : db_log_option | db_log_option_list ',' db_log_option - { $$ = make_node (nod_list, (int) 2, $1, $3); } + { $$ = make_node (nod_list, (int) 2, $1, $3); } ; @@ -2139,10 +2139,10 @@ new_trigger_action : trigger_action ; /* DROP metadata operations */ - + drop : DROP drop_clause { $$ = $2; } - ; + ; drop_clause : EXCEPTION symbol_exception_name { $$ = make_node (nod_del_exception, 1, $2); } @@ -2182,15 +2182,15 @@ non_array_type : simple_type ; array_type : non_charset_simple_type '[' array_spec ']' - { lex.g_field->fld_ranges = make_list ($3); - lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; - lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; - $$ = $1; } + { lex.g_field->fld_ranges = make_list ($3); + lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; + lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; + $$ = $1; } | character_type '[' array_spec ']' charset_clause - { lex.g_field->fld_ranges = make_list ($3); - lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; - lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; - $$ = $1; } + { lex.g_field->fld_ranges = make_list ($3); + lex.g_field->fld_dimensions = lex.g_field->fld_ranges->nod_count / 2; + lex.g_field->fld_element_dtype = lex.g_field->fld_dtype; + $$ = $1; } ; array_spec : array_range @@ -2199,16 +2199,16 @@ array_spec : array_range ; array_range : signed_long_integer - { if ((SLONG) $1 < 1) - $$ = make_node (nod_list, (int) 2, + { if ((SLONG) $1 < 1) + $$ = make_node (nod_list, (int) 2, MAKE_constant ((STR) $1, CONSTANT_SLONG), MAKE_constant ((STR) 1, CONSTANT_SLONG)); - else - $$ = make_node (nod_list, (int) 2, + else + $$ = make_node (nod_list, (int) 2, MAKE_constant ((STR) 1, CONSTANT_SLONG), MAKE_constant ((STR) $1, CONSTANT_SLONG) ); } | signed_long_integer ':' signed_long_integer - { $$ = make_node (nod_list, (int) 2, + { $$ = make_node (nod_list, (int) 2, MAKE_constant ((STR) $1, CONSTANT_SLONG), MAKE_constant ((STR) $3, CONSTANT_SLONG)); } ; @@ -2223,17 +2223,17 @@ non_charset_simple_type : national_character_type | BIGINT { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "BIGINT", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "BIGINT", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "BIGINT", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "BIGINT", + 0); lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); } @@ -2251,35 +2251,35 @@ non_charset_simple_type : national_character_type { *stmt_ambiguous = TRUE; if (client_dialect <= SQL_DIALECT_V5) - { - /* Post warning saying that DATE is equivalent to TIMESTAMP */ - ERRD_post_warning (isc_sqlwarn, gds_arg_number, (SLONG) 301, - isc_arg_warning, isc_dtype_renamed, 0); - lex.g_field->fld_dtype = dtype_timestamp; - lex.g_field->fld_length = sizeof (GDS_TIMESTAMP); - } + { + /* Post warning saying that DATE is equivalent to TIMESTAMP */ + ERRD_post_warning (isc_sqlwarn, gds_arg_number, (SLONG) 301, + isc_arg_warning, isc_dtype_renamed, 0); + lex.g_field->fld_dtype = dtype_timestamp; + lex.g_field->fld_length = sizeof (GDS_TIMESTAMP); + } else if (client_dialect == SQL_DIALECT_V6_TRANSITION) - yyabandon (-104, isc_transitional_date); + yyabandon (-104, isc_transitional_date); else - { - lex.g_field->fld_dtype = dtype_sql_date; - lex.g_field->fld_length = sizeof (ULONG); - } + { + lex.g_field->fld_dtype = dtype_sql_date; + lex.g_field->fld_length = sizeof (ULONG); + } } | TIME { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); lex.g_field->fld_dtype = dtype_sql_time; lex.g_field->fld_length = sizeof (SLONG); } @@ -2405,15 +2405,15 @@ character_keyword : CHARACTER national_character_keyword : NCHAR | NATIONAL CHARACTER - | NATIONAL KW_CHAR - ; + | NATIONAL KW_CHAR + ; /* numeric type */ numeric_type : KW_NUMERIC prec_scale - { + { lex.g_field->fld_sub_type = dsc_num_type_numeric; } | decimal_keyword prec_scale @@ -2430,120 +2430,120 @@ numeric_type : KW_NUMERIC prec_scale prec_scale : { lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); + lex.g_field->fld_length = sizeof (SLONG); lex.g_field->fld_precision = 9; - } + } | '(' signed_long_integer ')' - { + { if ( ((SLONG) $2 < 1) || ((SLONG) $2 > 18) ) - yyabandon (-842, isc_precision_err); + yyabandon (-842, isc_precision_err); /* Precision most be between 1 and 18. */ if ((SLONG) $2 > 9) - { - if ( ( (client_dialect <= SQL_DIALECT_V5) && - (db_dialect > SQL_DIALECT_V5) ) || + { + if ( ( (client_dialect <= SQL_DIALECT_V5) && + (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && - (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (gds_sqlerr, + (db_dialect <= SQL_DIALECT_V5) ) ) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -817, gds_arg_gds, isc_ddl_not_allowed_by_db_sql_dial, gds_arg_number, (SLONG) db_dialect, 0); - if (client_dialect <= SQL_DIALECT_V5) - { + if (client_dialect <= SQL_DIALECT_V5) + { lex.g_field->fld_dtype = dtype_double; lex.g_field->fld_length = sizeof (double); - } - else - { + } + else + { if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - ERRD_post_warning ( + { + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous1, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous2, gds_arg_end ); - } + } lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); - } - } + } + } else - if ((SLONG) $2 < 5) - { - lex.g_field->fld_dtype = dtype_short; - lex.g_field->fld_length = sizeof (SSHORT); - } - else - { - lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); - } + if ((SLONG) $2 < 5) + { + lex.g_field->fld_dtype = dtype_short; + lex.g_field->fld_length = sizeof (SSHORT); + } + else + { + lex.g_field->fld_dtype = dtype_long; + lex.g_field->fld_length = sizeof (SLONG); + } lex.g_field->fld_precision = (USHORT)(ULONG) $2; } | '(' signed_long_integer ',' signed_long_integer ')' { if ( ((SLONG) $2 < 1) || ((SLONG) $2 > 18) ) - yyabandon (-842, isc_precision_err); + yyabandon (-842, isc_precision_err); /* Precision should be between 1 and 18 */ if (((SLONG) $4 > (SLONG) $2) || ((SLONG) $4 < 0)) - yyabandon (-842, isc_scale_nogt); + yyabandon (-842, isc_scale_nogt); /* Scale must be between 0 and precision */ if ((SLONG) $2 > 9) - { - if ( ( (client_dialect <= SQL_DIALECT_V5) && - (db_dialect > SQL_DIALECT_V5) ) || + { + if ( ( (client_dialect <= SQL_DIALECT_V5) && + (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && - (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (gds_sqlerr, + (db_dialect <= SQL_DIALECT_V5) ) ) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -817, gds_arg_gds, isc_ddl_not_allowed_by_db_sql_dial, gds_arg_number, (SLONG) db_dialect, 0); - if (client_dialect <= SQL_DIALECT_V5) - { + if (client_dialect <= SQL_DIALECT_V5) + { lex.g_field->fld_dtype = dtype_double; lex.g_field->fld_length = sizeof (double); - } - else - { + } + else + { if (client_dialect == SQL_DIALECT_V6_TRANSITION) { - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous1, gds_arg_end ); - ERRD_post_warning ( + ERRD_post_warning ( isc_dsql_warn_precision_ambiguous2, gds_arg_end ); } /* client_dialect >= SQL_DIALECT_V6 */ lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); - } - } + } + } else - { - if ((SLONG) $2 < 5) - { - lex.g_field->fld_dtype = dtype_short; - lex.g_field->fld_length = sizeof (SSHORT); - } - else - { - lex.g_field->fld_dtype = dtype_long; - lex.g_field->fld_length = sizeof (SLONG); - } - } + { + if ((SLONG) $2 < 5) + { + lex.g_field->fld_dtype = dtype_short; + lex.g_field->fld_length = sizeof (SSHORT); + } + else + { + lex.g_field->fld_dtype = dtype_long; + lex.g_field->fld_length = sizeof (SLONG); + } + } lex.g_field->fld_precision = (USHORT)(ULONG) $2; lex.g_field->fld_scale = - (SSHORT)(SLONG) $4; } @@ -2560,15 +2560,15 @@ decimal_keyword : DECIMAL float_type : KW_FLOAT precision_opt { if ((SLONG) $2 > 7) - { - lex.g_field->fld_dtype = dtype_double; - lex.g_field->fld_length = sizeof (double); - } + { + lex.g_field->fld_dtype = dtype_double; + lex.g_field->fld_length = sizeof (double); + } else - { - lex.g_field->fld_dtype = dtype_real; - lex.g_field->fld_length = sizeof (float); - } + { + lex.g_field->fld_dtype = dtype_real; + lex.g_field->fld_length = sizeof (float); + } } | KW_LONG KW_FLOAT precision_opt { @@ -2607,16 +2607,16 @@ set_generator : SET GENERATOR symbol_generator_name TO signed_long_integer $$ = make_node (nod_set_generator2,e_gen_id_count,$3, MAKE_constant ((STR) $5, CONSTANT_SLONG)); } - | SET GENERATOR symbol_generator_name TO NUMBER64BIT - { + | SET GENERATOR symbol_generator_name TO NUMBER64BIT + { $$ = make_node (nod_set_generator2,e_gen_id_count,$3, - MAKE_constant((STR)$5, CONSTANT_SINT64)); + MAKE_constant((STR)$5, CONSTANT_SINT64)); } - | SET GENERATOR symbol_generator_name TO '-' NUMBER64BIT - { + | SET GENERATOR symbol_generator_name TO '-' NUMBER64BIT + { $$ = make_node (nod_set_generator2, e_gen_id_count, $3, make_node(nod_negate, 1, - MAKE_constant((STR)$6, CONSTANT_SINT64))); + MAKE_constant((STR)$6, CONSTANT_SINT64))); } ; @@ -2684,7 +2684,7 @@ tran_opt_list_m : tran_opt_list tran_opt_list : tran_opt | tran_opt_list tran_opt - { $$ = make_node (nod_list, (int) 2, $1, $2); } + { $$ = make_node (nod_list, (int) 2, $1, $2); } ; tran_opt : access_mode @@ -2754,7 +2754,7 @@ lock_mode : READ restr_list : restr_option | restr_list ',' restr_option - { $$ = make_node (nod_list, (int) 2, $1, $3); } + { $$ = make_node (nod_list, (int) 2, $1, $3); } ; restr_option : table_list table_lock @@ -2769,7 +2769,7 @@ table_lock : FOR lock_type lock_mode table_list : simple_table_name | table_list ',' simple_table_name - { $$ = make_node (nod_list, (int) 2, $1, $3); } + { $$ = make_node (nod_list, (int) 2, $1, $3); } ; @@ -2850,7 +2850,7 @@ lock_clause : WITH LOCK /* SELECT expression */ select_expr : SELECT limit_clause - distinct_clause + distinct_clause select_list from_clause where_clause @@ -2859,10 +2859,10 @@ select_expr : SELECT limit_clause plan_clause { $$ = make_node (nod_select_expr, e_sel_count, $2, $3, $4, $5, $6, $7, $8, $9, NULL, NULL); } - ; + ; ordered_select_expr : SELECT limit_clause - distinct_clause + distinct_clause select_list from_clause where_clause @@ -2872,7 +2872,7 @@ ordered_select_expr : SELECT limit_clause order_clause { $$ = make_node (nod_select_expr, e_sel_count, $2, $3, $4, $5, $6, $7, $8, $9, $10, NULL); } - ; + ; begin_limit : { lex.limit_clause = true; } @@ -3006,14 +3006,14 @@ null_or_value_list : null_or_value ; null_or_value : null_value - | value - ; + | value + ; table_name : simple_table_name | symbol_table_name symbol_table_alias_name { $$ = make_node (nod_relation_name, (int) e_rln_count, $1, $2); } - ; + ; simple_table_name: symbol_table_name { $$ = make_node (nod_relation_name, @@ -3171,11 +3171,11 @@ update : update_searched update_searched : UPDATE table_name SET assignments where_clause { $$ = make_node (nod_update, e_upd_count, $2, make_list ($4), $5, NULL); } - ; + ; update_positioned : UPDATE table_name SET assignments cursor_clause { $$ = make_node (nod_update, e_upd_count, - $2, make_list ($4), NULL, $5); } + $2, make_list ($4), NULL, $5); } ; assignments : assignment @@ -3194,9 +3194,9 @@ rhs : value /* BLOB get and put */ -blob : READ BLOB simple_column_name FROM simple_table_name filter_clause segment_clause +blob : READ BLOB simple_column_name FROM simple_table_name filter_clause segment_clause { $$ = make_node (nod_get_segment, e_blb_count, $3, $5, $6, $7); } - | INSERT BLOB simple_column_name INTO simple_table_name filter_clause segment_clause + | INSERT BLOB simple_column_name INTO simple_table_name filter_clause segment_clause { $$ = make_node (nod_put_segment, e_blb_count, $3, $5, $6, $7); } ; @@ -3258,7 +3258,7 @@ ins_column_list : update_column_name ; /* end IBO hack */ -column_name : simple_column_name +column_name : simple_column_name | symbol_table_alias_name '.' symbol_column_name { $$ = make_node (nod_field_name, (int) e_fln_count, $1, $3); } @@ -3490,7 +3490,7 @@ table_subquery : '(' column_select ')' ; column_select : SELECT limit_clause - distinct_clause + distinct_clause value from_clause where_clause @@ -3498,12 +3498,12 @@ column_select : SELECT limit_clause having_clause plan_clause order_clause - { $$ = make_node (nod_select_expr, e_sel_count, + { $$ = make_node (nod_select_expr, e_sel_count, $2, $3, make_list ($4), $5, $6, $7, $8, $9, $10, NULL); } ; column_singleton : SELECT limit_clause - distinct_clause + distinct_clause value from_clause where_clause @@ -3511,7 +3511,7 @@ column_singleton : SELECT limit_clause having_clause plan_clause order_clause - { $$ = make_node (nod_select_expr, e_sel_count, + { $$ = make_node (nod_select_expr, e_sel_count, $2, $3, make_list ($4), $5, $6, $7, $8, $9, $10, MAKE_constant ((STR) 1, CONSTANT_SLONG)); } ; @@ -3530,14 +3530,14 @@ value : column_name | udf | '-' value { $$ = make_node (nod_negate, 1, $2); } - | '+' value - { $$ = $2; } + | '+' value + { $$ = $2; } | value '+' value { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_add2, 2, $1, $3); + $$ = make_node (nod_add2, 2, $1, $3); else - $$ = make_node (nod_add, 2, $1, $3); + $$ = make_node (nod_add, 2, $1, $3); } | value CONCATENATE value { $$ = make_node (nod_concatenate, 2, $1, $3); } @@ -3546,23 +3546,23 @@ value : column_name | value '-' value { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_subtract2, 2, $1, $3); + $$ = make_node (nod_subtract2, 2, $1, $3); else - $$ = make_node (nod_subtract, 2, $1, $3); + $$ = make_node (nod_subtract, 2, $1, $3); } | value '*' value { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_multiply2, 2, $1, $3); + $$ = make_node (nod_multiply2, 2, $1, $3); else - $$ = make_node (nod_multiply, 2, $1, $3); + $$ = make_node (nod_multiply, 2, $1, $3); } | value '/' value { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_divide2, 2, $1, $3); + $$ = make_node (nod_divide2, 2, $1, $3); else - $$ = make_node (nod_divide, 2, $1, $3); + $$ = make_node (nod_divide, 2, $1, $3); } | '(' value ')' { $$ = $2; } @@ -3575,10 +3575,10 @@ value : column_name { $$ = make_node (nod_dbkey, 1, NULL); } | symbol_table_alias_name '.' DB_KEY { $$ = make_node (nod_dbkey, 1, $1); } - | KW_VALUE - { + | KW_VALUE + { $$ = make_node (nod_dom_value, 0, NULL); - } + } | datetime_value_expression { $$ = $1; } ; @@ -3586,33 +3586,33 @@ value : column_name datetime_value_expression : CURRENT_DATE { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "DATE", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "DATE", + 0); $$ = make_node (nod_current_date, 0, NULL); } | CURRENT_TIME { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); $$ = make_node (nod_current_time, 0, NULL); } | CURRENT_TIMESTAMP @@ -3651,33 +3651,33 @@ u_constant : u_numeric_constant | DATE STRING { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "DATE", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "DATE", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "DATE", + 0); $$ = MAKE_constant ((STR) $2, CONSTANT_DATE); } | TIME STRING { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_dialect_datatype_unsupport, - gds_arg_number, client_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_dialect_datatype_unsupport, + gds_arg_number, client_dialect, + gds_arg_string, "TIME", + 0); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, - gds_arg_number, db_dialect, - gds_arg_string, "TIME", - 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, isc_sql_db_dialect_dtype_unsupport, + gds_arg_number, db_dialect, + gds_arg_string, "TIME", + 0); $$ = MAKE_constant ((STR) $2, CONSTANT_TIME); } | TIMESTAMP STRING @@ -3729,28 +3729,28 @@ signed_short_integer : nonneg_short_integer nonneg_short_integer : NUMBER { if ((SLONG) $1 > SHRT_POS_MAX) - yyabandon (-842, isc_expec_short); + yyabandon (-842, isc_expec_short); /* Short integer expected */ $$ = $1;} ; neg_short_integer : NUMBER { if ((SLONG) $1 > SHRT_NEG_MAX) - yyabandon (-842, isc_expec_short); + yyabandon (-842, isc_expec_short); /* Short integer expected */ $$ = $1;} ; pos_short_integer : nonneg_short_integer { if ((SLONG) $1 == 0) - yyabandon (-842, isc_expec_positive); + yyabandon (-842, isc_expec_positive); /* Positive number expected */ $$ = $1;} ; unsigned_short_integer : NUMBER { if ((SLONG) $1 > SHRT_UNSIGNED_MAX) - yyabandon (-842, isc_expec_ushort); + yyabandon (-842, isc_expec_ushort); /* Unsigned short integer expected */ $$ = $1;} ; @@ -3778,37 +3778,37 @@ aggregate_function : COUNT '(' '*' ')' { $$ = make_node (nod_agg_count, 1, $4); } | COUNT '(' DISTINCT value ')' { $$ = make_flag_node (nod_agg_count, - NOD_AGG_DISTINCT, 1, $4); } + NOD_AGG_DISTINCT, 1, $4); } | SUM '(' all_noise value ')' { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_agg_total2, 1, $4); + $$ = make_node (nod_agg_total2, 1, $4); else - $$ = make_node (nod_agg_total, 1, $4); + $$ = make_node (nod_agg_total, 1, $4); } | SUM '(' DISTINCT value ')' { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_flag_node (nod_agg_total2, + $$ = make_flag_node (nod_agg_total2, NOD_AGG_DISTINCT, 1, $4); else - $$ = make_flag_node (nod_agg_total, + $$ = make_flag_node (nod_agg_total, NOD_AGG_DISTINCT, 1, $4); } | AVG '(' all_noise value ')' { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_agg_average2, 1, $4); + $$ = make_node (nod_agg_average2, 1, $4); else - $$ = make_node (nod_agg_average, 1, $4); + $$ = make_node (nod_agg_average, 1, $4); } | AVG '(' DISTINCT value ')' { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_flag_node (nod_agg_average2, + $$ = make_flag_node (nod_agg_average2, NOD_AGG_DISTINCT, 1, $4); else - $$ = make_flag_node (nod_agg_average, + $$ = make_flag_node (nod_agg_average, NOD_AGG_DISTINCT, 1, $4); } | MINIMUM '(' all_noise value ')' @@ -3826,7 +3826,7 @@ aggregate_function : COUNT '(' '*' ')' generate_value_function : GEN_ID '(' symbol_generator_name ',' value ')' { if (client_dialect >= SQL_DIALECT_V6_TRANSITION) - $$ = make_node (nod_gen_id2, 2, $3, $5); + $$ = make_node (nod_gen_id2, 2, $3, $5); else $$ = make_node (nod_gen_id, 2, $3, $5); } @@ -4042,11 +4042,11 @@ non_reserved_word : | NULLS | STATEMENT | USING - | INSERTING - | UPDATING - | DELETING + | INSERTING + | UPDATING + | DELETING /* | FIRST | SKIP -- this is handled by the lexer. */ - | BACKUP /* added in FB 2.0 */ + | BACKUP /* added in FB 2.0 */ | KW_DIFFERENCE ; @@ -4092,9 +4092,9 @@ void LEX_dsql_init (void) void LEX_string ( - TEXT *string, - USHORT length, - SSHORT character_set) + TEXT *string, + USHORT length, + SSHORT character_set) { /************************************** * @@ -4107,12 +4107,12 @@ void LEX_string ( * **************************************/ - lex.line_start = lex.ptr = string; - lex.end = string + length; - lex.lines = 1; - lex.att_charset = character_set; - lex.line_start_bk = lex.line_start; - lex.lines_bk = lex.lines; + lex.line_start = lex.ptr = string; + lex.end = string + length; + lex.lines = 1; + lex.att_charset = character_set; + lex.line_start_bk = lex.line_start; + lex.lines_bk = lex.lines; lex.param_number = 1; lex.prev_keyword = -1; lex.prev_prev_keyword = -1; @@ -4120,8 +4120,8 @@ void LEX_string ( lex.first_detection = false; lex.brace_analysis = false; #ifdef DEV_BUILD - if (DSQL_debug & 32) - printf("%.*s\n", (int)length, string); + if (DSQL_debug & 32) + printf("%.*s\n", (int)length, string); #endif } @@ -4139,23 +4139,23 @@ static void check_log_file_attrs (void) * *********************************************/ - if (lex.g_file->fil_partitions) { - if (!lex.g_file->fil_length) { - yyabandon (-261, isc_log_length_spec); - /* Total length of a partitioned log must be specified */ - } - - if (PARTITION_SIZE (OneK * lex.g_file->fil_length, lex.g_file->fil_partitions) < - (OneK*MIN_LOG_LENGTH)) { - yyabandon (-239, isc_partition_too_small); - /* Log partition size too small */ - } - } - else { - if ((lex.g_file->fil_length) && (lex.g_file->fil_length < MIN_LOG_LENGTH)) { - yyabandon (-239, isc_log_too_small); /* Log size too small */ - } - } + if (lex.g_file->fil_partitions) { + if (!lex.g_file->fil_length) { + yyabandon (-261, isc_log_length_spec); + /* Total length of a partitioned log must be specified */ + } + + if (PARTITION_SIZE (OneK * lex.g_file->fil_length, lex.g_file->fil_partitions) < + (OneK*MIN_LOG_LENGTH)) { + yyabandon (-239, isc_partition_too_small); + /* Log partition size too small */ + } + } + else { + if ((lex.g_file->fil_length) && (lex.g_file->fil_length < MIN_LOG_LENGTH)) { + yyabandon (-239, isc_log_too_small); /* Log size too small */ + } + } } @@ -4173,14 +4173,13 @@ static TEXT *lex_position (void) * **************************************/ -return lex.ptr; + return lex.ptr; } #ifdef NOT_USED_OR_REPLACED -static BOOLEAN long_int ( - DSQL_NOD string, - SLONG *long_value) +static bool long_int(DSQL_NOD string, + SLONG *long_value) { /************************************* * @@ -4197,18 +4196,17 @@ static BOOLEAN long_int ( for (const char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) { if (!(classes [*p] & CHR_DIGIT)) { - return FALSE; + return false; } } *long_value = atol ((char *)((STR) string)->str_data); - return TRUE; + return true; } #endif -static DSQL_FLD make_field ( - DSQL_NOD field_name) +static DSQL_FLD make_field (DSQL_NOD field_name) { /************************************** * @@ -4220,23 +4218,23 @@ static DSQL_FLD make_field ( * Make a field block of given name. * **************************************/ -DSQL_FLD field; -STR string; -TSQL tdsql; + DSQL_FLD field; + STR string; + TSQL tdsql; -tdsql = GET_THREAD_DATA; - -if (field_name == NULL) - { - field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; - strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); - return field; - } -string = (STR) field_name->nod_arg [1]; -field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; -strcpy (field->fld_name, (TEXT*) string->str_data); + tdsql = GET_THREAD_DATA; -return field; + if (field_name == NULL) + { + field = FB_NEW_RPT(*tdsql->tsql_default, sizeof (INTERNAL_FIELD_NAME)) dsql_fld; + strcpy (field->fld_name, (TEXT*) INTERNAL_FIELD_NAME); + return field; + } + string = (STR) field_name->nod_arg [1]; + field = FB_NEW_RPT(*tdsql->tsql_default, strlen ((SCHAR*) string->str_data)) dsql_fld; + strcpy (field->fld_name, (TEXT*) string->str_data); + + return field; } @@ -4252,19 +4250,18 @@ static FIL make_file (void) * Make a file block * **************************************/ -FIL temp_file; -TSQL tdsql; + FIL temp_file; + TSQL tdsql; -tdsql = GET_THREAD_DATA; - -temp_file = FB_NEW(*tdsql->tsql_default) fil; + tdsql = GET_THREAD_DATA; + + temp_file = FB_NEW(*tdsql->tsql_default) fil; -return temp_file; + return temp_file; } -static DSQL_NOD make_list ( - DSQL_NOD node) +static DSQL_NOD make_list (DSQL_NOD node) { /************************************** * @@ -4276,33 +4273,33 @@ static DSQL_NOD make_list ( * Collapse nested list nodes into single list. * **************************************/ -DSQL_NOD *ptr; -DLLS stack, temp; -USHORT l; -DSQL_NOD old; -TSQL tdsql; + DSQL_NOD *ptr; + DLLS stack, temp; + USHORT l; + DSQL_NOD old; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -if (!node) - return node; + if (!node) + return node; -stack = 0; -stack_nodes (node, &stack); -for (l = 0, temp = stack; temp; temp = temp->lls_next) - l++; + stack = 0; + stack_nodes (node, &stack); + for (l = 0, temp = stack; temp; temp = temp->lls_next) + l++; -old = node; -node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; -node->nod_count = l; -node->nod_type = nod_list; -node->nod_flags = old->nod_flags; -ptr = node->nod_arg + node->nod_count; + old = node; + node = FB_NEW_RPT(*tdsql->tsql_default, l) dsql_nod; + node->nod_count = l; + node->nod_type = nod_list; + node->nod_flags = old->nod_flags; + ptr = node->nod_arg + node->nod_count; -while (stack) - *--ptr = (DSQL_NOD) LLS_POP (&stack); + while (stack) + *--ptr = (DSQL_NOD) LLS_POP (&stack); -return node; + return node; } @@ -4319,26 +4316,25 @@ static DSQL_NOD make_parameter (void) * Any change should also be made to function below * **************************************/ -DSQL_NOD node; -TSQL tdsql; + DSQL_NOD node; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; -node->nod_type = nod_parameter; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = 1; -node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; + node = FB_NEW_RPT(*tdsql->tsql_default, 1) dsql_nod; + node->nod_type = nod_parameter; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = 1; + node->nod_arg[0] = (DSQL_NOD)(ULONG) lex.param_number++; -return node; + return node; } -static DSQL_NOD make_node ( - NOD_TYPE type, - int count, - ...) +static DSQL_NOD make_node (NOD_TYPE type, + int count, + ...) { /************************************** * @@ -4351,32 +4347,31 @@ static DSQL_NOD make_node ( * Any change should also be made to function below * **************************************/ -DSQL_NOD node, *p; -va_list ptr; -TSQL tdsql; + DSQL_NOD node, *p; + va_list ptr; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; -node->nod_type = type; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = count; -p = node->nod_arg; -VA_START (ptr, count); + node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; + node->nod_type = type; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = count; + p = node->nod_arg; + VA_START (ptr, count); -while (--count >= 0) - *p++ = va_arg (ptr, DSQL_NOD); + while (--count >= 0) + *p++ = va_arg (ptr, DSQL_NOD); -return node; + return node; } -static DSQL_NOD make_flag_node ( - NOD_TYPE type, - SSHORT flag, - int count, - ...) +static DSQL_NOD make_flag_node (NOD_TYPE type, + SSHORT flag, + int count, + ...) { /************************************** * @@ -4388,25 +4383,25 @@ static DSQL_NOD make_flag_node ( * Make a node of given type. Set flag field * **************************************/ -DSQL_NOD node, *p; -va_list ptr; -TSQL tdsql; + DSQL_NOD node, *p; + va_list ptr; + TSQL tdsql; -tdsql = GET_THREAD_DATA; + tdsql = GET_THREAD_DATA; -node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; -node->nod_type = type; -node->nod_flags = flag; -node->nod_line = (USHORT) lex.lines_bk; -node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); -node->nod_count = count; -p = node->nod_arg; -VA_START (ptr, count); + node = FB_NEW_RPT(*tdsql->tsql_default, count) dsql_nod; + node->nod_type = type; + node->nod_flags = flag; + node->nod_line = (USHORT) lex.lines_bk; + node->nod_column = (USHORT) (lex.last_token_bk - lex.line_start_bk + 1); + node->nod_count = count; + p = node->nod_arg; + VA_START (ptr, count); -while (--count >= 0) - *p++ = va_arg (ptr, DSQL_NOD); + while (--count >= 0) + *p++ = va_arg (ptr, DSQL_NOD); -return node; + return node; } @@ -4425,35 +4420,34 @@ static void prepare_console_debug (int level, int *yydeb) * *************************************/ #if defined(DEV_BUILD) - DSQL_debug = level; + DSQL_debug = level; #endif - if (level >> 8) - *yydeb = level >> 8; - /* CVC: I added this code form Mike Nordell to see the output from internal - operations that's generated in DEV build when DEBUG is typed into isql.exe. - When n>0, the output console is activated; otherwise it's closed. */ + if (level >> 8) + *yydeb = level >> 8; + /* CVC: I added this code form Mike Nordell to see the output from internal + operations that's generated in DEV build when DEBUG is typed into isql.exe. + When n>0, the output console is activated; otherwise it's closed. */ #if defined(DEV_BUILD) && defined(WIN_NT) && defined(SUPERSERVER) -static FILE* redirected_output; - if (level > 0) { - /* Console debug code inside this scope */ - if (AllocConsole()) { - redirected_output = freopen("CONOUT$", "wt", stdout); - printf("DebugConsole - Yes, it's working.\n"); - } - } - else if (level <= 0 && redirected_output) { - fclose (redirected_output); - redirected_output = 0; - FreeConsole(); - } + static FILE* redirected_output; + if (level > 0) { + /* Console debug code inside this scope */ + if (AllocConsole()) { + redirected_output = freopen("CONOUT$", "wt", stdout); + printf("DebugConsole - Yes, it's working.\n"); + } + } + else if (level <= 0 && redirected_output) { + fclose (redirected_output); + redirected_output = 0; + FreeConsole(); + } #endif } #ifdef NOT_USED_OR_REPLACED -static BOOLEAN short_int ( - DSQL_NOD string, - SLONG *long_value, - SSHORT range) +static bool short_int(DSQL_NOD string, + SLONG *long_value, + SSHORT range) { /************************************* * @@ -4468,20 +4462,20 @@ static BOOLEAN short_int ( *************************************/ if (((STR) string)->str_length > 5) { - return FALSE; + return false; } for (char* p = ((STR) string)->str_data; classes [*p] & CHR_DIGIT; p++) { if (!(classes [*p] & CHR_DIGIT)) { - return FALSE; + return false; } } /* there are 5 or fewer digits, it's value may still be greater * than 32767... */ - SCHAR buf[10]; + SCHAR buf[10]; buf [0] = ((STR) string)->str_data[0]; buf [1] = ((STR) string)->str_data[1]; buf [2] = ((STR) string)->str_data[2]; @@ -4491,27 +4485,26 @@ static BOOLEAN short_int ( *long_value = atoi (buf); - BOOLEAN return_value; + bool return_value; switch (range) { case POSITIVE: - return_value = *long_value > SHRT_POS_MAX; + return_value = *long_value > SHRT_POS_MAX; break; case NEGATIVE: return_value = *long_value > SHRT_NEG_MAX; break; case UNSIGNED: - return_value = *long_value > SHRT_UNSIGNED_MAX; + return_value = *long_value > SHRT_UNSIGNED_MAX; break; } return !return_value; } #endif -static void stack_nodes ( - DSQL_NOD node, - DLLS *stack) +static void stack_nodes (DSQL_NOD node, + DLLS *stack) { /************************************** * @@ -4523,78 +4516,78 @@ static void stack_nodes ( * Assist in turning a tree of misc nodes into a clean list. * **************************************/ -DSQL_NOD *ptr, *end; -DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; + DSQL_NOD *ptr, *end; + DSQL_NOD curr_node, next_node, start_chain, end_chain, save_link; -if (node->nod_type != nod_list) - { - LLS_PUSH (node, stack); - return; - } + if (node->nod_type != nod_list) + { + LLS_PUSH (node, stack); + return; + } -/* To take care of cases where long lists of nodes are in a chain - of list nodes with exactly one entry, this algorithm will look - for a pattern of repeated list nodes with two entries, the first - being a list node and the second being a non-list node. Such - a list will be reverse linked, and then re-reversed, stacking the - non-list nodes in the process. The purpose of this is to avoid - massive recursion of this function. */ + /* To take care of cases where long lists of nodes are in a chain + of list nodes with exactly one entry, this algorithm will look + for a pattern of repeated list nodes with two entries, the first + being a list node and the second being a non-list node. Such + a list will be reverse linked, and then re-reversed, stacking the + non-list nodes in the process. The purpose of this is to avoid + massive recursion of this function. */ -start_chain = node; -end_chain = NULL; -curr_node = node; -next_node = node->nod_arg[0]; -while ( curr_node->nod_count == 2 && - curr_node->nod_arg[0]->nod_type == nod_list && - curr_node->nod_arg[1]->nod_type != nod_list && - next_node->nod_arg[0]->nod_type == nod_list && - next_node->nod_arg[1]->nod_type != nod_list) - { + start_chain = node; + end_chain = NULL; + curr_node = node; + next_node = node->nod_arg[0]; + while ( curr_node->nod_count == 2 && + curr_node->nod_arg[0]->nod_type == nod_list && + curr_node->nod_arg[1]->nod_type != nod_list && + next_node->nod_arg[0]->nod_type == nod_list && + next_node->nod_arg[1]->nod_type != nod_list) + { - /* pattern was found so reverse the links and go to next node */ + /* pattern was found so reverse the links and go to next node */ - save_link = next_node->nod_arg[0]; - next_node->nod_arg[0] = curr_node; - curr_node = next_node; - next_node = save_link; - end_chain = curr_node; - } + save_link = next_node->nod_arg[0]; + next_node->nod_arg[0] = curr_node; + curr_node = next_node; + next_node = save_link; + end_chain = curr_node; + } -/* see if any chain was found */ + /* see if any chain was found */ -if ( end_chain) - { + if ( end_chain) + { - /* first, handle the rest of the nodes */ - /* note that next_node still points to the first non-pattern node */ + /* first, handle the rest of the nodes */ + /* note that next_node still points to the first non-pattern node */ - stack_nodes( next_node, stack); + stack_nodes( next_node, stack); - /* stack the non-list nodes and reverse the chain on the way back */ - - curr_node = end_chain; - while ( TRUE) - { - LLS_PUSH( curr_node->nod_arg[1], stack); - if ( curr_node == start_chain) - break; - save_link = curr_node->nod_arg[0]; - curr_node->nod_arg[0] = next_node; - next_node = curr_node; - curr_node = save_link; - } - return; - } + /* stack the non-list nodes and reverse the chain on the way back */ + + curr_node = end_chain; + while (true) + { + LLS_PUSH( curr_node->nod_arg[1], stack); + if ( curr_node == start_chain) + break; + save_link = curr_node->nod_arg[0]; + curr_node->nod_arg[0] = next_node; + next_node = curr_node; + curr_node = save_link; + } + return; + } -for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) - stack_nodes (*ptr, stack); + for (ptr = node->nod_arg, end = ptr + node->nod_count; ptr < end; ptr++) + stack_nodes (*ptr, stack); } inline static int yylex ( - USHORT client_dialect, - USHORT db_dialect, - USHORT parser_version, - BOOLEAN *stmt_ambiguous) + USHORT client_dialect, + USHORT db_dialect, + USHORT parser_version, + BOOLEAN *stmt_ambiguous) { int temp = lex.yylex(client_dialect, db_dialect, parser_version, stmt_ambiguous); lex.prev_prev_keyword = lex.prev_keyword; @@ -4603,10 +4596,10 @@ inline static int yylex ( } int LexerState::yylex ( - USHORT client_dialect, - USHORT db_dialect, - USHORT parser_version, - BOOLEAN *stmt_ambiguous) + USHORT client_dialect, + USHORT db_dialect, + USHORT parser_version, + BOOLEAN *stmt_ambiguous) { /************************************** * @@ -4617,179 +4610,179 @@ int LexerState::yylex ( * Functional description: lexer. * **************************************/ -UCHAR tok_class; -char string[MAX_TOKEN_LEN]; -char* p; -char* buffer; -char* buffer_end; -char* new_buffer; -SYM sym; -SSHORT c; -USHORT buffer_len; + UCHAR tok_class; + char string[MAX_TOKEN_LEN]; + char* p; + char* buffer; + char* buffer_end; + char* new_buffer; + SYM sym; + SSHORT c; + USHORT buffer_len; -STR delimited_id_str; + STR delimited_id_str; -/* Find end of white space and skip comments */ + /* Find end of white space and skip comments */ -for (;;) - { - if (ptr >= end) - return -1; - - c = *ptr++; - - /* Process comments */ - - if (c == '\n') { - lines++; - line_start = ptr; - continue; - } - - if ((c == '-') && (*ptr == '-')) { - - /* single-line */ - - ptr++; - while (ptr < end) { - if ((c = *ptr++) == '\n') { - lines++; - line_start = ptr /* + 1*/; /* CVC: +1 left out. */ - break; - } - } + for (;;) + { if (ptr >= end) return -1; - continue; - } - else if ((c == '/') && (*ptr == '*')) { - - /* multi-line */ - - ptr++; - while (ptr < end) { - if ((c = *ptr++) == '*') { - if (*ptr == '/') + + c = *ptr++; + + /* Process comments */ + + if (c == '\n') { + lines++; + line_start = ptr; + continue; + } + + if ((c == '-') && (*ptr == '-')) { + + /* single-line */ + + ptr++; + while (ptr < end) { + if ((c = *ptr++) == '\n') { + lines++; + line_start = ptr /* + 1*/; /* CVC: +1 left out. */ break; + } } - if (c == '\n') { - lines++; - line_start = ptr /* + 1*/; /* CVC: +1 left out. */ + if (ptr >= end) + return -1; + continue; + } + else if ((c == '/') && (*ptr == '*')) { + + /* multi-line */ + + ptr++; + while (ptr < end) { + if ((c = *ptr++) == '*') { + if (*ptr == '/') + break; + } + if (c == '\n') { + lines++; + line_start = ptr /* + 1*/; /* CVC: +1 left out. */ + } } - } + if (ptr >= end) + return -1; + ptr++; + continue; + } + + tok_class = classes [c]; + + if (!(tok_class & CHR_WHITE)) + break; + } + + /* Depending on tok_class of token, parse token */ + + last_token = ptr - 1; + + if (tok_class & CHR_INTRODUCER) + { + /* The Introducer (_) is skipped, all other idents are copied + * to become the name of the character set + */ + p = string; + for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) + { if (ptr >= end) return -1; - ptr++; - continue; - } - - tok_class = classes [c]; - - if (!(tok_class & CHR_WHITE)) - break; - } - -/* Depending on tok_class of token, parse token */ - -last_token = ptr - 1; - -if (tok_class & CHR_INTRODUCER) - { - /* The Introducer (_) is skipped, all other idents are copied - * to become the name of the character set - */ - p = string; - for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) - { - if (ptr >= end) - return -1; - CHECK_COPY_INCR(p, UPPER7(*ptr)); - } - - CHECK_BOUND(p); - *p = 0; - - /* make a string value to hold the name, the name - * is resolved in pass1_constant */ - - yylval = (DSQL_NOD) (MAKE_string(string, p - string))->str_data; - - return INTRODUCER; - } - -/* parse a quoted string, being sure to look for double quotes */ - -if (tok_class & CHR_QUOTE) - { - buffer = string; - buffer_len = sizeof (string); - buffer_end = buffer + buffer_len - 1; - for (p = buffer; ; p++) - { - if (ptr >= end) - { - if (buffer != string) - gds__free (buffer); - return -1; - } - /* *ptr is quote - if next != quote we're at the end */ - if ((*ptr == c) && ((++ptr == end) || (*ptr != c))) - break; - if (p > buffer_end) - { - new_buffer = (char*)gds__alloc (2 * buffer_len); - /* FREE: at outer block */ - if (!new_buffer) /* NOMEM: */ - { - if (buffer != string) - gds__free (buffer); - return -1; + CHECK_COPY_INCR(p, UPPER7(*ptr)); } - memcpy (new_buffer, buffer, buffer_len); - if (buffer != string) - gds__free (buffer); - buffer = new_buffer; - p = buffer + buffer_len; - buffer_len = 2 * buffer_len; - buffer_end = buffer + buffer_len - 1; - } - *p = *ptr++; - } - if (c == '"') - { - *stmt_ambiguous = TRUE; /* string delimited by double quotes could be - ** either a string constant or a SQL delimited - ** identifier, therefore marks the SQL - ** statement as ambiguous */ - if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - if (buffer != string) - gds__free (buffer); - yyabandon (-104, isc_invalid_string_constant); - } - else if (client_dialect >= SQL_DIALECT_V6) - { - if ((p - buffer) >= MAX_TOKEN_LEN) - { - if (buffer != string) - gds__free (buffer); - yyabandon (-104, isc_token_too_long); + + CHECK_BOUND(p); + *p = 0; + + /* make a string value to hold the name, the name + * is resolved in pass1_constant */ + + yylval = (DSQL_NOD) (MAKE_string(string, p - string))->str_data; + + return INTRODUCER; } - yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); - delimited_id_str = (STR) yylval; - delimited_id_str->str_flags |= STR_delimited_id; - if (buffer != string) + + /* parse a quoted string, being sure to look for double quotes */ + + if (tok_class & CHR_QUOTE) + { + buffer = string; + buffer_len = sizeof (string); + buffer_end = buffer + buffer_len - 1; + for (p = buffer; ; p++) + { + if (ptr >= end) + { + if (buffer != string) + gds__free (buffer); + return -1; + } + /* *ptr is quote - if next != quote we're at the end */ + if ((*ptr == c) && ((++ptr == end) || (*ptr != c))) + break; + if (p > buffer_end) + { + new_buffer = (char*)gds__alloc (2 * buffer_len); + /* FREE: at outer block */ + if (!new_buffer) /* NOMEM: */ + { + if (buffer != string) + gds__free (buffer); + return -1; + } + memcpy (new_buffer, buffer, buffer_len); + if (buffer != string) + gds__free (buffer); + buffer = new_buffer; + p = buffer + buffer_len; + buffer_len = 2 * buffer_len; + buffer_end = buffer + buffer_len - 1; + } + *p = *ptr++; + } + if (c == '"') + { + *stmt_ambiguous = TRUE; /* string delimited by double quotes could be + ** either a string constant or a SQL delimited + ** identifier, therefore marks the SQL + ** statement as ambiguous */ + if (client_dialect == SQL_DIALECT_V6_TRANSITION) + { + if (buffer != string) + gds__free (buffer); + yyabandon (-104, isc_invalid_string_constant); + } + else if (client_dialect >= SQL_DIALECT_V6) + { + if ((p - buffer) >= MAX_TOKEN_LEN) + { + if (buffer != string) + gds__free (buffer); + yyabandon (-104, isc_token_too_long); + } + yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); + delimited_id_str = (STR) yylval; + delimited_id_str->str_flags |= STR_delimited_id; + if (buffer != string) + gds__free (buffer); + return SYMBOL; + } + } + yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); + if (buffer != string) gds__free (buffer); - return SYMBOL; - } - } - yylval = (DSQL_NOD) MAKE_string(buffer, p - buffer); - if (buffer != string) - gds__free (buffer); - return STRING; - } - + return STRING; + } + /* * Check for a numeric constant, which starts either with a digit or with * a decimal point followed by a digit. @@ -4816,344 +4809,344 @@ if (tok_class & CHR_QUOTE) * ptr points to the next character. */ -assert(ptr <= end); + assert(ptr <= end); -if ((tok_class & CHR_DIGIT) || - ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) - { - /* The following variables are used to recognize kinds of numbers. */ - - BOOLEAN have_error = FALSE; /* syntax error or value too large */ - BOOLEAN have_digit = FALSE; /* we've seen a digit */ - BOOLEAN have_decimal = FALSE; /* we've seen a '.' */ - BOOLEAN have_exp = FALSE; /* digit ... [eE] */ - BOOLEAN have_exp_sign = FALSE; /* digit ... [eE] {+-] */ - BOOLEAN have_exp_digit = FALSE; /* digit ... [eE] ... digit */ - UINT64 number = 0; - UINT64 limit_by_10 = MAX_SINT64 / 10; - - for (--ptr ; ptr < end ; ptr++) - { - c = *ptr; - if (have_exp_digit && (! (classes [c] & CHR_DIGIT))) - /* First non-digit after exponent and digit terminates - the token. */ - break; - else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) - { - /* only digits can be accepted after "1E-" */ - have_error = TRUE; - break; - } - else if (have_exp) - { - /* We've seen e or E, but nothing beyond that. */ - if ( ('-' == c) || ('+' == c) ) - have_exp_sign = TRUE; - else if ( classes [c] & CHR_DIGIT ) - /* We have a digit: we haven't seen a sign yet, - but it's too late now. */ - have_exp_digit = have_exp_sign = TRUE; - else - { - /* end of the token */ - have_error = TRUE; - break; - } - } - else if ('.' == c) - { - if (!have_decimal) - have_decimal = TRUE; - else - { - have_error = TRUE; - break; - } - } - else if (classes [c] & CHR_DIGIT) - { - /* Before computing the next value, make sure there will be - no overflow. */ - - have_digit = TRUE; - - if (number >= limit_by_10) - /* possibility of an overflow */ - if ((number > limit_by_10) || (c > '8')) - { - have_error = TRUE; - break; - } - number = number * 10 + (c - '0'); - } - else if ( (('E' == c) || ('e' == c)) && have_digit ) - have_exp = TRUE; - else - /* Unexpected character: this is the end of the number. */ - break; - } - - /* We're done scanning the characters: now return the right kind - of number token, if any fits the bill. */ - - if (!have_error) + if ((tok_class & CHR_DIGIT) || + ((c == '.') && (ptr < end) && (classes [*ptr] & CHR_DIGIT))) { - assert(have_digit); + /* The following variables are used to recognize kinds of numbers. */ - if (have_exp_digit) - { - yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; + bool have_error = false; /* syntax error or value too large */ + bool have_digit = false; /* we've seen a digit */ + bool have_decimal = false; /* we've seen a '.' */ + bool have_exp = false; /* digit ... [eE] */ + bool have_exp_sign = false; /* digit ... [eE] {+-] */ + bool have_exp_digit = false; /* digit ... [eE] ... digit */ + UINT64 number = 0; + UINT64 limit_by_10 = MAX_SINT64 / 10; - return FLOAT_NUMBER; - } - else if (!have_exp) - { - - /* We should return some kind (scaled-) integer type - except perhaps in dialect 1. */ - - if (!have_decimal && (number <= MAX_SLONG)) + for (--ptr ; ptr < end ; ptr++) { - yylval = (DSQL_NOD) (ULONG) number; - return NUMBER; - } - else - { - /* We have either a decimal point with no exponent - or a string of digits whose value exceeds MAX_SLONG: - the returned type depends on the client dialect, - so warn of the difference if the client dialect is - SQL_DIALECT_V6_TRANSITION. - */ - - if (SQL_DIALECT_V6_TRANSITION == client_dialect) - { - /* Issue a warning about the ambiguity of the numeric - * numeric literal. There are multiple calls because - * the message text exceeds the 119-character limit - * of our message database. - */ - ERRD_post_warning( isc_dsql_warning_number_ambiguous, - gds_arg_string, - ERR_string( last_token, - ptr - last_token ), - gds_arg_end ); - ERRD_post_warning( isc_dsql_warning_number_ambiguous1, - gds_arg_end ); - } - - yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); - - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - - if (client_dialect < SQL_DIALECT_V6_TRANSITION) - return FLOAT_NUMBER; - else if (have_decimal) - return SCALEDINT; - else - return NUMBER64BIT; - } - } /* else if (!have_exp) */ - } /* if (!have_error) */ - - /* we got some kind of error or overflow, so don't recognize this - * as a number: just pass it through to the next part of the lexer. - */ - } - -/* Restore the status quo ante, before we started our unsuccessful - attempt to recognize a number. */ -ptr = last_token; -c = *ptr++; -/* We never touched tok_class, so it doesn't need to be restored. */ - -/* end of number-recognition code */ - - -if (tok_class & CHR_LETTER) -{ - p = string; - CHECK_COPY_INCR(p, UPPER (c)); - for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) - { - if (ptr >= end) - return -1; - CHECK_COPY_INCR(p, UPPER (*ptr)); - } - - CHECK_BOUND(p); - *p = 0; - sym = HSHD_lookup (NULL, (TEXT *) string, (SSHORT)(p - string), SYM_keyword, parser_version); - if (sym) - { - /* 13 June 2003. Nickolay Samofatov - * Detect INSERTING/UPDATING/DELETING as non-reserved keywords. - * We need to help parser from lexer because our grammar is not LARL(1) in this case - */ - if (prev_keyword == '(' && !brace_analysis && - (sym->sym_keyword == INSERTING || - sym->sym_keyword == UPDATING || - sym->sym_keyword == DELETING - ) && - /* Produce special_trigger_action_predicate only where we can handle it - - in search conditions */ - (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || - prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || - prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) - { - LexerState savedState = lex; - int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - lex = savedState; - if (nextToken==OR || nextToken==AND) { - switch(sym->sym_keyword) { - case INSERTING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_INSERTING; - case UPDATING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_UPDATING; - case DELETING: - yylval = (DSQL_NOD) sym->sym_object; - return KW_DELETING; + c = *ptr; + if (have_exp_digit && (! (classes [c] & CHR_DIGIT))) + /* First non-digit after exponent and digit terminates + the token. */ + break; + else if (have_exp_sign && (! (classes [c] & CHR_DIGIT))) + { + /* only digits can be accepted after "1E-" */ + have_error = true; + break; + } + else if (have_exp) + { + /* We've seen e or E, but nothing beyond that. */ + if ( ('-' == c) || ('+' == c) ) + have_exp_sign = true; + else if ( classes [c] & CHR_DIGIT ) + /* We have a digit: we haven't seen a sign yet, + but it's too late now. */ + have_exp_digit = have_exp_sign = true; + else + { + /* end of the token */ + have_error = true; + break; } } - } - /* 23 May 2003. Nickolay Samofatov - * Detect FIRST/SKIP as non-reserved keywords - * 1. We detect FIRST or SKIP as keywords if they appear just after SELECT and - * immediately before parameter mark ('?'), opening brace ('(') or number - * 2. We detect SKIP as a part of FIRST/SKIP clause the same way - * 3. We detect FIRST if we are explicitly asked for (such as in NULLS FIRST/LAST clause) - * 4. In all other cases we return them as SYMBOL - */ - if ((sym->sym_keyword == FIRST && !first_detection) || sym->sym_keyword == SKIP) { - if (prev_keyword == SELECT || limit_clause) { - LexerState savedState = lex; - int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - lex = savedState; - if (nextToken != NUMBER && nextToken != '?' && nextToken != '(') { - yylval = (DSQL_NOD) MAKE_string(string, p - string); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return SYMBOL; - } else { - yylval = (DSQL_NOD) sym->sym_object; - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return sym->sym_keyword; + else if ('.' == c) + { + if (!have_decimal) + have_decimal = true; + else + { + have_error = true; + break; } - } /* else fall down and return token as SYMBOL */ - } else { - yylval = (DSQL_NOD) sym->sym_object; - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return sym->sym_keyword; + } + else if (classes [c] & CHR_DIGIT) + { + /* Before computing the next value, make sure there will be + no overflow. */ + + have_digit = true; + + if (number >= limit_by_10) + /* possibility of an overflow */ + if ((number > limit_by_10) || (c > '8')) + { + have_error = true; + break; + } + number = number * 10 + (c - '0'); + } + else if ( (('E' == c) || ('e' == c)) && have_digit ) + have_exp = true; + else + /* Unexpected character: this is the end of the number. */ + break; } - } - yylval = (DSQL_NOD) MAKE_string(string, p - string); - last_token_bk = last_token; - line_start_bk = line_start; - lines_bk = lines; - return SYMBOL; -} -/* Must be punctuation -- test for double character punctuation */ + /* We're done scanning the characters: now return the right kind + of number token, if any fits the bill. */ -if (last_token + 1 < end) - { - sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); - if (sym) - { - ++ptr; - return sym->sym_keyword; - } - } - -/* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ -/* This algorithm is not perfect, but it is ok for now. - It should be dropped when BOOLEAN datatype is introduced in Firebird */ -if ( c == '(' && !brace_analysis && - /* 1) We need to swallow braces in all boolean expressions - 2) We may swallow braces in ordinary expressions - 3) We should not swallow braces after special tokens - like IF, FIRST, SKIP, VALUES and 30 more other - */ - (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || - prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) -{ - LexerState savedState = lex; - brace_analysis = true; - int openCount = 0; - int nextToken; - do { - openCount++; - nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); - } while (nextToken == '('); - DSQL_NOD temp_val = yylval; - if (nextToken == INSERTING || nextToken == UPDATING || nextToken == DELETING) - { - /* Skip closing braces. */ - while ( openCount && - yylex(client_dialect,db_dialect, - parser_version,stmt_ambiguous) == ')') + if (!have_error) { - openCount--; + assert(have_digit); + + if (have_exp_digit) + { + yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + + return FLOAT_NUMBER; + } + else if (!have_exp) + { + + /* We should return some kind (scaled-) integer type + except perhaps in dialect 1. */ + + if (!have_decimal && (number <= MAX_SLONG)) + { + yylval = (DSQL_NOD) (ULONG) number; + return NUMBER; + } + else + { + /* We have either a decimal point with no exponent + or a string of digits whose value exceeds MAX_SLONG: + the returned type depends on the client dialect, + so warn of the difference if the client dialect is + SQL_DIALECT_V6_TRANSITION. + */ + + if (SQL_DIALECT_V6_TRANSITION == client_dialect) + { + /* Issue a warning about the ambiguity of the numeric + * numeric literal. There are multiple calls because + * the message text exceeds the 119-character limit + * of our message database. + */ + ERRD_post_warning( isc_dsql_warning_number_ambiguous, + gds_arg_string, + ERR_string( last_token, + ptr - last_token ), + gds_arg_end ); + ERRD_post_warning( isc_dsql_warning_number_ambiguous1, + gds_arg_end ); + } + + yylval = (DSQL_NOD) MAKE_string(last_token, ptr - last_token); + + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + + if (client_dialect < SQL_DIALECT_V6_TRANSITION) + return FLOAT_NUMBER; + else if (have_decimal) + return SCALEDINT; + else + return NUMBER64BIT; + } + } /* else if (!have_exp) */ + } /* if (!have_error) */ + + /* we got some kind of error or overflow, so don't recognize this + * as a number: just pass it through to the next part of the lexer. + */ + } + + /* Restore the status quo ante, before we started our unsuccessful + attempt to recognize a number. */ + ptr = last_token; + c = *ptr++; + /* We never touched tok_class, so it doesn't need to be restored. */ + + /* end of number-recognition code */ + + + if (tok_class & CHR_LETTER) + { + p = string; + CHECK_COPY_INCR(p, UPPER (c)); + for (; ptr < end && classes [*ptr] & CHR_IDENT; ptr++) + { + if (ptr >= end) + return -1; + CHECK_COPY_INCR(p, UPPER (*ptr)); } - if (openCount) { - /* Not enough closing braces. Restore status quo. */ - lex = savedState; - } - else { - /* Cool! We successfully swallowed braces ! */ - brace_analysis = false; - yylval = temp_val; - /* Check if we need to handle LR(2) grammar case */ - if (prev_keyword == '(' && + + CHECK_BOUND(p); + *p = 0; + sym = HSHD_lookup (NULL, (TEXT *) string, (SSHORT)(p - string), SYM_keyword, parser_version); + if (sym) + { + /* 13 June 2003. Nickolay Samofatov + * Detect INSERTING/UPDATING/DELETING as non-reserved keywords. + * We need to help parser from lexer because our grammar is not LARL(1) in this case + */ + if (prev_keyword == '(' && !brace_analysis && + (sym->sym_keyword == INSERTING || + sym->sym_keyword == UPDATING || + sym->sym_keyword == DELETING + ) && /* Produce special_trigger_action_predicate only where we can handle it - in search conditions */ (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) { - savedState = lex; - int token = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + LexerState savedState = lex; + int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); lex = savedState; - if (token==OR || token==AND) { - switch(nextToken) { + if (nextToken==OR || nextToken==AND) { + switch(sym->sym_keyword) { case INSERTING: + yylval = (DSQL_NOD) sym->sym_object; return KW_INSERTING; case UPDATING: + yylval = (DSQL_NOD) sym->sym_object; return KW_UPDATING; case DELETING: + yylval = (DSQL_NOD) sym->sym_object; return KW_DELETING; } } } - return nextToken; + /* 23 May 2003. Nickolay Samofatov + * Detect FIRST/SKIP as non-reserved keywords + * 1. We detect FIRST or SKIP as keywords if they appear just after SELECT and + * immediately before parameter mark ('?'), opening brace ('(') or number + * 2. We detect SKIP as a part of FIRST/SKIP clause the same way + * 3. We detect FIRST if we are explicitly asked for (such as in NULLS FIRST/LAST clause) + * 4. In all other cases we return them as SYMBOL + */ + if ((sym->sym_keyword == FIRST && !first_detection) || sym->sym_keyword == SKIP) { + if (prev_keyword == SELECT || limit_clause) { + LexerState savedState = lex; + int nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + lex = savedState; + if (nextToken != NUMBER && nextToken != '?' && nextToken != '(') { + yylval = (DSQL_NOD) MAKE_string(string, p - string); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return SYMBOL; + } else { + yylval = (DSQL_NOD) sym->sym_object; + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return sym->sym_keyword; + } + } /* else fall down and return token as SYMBOL */ + } else { + yylval = (DSQL_NOD) sym->sym_object; + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return sym->sym_keyword; + } } - } else { - /* Restore status quo. */ - lex = savedState; + yylval = (DSQL_NOD) MAKE_string(string, p - string); + last_token_bk = last_token; + line_start_bk = line_start; + lines_bk = lines; + return SYMBOL; } -} -/* Single character punctuation are simply passed on */ + /* Must be punctuation -- test for double character punctuation */ -return c; + if (last_token + 1 < end) + { + sym = HSHD_lookup (NULL, last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); + if (sym) + { + ++ptr; + return sym->sym_keyword; + } + } + + /* We need to swallow braces around INSERTING/UPDATING/DELETING keywords */ + /* This algorithm is not perfect, but it is ok for now. + It should be dropped when BOOLEAN datatype is introduced in Firebird */ + if ( c == '(' && !brace_analysis && + /* 1) We need to swallow braces in all boolean expressions + 2) We may swallow braces in ordinary expressions + 3) We should not swallow braces after special tokens + like IF, FIRST, SKIP, VALUES and 30 more other + */ + (prev_keyword=='(' || prev_keyword==NOT || prev_keyword==AND || prev_keyword==OR || + prev_keyword==ON || prev_keyword==HAVING || prev_keyword==WHERE || prev_keyword==WHEN) ) + { + LexerState savedState = lex; + brace_analysis = true; + int openCount = 0; + int nextToken; + do { + openCount++; + nextToken = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + } while (nextToken == '('); + DSQL_NOD temp_val = yylval; + if (nextToken == INSERTING || nextToken == UPDATING || nextToken == DELETING) + { + /* Skip closing braces. */ + while ( openCount && + yylex(client_dialect,db_dialect, + parser_version,stmt_ambiguous) == ')') + { + openCount--; + } + if (openCount) { + /* Not enough closing braces. Restore status quo. */ + lex = savedState; + } + else { + /* Cool! We successfully swallowed braces ! */ + brace_analysis = false; + yylval = temp_val; + /* Check if we need to handle LR(2) grammar case */ + if (prev_keyword == '(' && + /* Produce special_trigger_action_predicate only where we can handle it - + in search conditions */ + (prev_prev_keyword=='(' || prev_prev_keyword==NOT || prev_prev_keyword==AND || + prev_prev_keyword==OR || prev_prev_keyword==ON || prev_prev_keyword==HAVING || + prev_prev_keyword==WHERE || prev_prev_keyword==WHEN) ) + { + savedState = lex; + int token = yylex(client_dialect,db_dialect,parser_version,stmt_ambiguous); + lex = savedState; + if (token==OR || token==AND) { + switch(nextToken) { + case INSERTING: + return KW_INSERTING; + case UPDATING: + return KW_UPDATING; + case DELETING: + return KW_DELETING; + } + } + } + return nextToken; + } + } else { + /* Restore status quo. */ + lex = savedState; + } + } + + /* Single character punctuation are simply passed on */ + + return c; } static void yyerror ( - TEXT *error_string) + TEXT *error_string) { /************************************** * @@ -5166,27 +5159,25 @@ static void yyerror ( * **************************************/ -if (yychar < 1) - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ - 0); -else - { - ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, - gds_arg_gds, gds_dsql_token_unk_err, - gds_arg_number, (SLONG) lex.lines, - gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ - /* Token unknown - line %d, char %d */ - gds_arg_gds, gds_random, - gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, - 0); - } + if (yychar < 1) + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, gds_command_end_err, /* Unexpected end of command */ + 0); + else + { + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) -104, + gds_arg_gds, gds_dsql_token_unk_err, + gds_arg_number, (SLONG) lex.lines, + gds_arg_number, (SLONG) (lex.last_token - lex.line_start + 1), /*CVC: +1*/ + /* Token unknown - line %d, char %d */ + gds_arg_gds, gds_random, + gds_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, 0); + } } -static void yyabandon ( - SSHORT sql_code, - ISC_STATUS error_symbol) +static void yyabandon (SSHORT sql_code, + ISC_STATUS error_symbol) { /************************************** * @@ -5199,6 +5190,6 @@ static void yyabandon ( * **************************************/ -ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, - gds_arg_gds, error_symbol, 0); + ERRD_post (gds_sqlerr, gds_arg_number, (SLONG) sql_code, + gds_arg_gds, error_symbol, 0); } diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 76944745b2..8ada7fb262 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -1958,7 +1958,7 @@ static void explode_asterisk(DSQL_REQ request, DSQL_NOD node, DSQL_NOD aggregate DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_derived_field_value]; derived_field->nod_arg[e_derived_field_name] = select_item->nod_arg[e_derived_field_name]; - derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; + derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level; derived_field->nod_desc = select_item->nod_desc; LLS_PUSH(derived_field, stack); } @@ -3424,7 +3424,7 @@ static DSQL_NOD pass1_derived_table(DSQL_REQ request, DSQL_NOD input) derived_field = MAKE_node(nod_derived_field, e_derived_field_count); derived_field->nod_arg[e_derived_field_value] = select_item; derived_field->nod_arg[e_derived_field_name] = list->nod_arg[count]; - derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; + derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level; derived_field->nod_desc = select_item->nod_desc; rse->nod_arg[e_rse_items]->nod_arg[count] = derived_field; @@ -4537,7 +4537,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); derived_field->nod_arg[e_derived_field_value] = select_item; derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias; - derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; + derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level; derived_field->nod_desc = select_item->nod_desc; return derived_field; } @@ -4555,7 +4555,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD DSQL_NOD derived_field = MAKE_node(nod_derived_field, e_derived_field_count); derived_field->nod_arg[e_derived_field_value] = select_item->nod_arg[e_alias_value]; derived_field->nod_arg[e_derived_field_name] = (DSQL_NOD) alias; - derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; + derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level; derived_field->nod_desc = select_item->nod_desc; return derived_field; } @@ -4570,7 +4570,7 @@ static DSQL_NOD pass1_make_derived_field(DSQL_REQ request, TSQL tdsql, DSQL_NOD // with orginal map. if (derived_field->nod_type == nod_derived_field) { derived_field->nod_arg[e_derived_field_value] = select_item; - derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD) request->req_scope_level; + derived_field->nod_arg[e_derived_field_scope] = (DSQL_NOD)(ULONG) request->req_scope_level; derived_field->nod_desc = select_item->nod_desc; return derived_field; } diff --git a/src/dsql/preparse.cpp b/src/dsql/preparse.cpp index 6086dc4b7f..262b7d390c 100644 --- a/src/dsql/preparse.cpp +++ b/src/dsql/preparse.cpp @@ -60,7 +60,7 @@ extern "C" { static void generate_error(ISC_STATUS *, SCHAR *, SSHORT, SSHORT); static SSHORT get_next_token(SCHAR **, SCHAR *, SCHAR *, USHORT *); -static SSHORT get_token(ISC_STATUS *, SSHORT, BOOLEAN, SCHAR **, SCHAR *, +static SSHORT get_token(ISC_STATUS *, SSHORT, bool, SCHAR **, SCHAR *, SCHAR *, USHORT *); typedef struct pp_table { @@ -111,18 +111,21 @@ static const PP_TABLE pp_symbols[] = { @param dialect **/ -int DLL_EXPORT PREPARSE_execute( - ISC_STATUS * user_status, +int DLL_EXPORT PREPARSE_execute(ISC_STATUS * user_status, FRBRD ** db_handle, FRBRD ** trans_handle, -USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) + USHORT stmt_length, + SCHAR * stmt, + BOOLEAN * stmt_eaten, + USHORT dialect) { TEXT file_name[MAX_TOKEN_SIZE + 1]; SCHAR *token, *dpb_array, *dpb, *ch, *stmt_end; SLONG page_size = 0; USHORT dpb_len = 0, token_length; SSHORT i, l, result; - BOOLEAN matched, get_out; + bool matched; + bool get_out; ISC_STATUS_ARRAY temp_status; FRBRD *temp_db_handle = NULL; @@ -139,26 +142,29 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) stmt_length = strlen(stmt); stmt_end = stmt + stmt_length; - if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, token, + if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token, &token_length) || token_length != pp_symbols[PP_CREATE].length || - strcmp(token, pp_symbols[PP_CREATE].symbol)) { + strcmp(token, pp_symbols[PP_CREATE].symbol)) + { gds__free((SLONG *) token); return FALSE; } - if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, token, + if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token, &token_length) || (token_length != pp_symbols[PP_DATABASE].length && token_length != pp_symbols[PP_SCHEMA].length) || (strcmp(token, pp_symbols[PP_DATABASE].symbol) && - strcmp(token, pp_symbols[PP_SCHEMA].symbol))) { + strcmp(token, pp_symbols[PP_SCHEMA].symbol))) + { gds__free((SLONG *) token); return FALSE; } - if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, token, - &token_length)) { + if (get_token(user_status, STRING, false, &stmt, stmt_end, token, + &token_length)) + { gds__free((SLONG *) token); return TRUE; } @@ -191,33 +197,35 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) else if (result < 0) break; - matched = FALSE; + matched = false; for (i = 3; pp_symbols[i].length && !matched; i++) { if (token_length == pp_symbols[i].length && !strcmp(token, pp_symbols[i].symbol)) { - get_out = FALSE; + get_out = false; switch (pp_symbols[i].code) { case PP_PAGE_SIZE: case PP_PAGESIZE: - if (get_token(user_status, '=', TRUE, &stmt, stmt_end, + if (get_token(user_status, '=', true, &stmt, stmt_end, token, &token_length) || - get_token(user_status, NUMERIC, FALSE, &stmt, - stmt_end, token, &token_length)) { - get_out = TRUE; + get_token(user_status, NUMERIC, false, &stmt, + stmt_end, token, &token_length)) + { + get_out = true; break; } page_size = atol(token); STUFF_DPB(gds_dpb_page_size); STUFF_DPB(4); STUFF_DPB_INT(page_size); - matched = TRUE; + matched = true; break; case PP_USER: - if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, - token, &token_length)) { - get_out = TRUE; + if (get_token(user_status, STRING, false, &stmt, stmt_end, + token, &token_length)) + { + get_out = true; break; } @@ -227,13 +235,14 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) ch = token; while (*ch) STUFF_DPB(*ch++); - matched = TRUE; + matched = true; break; case PP_PASSWORD: - if (get_token(user_status, STRING, FALSE, &stmt, stmt_end, - token, &token_length)) { - get_out = TRUE; + if (get_token(user_status, STRING, false, &stmt, stmt_end, + token, &token_length)) + { + get_out = true; break; } @@ -243,17 +252,18 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) ch = token; while (*ch) STUFF_DPB(*ch++); - matched = TRUE; + matched = true; break; case PP_SET: - if (get_token(user_status, SYMBOL, FALSE, &stmt, stmt_end, + if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token, &token_length) || token_length != pp_symbols[PP_NAMES].length || strcmp(token, pp_symbols[PP_NAMES].symbol) || - get_token(user_status, STRING, FALSE, &stmt, stmt_end, - token, &token_length)) { - get_out = TRUE; + get_token(user_status, STRING, false, &stmt, stmt_end, + token, &token_length)) + { + get_out = true; break; } @@ -263,26 +273,27 @@ USHORT stmt_length, SCHAR * stmt, BOOLEAN * stmt_eaten, USHORT dialect) ch = token; while (*ch) STUFF_DPB(*ch++); - matched = TRUE; + matched = true; break; case PP_LENGTH: /* Skip a token for value */ - if (get_token(user_status, '=', TRUE, &stmt, stmt_end, + if (get_token(user_status, '=', true, &stmt, stmt_end, token, &token_length) || - get_token(user_status, NUMERIC, FALSE, &stmt, - stmt_end, token, &token_length)) { - get_out = TRUE; + get_token(user_status, NUMERIC, false, &stmt, + stmt_end, token, &token_length)) + { + get_out = true; break; } - matched = TRUE; + matched = true; break; case PP_PAGE: case PP_PAGES: - matched = TRUE; + matched = true; break; } @@ -531,12 +542,13 @@ static SSHORT get_next_token( @param token_length **/ -static SSHORT get_token( - ISC_STATUS * status, +static SSHORT get_token(ISC_STATUS * status, SSHORT token_type, - BOOLEAN optional, + bool optional, SCHAR ** stmt, -SCHAR * stmt_end, SCHAR * token, USHORT * token_length) + SCHAR * stmt_end, + SCHAR * token, + USHORT * token_length) { SSHORT result; SCHAR *temp_stmt; diff --git a/src/dsql/user_dsql.cpp b/src/dsql/user_dsql.cpp index 74d863e114..3aae2420a0 100644 --- a/src/dsql/user_dsql.cpp +++ b/src/dsql/user_dsql.cpp @@ -101,13 +101,13 @@ static void init(FRBRD**); static NAME insert_name(SCHAR*, NAME *, STMT); static USHORT name_length(SCHAR *); static void remove_name(NAME, NAME *); -static BOOLEAN scompare(SCHAR*, USHORT, SCHAR*, USHORT); +static bool scompare(SCHAR*, USHORT, SCHAR*, USHORT); /* declare the private data */ #pragma FB_COMPILER_MESSAGE("Dragons ahead. Static data. Not thread safe!") -static BOOLEAN init_flag = FALSE; /* whether we've been initialized */ +static bool init_flag = false; /* whether we've been initialized */ static ERR UDSQL_error = NULL; static STMT statements = NULL; static NAME statement_names = NULL; @@ -1339,7 +1339,7 @@ static void cleanup(void* arg) return; } - init_flag = FALSE; + init_flag = false; gds__free(UDSQL_error); UDSQL_error = NULL; @@ -1500,7 +1500,7 @@ static void init(FRBRD** db_handle) if (!UDSQL_error) { // NOMEM: return; // Don't set the init_flag } - init_flag = TRUE; + init_flag = true; gds__register_cleanup(cleanup, 0); } @@ -1527,10 +1527,7 @@ static void init(FRBRD** db_handle) dbb->dbb_database_handle = *db_handle; ISC_STATUS_ARRAY local_status; - gds__database_cleanup(local_status, - db_handle, - cleanup_database, - (SLONG) FALSE); + gds__database_cleanup(local_status, db_handle, cleanup_database, (SLONG) 0); } @@ -1671,10 +1668,10 @@ static void remove_name(NAME name, NAME* list_ptr) } -static BOOLEAN scompare(SCHAR* string1, - USHORT length1, - SCHAR* string2, - USHORT length2) +static bool scompare(SCHAR* string1, + USHORT length1, + SCHAR* string2, + USHORT length2) { /************************************** * @@ -1688,7 +1685,7 @@ static BOOLEAN scompare(SCHAR* string1, **************************************/ if (length1 != length2) { - return FALSE; + return false; } SCHAR c1, c2; @@ -1698,11 +1695,11 @@ static BOOLEAN scompare(SCHAR* string1, c2 = *string2++; if (c1 != c2 && UPPER7(c1) != UPPER7(c2)) { - return FALSE; + return false; } } - return TRUE; + return true; } diff --git a/src/jrd/os/thd_priority.h b/src/jrd/os/thd_priority.h index 54f29939d6..7078a688b4 100644 --- a/src/jrd/os/thd_priority.h +++ b/src/jrd/os/thd_priority.h @@ -51,9 +51,9 @@ private: static MemoryPool * pool; // where we should place our thps static ThreadPriorityScheduler * chain; // where starts thps chain static ThreadPriorityScheduler * news; // where starts new thps chain - static BOOLEAN initialized; + static bool initialized; static DWORD specific_key; // for thread LS access - static BOOLEAN shutdown; // server shutting down + static bool shutdown; // server shutting down ThreadPriorityScheduler * next; // next thread in list union { @@ -77,7 +77,7 @@ public: static void Exit(void); static thdd *Get(void); static void Set(thdd *val); - static BOOLEAN Boosted(void); + static bool Boosted(void); static void Cleanup(void); static void Init(void); static void Attach(HANDLE tHandle, DWORD thread_id, int &p); @@ -109,7 +109,7 @@ public: #define THPS_INIT() #define THPS_FINI() #define THPS_ATTACH(handle, thread_id, priority) -#define THPS_BOOSTDONE() FALSE +#define THPS_BOOSTDONE() false #endif // THREAD_PSCHED diff --git a/src/jrd/os/vms/extvms.cpp b/src/jrd/os/vms/extvms.cpp index 8060e821f6..8dce472051 100644 --- a/src/jrd/os/vms/extvms.cpp +++ b/src/jrd/os/vms/extvms.cpp @@ -48,18 +48,18 @@ static struct FAB fab; static struct RAB rab; -static BOOLEAN check_sort(NOD, IDX *, USHORT); -static BOOLEAN compare(UCHAR *, UCHAR *, USHORT); +static bool check_sort(NOD, IDX *, USHORT); +static bool compare(UCHAR *, UCHAR *, USHORT); static int compare_segment(NOD, UCHAR *, DSC *); static int connect(EXT, USHORT); static void disconnect(EXT); static void expand_format(FMT, FMT); static SLONG find_field(FMT, USHORT, USHORT, USHORT); -static int get_dbkey(RSB); -static int get_indexed(RSB); +static bool get_dbkey(RSB); +static bool get_indexed(RSB); static USHORT get_key_segment(NOD, UCHAR *, DSC *); -static BOOLEAN get_sequential(RSB); -static BOOLEAN match_index(FMT, struct XABKEY *, IDX *); +static bool get_sequential(RSB); +static bool match_index(FMT, struct XABKEY *, IDX *); static int open_indexed(RSB); static int open_sequential(RSB); static void position_by_rfa(EXT, USHORT *); @@ -313,17 +313,26 @@ int EXT_get(RSB rsb) return FALSE; switch (rsb->rsb_type) { - case rsb_ext_sequential: - return get_sequential(rsb); - - case rsb_ext_indexed: - return get_indexed(rsb); - - case rsb_ext_dbkey: - return get_dbkey(rsb); - - default: - IBERROR(181); /* msg 181 external access type not implemented */ + case rsb_ext_sequential: + if (get_sequential(rsb)) + return TRUE; + else + return FALSE; + + case rsb_ext_indexed: + if (get_indexed(rsb)) + return TRUE + else + return FALSE; + + case rsb_ext_dbkey: + if (get_dbkey(rsb)) + return TRUE + else + return FALSE + + default: + IBERROR(181); /* msg 181 external access type not implemented */ } } @@ -641,7 +650,7 @@ void EXT_trans_start(TRA transaction) } -static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream) +static bool check_sort(NOD sort, IDX * index, USHORT stream) { /************************************** * @@ -661,7 +670,7 @@ static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream) index segments, we obviously can optimize anything */ if (!sort || sort->nod_count > index->idx_count) - return FALSE; + return false; /* For each sort key, make sure the key matches the index segment, and that the sort is ascending */ @@ -672,14 +681,17 @@ static BOOLEAN check_sort(NOD sort, IDX * index, USHORT stream) if (field->nod_type != nod_field || (USHORT) field->nod_arg[e_fld_stream] != stream || (USHORT) field->nod_arg[e_fld_id] != tail->idx_field || - ptr[sort->nod_count]) return FALSE; + ptr[sort->nod_count]) + { + return false; + } } - return TRUE; + return true; } -static BOOLEAN compare(UCHAR * string1, UCHAR * string2, USHORT length) +static bool compare(UCHAR * string1, UCHAR * string2, USHORT length) { /************************************** * @@ -694,10 +706,10 @@ static BOOLEAN compare(UCHAR * string1, UCHAR * string2, USHORT length) do if (*string1++ != *string2++) - return 1; + return true; while (--length); - return 0; + return false; } @@ -862,7 +874,7 @@ static SLONG find_field( } -static get_dbkey(RSB rsb) +static bool get_dbkey(RSB rsb) { /************************************** * @@ -903,7 +915,7 @@ static get_dbkey(RSB rsb) /* If this isn't the first time thru its the last time thru */ if (!(impure->irsb_flags & irsb_first)) - return FALSE; + return false; /* Evaluate expression */ @@ -922,18 +934,18 @@ static get_dbkey(RSB rsb) file->ext_flags &= ~EXT_eof; if (status == RMS$_EOF) - return FALSE; + return false; sys$free(&rab); set_flags(relation, record); MOVE_FAST(rab.rab$w_rfa, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa)); MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa)); - return TRUE; + return true; } -static get_indexed(RSB rsb) +static bool get_indexed(RSB rsb) { /************************************** * @@ -999,7 +1011,7 @@ static get_indexed(RSB rsb) status = sys$find(&rab); file->ext_flags &= ~EXT_eof; if (status == RMS$_EOF || status == RMS$_RNF) - return FALSE; + return false; if (!(status & 1)) ERR_post(isc_io_error, gds_arg_string, "sys$find", @@ -1012,7 +1024,7 @@ static get_indexed(RSB rsb) EOF, we're done */ if (!get_sequential(rsb)) - return FALSE; + return false; /* Check record against upper bound. If we pass it, we're done. Note: this code ignores issues of inclusive/exclusive upper @@ -1029,10 +1041,10 @@ static get_indexed(RSB rsb) if (result < 0) break; if (result > 0) - return FALSE; + return false; } - return TRUE; + return true; } @@ -1062,7 +1074,7 @@ static USHORT get_key_segment(NOD node, UCHAR * buffer, DSC * target) } -static BOOLEAN get_sequential(RSB rsb) +static bool get_sequential(RSB rsb) { /************************************** * @@ -1106,7 +1118,9 @@ static BOOLEAN get_sequential(RSB rsb) if (rpb->rpb_ext_isi == file->ext_isi && !(impure->irsb_flags & irsb_first) && compare(file->ext_dbkey, &rpb->rpb_ext_dbkey, sizeof(rab.rab$w_rfa))) + { position_by_rfa(file, &rpb->rpb_ext_dbkey); + } rab.rab$b_rac = RAB$C_SEQ; status = sys$get(&rab); @@ -1114,7 +1128,7 @@ static BOOLEAN get_sequential(RSB rsb) file->ext_flags &= ~EXT_eof; if (status == RMS$_EOF) - return FALSE; + return false; if (!(status & 1)) ERR_post(isc_io_error, @@ -1133,11 +1147,11 @@ static BOOLEAN get_sequential(RSB rsb) if (rpb->rpb_ext_isi == file->ext_isi) MOVE_FAST(rab.rab$w_rfa, file->ext_dbkey, sizeof(rab.rab$w_rfa)); - return TRUE; + return true; } -static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx) +static bool match_index(FMT format, struct XABKEY *xab, IDX * idx) { /************************************** * @@ -1147,8 +1161,8 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx) * * Functional description * Try to match RMS key against fields. If success, build - * internal index description and return TRUE. Otherwise - * return FALSE. + * internal index description and return true. Otherwise + * return false. * **************************************/ int n, dtype; @@ -1163,7 +1177,7 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx) for (; size < end; size++, position++, tail++) { if ((n = find_field(format, xab->xab$b_dtp, *position, *size)) < 0) - return FALSE; + return false; tail->idx_field = n; tail->idx_itype = xab->xab$b_dtp; } @@ -1173,7 +1187,7 @@ static BOOLEAN match_index(FMT format, struct XABKEY *xab, IDX * idx) idx->idx_flags = 0; idx->idx_id = xab->xab$b_ref; - return TRUE; + return true; } diff --git a/src/jrd/os/vms/map.cpp b/src/jrd/os/vms/map.cpp index bdf6d3595d..4e2c4b5cef 100644 --- a/src/jrd/os/vms/map.cpp +++ b/src/jrd/os/vms/map.cpp @@ -55,7 +55,7 @@ typedef struct map_msg { extern double MTH$CVT_D_G(), MTH$CVT_G_D(); static void bugcheck(int); -static BOOLEAN check_message(UCHAR **); +static bool check_message(UCHAR **); static MAP_MSG rebuild_message(UCHAR **, UCHAR **); static int translate_status(ISC_STATUS *, ISC_STATUS *, SCHAR **); @@ -394,7 +394,8 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) **************************************/ ISC_STATUS code, number, length, gds_index, *tmp; ISC_STATUS_ARRAY temp; - USHORT shift, flag; + USHORT shift; + bool flag; SCHAR msgbuff[WRKBUF_SIZ], *p, *q, *pw1, *pw2, flags[4], part; struct dsc$descriptor_s desc, *dsc_ptr; // static const SCHAR * const messages[] = { @@ -432,7 +433,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) return gds__random; } - flag = FALSE; + flag = false; vms_status = vms_status + 3; if (*p == '%') @@ -455,7 +456,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) BUGCHECK(235); /* msg 235 Unimplemented conversion, FAO directive X,U */ *tmp++ = gds_arg_number; number = *tmp++ = *vms_status++; - flag = (number == 1) ? FALSE : TRUE; + flag = (number == 1) ? false : true; sprintf(pw2, "%%x%x", number); while (*pw2) ++pw2; @@ -524,7 +525,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) p = messages[gds_index]; tmp = temp; gds_status = gds_status + 2; - flag = FALSE; + flag = false; while (*p) { if (*p++ != '%') @@ -533,7 +534,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) case 's': *gds_status++ = gds_arg_cstring; if (*tmp++ != gds_arg_cstring || flag) { - flag = TRUE; + flag = true; *gds_status++ = 3; *gds_status++ = pw2; sprintf(pw2, ""); @@ -548,7 +549,7 @@ int MAP_status_to_gds(ISC_STATUS * vms_status, ISC_STATUS * gds_status) case 'd': *gds_status++ = gds_arg_number; if (*tmp++ != gds_arg_number || flag) { - flag = TRUE; + flag = true; *gds_status++ = -1; break; } @@ -632,7 +633,7 @@ static void bugcheck(int number) } -static BOOLEAN check_message(UCHAR ** org_ptr) +static bool check_message(UCHAR ** org_ptr) { /************************************** * @@ -642,7 +643,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr) * * Functional description * Parse a blr message. If the message contains a non-Rdb data type, - * return TRUE. Otherwise update the blr pointer and return FALSE. + * return true. Otherwise update the blr pointer and return false. * **************************************/ UCHAR *org, dtype; @@ -659,7 +660,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr) case blr_timestamp: case blr_cstring: case blr_d_float: - return TRUE; + return true; case blr_text: case blr_varying: @@ -673,7 +674,7 @@ static BOOLEAN check_message(UCHAR ** org_ptr) *org_ptr = org; - return FALSE; + return false; } diff --git a/src/jrd/os/vms/vms.cpp b/src/jrd/os/vms/vms.cpp index fd0369cd89..38b87abf85 100644 --- a/src/jrd/os/vms/vms.cpp +++ b/src/jrd/os/vms/vms.cpp @@ -58,12 +58,12 @@ extern "C" { extern gds__completion_ast(); -static BOOLEAN extend_file(FIL, ISC_STATUS *); +static bool extend_file(FIL, ISC_STATUS *); static FIL seek_file(FIL, BDB, int *); static FIL setup_file(DBB, TEXT *, USHORT, USHORT, struct NAM *); static void setup_trace(FIL, SSHORT); static void trace_event(FIL, SSHORT, SCHAR *, SSHORT); -static BOOLEAN vms_io_error(ISC_STATUS *, TEXT *, ISC_STATUS, int, FIL); +static bool vms_io_error(ISC_STATUS *, TEXT *, ISC_STATUS, int, FIL); #define DVI$_DEVLOCKNAM 240 @@ -671,7 +671,7 @@ int PIO_write(FIL file, BDB bdb, PAG page, ISC_STATUS * status_vector) } -static BOOLEAN extend_file(FIL file, ISC_STATUS * status_vector) +static bool extend_file(FIL file, ISC_STATUS * status_vector) { /************************************** * @@ -757,7 +757,7 @@ static BOOLEAN extend_file(FIL file, ISC_STATUS * status_vector) return vms_io_error(status_vector, "QIO IO$_MODIFY", isc_io_access_err, status, file); - return TRUE; + return true; } @@ -930,7 +930,7 @@ static void trace_event(FIL file, SSHORT type, SCHAR * ptr, SSHORT length) #endif -static BOOLEAN vms_io_error( +static bool vms_io_error( ISC_STATUS * status_vector, TEXT * string, ISC_STATUS operation, int code, FIL file) @@ -959,7 +959,7 @@ static BOOLEAN vms_io_error( *status_vector++ = code; *status_vector++ = gds_arg_end; - return FALSE; + return false; } diff --git a/src/jrd/os/vms/vmsevent.cpp b/src/jrd/os/vms/vmsevent.cpp index dc48d10d91..36c2e56843 100644 --- a/src/jrd/os/vms/vmsevent.cpp +++ b/src/jrd/os/vms/vmsevent.cpp @@ -91,7 +91,8 @@ static SES sessions; static EVNT parent_events; static SLONG request_id; static POKE pokes; -static USHORT thread_started, delivery_flag; +static bool thread_started; +static bool delivery_flag; static UCHAR *alloc(USHORT); static void blocking_ast(EVNT); @@ -100,14 +101,13 @@ static void delete_request(VMS_REQ); static void deliver(EVNT); static void deliver_request(VMS_REQ); static void delivery_thread(void); -static int delivery_wait(void); static ISC_STATUS error(ISC_STATUS *, TEXT *, ISC_STATUS); static EVNT find_event(USHORT, TEXT *, EVNT); static void free(SCHAR *); static RINT historical_interest(SES, EVNT); static EVNT make_event(USHORT, TEXT *, EVNT); static void poke_ast(POKE); -static BOOLEAN request_completed(VMS_REQ); +static bool request_completed(VMS_REQ); static int return_ok(ISC_STATUS *); @@ -153,7 +153,7 @@ SLONG EVENT_create_session(ISC_STATUS status_vector) session = (SES) alloc(sizeof(struct ses)); if (!session) { - assert(FALSE); /* No error handling */ + assert(false); /* No error handling */ return 0L; } session->ses_next = sessions; @@ -325,7 +325,9 @@ SLONG EVENT_que(ISC_STATUS * status_vector, USHORT string_length, TEXT * string, USHORT events_length, - UCHAR * events, void (*ast_routine) (), void *ast_arg) + UCHAR * events, + void (*ast_routine) (), + void *ast_arg) { /************************************** * @@ -339,7 +341,9 @@ SLONG EVENT_que(ISC_STATUS * status_vector, **************************************/ SES session; UCHAR *p, *end, *find_end; - USHORT count, flag, len; + USHORT count; + bool flag; + USHORT len; VMS_REQ request, next; EVNT event, parent; RINT interest, *ptr, *ptr2; @@ -348,7 +352,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector, session = (SES) session_id; if (!thread_started) { - thread_started = TRUE; + thread_started = true; gds__thread_start(delivery_thread, 0, THREAD_high, THREAD_ast); } @@ -388,7 +392,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector, ptr = &request->req_interests; p = events + 1; end = events + events_length; - flag = FALSE; + flag = false; while (p < end) { count = *p++; @@ -422,7 +426,7 @@ SLONG EVENT_que(ISC_STATUS * status_vector, interest->rint_count = gds__vax_integer(p, 4); p += 4; if (interest->rint_count <= event->evnt_count) - flag = TRUE; + flag = true; } if (flag) @@ -613,10 +617,12 @@ static void deliver(EVNT event) event->evnt_count = event->evnt_lksb.lksb_value[0]; for (interest = event->evnt_interests; interest; - interest = interest->rint_evnt_interests) if (request = - interest->rint_request) - if (request->req_ast && request_completed(request)) - delivery_flag = TRUE; + interest = interest->rint_evnt_interests) + { + if (request = interest->rint_request) + if (request->req_ast && request_completed(request)) + delivery_flag = true; + } gds__completion_ast(); } @@ -701,39 +707,28 @@ static void delivery_thread(void) SES session; for (;;) { - delivery_flag = FALSE; + delivery_flag = false; for (session = sessions; session; session = session->ses_next) for (request = session->ses_requests; request; request = request->req_next) - if (request->req_ast && request_completed(request)) { + { + if (request->req_ast && request_completed(request)) + { deliver_request(request); request->req_ast = NULL; } - gds__thread_wait(delivery_wait, 0); + } + if (delivery_flag) + gds__thread_wait(TRUE, 0); + else + gds__thread_wait(FALSE, 0); } } - -static int delivery_wait(void) +static ISC_STATUS error(ISC_STATUS * status_vector, + TEXT * string, + ISC_STATUS status) { -/************************************** - * - * d e l i v e r y _ w a i t - * - ************************************** - * - * Functional description - * See if the deliver thread should wake up. - * - **************************************/ - - return delivery_flag; -} - - -static ISC_STATUS error(ISC_STATUS * status_vector; - TEXT * string; - ISC_STATUS status; { /************************************** * * e r r o r @@ -745,18 +740,20 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * **************************************/ - *status_vector++ = gds_arg_gds; - *status_vector++ = gds__sys_request; - *status_vector++ = gds_arg_string; - *status_vector++ = (ISC_STATUS) string; - *status_vector++ = gds_arg_vms; - *status_vector++ = status; *status_vector++ = gds_arg_end; - return gds__sys_request; - } + *status_vector++ = gds_arg_gds; + *status_vector++ = gds__sys_request; + *status_vector++ = gds_arg_string; + *status_vector++ = (ISC_STATUS) string; + *status_vector++ = gds_arg_vms; + *status_vector++ = status; *status_vector++ = gds_arg_end; + return gds__sys_request; +} - static EVNT find_event(USHORT length, - TEXT * string, EVNT parent) { +static EVNT find_event(USHORT length, + TEXT * string, + EVNT parent) +{ /************************************** * * f i n d _ e v e n t @@ -767,15 +764,19 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * Lookup an event. * **************************************/ - EVNT event; - event = (parent) ? parent->evnt_offspring : parent_events; - for (; event; event = event->evnt_next) - if (event->evnt_length == length && - !strncmp(string, event->evnt_name, length)) - return event; return NULL;} + EVNT event; + event = (parent) ? parent->evnt_offspring : parent_events; + for (; event; event = event->evnt_next) + if (event->evnt_length == length && + !strncmp(string, event->evnt_name, length)) + { + return event; + } + return NULL; +} - static void free(SCHAR * block) { +static void free(SCHAR * block) { /************************************** * * f r e e @@ -787,10 +788,13 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * **************************************/ - gds__free(block);} + gds__free(block); +} - static RINT historical_interest(SES session, EVNT event) { +static RINT historical_interest(SES session, + EVNT event) +{ /************************************** * * h i s t o r i c a l _ i n t e r e s t @@ -801,15 +805,21 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * Find a historical interest, if any, of an event with a session. * **************************************/ - RINT interest, *ptr; - for (ptr = &session->ses_interests; interest = *ptr; - ptr = &(*ptr)->rint_req_interests) - if (interest->rint_event == event) - return interest; return NULL;} + RINT interest, *ptr; + for (ptr = &session->ses_interests; interest = *ptr; + ptr = &(*ptr)->rint_req_interests) + { + if (interest->rint_event == event) + return interest; + } + return NULL; +} - static EVNT make_event(USHORT length, - TEXT * string, EVNT parent) { +static EVNT make_event(USHORT length, + TEXT * string, + EVNT parent) +{ /************************************** * * m a k e _ e v e n t @@ -820,69 +830,71 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * Allocate an link in an event. * **************************************/ - EVNT event, *ptr; - LKSB * lksb; - SLONG parent_id; - int status; - struct dsc$descriptor desc; - event = (EVNT) alloc(sizeof(struct evnt) + length); - if (!event) return NULL; if (parent) { - ptr = &parent->evnt_offspring; - parent_id = parent->evnt_lksb.lksb_lock_id;} - else - { - ptr = &parent_events; parent_id = 0;} + EVNT event, *ptr; + LKSB * lksb; + SLONG parent_id; + int status; + struct dsc$descriptor desc; + event = (EVNT) alloc(sizeof(struct evnt) + length); + if (!event) return NULL; if (parent) { + ptr = &parent->evnt_offspring; + parent_id = parent->evnt_lksb.lksb_lock_id;} + else + { + ptr = &parent_events; parent_id = 0;} - event->evnt_next = *ptr; - *ptr = event; - event->evnt_parent = parent; - event->evnt_length = length; - strncpy(event->evnt_name, string, length); + event->evnt_next = *ptr; + *ptr = event; + event->evnt_parent = parent; + event->evnt_length = length; + strncpy(event->evnt_name, string, length); /* Request VMS lock on event */ - ISC_make_desc(string, &desc, length); - lksb = &event->evnt_lksb; status = sys$enqw(0, /* event flag */ - LCK$K_PRMODE, /* lock mode */ - lksb, /* Lock status block */ - LCK$M_SYSTEM | LCK$M_VALBLK, /* flags */ - &desc, /* resource name */ - parent_id, /* parent id */ - 0, /* ast address */ - event, /* ast argument */ - blocking_ast, /* blocking ast */ - 0, /* access mode */ - 0); - event->evnt_count = lksb->lksb_value[0]; + ISC_make_desc(string, &desc, length); + lksb = &event->evnt_lksb; status = sys$enqw(0, /* event flag */ + LCK$K_PRMODE, /* lock mode */ + lksb, /* Lock status block */ + LCK$M_SYSTEM | LCK$M_VALBLK, /* flags */ + &desc, /* resource name */ + parent_id, /* parent id */ + 0, /* ast address */ + event, /* ast argument */ + blocking_ast, /* blocking ast */ + 0, /* access mode */ + 0); + event->evnt_count = lksb->lksb_value[0]; /* If the lock block is invalid, clean it up immediately */ - if ((status & 1) && - event->evnt_lksb.lksb_status == SS$_VALNOTVALID) { - status = sys$enqw(0, /* event flag */ - LCK$K_PWMODE, /* lock mode */ - lksb, /* Lock status block */ - LCK$M_CONVERT, /* flags */ - 0, /* resource name */ - 0, /* parent id */ - 0, /* ast address */ - event, /* ast argument */ - blocking_ast, /* blocking ast */ - 0, /* access mode */ - 0); - event->evnt_count = lksb->lksb_value[0] = 0; - status = sys$enqw(0, /* event flag */ - LCK$K_PRMODE, /* lock mode */ - lksb, /* Lock status block */ - LCK$M_CONVERT | LCK$M_VALBLK, /* flags */ - 0, /* resource name */ - 0, /* parent id */ - 0, /* ast address */ - event, /* ast argument */ - blocking_ast, /* blocking ast */ - 0, /* access mode */ - 0);} + if ((status & 1) && + event->evnt_lksb.lksb_status == SS$_VALNOTVALID) { + status = sys$enqw(0, /* event flag */ + LCK$K_PWMODE, /* lock mode */ + lksb, /* Lock status block */ + LCK$M_CONVERT, /* flags */ + 0, /* resource name */ + 0, /* parent id */ + 0, /* ast address */ + event, /* ast argument */ + blocking_ast, /* blocking ast */ + 0, /* access mode */ + 0); + event->evnt_count = lksb->lksb_value[0] = 0; + status = sys$enqw(0, /* event flag */ + LCK$K_PRMODE, /* lock mode */ + lksb, /* Lock status block */ + LCK$M_CONVERT | LCK$M_VALBLK, /* flags */ + 0, /* resource name */ + 0, /* parent id */ + 0, /* ast address */ + event, /* ast argument */ + blocking_ast, /* blocking ast */ + 0, /* access mode */ + 0);} - return event;} + return event; +} - static void poke_ast(POKE poke) { +static void poke_ast(POKE poke) +{ /************************************** * * p o k e _ a s t @@ -894,17 +906,18 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * and deque the lock. * **************************************/ - int status; - LKSB * lksb; - lksb = &poke->poke_lksb; - lksb->lksb_value[0] += poke->poke_value; - status = - sys$deq(lksb->lksb_lock_id, lksb->lksb_value, 0, 0); - status = sys$deq(poke->poke_parent_id, 0, 0, 0); - --poke->poke_use_count;} + int status; + LKSB * lksb; + lksb = &poke->poke_lksb; + lksb->lksb_value[0] += poke->poke_value; + status = sys$deq(lksb->lksb_lock_id, lksb->lksb_value, 0, 0); + status = sys$deq(poke->poke_parent_id, 0, 0, 0); + --poke->poke_use_count; +} - static BOOLEAN request_completed(VMS_REQ request) { +static bool request_completed(VMS_REQ request) +{ /************************************** * * r e q u e s t _ c o m p l e t e d @@ -915,18 +928,22 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * See if request is completed. * **************************************/ - RINT interest; - EVNT event; - for (interest = request->req_interests; interest; - interest = interest->rint_req_interests) { - event = interest->rint_event; - if (interest->rint_count <= - event->evnt_count) return TRUE;} + RINT interest; + EVNT event; + for (interest = request->req_interests; interest; + interest = interest->rint_req_interests) + { + event = interest->rint_event; + if (interest->rint_count <= event->evnt_count) + return true; + } - return FALSE;} + return false; +} - static int return_ok(ISC_STATUS * status_vector) { +static int return_ok(ISC_STATUS * status_vector) +{ /************************************** * * r e t u r n _ o k @@ -938,6 +955,8 @@ static ISC_STATUS error(ISC_STATUS * status_vector; * **************************************/ - *status_vector++ = gds_arg_gds; - *status_vector++ = 0; - *status_vector = gds_arg_end; return 0;} + *status_vector++ = gds_arg_gds; + *status_vector++ = 0; + *status_vector = gds_arg_end; + return 0; +} diff --git a/src/jrd/os/win32/thd_priority.cpp b/src/jrd/os/win32/thd_priority.cpp index 9891df4d4d..75ae5195de 100644 --- a/src/jrd/os/win32/thd_priority.cpp +++ b/src/jrd/os/win32/thd_priority.cpp @@ -49,9 +49,9 @@ MUTX_T ThreadPriorityScheduler::mutex; MemoryPool * ThreadPriorityScheduler::pool = 0; ThreadPriorityScheduler * ThreadPriorityScheduler::chain = 0; ThreadPriorityScheduler * ThreadPriorityScheduler::news = 0; -BOOLEAN ThreadPriorityScheduler::initialized = FALSE; +bool ThreadPriorityScheduler::initialized = false; DWORD ThreadPriorityScheduler::specific_key = (DWORD) -1; -BOOLEAN ThreadPriorityScheduler::shutdown = FALSE; +bool ThreadPriorityScheduler::shutdown = false; //____________________________________________________________ // @@ -60,8 +60,8 @@ BOOLEAN ThreadPriorityScheduler::shutdown = FALSE; void ThreadPriorityScheduler::Cleanup(void) { if (initialized) { - initialized = FALSE; - shutdown = TRUE; + initialized = false; + shutdown = true; } } @@ -102,7 +102,7 @@ void ThreadPriorityScheduler::Init(void) if (initialized) return; - initialized = TRUE; + initialized = true; specific_key = TlsAlloc(); // memory pool for thps allocation @@ -224,8 +224,8 @@ void ThreadPriorityScheduler::Exit(void) { // // Check whether current thread has high priority // -BOOLEAN ThreadPriorityScheduler::Boosted(void) { - return InternalGet()->flags & THPS_BOOSTED ? TRUE : FALSE; +bool ThreadPriorityScheduler::Boosted(void) { + return InternalGet()->flags & THPS_BOOSTED ? true : false; } //____________________________________________________________ diff --git a/src/lock/lock.cpp b/src/lock/lock.cpp index 225c7d59bd..c4c183df1c 100644 --- a/src/lock/lock.cpp +++ b/src/lock/lock.cpp @@ -39,7 +39,7 @@ */ /* -$Id: lock.cpp,v 1.67 2003-09-01 07:51:50 brodsom Exp $ +$Id: lock.cpp,v 1.68 2003-09-04 21:22:22 brodsom Exp $ */ #include "firebird.h" @@ -108,12 +108,12 @@ $Id: lock.cpp,v 1.67 2003-09-01 07:51:50 brodsom Exp $ #include #include #define statistics stat -static BOOLEAN LOCK_post_manager; +static bool LOCK_post_manager; #endif #ifdef DEV_BUILD -#define ASSERT_ACQUIRED current_is_active_owner (TRUE, __LINE__) -#define ASSERT_RELEASED current_is_active_owner (FALSE, __LINE__) +#define ASSERT_ACQUIRED current_is_active_owner (true, __LINE__) +#define ASSERT_RELEASED current_is_active_owner (false, __LINE__) #define VALIDATE_LOCK_TABLE #if ((defined HAVE_MMAP) && !(defined SUPERSERVER)) #define LOCK_DEBUG_ACQUIRE @@ -212,14 +212,14 @@ static void bug(ISC_STATUS *, const TEXT *); #ifdef DEV_BUILD static void bug_assert(const TEXT *, ULONG); #endif -static BOOLEAN convert(PTR, UCHAR, SSHORT, lock_ast_t, void *, ISC_STATUS *); +static bool convert(PTR, UCHAR, SSHORT, lock_ast_t, void *, ISC_STATUS *); static USHORT create_owner(ISC_STATUS *, SLONG, UCHAR, SLONG *); #ifdef DEV_BUILD -static void current_is_active_owner(BOOLEAN, ULONG); +static void current_is_active_owner(bool, ULONG); #endif static void deadlock_clear(void); static LRQ deadlock_scan(OWN, LRQ); -static LRQ deadlock_walk(LRQ, BOOLEAN *); +static LRQ deadlock_walk(LRQ, bool *); static void dequeue(PTR); #ifdef DEBUG static void debug_delay(ULONG); @@ -227,8 +227,8 @@ static void debug_delay(ULONG); static void exit_handler(void *); static LBL find_lock(PTR, USHORT, UCHAR *, USHORT, USHORT *); #ifdef MANAGER_PROCESS -static USHORT fork_lock_manager(ISC_STATUS *); -static OWN get_manager(BOOLEAN); +static bool fork_lock_manager(ISC_STATUS *); +static OWN get_manager(bool); #endif static LRQ get_request(PTR); static void grant(LRQ, LBL); @@ -243,12 +243,12 @@ static void insert_data_que(LBL); static void insert_tail(SRQ, SRQ); static USHORT lock_state(LBL); //static void port_waker(PTR *); -static void post_blockage(LRQ, LBL, BOOLEAN); -static void post_history(USHORT, PTR, PTR, PTR, BOOLEAN); +static void post_blockage(LRQ, LBL, bool); +static void post_history(USHORT, PTR, PTR, PTR, bool); static void post_pending(LBL); static void post_wakeup(OWN); #ifndef SUPERSERVER -static BOOLEAN probe_owners(PTR); +static bool probe_owners(PTR); #endif static void purge_owner(PTR, OWN); static void remove_que(SRQ); @@ -300,7 +300,7 @@ static SLONG LOCK_hash_slots; static SLONG LOCK_scan_interval; static SLONG LOCK_acquire_spins; static SH_MEM_T LOCK_data; -static BOOLEAN start_manager = FALSE; +static bool start_manager = false; static TEXT LOCK_bug_buffer[128]; @@ -410,12 +410,11 @@ int LOCK_convert(PTR request_offset, else ++LOCK_header->lhb_operations[0]; - return convert(request_offset, - type, - lck_wait, - ast_routine, - ast_argument, - status_vector); + if (convert(request_offset, type, lck_wait, ast_routine, ast_argument, + status_vector)) + return TRUE; + else + return FALSE; } @@ -604,7 +603,7 @@ SLONG LOCK_enq( PTR prior_request, } owner = (OWN) ABS_PTR(owner_offset); /* Re-init after a potential remap */ - post_history(his_enq, owner_offset, (PTR)0, REL_PTR(request), TRUE); + post_history(his_enq, owner_offset, (PTR)0, REL_PTR(request), true); request->lrq_type = type_lrq; request->lrq_flags = 0; @@ -798,7 +797,7 @@ int LOCK_init( if (!LOCK_header) { /* We haven't yet mapped the shared region. Do so now. */ - start_manager = FALSE; + start_manager = false; if (init_lock_table(status_vector) != FB_SUCCESS) { return FB_FAILURE; } @@ -828,8 +827,7 @@ int LOCK_init( #if !defined SUPERSERVER && defined WIN_NT owner = (OWN) ABS_PTR(*owner_handle); wakeup_event[0] = owner->own_wakeup_hndl; - blocking_event[0] = - ISC_make_signal(TRUE, FALSE, LOCK_pid, LOCK_block_signal); + blocking_event[0] = ISC_make_signal(TRUE, FALSE, LOCK_pid, LOCK_block_signal); owner->own_blocking_hndl = blocking_event[0]; AST_ALLOC; if (gds__thread_start @@ -881,7 +879,7 @@ int LOCK_init( #ifdef MANAGER_PROCESS if (start_manager) { - start_manager = FALSE; + start_manager = false; if (!fork_lock_manager(status_vector)) return FB_FAILURE; } @@ -934,7 +932,7 @@ void LOCK_manager( PTR manager_owner_offset) /* If there already is a lock manager running, quietly return */ - while (owner = get_manager(FALSE)) + while (owner = get_manager(false)) if (signal_owner(owner, (PTR) NULL)) purge_owner(manager_owner_offset, owner); else { @@ -1070,7 +1068,7 @@ SLONG LOCK_query_data(PTR parent_request, USHORT series, USHORT aggregate) if (parent_request && series < LCK_MAX_SERIES) parent = get_request(parent_request); else { - CHECK(FALSE); + CHECK(false); return 0; } @@ -1139,7 +1137,7 @@ SLONG LOCK_query_data(PTR parent_request, USHORT series, USHORT aggregate) break; default: - CHECK(FALSE); + CHECK(false); } release(parent->lrq_owner); @@ -1301,7 +1299,7 @@ void LOCK_re_post( lock_ast_t ast, void *arg, PTR owner_offset) } -BOOLEAN LOCK_shut_manager(void) +bool LOCK_shut_manager(void) { /************************************** * @@ -1318,20 +1316,20 @@ BOOLEAN LOCK_shut_manager(void) OWN manager; acquire(DUMMY_OWNER_SHUTDOWN); - if (manager = get_manager(FALSE)) { + if (manager = get_manager(false)) { LOCK_header->lhb_flags |= LHB_shut_manager; post_wakeup(manager); release_mutex(); sleep(5); acquire(DUMMY_OWNER_SHUTDOWN); LOCK_header->lhb_flags &= ~LHB_shut_manager; - manager = get_manager(FALSE); + manager = get_manager(false); } release_mutex(); - return (manager ? FALSE : TRUE); + return (manager ? false : true); #else - return TRUE; + return true; #endif } @@ -1462,7 +1460,7 @@ static void acquire( PTR owner_offset) LOCK_header->lhb_active_owner = owner_offset; #ifdef MANAGER_PROCESS - LOCK_post_manager = FALSE; + LOCK_post_manager = false; #endif #ifndef SUPERSERVER @@ -1510,7 +1508,7 @@ static void acquire( PTR owner_offset) SHB recover; SRQ que; - post_history(his_active, owner_offset, prior_active, (PTR) 0, FALSE); + post_history(his_active, owner_offset, prior_active, (PTR) 0, false); recover = (SHB) ABS_PTR(LOCK_header->lhb_secondary); if (recover->shb_remove_node) { /* There was a remove_que operation in progress when the prior_owner died */ @@ -1616,8 +1614,7 @@ static UCHAR *alloc( SSHORT size, ISC_STATUS * status_vector) */ #if (defined WIN_NT && defined SUPERSERVER) || (!defined SUPERSERVER && defined HAVE_MMAP) ULONG length = LOCK_data.sh_mem_length_mapped + EXTEND_SIZE; - LHB header = - (LHB) ISC_remap_file(status_vector, &LOCK_data, length, TRUE); + LHB header = (LHB) ISC_remap_file(status_vector, &LOCK_data, length, TRUE); if (header) { LOCK_header = header; #ifdef WIN_NT @@ -1865,7 +1862,7 @@ static void blocking_action2( * signaled" flag and start winding out of here */ owner->own_ast_flags &= ~OWN_signaled; - /*post_history (his_leave_ast, blocking_owner_offset, 0, 0, TRUE); */ + /*post_history (his_leave_ast, blocking_owner_offset, 0, 0, true); */ break; } request = (LRQ) ((UCHAR *) que - OFFSET(LRQ, lrq_own_blocks)); @@ -1877,7 +1874,7 @@ static void blocking_action2( request->lrq_flags |= LRQ_blocking_seen; ++LOCK_header->lhb_blocks; post_history(his_post_ast, blocking_owner_offset, - request->lrq_lock, REL_PTR(request), TRUE); + request->lrq_lock, REL_PTR(request), true); } else if (request->lrq_flags & LRQ_repost) { request->lrq_type = type_null; @@ -1914,7 +1911,7 @@ static void THREAD_ROUTINE blocking_action_thread( PTR * owner_offset_ptr) AST_INIT; /* Check into scheduler as AST thread */ - while (TRUE) { + while (true) { ret = WaitForSingleObject(blocking_event[0], INFINITE); AST_ENTER; owner = (OWN) ABS_PTR(*owner_offset_ptr); @@ -1949,7 +1946,7 @@ static void THREAD_ROUTINE blocking_action_thread( PTR * owner_offset_ptr) AST_INIT; /* Check into scheduler as AST thread */ - while (TRUE) { + while (true) { AST_ENTER; /* See if main thread has requested us to go away */ @@ -2086,12 +2083,12 @@ static void bug( ISC_STATUS * status_vector, const TEXT * string) } -static BOOLEAN convert(PTR request_offset, - UCHAR type, - SSHORT lck_wait, - lock_ast_t ast_routine, - void* ast_argument, - ISC_STATUS* status_vector) +static bool convert(PTR request_offset, + UCHAR type, + SSHORT lck_wait, + lock_ast_t ast_routine, + void* ast_argument, + ISC_STATUS* status_vector) { /************************************** * @@ -2102,15 +2099,15 @@ static BOOLEAN convert(PTR request_offset, * Functional description * Perform a lock conversion, if possible. If the lock cannot be * granted immediately, either return immediately or wait depending - * on a wait flag. If the lock is granted return TRUE, otherwise - * return FALSE. Note: if the conversion would cause a deadlock, + * on a wait flag. If the lock is granted return true, otherwise + * return false. Note: if the conversion would cause a deadlock, * FALSE is returned even if wait was requested. * **************************************/ LBL lock; LRQ request; UCHAR temp; - BOOLEAN new_ast; + bool new_ast; PTR owner_offset; ASSERT_ACQUIRED; @@ -2118,7 +2115,7 @@ static BOOLEAN convert(PTR request_offset, lock = (LBL) ABS_PTR(request->lrq_lock); owner_offset = request->lrq_owner; post_history(his_convert, owner_offset, request->lrq_lock, request_offset, - TRUE); + true); request->lrq_requested = type; request->lrq_flags &= ~LRQ_blocking_seen; @@ -2137,7 +2134,7 @@ static BOOLEAN convert(PTR request_offset, grant(request, lock); post_pending(lock); release(owner_offset); - return TRUE; + return true; } ++lock->lbl_counts[request->lrq_state]; @@ -2148,13 +2145,13 @@ static BOOLEAN convert(PTR request_offset, if (lck_wait) { if (request->lrq_ast_routine != ast_routine || request->lrq_ast_argument != ast_argument) - new_ast = TRUE; + new_ast = true; else - new_ast = FALSE; + new_ast = false; if (wait_for_request(request, lck_wait, status_vector)) { ASSERT_RELEASED; - return FALSE; + return false; } request = (LRQ) ABS_PTR(request_offset); if (!(request->lrq_flags & LRQ_rejected)) { @@ -2166,7 +2163,7 @@ static BOOLEAN convert(PTR request_offset, release(owner_offset); } ASSERT_RELEASED; - return TRUE; + return true; } acquire(owner_offset); request = get_request(request_offset); @@ -2186,7 +2183,7 @@ static BOOLEAN convert(PTR request_offset, ((lck_wait < 0) ? gds_lock_timeout : gds_lock_conflict); *status_vector++ = gds_arg_end; - return FALSE; + return false; } @@ -2277,7 +2274,7 @@ static USHORT create_owner(ISC_STATUS* status_vector, #ifdef DEV_BUILD -static void current_is_active_owner( BOOLEAN expect_acquired, ULONG line) +static void current_is_active_owner(bool expect_acquired, ULONG line) { /************************************** * @@ -2300,7 +2297,7 @@ static void current_is_active_owner( BOOLEAN expect_acquired, ULONG line) return; /* Use a local copy of lhb_active_owner. We're viewing the lock table - without being acquired in the "expect_acquired FALSE" case, so it + without being acquired in the "expect_acquired false" case, so it can change out from under us. We don't care that it changes, but if it gets set to DUMMY_OWNER_SHUTDOWN, DUMMY_OWNER_CREATE or DUMMY_OWNER_DELETE it can lead to a core drop when we try to map @@ -2394,7 +2391,8 @@ static void deadlock_clear(void) } -static LRQ deadlock_scan( OWN owner, LRQ request) +static LRQ deadlock_scan(OWN owner, + LRQ request) { /************************************** * @@ -2410,7 +2408,7 @@ static LRQ deadlock_scan( OWN owner, LRQ request) * **************************************/ LRQ victim; - BOOLEAN maybe_deadlock = FALSE; + bool maybe_deadlock = false; LOCK_TRACE( ("deadlock_scan: owner %ld request %ld\n", REL_PTR(owner), @@ -2419,7 +2417,7 @@ static LRQ deadlock_scan( OWN owner, LRQ request) ASSERT_ACQUIRED; ++LOCK_header->lhb_scans; post_history(his_scan, request->lrq_owner, request->lrq_lock, - REL_PTR(request), TRUE); + REL_PTR(request), true); deadlock_clear(); #ifdef VALIDATE_LOCK_TABLE @@ -2443,7 +2441,8 @@ static LRQ deadlock_scan( OWN owner, LRQ request) } -static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock) +static LRQ deadlock_walk(LRQ request, + bool * maybe_deadlock) { /************************************** * @@ -2461,7 +2460,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock) LBL lock; OWN owner; PTR pending_offset; - BOOLEAN conversion; + bool conversion; /* If this request was scanned for deadlock earlier than don't visit it again. */ @@ -2481,7 +2480,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock) /* Check if this is a conversion request. */ - conversion = (request->lrq_state > LCK_null) ? TRUE : FALSE; + conversion = (request->lrq_state > LCK_null) ? true : false; /* Find the parent lock of the request */ @@ -2538,7 +2537,7 @@ static LRQ deadlock_walk( LRQ request, BOOLEAN * maybe_deadlock) if (owner->own_ast_flags & OWN_signaled || !QUE_EMPTY((owner->own_blocks))) { - *maybe_deadlock = TRUE; + *maybe_deadlock = true; continue; } @@ -2597,7 +2596,7 @@ static void dequeue( PTR request_offset) request = get_request(request_offset); post_history(his_deq, request->lrq_owner, request->lrq_lock, - request_offset, TRUE); + request_offset, true); request->lrq_ast_routine = NULL; release_request(request); } @@ -2785,7 +2784,7 @@ static LBL find_lock( #ifdef MANAGER_PROCESS -static USHORT fork_lock_manager( ISC_STATUS * status_vector) +static bool fork_lock_manager( ISC_STATUS * status_vector) { /************************************** * @@ -2812,7 +2811,7 @@ static USHORT fork_lock_manager( ISC_STATUS * status_vector) if (statistics(string, &stat_buf) == -1) { sprintf (errorstring, "can't start lock manager: %s", string); bug(status_vector, errorstring); - return FALSE; + return false; } if (!(pid = vfork())) { @@ -2825,19 +2824,19 @@ static USHORT fork_lock_manager( ISC_STATUS * status_vector) if (pid == -1) { bug(status_vector, "can't start lock manager"); - return FALSE; + return false; } while (waitpid(pid, NULL, 0) == -1 && SYSCALL_INTERRUPTED(errno)) /* do nothing */ ; - return TRUE; + return true; } #endif #ifdef MANAGER_PROCESS -static OWN get_manager( BOOLEAN flag) +static OWN get_manager(bool flag) { /************************************** * @@ -2934,7 +2933,7 @@ static void grant( LRQ request, LBL lock) CHECK(REL_PTR(lock) == request->lrq_lock); post_history(his_grant, request->lrq_owner, request->lrq_lock, - REL_PTR(request), TRUE); + REL_PTR(request), true); ++lock->lbl_counts[request->lrq_requested]; request->lrq_state = request->lrq_requested; @@ -3015,7 +3014,7 @@ static PTR grant_or_que( LRQ request, LBL lock, SSHORT lck_wait) request = (LRQ) ABS_PTR(request_offset); post_history(his_deny, request->lrq_owner, request->lrq_lock, - REL_PTR(request), TRUE); + REL_PTR(request), true); ASSERT_ACQUIRED; ++LOCK_header->lhb_denies; if (lck_wait < 0) @@ -3101,8 +3100,7 @@ static ISC_STATUS init_lock_table( ISC_STATUS * status_vector) /* Now get the globally consistent value of LOCK_ordering from the shared lock table. */ - LOCK_ordering = - (LOCK_header->lhb_flags & LHB_lock_ordering) ? TRUE : FALSE; + LOCK_ordering = (LOCK_header->lhb_flags & LHB_lock_ordering) ? TRUE : FALSE; gds__register_cleanup(exit_handler, 0); @@ -3158,16 +3156,15 @@ static void init_owner_block( #if defined(WIN_NT) && !defined(SUPERSERVER) // Skidder: This Win32 EVENT is deleted when our process is closing if (new_block != OWN_BLOCK_dummy) - owner->own_wakeup_hndl = - ISC_make_signal(TRUE, TRUE, LOCK_pid, LOCK_wakeup_signal); + owner->own_wakeup_hndl = ISC_make_signal(TRUE, TRUE, LOCK_pid, + LOCK_wakeup_signal); #endif if (new_block == OWN_BLOCK_new) { #if defined WIN_NT && defined SUPERSERVER // TMN: This Win32 EVENT is never deleted! // Skidder: But it may be reused along with the owner block - owner->own_wakeup_hndl = - ISC_make_signal(TRUE, TRUE, LOCK_pid, 0); + owner->own_wakeup_hndl = ISC_make_signal(TRUE, TRUE, LOCK_pid, 0); #endif #ifdef USE_WAKEUP_EVENTS #if (defined WIN_NT && defined SUPERSERVER) @@ -3259,7 +3256,7 @@ static void lock_initialize( void *arg, SH_MEM shmem_data, int initialize) return; } - start_manager = TRUE; + start_manager = true; memset(LOCK_header, 0, sizeof(struct lhb)); LOCK_header->lhb_type = type_lhb; @@ -3495,7 +3492,9 @@ static USHORT lock_state( LBL lock) } -static void post_blockage( LRQ request, LBL lock, BOOLEAN force) +static void post_blockage(LRQ request, + LBL lock, + bool force) { /************************************** * @@ -3566,10 +3565,11 @@ static void post_blockage( LRQ request, LBL lock, BOOLEAN force) } -static void post_history( - USHORT operation, +static void post_history(USHORT operation, PTR process, - PTR lock, PTR request, BOOLEAN old_version) + PTR lock, + PTR request, + bool old_version) { /************************************** * @@ -3736,7 +3736,7 @@ static void post_wakeup( OWN owner) #ifndef SUPERSERVER -static BOOLEAN probe_owners( PTR probing_owner_offset) +static bool probe_owners( PTR probing_owner_offset) { /************************************** * @@ -3751,9 +3751,9 @@ static BOOLEAN probe_owners( PTR probing_owner_offset) **************************************/ SRQ que; OWN owner; - BOOLEAN purged; + bool purged; - purged = FALSE; + purged = false; ASSERT_ACQUIRED; QUE_LOOP(LOCK_header->lhb_owners, que) { @@ -3765,7 +3765,7 @@ static BOOLEAN probe_owners( PTR probing_owner_offset) owner->own_process_uid, FALSE)) { que = (SRQ) ABS_PTR(que->srq_backward); purge_owner(probing_owner_offset, owner); - purged = TRUE; + purged = true; } } @@ -3792,7 +3792,7 @@ static void purge_owner(PTR purging_owner_offset, OWN owner) LOCK_TRACE(("purge_owner (%ld)\n", purging_owner_offset)); post_history(his_del_owner, purging_owner_offset, REL_PTR(owner), 0, - FALSE); + false); #ifdef USE_STATIC_SEMAPHORES release_semaphore(owner); @@ -3935,7 +3935,7 @@ static void release( PTR owner_offset) bug(NULL, "release when not owner"); #ifdef MANAGER_PROCESS - if (LOCK_post_manager && (owner = get_manager(TRUE))) + if (LOCK_post_manager && (owner = get_manager(true))) post_wakeup(owner); #endif @@ -4212,7 +4212,7 @@ static int signal_owner( OWN blocking_owner, PTR blocked_owner_offset) * **************************************/ -/*post_history (his_signal, LOCK_header->lhb_iactive_owner, REL_PTR (blocking_owner), 0, TRUE);*/ +/*post_history (his_signal, LOCK_header->lhb_iactive_owner, REL_PTR (blocking_owner), 0, true);*/ ASSERT_ACQUIRED; @@ -4298,7 +4298,7 @@ static int signal_owner( OWN blocking_owner, PTR blocked_owner_offset) process for delivery. */ if (!(LOCK_process_owner.own_flags & OWN_manager)) { - LOCK_post_manager = TRUE; + LOCK_post_manager = true; return FB_SUCCESS; } #endif @@ -4334,7 +4334,7 @@ static void validate_history( PTR history_header) LOCK_TRACE(("validate_history: %ld\n", history_header)); - for (history = (HIS) ABS_PTR(history_header); TRUE; + for (history = (HIS) ABS_PTR(history_header); true; history = (HIS) ABS_PTR(history->his_next)) { count++; CHECK(history->his_type == type_his); @@ -4710,7 +4710,7 @@ static void validate_owner( PTR own_ptr, USHORT freed) * exists in the queue for the lock. */ if (owner_own_pending_request && (freed == EXPECT_inuse)) { - BOOLEAN found_pending; + bool found_pending; LRQ request; LBL lock; LRQ pending; @@ -4727,13 +4727,13 @@ static void validate_owner( PTR own_ptr, USHORT freed) /* Make sure the pending request is on the list of requests for the lock */ - found_pending = FALSE; + found_pending = false; QUE_LOOP(lock->lbl_requests, que_of_lbl_requests) { pending = (LRQ) ((UCHAR *) que_of_lbl_requests - OFFSET(LRQ, lrq_lbl_requests)); if (REL_PTR(pending) == owner_own_pending_request) { - found_pending = TRUE; + found_pending = true; break; } } @@ -4947,8 +4947,8 @@ static USHORT wait_for_request( /* Post blockage. If the blocking owner has disappeared, the blockage may clear spontaneously. */ - post_blockage(request, lock, FALSE); - post_history(his_wait, owner_offset, lock_offset, REL_PTR(request), TRUE); + post_blockage(request, lock, false); + post_history(his_wait, owner_offset, lock_offset, REL_PTR(request), true); release(owner_offset); current_time = GET_TIME; @@ -4962,7 +4962,7 @@ static USHORT wait_for_request( /* Wait in a loop until the lock becomes available */ - while (TRUE) { + while (true) { /* NOTE: Many operations in this loop are done without having * the lock table acquired - for performance reasons */ @@ -5176,7 +5176,7 @@ static USHORT wait_for_request( This could happen if the lock was granted to a different request, we have to tell the new owner of the lock that they are blocking us. */ - post_blockage(request, lock, FALSE); + post_blockage(request, lock, false); release(owner_offset); continue; } @@ -5237,7 +5237,7 @@ static USHORT wait_for_request( We need to inform the new owner. */ DEBUG_MSG(0, ("wait_for_request: forcing a resignal of blockers\n")); - post_blockage(request, lock, FALSE); + post_blockage(request, lock, false); #ifdef DEV_BUILD repost_counter++; if (repost_counter % 50 == 0) { diff --git a/src/lock/lock_proto.h b/src/lock/lock_proto.h index a8cdc8a708..eca9503bf0 100644 --- a/src/lock/lock_proto.h +++ b/src/lock/lock_proto.h @@ -38,7 +38,7 @@ SLONG LOCK_query_data(SLONG, USHORT, USHORT); SLONG LOCK_read_data(SLONG); SLONG LOCK_read_data2(SLONG, USHORT, UCHAR *, USHORT, SLONG); void LOCK_re_post(int (*)(void *), void *, SLONG); -BOOLEAN LOCK_shut_manager(void); +bool LOCK_shut_manager(void); SLONG LOCK_write_data(SLONG, SLONG); #endif /* _LOCK_LOCK_PROTO_H_ */ diff --git a/src/lock/print.cpp b/src/lock/print.cpp index a725d19b0f..b04291a862 100644 --- a/src/lock/print.cpp +++ b/src/lock/print.cpp @@ -80,7 +80,7 @@ static void prt_lock_activity(OUTFILE, LHB, USHORT, USHORT, USHORT); static void prt_lock_init(void); static void prt_history(OUTFILE, LHB, PTR, SCHAR *); static void prt_lock(OUTFILE, LHB, LBL, USHORT); -static void prt_owner(OUTFILE, LHB, OWN, BOOLEAN, BOOLEAN); +static void prt_owner(OUTFILE, LHB, OWN, bool, bool); static void prt_owner_wait_cycle(OUTFILE, LHB, OWN, USHORT, struct waitque *); static void prt_request(OUTFILE, LHB, LRQ); static void prt_que(OUTFILE, LHB, SCHAR *, SRQ, USHORT); @@ -123,11 +123,15 @@ void CLIB_ROUTINE main( int argc, char *argv[]) * to ib_stdout. * **************************************/ - BOOLEAN sw_requests, sw_owners, sw_locks, sw_history, sw_nobridge; + bool sw_requests; + bool sw_owners; + bool sw_locks; + bool sw_history; + bool sw_nobridge; USHORT sw_series, sw_interactive, sw_intervals, sw_seconds; - BOOLEAN sw_consistency; - BOOLEAN sw_waitlist; - BOOLEAN sw_file; + bool sw_consistency; + bool sw_waitlist; + bool sw_file; LHB LOCK_header, header = NULL; SLONG LOCK_size_mapped = DEFAULT_SIZE; int orig_argc; @@ -188,11 +192,11 @@ void CLIB_ROUTINE main( int argc, char *argv[]) /* Handle switches, etc. */ argv++; - sw_consistency = FALSE; - sw_waitlist = FALSE; - sw_file = FALSE; - sw_requests = sw_locks = sw_history = sw_nobridge = FALSE; - sw_owners = TRUE; + sw_consistency = false; + sw_waitlist = false; + sw_file = false; + sw_requests = sw_locks = sw_history = sw_nobridge = false; + sw_owners = true; sw_series = sw_interactive = sw_intervals = sw_seconds = 0; while (--argc) { @@ -206,31 +210,31 @@ void CLIB_ROUTINE main( int argc, char *argv[]) switch (c) { case 'o': case 'p': - sw_owners = TRUE; + sw_owners = true; break; case 'c': - sw_nobridge = TRUE; - sw_consistency = TRUE; + sw_nobridge = true; + sw_consistency = true; break; case 'l': - sw_locks = TRUE; + sw_locks = true; break; case 'r': - sw_requests = TRUE; + sw_requests = true; break; case 'a': - sw_locks = TRUE; - sw_owners = TRUE; - sw_requests = TRUE; - sw_history = TRUE; + sw_locks = true; + sw_owners = true; + sw_requests = true; + sw_history = true; break; case 'h': - sw_history = TRUE; + sw_history = true; break; case 's': @@ -245,7 +249,7 @@ void CLIB_ROUTINE main( int argc, char *argv[]) break; case 'n': - sw_nobridge = TRUE; + sw_nobridge = true; break; case 'i': @@ -277,7 +281,7 @@ void CLIB_ROUTINE main( int argc, char *argv[]) sw_interactive = (SW_I_ACQUIRE | SW_I_OPERATION | SW_I_TYPE | SW_I_WAIT); - sw_nobridge = TRUE; + sw_nobridge = true; sw_seconds = sw_intervals = 1; if (argc > 1) { sw_seconds = atoi(*argv++); @@ -296,13 +300,13 @@ void CLIB_ROUTINE main( int argc, char *argv[]) break; case 'w': - sw_nobridge = TRUE; - sw_waitlist = TRUE; + sw_nobridge = true; + sw_waitlist = true; break; case 'f': - sw_nobridge = TRUE; - sw_file = TRUE; + sw_nobridge = true; + sw_file = true; if (argc > 1) { lock_file = *argv++; --argc; @@ -358,8 +362,8 @@ void CLIB_ROUTINE main( int argc, char *argv[]) && LOCK_header->lhb_length > shmem_data.sh_mem_length_mapped) { length = LOCK_header->lhb_length; #if (!(defined UNIX) || (defined HAVE_MMAP)) - LOCK_header = - (LHB) ISC_remap_file(status_vector, &shmem_data, length, FALSE); + LOCK_header = (LHB) ISC_remap_file(status_vector, &shmem_data, length, + FALSE); #endif } @@ -832,7 +836,7 @@ static void prt_history( FPRINTF(outfile, "%s:\n", title); - for (history = (HIS) ABS_PTR(history_header); TRUE; + for (history = (HIS) ABS_PTR(history_header); true; history = (HIS) ABS_PTR(history->his_next)) { if (history->his_operation) FPRINTF(outfile, @@ -920,10 +924,11 @@ static void prt_lock( } -static void prt_owner( - OUTFILE outfile, +static void prt_owner(OUTFILE outfile, LHB LOCK_header, - OWN owner, BOOLEAN sw_requests, BOOLEAN sw_waitlist) + OWN owner, + bool sw_requests, + bool sw_waitlist) { /************************************** * @@ -1043,7 +1048,7 @@ static void prt_owner_wait_cycle( LRQ owner_request; LBL lock; USHORT counter; - BOOLEAN owner_conversion; + bool owner_conversion; if (waiters->waitque_depth > FB_NELEM(waiters->waitque_entry)) { FPRINTF(outfile, "Dependency too deep\n"); @@ -1055,8 +1060,7 @@ static void prt_owner_wait_cycle( FPRINTF(outfile, "\n"); owner_request = (LRQ) ABS_PTR(owner->own_pending_request); assert(owner_request->lrq_type == type_lrq); - owner_conversion = - (owner_request->lrq_state > LCK_null) ? TRUE : FALSE; + owner_conversion = (owner_request->lrq_state > LCK_null) ? true : false; lock = (LBL) ABS_PTR(owner_request->lrq_lock); assert(lock->lbl_type == type_lbl); @@ -1079,8 +1083,7 @@ static void prt_owner_wait_cycle( assert(lock_request->lrq_type == type_lrq); - if (LOCK_header->lhb_flags & LHB_lock_ordering - && !owner_conversion) { + if (LOCK_header->lhb_flags & LHB_lock_ordering && !owner_conversion) { /* Requests AFTER our request can't block us */ if (owner_request == lock_request)