This repository has been archived by the owner on Jun 7, 2021. It is now read-only.
[TRAFODION-2202] in mode_special_4, sequence function is broken #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when CQD mode_special_4 is 'on', the binder try to support Oracle sequence syntax as 'indentifier.nextval'.
Binder will regard the identifier as a sequence object which object_type is 'SG'.
However, the sequence execution code will try to get the current value via such a query in SeqGenCliInterfaceUpdAndValidate():
"select case when cast(? as largeint not null) = 1 then t.startVal else t.nextVal end, t.redefTS from
(update %s."%s".%s set next_value = (case when cast(? as largeint not null) = 1 then start_value +
cast(? as largeint not null) else (case when next_value + cast(? as largeint not null) > max_value then max_value+1 else next_value + cast(? as largeint not null) end) end), num_calls = num_calls + 1 where seq_uid = %Ld return old.start_value, old.next_value, old.redef_ts) t(startVal, nextVal, redefTS);",
so the t.nextval will be handled special, try to find SG object for object 'T', which cannot find, so trigger issues.
This change is very simple, to change the nextval into some other string: 'nextvalue', so the binder will NOT try to treat it as a Oracle syntax.
So when mode_special_4 is 'ON', one can still use the normal sequence function.