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

Creating a table with duplicate column name should not be possible #6729

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

Creating a table with duplicate column name should not be possible #6729

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

Comments

@monetdb-team
Copy link

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

Date: 2019-07-11 17:37:22 +0200
From: Martin van Dinther <<martin.van.dinther>>
To: SQL devs <>
Version: 11.33.3 (Apr2019)
CC: @PedroTadim

Last updated: 2019-09-02 16:05:26 +0200

Comment 27130

Date: 2019-07-11 17:37:22 +0200
From: Martin van Dinther <<martin.van.dinther>>

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

By using CREATE TABLE products_new (id serial, LIKE products); it is possible to create a table which has multiple columns with the same name.
This should not be allowed.
It also results in low level GDK errors when querying the table after data has been inserted.

Reproducible: Always

Steps to Reproduce:

CREATE TABLE products (id int not null primary key, name varchar(99) not null, price decimal(7,2) not null);
INSERT INTO products (id, name, price) VALUES (6, 'beer', 1.55);
INSERT INTO products (id, name, price) VALUES (8, 'wine', 5.67);
SELECT * FROM products;

CREATE TABLE products_new (id serial, like products);
-- the table is created with 2 columns named id !!
\d products_new
SELECT id from products_new;
SELECT * from products_new;
SELECT id, id, name, price from products_new;
SELECT id, name, price from products_new;
SELECT name, price from products_new;
SELECT name from products_new;

INSERT INTO products_new (id, name, price) VALUES (6, 'beer', 1.55);
INSERT INTO products_new (id, name, price) VALUES (8, 'wine', 5.67);
SELECT id from products_new;
-- 4 rows instead of 2 inserted!

SELECT * from products_new;
-- fails with Error: GDK reported error: BATproject: does not match always
SELECT id, id, name, price from products_new;
-- fails with Error: GDK reported error: BATproject: does not match always
SELECT id, name, price from products_new;
-- fails with Error: GDK reported error: BATproject: does not match always
SELECT name, price from products_new;
-- fails with Error: GDK reported error: BATproject: does not match always
SELECT name from products_new;
-- fails with Error: GDK reported error: BATproject: does not match always

CREATE TABLE products_new2 (id serial, like products, name2 varchar(299) not null, like products);
\d products_new2
SELECT id from products_new2;
SELECT * from products_new2;
SELECT name from products_new2;
SELECT name2 from products_new2;
SELECT price from products_new2;

INSERT INTO products_new2 (id, name2, price) VALUES (6, 'beer', 1.55);
INSERT INTO products_new2 (id, name2, price) VALUES (8, 'wine', 5.67);
SELECT id from products_new2;
SELECT * from products_new2;
SELECT name from products_new2;
SELECT name2 from products_new2;
SELECT price from products_new2;

DROP TABLE IF EXISTS products;
DROP TABLE IF EXISTS products_new;
DROP TABLE IF EXISTS products_new2;

Actual Results:

Tables products_new and products_new2 are created without error!
They contain columns which have the exact same name, which should not be possible.
After inserting data into products_new, querying the table produces Error: GDK reported error: BATproject: does not match always
After inserting data into products_new2, querying the table shows no data!

Expected Results:

Commands
CREATE TABLE products_new (id serial, like products);
and
CREATE TABLE products_new2 (id serial, like products, name2 varchar(299) not null, like products);
should produce eror: CREATE TABLE: a column named 'id' already exists

Comment 27131

Date: 2019-07-11 17:57:34 +0200
From: MonetDB Mercurial Repository <>

Changeset 028329c47ed9 made by Pedro Ferreira pedro.ferreira@monetdbsolutions.com in the MonetDB repo, refers to this bug.

For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=028329c47ed9

Changeset description:

Added test and fix for bug #6729.
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