Changeset: 0015b5a45265 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0015b5a45265
Modified Files:
monetdb5/mal/mal_function.c
monetdb5/mal/mal_function.h
monetdb5/optimizer/Tests/argumenttypes.maltest
monetdb5/optimizer/opt_garbageCollector.c
Branch: default
Log Message:
Move the variable renaming to its logical place
diffs (89 lines):
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -471,6 +471,24 @@ listFunction(stream *fd, MalBlkPtr mb, M
printInstruction(fd, mb, stk, getInstrPtr(mb, i), flg);
}
+
+void
+renameVariables(MalBlkPtr mb)
+{
+ int i;
+ /* variables get their name from the position in the symbol table */
+ /* During optimization they may be copied around, which means there
name should be re-establised */
+ /* rename all temporaries for ease of variable table interpretation */
+ /* this code should not be necessary is variables always keep their
position */
+ for( i = 0; i < mb->vtop; i++) {
+ if (getVarName(mb,i)[0] == 'X' && getVarName(mb,i)[1] == '_')
+ snprintf(getVarName(mb,i),IDLENGTH,"X_%d",i);
+ else
+ if (getVarName(mb,i)[0] == 'C' && getVarName(mb,i)[1] == '_')
+ snprintf(getVarName(mb,i),IDLENGTH,"C_%d",i);
+ }
+}
+
void printFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int flg)
{
int i,j;
diff --git a/monetdb5/mal/mal_function.h b/monetdb5/mal/mal_function.h
--- a/monetdb5/mal/mal_function.h
+++ b/monetdb5/mal/mal_function.h
@@ -29,6 +29,7 @@ mal_export int isLoopBarrier(MalBlkPtr m
mal_export int getBlockExit(MalBlkPtr mb,int pc);
mal_export int getBlockBegin(MalBlkPtr mb,int pc);
mal_export void setVariableScope(MalBlkPtr mb);
+mal_export void renameVariables(MalBlkPtr mb);
mal_export void printFunction(stream *fd, MalBlkPtr mb, MalStkPtr stk, int
flg);
mal_export void traceFunction(component_t comp, MalBlkPtr mb, MalStkPtr stk,
int flg);
diff --git a/monetdb5/optimizer/Tests/argumenttypes.maltest
b/monetdb5/optimizer/Tests/argumenttypes.maltest
--- a/monetdb5/optimizer/Tests/argumenttypes.maltest
+++ b/monetdb5/optimizer/Tests/argumenttypes.maltest
@@ -1,8 +1,11 @@
statement ok
-X:bat[:int] := bat.new(nil:int)
+function foo();
+X:bat[:int] := bat.new(nil:int);
+(X_115:bat[:int], X_116:bat[:oid], X_117:bat[:oid]) :=
algebra.sort(X:bat[:int], false:bit, false:bit, false:bit);
+end foo;
statement ok
-(X_115:bat[:int], X_116:bat[:oid], X_117:bat[:oid]) :=
algebra.sort(X:bat[:int], false:bit, false:bit, false:bit)
+foo()
statement error
(X_115:bat[:lng], X_116:bat[:oid], X_117:bat[:oid]) :=
algebra.sort(X:bat[:lng], false:bit, false:bit, false:bit)
diff --git a/monetdb5/optimizer/opt_garbageCollector.c
b/monetdb5/optimizer/opt_garbageCollector.c
--- a/monetdb5/optimizer/opt_garbageCollector.c
+++ b/monetdb5/optimizer/opt_garbageCollector.c
@@ -22,6 +22,7 @@
*
* The life time of such BATs is forcefully terminated after the block exit.
*/
+
str
OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci)
{
@@ -39,20 +40,8 @@ OPTgarbageCollectorImplementation(Client
return 0;
limit = mb->stop;
+ renameVariables(mb);
- /* variables get their name from the position */
- /* rename all temporaries for ease of variable table interpretation */
- /* this code should not be necessary is variables always keep their
position */
- for( i = 0; i < mb->vtop; i++) {
- //strcpy(buf, getVarName(mb,i));
- if (getVarName(mb,i)[0] == 'X' && getVarName(mb,i)[1] == '_')
- snprintf(getVarName(mb,i),IDLENGTH,"X_%d",i);
- else
- if (getVarName(mb,i)[0] == 'C' && getVarName(mb,i)[1] == '_')
- snprintf(getVarName(mb,i),IDLENGTH,"C_%d",i);
- //if(strcmp(buf, getVarName(mb,i)) )
- //fprintf(stderr, "non-matching name/entry %s %s\n",
buf, getVarName(mb,i));
- }
// move SQL query definition to the front for event profiling tools
p = NULL;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list