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

Equivalent multi-way join queries give different results #2998

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Equivalent multi-way join queries give different results #2998

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2012-02-06 16:58:41 +0100
From: @swingbit
To: SQL devs <>
Version: 11.7.5 (Dec2011) [obsolete]
CC: @njnes

Last updated: 2012-03-16 14:56:52 +0100

Comment 16865

Date: 2012-02-06 16:58:41 +0100
From: @swingbit

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
Build Identifier:

-- Example data
CREATE TABLE "treeitems" (
"tree" CHARACTER LARGE OBJECT,
"pre" BIGINT
);
INSERT INTO treeitems VALUES('documentStructure', 0);
INSERT INTO treeitems VALUES('documentStructure', 1);

-- Queries 1 and 2 are semantically equivalent
-- Query 1 gives CORRECT results, Query 2 gives WRONG results

-- Query 1
SELECT *
FROM treeitems AS a,
treeitems AS b
WHERE a.pre > b.pre
AND a.tree = 'documentStructure'
AND b.tree = 'documentStructure';

-- Query 2
SELECT *
FROM treeitems AS a,
treeitems AS b
WHERE a.pre > b.pre
AND a.tree = 'documentStructure'
AND b.tree = a.tree;

Reproducible: Always

Steps to Reproduce:

1.execute SQL code in details
2.
3.

Actual Results:

sql>CREATE TABLE "treeitems" (
more> "tree" CHARACTER LARGE OBJECT,
more> "pre" BIGINT
more>);
operation successful (1.147ms)
sql>INSERT INTO treeitems VALUES('documentStructure', 0);
1 affected row (0.649ms)
sql>INSERT INTO treeitems VALUES('documentStructure', 1);
1 affected row (0.230ms)
sql>
sql>SELECT *
more>FROM treeitems AS a,
more> treeitems AS b
more>WHERE a.pre > b.pre
more>AND a.tree = 'documentStructure'
more>AND b.tree = 'documentStructure';
+-------------------+------+-------------------+------+
| tree | pre | tree | pre |
+===================+======+===================+======+
| documentStructure | 1 | documentStructure | 0 |
+-------------------+------+-------------------+------+
1 tuple (2.518ms)
sql>
sql>SELECT *
more>FROM treeitems AS a,
more> treeitems AS b
more>WHERE a.pre > b.pre
more>AND a.tree = 'documentStructure'
more>AND b.tree = a.tree;
+-------------------+------+-------------------+------+
| tree | pre | tree | pre |
+===================+======+===================+======+
| documentStructure | 0 | documentStructure | 0 |
| documentStructure | 1 | documentStructure | 1 |
+-------------------+------+-------------------+------+
2 tuples (3.984ms)
sql>

Expected Results:

sql>CREATE TABLE "treeitems" (
more> "tree" CHARACTER LARGE OBJECT,
more> "pre" BIGINT
more>);
operation successful (1.147ms)
sql>INSERT INTO treeitems VALUES('documentStructure', 0);
1 affected row (0.649ms)
sql>INSERT INTO treeitems VALUES('documentStructure', 1);
1 affected row (0.230ms)
sql>
sql>SELECT *
more>FROM treeitems AS a,
more> treeitems AS b
more>WHERE a.pre > b.pre
more>AND a.tree = 'documentStructure'
more>AND b.tree = 'documentStructure';
+-------------------+------+-------------------+------+
| tree | pre | tree | pre |
+===================+======+===================+======+
| documentStructure | 1 | documentStructure | 0 |
+-------------------+------+-------------------+------+
1 tuple (2.518ms)
sql>
sql>SELECT *
more>FROM treeitems AS a,
more> treeitems AS b
more>WHERE a.pre > b.pre
more>AND a.tree = 'documentStructure'
more>AND b.tree = a.tree;
+-------------------+------+-------------------+------+
| tree | pre | tree | pre |
+===================+======+===================+======+
| documentStructure | 1 | documentStructure | 0 |
+-------------------+------+-------------------+------+
1 tuple (2.518ms)
sql>

$ mserver5 --version
MonetDB 5 server v11.7.6 (64-bit, 64-bit oids)
This is an unreleased version
Copyright (c) 1993-July 2008 CWI
Copyright (c) August 2008-2012 MonetDB B.V., all rights reserved
Visit http://www.monetdb.org/ for further information
Found 35.5GiB available memory, 8 available cpu cores
Libraries:
libpcre: 7.8 2008-09-05 (compiled with 7.8)
openssl: OpenSSL 1.0.0d 8 Feb 2011 (compiled with OpenSSL 1.0.0d-fips 8 Feb 2011)
libxml2: 2.7.7 (compiled with 2.7.7)
Compiled by: roberto@spinque01.ins.cwi.nl (x86_64-unknown-linux-gnu)
Compilation: gcc -g -Werror -Wall -Wextra -W -Werror-implicit-function-declaration -Wpointer-arith -Wdeclaration-after-statement -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wpacked -Wunknown-pragmas -Wvariadic-macros -fstack-protector-all -Wstack-protector -Wpacked-bitfield-compat -Wsync-nand -Wmissing-include-dirs -Wp,-D_FORTIFY_SOURCE=2
Linking : /usr/bin/ld -m elf_x86_64

Comment 16999

Date: 2012-02-26 21:03:07 +0100
From: @njnes

is fixed by the changes to the rel2bin_join some days back

Comment 17000

Date: 2012-02-26 21:05:41 +0100
From: @njnes

Changeset b6dd338c7c98 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=b6dd338c7c98

Changeset description:

added test for bug #2998

Comment 17094

Date: 2012-03-16 14:56:52 +0100
From: @grobian

Released in Dec2011-SP2

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

Successfully merging a pull request may close this issue.

None yet
1 participant