mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Misc changes:
- const - variables in scope - style - a duplicate function deleted - some unneeded casts removed
This commit is contained in:
parent
7e9785325c
commit
a65ccddbd4
@ -27,7 +27,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: c_cxx.cpp,v 1.49 2004-05-24 17:13:37 brodsom Exp $
|
||||
// $Id: c_cxx.cpp,v 1.50 2004-06-03 07:31:09 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -1483,8 +1483,8 @@ static void gen_database( const act* action, int column)
|
||||
for (REF reference = port->por_references; reference;
|
||||
reference = reference->ref_next)
|
||||
{
|
||||
if (reference->ref_flags & REF_fetch_array)
|
||||
make_array_declaration(reference);
|
||||
if (reference->ref_flags & REF_fetch_array)
|
||||
make_array_declaration(reference);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2581,9 +2581,11 @@ static void gen_on_error( const act* action, USHORT column)
|
||||
if ((err_action->act_type == ACT_get_segment) ||
|
||||
(err_action->act_type == ACT_put_segment) ||
|
||||
(err_action->act_type == ACT_endblob))
|
||||
printa(column,
|
||||
"if (%s [1] && (%s [1] != isc_segment) && (%s [1] != isc_segstr_eof))",
|
||||
global_status_name, global_status_name, global_status_name);
|
||||
{
|
||||
printa(column,
|
||||
"if (%s [1] && (%s [1] != isc_segment) && (%s [1] != isc_segstr_eof))",
|
||||
global_status_name, global_status_name, global_status_name);
|
||||
}
|
||||
else
|
||||
printa(column, "if (%s [1])", global_status_name);
|
||||
column += INDENT;
|
||||
@ -2652,8 +2654,6 @@ static void gen_procedure( const act* action, int column)
|
||||
|
||||
static void gen_put_segment( const act* action, int column)
|
||||
{
|
||||
blb* blob;
|
||||
PAT args;
|
||||
const TEXT* pattern1 = "%IF%S1 [1] = %ENisc_put_segment (%V1, &%BH, %I1, %I2);";
|
||||
|
||||
if (!action->act_error)
|
||||
@ -2661,6 +2661,7 @@ static void gen_put_segment( const act* action, int column)
|
||||
if (action->act_error || (action->act_flags & ACT_sql))
|
||||
begin(column);
|
||||
|
||||
blb* blob;
|
||||
if (action->act_flags & ACT_sql) {
|
||||
blob = (blb*) action->act_request->req_blobs;
|
||||
REF from = action->act_object;
|
||||
@ -2675,6 +2676,7 @@ static void gen_put_segment( const act* action, int column)
|
||||
else
|
||||
blob = (blb*) action->act_object;
|
||||
|
||||
PAT args;
|
||||
args.pat_blob = blob;
|
||||
args.pat_vector1 = status_vector(action);
|
||||
args.pat_condition = !(action->act_error
|
||||
@ -2925,7 +2927,7 @@ static void gen_request(const gpre_req* request)
|
||||
printa(0, "static %schar\n isc_%d [] = {", CONST_STR,
|
||||
reference->ref_sdl_ident);
|
||||
if (gpreGlob.sw_raw)
|
||||
gen_raw((UCHAR *) reference->ref_sdl,
|
||||
gen_raw(reference->ref_sdl,
|
||||
reference->ref_sdl_length);
|
||||
else
|
||||
if (PRETTY_print_sdl(reference->ref_sdl, gen_blr, 0, 0))
|
||||
@ -3140,6 +3142,7 @@ static void gen_select( const act* action, int column)
|
||||
align(column);
|
||||
asgn_to(action, (REF) var_list->nod_arg[i], column);
|
||||
}
|
||||
|
||||
if (request->req_database->dbb_flags & DBB_v3) {
|
||||
gen_receive(action, column, port);
|
||||
printa(column, "if (!SQLCODE && %s)", name);
|
||||
@ -3182,7 +3185,6 @@ static void gen_send( const act* action, const gpre_port* port, int column)
|
||||
|
||||
static void gen_slice( const act* action, REF var_reference, int column)
|
||||
{
|
||||
PAT args;
|
||||
const TEXT* pattern1 = "isc_get_slice (%V1, &%DH, &%RT, &%FR, (short) %N1, \
|
||||
(char *) %I1, (short) %N2, %I1v, %I1s, %S5, &isc_array_length);";
|
||||
const TEXT* pattern2 = "isc_put_slice (%V1, &%DH, &%RT, &%FR, (short) %N1, \
|
||||
@ -3197,13 +3199,13 @@ static void gen_slice( const act* action, REF var_reference, int column)
|
||||
printa(column, "isc_%ds = %d", request->req_ident,
|
||||
slice->slc_field->fld_array->fld_length);
|
||||
|
||||
slc::slc_repeat *tail, *end;
|
||||
for (tail = slice->slc_rpt, end = tail + slice->slc_dimensions;
|
||||
const slc::slc_repeat* tail = slice->slc_rpt;
|
||||
for (const slc::slc_repeat* const end = tail + slice->slc_dimensions;
|
||||
tail < end; ++tail)
|
||||
{
|
||||
if (tail->slc_upper != tail->slc_lower) {
|
||||
REF lower = (REF) tail->slc_lower->nod_arg[0];
|
||||
REF upper = (REF) tail->slc_upper->nod_arg[0];
|
||||
const ref* lower = (REF) tail->slc_lower->nod_arg[0];
|
||||
const ref* upper = (REF) tail->slc_upper->nod_arg[0];
|
||||
if (lower->ref_value)
|
||||
fprintf(gpreGlob.out_file, " * ( %s - %s + 1)", upper->ref_value,
|
||||
lower->ref_value);
|
||||
@ -3224,6 +3226,7 @@ static void gen_slice( const act* action, REF var_reference, int column)
|
||||
request->req_ident, reference->ref_id, reference->ref_value);
|
||||
}
|
||||
|
||||
PAT args;
|
||||
args.pat_reference =
|
||||
(var_reference ? var_reference : slice->slc_field_ref);
|
||||
args.pat_request = parent_request; // blob id request
|
||||
@ -3261,7 +3264,6 @@ static void gen_start(const act* action,
|
||||
int column,
|
||||
bool sending)
|
||||
{
|
||||
PAT args;
|
||||
const TEXT* pattern1 =
|
||||
"isc_start_and_send (%V1, (FB_API_HANDLE*) &%RH, (FB_API_HANDLE*) &%S1, (short) %PN, (short) %PL, &%PI, (short) %RL);";
|
||||
const TEXT* pattern2 = "isc_start_request (%V1, (FB_API_HANDLE*) &%RH, (FB_API_HANDLE*) &%S1, (short) %RL);";
|
||||
@ -3275,6 +3277,7 @@ static void gen_start(const act* action,
|
||||
}
|
||||
}
|
||||
|
||||
PAT args;
|
||||
args.pat_request = action->act_request;
|
||||
args.pat_vector1 = status_vector(action);
|
||||
args.pat_port = port;
|
||||
|
@ -25,7 +25,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: cme.cpp,v 1.29 2004-05-29 04:50:46 robocop Exp $
|
||||
// $Id: cme.cpp,v 1.30 2004-06-03 07:31:09 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -499,16 +499,18 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
|
||||
|
||||
case dtype_sql_date:
|
||||
if (kw_word == KW_HOUR || kw_word == KW_MINUTE
|
||||
|| kw_word ==
|
||||
KW_SECOND)
|
||||
CPR_error("Invalid extract part for SQL DATE type");
|
||||
|| kw_word == KW_SECOND)
|
||||
{
|
||||
CPR_error("Invalid extract part for SQL DATE type");
|
||||
}
|
||||
break;
|
||||
|
||||
case dtype_sql_time:
|
||||
if (kw_word != KW_HOUR && kw_word != KW_MINUTE
|
||||
&& kw_word !=
|
||||
KW_SECOND)
|
||||
CPR_error("Invalid extract part for SQL TIME type");
|
||||
&& kw_word != KW_SECOND)
|
||||
{
|
||||
CPR_error("Invalid extract part for SQL TIME type");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1078,7 +1080,6 @@ void CME_relation(gpre_ctx* context, gpre_req* request)
|
||||
|
||||
void CME_rse(gpre_rse* selection, gpre_req* request)
|
||||
{
|
||||
gpre_rse* sub_rse;
|
||||
SSHORT i;
|
||||
|
||||
if (selection->rse_join_type == (NOD_T) 0)
|
||||
@ -1095,6 +1096,7 @@ void CME_rse(gpre_rse* selection, gpre_req* request)
|
||||
|
||||
// Process unions, if any, otherwise process relations
|
||||
|
||||
gpre_rse* sub_rse = 0;
|
||||
gpre_nod* union_node = selection->rse_union;
|
||||
if (union_node)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: cmp.cpp,v 1.31 2004-05-24 17:13:36 brodsom Exp $
|
||||
// $Id: cmp.cpp,v 1.32 2004-06-03 07:31:09 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -994,37 +994,37 @@ static void cmp_loop( gpre_req* request)
|
||||
switch (node->nod_type)
|
||||
{
|
||||
case nod_modify:
|
||||
{
|
||||
request->add_byte(blr_modify);
|
||||
request->add_byte(for_context->ctx_internal);
|
||||
request->add_byte(update_context->ctx_internal);
|
||||
gpre_nod* list = node->nod_arg[0];
|
||||
request->add_byte(blr_begin);
|
||||
gpre_nod** ptr = list->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + list->nod_count; ptr < end;
|
||||
ptr++)
|
||||
{
|
||||
cmp_assignment(*ptr, request);
|
||||
request->add_byte(blr_modify);
|
||||
request->add_byte(for_context->ctx_internal);
|
||||
request->add_byte(update_context->ctx_internal);
|
||||
gpre_nod* list = node->nod_arg[0];
|
||||
request->add_byte(blr_begin);
|
||||
gpre_nod** ptr = list->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + list->nod_count; ptr < end;
|
||||
ptr++)
|
||||
{
|
||||
cmp_assignment(*ptr, request);
|
||||
}
|
||||
request->add_byte(blr_end);
|
||||
break;
|
||||
}
|
||||
request->add_byte(blr_end);
|
||||
break;
|
||||
}
|
||||
case nod_store:
|
||||
{
|
||||
update_context = (gpre_ctx*) node->nod_arg[0];
|
||||
request->add_byte(blr_store);
|
||||
CME_relation(update_context, request);
|
||||
gpre_nod* list = node->nod_arg[1];
|
||||
request->add_byte(blr_begin);
|
||||
gpre_nod** ptr = list->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + list->nod_count; ptr < end;
|
||||
ptr++)
|
||||
{
|
||||
cmp_assignment(*ptr, request);
|
||||
update_context = (gpre_ctx*) node->nod_arg[0];
|
||||
request->add_byte(blr_store);
|
||||
CME_relation(update_context, request);
|
||||
gpre_nod* list = node->nod_arg[1];
|
||||
request->add_byte(blr_begin);
|
||||
gpre_nod** ptr = list->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + list->nod_count; ptr < end;
|
||||
ptr++)
|
||||
{
|
||||
cmp_assignment(*ptr, request);
|
||||
}
|
||||
request->add_byte(blr_end);
|
||||
break;
|
||||
}
|
||||
request->add_byte(blr_end);
|
||||
break;
|
||||
}
|
||||
case nod_erase:
|
||||
request->add_byte(blr_erase);
|
||||
request->add_byte(for_context->ctx_internal);
|
||||
|
@ -27,7 +27,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: cob.cpp,v 1.45 2004-05-29 04:50:46 robocop Exp $
|
||||
// $Id: cob.cpp,v 1.46 2004-06-03 07:31:09 robocop Exp $
|
||||
//
|
||||
// 2002.10.27 Sean Leyne - Completed removal of obsolete "DG_X86" port
|
||||
// 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "UNIXWARE" port
|
||||
@ -3371,7 +3371,7 @@ static void gen_request( gpre_req* request)
|
||||
if (reference->ref_sdl) {
|
||||
printa(names[COLUMN_0], false, "01 %s%d.", names[isc_a_pos],
|
||||
reference->ref_sdl_ident);
|
||||
gen_raw((UCHAR*) reference->ref_sdl, REQ_slice,
|
||||
gen_raw(reference->ref_sdl, REQ_slice,
|
||||
reference->ref_sdl_length, reference->ref_sdl_ident);
|
||||
if (!gpreGlob.sw_raw)
|
||||
if (PRETTY_print_sdl(reference->ref_sdl, gen_blr, 0, 0))
|
||||
|
@ -24,7 +24,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: ftn.cpp,v 1.47 2004-05-29 04:50:46 robocop Exp $
|
||||
// $Id: ftn.cpp,v 1.48 2004-06-03 07:31:09 robocop Exp $
|
||||
//
|
||||
// 2002.10.28 Sean Leyne - Completed removal of obsolete "DGUX" port
|
||||
// 2002.10.28 Sean Leyne - Completed removal of obsolete "SGI" port
|
||||
@ -2946,7 +2946,7 @@ static void gen_request_data( const gpre_req* request)
|
||||
reference->ref_sdl_ident, COMMA,
|
||||
(begin_i / sizeof(SLONG)) + 1,
|
||||
(end_i / sizeof(SLONG)) + 1);
|
||||
gen_raw((const UCHAR*) reference->ref_sdl, REQ_slice,
|
||||
gen_raw(reference->ref_sdl, REQ_slice,
|
||||
reference->ref_sdl_length, begin_i, end_i);
|
||||
}
|
||||
if (!(gpreGlob.sw_raw)) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
* $Id: gpre.h,v 1.68 2004-05-29 04:48:42 robocop Exp $
|
||||
* $Id: gpre.h,v 1.69 2004-06-03 07:31:09 robocop Exp $
|
||||
* Revision 1.3 2000/11/27 09:26:13 fsg
|
||||
* Fixed bugs in gpre to handle PYXIS forms
|
||||
* and allow edit.e and fred.e to go through
|
||||
@ -1242,9 +1242,9 @@ class ref {
|
||||
gpre_nod* ref_expr; /* expression, if node is expression */
|
||||
TEXT *ref_value; /* value string if host language value */
|
||||
val* ref_values; /* linked list of values */
|
||||
TEXT *ref_null_value; /* value string if host language value */
|
||||
UCHAR *ref_sdl; /* Raw slice description language for an array */
|
||||
UCHAR *ref_sdl_base; /* base of sdl string during generation */
|
||||
TEXT* ref_null_value; /* value string if host language value */
|
||||
UCHAR* ref_sdl; /* Raw slice description language for an array */
|
||||
UCHAR* ref_sdl_base; /* base of sdl string during generation */
|
||||
int ref_sdl_length; /* sdl length for this reference */
|
||||
slc* ref_slice; /* Slice, if field referenced is sliced */
|
||||
USHORT ref_sdl_ident; /* identifier of sdl structure */
|
||||
@ -1253,7 +1253,7 @@ class ref {
|
||||
SSHORT ref_ttype; /* Character set type for literals */
|
||||
|
||||
inline void add_byte(const int byte) {
|
||||
*ref_sdl++ = (SCHAR) (byte);
|
||||
*ref_sdl++ = (UCHAR) byte;
|
||||
}
|
||||
inline void add_word(const int word) {
|
||||
add_byte(word);
|
||||
|
@ -26,7 +26,7 @@
|
||||
*
|
||||
*____________________________________________________________
|
||||
*
|
||||
* $Id: gpre_meta.epp,v 1.43 2004-05-24 17:13:37 brodsom Exp $
|
||||
* $Id: gpre_meta.epp,v 1.44 2004-06-03 07:31:09 robocop Exp $
|
||||
*/
|
||||
|
||||
#include "firebird.h"
|
||||
@ -171,7 +171,8 @@ bool MET_database(dbb* database, bool print_version)
|
||||
}
|
||||
|
||||
if (isc_attach_database
|
||||
(gds_status, 0, database->dbb_filename, &DB, d - &dpb[0], dpb)) {
|
||||
(gds_status, 0, database->dbb_filename, &DB, d - &dpb[0], dpb))
|
||||
{
|
||||
/* We failed to attach, try in read only mode just in case
|
||||
if (d == dpb)
|
||||
*d++ = isc_dpb_version1;
|
||||
@ -278,7 +279,8 @@ bool MET_database(dbb* database, bool print_version)
|
||||
// get the base level of the engine
|
||||
|
||||
if (isc_database_info(gds_status, &DB, sizeof(db_version_info),
|
||||
db_version_info, sizeof(buffer), buffer)) {
|
||||
db_version_info, sizeof(buffer), buffer))
|
||||
{
|
||||
isc_print_status(gds_status);
|
||||
return false;
|
||||
}
|
||||
@ -1406,7 +1408,9 @@ IND MET_index(dbb* database, const TEXT* string)
|
||||
if (symbol->sym_type == SYM_index &&
|
||||
(index = (IND) symbol->sym_object) &&
|
||||
index->ind_relation->rel_database == database)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
if (gpreGlob.sw_language == lang_internal)
|
||||
return NULL;
|
||||
@ -1480,7 +1484,6 @@ void MET_load_hash_table(dbb* database)
|
||||
database->dbb_flags |= DBB_v3;
|
||||
|
||||
gpre_sym* symbol;
|
||||
TEXT* p;
|
||||
SLONG length;
|
||||
|
||||
/* Pick up all relations (necessary to parse parts of the GDML grammar) */
|
||||
@ -1565,6 +1568,7 @@ void MET_load_hash_table(dbb* database)
|
||||
* this may fail
|
||||
*/
|
||||
|
||||
TEXT* p;
|
||||
FB_API_HANDLE handle2 = 0;
|
||||
|
||||
FOR(REQUEST_HANDLE handle)
|
||||
@ -2216,7 +2220,8 @@ static int symbol_length(const TEXT* string)
|
||||
|
||||
const TEXT* p = string + (len - 1);
|
||||
|
||||
for (; p >= string && *p == ' '; p--);
|
||||
while (p >= string && *p == ' ')
|
||||
--p;
|
||||
if (p < string)
|
||||
return 0;
|
||||
++p;
|
||||
@ -2232,11 +2237,10 @@ static int symbol_length(const TEXT* string)
|
||||
|
||||
static int upcase(const TEXT* from, TEXT* to)
|
||||
{
|
||||
TEXT c;
|
||||
|
||||
TEXT* p = to;
|
||||
const TEXT* const end = to + NAME_SIZE;
|
||||
|
||||
TEXT c;
|
||||
while (p < end && (c = *from++)) {
|
||||
*p++ = UPPER(c);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: hsh.cpp,v 1.19 2004-05-24 17:13:37 brodsom Exp $
|
||||
// $Id: hsh.cpp,v 1.20 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -59,10 +59,8 @@ static struct word {
|
||||
|
||||
void HSH_fini(void)
|
||||
{
|
||||
gpre_sym* symbol;
|
||||
|
||||
while (key_symbols) {
|
||||
symbol = key_symbols;
|
||||
gpre_sym* symbol = key_symbols;
|
||||
key_symbols = (gpre_sym*) key_symbols->sym_object;
|
||||
HSH_remove(symbol);
|
||||
MSC_free((UCHAR *) symbol);
|
||||
@ -78,19 +76,18 @@ void HSH_fini(void)
|
||||
|
||||
void HSH_init(void)
|
||||
{
|
||||
SCHAR *string;
|
||||
gpre_sym* symbol;
|
||||
gpre_sym** ptr;
|
||||
int i;
|
||||
word* a_word;
|
||||
//SCHAR *string;
|
||||
|
||||
for (ptr = hash_table, i = 0; i < HASH_SIZE; i++)
|
||||
int i = 0;
|
||||
for (gpre_sym** ptr = hash_table; i < HASH_SIZE; i++)
|
||||
*ptr++ = NULL;
|
||||
|
||||
fflush(stdout);
|
||||
word* a_word;
|
||||
for (i = 0, a_word = keywords; i < FB_NELEM(keywords); i++, a_word++) {
|
||||
for (string = a_word->keyword; *string; string++);
|
||||
symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
// Unused code: SYM_LEN is used always.
|
||||
//for (string = a_word->keyword; *string; string++);
|
||||
gpre_sym* symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
symbol->sym_type = SYM_keyword;
|
||||
symbol->sym_string = a_word->keyword;
|
||||
symbol->sym_keyword = (int) a_word->id;
|
||||
@ -108,13 +105,10 @@ void HSH_init(void)
|
||||
|
||||
void HSH_insert( gpre_sym* symbol)
|
||||
{
|
||||
gpre_sym** next;
|
||||
gpre_sym* ptr;
|
||||
const int h = hash(symbol->sym_string);
|
||||
|
||||
int h = hash(symbol->sym_string);
|
||||
|
||||
for (next = &hash_table[h]; *next; next = &(*next)->sym_collision) {
|
||||
for (ptr = *next; ptr; ptr = ptr->sym_homonym)
|
||||
for (gpre_sym** next = &hash_table[h]; *next; next = &(*next)->sym_collision) {
|
||||
for (const gpre_sym* ptr = *next; ptr; ptr = ptr->sym_homonym)
|
||||
if (ptr == symbol)
|
||||
return;
|
||||
|
||||
@ -190,13 +184,12 @@ gpre_sym* HSH_lookup2(const SCHAR* string)
|
||||
|
||||
void HSH_remove( gpre_sym* symbol)
|
||||
{
|
||||
gpre_sym** next;
|
||||
gpre_sym** ptr;
|
||||
gpre_sym* homonym;
|
||||
|
||||
int h = hash(symbol->sym_string);
|
||||
const int h = hash(symbol->sym_string);
|
||||
|
||||
for (next = &hash_table[h]; *next; next = &(*next)->sym_collision)
|
||||
for (gpre_sym** next = &hash_table[h]; *next; next = &(*next)->sym_collision)
|
||||
if (symbol == *next)
|
||||
if (homonym = symbol->sym_homonym) {
|
||||
homonym->sym_collision = symbol->sym_collision;
|
||||
@ -273,3 +266,4 @@ static bool scompare2(const SCHAR* string1,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: jrdmet.cpp,v 1.17 2004-05-02 23:04:17 skidder Exp $
|
||||
// $Id: jrdmet.cpp,v 1.18 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -50,8 +50,6 @@
|
||||
|
||||
void JRDMET_init( DBB db)
|
||||
{
|
||||
gpre_sym* symbol;
|
||||
|
||||
const UCHAR* relfld = relfields;
|
||||
|
||||
while (relfld[RFLD_R_NAME]) {
|
||||
@ -60,7 +58,8 @@ void JRDMET_init( DBB db)
|
||||
relation->rel_next = db->dbb_relations;
|
||||
relation->rel_id = relfld[RFLD_R_ID];
|
||||
db->dbb_relations = relation;
|
||||
relation->rel_symbol = symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
gpre_sym* symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
relation->rel_symbol = symbol;
|
||||
symbol->sym_type = SYM_relation;
|
||||
symbol->sym_object = (gpre_ctx*) relation;
|
||||
|
||||
@ -122,7 +121,8 @@ void JRDMET_init( DBB db)
|
||||
|
||||
for (const rtyp* rtype = types; rtype->rtyp_name; rtype++) {
|
||||
field_type* type = (field_type*) MSC_alloc(TYP_LEN);
|
||||
type->typ_symbol = symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
gpre_sym* symbol = (gpre_sym*) MSC_alloc(SYM_LEN);
|
||||
type->typ_symbol = symbol;
|
||||
type->typ_value = rtype->rtyp_value;
|
||||
symbol->sym_type = SYM_type;
|
||||
symbol->sym_object = (gpre_ctx*) type;
|
||||
|
104
src/gpre/par.cpp
104
src/gpre/par.cpp
@ -20,7 +20,7 @@
|
||||
//
|
||||
// All Rights Reserved.
|
||||
// Contributor(s): ______________________________________.
|
||||
// $Id: par.cpp,v 1.50 2004-05-29 04:54:20 robocop Exp $
|
||||
// $Id: par.cpp,v 1.51 2004-06-03 07:31:10 robocop Exp $
|
||||
// Revision 1.2 2000/11/27 09:26:13 fsg
|
||||
// Fixed bugs in gpre to handle PYXIS forms
|
||||
// and allow edit.e and fred.e to go through
|
||||
@ -401,7 +401,6 @@ SSHORT PAR_blob_subtype(DBB db)
|
||||
|
||||
act* PAR_database(bool sql, const TEXT* base_directory)
|
||||
{
|
||||
DBB* db_ptr;
|
||||
TEXT s[256], *string;
|
||||
|
||||
act* action = MSC_action(0, ACT_database);
|
||||
@ -564,7 +563,7 @@ act* PAR_database(bool sql, const TEXT* base_directory)
|
||||
// Since we have a real DATABASE statement, get rid of any artificial
|
||||
// databases that were created because of an INCLUDE SQLCA statement.
|
||||
|
||||
for (db_ptr = &gpreGlob.isc_databases; *db_ptr;)
|
||||
for (DBB* db_ptr = &gpreGlob.isc_databases; *db_ptr;)
|
||||
if ((*db_ptr)->dbb_flags & DBB_sqlca)
|
||||
*db_ptr = (*db_ptr)->dbb_next;
|
||||
else
|
||||
@ -615,10 +614,6 @@ void PAR_error(const TEXT* string)
|
||||
|
||||
act* PAR_event_init(bool sql)
|
||||
{
|
||||
GPRE_NOD node;
|
||||
gpre_lls* stack = NULL;
|
||||
gpre_sym* symbol;
|
||||
int count = 0;
|
||||
char req_name[128];
|
||||
|
||||
// make up statement node
|
||||
@ -635,7 +630,8 @@ act* PAR_event_init(bool sql)
|
||||
// parse optional database handle
|
||||
|
||||
if (!MSC_match(KW_LEFT_PAREN)) {
|
||||
if ((symbol = gpreGlob.token_global.tok_symbol) && (symbol->sym_type == SYM_database))
|
||||
gpre_sym* symbol = gpreGlob.token_global.tok_symbol;
|
||||
if (symbol && (symbol->sym_type == SYM_database))
|
||||
init->nod_arg[3] = (GPRE_NOD) symbol->sym_object;
|
||||
else
|
||||
CPR_s_error("left parenthesis or database handle");
|
||||
@ -648,10 +644,15 @@ act* PAR_event_init(bool sql)
|
||||
// eat any number of event strings until a right paren is found,
|
||||
// pushing the gpreGlob.events onto a stack
|
||||
|
||||
GPRE_NOD node;
|
||||
gpre_lls* stack = NULL;
|
||||
int count = 0;
|
||||
|
||||
while (true) {
|
||||
if (MSC_match(KW_RIGHT_PAREN))
|
||||
break;
|
||||
|
||||
const gpre_sym* symbol;
|
||||
if (!sql && (symbol = gpreGlob.token_global.tok_symbol)
|
||||
&& symbol->sym_type == SYM_context)
|
||||
{
|
||||
@ -802,8 +803,6 @@ TEXT* PAR_native_value(bool array_ref,
|
||||
{
|
||||
SCHAR buffer[512];
|
||||
SCHAR* s1;
|
||||
enum kwwords keyword;
|
||||
USHORT parens, brackets;
|
||||
|
||||
SCHAR* string = buffer;
|
||||
|
||||
@ -855,12 +854,11 @@ TEXT* PAR_native_value(bool array_ref,
|
||||
if ((gpreGlob.sw_language == lang_ada) && (gpreGlob.token_global.tok_string[0] == '\'')) {
|
||||
gobble(string, s1);
|
||||
}
|
||||
keyword = gpreGlob.token_global.tok_keyword;
|
||||
enum kwwords keyword = gpreGlob.token_global.tok_keyword;
|
||||
if (keyword == KW_LEFT_PAREN) {
|
||||
parens = 1;
|
||||
int parens = 1;
|
||||
while (parens) {
|
||||
enum tok_t typ;
|
||||
typ = gpreGlob.token_global.tok_type;
|
||||
const enum tok_t typ = gpreGlob.token_global.tok_type;
|
||||
if (isQuoted(typ))
|
||||
*string++ = (typ == tok_sglquoted) ? '\'' : '\"';
|
||||
gobble(string, s1);
|
||||
@ -876,7 +874,7 @@ TEXT* PAR_native_value(bool array_ref,
|
||||
keyword = gpreGlob.token_global.tok_keyword;
|
||||
}
|
||||
while (keyword == KW_L_BRCKET) {
|
||||
brackets = 1;
|
||||
int brackets = 1;
|
||||
while (brackets) {
|
||||
gobble(string, s1);
|
||||
keyword = gpreGlob.token_global.tok_keyword;
|
||||
@ -949,7 +947,6 @@ gpre_fld* PAR_null_field()
|
||||
void PAR_reserving( USHORT flags, bool parse_sql)
|
||||
{
|
||||
DBB database;
|
||||
USHORT lock_level, lock_mode;
|
||||
|
||||
while (true) {
|
||||
// find a relation name, or maybe a list of them
|
||||
@ -974,8 +971,8 @@ void PAR_reserving( USHORT flags, bool parse_sql)
|
||||
*/
|
||||
|
||||
MSC_match(KW_FOR);
|
||||
lock_level = (flags & TRA_con) ? isc_tpb_protected : isc_tpb_shared;
|
||||
lock_mode = isc_tpb_lock_read;
|
||||
USHORT lock_level = (flags & TRA_con) ? isc_tpb_protected : isc_tpb_shared;
|
||||
USHORT lock_mode = isc_tpb_lock_read;
|
||||
|
||||
if (MSC_match(KW_PROTECTED))
|
||||
lock_level = isc_tpb_protected;
|
||||
@ -1254,12 +1251,9 @@ static act* par_at()
|
||||
|
||||
static act* par_based()
|
||||
{
|
||||
gpre_fld* field;
|
||||
gpre_rel* relation;
|
||||
TEXT s[64];
|
||||
TEXT t_str[NAME_SIZE + 1];
|
||||
bool ambiguous_flag;
|
||||
int notSegment = 0; // a COBOL specific patch
|
||||
bool notSegment = false; // a COBOL specific patch
|
||||
char tmpChar[2]; // a COBOL specific patch
|
||||
|
||||
MSC_match(KW_ON);
|
||||
@ -1268,11 +1262,12 @@ static act* par_based()
|
||||
action->act_object = (REF) based_on;
|
||||
|
||||
if ((gpreGlob.sw_language != lang_fortran) || gpreGlob.isc_databases) {
|
||||
relation = EXP_relation();
|
||||
gpre_rel* relation = EXP_relation();
|
||||
if (!MSC_match(KW_DOT))
|
||||
CPR_s_error("dot in qualified field reference");
|
||||
SQL_resolve_identifier("<fieldname>", t_str);
|
||||
if (!(field = MET_field(relation, gpreGlob.token_global.tok_string))) {
|
||||
gpre_fld* field = MET_field(relation, gpreGlob.token_global.tok_string);
|
||||
if (!field) {
|
||||
sprintf(s, "undefined field %s", gpreGlob.token_global.tok_string);
|
||||
PAR_error(s);
|
||||
}
|
||||
@ -1297,7 +1292,7 @@ static act* par_based()
|
||||
("only .SEGMENT allowed after qualified field name");
|
||||
else {
|
||||
strcpy(based_on->bas_terminator, tmpChar);
|
||||
notSegment = 1;
|
||||
notSegment = true;
|
||||
}
|
||||
}
|
||||
else if (!(field->fld_flags & FLD_blob)) {
|
||||
@ -1305,8 +1300,8 @@ static act* par_based()
|
||||
field->fld_symbol->sym_string);
|
||||
PAR_error(s);
|
||||
}
|
||||
if (notSegment == 0) /* this is flag is to solve KW_DOT problem
|
||||
in COBOL. should be 0 for all other lang */
|
||||
if (!notSegment) /* this is flag is to solve KW_DOT problem
|
||||
in COBOL. should be false for all other lang */
|
||||
based_on->bas_flags |= BAS_segment;
|
||||
}
|
||||
based_on->bas_field = field;
|
||||
@ -1322,7 +1317,7 @@ static act* par_based()
|
||||
based_on->bas_fld_name = (STR) MSC_alloc(gpreGlob.token_global.tok_length + 1);
|
||||
MSC_copy(gpreGlob.token_global.tok_string, gpreGlob.token_global.tok_length,
|
||||
based_on->bas_fld_name->str_string);
|
||||
ambiguous_flag = false;
|
||||
bool ambiguous_flag = false;
|
||||
PAR_get_token();
|
||||
if (MSC_match(KW_DOT)) {
|
||||
based_on->bas_db_name = based_on->bas_rel_name;
|
||||
@ -1559,8 +1554,8 @@ static act* par_derived_from()
|
||||
CPR_s_error("dot in qualified field reference");
|
||||
SQL_resolve_identifier("<Field Name>", s);
|
||||
|
||||
gpre_fld* field;
|
||||
if (!(field = MET_field(relation, gpreGlob.token_global.tok_string))) {
|
||||
gpre_fld* field = MET_field(relation, gpreGlob.token_global.tok_string);
|
||||
if (!field) {
|
||||
sprintf(s, "undefined field %s", gpreGlob.token_global.tok_string);
|
||||
PAR_error(s);
|
||||
}
|
||||
@ -1816,12 +1811,8 @@ static act* par_end_stream()
|
||||
|
||||
static act* par_end_store(bool special)
|
||||
{
|
||||
gpre_ctx* context;
|
||||
upd* return_values;
|
||||
REF reference, change;
|
||||
GPRE_NOD assignments, item;
|
||||
int count;
|
||||
gpre_lls* stack;
|
||||
REF reference;
|
||||
GPRE_NOD assignments;
|
||||
|
||||
if (!cur_store)
|
||||
PAR_error("unmatched END_STORE");
|
||||
@ -1837,7 +1828,7 @@ static act* par_end_store(bool special)
|
||||
|
||||
// Make up an assignment list for all field references
|
||||
|
||||
count = 0;
|
||||
int count = 0;
|
||||
for (reference = request->req_references; reference;
|
||||
reference = reference->ref_next)
|
||||
{
|
||||
@ -1853,7 +1844,7 @@ static act* par_end_store(bool special)
|
||||
{
|
||||
if (reference->ref_master)
|
||||
continue;
|
||||
item = MSC_node(nod_assignment, 2);
|
||||
gpre_nod* item = MSC_node(nod_assignment, 2);
|
||||
item->nod_arg[0] = MSC_unary(nod_value, (GPRE_NOD) reference);
|
||||
item->nod_arg[1] = MSC_unary(nod_field, (GPRE_NOD) reference);
|
||||
assignments->nod_arg[count++] = item;
|
||||
@ -1866,12 +1857,12 @@ static act* par_end_store(bool special)
|
||||
*/
|
||||
|
||||
act* action2 = (act*) MSC_pop(&cur_store);
|
||||
return_values = (upd*) action2->act_object;
|
||||
upd* return_values = (upd*) action2->act_object;
|
||||
|
||||
// Build assignments for all fields and null flags referenced
|
||||
|
||||
stack = NULL;
|
||||
count = 0;
|
||||
gpre_lls* stack = NULL;
|
||||
int count = 0;
|
||||
|
||||
for (reference = request->req_references; reference;
|
||||
reference = reference->ref_next)
|
||||
@ -1880,13 +1871,13 @@ static act* par_end_store(bool special)
|
||||
reference->ref_level >= return_values->upd_level &&
|
||||
!reference->ref_master)
|
||||
{
|
||||
change = MSC_reference(&return_values->upd_references);
|
||||
ref* change = MSC_reference(&return_values->upd_references);
|
||||
change->ref_context = return_values->upd_update;
|
||||
change->ref_field = reference->ref_field;
|
||||
change->ref_source = reference;
|
||||
change->ref_flags = reference->ref_flags;
|
||||
|
||||
item = MSC_node(nod_assignment, 2);
|
||||
gpre_nod* item = MSC_node(nod_assignment, 2);
|
||||
item->nod_arg[0] = MSC_unary(nod_field, (GPRE_NOD) change);
|
||||
item->nod_arg[1] = MSC_unary(nod_value, (GPRE_NOD) change);
|
||||
MSC_push((GPRE_NOD) item, &stack);
|
||||
@ -1903,7 +1894,9 @@ static act* par_end_store(bool special)
|
||||
while (stack)
|
||||
*--ptr = (GPRE_NOD) MSC_pop(&stack);
|
||||
}
|
||||
if ((context = request->req_contexts))
|
||||
|
||||
gpre_ctx* context = request->req_contexts;
|
||||
if (context)
|
||||
HSH_remove(context->ctx_symbol);
|
||||
|
||||
act* action;
|
||||
@ -2107,8 +2100,8 @@ static act* par_left_brace()
|
||||
if (brace_count++ > 0)
|
||||
return NULL;
|
||||
|
||||
act* action;
|
||||
gpreGlob.cur_routine = action = MSC_action(0, ACT_routine);
|
||||
act* action = MSC_action(0, ACT_routine);
|
||||
gpreGlob.cur_routine = action;
|
||||
action->act_flags |= ACT_mark;
|
||||
|
||||
return action;
|
||||
@ -2378,11 +2371,9 @@ static act* par_ready()
|
||||
{
|
||||
gpre_req* request;
|
||||
gpre_sym* symbol;
|
||||
rdy* ready;
|
||||
DBB db;
|
||||
bool need_handle = false;
|
||||
USHORT default_buffers = 0;
|
||||
USHORT buffers;
|
||||
|
||||
act* action = MSC_action(0, ACT_ready);
|
||||
|
||||
@ -2405,7 +2396,7 @@ static act* par_ready()
|
||||
continue;
|
||||
}
|
||||
|
||||
ready = (rdy*) MSC_alloc(RDY_LEN);
|
||||
rdy* ready = (rdy*) MSC_alloc(RDY_LEN);
|
||||
ready->rdy_next = (rdy*) action->act_object;
|
||||
action->act_object = (REF) ready;
|
||||
|
||||
@ -2432,7 +2423,7 @@ static act* par_ready()
|
||||
|
||||
// pick up the possible parameters, in any order
|
||||
|
||||
buffers = 0;
|
||||
USHORT buffers = 0;
|
||||
db = ready->rdy_database;
|
||||
for (;;) {
|
||||
if (MSC_match(KW_CACHE)) {
|
||||
@ -2486,7 +2477,7 @@ static act* par_ready()
|
||||
|
||||
if (action->act_object) {
|
||||
if (default_buffers)
|
||||
for (ready = (rdy*) action->act_object; ready;
|
||||
for (rdy* ready = (rdy*) action->act_object; ready;
|
||||
ready = ready->rdy_next)
|
||||
{
|
||||
if (!ready->rdy_request)
|
||||
@ -2499,7 +2490,7 @@ static act* par_ready()
|
||||
|
||||
for (db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
if (db->dbb_runtime || !(db->dbb_flags & DBB_sqlca)) {
|
||||
ready = (rdy*) MSC_alloc(RDY_LEN);
|
||||
rdy* ready = (rdy*) MSC_alloc(RDY_LEN);
|
||||
ready->rdy_next = (rdy*) action->act_object;
|
||||
action->act_object = (REF) ready;
|
||||
ready->rdy_database = db;
|
||||
@ -2508,7 +2499,7 @@ static act* par_ready()
|
||||
if (!action->act_object)
|
||||
PAR_error("no database available to READY");
|
||||
else
|
||||
for (ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) {
|
||||
for (rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) {
|
||||
request = ready->rdy_request;
|
||||
if (default_buffers && !ready->rdy_request)
|
||||
request = PAR_set_up_dpb_info(ready, action, default_buffers);
|
||||
@ -2552,7 +2543,6 @@ static act* par_returning_values()
|
||||
{
|
||||
|
||||
REF reference;
|
||||
GPRE_NOD assignments;
|
||||
|
||||
if (!cur_store)
|
||||
PAR_error("STORE must precede RETURNING_VALUES");
|
||||
@ -2572,11 +2562,13 @@ static act* par_returning_values()
|
||||
count++;
|
||||
}
|
||||
|
||||
request->req_node = assignments = MSC_node(nod_list, (SSHORT) count);
|
||||
GPRE_NOD assignments = MSC_node(nod_list, (SSHORT) count);
|
||||
request->req_node = assignments;
|
||||
count = 0;
|
||||
|
||||
for (reference = request->req_references; reference;
|
||||
reference = reference->ref_next) {
|
||||
reference = reference->ref_next)
|
||||
{
|
||||
REF save_ref = MSC_reference(&begin_action->act_object);
|
||||
save_ref->ref_context = reference->ref_context;
|
||||
save_ref->ref_field = reference->ref_field;
|
||||
|
@ -24,7 +24,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: pas.cpp,v 1.39 2004-05-24 17:13:37 brodsom Exp $
|
||||
// $Id: pas.cpp,v 1.40 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -2723,7 +2723,7 @@ static void gen_request( const gpre_req* request, int column)
|
||||
reference->ref_sdl_ident, PACKED_ARRAY,
|
||||
reference->ref_sdl_length, OPEN_BRACKET);
|
||||
if (gpreGlob.sw_raw)
|
||||
gen_raw(reinterpret_cast<UCHAR*>(reference->ref_sdl), reference->ref_sdl_length,
|
||||
gen_raw(reference->ref_sdl, reference->ref_sdl_length,
|
||||
column);
|
||||
else if (PRETTY_print_sdl(reference->ref_sdl, gen_blr, 0, 1))
|
||||
CPR_error("internal error during SDL generation");
|
||||
|
@ -25,7 +25,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: pretty.cpp,v 1.26 2004-05-23 23:24:42 brodsom Exp $
|
||||
// $Id: pretty.cpp,v 1.27 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -115,12 +115,6 @@ int PRETTY_print_cdb( UCHAR* blr,
|
||||
ctl ctl_buffer;
|
||||
ctl* control = &ctl_buffer;
|
||||
SCHAR temp[32];
|
||||
SSHORT parameter;
|
||||
SSHORT level = 0;
|
||||
SSHORT length;
|
||||
SSHORT i;
|
||||
SSHORT offset = 0;
|
||||
|
||||
|
||||
if (!routine) {
|
||||
routine = gds__default_printer;
|
||||
@ -133,19 +127,24 @@ int PRETTY_print_cdb( UCHAR* blr,
|
||||
control->ctl_ptr = control->ctl_buffer;
|
||||
control->ctl_language = language;
|
||||
|
||||
SSHORT level = 0;
|
||||
indent(control, level);
|
||||
i = BLR_BYTE;
|
||||
const SSHORT i = BLR_BYTE;
|
||||
if (*control->ctl_blr)
|
||||
sprintf(temp, "gds__dpb_version%d, ", i);
|
||||
else
|
||||
sprintf(temp, "gds__dpb_version%d", i);
|
||||
blr_format(control, temp);
|
||||
|
||||
SSHORT offset = 0;
|
||||
print_line(control, offset);
|
||||
|
||||
SSHORT parameter;
|
||||
while (parameter = BLR_BYTE) {
|
||||
const char *p;
|
||||
const char* p;
|
||||
if (parameter > FB_NELEM(cdb_table) ||
|
||||
!(p = cdb_table[parameter])) {
|
||||
!(p = cdb_table[parameter]))
|
||||
{
|
||||
return error(control, 0,
|
||||
"*** cdb parameter %d is undefined ***\n",
|
||||
parameter);
|
||||
@ -153,7 +152,8 @@ int PRETTY_print_cdb( UCHAR* blr,
|
||||
indent(control, level);
|
||||
blr_format(control, p);
|
||||
PUT_BYTE(',');
|
||||
if (length = print_byte(control, offset)) {
|
||||
SSHORT length = print_byte(control, offset);
|
||||
if (length) {
|
||||
do {
|
||||
print_char(control, offset);
|
||||
} while (--length);
|
||||
@ -177,9 +177,6 @@ int PRETTY_print_dyn(
|
||||
{
|
||||
ctl ctl_buffer;
|
||||
ctl* control = &ctl_buffer;
|
||||
SSHORT offset = 0;
|
||||
SSHORT version = 0;
|
||||
SSHORT level = 0;
|
||||
|
||||
if (!routine) {
|
||||
routine = gds__default_printer;
|
||||
@ -192,8 +189,9 @@ int PRETTY_print_dyn(
|
||||
control->ctl_ptr = control->ctl_buffer;
|
||||
control->ctl_language = language;
|
||||
|
||||
version = BLR_BYTE;
|
||||
const SSHORT version = BLR_BYTE;
|
||||
|
||||
SSHORT offset = 0;
|
||||
if (version != isc_dyn_version_1)
|
||||
return error(control, offset,
|
||||
"*** dyn version %d is not supported ***\n",
|
||||
@ -201,7 +199,7 @@ int PRETTY_print_dyn(
|
||||
|
||||
blr_format(control, "gds__dyn_version_1, ");
|
||||
print_line(control, offset);
|
||||
level++;
|
||||
SSHORT level = 1;
|
||||
PRINT_DYN_VERB;
|
||||
|
||||
if (BLR_BYTE != isc_dyn_eoc)
|
||||
@ -227,9 +225,6 @@ PRETTY_print_sdl(UCHAR* blr,
|
||||
{
|
||||
ctl ctl_buffer;
|
||||
ctl* control = &ctl_buffer;
|
||||
SSHORT offset = 0;
|
||||
SSHORT version;
|
||||
SSHORT level = 0;
|
||||
|
||||
if (!routine) {
|
||||
routine = gds__default_printer;
|
||||
@ -242,8 +237,9 @@ PRETTY_print_sdl(UCHAR* blr,
|
||||
control->ctl_ptr = control->ctl_buffer;
|
||||
control->ctl_language = language;
|
||||
|
||||
version = BLR_BYTE;
|
||||
const SSHORT version = BLR_BYTE;
|
||||
|
||||
SSHORT offset = 0;
|
||||
if (version != isc_sdl_version1)
|
||||
return error(control, offset,
|
||||
"*** sdl version %d is not supported ***\n",
|
||||
@ -251,7 +247,7 @@ PRETTY_print_sdl(UCHAR* blr,
|
||||
|
||||
blr_format(control, "gds__sdl_version1, ");
|
||||
print_line(control, offset);
|
||||
level++;
|
||||
SSHORT level = 1;
|
||||
|
||||
while (NEXT_BYTE != isc_sdl_eoc)
|
||||
PRINT_SDL_VERB;
|
||||
@ -323,16 +319,10 @@ static int indent( CTL control, SSHORT level)
|
||||
static int print_blr_dtype(CTL control,
|
||||
bool print_object)
|
||||
{
|
||||
unsigned short dtype;
|
||||
SCHAR *string;
|
||||
const char* string;
|
||||
SSHORT length;
|
||||
// TMN: FIX FIX Note that offset is not initialized to anything useful
|
||||
// for e.g. print_word(control, (SSHORT)offset). I assume it's better to initialize it to zero
|
||||
// than letting it be random.
|
||||
//
|
||||
SSHORT offset = 0;
|
||||
|
||||
dtype = BLR_BYTE;
|
||||
const USHORT dtype = BLR_BYTE;
|
||||
|
||||
// Special case blob (261) to keep down the size of the
|
||||
// jump table
|
||||
@ -427,6 +417,11 @@ static int print_blr_dtype(CTL control,
|
||||
|
||||
if (!print_object)
|
||||
return length;
|
||||
|
||||
// TMN: FIX FIX Note that offset is not initialized to anything useful
|
||||
// for e.g. print_word(control, (SSHORT)offset). I assume it's better to initialize it to zero
|
||||
// than letting it be random.
|
||||
SSHORT offset = 0;
|
||||
|
||||
switch (dtype) {
|
||||
case blr_text:
|
||||
@ -480,7 +475,7 @@ static int print_blr_dtype(CTL control,
|
||||
|
||||
static void print_blr_line(void* arg, SSHORT offset, const char* line)
|
||||
{
|
||||
CTL control = reinterpret_cast<CTL>(arg);
|
||||
CTL control = static_cast<CTL>(arg);
|
||||
bool comma = false;
|
||||
char c;
|
||||
|
||||
@ -508,9 +503,7 @@ static void print_blr_line(void* arg, SSHORT offset, const char* line)
|
||||
|
||||
static int print_byte( CTL control, SSHORT offset)
|
||||
{
|
||||
UCHAR v;
|
||||
|
||||
v = BLR_BYTE;
|
||||
const UCHAR v = BLR_BYTE;
|
||||
sprintf(control->ctl_ptr, (control->ctl_language) ? "chr(%d), " : "%d, ",
|
||||
v);
|
||||
ADVANCE_PTR(control->ctl_ptr);
|
||||
@ -526,11 +519,8 @@ static int print_byte( CTL control, SSHORT offset)
|
||||
|
||||
static int print_char( CTL control, SSHORT offset)
|
||||
{
|
||||
UCHAR c;
|
||||
SSHORT printable;
|
||||
|
||||
c = BLR_BYTE;
|
||||
printable = (c >= 'a' && c <= 'z') ||
|
||||
const UCHAR c = BLR_BYTE;
|
||||
const bool printable = (c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9' || c == '$' || c == '_');
|
||||
|
||||
@ -879,9 +869,7 @@ static int print_sdl_verb( CTL control, SSHORT level)
|
||||
|
||||
static int print_string( CTL control, SSHORT offset)
|
||||
{
|
||||
SSHORT n;
|
||||
|
||||
n = print_byte(control, offset);
|
||||
SSHORT n = print_byte(control, offset);
|
||||
while (--n >= 0)
|
||||
print_char(control, offset);
|
||||
|
||||
@ -897,10 +885,8 @@ static int print_string( CTL control, SSHORT offset)
|
||||
|
||||
static int print_word( CTL control, SSHORT offset)
|
||||
{
|
||||
UCHAR v1, v2;
|
||||
|
||||
v1 = BLR_BYTE;
|
||||
v2 = BLR_BYTE;
|
||||
const UCHAR v1 = BLR_BYTE;
|
||||
const UCHAR v2 = BLR_BYTE;
|
||||
sprintf(control->ctl_ptr,
|
||||
(control->ctl_language) ? "chr(%d),chr(%d), " : "%d,%d, ", v1,
|
||||
v2);
|
||||
@ -908,3 +894,4 @@ static int print_word( CTL control, SSHORT offset)
|
||||
|
||||
return (v2 << 8) | v1;
|
||||
}
|
||||
|
||||
|
267
src/gpre/sqe.cpp
267
src/gpre/sqe.cpp
@ -37,7 +37,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: sqe.cpp,v 1.32 2004-05-29 04:54:20 robocop Exp $
|
||||
// $Id: sqe.cpp,v 1.33 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
#include "firebird.h"
|
||||
#include <stdio.h>
|
||||
@ -82,7 +82,7 @@ static void pair(GPRE_NOD, GPRE_NOD);
|
||||
static gpre_ctx* par_alias_list(gpre_req*, GPRE_NOD);
|
||||
static gpre_ctx* par_alias(gpre_req*, TEXT *);
|
||||
static GPRE_NOD par_and(gpre_req*, USHORT *);
|
||||
static gpre_rel* par_base_table(gpre_req*, gpre_rel*, TEXT *);
|
||||
static gpre_rel* par_base_table(gpre_req*, const gpre_rel*, const TEXT*);
|
||||
static GPRE_NOD par_collate(gpre_req*, GPRE_NOD);
|
||||
static GPRE_NOD par_in(gpre_req*, GPRE_NOD);
|
||||
static gpre_ctx* par_joined_relation(gpre_req*, gpre_ctx*);
|
||||
@ -113,7 +113,6 @@ static gpre_ctx* resolve_asterisk(TOK, gpre_rse*);
|
||||
static void set_ref(GPRE_NOD, gpre_fld*);
|
||||
static char* upcase_string(const char*);
|
||||
static bool validate_references(GPRE_NOD, GPRE_NOD);
|
||||
static void dialect1_bad_type(USHORT);
|
||||
|
||||
|
||||
|
||||
@ -210,13 +209,9 @@ GPRE_NOD SQE_boolean( gpre_req* request, USHORT * paren_count)
|
||||
|
||||
gpre_ctx* SQE_context(gpre_req* request)
|
||||
{
|
||||
gpre_sym* symbol;
|
||||
gpre_prc* procedure;
|
||||
USHORT local_count;
|
||||
SCHAR r_name[NAME_SIZE + 1], db_name[NAME_SIZE + 1],
|
||||
owner_name[NAME_SIZE + 1];
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
gpre_fld* field;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
@ -227,14 +222,16 @@ gpre_ctx* SQE_context(gpre_req* request)
|
||||
SQL_relation(request, r_name, db_name, owner_name, false)))
|
||||
{
|
||||
// check for a procedure
|
||||
if (procedure = context->ctx_procedure =
|
||||
SQL_procedure(request, r_name, db_name, owner_name, false)) {
|
||||
gpre_prc* procedure = context->ctx_procedure =
|
||||
SQL_procedure(request, r_name, db_name, owner_name, false);
|
||||
if (procedure)
|
||||
{
|
||||
if (procedure->prc_inputs) {
|
||||
if (!MSC_match(KW_LEFT_PAREN))
|
||||
CPR_s_error("( <procedure input parameters> )");
|
||||
// parse input references
|
||||
context->ctx_prc_inputs = SQE_list(SQE_value, request, false);
|
||||
local_count = 1;
|
||||
USHORT local_count = 1;
|
||||
par_terminating_parens(&local_count, &local_count);
|
||||
if (procedure->prc_in_count !=
|
||||
context->ctx_prc_inputs->nod_count)
|
||||
@ -242,7 +239,7 @@ gpre_ctx* SQE_context(gpre_req* request)
|
||||
PAR_error("count of input values doesn't match count of parameters");
|
||||
}
|
||||
gpre_nod** input = context->ctx_prc_inputs->nod_arg;
|
||||
for (field = procedure->prc_inputs; field;
|
||||
for (gpre_fld* field = procedure->prc_inputs; field;
|
||||
input++, field = field->fld_next)
|
||||
{
|
||||
SQE_post_field(*input, field);
|
||||
@ -263,7 +260,8 @@ gpre_ctx* SQE_context(gpre_req* request)
|
||||
// It may, however, be an "end of line" token. If so, trade it in on the
|
||||
// next "real" token.
|
||||
|
||||
if ((symbol = gpreGlob.token_global.tok_symbol) && symbol->sym_type == SYM_keyword) {
|
||||
gpre_sym* symbol = gpreGlob.token_global.tok_symbol;
|
||||
if (symbol && symbol->sym_type == SYM_keyword) {
|
||||
if (!gpreGlob.token_global.tok_length)
|
||||
CPR_token();
|
||||
return context;
|
||||
@ -289,7 +287,7 @@ gpre_ctx* SQE_context(gpre_req* request)
|
||||
}
|
||||
|
||||
if (conflict) {
|
||||
SCHAR *error_type;
|
||||
const char* error_type;
|
||||
if (symbol->sym_type == SYM_relation)
|
||||
error_type = "table";
|
||||
else if (symbol->sym_type == SYM_procedure)
|
||||
@ -327,24 +325,17 @@ gpre_ctx* SQE_context(gpre_req* request)
|
||||
GPRE_NOD SQE_field(gpre_req* request,
|
||||
bool aster_ok)
|
||||
{
|
||||
GPRE_NOD node, tail;
|
||||
gpre_sym* temp_symbol;
|
||||
GPRE_NOD node;
|
||||
gpre_ctx* context;
|
||||
gpre_rel* relation;
|
||||
gpre_prc* procedure;
|
||||
TOK f_token;
|
||||
int count = 0;
|
||||
gpre_req* slice_req;
|
||||
slc* slice;
|
||||
act* action;
|
||||
TEXT s[ERROR_LENGTH];
|
||||
tok hold_token;
|
||||
slc::slc_repeat * tail_ptr;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
gpre_lls* upper_dim = NULL;
|
||||
gpre_lls* lower_dim = NULL;
|
||||
tok hold_token;
|
||||
hold_token.tok_type = tok_t(0);
|
||||
|
||||
if (aster_ok && MSC_match(KW_ASTERISK)) {
|
||||
@ -359,6 +350,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
// For domains we can't be resolving tokens to field names
|
||||
// in the CHECK constraint.
|
||||
|
||||
act* action;
|
||||
if (request &&
|
||||
request->req_type == REQ_ddl &&
|
||||
(action = request->req_actions) &&
|
||||
@ -388,7 +380,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
if (!request || !request->req_contexts || request->req_in_select_list) {
|
||||
node = MSC_node(nod_defered, 3);
|
||||
node->nod_count = 0;
|
||||
f_token = (TOK) MSC_alloc(TOK_LEN);
|
||||
TOK f_token = (TOK) MSC_alloc(TOK_LEN);
|
||||
node->nod_arg[0] = (GPRE_NOD) f_token;
|
||||
f_token->tok_length = gpreGlob.token_global.tok_length;
|
||||
SQL_resolve_identifier("<identifier>", f_token->tok_string);
|
||||
@ -417,7 +409,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
slice_req = MSC_request(REQ_slice);
|
||||
do {
|
||||
count++;
|
||||
tail = par_subscript(slice_req);
|
||||
gpre_nod* tail = par_subscript(slice_req);
|
||||
MSC_push(tail, &lower_dim);
|
||||
if (MSC_match(KW_COLON)) {
|
||||
// if (!MSC_match (KW_DOT))
|
||||
@ -431,8 +423,9 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
|
||||
if (!MSC_match(KW_R_BRCKET))
|
||||
CPR_s_error("<right bracket>");
|
||||
slice_req->req_slice = slice = (slc*) MSC_alloc(SLC_LEN(count));
|
||||
tail_ptr = &slice->slc_rpt[count];
|
||||
slc* slice = (slc*) MSC_alloc(SLC_LEN(count));
|
||||
slice_req->req_slice = slice;
|
||||
slc::slc_repeat* tail_ptr = &slice->slc_rpt[count];
|
||||
slice->slc_dimensions = count;
|
||||
slice->slc_parent_request = request;
|
||||
while (lower_dim) {
|
||||
@ -445,7 +438,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
/* added this to assign the correct nod_count
|
||||
The nod type is converted to nod_field in SQE_resolve()
|
||||
The nod_count is check to confirm if the array slice
|
||||
has been initialized in cmd.c
|
||||
has been initialized in cmd.cpp
|
||||
*/
|
||||
node->nod_count = 3;
|
||||
}
|
||||
@ -469,7 +462,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
is not in the request, resulting in a bogus error */
|
||||
|
||||
if (symbol->sym_type != SYM_field) {
|
||||
for (temp_symbol = symbol; temp_symbol;
|
||||
for (gpre_sym* temp_symbol = symbol; temp_symbol;
|
||||
temp_symbol = temp_symbol->sym_homonym)
|
||||
{
|
||||
if (temp_symbol->sym_type == SYM_context) {
|
||||
@ -500,7 +493,8 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
SQL_resolve_identifier("<Column Name>", s);
|
||||
if (!
|
||||
(reference->ref_field =
|
||||
MET_context_field(context, gpreGlob.token_global.tok_string))) {
|
||||
MET_context_field(context, gpreGlob.token_global.tok_string)))
|
||||
{
|
||||
sprintf(s, "column \"%s\" not in context",
|
||||
gpreGlob.token_global.tok_string);
|
||||
PAR_error(s);
|
||||
@ -511,7 +505,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
(dtype_sql_time == field_dtype) ||
|
||||
(dtype_int64 == field_dtype))
|
||||
{
|
||||
dialect1_bad_type(field_dtype);
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
reference->ref_context = context;
|
||||
@ -519,7 +513,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
return node;
|
||||
}
|
||||
else if (symbol->sym_type == SYM_relation) {
|
||||
relation = (gpre_rel*) symbol->sym_object;
|
||||
const gpre_rel* relation = (gpre_rel*) symbol->sym_object;
|
||||
if (relation->rel_database != request->req_database)
|
||||
PAR_error("table not in appropriate database");
|
||||
|
||||
@ -555,7 +549,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
(dtype_sql_time == field_dtype) ||
|
||||
(dtype_int64 == field_dtype))
|
||||
{
|
||||
dialect1_bad_type(field_dtype);
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
reference->ref_context = context;
|
||||
@ -576,7 +570,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
}
|
||||
}
|
||||
else if (symbol->sym_type == SYM_procedure) {
|
||||
procedure = (gpre_prc*) symbol->sym_object;
|
||||
const gpre_prc* procedure = (gpre_prc*) symbol->sym_object;
|
||||
if (procedure->prc_database != request->req_database)
|
||||
PAR_error("procedure not in appropriate database");
|
||||
CPR_token();
|
||||
@ -596,7 +590,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
(dtype_sql_time == field_dtype) ||
|
||||
(dtype_int64 == field_dtype))
|
||||
{
|
||||
dialect1_bad_type(field_dtype);
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
reference->ref_context = context;
|
||||
@ -632,7 +626,7 @@ GPRE_NOD SQE_field(gpre_req* request,
|
||||
(dtype_sql_time == field_dtype) ||
|
||||
(dtype_int64 == field_dtype))
|
||||
{
|
||||
dialect1_bad_type(field_dtype);
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
reference->ref_context = context;
|
||||
@ -704,9 +698,7 @@ REF SQE_parameter(gpre_req* request,
|
||||
bool aster_ok)
|
||||
{
|
||||
REF reference;
|
||||
gpre_sym* symbol;
|
||||
SCHAR *string, *s;
|
||||
int sign;
|
||||
SCHAR* string;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
@ -719,6 +711,7 @@ REF SQE_parameter(gpre_req* request,
|
||||
CPR_token();
|
||||
return reference;
|
||||
}
|
||||
|
||||
if ((isQuoted(gpreGlob.token_global.tok_type) && gpreGlob.sw_sql_dialect == 1) ||
|
||||
gpreGlob.token_global.tok_type == tok_sglquoted)
|
||||
{
|
||||
@ -738,8 +731,10 @@ REF SQE_parameter(gpre_req* request,
|
||||
CPR_token();
|
||||
return reference;
|
||||
}
|
||||
|
||||
if (gpreGlob.token_global.tok_keyword == KW_PLUS || gpreGlob.token_global.tok_keyword == KW_MINUS)
|
||||
{
|
||||
int sign;
|
||||
if (gpreGlob.token_global.tok_keyword == KW_MINUS)
|
||||
sign = 1;
|
||||
else
|
||||
@ -748,7 +743,7 @@ REF SQE_parameter(gpre_req* request,
|
||||
if (gpreGlob.token_global.tok_type != tok_number)
|
||||
CPR_s_error("<host variable> or <constant>");
|
||||
reference = (REF) MSC_alloc(REF_LEN);
|
||||
s = string = (TEXT *) MSC_alloc(gpreGlob.token_global.tok_length + 1 + sign);
|
||||
char* s = string = (TEXT *) MSC_alloc(gpreGlob.token_global.tok_length + 1 + sign);
|
||||
if (sign)
|
||||
*s++ = '-';
|
||||
MSC_copy(gpreGlob.token_global.tok_string, gpreGlob.token_global.tok_length, s);
|
||||
@ -766,11 +761,14 @@ REF SQE_parameter(gpre_req* request,
|
||||
|
||||
reference = (REF) MSC_alloc(REF_LEN);
|
||||
|
||||
for (symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym)
|
||||
for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol;
|
||||
symbol = symbol->sym_homonym)
|
||||
{
|
||||
if (symbol->sym_type == SYM_variable) {
|
||||
reference->ref_field = (gpre_fld*) symbol->sym_object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reference->ref_value = PAR_native_value(false, false);
|
||||
|
||||
@ -792,9 +790,6 @@ REF SQE_parameter(gpre_req* request,
|
||||
|
||||
void SQE_post_field( GPRE_NOD input, gpre_fld* field)
|
||||
{
|
||||
GPRE_NOD node;
|
||||
MEL element;
|
||||
|
||||
if (!input || !field)
|
||||
return;
|
||||
|
||||
@ -821,10 +816,12 @@ void SQE_post_field( GPRE_NOD input, gpre_fld* field)
|
||||
return;
|
||||
|
||||
case nod_map_ref:
|
||||
element = (MEL) input->nod_arg[0];
|
||||
node = element->mel_expr;
|
||||
SQE_post_field(node, field);
|
||||
return;
|
||||
{
|
||||
mel* element = (MEL) input->nod_arg[0];
|
||||
gpre_nod* node = element->mel_expr;
|
||||
SQE_post_field(node, field);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
@ -848,7 +845,8 @@ void SQE_post_field( GPRE_NOD input, gpre_fld* field)
|
||||
// isn't a context, well, there isn't a context.
|
||||
//
|
||||
|
||||
REF SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context, GPRE_NOD node)
|
||||
REF SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context,
|
||||
GPRE_NOD node)
|
||||
{
|
||||
REF reference;
|
||||
|
||||
@ -915,10 +913,6 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
gpre_req* request,
|
||||
gpre_rse* selection)
|
||||
{
|
||||
REF reference;
|
||||
gpre_ctx* context;
|
||||
gpre_fld* field;
|
||||
SSHORT i;
|
||||
bool result = false;
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
act* slice_action = 0;
|
||||
@ -951,7 +945,7 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
if (node->nod_arg[0]) {
|
||||
SQE_resolve(node->nod_arg[0], request, selection);
|
||||
gpre_nod* node_arg = node->nod_arg[0];
|
||||
reference = (REF) node_arg->nod_arg[0];
|
||||
const ref* reference = (REF) node_arg->nod_arg[0];
|
||||
if (node_arg->nod_type == nod_field && reference &&
|
||||
reference->ref_field && reference->ref_field->fld_array_info)
|
||||
{
|
||||
@ -992,8 +986,9 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
if (q_token)
|
||||
q_token->tok_symbol = HSH_lookup(q_token->tok_string);
|
||||
|
||||
field = NULL;
|
||||
gpre_fld* field = NULL;
|
||||
|
||||
gpre_ctx* context;
|
||||
if (request)
|
||||
for (context = request->req_contexts; context;
|
||||
context = context->ctx_next)
|
||||
@ -1002,10 +997,9 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
&& (field = resolve(node, context, 0, &slice_action))) break;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < selection->rse_count; i++) {
|
||||
if (field =
|
||||
resolve(node, selection->rse_context[i], &context,
|
||||
&slice_action)) break;
|
||||
for (SSHORT i = 0; i < selection->rse_count; i++) {
|
||||
if (field = resolve(node, selection->rse_context[i], &context, &slice_action))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!field) {
|
||||
@ -1025,10 +1019,10 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
(dtype_sql_time == field->fld_dtype) ||
|
||||
(dtype_int64 == field->fld_dtype)))
|
||||
{
|
||||
dialect1_bad_type(field->fld_dtype);
|
||||
SQL_dialect1_bad_type(field->fld_dtype);
|
||||
}
|
||||
|
||||
reference = (REF) MSC_alloc(REF_LEN);
|
||||
ref* reference = (REF) MSC_alloc(REF_LEN);
|
||||
reference->ref_field = field;
|
||||
reference->ref_context = context;
|
||||
reference->ref_slice = (slc*) slice_action;
|
||||
@ -1053,10 +1047,6 @@ bool SQE_resolve(GPRE_NOD node,
|
||||
gpre_rse* SQE_select(gpre_req* request,
|
||||
bool view_flag)
|
||||
{
|
||||
gpre_rse* select = NULL;
|
||||
gpre_rse* rse1 = NULL;
|
||||
gpre_rse* rse2 = NULL;
|
||||
GPRE_NOD node;
|
||||
gpre_lls* context_stack = NULL;
|
||||
gpre_ctx* context = 0;
|
||||
bool have_union = false;
|
||||
@ -1068,27 +1058,30 @@ gpre_rse* SQE_select(gpre_req* request,
|
||||
// Get components of union. Most likely there isn't one, so this is
|
||||
// probably wasted work.
|
||||
|
||||
gpre_rse* select = NULL;
|
||||
gpre_rse* rse1 = NULL;
|
||||
select = rse1 = par_select(request, NULL);
|
||||
|
||||
// "Look for ... the UNION label ... "
|
||||
while (MSC_match(KW_UNION)) {
|
||||
|
||||
have_union = true;
|
||||
bool union_all = MSC_match(KW_ALL);
|
||||
const bool union_all = MSC_match(KW_ALL);
|
||||
if (!MSC_match(KW_SELECT))
|
||||
CPR_s_error("SELECT");
|
||||
|
||||
MSC_push((GPRE_NOD) request->req_contexts, &context_stack);
|
||||
request->req_contexts = NULL;
|
||||
request->req_map = NULL;
|
||||
rse2 = par_select(request, rse1);
|
||||
gpre_rse* rse2 = par_select(request, rse1);
|
||||
|
||||
/* We've got a bona fide union. Make a union node to hold sub-rse
|
||||
and then a new rse to point to it. */
|
||||
|
||||
select = (gpre_rse*) MSC_alloc(RSE_LEN(1));
|
||||
select->rse_context[0] = context = MSC_context(request);
|
||||
select->rse_union = node = MSC_node(nod_union, 2);
|
||||
gpre_nod* node = MSC_node(nod_union, 2);
|
||||
select->rse_union = node;
|
||||
node->nod_arg[0] = (GPRE_NOD) rse1;
|
||||
node->nod_arg[1] = (GPRE_NOD) rse2;
|
||||
|
||||
@ -1222,12 +1215,14 @@ GPRE_NOD SQE_variable(gpre_req* request,
|
||||
|
||||
ref* reference = (REF) MSC_alloc(REF_LEN);
|
||||
|
||||
gpre_sym* symbol;
|
||||
for (symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym)
|
||||
for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol;
|
||||
symbol = symbol->sym_homonym)
|
||||
{
|
||||
if (symbol->sym_type == SYM_variable) {
|
||||
reference->ref_field = (gpre_fld*) symbol->sym_object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reference->ref_value = PAR_native_value(false, false);
|
||||
|
||||
@ -1378,7 +1373,6 @@ static GPRE_NOD explode_asterisk_all(GPRE_NOD fields,
|
||||
|
||||
static gpre_fld* get_ref( GPRE_NOD expr)
|
||||
{
|
||||
ref* reference;
|
||||
gpre_fld* field;
|
||||
|
||||
assert_IS_NOD(expr);
|
||||
@ -1391,6 +1385,8 @@ static gpre_fld* get_ref( GPRE_NOD expr)
|
||||
return field;
|
||||
}
|
||||
|
||||
ref* reference;
|
||||
|
||||
switch (expr->nod_type) {
|
||||
case nod_field:
|
||||
reference = (ref*) expr->nod_arg[0];
|
||||
@ -1826,7 +1822,8 @@ static gpre_ctx* par_alias( gpre_req* request, TEXT * alias)
|
||||
// has a base table which matches the passed alias.
|
||||
//
|
||||
|
||||
static gpre_rel* par_base_table( gpre_req* request, gpre_rel* relation, TEXT * alias)
|
||||
static gpre_rel* par_base_table( gpre_req* request, const gpre_rel* relation,
|
||||
const TEXT* alias)
|
||||
{
|
||||
|
||||
assert_IS_REQ(request);
|
||||
@ -1899,8 +1896,7 @@ static GPRE_NOD par_collate( gpre_req* request, GPRE_NOD arg)
|
||||
|
||||
static GPRE_NOD par_in( gpre_req* request, GPRE_NOD value)
|
||||
{
|
||||
GPRE_NOD value2, node;
|
||||
REF ref1, ref2;
|
||||
GPRE_NOD node;
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
|
||||
assert_IS_REQ(request);
|
||||
@ -1915,11 +1911,11 @@ static GPRE_NOD par_in( gpre_req* request, GPRE_NOD value)
|
||||
else {
|
||||
node = NULL;
|
||||
while (true) {
|
||||
value2 = par_primitive_value(request, false, 0, NULL);
|
||||
gpre_nod* value2 = par_primitive_value(request, false, 0, NULL);
|
||||
if (value2->nod_type == nod_value) {
|
||||
ref2 = (REF) value2->nod_arg[0];
|
||||
ref* ref2 = (REF) value2->nod_arg[0];
|
||||
if (value->nod_type == nod_field) {
|
||||
ref1 = (REF) value->nod_arg[0];
|
||||
ref* ref1 = (REF) value->nod_arg[0];
|
||||
ref2->ref_field = ref1->ref_field;
|
||||
}
|
||||
else {
|
||||
@ -2080,9 +2076,7 @@ static GPRE_NOD par_multiply(gpre_req* request,
|
||||
|
||||
static GPRE_NOD par_not( gpre_req* request, USHORT * paren_count)
|
||||
{
|
||||
gpre_rse* selection;
|
||||
GPRE_NOD node, expr, field;
|
||||
scope saved_scope;
|
||||
GPRE_NOD node, field;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
@ -2096,6 +2090,7 @@ static GPRE_NOD par_not( gpre_req* request, USHORT * paren_count)
|
||||
else if (MSC_match(KW_SINGULAR))
|
||||
type = nod_unique;
|
||||
if (type == nod_any || type == nod_unique) {
|
||||
scope saved_scope;
|
||||
push_scope(request, &saved_scope);
|
||||
|
||||
EXP_left_paren(0);
|
||||
@ -2111,11 +2106,11 @@ static GPRE_NOD par_not( gpre_req* request, USHORT * paren_count)
|
||||
|
||||
node = MSC_node(type, 1);
|
||||
node->nod_count = 0;
|
||||
selection = par_rse(request, 0, false);
|
||||
gpre_rse* selection = par_rse(request, 0, false);
|
||||
node->nod_arg[0] = (GPRE_NOD) selection;
|
||||
if (field) {
|
||||
SQE_resolve(field, 0, selection);
|
||||
expr = MSC_unary(nod_missing, field);
|
||||
gpre_nod* expr = MSC_unary(nod_missing, field);
|
||||
selection->rse_boolean = merge(negate(expr), selection->rse_boolean);
|
||||
}
|
||||
EXP_rse_cleanup((gpre_rse*) node->nod_arg[0]);
|
||||
@ -2140,9 +2135,8 @@ static void par_order(gpre_req* request,
|
||||
bool union_f,
|
||||
bool view_flag)
|
||||
{
|
||||
GPRE_NOD sort, *ptr;
|
||||
GPRE_NOD sort;
|
||||
map* request_map;
|
||||
int count, direction;
|
||||
USHORT i;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
@ -2153,9 +2147,9 @@ static void par_order(gpre_req* request,
|
||||
if (MSC_match(KW_FOR)) {
|
||||
MSC_match(KW_UPDATE);
|
||||
MSC_match(KW_OF);
|
||||
do
|
||||
do {
|
||||
CPR_token();
|
||||
while (MSC_match(KW_COMMA));
|
||||
} while (MSC_match(KW_COMMA));
|
||||
}
|
||||
|
||||
if (!MSC_match(KW_ORDER))
|
||||
@ -2166,7 +2160,7 @@ static void par_order(gpre_req* request,
|
||||
MSC_match(KW_BY);
|
||||
gpre_lls* items = NULL;
|
||||
gpre_lls* directions = NULL;
|
||||
count = direction = 0;
|
||||
int count = 0, direction = 0;
|
||||
gpre_nod* values = select->rse_fields;
|
||||
|
||||
while (true) {
|
||||
@ -2200,7 +2194,7 @@ static void par_order(gpre_req* request,
|
||||
|
||||
select->rse_sort = sort = MSC_node(nod_sort, (SSHORT) (count * 2));
|
||||
sort->nod_count = count;
|
||||
ptr = sort->nod_arg + count * 2;
|
||||
gpre_nod** ptr = sort->nod_arg + count * 2;
|
||||
|
||||
while (items) {
|
||||
*--ptr = (GPRE_NOD) MSC_pop(&items);
|
||||
@ -2217,8 +2211,6 @@ static void par_order(gpre_req* request,
|
||||
|
||||
static GPRE_NOD par_plan( gpre_req* request)
|
||||
{
|
||||
GPRE_NOD plan_expression;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
// parse the join type
|
||||
@ -2235,7 +2227,7 @@ static GPRE_NOD par_plan( gpre_req* request)
|
||||
|
||||
// make up the plan expression node
|
||||
|
||||
plan_expression = MSC_node(nod_plan_expr, 2);
|
||||
gpre_nod* plan_expression = MSC_node(nod_plan_expr, 2);
|
||||
|
||||
if (nod_type != nod_join)
|
||||
plan_expression->nod_arg[0] = MSC_node(nod_type, 0);
|
||||
@ -2263,10 +2255,6 @@ static GPRE_NOD par_plan_item(gpre_req* request,
|
||||
USHORT * paren_count,
|
||||
bool * bool_flag)
|
||||
{
|
||||
gpre_lls* stack = NULL;
|
||||
int count;
|
||||
GPRE_NOD access_type, *ptr;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
// check for a plan expression
|
||||
@ -2281,6 +2269,8 @@ static GPRE_NOD par_plan_item(gpre_req* request,
|
||||
// aliases (more than one is used when there is
|
||||
// a need to differentiate base tables of a view)
|
||||
|
||||
int count;
|
||||
gpre_lls* stack = NULL;
|
||||
for (count = 0; gpreGlob.token_global.tok_type == tok_ident; count++) {
|
||||
if (gpreGlob.token_global.tok_keyword == KW_NATURAL ||
|
||||
gpreGlob.token_global.tok_keyword == KW_ORDER ||
|
||||
@ -2296,6 +2286,8 @@ static GPRE_NOD par_plan_item(gpre_req* request,
|
||||
if (!count)
|
||||
CPR_s_error("<table name> or <alias>");
|
||||
|
||||
gpre_nod** ptr;
|
||||
|
||||
gpre_nod* alias_list = MSC_node(nod_list, (SSHORT) count);
|
||||
for (ptr = &alias_list->nod_arg[count]; stack;)
|
||||
*--ptr = (GPRE_NOD) MSC_pop(&stack);
|
||||
@ -2306,6 +2298,7 @@ static GPRE_NOD par_plan_item(gpre_req* request,
|
||||
|
||||
// parse the access type
|
||||
|
||||
gpre_nod* access_type;
|
||||
if (gpreGlob.token_global.tok_keyword == KW_NATURAL) {
|
||||
access_type = MSC_node(nod_natural, 0);
|
||||
PAR_get_token();
|
||||
@ -2385,12 +2378,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
USHORT * paren_count,
|
||||
bool * bool_flag)
|
||||
{
|
||||
GPRE_NOD node_arg;
|
||||
REF reference;
|
||||
map* tmp_map;
|
||||
USHORT local_count;
|
||||
act* action;
|
||||
KWWORDS kw_word;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
|
||||
@ -2420,7 +2408,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
*/
|
||||
if (!request)
|
||||
PAR_error("VALUE cannot be used in this context");
|
||||
action = request->req_actions;
|
||||
const act* action = request->req_actions;
|
||||
if (request->req_type != REQ_ddl ||
|
||||
!action ||
|
||||
!(action->act_type == ACT_create_domain ||
|
||||
@ -2448,6 +2436,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
// ORDER clause. In this case, post only the complete expression, and not
|
||||
// the sub-expressions.
|
||||
|
||||
map* tmp_map = 0;
|
||||
for (const ops *op = stat_ops; (int) op->rel_kw != (int) KW_none; op++) {
|
||||
MSC_match(KW_ALL);
|
||||
if (MSC_match(op->rel_kw)) {
|
||||
@ -2476,7 +2465,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
else {
|
||||
node->nod_arg[0] = SQE_value(request, false, NULL, NULL);
|
||||
// Disallow arrays as arguments to aggregate functions
|
||||
node_arg = node->nod_arg[0];
|
||||
const gpre_nod* node_arg = node->nod_arg[0];
|
||||
if (node_arg && node_arg->nod_type == nod_array)
|
||||
PAR_error
|
||||
("Array columns not permitted in aggregate functions");
|
||||
@ -2522,7 +2511,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
PAR_error(":hostvar reference not supported in this context");
|
||||
return NULL;
|
||||
}
|
||||
reference = (REF) SQE_variable(request, false, NULL, NULL);
|
||||
ref* reference = (REF) SQE_variable(request, false, NULL, NULL);
|
||||
node = MSC_unary(nod_value, (GPRE_NOD) reference);
|
||||
reference->ref_next = request->req_values;
|
||||
request->req_values = reference;
|
||||
@ -2544,7 +2533,7 @@ static GPRE_NOD par_primitive_value(gpre_req* request,
|
||||
// anything that makes sense until now
|
||||
{
|
||||
// ** Begin date/time/timestamp support *
|
||||
kw_word = gpreGlob.token_global.tok_keyword;
|
||||
const KWWORDS kw_word = gpreGlob.token_global.tok_keyword;
|
||||
|
||||
if (MSC_match(KW_DATE) || MSC_match(KW_TIME) || MSC_match(KW_TIMESTAMP)) {
|
||||
gpreGlob.token_global.tok_keyword = kw_word;
|
||||
@ -2569,7 +2558,6 @@ static GPRE_NOD par_relational(gpre_req* request,
|
||||
USHORT * paren_count)
|
||||
{
|
||||
GPRE_NOD node;
|
||||
REF ref_value;
|
||||
bool negation = false;
|
||||
bool local_flag =true;
|
||||
|
||||
@ -2613,7 +2601,7 @@ static GPRE_NOD par_relational(gpre_req* request,
|
||||
gpre_nod* expr2 = SQE_value(request, false, NULL, NULL);
|
||||
node->nod_arg[2] = expr2;
|
||||
if (expr2->nod_type == nod_value) {
|
||||
ref_value = (REF) expr2->nod_arg[0];
|
||||
ref* ref_value = (REF) expr2->nod_arg[0];
|
||||
ref_value->ref_field = MET_make_field("like_escape_character",
|
||||
dtype_text, 2, false);
|
||||
}
|
||||
@ -2687,11 +2675,6 @@ static gpre_rse* par_rse(gpre_req* request,
|
||||
GPRE_NOD fields,
|
||||
bool distinct)
|
||||
{
|
||||
gpre_ctx* context;
|
||||
map* subselect_map;
|
||||
int i;
|
||||
int count = 0;
|
||||
int old_count;
|
||||
gpre_lls* stack = NULL;
|
||||
|
||||
assert_IS_REQ(request);
|
||||
@ -2702,6 +2685,8 @@ static gpre_rse* par_rse(gpre_req* request,
|
||||
if (!MSC_match(KW_FROM))
|
||||
CPR_s_error("FROM");
|
||||
|
||||
int count = 0;
|
||||
gpre_ctx* context;
|
||||
do {
|
||||
if (context = par_joined_relation(request, NULL)) {
|
||||
MSC_push((GPRE_NOD) context, &stack);
|
||||
@ -2726,12 +2711,12 @@ static gpre_rse* par_rse(gpre_req* request,
|
||||
|
||||
if (fields) {
|
||||
gpre_nod** ptr = fields->nod_arg;
|
||||
for (count = fields->nod_count, i = 0;
|
||||
i < count; i++)
|
||||
count = fields->nod_count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
gpre_nod* node = *(ptr + i);
|
||||
if (node->nod_type == nod_asterisk) {
|
||||
old_count = count;
|
||||
const int old_count = count;
|
||||
fields = explode_asterisk(fields, i, select);
|
||||
count = fields->nod_count;
|
||||
i += count - old_count;
|
||||
@ -2785,7 +2770,8 @@ static gpre_rse* par_rse(gpre_req* request,
|
||||
PAR_error
|
||||
("simple column reference not allowed in aggregate context");
|
||||
gpre_rse* sub_rse = select;
|
||||
sub_rse->rse_map = subselect_map = (map*) MSC_alloc(sizeof(map));
|
||||
map* subselect_map = (map*) MSC_alloc(sizeof(map));
|
||||
sub_rse->rse_map = subselect_map;
|
||||
if (select->rse_group_by)
|
||||
request->req_map = subselect_map;
|
||||
subselect_map->map_context = MSC_context(request);
|
||||
@ -2966,13 +2952,8 @@ static void par_terminating_parens(
|
||||
static GPRE_NOD par_udf( gpre_req* request)
|
||||
{
|
||||
GPRE_NOD node;
|
||||
udf* an_udf;
|
||||
udf* tmp_udf;
|
||||
USHORT local_count;
|
||||
gpre_fld* field;
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
DBB db;
|
||||
TEXT *gen_name;
|
||||
|
||||
if (!request)
|
||||
return NULL;
|
||||
@ -2983,6 +2964,8 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
// ** resolve only if an identifier *
|
||||
if ((isQuoted(gpreGlob.token_global.tok_type)) || gpreGlob.token_global.tok_type == tok_ident)
|
||||
SQL_resolve_identifier("<Udf Name>", s);
|
||||
|
||||
udf* an_udf;
|
||||
if (request->req_database)
|
||||
an_udf = MET_get_udf(request->req_database, gpreGlob.token_global.tok_string);
|
||||
else {
|
||||
@ -2990,8 +2973,10 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
for the existence of the udf */
|
||||
|
||||
an_udf = NULL;
|
||||
for (db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
if (tmp_udf = MET_get_udf(db, gpreGlob.token_global.tok_string))
|
||||
for (DBB db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
{
|
||||
udf* tmp_udf = MET_get_udf(db, gpreGlob.token_global.tok_string);
|
||||
if (tmp_udf)
|
||||
if (an_udf) {
|
||||
// udf was found in more than one database
|
||||
sprintf(s, "UDF %s is ambiguous", gpreGlob.token_global.tok_string);
|
||||
@ -3001,6 +2986,7 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
an_udf = tmp_udf;
|
||||
request->req_database = db;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (an_udf) {
|
||||
@ -3009,7 +2995,7 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
(dtype_sql_time == an_udf->udf_dtype) ||
|
||||
(dtype_int64 == an_udf->udf_dtype)))
|
||||
{
|
||||
dialect1_bad_type(an_udf->udf_dtype);
|
||||
SQL_dialect1_bad_type(an_udf->udf_dtype);
|
||||
}
|
||||
|
||||
node = MSC_node(nod_udf, 2);
|
||||
@ -3026,7 +3012,7 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
|
||||
// Match parameter types to the declared parameters
|
||||
gpre_nod** input = node->nod_arg[0]->nod_arg;
|
||||
for (field = an_udf->udf_inputs;
|
||||
for (gpre_fld* field = an_udf->udf_inputs;
|
||||
field;
|
||||
input++, field = field->fld_next)
|
||||
{
|
||||
@ -3047,7 +3033,7 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
|
||||
// Check for GEN_ID ()
|
||||
if (MSC_match(KW_GEN_ID)) {
|
||||
gen_name = (TEXT *) MSC_alloc(NAME_SIZE);
|
||||
TEXT* gen_name = (TEXT *) MSC_alloc(NAME_SIZE);
|
||||
node = MSC_node(nod_gen_id, 2);
|
||||
node->nod_count = 1;
|
||||
EXP_left_paren(0);
|
||||
@ -3111,10 +3097,10 @@ static GPRE_NOD par_udf( gpre_req* request)
|
||||
node = MSC_node(nod_cast, 2);
|
||||
node->nod_count = 1;
|
||||
EXP_left_paren(0);
|
||||
node->nod_arg[0] = SQE_value_or_null(request, FALSE, 0, 0);
|
||||
node->nod_arg[0] = SQE_value_or_null(request, false, 0, 0);
|
||||
if (!MSC_match(KW_AS))
|
||||
CPR_s_error("AS");
|
||||
field = (gpre_fld*) MSC_alloc(FLD_LEN);
|
||||
gpre_fld* field = (gpre_fld*) MSC_alloc(FLD_LEN);
|
||||
node->nod_arg[1] = (GPRE_NOD) field;
|
||||
SQL_par_field_dtype(request, field, false);
|
||||
SQL_par_field_collate(request, field);
|
||||
@ -3592,9 +3578,6 @@ static char* upcase_string(const char* p)
|
||||
static bool validate_references(GPRE_NOD fields,
|
||||
GPRE_NOD group_by)
|
||||
{
|
||||
bool invalid = false;
|
||||
bool context_match;
|
||||
|
||||
assert_IS_NOD(fields);
|
||||
assert_IS_NOD(group_by);
|
||||
|
||||
@ -3606,7 +3589,7 @@ static bool validate_references(GPRE_NOD fields,
|
||||
return true;
|
||||
ref* fref = (REF) fields->nod_arg[0];
|
||||
|
||||
context_match = false;
|
||||
bool context_match = false;
|
||||
gpre_nod** ptr = group_by->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + group_by->nod_count;
|
||||
ptr < end; ptr++)
|
||||
@ -3641,6 +3624,7 @@ static bool validate_references(GPRE_NOD fields,
|
||||
if ((fields->nod_type == nod_gen_id) || (fields->nod_type == nod_udf))
|
||||
return validate_references(fields->nod_arg[0], group_by);
|
||||
|
||||
bool invalid = false;
|
||||
gpre_nod** ptr = fields->nod_arg;
|
||||
for (const gpre_nod* const* const end = ptr + fields->nod_count; ptr < end;
|
||||
ptr++)
|
||||
@ -3690,26 +3674,3 @@ static bool validate_references(GPRE_NOD fields,
|
||||
return invalid;
|
||||
}
|
||||
|
||||
|
||||
static void dialect1_bad_type(USHORT field_dtype)
|
||||
{
|
||||
char buffer[200];
|
||||
const char* s;
|
||||
|
||||
switch (field_dtype) {
|
||||
case dtype_sql_date:
|
||||
s = "SQL DATE";
|
||||
break;
|
||||
case dtype_sql_time:
|
||||
s = "SQL TIME";
|
||||
break;
|
||||
case dtype_int64:
|
||||
s = "64-bit numeric";
|
||||
break;
|
||||
}
|
||||
sprintf(buffer,
|
||||
"Client SQL dialect 1 does not support reference to the %s datatype",
|
||||
s);
|
||||
PAR_error(buffer);
|
||||
}
|
||||
|
||||
|
225
src/gpre/sql.cpp
225
src/gpre/sql.cpp
@ -25,7 +25,7 @@
|
||||
//
|
||||
//____________________________________________________________
|
||||
//
|
||||
// $Id: sql.cpp,v 1.45 2004-05-24 17:13:38 brodsom Exp $
|
||||
// $Id: sql.cpp,v 1.46 2004-06-03 07:31:10 robocop Exp $
|
||||
//
|
||||
|
||||
#include "firebird.h"
|
||||
@ -110,7 +110,7 @@ static FIL define_file(void);
|
||||
static FIL define_log_file(bool);
|
||||
static dbb* dup_dbb(const dbb*);
|
||||
static void error(const TEXT *, const TEXT *);
|
||||
static TEXT *extract_string(bool);
|
||||
static TEXT* extract_string(bool);
|
||||
static swe* gen_whenever(void);
|
||||
static void into(gpre_req*, GPRE_NOD, GPRE_NOD);
|
||||
static gpre_fld* make_field(gpre_rel*);
|
||||
@ -136,7 +136,6 @@ static bool par_using(DYN);
|
||||
static USHORT resolve_dtypes(KWWORDS, bool);
|
||||
static bool tail_database(enum act_t, DBB);
|
||||
static void to_upcase(const TEXT *, TEXT *);
|
||||
static void dialect1_bad_type(USHORT);
|
||||
|
||||
static swe* global_whenever[SWE_max];
|
||||
static swe* global_whenever_list;
|
||||
@ -478,7 +477,9 @@ void SQL_par_field_collate( gpre_req* request, gpre_fld* field)
|
||||
if ((field->fld_dtype != dtype_text) &&
|
||||
(field->fld_dtype != dtype_cstring) &&
|
||||
(field->fld_dtype != dtype_varying))
|
||||
PAR_error("COLLATE applies only to character columns");
|
||||
{
|
||||
PAR_error("COLLATE applies only to character columns");
|
||||
}
|
||||
if (gpreGlob.token_global.tok_type != tok_ident)
|
||||
CPR_s_error("<collation name>");
|
||||
gpre_sym* symbol = MSC_find_symbol(gpreGlob.token_global.tok_symbol, SYM_collate);
|
||||
@ -495,11 +496,11 @@ void SQL_par_field_collate( gpre_req* request, gpre_fld* field)
|
||||
(field->fld_character_set->intlsym_charset_id !=
|
||||
field->fld_collate->intlsym_charset_id))
|
||||
|| (field->fld_global &&
|
||||
(field->fld_charset_id !=
|
||||
field->fld_collate->
|
||||
intlsym_charset_id)))
|
||||
PAR_error
|
||||
(field->fld_charset_id != field->fld_collate->intlsym_charset_id)))
|
||||
{
|
||||
PAR_error
|
||||
("Specified COLLATION is incompatible with column CHARACTER SET");
|
||||
}
|
||||
PAR_get_token();
|
||||
}
|
||||
}
|
||||
@ -516,13 +517,11 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
gpre_fld* field,
|
||||
bool is_udf)
|
||||
{
|
||||
int l, p, q;
|
||||
enum kwwords keyword;
|
||||
gpre_sym* symbol;
|
||||
char s[ERROR_LENGTH];
|
||||
bool sql_date = false;
|
||||
|
||||
switch (keyword = gpreGlob.token_global.tok_keyword) {
|
||||
enum kwwords keyword = gpreGlob.token_global.tok_keyword;
|
||||
switch (keyword) {
|
||||
case KW_SMALLINT:
|
||||
case KW_INT:
|
||||
case KW_INTEGER:
|
||||
@ -583,8 +582,9 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
}
|
||||
else {
|
||||
SQL_resolve_identifier("<domain name>", s);
|
||||
field->fld_global = symbol =
|
||||
gpre_sym* symbol =
|
||||
MSC_symbol(SYM_field, s, (USHORT) strlen(s), (gpre_ctx*) field);
|
||||
field->fld_global = symbol;
|
||||
if (!MET_domain_lookup(request, field, s))
|
||||
PAR_error("Specified DOMAIN or source column not found");
|
||||
PAR_get_token();
|
||||
@ -608,7 +608,7 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
|
||||
case KW_FLOAT:
|
||||
if (MSC_match(KW_LEFT_PAREN)) {
|
||||
l = EXP_USHORT_ordinal(true);
|
||||
const int l = EXP_USHORT_ordinal(true);
|
||||
EXP_match_paren();
|
||||
if (l < 17)
|
||||
field->fld_dtype = dtype_real;
|
||||
@ -696,7 +696,7 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
field->fld_precision = 9;
|
||||
field->fld_sub_type = (keyword == KW_NUMERIC) ? 1 : 2;
|
||||
if (MSC_match(KW_LEFT_PAREN)) {
|
||||
p = EXP_USHORT_ordinal(true);
|
||||
const int p = EXP_USHORT_ordinal(true);
|
||||
if ((p <= 0) || (p > 18))
|
||||
PAR_error("Precision must be from 1 to 18");
|
||||
|
||||
@ -710,7 +710,7 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
}
|
||||
|
||||
if (MSC_match(KW_COMMA)) {
|
||||
q = EXP_USHORT_ordinal(true);
|
||||
const int q = EXP_USHORT_ordinal(true);
|
||||
|
||||
if (q > p)
|
||||
PAR_error("Scale can not be greater than precision");
|
||||
@ -786,8 +786,9 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
}
|
||||
|
||||
if (field->fld_flags & FLD_national) {
|
||||
if (!(symbol = MSC_find_symbol(HSH_lookup(DEFAULT_CHARACTER_SET_NAME),
|
||||
SYM_charset)))
|
||||
gpre_sym* symbol = MSC_find_symbol(HSH_lookup(DEFAULT_CHARACTER_SET_NAME),
|
||||
SYM_charset);
|
||||
if (!symbol)
|
||||
{
|
||||
PAR_error("NATIONAL character set missing");
|
||||
}
|
||||
@ -801,9 +802,10 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
&& request->req_database->dbb_def_charset)
|
||||
{
|
||||
// Use database default character set
|
||||
if (symbol = MSC_find_symbol(HSH_lookup
|
||||
gpre_sym* symbol = MSC_find_symbol(HSH_lookup
|
||||
(request->req_database->dbb_def_charset),
|
||||
SYM_charset))
|
||||
SYM_charset);
|
||||
if (symbol)
|
||||
{
|
||||
field->fld_character_set = (INTLSYM) symbol->sym_object;
|
||||
}
|
||||
@ -820,16 +822,13 @@ void SQL_par_field_dtype(gpre_req* request,
|
||||
//
|
||||
|
||||
gpre_prc* SQL_procedure(gpre_req* request,
|
||||
TEXT * prc_string,
|
||||
TEXT * db_string,
|
||||
TEXT * owner_string,
|
||||
const TEXT* prc_string,
|
||||
const TEXT* db_string,
|
||||
const TEXT* owner_string,
|
||||
bool err_flag)
|
||||
{
|
||||
DBB db;
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
|
||||
gpre_prc* procedure = NULL;
|
||||
|
||||
if (db_string && db_string[0]) {
|
||||
// a database was specified for the procedure
|
||||
// search the known symbols for the database name
|
||||
@ -845,6 +844,8 @@ gpre_prc* SQL_procedure(gpre_req* request,
|
||||
request->req_database = (DBB) symbol->sym_object;
|
||||
}
|
||||
|
||||
gpre_prc* procedure = NULL;
|
||||
|
||||
if (request->req_database)
|
||||
procedure = MET_get_procedure(request->req_database, prc_string,
|
||||
owner_string);
|
||||
@ -853,7 +854,7 @@ gpre_prc* SQL_procedure(gpre_req* request,
|
||||
// for the existence of the procedure
|
||||
|
||||
procedure = NULL; // redundant
|
||||
for (db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
for (DBB db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
{
|
||||
gpre_prc* tmp_procedure = MET_get_procedure(db, prc_string,
|
||||
owner_string);
|
||||
@ -894,16 +895,13 @@ gpre_prc* SQL_procedure(gpre_req* request,
|
||||
//
|
||||
|
||||
gpre_rel* SQL_relation(gpre_req* request,
|
||||
TEXT * rel_string,
|
||||
TEXT * db_string,
|
||||
TEXT * owner_string,
|
||||
const TEXT* rel_string,
|
||||
const TEXT* db_string,
|
||||
const TEXT* owner_string,
|
||||
bool err_flag)
|
||||
{
|
||||
DBB db;
|
||||
SCHAR s[ERROR_LENGTH];
|
||||
|
||||
gpre_rel* relation = NULL;
|
||||
|
||||
if (db_string && db_string[0]) {
|
||||
/* a database was specified for the relation,
|
||||
search the known symbols for the database name */
|
||||
@ -919,6 +917,8 @@ gpre_rel* SQL_relation(gpre_req* request,
|
||||
request->req_database = (DBB) symbol->sym_object;
|
||||
}
|
||||
|
||||
gpre_rel* relation = NULL;
|
||||
|
||||
if (request->req_database)
|
||||
relation = MET_get_relation(request->req_database, rel_string,
|
||||
owner_string);
|
||||
@ -926,8 +926,8 @@ gpre_rel* SQL_relation(gpre_req* request,
|
||||
/* no database was specified, check the metadata for all the databases
|
||||
for the existence of the relation */
|
||||
|
||||
relation = NULL;
|
||||
for (db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
relation = NULL; // redundant
|
||||
for (DBB db = gpreGlob.isc_databases; db; db = db->dbb_next)
|
||||
{
|
||||
gpre_rel* tmp_relation = MET_get_relation(db, rel_string, owner_string);
|
||||
if (tmp_relation) {
|
||||
@ -964,13 +964,14 @@ gpre_rel* SQL_relation(gpre_req* request,
|
||||
// Get a relation name (checking for database specifier)
|
||||
//
|
||||
|
||||
void SQL_relation_name(TEXT * r_name,
|
||||
TEXT * db_name,
|
||||
TEXT * owner_name)
|
||||
void SQL_relation_name(TEXT* r_name,
|
||||
TEXT* db_name,
|
||||
TEXT* owner_name)
|
||||
{
|
||||
db_name[0] = 0;
|
||||
owner_name[0] = 0;
|
||||
|
||||
// Why not TEXT t_str[NAME_SIZE + 1]; instead and avoid deallocation problem?
|
||||
TEXT* t_str = (TEXT*) MSC_alloc(NAME_SIZE + 1);
|
||||
SQL_resolve_identifier("<Table name>", t_str);
|
||||
|
||||
@ -999,6 +1000,7 @@ void SQL_relation_name(TEXT * r_name,
|
||||
strcpy(r_name, gpreGlob.token_global.tok_string);
|
||||
PAR_get_token();
|
||||
}
|
||||
#pragma FB_COMPILER_MESSAGE("Apparently, no safe way to deallocate t_str here.")
|
||||
}
|
||||
|
||||
|
||||
@ -1007,7 +1009,7 @@ void SQL_relation_name(TEXT * r_name,
|
||||
// Extract SQL var
|
||||
//
|
||||
|
||||
TEXT *SQL_var_or_string(bool string_only)
|
||||
TEXT* SQL_var_or_string(bool string_only)
|
||||
{
|
||||
|
||||
if ((gpreGlob.token_global.tok_type != tok_sglquoted && gpreGlob.sw_sql_dialect == 3) ||
|
||||
@ -1304,10 +1306,7 @@ static act* act_alter_index(void)
|
||||
|
||||
static act* act_alter_table(void)
|
||||
{
|
||||
gpre_fld* field;
|
||||
gpre_ctx* context;
|
||||
|
||||
// create request block
|
||||
// create request block
|
||||
|
||||
gpre_req* request = MSC_request(REQ_ddl);
|
||||
|
||||
@ -1318,7 +1317,8 @@ static act* act_alter_table(void)
|
||||
// CHECK Constraints require the context to be set to the
|
||||
// current relation
|
||||
|
||||
request->req_contexts = context = MSC_context(request);
|
||||
gpre_ctx* context = MSC_context(request);
|
||||
request->req_contexts = context;
|
||||
context->ctx_relation = relation;
|
||||
|
||||
// Reserve context 1 for relation on which constraint is
|
||||
@ -1338,6 +1338,7 @@ static act* act_alter_table(void)
|
||||
gpre_fld** ptr = &relation->rel_fields;
|
||||
cnstrt** cnstrt_ptr = &relation->rel_constraints;
|
||||
cnstrt* cnstrt_str;
|
||||
gpre_fld* field;
|
||||
|
||||
while (!end_of_command()) {
|
||||
if (MSC_match(KW_ADD)) {
|
||||
@ -1479,7 +1480,8 @@ static act* act_connect(void)
|
||||
dpb can be extended at runtime */
|
||||
|
||||
if (db->dbb_r_user || db->dbb_r_password || db->dbb_r_sql_role
|
||||
|| db->dbb_r_lc_messages || db->dbb_r_lc_ctype) {
|
||||
|| db->dbb_r_lc_messages || db->dbb_r_lc_ctype)
|
||||
{
|
||||
if (!request)
|
||||
request =
|
||||
PAR_set_up_dpb_info(ready, action, default_buffers);
|
||||
@ -1492,8 +1494,10 @@ static act* act_connect(void)
|
||||
if (!request && (db->dbb_c_user || db->dbb_c_password ||
|
||||
db->dbb_c_sql_role ||
|
||||
db->dbb_c_lc_messages || db->dbb_c_lc_ctype))
|
||||
request =
|
||||
{
|
||||
request =
|
||||
PAR_set_up_dpb_info(ready, action, default_buffers);
|
||||
}
|
||||
|
||||
if (!MSC_match(KW_COMMA))
|
||||
break;
|
||||
@ -1554,8 +1558,10 @@ static act* act_connect(void)
|
||||
if (!request && (db->dbb_c_user || db->dbb_c_password ||
|
||||
db->dbb_c_sql_role ||
|
||||
db->dbb_c_lc_ctype || db->dbb_c_lc_messages))
|
||||
request =
|
||||
{
|
||||
request =
|
||||
PAR_set_up_dpb_info(ready, action, default_buffers);
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
@ -2197,7 +2203,8 @@ static act* act_declare(void)
|
||||
gpre_sym* symb = HSH_lookup2(gpreGlob.token_global.tok_string);
|
||||
if (symb &&
|
||||
(symb->sym_type == SYM_cursor ||
|
||||
symb->sym_type == SYM_delimited_cursor)) {
|
||||
symb->sym_type == SYM_delimited_cursor))
|
||||
{
|
||||
char s[64];
|
||||
sprintf(s, "symbol %s is already in use", t_str);
|
||||
PAR_error(s);
|
||||
@ -2281,7 +2288,8 @@ static act* act_declare(void)
|
||||
return action;
|
||||
|
||||
default:
|
||||
while (MSC_match(KW_COMMA));
|
||||
while (MSC_match(KW_COMMA))
|
||||
; // empty loop body
|
||||
if (MSC_match(KW_STATEMENT)) {
|
||||
action = (act*) MSC_alloc(ACT_LEN);
|
||||
action->act_type = ACT_dyn_statement;
|
||||
@ -2321,20 +2329,19 @@ static act* act_declare_filter(void)
|
||||
action->act_whenever = gen_whenever();
|
||||
action->act_object = (REF) filter;
|
||||
|
||||
SLONG input_type, output_type;
|
||||
|
||||
SLONG input_type;
|
||||
if (MSC_match(KW_INPUT_TYPE))
|
||||
input_type = EXP_SSHORT_ordinal(true);
|
||||
else
|
||||
CPR_s_error("INPUT_TYPE");
|
||||
|
||||
SLONG output_type;
|
||||
if (MSC_match(KW_OUTPUT_TYPE))
|
||||
output_type = EXP_SSHORT_ordinal(true);
|
||||
else
|
||||
CPR_s_error("OUTPUT_TYPE");
|
||||
|
||||
if (!range_short_integer(input_type)
|
||||
|| !range_short_integer(output_type))
|
||||
if (!range_short_integer(input_type) || !range_short_integer(output_type))
|
||||
PAR_error("Blob sub_type out of range");
|
||||
|
||||
filter->fltr_input_type = (SSHORT) input_type;
|
||||
@ -2449,8 +2456,6 @@ static act* act_declare_table( gpre_sym* symbol, DBB db)
|
||||
|
||||
static act* act_declare_udf(void)
|
||||
{
|
||||
SLONG return_parameter;
|
||||
|
||||
gpre_req* request = MSC_request(REQ_ddl);
|
||||
|
||||
if (gpreGlob.isc_databases && !gpreGlob.isc_databases->dbb_next)
|
||||
@ -2475,7 +2480,7 @@ static act* act_declare_udf(void)
|
||||
while (true) {
|
||||
if (MSC_match(KW_RETURNS)) {
|
||||
if (MSC_match(KW_PARAMETER)) {
|
||||
return_parameter = EXP_pos_USHORT_ordinal(true);
|
||||
const SLONG return_parameter = EXP_pos_USHORT_ordinal(true);
|
||||
if (return_parameter > 10)
|
||||
PAR_error("return parameter not in range");
|
||||
fb_assert(return_parameter <= MAX_SSHORT);
|
||||
@ -2553,7 +2558,7 @@ static act* act_delete(void)
|
||||
gpre_req* request = MSC_request(REQ_mass_update);
|
||||
upd* update = (upd*) MSC_alloc(UPD_LEN);
|
||||
|
||||
bool where = MSC_match(KW_WITH);
|
||||
const bool where = MSC_match(KW_WITH);
|
||||
if (where && MSC_match(KW_CURRENT)) {
|
||||
if (!MSC_match(KW_OF))
|
||||
CPR_s_error("OF <cursor>");
|
||||
@ -2563,7 +2568,8 @@ static act* act_delete(void)
|
||||
request = par_cursor(NULL);
|
||||
if ((transaction || request->req_trans) &&
|
||||
(!transaction || !request->req_trans ||
|
||||
strcmp(transaction, request->req_trans))) {
|
||||
strcmp(transaction, request->req_trans)))
|
||||
{
|
||||
if (transaction)
|
||||
PAR_error("different transaction for select and delete");
|
||||
else { // does not specify transaction clause in
|
||||
@ -2733,7 +2739,7 @@ static act* act_drop(void)
|
||||
gpre_req* request = NULL;
|
||||
gpre_rel* relation = NULL;
|
||||
SCHAR* db_string;
|
||||
TEXT* identifier_name;
|
||||
TEXT* identifier_name; // it's not deallocated.
|
||||
|
||||
switch (gpreGlob.token_global.tok_keyword) {
|
||||
case KW_DATABASE:
|
||||
@ -3000,7 +3006,7 @@ static act* act_fetch(void)
|
||||
// parse the fetch orientation
|
||||
|
||||
USHORT direction = blr_forward;
|
||||
TEXT* direction_string = NULL;
|
||||
const TEXT* direction_string = NULL;
|
||||
GPRE_NOD offset_node = NULL;
|
||||
|
||||
if (!MSC_match(KW_NEXT)) {
|
||||
@ -3087,7 +3093,7 @@ static act* act_fetch(void)
|
||||
if (offset_node)
|
||||
value->val_value = ((REF) offset_node->nod_arg[0])->ref_value;
|
||||
else {
|
||||
TEXT* offset_string = "1";
|
||||
const TEXT* offset_string = "1";
|
||||
string = (TEXT*) MSC_alloc(2);
|
||||
value->val_value = string;
|
||||
MSC_copy(offset_string, 1, string);
|
||||
@ -3242,7 +3248,8 @@ static act* act_grant_revoke( enum act_t type)
|
||||
else if (MSC_match(KW_VIEW)) {
|
||||
SQL_relation_name(r_name, db_name, owner_name);
|
||||
if (!MET_get_view_relation
|
||||
(request, r_name, relation_name->str_string, 0)) {
|
||||
(request, r_name, relation_name->str_string, 0))
|
||||
{
|
||||
sprintf(s, "VIEW %s not defined on table %s", r_name,
|
||||
relation_name->str_string);
|
||||
PAR_error(s);
|
||||
@ -3415,15 +3422,15 @@ static act* act_insert(void)
|
||||
|
||||
// Dialect 1 program may not insert new datatypes
|
||||
if ((SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) &&
|
||||
(nod_field == node->nod_type)) {
|
||||
USHORT field_dtype;
|
||||
|
||||
field_dtype =
|
||||
(nod_field == node->nod_type))
|
||||
{
|
||||
const USHORT field_dtype =
|
||||
((REF) (node->nod_arg[0]))->ref_field->fld_dtype;
|
||||
if ((dtype_sql_date == field_dtype)
|
||||
|| (dtype_sql_time == field_dtype)
|
||||
|| (dtype_int64 == field_dtype)) {
|
||||
dialect1_bad_type(field_dtype);
|
||||
|| (dtype_int64 == field_dtype))
|
||||
{
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3739,8 +3746,10 @@ static act* act_open_blob( ACT_T act_op, gpre_sym* symbol)
|
||||
blob->blb_from_charset = par_char_set();
|
||||
if (act_op == ACT_blob_open
|
||||
&& blob->blb_from_charset != field->fld_charset_id)
|
||||
PAR_error
|
||||
{
|
||||
PAR_error
|
||||
("Specified CHARACTER SET does not match BLOB column declaration.");
|
||||
}
|
||||
}
|
||||
else
|
||||
PAR_error("Only text BLOBS can specify CHARACTER SET");
|
||||
@ -3766,8 +3775,10 @@ static act* act_open_blob( ACT_T act_op, gpre_sym* symbol)
|
||||
blob->blb_to_charset = par_char_set();
|
||||
if (act_op == ACT_blob_create
|
||||
&& blob->blb_to_charset != field->fld_charset_id)
|
||||
PAR_error
|
||||
{
|
||||
PAR_error
|
||||
("Specified CHARACTER SET does not match BLOB column declaration.");
|
||||
}
|
||||
}
|
||||
else
|
||||
PAR_error("Only text BLOBS can specify CHARACTER SET");
|
||||
@ -4033,7 +4044,8 @@ static act* act_set_dialect(void)
|
||||
CPR_s_error("SQL DIALECT 1,2 or 3");
|
||||
|
||||
if (gpreGlob.isc_databases && dialect != gpreGlob.compiletime_db_dialect
|
||||
&& gpreGlob.sw_ods_version < 10) {
|
||||
&& gpreGlob.sw_ods_version < 10)
|
||||
{
|
||||
char warn_mesg[100];
|
||||
sprintf(warn_mesg,
|
||||
"Pre 6.0 database. Cannot use dialect %d, Resetting to %d\n",
|
||||
@ -4388,7 +4400,7 @@ static act* act_update(void)
|
||||
// then this is a sub-action of an existing request. If not, then it is
|
||||
// a free standing request
|
||||
|
||||
bool where = MSC_match(KW_WITH);
|
||||
const bool where = MSC_match(KW_WITH);
|
||||
if (where && MSC_match(KW_CURRENT)) {
|
||||
if (!MSC_match(KW_OF))
|
||||
CPR_s_error("OF cursor");
|
||||
@ -4405,7 +4417,8 @@ static act* act_update(void)
|
||||
PAR_error("expected a TABLE cursor, got a BLOB cursor");
|
||||
if ((transaction || request->req_trans) &&
|
||||
(!transaction || !request->req_trans ||
|
||||
strcmp(transaction, request->req_trans))) {
|
||||
strcmp(transaction, request->req_trans)))
|
||||
{
|
||||
if (transaction)
|
||||
PAR_error("different transaction for select and update");
|
||||
else { // does not specify transaction clause in
|
||||
@ -4471,7 +4484,8 @@ static act* act_update(void)
|
||||
slc* slice = NULL;
|
||||
act* slice_action = (act*) field_ref->ref_slice;
|
||||
if (slice_action &&
|
||||
(slice = (slc*) slice_action->act_object)) {
|
||||
(slice = (slc*) slice_action->act_object))
|
||||
{
|
||||
// These gpreGlob.requests got lost in freeing the main request
|
||||
|
||||
gpre_req* slice_request = slice_action->act_request;
|
||||
@ -4488,7 +4502,8 @@ static act* act_update(void)
|
||||
|
||||
bool found = false;
|
||||
for (REF req_ref = request->req_references; req_ref;
|
||||
req_ref = req_ref->ref_next) {
|
||||
req_ref = req_ref->ref_next)
|
||||
{
|
||||
if (req_ref == field_ref) {
|
||||
set_item->nod_arg[1]->nod_arg[0] = (GPRE_NOD) req_ref;
|
||||
found = true;
|
||||
@ -4496,8 +4511,10 @@ static act* act_update(void)
|
||||
}
|
||||
if ((req_ref->ref_field == field_ref->ref_field) &&
|
||||
(req_ref->ref_context == field_ref->ref_context))
|
||||
{
|
||||
PAR_error
|
||||
("Can't update multiple slices of same column");
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
field_ref->ref_next = request->req_references;
|
||||
@ -4568,14 +4585,14 @@ static act* act_update(void)
|
||||
if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) {
|
||||
for (int arg_num = 0; arg_num <= 1; arg_num++)
|
||||
if (nod_field == set_item->nod_arg[arg_num]->nod_type) {
|
||||
USHORT field_dtype =((REF)
|
||||
const USHORT field_dtype = ((REF)
|
||||
(set_item->nod_arg[arg_num]->
|
||||
nod_arg[0]))->ref_field->fld_dtype;
|
||||
if ((dtype_sql_date == field_dtype)
|
||||
|| (dtype_sql_time == field_dtype)
|
||||
|| (dtype_int64 == field_dtype))
|
||||
{
|
||||
dialect1_bad_type(field_dtype);
|
||||
SQL_dialect1_bad_type(field_dtype);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4663,7 +4680,7 @@ static act* act_whenever(void)
|
||||
|
||||
static bool check_filename(const TEXT * name)
|
||||
{
|
||||
USHORT l = strlen(name);
|
||||
const USHORT l = strlen(name);
|
||||
if (!l)
|
||||
return true;
|
||||
|
||||
@ -4882,7 +4899,7 @@ static void error(const TEXT * format, const TEXT * string2)
|
||||
// token.
|
||||
//
|
||||
|
||||
static TEXT *extract_string(bool advance_token)
|
||||
static TEXT* extract_string(bool advance_token)
|
||||
{
|
||||
switch (gpreGlob.sw_sql_dialect) {
|
||||
case 1:
|
||||
@ -4984,7 +5001,8 @@ static void into( gpre_req* request, GPRE_NOD field_list, GPRE_NOD var_list)
|
||||
|
||||
bool found = false;
|
||||
for (reference = request->req_references; reference;
|
||||
reference = reference->ref_next) {
|
||||
reference = reference->ref_next)
|
||||
{
|
||||
if (reference == field_ref) {
|
||||
found = true;
|
||||
break;
|
||||
@ -5113,8 +5131,8 @@ static void pair( GPRE_NOD expr, GPRE_NOD field_expr)
|
||||
|
||||
case nod_map_ref:
|
||||
{
|
||||
MEL element = (MEL) expr->nod_arg[0];
|
||||
pair(element->mel_expr, field_expr);
|
||||
MEL element = (MEL) expr->nod_arg[0];
|
||||
pair(element->mel_expr, field_expr);
|
||||
}
|
||||
return;
|
||||
|
||||
@ -5123,8 +5141,8 @@ static void pair( GPRE_NOD expr, GPRE_NOD field_expr)
|
||||
return;
|
||||
}
|
||||
|
||||
GPRE_NOD* ptr = expr->nod_arg;
|
||||
GPRE_NOD* end_ptr = ptr + expr->nod_count;
|
||||
gpre_nod** ptr = expr->nod_arg;
|
||||
const gpre_nod* const* const end_ptr = ptr + expr->nod_count;
|
||||
|
||||
for (; ptr < end_ptr; ptr++)
|
||||
pair(*ptr, field_expr);
|
||||
@ -5439,7 +5457,6 @@ static gpre_fld* par_field( gpre_req* request, gpre_rel* relation)
|
||||
static CNSTRT par_field_constraint( gpre_req* request, gpre_fld* for_field,
|
||||
gpre_rel* relation)
|
||||
{
|
||||
enum kwwords keyword;
|
||||
STR field_name;
|
||||
|
||||
cnstrt* new_constraint = (cnstrt*) MSC_alloc(CNSTRT_LEN);
|
||||
@ -5454,7 +5471,8 @@ static CNSTRT par_field_constraint( gpre_req* request, gpre_fld* for_field,
|
||||
PAR_get_token();
|
||||
}
|
||||
|
||||
switch (keyword = gpreGlob.token_global.tok_keyword) {
|
||||
const enum kwwords keyword = gpreGlob.token_global.tok_keyword;
|
||||
switch (keyword) {
|
||||
case KW_NOT:
|
||||
PAR_get_token();
|
||||
if (!MSC_match(KW_NULL))
|
||||
@ -5579,10 +5597,9 @@ static void par_options(const TEXT** transaction)
|
||||
|
||||
static int par_page_size(void)
|
||||
{
|
||||
int n1, n2;
|
||||
|
||||
MSC_match(KW_EQUALS);
|
||||
n2 = n1 = EXP_USHORT_ordinal(false);
|
||||
const int n1 = EXP_USHORT_ordinal(false);
|
||||
int n2 = n1;
|
||||
|
||||
if (n1 <= 1024)
|
||||
n2 = 1024;
|
||||
@ -5642,9 +5659,7 @@ static DYN par_statement(void)
|
||||
|
||||
static void par_fkey_extension(cnstrt* cnstrt_val)
|
||||
{
|
||||
enum kwwords keyword;
|
||||
|
||||
//
|
||||
//
|
||||
// Extended foreign key definition could be as follows :
|
||||
//
|
||||
// [ON DELETE { NO ACTION | CASCADE | SET DEFAULT | SET NULL } ]
|
||||
@ -5656,7 +5671,8 @@ static void par_fkey_extension(cnstrt* cnstrt_val)
|
||||
|
||||
PAR_get_token();
|
||||
|
||||
switch (keyword = gpreGlob.token_global.tok_keyword) {
|
||||
const enum kwwords keyword = gpreGlob.token_global.tok_keyword;
|
||||
switch (keyword) {
|
||||
case KW_DELETE:
|
||||
// NOTE: action must be defined only once
|
||||
if (cnstrt_val->cnstrt_fkey_def_type & REF_DELETE_ACTION)
|
||||
@ -5732,10 +5748,6 @@ static void par_fkey_extension(cnstrt* cnstrt_val)
|
||||
|
||||
static CNSTRT par_table_constraint( gpre_req* request, gpre_rel* relation)
|
||||
{
|
||||
enum kwwords keyword;
|
||||
gpre_lls** fields;
|
||||
USHORT num_for_key_flds = 0, num_prim_key_flds = 0;
|
||||
|
||||
cnstrt* constraint = (cnstrt*) MSC_alloc(CNSTRT_LEN);
|
||||
|
||||
if (gpreGlob.token_global.tok_keyword == KW_CONSTRAINT) {
|
||||
@ -5748,7 +5760,11 @@ static CNSTRT par_table_constraint( gpre_req* request, gpre_rel* relation)
|
||||
PAR_get_token();
|
||||
}
|
||||
|
||||
switch (keyword = gpreGlob.token_global.tok_keyword) {
|
||||
gpre_lls** fields;
|
||||
USHORT num_for_key_flds = 0, num_prim_key_flds = 0;
|
||||
|
||||
const enum kwwords keyword = gpreGlob.token_global.tok_keyword;
|
||||
switch (keyword) {
|
||||
case KW_PRIMARY:
|
||||
case KW_UNIQUE:
|
||||
case KW_FOREIGN:
|
||||
@ -5822,8 +5838,10 @@ static CNSTRT par_table_constraint( gpre_req* request, gpre_rel* relation)
|
||||
later on */
|
||||
if (constraint->cnstrt_referred_fields != NULL &&
|
||||
num_prim_key_flds != num_for_key_flds)
|
||||
PAR_error
|
||||
{
|
||||
PAR_error
|
||||
("FOREIGN KEY column count does not match PRIMARY KEY");
|
||||
}
|
||||
if (gpreGlob.token_global.tok_keyword == KW_ON) {
|
||||
par_fkey_extension(constraint);
|
||||
PAR_get_token();
|
||||
@ -6220,10 +6238,9 @@ static void to_upcase(const TEXT * p, TEXT * q)
|
||||
|
||||
//____________________________________________________________
|
||||
//
|
||||
//
|
||||
// To do: move these to the correct position in the file.
|
||||
|
||||
// The first param should be const probably.
|
||||
void SQL_resolve_identifier( TEXT * err_mesg, TEXT * str)
|
||||
void SQL_resolve_identifier( const TEXT* err_mesg, TEXT* str)
|
||||
{
|
||||
|
||||
switch (gpreGlob.sw_sql_dialect) {
|
||||
@ -6252,10 +6269,10 @@ void SQL_resolve_identifier( TEXT * err_mesg, TEXT * str)
|
||||
}
|
||||
|
||||
|
||||
static void dialect1_bad_type(USHORT field_dtype)
|
||||
void SQL_dialect1_bad_type(USHORT field_dtype)
|
||||
{
|
||||
char buffer[200];
|
||||
const char *s = NULL;
|
||||
const char* s = "unknown";
|
||||
|
||||
switch (field_dtype) {
|
||||
case dtype_sql_date:
|
||||
|
@ -26,13 +26,14 @@
|
||||
|
||||
act* SQL_action(const TEXT*);
|
||||
void SQL_adjust_field_dtype(gpre_fld*);
|
||||
void SQL_dialect1_bad_type(USHORT);
|
||||
void SQL_init(void);
|
||||
void SQL_par_field_collate(gpre_req*, gpre_fld*);
|
||||
void SQL_par_field_dtype(gpre_req*, gpre_fld*, bool);
|
||||
gpre_prc* SQL_procedure(gpre_req*, TEXT*, TEXT*, TEXT*, bool);
|
||||
gpre_rel* SQL_relation(gpre_req*, TEXT*, TEXT*, TEXT*, bool);
|
||||
gpre_prc* SQL_procedure(gpre_req*, const TEXT*, const TEXT*, const TEXT*, bool);
|
||||
gpre_rel* SQL_relation(gpre_req*, const TEXT*, const TEXT*, const TEXT*, bool);
|
||||
void SQL_relation_name(TEXT*, TEXT*, TEXT*);
|
||||
void SQL_resolve_identifier(TEXT*, TEXT*);
|
||||
void SQL_resolve_identifier(const TEXT*, TEXT*);
|
||||
TEXT* SQL_var_or_string(bool);
|
||||
|
||||
#endif // GPRE_SQL_PROTO_H
|
||||
|
Loading…
Reference in New Issue
Block a user