-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MB-32638 Fix scope of CTE to cover setop queries
Previous implementation of CTE associated CTE with a subselect, which is analogous to how LET is associated with a subselect. One issue with this approach is that when a CTE is defined in a setop query (e.g. UNION) the CTE is only visible from the first arm of the UNION, which is not how CTE is defined in the SQL standard. We now "raise" the scope of the CTE to be associated with a fullselect rather than a subselect, which is consistent with the SQL standard. In addition, in SQL standard the CTE (WITH clause) is only allowed to be specified for the top-most query, it is NOT allowed in a query that is under a setop operation (e.g. UNION). However, since 1. Previous implementation does allow WITH clause under a setop operation 2. Postgres also support this behavior (although Oracle follows the SQL standard and gives error for such queries) we will also support WITH clause in a query under setop operations. This means you could have "nested" WITH clause, and the scope (or visibility) of each WITH clause is defined by where it is specified in the query. Change-Id: Ie93eb33056d268c898ad33b91a175182dccf5e8f Reviewed-on: https://review.couchbase.org/c/query/+/175119 Reviewed-by: Sitaram Vemulapalli <sitaram.vemulapalli@couchbase.com> Reviewed-by: Marco Greco <marco.greco@couchbase.com> Tested-by: Bingjie Miao <bingjie.miao@couchbase.com>
- Loading branch information
1 parent
e5d1f03
commit 9d3793d
Showing
14 changed files
with
359 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.