Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
bbf3e56b43fe
Commit
e7520ae9
authored
Mar 13, 2019
by
Nicolas Chauvat
Browse files
[server.querier] construct ExecutionPlan from schema since querier is not needed
parent
24a20d2b8c84
Changes
1
Hide whitespace changes
Inline
Side-by-side
cubicweb/server/querier.py
View file @
bbf3e56b
...
...
@@ -154,7 +154,8 @@ def get_local_checks(cnx, rqlst, solution):
class
ExecutionPlan
(
object
):
"""the execution model of a rql query, composed of querier steps"""
def
__init__
(
self
,
querier
,
rqlst
,
args
,
cnx
):
def
__init__
(
self
,
schema
,
rqlst
,
args
,
cnx
):
self
.
schema
=
schema
# original rql syntax tree
self
.
rqlst
=
rqlst
self
.
args
=
args
or
{}
...
...
@@ -162,7 +163,6 @@ class ExecutionPlan(object):
self
.
cnx
=
cnx
# execution steps
self
.
steps
=
[]
self
.
querier
=
querier
# tracing token for debugging
self
.
rql_query_tracing_token
=
None
...
...
@@ -211,8 +211,8 @@ class ExecutionPlan(object):
noinvariant
=
()
if
cached
is
None
:
self
.
cnx
.
vreg
.
rqlhelper
.
simplify
(
union
)
RQLAnnotator
(
self
.
querier
.
schema
).
annotate
(
union
)
set_qdata
(
self
.
querier
.
schema
.
rschema
,
union
,
noinvariant
)
RQLAnnotator
(
self
.
schema
).
annotate
(
union
)
set_qdata
(
self
.
schema
.
rschema
,
union
,
noinvariant
)
if
union
.
has_text_query
:
self
.
cache_key
=
None
...
...
@@ -308,7 +308,7 @@ class ExecutionPlan(object):
for
sol
in
solutions
:
sol
[
newvarname
]
=
nvartype
select
.
clean_solutions
(
solutions
)
add_types_restriction
(
self
.
querier
.
schema
,
select
)
add_types_restriction
(
self
.
schema
,
select
)
self
.
cnx
.
vreg
.
rqlhelper
.
annotate
(
rqlst
)
self
.
preprocess
(
rqlst
,
security
=
False
)
return
rqlst
...
...
@@ -318,8 +318,8 @@ class InsertPlan(ExecutionPlan):
"""an execution model specific to the INSERT rql query
"""
def
__init__
(
self
,
querier
,
rqlst
,
args
,
cnx
):
ExecutionPlan
.
__init__
(
self
,
querier
,
rqlst
,
args
,
cnx
)
def
__init__
(
self
,
schema
,
rqlst
,
args
,
cnx
):
ExecutionPlan
.
__init__
(
self
,
schema
,
rqlst
,
args
,
cnx
)
# save originally selected variable, we may modify this
# dictionary for substitution (query parameters)
self
.
selected
=
rqlst
.
selection
...
...
@@ -339,7 +339,7 @@ class InsertPlan(ExecutionPlan):
def
add_relation_def
(
self
,
rdef
):
"""add an relation definition to build"""
edef
,
rtype
,
value
=
rdef
if
self
.
querier
.
schema
[
rtype
].
rule
:
if
self
.
schema
[
rtype
].
rule
:
raise
QueryError
(
"'%s' is a computed relation"
%
rtype
)
self
.
r_defs
.
add
(
rdef
)
if
not
isinstance
(
edef
,
int
):
...
...
@@ -487,8 +487,8 @@ class QuerierHelper(object):
def
plan_factory
(
self
,
rqlst
,
args
,
cnx
):
"""create an execution plan for an INSERT RQL query"""
if
rqlst
.
TYPE
==
'insert'
:
return
InsertPlan
(
self
,
rqlst
,
args
,
cnx
)
return
ExecutionPlan
(
self
,
rqlst
,
args
,
cnx
)
return
InsertPlan
(
self
.
schema
,
rqlst
,
args
,
cnx
)
return
ExecutionPlan
(
self
.
schema
,
rqlst
,
args
,
cnx
)
@
statsd_timeit
def
execute
(
self
,
cnx
,
rql
,
args
=
None
,
build_descr
=
True
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment