how to identify the left and the right operand table name?

27 views
Skip to first unread message

Amruta Meshram

unread,
May 21, 2014, 10:23:58 PM5/21/14
to akiba...@akiban.com
Hi,
    I am working on distributed databases.
    I was trying to check if the tablename of the leftoparand and the rightoperand of the OR node is same. but my OR node is on the Leftoparand of the AND node.
    I am using foundationdb.sql.parser
My code where I am facing the problem.This is a small part of my project :
protected void testaftermnf(ValueNode node) throws StandardException {
if (node.getNodeType()== NodeTypes.AND_NODE) {
AndNode and = (AndNode)node;
OrNode ornode = (OrNode)and.getLeftOperand();
if(and.getLeftOperand().getNodeType()==NodeTypes.OR_NODE)
{
if (ornode.getRightOperand().getTableName()== ornode.getLeftOperand().getTableName())
{
System.out.println("Condition satisfied");
}
else {
System.out.println("Condition not satisfied");
}
}
}
}  

PROBLEM:input: SELECT * FROM x, y WHERE ((y.b = 2) OR (y.d = 4)) AND (((y.b = 2) OR (x.c = 3)) AND (((x.a = 1) OR (y.d = 4)) AND ((x.a = 1) OR (x.c = 3))))
Output now:Condition satisfied 
Condition satisfied
Condition satisfied
Output suppose to be:Condition satisfied
Condition not satisfied
Condition not satisfied

The problem is with the bold statement.
The problem I am facing here is the code is unable to detect the tablename of ornode for both right and left operand so for this reason the output is coming as null.
I don't understand why is this happening. 



Reply all
Reply to author
Forward
0 new messages