diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromVariableStep.java b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromVariableStep.java index 86e26a69e86..a25d0f0dc2c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromVariableStep.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromVariableStep.java @@ -92,7 +92,9 @@ private void init() { } inited = true; Object src = ctx.getVariable(variableName); - if (src instanceof OResultSet) { + if(src instanceof OInternalResultSet){ + source = ((OInternalResultSet)src).copy(); + } else if (src instanceof OResultSet) { source = (OResultSet) src; source.reset(); } else if (src instanceof OElement) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OInternalResultSet.java b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OInternalResultSet.java index f294cdd98fc..b1a64c7ff1f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OInternalResultSet.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/executor/OInternalResultSet.java @@ -56,4 +56,10 @@ public void reset() { public int size() { return content.size(); } + + public OInternalResultSet copy() { + OInternalResultSet result = new OInternalResultSet(); + result.content = this.content; + return result; + } }