equal
deleted
inserted
replaced
666 if server.DEBUG & (server.DBG_RQL | server.DBG_SQL): |
666 if server.DEBUG & (server.DBG_RQL | server.DBG_SQL): |
667 if server.DEBUG & (server.DBG_MORE | server.DBG_SQL): |
667 if server.DEBUG & (server.DBG_MORE | server.DBG_SQL): |
668 print '*'*80 |
668 print '*'*80 |
669 print 'querier input', repr(rql), repr(args) |
669 print 'querier input', repr(rql), repr(args) |
670 # parse the query and binds variables |
670 # parse the query and binds variables |
671 cachekey = rql |
671 cachekey = (rql,) |
672 try: |
672 try: |
673 if args: |
673 if args: |
674 # search for named args in query which are eids (hence |
674 # search for named args in query which are eids (hence |
675 # influencing query's solutions) |
675 # influencing query's solutions) |
676 eidkeys = self._rql_ck_cache[rql] |
676 eidkeys = self._rql_ck_cache[rql] |
697 eidkeys = self.solutions(session, rqlst, args) |
697 eidkeys = self.solutions(session, rqlst, args) |
698 except UnknownEid: |
698 except UnknownEid: |
699 # we want queries such as "Any X WHERE X eid 9999" return an |
699 # we want queries such as "Any X WHERE X eid 9999" return an |
700 # empty result instead of raising UnknownEid |
700 # empty result instead of raising UnknownEid |
701 return empty_rset(rql, args, rqlst) |
701 return empty_rset(rql, args, rqlst) |
702 if args and not rql in self._rql_ck_cache: |
702 if args and rql not in self._rql_ck_cache: |
703 self._rql_ck_cache[rql] = eidkeys |
703 self._rql_ck_cache[rql] = eidkeys |
704 if eidkeys: |
704 if eidkeys: |
705 cachekey = self._repo.querier_cache_key(session, rql, args, |
705 cachekey = self._repo.querier_cache_key(session, rql, args, |
706 eidkeys) |
706 eidkeys) |
707 self._rql_cache[cachekey] = rqlst |
707 self._rql_cache[cachekey] = rqlst |
720 # on select query, always copy the cached rqlst so we don't have to |
720 # on select query, always copy the cached rqlst so we don't have to |
721 # bother modifying it. This is not necessary on write queries since |
721 # bother modifying it. This is not necessary on write queries since |
722 # a new syntax tree is built from them. |
722 # a new syntax tree is built from them. |
723 rqlst = rqlst.copy() |
723 rqlst = rqlst.copy() |
724 self._annotate(rqlst) |
724 self._annotate(rqlst) |
|
725 if args: |
|
726 # different SQL generated when some argument is None or not (IS |
|
727 # NULL). This should be considered when computing sql cache key |
|
728 cachekey += tuple(sorted([k for k,v in args.iteritems() |
|
729 if v is None])) |
725 # make an execution plan |
730 # make an execution plan |
726 plan = self.plan_factory(rqlst, args, session) |
731 plan = self.plan_factory(rqlst, args, session) |
727 plan.cache_key = cachekey |
732 plan.cache_key = cachekey |
728 self._planner.build_plan(plan) |
733 self._planner.build_plan(plan) |
729 # execute the plan |
734 # execute the plan |