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

sql: remove one row limit in EXISTS subquery #8847

Merged

Conversation

ImeevMA
Copy link
Collaborator

@ImeevMA ImeevMA commented Jul 5, 2023

According to ANSI, EXISTS is a predicate that tests a given subquery and returns true if it returns more than 0 rows, false otherwise. However, before this patch, EXISTS worked correctly only if there were exactly 0 or 1 rows, and in all other cases it gave an error. This patch makes EXITS work properly.

Closes #8676

@TarantoolBot document
Title: EXISTS predicate

The EXISTS predicate in SQL is a predicate that returns true if the given SQL subquery returns at least one row, and false otherwise.

Example:

SELECT EXISTS(SELECT * FROM (VALUES(1), (2)));

@ImeevMA ImeevMA requested a review from a team as a code owner July 5, 2023 08:45
@coveralls
Copy link

coveralls commented Jul 5, 2023

Coverage Status

coverage: 86.632% (-0.004%) from 86.636%
when pulling 17764a5 on ImeevMA:imeevma/gh-8676-exists-predicate
into 4b88d5f
on tarantool:master
.

Copy link
Contributor

@p7nov p7nov left a comment

Choose a reason for hiding this comment

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

Minor changelog formatting issue.

changelogs/unreleased/gh-8676-fix-exists-predicate.md Outdated Show resolved Hide resolved
@ImeevMA ImeevMA force-pushed the imeevma/gh-8676-exists-predicate branch from 9f04dab to 7ef5728 Compare July 5, 2023 10:58
Copy link
Collaborator

@Gerold103 Gerold103 left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!

src/box/sql/expr.c Outdated Show resolved Hide resolved
@kyukhin kyukhin assigned ImeevMA and unassigned Gerold103 Sep 8, 2023
@ImeevMA ImeevMA force-pushed the imeevma/gh-8676-exists-predicate branch from 7ef5728 to e6ceadf Compare November 10, 2023 08:06
@ImeevMA ImeevMA requested a review from a team as a code owner November 10, 2023 08:06
@ImeevMA ImeevMA requested a review from p7nov November 10, 2023 08:12
@ImeevMA ImeevMA force-pushed the imeevma/gh-8676-exists-predicate branch from e6ceadf to 6fea0c3 Compare November 10, 2023 08:15
@ImeevMA ImeevMA assigned Gerold103 and unassigned ImeevMA Nov 10, 2023
@ImeevMA ImeevMA force-pushed the imeevma/gh-8676-exists-predicate branch from 6fea0c3 to c0fda79 Compare November 10, 2023 11:12
Copy link
Collaborator

@Gerold103 Gerold103 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes!

test/sql-luatest/gh_8676_fix_exists_test.lua Outdated Show resolved Hide resolved
According to ANSI, EXISTS is a predicate that tests a given subquery and
returns true if it returns more than 0 rows, false otherwise. However,
after 2a720d1, EXISTS worked correctly only if there were exactly 0
or 1 rows, and in all other cases it gave an error. This patch makes
EXITS work properly.

Closes tarantool#8676

NO_DOC=bugfix
@ImeevMA ImeevMA force-pushed the imeevma/gh-8676-exists-predicate branch from c0fda79 to 17764a5 Compare November 15, 2023 10:16
@igormunkin igormunkin assigned igormunkin and unassigned Gerold103 Nov 16, 2023
Copy link
Collaborator

@igormunkin igormunkin left a comment

Choose a reason for hiding this comment

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

@ImeevMA, thanks for the patch! LGTM.

@igormunkin igormunkin added the full-ci Enables all tests for a pull request label Nov 24, 2023
@igormunkin igormunkin merged commit a5e498d into tarantool:master Nov 27, 2023
106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Enables all tests for a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXISTS fails in case its subquery returns several values
6 participants