From: Jim S. <jim...@us...> - 2005-09-15 16:33:40
|
Update of /cvsroot/firebird/vulcan/src/jrd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15722/src/jrd Modified Files: InternalStatement.cpp Request.cpp Request.h blrtable.cpp cmp.cpp cvt.cpp dls_proto.h dsc.h exe.cpp jrd.vcproj par.cpp Log Message: Untangle include files, specifically dls_proto.h. Also work in progress on execute statement. Index: InternalStatement.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/InternalStatement.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- InternalStatement.cpp 2 May 2005 13:52:39 -0000 1.2 +++ InternalStatement.cpp 15 Sep 2005 16:33:29 -0000 1.3 @@ -108,6 +108,7 @@ FOR_OBJECTS (InternalResultSet*, resultSet, &resultSets) resultSet->close(); END_FOR; + delete statement; } Index: Request.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Request.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -b -U3 -r1.6 -r1.7 --- Request.cpp 20 Jul 2005 22:43:48 -0000 1.6 +++ Request.cpp 15 Sep 2005 16:33:29 -0000 1.7 @@ -41,6 +41,7 @@ #include "../jrd/tra.h" #include "../jrd/blb.h" #include "../jrd/blb_proto.h" +#include "ExecStatement.h" Request::Request(JrdMemoryPool* pool, int rpbCount, int impureSize) : req_invariants(pool), req_fors(pool) { @@ -51,6 +52,7 @@ memset (req_impure, 0, req_impure_size); req_last_xcp = new StatusXcp; rsbs = NULL; + execStatements = NULL; } @@ -70,6 +72,7 @@ memset (req_rpb, 0, sizeof (record_param) * req_count); req_impure = new UCHAR [req_impure_size]; memset (req_impure, 0, req_impure_size); + execStatements = NULL; for (record_param* rpb1 = req_rpb, *end = rpb1 + req_count, *rpb2 = request->req_rpb; rpb1 < end; rpb1++, rpb2++) { @@ -90,6 +93,12 @@ rsbs = rsb->nextInRequest; delete rsb; } + + for (ExecStatement *exec; exec = execStatements;) + { + execStatements = exec->next; + delete exec; + } } @@ -232,3 +241,12 @@ req_tdbb = tdbb; req_attachment = tdbb->tdbb_attachment; } + +ExecStatement* Request::getExecStatement(void) +{ + ExecStatement *exec = new ExecStatement(this); + exec->next = execStatements; + execStatements = exec; + + return exec; +} Index: Request.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Request.h,v retrieving revision 1.7 retrieving revision 1.8 diff -b -U3 -r1.7 -r1.8 --- Request.h 26 Jul 2005 16:31:28 -0000 1.7 +++ Request.h 15 Sep 2005 16:33:29 -0000 1.8 @@ -69,6 +69,7 @@ class Savepoint; class StatusXcp; class RecordSource; +class ExecStatement; struct record_param; struct thread_db; @@ -136,9 +137,11 @@ UCHAR *req_impure; thread_db *req_tdbb; RecordSource *rsbs; + ExecStatement *execStatements; Request* getInstantiatedRequest(int instantiation); Request* findInstantiatedRequest(int instantiation); + int getRequestInfo(thread_db* threadData, int itemsLength, const UCHAR* items, int bufferLength, UCHAR* buffer); void release(void); void release(thread_db* tdbb); @@ -146,6 +149,7 @@ void releaseBlobs(void); void releaseProcedureSavePoints(void); void setThread(thread_db* tdbb); + ExecStatement* getExecStatement(void); }; #endif Index: blrtable.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/blrtable.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -b -U3 -r1.4 -r1.5 --- blrtable.cpp 29 Jul 2005 16:59:39 -0000 1.4 +++ blrtable.cpp 15 Sep 2005 16:33:29 -0000 1.5 @@ -23,8 +23,9 @@ * 2002.10.29 Nickolay Samofatov: Added support for savepoints */ +#include <stdio.h> #include "firebird.h" -#include "../jrd/ib_stdio.h" +//#include "../jrd/ib_stdio.h" #include "../jrd/gds.h" #include "../jrd/common.h" @@ -90,7 +91,7 @@ PAIR(nod_post, blr_post, 2, 1, STATEMENT, VALUE), PAIR(nod_post, blr_post_arg, 2, 2, STATEMENT, VALUE), PAIR(nod_exec_sql, blr_exec_sql, 1, 1, STATEMENT, VALUE), - PAIR(nod_exec_into, blr_exec_into, 0, 0, STATEMENT, OTHER), + PAIR(nod_exec_into, blr_exec_into, 3, 0, STATEMENT, OTHER), PAIR(nod_internal_info, blr_internal_info, 1, 1, VALUE, VALUE), PAIR2(nod_add, blr_add, 2, 2, VALUE, VALUE), PAIR(nod_agg_count, blr_agg_count, 1, 0, VALUE, VALUE), @@ -101,8 +102,7 @@ PAIR2(nod_agg_total, blr_agg_total, 1, 1, VALUE, VALUE), PAIR2(nod_agg_total_distinct, blr_agg_total_distinct, 2, 1, VALUE, VALUE), PAIR2(nod_agg_average, blr_agg_average, 1, 1, VALUE, VALUE), - PAIR2(nod_agg_average_distinct, blr_agg_average_distinct, 2, 1, VALUE, - VALUE), + PAIR2(nod_agg_average_distinct, blr_agg_average_distinct, 2, 1, VALUE, VALUE), PAIR(nod_argument, blr_parameter, e_arg_length, 0, VALUE, VALUE), PAIR(nod_argument, blr_parameter2, e_arg_length, 0, VALUE, VALUE), PAIR(nod_argument, blr_parameter3, e_arg_length, 0, VALUE, VALUE), @@ -248,7 +248,8 @@ const VERB *verb; int max, blr; - for (blr = 0; blr < FB_NELEM(table); blr++) { + for (blr = 0; blr < FB_NELEM(table); blr++) + { table[blr] = NULL; table2[blr] = NULL; lengths[blr] = NULL; @@ -258,39 +259,43 @@ sub_types[blr] = NULL; } - for (max = 0, verb = verbs; verb->internal; ++verb) { + for (max = 0, verb = verbs; verb->internal; ++verb) + { blr = verb->blr; - if (table[blr]) { - ib_fprintf(ib_stderr, "BLRTABLE: duplicate blr %d\n", blr); + + if (table[blr]) + { + fprintf(stderr, "BLRTABLE: duplicate blr %d\n", blr); exit(1); } + table[blr] = verb->internal; - table2[blr] = - (verb->internal2 == 0) ? verb->internal : verb->internal2; + table2[blr] = (verb->internal2 == 0) ? verb->internal : verb->internal2; lengths[blr] = verb->length; counts[blr] = verb->count; types[blr] = verb->type; sub_types[blr] = verb->sub_type; + if (blr > max) max = blr; } - ib_printf("static const UCHAR blr_table4 [] = {\n"); + printf("static const UCHAR blr_table4 [] = {\n"); print(table, max, "(UCHAR) "); - ib_printf("static const UCHAR blr_table [] = {\n"); + printf("static const UCHAR blr_table [] = {\n"); print(table2, max, "(UCHAR) "); - ib_printf("static const SCHAR length_table [] = {\n"); + printf("static const SCHAR length_table [] = {\n"); print(lengths, max, ""); - ib_printf("static const SCHAR count_table [] = {\n"); + printf("static const SCHAR count_table [] = {\n"); print(counts, max, ""); - ib_printf("static const SCHAR type_table [] = {\n"); + printf("static const SCHAR type_table [] = {\n"); print(types, max, ""); - ib_printf("static const SCHAR sub_type_table [] = {\n"); + printf("static const SCHAR sub_type_table [] = {\n"); print(sub_types, max, ""); return 0; @@ -322,11 +327,11 @@ while (*s) s++; if (s > buffer + 50) { - ib_printf("\t%s\n/*%3d*/", buffer, blr + 1); + printf("\t%s\n/*%3d*/", buffer, blr + 1); s = buffer; *s = 0; } } - ib_printf("\t%s 0};\n", buffer); + printf("\t%s 0};\n", buffer); } Index: cmp.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/cmp.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -b -U3 -r1.11 -r1.12 --- cmp.cpp 1 Aug 2005 19:46:53 -0000 1.11 +++ cmp.cpp 15 Sep 2005 16:33:29 -0000 1.12 @@ -86,7 +86,7 @@ #include "../jrd/mov_proto.h" #include "../jrd/dsc_proto.h" #include "../jrd/dbg_proto.h" // DBG_supervisor -#include "../jrd/ExecuteStatement.h" +#include "../jrd/ExecStatement.h" #include "../jrd/Triggers.h" #include "../jrd/sbm.h" @@ -4656,7 +4656,7 @@ break; case nod_exec_into: - csb->csb_impure += sizeof(class ExecuteStatement); + csb->csb_impure += sizeof(ExecStatement*); break; default: Index: cvt.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/cvt.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -b -U3 -r1.4 -r1.5 --- cvt.cpp 20 Jul 2005 17:26:59 -0000 1.4 +++ cvt.cpp 15 Sep 2005 16:33:29 -0000 1.5 @@ -1146,26 +1146,31 @@ || (desc->dsc_dtype == dtype_cstring) || (desc->dsc_dtype == dtype_varying))); -/* If the value is already a string (fixed or varying), just return + /* If the value is already a string (fixed or varying), just return the address and length. */ - if (desc->dsc_dtype <= dtype_any_text) { + if (desc->dsc_dtype <= dtype_any_text) + { *address = desc->dsc_address; *ttype = INTL_TTYPE(desc); + if (desc->dsc_dtype == dtype_text) return desc->dsc_length; + if (desc->dsc_dtype == dtype_cstring) return MIN((USHORT) strlen((char *) desc->dsc_address), desc->dsc_length - 1); - if (desc->dsc_dtype == dtype_varying) { + + if (desc->dsc_dtype == dtype_varying) + { vary* varying = (vary*) desc->dsc_address; *address = reinterpret_cast<UCHAR*>(varying->vary_string); - return MIN(varying->vary_length, - (USHORT) (desc->dsc_length - sizeof(USHORT))); + + return MIN(varying->vary_length, (USHORT) (desc->dsc_length - sizeof(USHORT))); } } -/* No luck -- convert value to varying string. */ + /* No luck -- convert value to varying string. */ dsc temp_desc; MOVE_CLEAR(&temp_desc, sizeof(temp_desc)); Index: dls_proto.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/dls_proto.h,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- dls_proto.h 6 Mar 2005 23:12:04 -0000 1.2 +++ dls_proto.h 15 Sep 2005 16:33:29 -0000 1.3 @@ -26,13 +26,15 @@ #ifndef JRD_DLS_PROTO_H #define JRD_DLS_PROTO_H -#include "../jrd/sort.h" +//#include "../jrd/sort.h" +class sort_work_file; +struct mdls; CLASS(ConfObject); BOOLEAN DLS_get_temp_space(ULONG, sort_work_file*); void DLS_put_temp_space(sort_work_file*); BOOLEAN API_ROUTINE DLS_add_dir(ULONG, const TEXT *); -MDLS* DLS_get_access(ConfObject *configuration); +mdls* DLS_get_access(ConfObject *configuration); #endif // JRD_DLS_PROTO_H Index: dsc.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/dsc.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- dsc.h 20 Jan 2005 19:20:15 -0000 1.1.1.1 +++ dsc.h 15 Sep 2005 16:33:29 -0000 1.2 @@ -29,12 +29,6 @@ /* Descriptor format */ -/* WARNING ! - This run-time structure is stored in RDB$FORMATS.RDB$DESCRIPTORS. - Any modification to this structure is tantamount to an ODS change. - See MET_format() and make_format() in MET.E for enlightenment. -*/ - struct dsc { dsc() Index: exe.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/exe.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -b -U3 -r1.9 -r1.10 --- exe.cpp 1 Aug 2005 19:46:53 -0000 1.9 +++ exe.cpp 15 Sep 2005 16:33:29 -0000 1.10 @@ -76,7 +76,6 @@ #include "../jrd/blb.h" #include "../jrd/blr.h" #include "../jrd/all_proto.h" -//#include "../jrd/bookmark.h" #include "../jrd/blb_proto.h" #include "../jrd/btr_proto.h" #include "../jrd/cmp_proto.h" @@ -96,7 +95,6 @@ #include "../jrd/opt_proto.h" #include "../jrd/par_proto.h" #include "../jrd/rlck_proto.h" -//#include "../jrd/rse_proto.h" #include "../jrd/rng_proto.h" #include "../jrd/thd_proto.h" #include "../jrd/tra_proto.h" @@ -106,8 +104,7 @@ #include "../jrd/Procedure.h" #include "../jrd/Triggers.h" -//#include "../jrd/ExecuteStatement.h" -//#include "../dsql/dsql_proto.h" +#include "../jrd/ExecStatement.h" #include "../jrd/rpb_chain.h" // StatusXcp class implementation @@ -2264,7 +2261,7 @@ node = receive_msg(tdbb, node); break; -#ifdef TOTALLY_BROKEN /* this needs to be rewritten with the DSQL */ +#ifdef NOT_YET_IMPLEMENTED case nod_exec_sql: if (request->req_operation == req_unwind) { @@ -2279,18 +2276,23 @@ node = node->nod_parent; break; +#endif NOT_YET_IMPLEMENTED case nod_exec_into: { - ExecuteStatement *impure = (ExecuteStatement*) IMPURE (request, node->nod_impure); + ExecStatement *exec = *(ExecStatement**) IMPURE (request, node->nod_impure); + + if (!exec) + exec = request->getExecStatement(); switch (request->req_operation) { case req_evaluate: - impure->Open(tdbb, node->nod_arg[0], node->nod_count - 2, (!node->nod_arg[1])); + //impure->Open(tdbb, node->nod_arg[0], node->nod_count - 2, (!node->nod_arg[1])); + exec->open(node->nod_arg[0], !node->nod_arg[1]); case req_return: case req_sync: - if (impure->Fetch(tdbb, &node->nod_arg[2])) + if (exec->fetch(node->nod_arg[2])) { request->req_operation = req_evaluate; node = node->nod_arg[1]; @@ -2299,12 +2301,11 @@ request->req_operation = req_return; default: // if have active opened request - close it - impure->Close(tdbb); + exec->close(); node = node->nod_parent; } } break; -#endif //TOTALLY_BROKEN this needs to be rewritten with the DSQL case nod_post: { Index: jrd.vcproj =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/jrd.vcproj,v retrieving revision 1.16 retrieving revision 1.17 diff -b -U3 -r1.16 -r1.17 --- jrd.vcproj 8 Sep 2005 23:17:35 -0000 1.16 +++ jrd.vcproj 15 Sep 2005 16:33:29 -0000 1.17 @@ -280,23 +280,6 @@ RelativePath=".\BlrPrint.cpp"> </File> <File - RelativePath="blrtable.cpp"> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="" - BasicRuntimeChecks="3"/> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32"> - <Tool - Name="VCCLCompilerTool" - Optimization="2"/> - </FileConfiguration> - </File> - <File RelativePath="btn.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -757,6 +740,9 @@ </FileConfiguration> </File> <File + RelativePath=".\ExecStatement.cpp"> + </File> + <File RelativePath=".\ExecutionPathInfoGen.cpp"> </File> <File @@ -2598,6 +2584,9 @@ RelativePath="exe_proto.h"> </File> <File + RelativePath=".\ExecStatement.h"> + </File> + <File RelativePath="ExecuteStatement.h"> </File> <File Index: par.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/par.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -b -U3 -r1.8 -r1.9 --- par.cpp 29 Jul 2005 16:59:56 -0000 1.8 +++ par.cpp 15 Sep 2005 16:33:29 -0000 1.9 @@ -40,7 +40,6 @@ #include "../jrd/common.h" #include <stdarg.h> #include "../jrd/jrd.h" -//#include "../jrd/y_ref.h" #include "../jrd/ibase.h" #include "../jrd/val.h" #include "../jrd/align.h" @@ -477,11 +476,12 @@ **************************************/ //SET_TDBB(tdbb); -/* Count the number of nodes */ + /* Count the number of nodes */ + USHORT count = 0; - for (const lls* temp = stack; temp; count++) { + + for (const lls* temp = stack; temp; count++) temp = temp->lls_next; - } jrd_nod* node = PAR_make_node(tdbb, count); node->nod_type = nod_list; @@ -576,15 +576,14 @@ const char* p = name; - while (*p && *p != ' ') { + while (*p && *p != ' ') p++; - } + const size_t length = p - name; - for (int i = 0; codes[i].code_number; ++i) { - if (!strncmp(name, codes[i].code_string, length)) { + + for (int i = 0; codes[i].code_number; ++i) + if (!strncmp(name, codes[i].code_string, length)) return codes[i].code_number; - } - } return 0; } @@ -607,7 +606,8 @@ int type; va_list args; -/* Don't bother to pass tdbb for error handling */ + /* Don't bother to pass tdbb for error handling */ + thread_db* tdbb = GET_THREAD_DATA; VA_START(args, csb); @@ -623,11 +623,11 @@ *p++ = isc_arg_gds; *p++ = va_arg(args, ISC_STATUS); -/* Pick up remaining args */ + /* Pick up remaining args */ while ( (*p++ = type = va_arg(args, int)) ) + switch (type) { - switch (type) { case isc_arg_gds: *p++ = (ISC_STATUS) va_arg(args, ISC_STATUS); break; @@ -654,9 +654,8 @@ *p++ = va_arg(args, int); break; } - } -/* Give up whatever we were doing and return to the user. */ + /* Give up whatever we were doing and return to the user. */ ERR_punt(); } @@ -697,11 +696,10 @@ node->nod_type = nod_list; jrd_nod** ptr = node->nod_arg; - if (count) { + if (count) do { *ptr++ = parse(tdbb, csb, expected); } while (--count); - } return node; } @@ -770,7 +768,8 @@ PsqlException* exception_list = FB_NEW_RPT(*tdbb->tdbb_default, 1) PsqlException(); exception_list->xcp_count = 1; - switch (code_type) { + switch (code_type) + { case blr_sql_code: exception_list->xcp_rpt[0].xcp_type = xcp_sql_code; exception_list->xcp_rpt[0].xcp_code = (SSHORT) BLR_WORD; @@ -830,14 +829,17 @@ //SET_TDBB(tdbb); -/* allocate a node to represent the conditions list */ + /* allocate a node to represent the conditions list */ const USHORT n = BLR_WORD; PsqlException* exception_list = FB_NEW_RPT(*tdbb->tdbb_default, n) PsqlException(); exception_list->xcp_count = n; - for (int i = 0; i < n; i++) { + + for (int i = 0; i < n; i++) + { const USHORT code_type = BLR_BYTE; - switch (code_type) { + switch (code_type) + { case blr_sql_code: exception_list->xcp_rpt[i].xcp_type = xcp_sql_code; exception_list->xcp_rpt[i].xcp_code = (SSHORT) BLR_WORD; @@ -846,27 +848,27 @@ case blr_gds_code: exception_list->xcp_rpt[i].xcp_type = xcp_gds_code; par_name(csb, name); + for (p = name; *p; *p++) *p = LOWWER(*p); + code_number = PAR_symbol_to_gdscode(name); if (code_number) exception_list->xcp_rpt[i].xcp_code = code_number; else - error(csb, isc_codnotdef, - isc_arg_string, ERR_cstring(name), 0); + error(csb, isc_codnotdef, isc_arg_string, ERR_cstring(name), 0); break; case blr_exception: exception_list->xcp_rpt[i].xcp_type = xcp_xcp_code; par_name(csb, name); - if (!(exception_list->xcp_rpt[i].xcp_code = - MET_lookup_exception_number(tdbb, name))) - error(csb, isc_xcpnotdef, - isc_arg_string, ERR_cstring(name), 0); + + if (!(exception_list->xcp_rpt[i].xcp_code = MET_lookup_exception_number(tdbb, name))) + error(csb, isc_xcpnotdef, isc_arg_string, ERR_cstring(name), 0); + dep_node = PAR_make_node(tdbb, e_dep_length); dep_node->nod_type = nod_dependency; - dep_node->nod_arg[e_dep_object] = - (JRD_NOD) (long) exception_list->xcp_rpt[0].xcp_code; + dep_node->nod_arg[e_dep_object] = (JRD_NOD) (long) exception_list->xcp_rpt[0].xcp_code; dep_node->nod_arg[e_dep_object_type] = (JRD_NOD) obj_exception; csb->csb_dependencies.push(dep_node); break; @@ -902,13 +904,14 @@ **************************************/ const SSHORT stream = csb->csb_n_stream++; - if (stream > MAX_STREAMS) { + + if (stream > MAX_STREAMS) // TMN: Someone please review this to verify that // isc_too_many_contexts is indeed the right error to report. // "Too many streams" would probably be more correct, but we /// don't have such an error (yet). error(csb, isc_too_many_contexts, 0); - } + fb_assert(stream <= MAX_STREAMS); const SSHORT context = (unsigned int) BLR_BYTE; CMP_csb_element(csb, stream); @@ -948,18 +951,20 @@ jrd_nod* node = PAR_make_node(tdbb, e_dep_length); node->nod_type = nod_dependency; - if (csb->csb_rpt[stream].csb_relation) { - node->nod_arg[e_dep_object] = - (JRD_NOD) csb->csb_rpt[stream].csb_relation; + + if (csb->csb_rpt[stream].csb_relation) + { + node->nod_arg[e_dep_object] = (JRD_NOD) csb->csb_rpt[stream].csb_relation; node->nod_arg[e_dep_object_type] = (JRD_NOD) obj_relation; } - else if (csb->csb_rpt[stream].csb_procedure) { - node->nod_arg[e_dep_object] = - (JRD_NOD) csb->csb_rpt[stream].csb_procedure; + else if (csb->csb_rpt[stream].csb_procedure) + { + node->nod_arg[e_dep_object] = (JRD_NOD) csb->csb_rpt[stream].csb_procedure; node->nod_arg[e_dep_object_type] = (JRD_NOD) obj_procedure; } - if (field_name) { + if (field_name) + { jrd_nod* field_node = PAR_make_node(tdbb, 1); node->nod_arg[e_dep_field] = field_node; field_node->nod_type = nod_literal; @@ -969,7 +974,8 @@ strcpy(reinterpret_cast<char*>(string->str_data), field_name); field_node->nod_arg[0] = (JRD_NOD) string->str_data; } - else if (id >= 0) { + else if (id >= 0) + { jrd_nod* field_node = PAR_make_node(tdbb, 1); node->nod_arg[e_dep_field] = field_node; field_node->nod_type = nod_field; @@ -1038,7 +1044,7 @@ **************************************/ //SET_TDBB(tdbb); -/* Fake RSE */ + /* Fake RSE */ for_node->nod_arg[e_for_re] = PAR_make_node(tdbb, 1 + rse_delta + 2); RecordSelExpr* rse = (RecordSelExpr*) for_node->nod_arg[e_for_re]; @@ -1048,7 +1054,7 @@ jrd_nod* relation = parse(tdbb, csb, RELATION); rse->rse_relation[0] = relation; -/* Fake boolean */ + /* Fake boolean */ jrd_nod* node = rse->rse_boolean = PAR_make_node(tdbb, 2); node->nod_type = nod_eql; @@ -1060,7 +1066,7 @@ node->nod_count = 0; node->nod_arg[0] = relation->nod_arg[e_rel_stream]; -/* Pick up statement */ + /* Pick up statement */ for_node->nod_arg[e_for_statement] = parse(tdbb, csb, STATEMENT); @@ -1309,7 +1315,8 @@ const UCHAR* q = csb->csb_running; SSHORT l = desc.dsc_length; - switch (desc.dsc_dtype) { + switch (desc.dsc_dtype) + { case dtype_short: l = 2; *(SSHORT *) p = (SSHORT) gds__vax_integer(q, l); @@ -1340,18 +1347,21 @@ numeric literal - the value is passed as if it were a text string. Convert the numeric string to its binary value (int64, long or double as appropriate). */ + l = BLR_WORD; q = csb->csb_running; - dtype = - CVT_get_numeric(q, l, &scale, (double *) p, ERR_post); + dtype = CVT_get_numeric(q, l, &scale, (double *) p, ERR_post); literal->lit_desc.dsc_dtype = dtype; + if (dtype == dtype_double) literal->lit_desc.dsc_length = sizeof(double); - else if (dtype == dtype_long) { + else if (dtype == dtype_long) + { literal->lit_desc.dsc_length = sizeof(SLONG); literal->lit_desc.dsc_scale = (SCHAR) scale; } - else { + else + { literal->lit_desc.dsc_length = sizeof(SINT64); literal->lit_desc.dsc_scale = (SCHAR) scale; } @@ -1360,11 +1370,11 @@ case dtype_text: { SSHORT ct = l; - if (ct) { + + if (ct) do { *p++ = *q++; } while (--ct); - } break; } @@ -1398,12 +1408,12 @@ SSHORT count = BLR_WORD; lls* map = NULL; - while (--count >= 0) { + while (--count >= 0) + { jrd_nod* assignment = PAR_make_node(tdbb, e_asgn_length); assignment->nod_type = nod_assignment; assignment->nod_count = e_asgn_length; - assignment->nod_arg[e_asgn_to] = - PAR_gen_field(tdbb, stream, BLR_WORD); + assignment->nod_arg[e_asgn_to] = PAR_gen_field(tdbb, stream, BLR_WORD); assignment->nod_arg[e_asgn_from] = parse(tdbb, csb, VALUE); LLS_PUSH(assignment, &map); } @@ -2276,48 +2286,47 @@ * **************************************/ TEXT name[32]; + const SSHORT op = BLR_BYTE; - //SET_TDBB(tdbb); - - const SSHORT operator_ = BLR_BYTE; - - if (operator_ < 0 || operator_ >= FB_NELEM(type_table)) { + if (op < 0 || op >= FB_NELEM(type_table)) syntax_error(csb, "invalid BLR code"); - } - const SSHORT sub_type = sub_type_table[operator_]; + const SSHORT sub_type = sub_type_table[op]; - if (expected && (expected != type_table[operator_])) { - if (expected_optional) { - if (expected_optional != type_table[operator_]) { + if (expected && (expected != type_table[op])) + if (expected_optional) + { + if (expected_optional != type_table[op]) syntax_error(csb, elements[expected]); } - } - else { + else syntax_error(csb, elements[expected]); - } - } -/* If there is a length given in the length table, pre-allocate + /* If there is a length given in the length table, pre-allocate the node and set its count. This saves an enormous amount of repetitive code. */ - jrd_nod* node; - jrd_nod** arg; - USHORT n = length_table[operator_]; - if (n) { + jrd_nod *node; + jrd_nod **arg; + jrd_nod *list; + USHORT n = length_table[op]; + + if (n) + { node = PAR_make_node(tdbb, n); - node->nod_count = count_table[operator_]; + node->nod_count = count_table[op]; arg = node->nod_arg; } - else { + else + { node = NULL; arg = NULL; }; -/* Dispatch on operator type. */ + /* Dispatch on operator type. */ - switch (operator_) { + switch (op) + { case blr_any: case blr_unique: case blr_ansi_any: @@ -2381,7 +2390,9 @@ break; case blr_exec_into: - n = BLR_WORD + 2 /*e_exec_into_count - 1*/ ; + { + /*** + n = BLR_WORD + 2; //e_exec_into_count - 1 node = PAR_make_node(tdbb, n); arg = node->nod_arg; *arg++ = parse(tdbb, csb, VALUE); @@ -2389,8 +2400,23 @@ *arg++ = 0; else *arg++ = parse(tdbb, csb, STATEMENT); - for (n = 2/*e_exec_into_list*/; n < node->nod_count; n++) + for (n = 2; n < node->nod_count; n++) // e_exec_into_list *arg++ = parse(tdbb, csb, VALUE); + ***/ + n = BLR_WORD; // number of items in "into list" + node->nod_arg[0] = parse(tdbb, csb, VALUE); // SQL string + + if (BLR_BYTE) // singleton + node->nod_arg[1] = 0; + else + node->nod_arg[1] = parse(tdbb, csb, STATEMENT); // body + + list = node->nod_arg[2] = PAR_make_node(tdbb, n); // value targets + list->nod_type = nod_list; + + for (int i = 0; i < n; i++) + list->nod_arg[i] = parse(tdbb, csb, VALUE); + } break; case blr_post_arg: @@ -2419,8 +2445,10 @@ case blr_store2: node->nod_arg[e_sto_relation] = parse(tdbb, csb, RELATION); node->nod_arg[e_sto_statement] = parse(tdbb, csb, sub_type); - if (operator_ == blr_store2) + + if (op == blr_store2) node->nod_arg[e_sto_statement2] = parse(tdbb, csb, sub_type); + break; /* Comparison operators */ @@ -2442,10 +2470,11 @@ case blr_erase: n = BLR_BYTE; + if (n >= csb->csb_rpt.getCount() || !(csb->csb_rpt[n].csb_flags & csb_used)) error(csb, isc_ctxnotdef, 0); - node->nod_arg[e_erase_stream] = - (JRD_NOD) (long) csb->csb_rpt[n].csb_stream; + + node->nod_arg[e_erase_stream] = (JRD_NOD) (long) csb->csb_rpt[n].csb_stream; break; case blr_modify: @@ -2454,12 +2483,12 @@ case blr_exec_proc: //case blr_exec_pid: - node = par_exec_proc(tdbb, csb, operator_); + node = par_exec_proc(tdbb, csb, op); break; //case blr_pid: case blr_procedure: - node = par_procedure(tdbb, csb, operator_); + node = par_procedure(tdbb, csb, op); break; case blr_function: @@ -2475,11 +2504,11 @@ if (BLR_PEEK == (UCHAR) blr_stall) node->nod_arg[e_for_stall] = parse(tdbb, csb, STATEMENT); - if (BLR_PEEK == (UCHAR) blr_rse || - BLR_PEEK == (UCHAR) blr_singular) + if (BLR_PEEK == (UCHAR) blr_rse || BLR_PEEK == (UCHAR) blr_singular) node->nod_arg[e_for_re] = parse(tdbb, csb, TYPE_RSE); else - node->nod_arg[e_for_re] = par_rse(tdbb, csb, operator_); + node->nod_arg[e_for_re] = par_rse(tdbb, csb, op); + node->nod_arg[e_for_statement] = parse(tdbb, csb, sub_type); break; @@ -2492,10 +2521,13 @@ n = BLR_BYTE; node->nod_arg[e_cursor_stmt_op] = (JRD_NOD) (IPTR) n; node->nod_arg[e_cursor_stmt_number] = (JRD_NOD) (IPTR) BLR_WORD; - switch (n) { + + switch (n) + { case blr_cursor_open: case blr_cursor_close: break; + case blr_cursor_fetch: #ifdef SCROLLABLE_CURSORS if (BLR_PEEK == blr_seek) @@ -2503,6 +2535,7 @@ #endif node->nod_arg[e_cursor_stmt_into] = parse(tdbb, csb, STATEMENT); break; + default: syntax_error(csb, "cursor operation clause"); } @@ -2510,7 +2543,7 @@ case blr_rse: case blr_rs_stream: - node = par_rse(tdbb, csb, operator_); + node = par_rse(tdbb, csb, op); break; case blr_singular: @@ -2522,7 +2555,7 @@ case blr_rid: case blr_relation2: case blr_rid2: - node = par_relation(tdbb, csb, operator_, TRUE); + node = par_relation(tdbb, csb, op, TRUE); break; case blr_union: @@ -2534,8 +2567,7 @@ fb_assert((int) (IPTR)node->nod_arg[e_agg_stream] <= MAX_STREAMS); node->nod_arg[e_agg_rse] = parse(tdbb, csb, TYPE_RSE); node->nod_arg[e_agg_group] = parse(tdbb, csb, OTHER); - node->nod_arg[e_agg_map] = - par_map(tdbb, csb, (USHORT)(long) node->nod_arg[e_agg_stream]); + node->nod_arg[e_agg_map] = par_map(tdbb, csb, (USHORT)(long) node->nod_arg[e_agg_stream]); break; case blr_group_by: @@ -2544,7 +2576,7 @@ case blr_field: case blr_fid: - node = par_field(tdbb, csb, operator_); + node = par_field(tdbb, csb, op); break; case blr_gen_id: @@ -2566,7 +2598,7 @@ in posting dependencies with set generator since it's DDL, so I will track only gen_id() in both dialects. */ - if ((operator_ == blr_gen_id) && (csb->csb_g_flags & csb_get_dependencies)) + if ((op == blr_gen_id) && (csb->csb_g_flags & csb_get_dependencies)) { JRD_NOD dep_node = PAR_make_node (tdbb, e_dep_length); dep_node->nod_type = nod_dependency; @@ -2654,7 +2686,7 @@ if (n >= format->fmt_count) error(csb, isc_badparnum, 0); - if (operator_ != blr_parameter) + if (op != blr_parameter) { jrd_nod* temp = PAR_make_node(tdbb, e_arg_length); node->nod_arg[e_arg_flag] = temp; @@ -2669,7 +2701,7 @@ error(csb, isc_badparnum, 0); } - if (operator_ == blr_parameter3) + if (op == blr_parameter3) { jrd_nod* temp = PAR_make_node(tdbb, e_arg_length); node->nod_arg[e_arg_indicator] = temp; @@ -2694,11 +2726,14 @@ { lls* stack = NULL; - while (BLR_PEEK != (UCHAR) blr_end) { - if (operator_ == blr_select && BLR_PEEK != blr_receive) + while (BLR_PEEK != (UCHAR) blr_end) + { + if (op == blr_select && BLR_PEEK != blr_receive) syntax_error(csb, "blr_receive"); + LLS_PUSH(parse(tdbb, csb, sub_type), &stack); } + BLR_BYTE; node = PAR_make_list(tdbb, stack); } @@ -2709,8 +2744,10 @@ lls* stack = NULL; node->nod_arg[e_blk_action] = parse(tdbb, csb, sub_type); + while (BLR_PEEK != (UCHAR) blr_end) LLS_PUSH(parse(tdbb, csb, sub_type), &stack); + BLR_BYTE; node->nod_arg[e_blk_handlers] = PAR_make_list(tdbb, stack); } @@ -2725,21 +2762,24 @@ { const bool flag = (BLR_PEEK == blr_exception_msg); node->nod_arg[e_xcp_desc] = (JRD_NOD) par_condition(tdbb, csb); + if (flag) - { node->nod_arg[e_xcp_msg] = parse(tdbb, csb, sub_type); - } + break; } case blr_if: node->nod_arg[e_if_boolean] = parse(tdbb, csb, BOOL); node->nod_arg[e_if_true] = parse(tdbb, csb, sub_type); - if (BLR_PEEK == (UCHAR) blr_end) { + + if (BLR_PEEK == (UCHAR) blr_end) + { node->nod_count = 2; BLR_BYTE; break; } + node->nod_arg[e_if_false] = parse(tdbb, csb, sub_type); break; @@ -2756,19 +2796,19 @@ case blr_maximum: case blr_minimum: case blr_count: -/* count2 + /* count2 case blr_count2: -*/ + */ case blr_average: case blr_total: case blr_from: case blr_via: node->nod_arg[e_stat_rse] = parse(tdbb, csb, TYPE_RSE); - if (operator_ != blr_count) + if (op != blr_count) node->nod_arg[e_stat_value] = parse(tdbb, csb, VALUE); - if (operator_ == blr_via) + if (op == blr_via) node->nod_arg[e_stat_default] = parse(tdbb, csb, VALUE); break; @@ -2785,9 +2825,9 @@ } if (csb->csb_g_flags & csb_blr_version4) - node->nod_type = (NOD_T) (USHORT) blr_table4[(int) operator_]; + node->nod_type = (NOD_T) (USHORT) blr_table4[(int) op]; else - node->nod_type = (NOD_T) (USHORT) blr_table[(int) operator_]; + node->nod_type = (NOD_T) (USHORT) blr_table[(int) op]; return node; } |