Skip to content

Commit

Permalink
[CBRD-24473] Index scan cannot be used when a stored function is used…
Browse files Browse the repository at this point in the history
… in a where condition. (#3811)

http://jira.cubrid.org/browse/CBRD-24473

I fixed it so that the method is treated as a pseudo constant in qo_analyze_terms().

'col1 = const' <== it is indexable.

There is one more problem. Index scan on correlated columns is not possible due to query rewrite in meth_translate() (check test cases for CBRD-24473.txt). I hope this will be fixed in the future.
  • Loading branch information
shparkcubrid authored Sep 27, 2022
1 parent 930fe21 commit 273eaa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/optimizer/query_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,13 @@ pt_is_pseudo_const (PT_NODE * expr)
*/
return true;

case PT_METHOD_CALL:
/*
* Even if there are columns(PT_NAME) in the parameter of the Java Stored Procedure(METHOD_CALL),
* it can be guaranteed to be evaluated by the time it is referenced.
*/
return true;

case PT_DOT_:
/*
* It would be nice if we could use expressions that are
Expand Down
8 changes: 8 additions & 0 deletions src/parser/xasl_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -7693,6 +7693,14 @@ pt_to_regu_variable (PARSER_CONTEXT * parser, PT_NODE * node, UNBOX unbox)
break;

case PT_METHOD_CALL:
/*
TODO : JSP containing column cannot be here because the query is rewritten in meth_translate().
The index scan may not work because of the query rewrite in meth_translate().
The method call should proceed in the same way as the internal function.
pt_to_regu_variable() : generate regu_var for jsp function
fetch_peek_dbval() : fetch regu_var for jsp function
*/

/* a method call that can be evaluated as a constant expression. */
regu_alloc (val);
pt_evaluate_tree (parser, node, val, 1);
Expand Down

0 comments on commit 273eaa6

Please sign in to comment.