Skip to content

Commit

Permalink
TEIID-5378 correcting to use the session level temp table store
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jun 15, 2018
1 parent 758e2a5 commit 79ad648
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManage
Create create = GlobalTableStoreImpl.getCreateCommand(group, false, metadata);
tts.addTempTable(tempTableID, create, buffer, true, context);
}
return getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
return tts.getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
}
TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate, forUpdate, context);
if (tempTable != null) {
Expand Down
24 changes: 24 additions & 0 deletions engine/src/test/java/org/teiid/query/processor/TestGlobalTemp.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,28 @@ public class TestGlobalTemp {
harness.execute("select count(*) from tabglob", new List<?>[] {Arrays.asList(2)});
}

@Test public void testTempInFunctionAndProcedure() throws Exception {
String ddl = "CREATE GLOBAL TEMPORARY TABLE teiidtemp(val integer) OPTIONS (UPDATABLE 'TRUE');\n" +
" \n" +
" CREATE VIRTUAL FUNCTION f1() RETURNS string AS\n" +
" BEGIN\n" +
" INSERT INTO teiidtemp(val) VALUES (1);\n" +
" DECLARE string v1 = SELECT 'default'||COUNT(val) FROM teiidtemp;\n" +
" RETURN v1;\n" +
" END;\n" +
" CREATE VIRTUAL PROCEDURE p1() RETURNS (v1 string) AS\n" +
" BEGIN\n" +
" INSERT INTO teiidtemp(val) VALUES (1);\n" +
" SELECT 'default'||COUNT(val) FROM teiidtemp;\n" +
" END;";

TempTableTestHarness harness = new TempTableTestHarness();
TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "x", "y");
HardcodedDataManager dm = new HardcodedDataManager();
harness.setUp(metadata, dm);
harness.execute("INSERT INTO teiidtemp(val) VALUES (1)", new List<?>[] {Arrays.asList(1)});
harness.execute("SELECT f1()", new List<?>[] {Arrays.asList("default2")});
harness.execute("SELECT a.v1 FROM (CALL p1()) a", new List<?>[] {Arrays.asList("default3")});
}

}

0 comments on commit 79ad648

Please sign in to comment.