Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-24420] dblink: correct oracle syntax error in rewritten query. #3705

Merged
merged 12 commits into from
Jul 18, 2022

Conversation

beyondykk9
Copy link
Contributor

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

The rewritten query by "predicate push down" at DBLINK would not be executed at ORACLE.
We should modify the rewritten routine not to ban the grammar of ORACLE.

-- create table at remote DB (oracle)
create table tbl1 (a int, b varchar, c int);

-- make a record of the table
insert into tbl1 values (1, 'abc', 2);

-- query to dblink
select *
from dblink (srv, 'select a, b, c from tbl1')
where a > 0;

The error arise as like "ORA-00933: SQL command not properly ended"

@beyondykk9 beyondykk9 added the bug label Jul 8, 2022
@beyondykk9 beyondykk9 added this to the fig milestone Jul 8, 2022
@beyondykk9 beyondykk9 self-assigned this Jul 8, 2022
src/parser/parse_tree_cl.c Outdated Show resolved Hide resolved
src/parser/parse_tree_cl.c Outdated Show resolved Hide resolved
src/parser/parse_tree_cl.c Outdated Show resolved Hide resolved
src/parser/view_transform.c Outdated Show resolved Hide resolved
PT_INTERNAL_ERROR (parser, "allocate new node");
return NULL;
}
*new_node = *old_node->info.expr.arg1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvl(col1) in cast( nvl(col1) as int) cannot be copied. It is recommended to make a full copy and remove cast().

Copy link
Contributor Author

@beyondykk9 beyondykk9 Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please show the full query as an incorrect rewrite result.
the below query is executed well:
select * from dblink(srv, 'select a, b, c from tbl') as t(col1 int, col2 varchar, col3 int) where cast( nvl(col1,1) as int) = 9999;

the rewritten query is as below:
SELECT * FROM (select a, b, c from tbl) cublink(col1, col2, col3) WHERE cast(nvl(col1, 1) as integer)=9999

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the routin "pt_remove_cast_wrap_for_dblink"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants