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

Invalid SQL (IN with subquery which returns multiple columns) is accepted #3462

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed
Labels
bug Something isn't working major SQL

Comments

@monetdb-team
Copy link

Date: 2014-03-28 17:31:18 +0100
From: Martin van Dinther <<martin.van.dinther>>
To: SQL devs <>
Version: 11.17.9 (Jan2014)
CC: @njnes

Last updated: 2014-05-22 09:52:29 +0200

Comment 19715

Date: 2014-03-28 17:31:18 +0100
From: Martin van Dinther <<martin.van.dinther>>

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0
Build Identifier:

The SQL query:
SELECT * FROM SYS.ARGS
WHERE FUNC_ID NOT IN (SELECT * FROM SYS.FUNCTIONS)

is accepted by MonetDB and even executed!
However the where-clause is invalid as
SELECT * FROM SYS.FUNCTIONS
returns multiple columns which cannot be mapped to 1 col: FUNC_ID

This invalid SQL query should be detected by the SQL parser/executor and reported as an SQL error.

Instead MonetDB executes it returns 3401 rows, same data as when executing:
SELECT * FROM SYS.ARGS;

Reproducible: Always

Steps to Reproduce:

  1. start mserver5
  2. start SQuirreL connecting to demo database
  3. execute SQL query:
    SELECT * FROM SYS.ARGS
    WHERE FUNC_ID NOT IN (SELECT * FROM SYS.FUNCTIONS)

Actual Results:

MonetDB executes it returns 3401 rows.
Same data as when executing: SELECT * FROM SYS.ARGS;

Expected Results:

An SQL syntax error (invalid subquery as it returns more than 1 col)

The correct SQL query:
SELECT * FROM SYS.ARGS
WHERE FUNC_ID NOT IN (SELECT ID FROM SYS.FUNCTIONS)
works fine and returns 0 rows as expected.

Comment 19718

Date: 2014-03-29 14:20:50 +0100
From: @njnes

properly check correct types (ie also number of columns should match)

Comment 19721

Date: 2014-03-29 14:24:04 +0100
From: MonetDB Mercurial Repository <>

Changeset c5338ccd7803 made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=c5338ccd7803

Changeset description:

fixed bugs 3458, 3461 and 3462

3461 added missing select
3462 check number of columns
@monetdb-team monetdb-team added bug Something isn't working major SQL labels Nov 30, 2020
@sjoerdmullender sjoerdmullender added this to the Ancient Release milestone Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major SQL
Projects
None yet
Development

No branches or pull requests

2 participants