- improved an optimization, to produce a simpler select condition under certain circumstances

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@343 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2011-11-07 19:01:33 +07:00
parent cd85b7e1c1
commit 3978259f4a
4 changed files with 21 additions and 1 deletions

@ -1,6 +1,7 @@
1.2
- Better tokenizer, gives more indicative errors
- Parser gives more indicative errors
- Improved select_union_intersect_subtract optimization to avoid parenthesis whenever possible
1.1
- Incorrect relational operations now raise an exception instead of returning None

@ -475,7 +475,22 @@ def select_union_intersect_subtract(n):
newnode=parser.node()
newnode.prop='((%s) %s (%s))' % (n.left.prop,op,n.right.prop)
if n.left.prop.startswith('(') or n.right.prop.startswith('('):
t_str='('
if n.left.prop.startswith('('):
t_str+='(%s)'
else:
t_str+='%s'
t_str+=' %s '
if n.right.prop.startswith('('):
t_str+='(%s)'
else:
t_str+='%s'
t_str+=')'
newnode.prop= t_str % (n.left.prop,op,n.right.prop)
else:
newnode.prop='%s %s %s' % (n.left.prop,op,n.right.prop)
newnode.name=SELECTION
newnode.child=n.left.child
newnode.kind=parser.UNARY

@ -0,0 +1 @@
σ skill=='C' and chief==0 ((σ age<30 (people) σ age>40(people)) ᐅᐊ skills)

@ -0,0 +1,3 @@
id,name,chief,age,skill
0,jack,0,22,C
4,eve,0,25,C