|
From: <asf...@us...> - 2010-12-04 22:15:15
|
Revision: 52024
http://firebird.svn.sourceforge.net/firebird/?rev=52024&view=rev
Author: asfernandes
Date: 2010-12-04 22:15:03 +0000 (Sat, 04 Dec 2010)
Log Message:
-----------
Finish the statements refactor in the engine. Get rid of jrd_nod.
Modified Paths:
--------------
firebird/trunk/builds/mac_os_x/CS/CS.pbproj/project.pbxproj
firebird/trunk/builds/posix/Makefile.in
firebird/trunk/builds/posix/make.defaults
firebird/trunk/builds/posix/make.shared.targets
firebird/trunk/builds/posix/make.shared.variables
firebird/trunk/builds/win32/clean_all.bat
firebird/trunk/builds/win32/make_boot.bat
firebird/trunk/builds/win32/msvc7/engine.vcproj
firebird/trunk/builds/win32/msvc7/engine_classic.vcproj
firebird/trunk/builds/win32/msvc7/engine_embed.vcproj
firebird/trunk/builds/win32/msvc8/engine.vcproj
firebird/trunk/builds/win32/msvc9/engine.vcproj
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/dsql/AggNodes.cpp
firebird/trunk/src/dsql/BoolNodes.cpp
firebird/trunk/src/dsql/BoolNodes.h
firebird/trunk/src/dsql/ExprNodes.cpp
firebird/trunk/src/dsql/ExprNodes.h
firebird/trunk/src/dsql/Nodes.h
firebird/trunk/src/dsql/StmtNodes.cpp
firebird/trunk/src/dsql/StmtNodes.h
firebird/trunk/src/dsql/Visitors.h
firebird/trunk/src/dsql/WinNodes.cpp
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/jrd/Attachment.h
firebird/trunk/src/jrd/ExtEngineManager.h
firebird/trunk/src/jrd/Function.epp
firebird/trunk/src/jrd/JrdStatement.cpp
firebird/trunk/src/jrd/JrdStatement.h
firebird/trunk/src/jrd/RecordSourceNodes.cpp
firebird/trunk/src/jrd/RecordSourceNodes.h
firebird/trunk/src/jrd/Relation.h
firebird/trunk/src/jrd/btr.h
firebird/trunk/src/jrd/cmp.cpp
firebird/trunk/src/jrd/cmp_proto.h
firebird/trunk/src/jrd/dfw.epp
firebird/trunk/src/jrd/evl.cpp
firebird/trunk/src/jrd/exe.cpp
firebird/trunk/src/jrd/exe.h
firebird/trunk/src/jrd/exe_proto.h
firebird/trunk/src/jrd/ext_proto.h
firebird/trunk/src/jrd/extds/ExtDS.cpp
firebird/trunk/src/jrd/extds/ExtDS.h
firebird/trunk/src/jrd/inf.cpp
firebird/trunk/src/jrd/jrd.cpp
firebird/trunk/src/jrd/jrd.h
firebird/trunk/src/jrd/lls.h
firebird/trunk/src/jrd/met.epp
firebird/trunk/src/jrd/met_proto.h
firebird/trunk/src/jrd/opt_proto.h
firebird/trunk/src/jrd/par.cpp
firebird/trunk/src/jrd/par_proto.h
firebird/trunk/src/jrd/pcmet.epp
firebird/trunk/src/jrd/recsrc/ProcedureScan.cpp
firebird/trunk/src/jrd/recsrc/RecordSource.h
firebird/trunk/src/jrd/req.h
firebird/trunk/src/jrd/rse.h
firebird/trunk/src/jrd/trace/TraceObjects.cpp
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Removed Paths:
-------------
firebird/trunk/builds/win32/blrtable.bat
firebird/trunk/src/jrd/nod.h
firebird/trunk/src/misc/blrtable.cpp
Modified: firebird/trunk/builds/mac_os_x/CS/CS.pbproj/project.pbxproj
===================================================================
--- firebird/trunk/builds/mac_os_x/CS/CS.pbproj/project.pbxproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/mac_os_x/CS/CS.pbproj/project.pbxproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -1951,11 +1951,6 @@
path = autoconfig_msvc.h;
refType = 4;
};
- F616C4560200B0CF01EF0ADE = {
- isa = PBXFileReference;
- path = blrtable.h;
- refType = 4;
- };
F616C4580200B0CF01EF0ADE = {
isa = PBXFileReference;
path = codetext.h;
@@ -3801,16 +3796,6 @@
path = blr.h;
refType = 4;
};
- F616C5820200B0CF01EF0ADE = {
- isa = PBXFileReference;
- path = blrtable.cpp;
- refType = 4;
- };
- F616C5830200B0CF01EF0ADE = {
- isa = PBXFileReference;
- path = blrtable.h;
- refType = 4;
- };
F616C5860200B0CF01EF0ADE = {
children = (
F616C5870200B0CF01EF0ADE,
Modified: firebird/trunk/builds/posix/Makefile.in
===================================================================
--- firebird/trunk/builds/posix/Makefile.in 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/posix/Makefile.in 2010-12-04 22:15:03 UTC (rev 52024)
@@ -145,7 +145,7 @@
# gpre_boot
#
-boot: $(GPRE_BOOT) $(SRC_ROOT)/include/gen/blrtable.h
+boot: $(GPRE_BOOT)
$(GPRE_BOOT): $(GPRE_Boot_Objects) $(COMMON_LIB)
$(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
@@ -554,7 +554,6 @@
-$(RM) $(GEN_ROOT)/examples/Make*
$(RM) $(ROOT)/Makefile
$(RM) $(SRC_ROOT)/include/gen/autoconfig.h
- $(RM) $(SRC_ROOT)/include/gen/blrtable.h
clean_gpre_gen:
-$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.cpp' -print`
Modified: firebird/trunk/builds/posix/make.defaults
===================================================================
--- firebird/trunk/builds/posix/make.defaults 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/posix/make.defaults 2010-12-04 22:15:03 UTC (rev 52024)
@@ -200,9 +200,7 @@
# From jrd
-BLRTABLE = $(BIN)/blrtable$(EXEC_EXT)
-
# The firebird shared library name
# SD: This name is also hard-coded in builds/install/.../linux/classic scripts.
# Scold me, but I don't want library names to be in configure.in
Modified: firebird/trunk/builds/posix/make.shared.targets
===================================================================
--- firebird/trunk/builds/posix/make.shared.targets 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/posix/make.shared.targets 2010-12-04 22:15:03 UTC (rev 52024)
@@ -57,17 +57,9 @@
#$(SRC_ROOT)/qli/meta.cpp $(SRC_ROOT)/qli/proc.cpp $(SRC_ROOT)/qli/show.cpp: yachts.lnk
#$(SRC_ROOT)/qli/help.cpp: help.fdb
-# Explicit dependencies on generated header
-$(OBJ)/jrd/par.o: $(SRC_ROOT)/include/gen/blrtable.h
-
# Explicit dependence on generated header (parser)
$(OBJ)/dsql/Parser.o $(OBJ)/yvalve/keywords.o $(OBJ)/dsql/dsql.o: $(SRC_ROOT)/include/gen/parse.h
-$(OBJ)/dsql/AggNodes.o: $(SRC_ROOT)/include/gen/blrtable.h
-$(OBJ)/dsql/ExprNodes.o: $(SRC_ROOT)/include/gen/blrtable.h
-$(OBJ)/dsql/StmtNodes.o: $(SRC_ROOT)/include/gen/blrtable.h
-$(OBJ)/dsql/WinNodes.o: $(SRC_ROOT)/include/gen/blrtable.h
-
# Special cases for building cpp from epp
$(OBJ)/dsql/metd.cpp: $(SRC_ROOT)/dsql/metd.epp
$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@
@@ -78,13 +70,6 @@
$(OBJ)/dsql/PackageNodes.cpp: $(SRC_ROOT)/dsql/PackageNodes.epp
$(GPRE_CURRENT) $(JRD_GPRE_FLAGS) $< $@
-# Rebuild blrtable.h
-$(SRC_ROOT)/include/gen/blrtable.h: $(BLRTABLE)
- $(BLRTABLE) > $(SRC_ROOT)/include/gen/blrtable.h
-
-$(BLRTABLE): $(BLRTABLE_Objects)
- $(STATICEXE_LINK) $(LINK_OPTS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
-
# Adding resources as prerequisite for some files
$(FilesToAddVersionInfo): $(GEN_ROOT)/jrd/version.res
Modified: firebird/trunk/builds/posix/make.shared.variables
===================================================================
--- firebird/trunk/builds/posix/make.shared.variables 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/posix/make.shared.variables 2010-12-04 22:15:03 UTC (rev 52024)
@@ -192,9 +192,3 @@
BUILD_Objects:= $(call makeObjects,msgs,build_file.epp)
AllObjects += $(BUILD_Objects)
-
-
-# BLR
-BLRTABLE_Objects = $(call makeObjects,misc,blrtable.cpp)
-
-AllObjects += $(BLRTABLE_Objects)
Deleted: firebird/trunk/builds/win32/blrtable.bat
===================================================================
--- firebird/trunk/builds/win32/blrtable.bat 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/blrtable.bat 2010-12-04 22:15:03 UTC (rev 52024)
@@ -1,19 +0,0 @@
-@echo off
-
-@cl -Ob2iytp -Gs -DWIN95 -W3 -G4 -Gd -MD -I..\..\src\include -I..\..\src\include\gen -DSUPERSERVER -DNOMSG -D_X86_=1 -DWIN32 -DI386 ..\..\src\misc\blrtable.cpp > blrtable_%FB_TARGET_PLATFORM%.log 2>&1
-@if errorlevel 1 goto :ERROR
-@blrtable.exe > blrtable.h
-@copy blrtable.h ..\..\src\include\gen\blrtable.h > nul
-@del blrtable.exe
-@del blrtable.obj
-@del blrtable.h
-
-goto :EOF
-
-
-:ERROR
-@echo.
-@echo A compiler error occurred.
-@echo.
-goto :EOF
-
Modified: firebird/trunk/builds/win32/clean_all.bat
===================================================================
--- firebird/trunk/builds/win32/clean_all.bat 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/clean_all.bat 2010-12-04 22:15:03 UTC (rev 52024)
@@ -45,7 +45,6 @@
if defined FB_CLEAN_SHARED (
@echo Cleaning shared gen and dsql files...
@del %FB_ROOT_PATH%\src\include\gen\autoconfig.h 2>nul
-@del %FB_ROOT_PATH%\src\include\gen\blrtable.h 2>nul
@del %FB_ROOT_PATH%\src\dsql\dsql.tab.h 2>nul
@del %FB_ROOT_PATH%\src\dsql\parse.cpp 2>nul
)
Modified: firebird/trunk/builds/win32/make_boot.bat
===================================================================
--- firebird/trunk/builds/win32/make_boot.bat 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/make_boot.bat 2010-12-04 22:15:03 UTC (rev 52024)
@@ -44,11 +44,6 @@
if "%ERRLEV%"=="1" goto :END
::=======
-@echo.
-@echo Building BLR Table
-@call blrtable.bat
-
-::=======
call :gpre_boot
if "%ERRLEV%"=="1" goto :END
Modified: firebird/trunk/builds/win32/msvc7/engine.vcproj
===================================================================
--- firebird/trunk/builds/win32/msvc7/engine.vcproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/msvc7/engine.vcproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -279,8 +279,6 @@
</File>
<File RelativePath="..\..\..\src\jrd\BlrReader.h">
</File>
- <File RelativePath="..\..\..\src\include\gen\blrtable.h">
- </File>
<File RelativePath="..\..\..\src\jrd\btn.h">
</File>
<File RelativePath="..\..\..\src\jrd\btr.h">
Modified: firebird/trunk/builds/win32/msvc7/engine_classic.vcproj
===================================================================
--- firebird/trunk/builds/win32/msvc7/engine_classic.vcproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/msvc7/engine_classic.vcproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -279,8 +279,6 @@
</File>
<File RelativePath="..\..\..\src\jrd\BlrReader.h">
</File>
- <File RelativePath="..\..\..\src\include\gen\blrtable.h">
- </File>
<File RelativePath="..\..\..\src\jrd\btn.h">
</File>
<File RelativePath="..\..\..\src\jrd\btr.h">
Modified: firebird/trunk/builds/win32/msvc7/engine_embed.vcproj
===================================================================
--- firebird/trunk/builds/win32/msvc7/engine_embed.vcproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/msvc7/engine_embed.vcproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -279,8 +279,6 @@
</File>
<File RelativePath="..\..\..\src\jrd\BlrReader.h">
</File>
- <File RelativePath="..\..\..\src\include\gen\blrtable.h">
- </File>
<File RelativePath="..\..\..\src\jrd\btn.h">
</File>
<File RelativePath="..\..\..\src\jrd\btr.h">
Modified: firebird/trunk/builds/win32/msvc8/engine.vcproj
===================================================================
--- firebird/trunk/builds/win32/msvc8/engine.vcproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/msvc8/engine.vcproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -912,10 +912,6 @@
>
</File>
<File
- RelativePath="..\..\..\src\include\gen\blrtable.h"
- >
- </File>
- <File
RelativePath="..\..\..\src\dsql\BlrWriter.h"
>
</File>
Modified: firebird/trunk/builds/win32/msvc9/engine.vcproj
===================================================================
--- firebird/trunk/builds/win32/msvc9/engine.vcproj 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/builds/win32/msvc9/engine.vcproj 2010-12-04 22:15:03 UTC (rev 52024)
@@ -912,10 +912,6 @@
>
</File>
<File
- RelativePath="..\..\..\src\include\gen\blrtable.h"
- >
- </File>
- <File
RelativePath="..\..\..\src\dsql\BlrWriter.h"
>
</File>
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2010-12-04 22:15:03 UTC (rev 52024)
@@ -1454,6 +1454,8 @@
PARAMETER (GDS__request_outdated = 335545020)
INTEGER*4 GDS__bad_events_handle
PARAMETER (GDS__bad_events_handle = 335545021)
+ INTEGER*4 GDS__cannot_copy_stmt
+ PARAMETER (GDS__cannot_copy_stmt = 335545022)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2010-12-04 22:15:03 UTC (rev 52024)
@@ -734,6 +734,7 @@
gds_private_procedure = 335545019;
gds_request_outdated = 335545020;
gds_bad_events_handle = 335545021;
+ gds_cannot_copy_stmt = 335545022;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/dsql/AggNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/AggNodes.cpp 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/AggNodes.cpp 2010-12-04 22:15:03 UTC (rev 52024)
@@ -46,8 +46,6 @@
using namespace Firebird;
using namespace Jrd;
-#include "gen/blrtable.h"
-
namespace Jrd {
Modified: firebird/trunk/src/dsql/BoolNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/BoolNodes.cpp 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/BoolNodes.cpp 2010-12-04 22:15:03 UTC (rev 52024)
@@ -45,8 +45,6 @@
using namespace Firebird;
using namespace Jrd;
-#include "gen/blrtable.h"
-
namespace Jrd {
@@ -140,7 +138,7 @@
addChildNode(dsqlArg2, arg2);
}
-BoolExprNode* BinaryBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
+DmlNode* BinaryBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
{
BinaryBoolNode* node = FB_NEW(pool) BinaryBoolNode(pool, blrOp);
node->arg1 = PAR_parse_boolean(tdbb, csb);
@@ -351,7 +349,7 @@
addChildNode(dsqlArg3, arg3);
}
-BoolExprNode* ComparativeBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
+DmlNode* ComparativeBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
{
ComparativeBoolNode* node = FB_NEW(pool) ComparativeBoolNode(pool, blrOp);
@@ -586,7 +584,7 @@
break;
}
- arg1 = CMP_pass1(tdbb, csb, arg1);
+ doPass1(tdbb, csb, arg1.getAddress());
if (invariantCheck)
{
@@ -595,11 +593,9 @@
csb->csb_current_nodes.push(this);
}
- arg2 = CMP_pass1(tdbb, csb, arg2);
+ doPass1(tdbb, csb, arg2.getAddress());
+ doPass1(tdbb, csb, arg3.getAddress());
- if (arg3)
- arg3 = CMP_pass1(tdbb, csb, arg3);
-
if (invariantCheck)
{
csb->csb_current_nodes.pop();
@@ -1347,7 +1343,7 @@
addChildNode(dsqlArg, arg);
}
-BoolExprNode* MissingBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
+DmlNode* MissingBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
{
MissingBoolNode* node = FB_NEW(pool) MissingBoolNode(pool);
node->arg = PAR_parse_value(tdbb, csb);
@@ -1429,7 +1425,7 @@
addChildNode(dsqlArg, arg);
}
-BoolExprNode* NotBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
+DmlNode* NotBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
{
NotBoolNode* node = FB_NEW(pool) NotBoolNode(pool);
node->arg = PAR_parse_boolean(tdbb, csb);
@@ -1625,7 +1621,7 @@
addChildNode(dsqlRse, rse);
}
-BoolExprNode* RseBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
+DmlNode* RseBoolNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
{
RseBoolNode* node = FB_NEW(pool) RseBoolNode(pool, blrOp);
node->rse = PAR_rse(tdbb, csb);
@@ -1698,7 +1694,10 @@
{
BoolExprNode* newNode = convertNeqAllToNotAny(tdbb, csb);
if (newNode)
- return CMP_pass1(tdbb, csb, newNode);
+ {
+ doPass1(tdbb, csb, &newNode);
+ return newNode;
+ }
nodFlags |= FLAG_DEOPTIMIZE;
}
Modified: firebird/trunk/src/dsql/BoolNodes.h
===================================================================
--- firebird/trunk/src/dsql/BoolNodes.h 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/BoolNodes.h 2010-12-04 22:15:03 UTC (rev 52024)
@@ -37,7 +37,7 @@
public:
BinaryBoolNode(MemoryPool& pool, UCHAR aBlrOp, dsql_nod* aArg1 = NULL, dsql_nod* aArg2 = NULL);
- static BoolExprNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
+ static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@@ -75,7 +75,7 @@
ComparativeBoolNode(MemoryPool& pool, UCHAR aBlrOp, dsql_nod* aArg1 = NULL,
dsql_nod* aArg2 = NULL, dsql_nod* aArg3 = NULL);
- static BoolExprNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
+ static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@@ -122,7 +122,7 @@
public:
MissingBoolNode(MemoryPool& pool, dsql_nod* aArg = NULL);
- static BoolExprNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
+ static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@@ -149,7 +149,7 @@
public:
NotBoolNode(MemoryPool& pool, dsql_nod* aArg = NULL);
- static BoolExprNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
+ static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
@@ -178,7 +178,7 @@
public:
RseBoolNode(MemoryPool& pool, UCHAR aBlrOp, dsql_nod* aDsqlRse = NULL);
- static BoolExprNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
+ static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp);
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
virtual BoolExprNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
Modified: firebird/trunk/src/dsql/ExprNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.cpp 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/ExprNodes.cpp 2010-12-04 22:15:03 UTC (rev 52024)
@@ -25,6 +25,7 @@
#include "../common/classes/VaryStr.h"
#include "../dsql/ExprNodes.h"
#include "../dsql/BoolNodes.h"
+#include "../dsql/StmtNodes.h"
#include "../dsql/node.h"
#include "../jrd/align.h"
#include "../jrd/blr.h"
@@ -59,8 +60,6 @@
using namespace Firebird;
using namespace Jrd;
-#include "gen/blrtable.h"
-
namespace Jrd {
@@ -115,18 +114,6 @@
reinterpret_cast<ExprNode*>(node->nod_arg[0]) : NULL;
}
-const ExprNode* ExprNode::fromLegacy(const jrd_nod* node)
-{
- return node && node->nod_type == nod_class_exprnode_jrd ?
- reinterpret_cast<const ExprNode*>(node->nod_arg[0]) : NULL;
-}
-
-ExprNode* ExprNode::fromLegacy(jrd_nod* node)
-{
- return node && node->nod_type == nod_class_exprnode_jrd ?
- reinterpret_cast<ExprNode*>(node->nod_arg[0]) : NULL;
-}
-
bool ExprNode::dsqlVisit(ConstDsqlNodeVisitor& visitor)
{
bool ret = false;
@@ -149,7 +136,6 @@
void ExprNode::print(string& text, Array<dsql_nod*>& nodes) const
{
- text = "ExprNode"; // needed or not?
for (dsql_nod* const* const* i = dsqlChildNodes.begin(); i != dsqlChildNodes.end(); ++i)
nodes.add(**i);
}
@@ -2613,11 +2599,11 @@
{
// ASF: Commented out code here appears correct and makes the expression
// "1 + NULLIF(NULL, 0)" (failing since v2.1) to work. While this is natural as others
- // nodes calling CMP_get_desc on sub nodes, it's causing some problem with contexts of
+ // nodes calling getDesc on sub nodes, it's causing some problem with contexts of
// views.
dsc desc1;
- ////CMP_get_desc(tdbb, csb, source, &desc1);
+ ////source->getDesc(tdbb, csb, source, &desc1);
*desc = format->fmt_desc[0];
@@ -4566,10 +4552,12 @@
}
}
- return CMP_pass1(tdbb, csb, sub); // note: scope of AutoSetRestore
+ doPass1(tdbb, csb, &sub); // note: scope of AutoSetRestore
}
+ else
+ doPass1(tdbb, csb, &sub);
- return CMP_pass1(tdbb, csb, sub);
+ return sub;
}
ValueExprNode* FieldNode::pass2(thread_db* tdbb, CompilerScratch* csb)
@@ -6302,8 +6290,8 @@
DmlNode* ParameterNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
{
- jrd_nod* message = NULL;
- USHORT n = (USHORT) csb->csb_blr_reader.getByte();
+ MessageNode* message = NULL;
+ USHORT n = csb->csb_blr_reader.getByte();
if (n >= csb->csb_rpt.getCount() || !(message = csb->csb_rpt[n].csb_message))
PAR_error(csb, Arg::Gds(isc_badmsgnum));
@@ -6313,7 +6301,7 @@
node->message = message;
node->argNumber = csb->csb_blr_reader.getWord();
- const Format* format = (Format*) message->nod_arg[e_msg_format];
+ const Format* format = message->format;
if (node->argNumber >= format->fmt_count)
PAR_error(csb, Arg::Gds(isc_badparnum));
@@ -6522,8 +6510,7 @@
void ParameterNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
{
- const Format* format = (Format*) message->nod_arg[e_msg_format];
- *desc = format->fmt_desc[argNumber];
+ *desc = message->format->fmt_desc[argNumber];
}
ValueExprNode* ParameterNode::copy(thread_db* tdbb, NodeCopier& copier)
@@ -6547,11 +6534,8 @@
// in nod_argument. If it don't, it may be an input parameter cloned
// in RseBoolNode::convertNeqAllToNotAny - see CORE-3094.
- if (copier.message &&
- (IPTR) copier.message->nod_arg[e_msg_number] == (IPTR) message->nod_arg[e_msg_number])
- {
+ if (copier.message && copier.message->messageNumber == message->messageNumber)
node->message = copier.message;
- }
else
node->message = message;
@@ -6564,7 +6548,7 @@
ValueExprNode* ParameterNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
argInfo = CMP_pass2_validation(tdbb, csb,
- Item(Item::TYPE_PARAMETER, (IPTR) message->nod_arg[e_msg_number], argNumber));
+ Item(Item::TYPE_PARAMETER, message->messageNumber, argNumber));
ValueExprNode::pass2(tdbb, csb);
@@ -6589,11 +6573,10 @@
request->req_flags |= req_null;
}
- const Format* format = (Format*) message->nod_arg[e_msg_format];
- desc = &format->fmt_desc[argNumber];
+ desc = &message->format->fmt_desc[argNumber];
impure->vlu_desc.dsc_address = request->getImpure<UCHAR>(
- message->nod_impure + (IPTR) desc->dsc_address);
+ message->impureOffset + (IPTR) desc->dsc_address);
impure->vlu_desc.dsc_dtype = desc->dsc_dtype;
impure->vlu_desc.dsc_length = desc->dsc_length;
impure->vlu_desc.dsc_scale = desc->dsc_scale;
@@ -6603,15 +6586,13 @@
INTL_adjust_text_descriptor(tdbb, &impure->vlu_desc);
USHORT* impure_flags = request->getImpure<USHORT>(
- (IPTR) message->nod_arg[e_msg_impure_flags] +
- (sizeof(USHORT) * argNumber));
+ message->impureFlags + (sizeof(USHORT) * argNumber));
if (!(*impure_flags & VLU_checked))
{
if (argInfo)
{
- EVL_validate(tdbb,
- Item(Item::TYPE_PARAMETER, (IPTR) message->nod_arg[e_msg_number], argNumber),
+ EVL_validate(tdbb, Item(Item::TYPE_PARAMETER, message->messageNumber, argNumber),
argInfo, &impure->vlu_desc, request->req_flags & req_null);
}
@@ -7266,7 +7247,7 @@
{
StmtExprNode* node = FB_NEW(pool) StmtExprNode(pool);
- node->stmt = PAR_parse_node(tdbb, csb, STATEMENT);
+ node->stmt = PAR_parse_stmt(tdbb, csb);
node->expr = PAR_parse_value(tdbb, csb);
return node;
@@ -7287,13 +7268,13 @@
ValueExprNode* StmtExprNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
- stmt = CMP_pass1(tdbb, csb, stmt);
+ doPass1(tdbb, csb, stmt.getAddress());
return ValueExprNode::pass1(tdbb, csb);
}
ValueExprNode* StmtExprNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
- stmt = CMP_pass2(tdbb, csb, stmt, NULL);
+ StmtNode::doPass2(tdbb, csb, stmt.getAddress(), NULL);
ValueExprNode::pass2(tdbb, csb);
@@ -7306,7 +7287,7 @@
dsc* StmtExprNode::execute(thread_db* tdbb, jrd_req* request) const
{
- EXE_looper(tdbb, request, stmt, true);
+ EXE_looper(tdbb, request, stmt.getObject(), true);
dsc* desc = EVL_expr(tdbb, request, expr);
@@ -8009,16 +7990,13 @@
ValueExprNode* SubQueryNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
rse->ignoreDbKey(tdbb, csb);
- rse->pass1(tdbb, csb);
+ doPass1(tdbb, csb, rse.getAddress());
csb->csb_current_nodes.push(rse.getObject());
- if (value1)
- value1 = CMP_pass1(tdbb, csb, value1);
+ doPass1(tdbb, csb, value1.getAddress());
+ doPass1(tdbb, csb, value2.getAddress());
- if (value2)
- value2 = CMP_pass1(tdbb, csb, value2);
-
csb->csb_current_nodes.pop();
return this;
@@ -8639,14 +8617,14 @@
ValueExprNode* SubstringSimilarNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
- expr = CMP_pass1(tdbb, csb, expr);
+ doPass1(tdbb, csb, expr.getAddress());
// We need to take care of invariantness expressions to be able to pre-compile the pattern.
nodFlags |= FLAG_INVARIANT;
csb->csb_current_nodes.push(this);
- pattern = CMP_pass1(tdbb, csb, pattern);
- escape = CMP_pass1(tdbb, csb, escape);
+ doPass1(tdbb, csb, pattern.getAddress());
+ doPass1(tdbb, csb, escape.getAddress());
csb->csb_current_nodes.pop();
@@ -9727,7 +9705,7 @@
DmlNode* VariableNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
{
USHORT n = csb->csb_blr_reader.getWord();
- vec<jrd_nod*>* vector = csb->csb_variables;
+ vec<DeclareVariableNode*>* vector = csb->csb_variables;
if (!vector || n >= vector->count())
PAR_syntax_error(csb, "variable identifier");
@@ -9799,7 +9777,7 @@
void VariableNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
{
- *desc = *(DSC*) (varDecl->nod_arg + e_dcl_desc);
+ *desc = varDecl->varDesc;
}
ValueExprNode* VariableNode::copy(thread_db* tdbb, NodeCopier& copier)
@@ -9821,7 +9799,7 @@
{
ValueExprNode::pass1(tdbb, csb);
- vec<jrd_nod*>* vector = csb->csb_variables;
+ vec<DeclareVariableNode*>* vector = csb->csb_variables;
if (!vector || varId >= vector->count() || !(varDecl = (*vector)[varId]))
PAR_syntax_error(csb, "variable identifier");
@@ -9843,7 +9821,7 @@
dsc* VariableNode::execute(thread_db* tdbb, jrd_req* request) const
{
impure_value* const impure = request->getImpure<impure_value>(impureOffset);
- impure_value* impure2 = request->getImpure<impure_value>(varDecl->nod_impure);
+ impure_value* impure2 = request->getImpure<impure_value>(varDecl->impureOffset);
request->req_flags &= ~req_null;
Modified: firebird/trunk/src/dsql/ExprNodes.h
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.h 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/ExprNodes.h 2010-12-04 22:15:03 UTC (rev 52024)
@@ -32,6 +32,7 @@
namespace Jrd {
struct ItemInfo;
+class DeclareVariableNode;
class RecordSource;
class ValueListNode;
@@ -783,7 +784,7 @@
public:
USHORT dsqlParameterIndex;
dsql_par* dsqlParameter;
- NestConst<jrd_nod> message;
+ NestConst<MessageNode> message;
USHORT argNumber;
NestConst<ValueExprNode> argFlag;
NestConst<ValueExprNode> argIndicator;
@@ -936,7 +937,7 @@
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const;
public:
- NestConst<jrd_nod> stmt;
+ NestConst<StmtNode> stmt;
NestConst<ValueExprNode> expr;
};
@@ -1348,7 +1349,7 @@
dsql_var* dsqlVar;
dsc varDesc;
USHORT varId;
- NestConst<jrd_nod> varDecl;
+ NestConst<DeclareVariableNode> varDecl;
NestConst<ItemInfo> varInfo;
};
Modified: firebird/trunk/src/dsql/Nodes.h
===================================================================
--- firebird/trunk/src/dsql/Nodes.h 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/Nodes.h 2010-12-04 22:15:03 UTC (rev 52024)
@@ -38,7 +38,6 @@
class Cursor;
class dsql_nod;
class ExprNode;
-class jrd_nod;
class OptimizerRetrieval;
class RseNode;
class SlidingWindow;
@@ -74,72 +73,6 @@
typedef Firebird::Array<NestConst<ValueExprNode> > NestValueArray;
-// Stores a reference to a specialized ExprNode.
-// This class and NodeRefImpl exists to nodes replace themselfs (eg. pass1) in a type-safe way.
-class NodeRef
-{
-public:
- virtual ~NodeRef()
- {
- }
-
- bool operator !() const
- {
- return !getExpr();
- }
-
- operator bool() const
- {
- return getExpr() != NULL;
- }
-
- virtual ExprNode* getExpr() = 0;
- virtual const ExprNode* getExpr() const = 0;
-
- virtual void pass1(thread_db* tdbb, CompilerScratch* csb) = 0;
- void pass2(thread_db* tdbb, CompilerScratch* csb);
-
-protected:
- virtual void internalPass2(thread_db* tdbb, CompilerScratch* csb) = 0;
-};
-
-template <typename T> class NodeRefImpl : public NodeRef
-{
-public:
- NodeRefImpl(T** aPtr)
- : ptr(aPtr)
- {
- fb_assert(aPtr);
- }
-
- virtual ExprNode* getExpr()
- {
- return *ptr;
- }
-
- virtual const ExprNode* getExpr() const
- {
- return *ptr;
- }
-
- virtual void pass1(thread_db* tdbb, CompilerScratch* csb)
- {
- if (*ptr)
- *ptr = (*ptr)->pass1(tdbb, csb);
- }
-
-protected:
- virtual void internalPass2(thread_db* tdbb, CompilerScratch* csb)
- {
- if (*ptr)
- *ptr = (*ptr)->pass2(tdbb, csb);
- }
-
-private:
- T** ptr;
-};
-
-
template <typename T>
class RegisterNode
{
@@ -275,15 +208,38 @@
class DmlNode : public Node
{
public:
- explicit DmlNode(MemoryPool& pool)
- : Node(pool)
+ // DML node kinds
+ enum Kind
{
+ KIND_STATEMENT,
+ KIND_VALUE,
+ KIND_BOOLEAN,
+ KIND_REC_SOURCE
+ };
+
+ explicit DmlNode(MemoryPool& pool, Kind aKind)
+ : Node(pool),
+ kind(aKind)
+ {
}
+ // Merge missing values, computed values, validation expressions, and views into a parsed request.
+ template <typename T> static void doPass1(thread_db* tdbb, CompilerScratch* csb, T** node)
+ {
+ if (!*node)
+ return;
+
+ *node = (*node)->pass1(tdbb, csb);
+ }
+
public:
virtual void genBlr(DsqlCompilerScratch* dsqlScratch) = 0;
virtual DmlNode* pass1(thread_db* tdbb, CompilerScratch* csb) = 0;
virtual DmlNode* pass2(thread_db* tdbb, CompilerScratch* csb) = 0;
+ virtual DmlNode* copy(thread_db* tdbb, NodeCopier& copier) = 0;
+
+public:
+ const Kind kind;
};
@@ -301,6 +257,67 @@
};
+// Stores a reference to a specialized ExprNode.
+// This class and NodeRefImpl exists to nodes replace themselfs (eg. pass1) in a type-safe way.
+class NodeRef
+{
+public:
+ virtual ~NodeRef()
+ {
+ }
+
+ bool operator !() const
+ {
+ return !getExpr();
+ }
+
+ operator bool() const
+ {
+ return getExpr() != NULL;
+ }
+
+ virtual ExprNode* getExpr() = 0;
+ virtual const ExprNode* getExpr() const = 0;
+
+ virtual void pass1(thread_db* tdbb, CompilerScratch* csb) = 0;
+ void pass2(thread_db* tdbb, CompilerScratch* csb);
+
+protected:
+ virtual void internalPass2(thread_db* tdbb, CompilerScratch* csb) = 0;
+};
+
+template <typename T> class NodeRefImpl : public NodeRef
+{
+public:
+ NodeRefImpl(T** aPtr)
+ : ptr(aPtr)
+ {
+ fb_assert(aPtr);
+ }
+
+ virtual ExprNode* getExpr()
+ {
+ return *ptr;
+ }
+
+ virtual const ExprNode* getExpr() const
+ {
+ return *ptr;
+ }
+
+ virtual void pass1(thread_db* tdbb, CompilerScratch* csb)
+ {
+ DmlNode::doPass1(tdbb, csb, ptr);
+ }
+
+protected:
+ virtual inline void internalPass2(thread_db* tdbb, CompilerScratch* csb);
+
+private:
+ T** ptr;
+};
+
+
class ExprNode : public DmlNode
{
public:
@@ -373,8 +390,8 @@
static const unsigned FLAG_DATE = 0x20;
static const unsigned FLAG_VALUE = 0x40; // Full value area required in impure space.
- explicit ExprNode(Type aType, MemoryPool& pool)
- : DmlNode(pool),
+ explicit ExprNode(Type aType, MemoryPool& pool, Kind aKind)
+ : DmlNode(pool, aKind),
type(aType),
nodFlags(0),
impureOffset(0),
@@ -428,9 +445,16 @@
}
static ExprNode* fromLegacy(const dsql_nod* node);
- static const ExprNode* fromLegacy(const jrd_nod* node);
- static ExprNode* fromLegacy(jrd_nod* node);
+ // Allocate and assign impure space for various nodes.
+ template <typename T> static void doPass2(thread_db* tdbb, CompilerScratch* csb, T** node)
+ {
+ if (!*node)
+ return;
+
+ *node = (*node)->pass2(tdbb, csb);
+ }
+
virtual bool dsqlAggregateFinder(AggregateFinder& visitor)
{
return dsqlVisit(visitor);
@@ -537,11 +561,19 @@
Firebird::Array<NodeRef*> jrdChildNodes;
};
+
+template <typename T>
+inline void NodeRefImpl<T>::internalPass2(thread_db* tdbb, CompilerScratch* csb)
+{
+ ExprNode::doPass2(tdbb, csb, ptr);
+}
+
+
class BoolExprNode : public ExprNode
{
public:
BoolExprNode(Type aType, MemoryPool& pool)
- : ExprNode(aType, pool)
+ : ExprNode(aType, pool, KIND_BOOLEAN)
{
}
@@ -578,7 +610,7 @@
{
public:
ValueExprNode(Type aType, MemoryPool& pool)
- : ExprNode(aType, pool),
+ : ExprNode(aType, pool, KIND_VALUE),
nodScale(0)
{
}
@@ -610,7 +642,9 @@
return this;
}
+ // Compute descriptor for value expression.
virtual void getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc) = 0;
+
virtual ValueExprNode* copy(thread_db* tdbb, NodeCopier& copier) = 0;
virtual dsc* execute(thread_db* tdbb, jrd_req* request) const = 0;
@@ -802,10 +836,13 @@
public:
enum Type
{
+ TYPE_ASSIGNMENT,
TYPE_BLOCK,
+ TYPE_COMPOUND_STMT,
TYPE_CONTINUE_LEAVE,
TYPE_CURSOR_STMT,
TYPE_DECLARE_CURSOR,
+ TYPE_DECLARE_VARIABLE,
TYPE_ERASE,
TYPE_ERROR_HANDLER,
TYPE_EXCEPTION,
@@ -815,11 +852,13 @@
TYPE_EXIT,
TYPE_IF,
TYPE_IN_AUTO_TRANS,
+ TYPE_INIT_VARIABLE,
TYPE_FOR,
TYPE_HANDLER,
TYPE_LABEL,
TYPE_LOOP,
TYPE_MERGE,
+ TYPE_MESSAGE,
TYPE_MODIFY,
TYPE_POST_EVENT,
TYPE_RECEIVE,
@@ -864,15 +903,16 @@
WhichTrigger whichEraseTrig;
WhichTrigger whichStoTrig;
WhichTrigger whichModTrig;
- const jrd_nod* topNode;
- const jrd_nod* prevNode;
+ const StmtNode* topNode;
+ const StmtNode* prevNode;
};
public:
explicit StmtNode(Type aType, MemoryPool& pool)
- : DmlNode(pool),
+ : DmlNode(pool, KIND_STATEMENT),
type(aType),
- node(NULL)
+ parentStmt(NULL),
+ impureOffset(0)
{
}
@@ -920,30 +960,39 @@
}
static StmtNode* fromLegacy(const dsql_nod* node);
- static const StmtNode* fromLegacy(const jrd_nod* node);
- static StmtNode* fromLegacy(jrd_nod* node);
- jrd_nod* getNode()
+ // Allocate and assign impure space for various nodes.
+ template <typename T> static void doPass2(thread_db* tdbb, CompilerScratch* csb, T** node,
+ StmtNode* parentStmt)
{
- return node;
+ if (!*node)
+ return;
+
+ if (parentStmt)
+ (*node)->parentStmt = parentStmt;
+
+ *node = (*node)->pass2(tdbb, csb);
}
- void setNode(jrd_nod* value)
+ virtual StmtNode* pass1(thread_db* tdbb, CompilerScratch* csb) = 0;
+ virtual StmtNode* pass2(thread_db* tdbb, CompilerScratch* csb) = 0;
+
+ virtual StmtNode* copy(thread_db* tdbb, NodeCopier& copier)
{
- node = value;
- }
+ fb_assert(false);
+ Firebird::status_exception::raise(
+ Firebird::Arg::Gds(isc_cannot_copy_stmt) <<
+ Firebird::Arg::Num(int(type)));
- virtual void pass2Cursor(RseNode*& /*rsePtr*/, Cursor**& /*cursorPtr*/)
- {
+ return NULL;
}
- virtual const jrd_nod* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const = 0;
+ virtual const StmtNode* execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const = 0;
public:
const Type type;
-
-protected:
- NestConst<jrd_nod> node;
+ NestConst<StmtNode> parentStmt;
+ ULONG impureOffset; // Inpure offset from request block.
};
@@ -958,21 +1007,27 @@
}
public:
- DsqlOnlyStmtNode* pass1(thread_db* /*tdbb*/, CompilerScratch* /*csb*/)
+ virtual DsqlOnlyStmtNode* pass1(thread_db* /*tdbb*/, CompilerScratch* /*csb*/)
{
fb_assert(false);
return this;
}
- DsqlOnlyStmtNode* pass2(thread_db* /*tdbb*/, CompilerScratch* /*csb*/)
+ virtual DsqlOnlyStmtNode* pass2(thread_db* /*tdbb*/, CompilerScratch* /*csb*/)
{
fb_assert(false);
return this;
}
- const jrd_nod* execute(thread_db* /*tdbb*/, jrd_req* /*request*/, ExeState* /*exeState*/) const
+ virtual DsqlOnlyStmtNode* copy(thread_db* /*tdbb*/, NodeCopier& /*copier*/)
{
fb_assert(false);
+ return this;
+ }
+
+ const StmtNode* execute(thread_db* /*tdbb*/, jrd_req* /*request*/, ExeState* /*exeState*/) const
+ {
+ fb_assert(false);
return NULL;
}
};
Modified: firebird/trunk/src/dsql/StmtNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/StmtNodes.cpp 2010-12-04 17:19:48 UTC (rev 52023)
+++ firebird/trunk/src/dsql/StmtNodes.cpp 2010-12-04 22:15:03 UTC (rev 52024)
@@ -57,9 +57,7 @@
using namespace Firebird;
using namespace Jrd;
-#include "gen/blrtable.h"
-
namespace
{
// Node copier that remaps the field id 0 of stream 0 to a given field id.
@@ -91,17 +89,19 @@
static void cleanupRpb(thread_db* tdbb, record_param* rpb);
-static jrd_nod* makeValidation(thread_db* tdbb, CompilerScratch* csb, USHORT stream);
-static jrd_nod* pass1ExpandView(thread_db* tdbb, CompilerScratch* csb, USHORT orgStream,
+static void makeValidation(thread_db* tdbb, CompilerScratch* csb, USHORT stream,
+ Array<ValidateInfo>& validations);
+static StmtNode* pass1ExpandView(thread_db* tdbb, CompilerScratch* csb, USHORT orgStream,
USHORT newStream, bool remap);
static RelationSourceNode* pass1Update(thread_db* tdbb, CompilerScratch* csb, jrd_rel* relation,
const trig_vec* trigger, USHORT stream, USHORT updateStream, SecurityClass::flags_t priv,
jrd_rel* view, USHORT viewStream);
+static void pass1Validations(thread_db* tdbb, CompilerScratch* csb, Array<ValidateInfo>& validations);
static void postTriggerAccess(CompilerScratch* csb, jrd_rel* ownerRelation,
ExternalAccess::exa_act operation, jrd_rel* view);
static void preModifyEraseTriggers(thread_db* tdbb, trig_vec** trigs,
StmtNode::WhichTrigger whichTrig, record_param* rpb, record_param* rec, jrd_req::req_ta op);
-static void validateExpressions(thread_db* tdbb, const jrd_nod* list);
+static void validateExpressions(thread_db* tdbb, const Array<ValidateInfo>& validations);
//--------------------
@@ -113,19 +113,7 @@
reinterpret_cast<StmtNode*>(node->nod_arg[0]) : NULL;
}
-const StmtNode* StmtNode::fromLegacy(const jrd_nod* node)
-{
- return node && node->nod_type == nod_class_stmtnode_jrd ?
- reinterpret_cast<const StmtNode*>(node->nod_arg[0]) : NULL;
-}
-StmtNode* StmtNode::fromLegacy(jrd_nod* node)
-{
- return node && node->nod_type == nod_class_stmtnode_jrd ?
- reinterpret_cast<StmtNode*>(node->nod_arg[0]) : NULL;
-}
-
-
//--------------------
@@ -140,7 +128,6 @@
return node;
}
-
void SavepointEncloseNode::print(string& text, Array<dsql_nod*>& nodes) const
{
text = "SavepointEncloseNode\n";
@@ -149,7 +136,6 @@
text += s;
}
-
void SavepointEncloseNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blr_begin);
@@ -163,17 +149,131 @@
//--------------------
+static RegisterNode<AssignmentNode> regAssignmentNode(blr_assignment);
+
+DmlNode* AssignmentNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp)
+{
+ AssignmentNode* node = FB_NEW(pool) AssignmentNode(pool);
+ node->asgnFrom = PAR_parse_value(tdbb, csb);
+ node->asgnTo = PAR_parse_value(tdbb, csb);
+ return node;
+}
+
+AssignmentNode* AssignmentNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
+{
+ return this;
+}
+
+void AssignmentNode::print(string& text, Array<dsql_nod*>& nodes) const
+{
+ text = "AssignmentNode";
+}
+
+void AssignmentNode::genBlr(DsqlCompilerScratch* dsqlScratch)
+{
+}
+
+AssignmentNode* AssignmentNode::copy(thread_db* tdbb, NodeCopier& copier)
+{
+ AssignmentNode* node = FB_NEW(*tdbb->getDefaultPool()) AssignmentNode(*tdbb->getDefaultPool());
+ node->asgnFrom = copier.copy(tdbb, asgnFrom);
+ node->asgnTo = copier.copy(tdbb, asgnTo);
+ node->missing = copier.copy(tdbb, missing);
+ node->missing2 = copier.copy(tdbb, missing2);
+ return node;
+}
+
+AssignmentNode* AssignmentNode::pass1(thread_db* tdbb, CompilerScratch* csb)
+{
+ ValueExprNode* sub = asgnFrom;
+ FieldNode* fieldNode;
+ USHORT stream;
+ CompilerScratch::csb_repeat* tail;
+
+ if ((fieldNode = sub->as<FieldNode>()))
+ {
+ stream = fieldNode->fieldStream;
+ jrd_fld* field = MET_get_field(csb->csb_rpt[stream].csb_relation, fieldNode->fieldId);
+
+ if (field)
+ missing2 = field->fld_missing_value;
+ }
+
+ sub = asgnTo;
+
+ if ((fieldNode = sub->as<FieldNode>()))
+ {
+ stream = fieldNode->fieldStream;
+ tail = &csb->csb_rpt[stream];
+ jrd_fld* field = MET_get_field(tail->csb_relation, fieldNode->fieldId);
+
+ if (field && field->fld_missing_value)
+ missing = field->fld_missing_value;
+ }
+
+ doPass1(tdbb, csb, asgnFrom.getAddress());
+ doPass1(tdbb, csb, asgnTo.getAddress());
+ doPass1(tdbb, csb, missing.getAddress());
+ // ASF: No idea why we do not call pass1 for missing2.
+
+ // Perform any post-processing here.
+
+ sub = asgnTo;
+
+ if ((fieldNode = sub->as<FieldNode>()))
+ {
+ stream = fieldNode->fieldStream;
+ tail = &csb->csb_rpt[stream];
+
+ // Assignments to the OLD context are prohibited for all trigger types.
+ if ((tail->csb_flags & csb_trigger) && stream == 0)
+ ERR_post(Arg::Gds(isc_read_only_field));
+
+ // Assignments to the NEW context are prohibited for post-action triggers.
+ if ((tail->csb_flags & csb_trigger) && stream == 1 &&
+ (csb->csb_g_flags & csb_post_trigger))
+ {
+ ERR_post(Arg::Gds(isc_read_only_field));
+ }
+ }
+ else if (!(sub->is<ParameterNode>() || sub->is<VariableNode>() || sub->is<NullNode>()))
+ ERR_post(Arg::Gds(isc_read_only_field));
+
+ return this;
+}
+
+AssignmentNode* AssignmentNode::pass2(thread_db* tdbb, CompilerScratch* csb)
+{
+ ExprNode::doPass2(tdbb, csb, asgnFrom.getAddress());
+ ExprNode::doPass2(tdbb, csb, asgnTo.getAddress());
+ ExprNode::doPass2(tdbb, csb, missing.getAddress());
+ ExprNode::doPass2(tdbb, csb, missing2.getAddress());
+ return this;
+}
+
+const StmtNode* AssignmentNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*exeState*/) const
+{
+ if (request->req_operation == jrd_req::req_evaluate)
+ EXE_assignment(tdbb, this);
+
+ return parentStmt;
+}
+
+
+//--------------------
+
+
static RegisterNode<BlockNode> regBlockNode(blr_block);
DmlNode* BlockNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
{
BlockNode* node = FB_NEW(pool) BlockNode(pool);
- node->action = PAR_parse_node(tdbb, csb, STATEMENT);
+ node->action = PAR_parse_stmt(tdbb, csb);
- NodeStack stack;
+ StmtNodeStack stack;
while (csb->csb_blr_reader.peekByte() != blr_end)
- stack.push(PAR_parse_node(tdbb, csb, STATEMENT));
+ stack.push(PAR_parse_stmt(tdbb, csb));
csb->csb_blr_reader.getByte(); // skip blr_end
@@ -198,22 +298,22 @@
BlockNode* BlockNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
- action = CMP_pass1(tdbb, csb, action);
- handlers = CMP_pass1(tdbb, csb, handlers);
+ doPass1(tdbb, csb, action.getAddress());
+ doPass1(tdbb, csb, handlers.getAddress());
return this;
}
BlockNode* BlockNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
- action = CMP_pass2(tdbb, csb, action, node);
- handlers = CMP_pass2(tdbb, csb, handlers, node);
+ doPass2(tdbb, csb, action.getAddress(), this);
+ doPass2(tdbb, csb, handlers.getAddress(), this);
- node->nod_impure = CMP_impure(csb, sizeof(SLONG));
+ impureOffset = CMP_impure(csb, sizeof(SLONG));
return this;
}
-const jrd_nod* BlockNode::execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const
+const StmtNode* BlockNode::execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const
{
jrd_tra* transaction = request->req_transaction;
jrd_tra* sysTransaction = request->req_attachment->getSysTransaction();
@@ -227,7 +327,7 @@
VIO_start_save_point(tdbb, transaction);
const Savepoint* save_point = transaction->tra_save_point;
count = save_point->sav_number;
- *request->getImpure<SLONG>(node->nod_impure) = count;
+ *request->getImpure<SLONG>(impureOffset) = count;
}
return action;
@@ -243,7 +343,7 @@
if (transaction != sysTransaction)
{
- count = *request->getImpure<SLONG>(node->nod_impure);
+ count = *request->getImpure<SLONG>(impureOffset);
for (const Savepoint* save_point = transaction->tra_save_point;
save_point && count <= save_point->sav_number;
@@ -253,12 +353,12 @@
}
}
- return node->nod_parent;
+ return parentStmt;
}
if (transaction != sysTransaction)
{
- count = *request->getImpure<SLONG>(node->nod_impure);
+ count = *request->getImpure<SLONG>(impureOffset);
// Since there occurred an error (req_unwind), undo all savepoints
// up to, but not including, the savepoint of this block. The
@@ -273,16 +373,18 @@
}
}
- const jrd_nod* temp;
+ const StmtNode* temp;
if (handlers)
{
- temp = node->nod_parent;
- const jrd_nod* const* ptr = handlers->nod_arg;
+ temp = parentStmt;
+ const NestConst<StmtNode>* ptr = handlers->statements.begin();
- for (const jrd_nod* const* const end = ptr + handlers->nod_count; ptr < end; ++ptr)
+ for (const NestConst<StmtNode>* const end = handlers->statements.end();
+ ptr != end;
+ ++ptr)
{
- const ErrorHandlerNode* handlerNode = StmtNode::as<ErrorHandlerNode>(*ptr);
+ const ErrorHandlerNode* handlerNode = (*ptr)->as<ErrorHandlerNode>();
const PsqlException* xcpNode = handlerNode->conditions;
if (testAndFixupError(tdbb, request, xcpNode))
@@ -342,7 +444,7 @@
}
}
else
- temp = node->nod_parent;
+ temp = parentStmt;
// If the application didn't have an error handler, then
// the error will still be pending. Undo the block by
@@ -365,7 +467,7 @@
case jrd_req::req_return:
if (transaction != sysTransaction)
{
- count = *request->getImpure<SLONG>(node->nod_impure);
+ count = *request->getImpure<SLONG>(impureOffset);
for (const Savepoint* save_point = transaction->tra_save_point;
save_point && count <= save_point->sav_number;
@@ -376,7 +478,7 @@
}
default:
- return node->nod_parent;
+ return parentStmt;
}
fb_assert(false);
@@ -442,6 +544,116 @@
//--------------------
+static RegisterNode<CompoundStmtNode> regCompoundStmtNode(blr_begin);
+
+DmlNode* CompoundStmtNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
+{
+ CompoundStmtNode* node = FB_NEW(pool) CompoundStmtNode(pool);
+
+ while (csb->csb_blr_reader.peekByte() != blr_end)
+ node->statements.add(PAR_parse_stmt(tdbb, csb));
+
+ csb->csb_blr_reader.getByte(); // skip blr_end
+
+ return node;
+}
+
+CompoundStmtNode* CompoundStmtNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
+{
+ return this;
+}
+
+void CompoundStmtNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
+{
+ text = "CompoundStmtNode";
+}
+
+void CompoundStmtNode::genBlr(DsqlCompilerScratch* dsqlScratch)
+{
+}
+
+CompoundStmtNode* CompoundStmtNode::copy(thread_db* tdbb, NodeCopier& copier)
+{
+ CompoundStmtNode* node = FB_NEW(*tdbb->getDefaultPool()) CompoundStmtNode(*tdbb->getDefaultPool());
+ node->onlyAssignments = onlyAssignments;
+
+ NestConst<StmtNode>* j = node->statements.getBuffer(statements.getCount());
+
+ for (NestConst<StmtNode>* i = statements.begin(); i != statements.end(); ++i, ++j)
+ *j = copier.copy(tdbb, *i);
+
+ return node;
+}
+
+CompoundStmtNode* CompoundStmtNode::pass1(thread_db* tdbb, CompilerScratch* csb)
+{
+ for (NestConst<StmtNode>* i = statements.begin(); i != statements.end(); ++i)
+ doPass1(tdbb, csb, i->getAddress());
+ return this;
+}
+
+CompoundStmtNode* CompoundStmtNode::pass2(thread_db* tdbb, CompilerScratch* csb)
+{
+ for (NestConst<StmtNode>* i = statements.begin(); i != statements.end(); ++i)
+ doPass2(tdbb, csb, i->getAddress(), this);
+
+ impureOffset = CMP_impure(csb, sizeof(impure_state));
+
+ for (NestConst<StmtNode>* i = statements.begin(); i != statements.end(); ++i)
+ {
+ if (!StmtNode::is<AssignmentNode>(i->getObject()))
+ return this;
+ }
+
+ onlyAssignments = true;
+
+ return this;
+}
+
+const StmtNode* CompoundStmtNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*exeState*/) const
+{
+ const NestConst<StmtNode>* end = statements.end();
+
+ if (onlyAssignments)
+ {
+ if (request->req_operation == jrd_req::req_evaluate)
+ {
+ for (const NestConst<StmtNode>* i = statements.begin(); i != end; ++i)
+ EXE_assignment(tdbb, static_cast<const AssignmentNode*>(i->getObject()));
+
+ request->req_operation = jrd_req::req_return;
+ }
+
+ return parentStmt;
+ }
+
+ impure_state* impure = request->getImpure<impure_state>(impureOffset);
+
+ switch (request->req_operation)
+ {
+ case jrd_req::req_evaluate:
+ impure->sta_state = 0;
+ // fall into
+
+ case jrd_req::req_return:
+ case jrd_req::req_sync:
+ if (impure->sta_state < int(statements.getCount()))
+ {
+ request->req_operation = jrd_req::req_evaluate;
+ return statements[impure->sta_state++];
+ }
+ request->req_operation = jrd_req::req_return;
+ // fall into
+
+ default:
+ return parentStmt;
+ }
+}
+
+
+//--------------------
+
+
static RegisterNode<ContinueLeaveNode> regContinueLeaveNodeContinue(blr_continue_loop);
static RegisterNode<ContinueLeaveNode> regContinueLeaveNodeLeave(blr_leave);
@@ -466,12 +678,12 @@
{
}
-const jrd_nod* ContinueLeaveNode::execute(thread_db* /*tdbb*/, jrd_req* request, ExeState* /*exeState*/) const
+const StmtNode* ContinueLeaveNode::execute(thread_db* /*tdbb*/, jrd_req* request, ExeState* /*exeState*/) const
{
request->req_operation = jrd_req::req_unwind;
request->req_label = labelNumber;
request->req_flags |= (blrOp == blr_continue_loop ? req_continue_loop : req_leave);
- return node->nod_parent;
+ return parentStmt;
}
@@ -500,7 +712,7 @@
case blr_cursor_fetch:
csb->csb_g_flags |= csb_reuse_context;
- node->intoStmt = PAR_parse_node(tdbb, csb, STATEMENT);
+ node->intoStmt = PAR_parse_stmt(tdbb, csb);
csb->csb_g_flags &= ~csb_reuse_context;
break;
@@ -527,19 +739,19 @@
CursorStmtNode* CursorStmtNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
- scrollExpr = CMP_pass1(tdbb, csb, scrollExpr);
- intoStmt = CMP_pass1(tdbb, csb, intoStmt);
+ doPass1(tdbb, csb, scrollExpr.getAddress());
+ doPass1(tdbb, csb, intoStmt.getAddress());
return this;
}
CursorStmtNode* CursorStmtNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
- scrollExpr = CMP_pass2(tdbb, csb, scrollExpr);
- intoStmt = CMP_pass2(tdbb, csb, intoStmt, node);
+ ExprNode::doPass2(tdbb, csb, scrollExpr.getAddress());
+ doPass2(tdbb, csb, intoStmt.getAddress(), this);
return this;
}
-const jrd_nod* CursorStmtNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*exeState*/) const
+const StmtNode* CursorStmtNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*exeState*/) const
{
fb_assert(cursorNumber < request->req_cursors.getCount());
const Cursor* const cursor = request->req_cursors[cursorNumber];
@@ -553,7 +765,7 @@
cursor->open(tdbb);
request->req_operation = jrd_req::req_return;
}
- return node->nod_parent;
+ return parentStmt;
case blr_cursor_close:
if (request->req_operation == jrd_req::req_evaluate)
@@ -561,7 +773,7 @@
cursor->close(tdbb);
request->req_operation = jrd_req::req_return;
}
- return node->nod_parent;
+ return parentStmt;
case blr_cursor_fetch:
case blr_cursor_fetch_scroll:
@@ -615,7 +827,7 @@
request->req_operation = jrd_req::req_return;
default:
- return node->nod_parent;
+ return parentStmt;
}
break;
}
@@ -659,19 +871,30 @@
DeclareCursorNode* DeclareCursorNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
- rse = rse->pass1(tdbb, csb);
- refs = refs->pass1(tdbb, csb);
+ doPass1(tdbb, csb, rse.getAddress());
+ doPass1(tdbb, csb, refs.getAddress());
return this;
}
DeclareCursorNode* DeclareCursorNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
- rse = rse->pass2(tdbb, csb);
- refs = refs->pass2(tdbb, csb);
+ rse->pass2Rse(tdbb, csb);
+
+ ExprNode::doPass2(tdbb, csb, rse.getAddress());
+ ExprNode::doPass2(tdbb, csb, refs.getAddress());
+
+ // Finish up processing of record selection expressions.
+
+ RecordSource* const rsb = CMP_post_rse(tdbb, csb, rse.getObject());
+ csb->csb_fors.add(rsb);
+
+ cursor = FB_NEW(*tdbb->getDefaultPool()) Cursor(csb, rsb, rse->rse_invariants,
+ (rse->flags & RseNode::FLAG_SCROLLABLE));
+
return this;
}
-const jrd_nod* DeclareCursorNode::execute(thread_db* /*tdbb*/, jrd_req* request, ExeState* /*exeState*/) const
+const StmtNode* DeclareCursorNode::execute(thread_db* /*tdbb*/, jrd_req* request, ExeState* /*exeState*/) const
{
if (request->req_operation == jrd_req::req_evaluate)
{
@@ -684,13 +907,112 @@
request->req_operation = jrd_req::req_return;
}
- return node->nod_parent;
+ return parentStmt;
}
//--------------------
+static RegisterNode<DeclareVariableNode> regDeclareVariableNode(blr_dcl_variable);
+
+DmlNode* DeclareVariableNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
+{
+ DeclareVariableNode* node = FB_NEW(pool) DeclareVariableNode(pool);
+
+ node->varId = csb->csb_blr_reader.getWord();
+
+ ItemInfo itemInfo;
+ PAR_desc(tdbb, csb, &node->varDesc, &itemInfo);
+
+ csb->csb_variables = vec<DeclareVariableNode*>::newVector(
+ *tdbb->getDefaultPool(), csb->csb_variables, node->varId + 1);
+
+ if (itemInfo.isSpecial())
+ {
+ csb->csb_dbg_info.varIndexToName.get(node->varId, itemInfo.name);
+ csb->csb_map_item_info.put(Item(Item::TYPE_VARIABLE, node->varId), itemInfo);
+ }
+
+ if (itemInfo.explicitCollation)
+ {
+ CompilerScratch::Dependency dependency(obj_collation);
+ dependency.number = INTL_TEXT_TYPE(node->varDesc);
+ csb->csb_dependencies.push(dependency);
+ }
+
+ return node;
+}
+
+DeclareVariableNode* DeclareVariableNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
+{
+ return this;
+}
+
+void DeclareVariableNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
+{
+ text = "DeclareVariableNode";
+}
+
+void DeclareVariableNode::genBlr(DsqlCompilerScratch* dsqlScratch)
+{
+}
+
+DeclareVariableNode* DeclareVariableNode::copy(thread_db* tdbb, NodeCopier& copier)
+{
+ if (copier.csb->csb_remap_variable == 0)
+ return this;
+
+ DeclareVariableNode* node = FB_NEW(*tdbb->getDefaultPool()) DeclareVariableNode(*tdbb->getDefaultPool());
+ node->varId = varId + copier.csb->csb_remap_variable;
+ node->varDesc = varDesc;
+
+ copier.csb->csb_variables = vec<DeclareVariableNode*>::newVector(*tdbb->getDefaultPool(),
+ copier.csb->csb_variables, node->varId + 1);
+
+ return node;
+}
+
+DeclareVariableNode* DeclareVariableNode::pass1(thread_db* tdbb, CompilerScratch* csb)
+{
+ vec<DeclareVariableNode*>* vector = csb->csb_variables = vec<DeclareVariableNode*>::newVector(
+ *tdbb->getDefaultPool(), csb->csb_variables, varId + 1);
+ fb_assert(!(*vector)[varId]);
+ (*vector)[varId] = this;
+
+ return this;
+}
+
+DeclareVariableNode* DeclareVariableNode::pass2(thread_db* tdbb, CompilerScratch* csb)
+{
+ impureOffset = CMP_impure(csb, sizeof(impure_value) + varDesc.dsc_length);
+ return this;
+}
+
+const StmtNode* DeclareVariableNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*exeState*/) const
+{
+ impure_value* variable = request->getImpure<impure_value>(impureOffset);
+ variable->vlu_desc = varDesc;
+ variable->vlu_desc.dsc_flags = 0;
+ variable->vlu_desc.dsc_address = (UCHAR*) &variable->vlu_misc;
+
+ if (variable->vlu_desc.dsc_dtype <= dtype_varying && !variable->vlu_string)
+ {
+ const USHORT len = variable->vlu_desc.dsc_length;
+ variable->vlu_string = FB_NEW_RPT(*tdbb->getDefaultPool(), len) VaryingString();
+ variable->vlu_string->str_length = len;
+ variable->vlu_desc.dsc_address = variable->vlu_string->str_data;
+ }
+
+ request->req_operation = jrd_req::req_return;
+
+ return parentStmt;
+}
+
+
+//--------------------
+
+
static RegisterNode<EraseNode> regEraseNode(blr_erase);
DmlNode* EraseNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR /*blrOp*/)
@@ -724,8 +1046,8 @@
{
pass1Erase(tdbb, csb, this);
- statement = CMP_pass1(tdbb, csb, statement);
- subStatement = CMP_pass1(tdbb, csb, subStatement);
+ doPass1(tdbb, csb, statement.getAddress());
+ doPass1(tdbb, csb, subStatement.getAddress());
return this;
}
@@ -809,10 +1131,7 @@
EraseNode* viewNode = FB_NEW(*tdbb->getDefaultPool()) EraseNode(*tdbb->getDefaultPool());
viewNode->stream = node->stream;
- node->subStatement = PAR_make_node(tdbb, 1);
- node->subStatement->nod_type = nod_class_stmtnode_jrd;
- node->subStatement->nod_count = 0;
- node->subStatement->nod_arg[0] = reinterpret_cast<jrd_nod*>(viewNode);
+ node->subStatement = viewNode;
// Substitute the original delete node with the newly created one.
node = viewNode;
@@ -832,40 +1151,40 @@
EraseNode* EraseNode::pass2(thread_db* tdbb, CompilerScratch* csb)
{
- statement = CMP_pass2(tdbb, csb, statement, node);
- subStatement = CMP_pass2(tdbb, csb, subStatement, node);
+ doPass2(tdbb, csb, statement.getAddress(), this);
+ doPass2(tdbb, csb, subStatement.getAddress(), this);
- node->nod_impure = CMP_impure(csb, sizeof(SLONG));
+ impureOffset = CMP_impure(csb, sizeof(SLONG));
csb->csb_rpt[stream].csb_flags |= csb_update;
return this;
}
-const jrd_nod* EraseNode::execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const
+const StmtNode* EraseNode::execute(thread_db* tdbb, jrd_req* request, ExeState* exeState) const
{
- const jrd_nod* retNode;
+ const StmtNode* retNode;
if (request->req_operation == jrd_req::req_unwind)
- retNode = node->nod_parent;
+ retNode = parentStmt;
else if (request->req_operation == jrd_req::req_return && subStatement)
{
if (!exeState->topNode)
{
- exeState->topNode = node;
+ exeState->topNode = this;
exeState->whichEraseTrig = PRE_TRIG;
}
- exeState->prevNode = node;
+ exeState->prevNode = this;
retNode = erase(tdbb, request, exeState->whichEraseTrig);
if (exeState->whichEraseTrig == PRE_TRIG)
{
retNode = subStatement;
- fb_assert(retNode->nod_parent == node);
- ///retNode->nod_parent = exeState->prevNode;
+ fb_assert(retNode->parentStmt == this);
+ ///retNode->parentStmt = exeState->prevNode;
}
- if (exeState->topNode == node && exeState->whichEraseTrig == POST_TRIG)
+ if (exeState->topNode == this && exeState->whichEraseTrig == POST_TRIG)
{
exeState->topNode = NULL;
exeState->whichEraseTrig = ALL_TRIGS;
@@ -875,7 +1194,7 @@
}
else
{
- exeState->prevNode = node;
+ exeState->prevNode = this;
retNode = erase(tdbb, request, ALL_TRIGS);
if (!subStatement && exeState->whichEraseTrig == PRE_TRIG)
@@ -886,7 +1205,7 @@
}
// Perform erase operation.
-const jrd_nod* EraseNode::erase(thread_db* tdbb, jrd_req* request, WhichTrigger whichTrig) const
+const StmtNode* EraseNode::erase(thread_db* tdbb, jrd_req* request, WhichTrigger whichTrig) const
{
Jrd::Attachment* attachment = tdbb->...
[truncated message content] |