Giter Site home page Giter Site logo

Comments (3)

ibrarahmad avatar ibrarahmad commented on August 13, 2024

The first column must be unique, I think that is missing in the
documentation. I will add that in the documentation.

Actually postgres_fdw is using ctid to identify the unique column for
DELETE and UPDATE which does not exists in mysql, so I am using the first
column for that purpose. Some other fdw are using the same technique.

I am thinking to add an option to specify a key column (which must be
unique) while creating a foreign table, instead of using the first column.

On Tue, Mar 3, 2015 at 8:49 PM, Radim Blazek [email protected]
wrote:

PostgreSQL 9.3, MySQL 5.5, mysql_fdw ddd5344
ddd5344

MySQL:

CREATE TABLE foo (
a int,
b int,
c varchar(3)
);
INSERT INTO foo VALUES ( 1, 1, 'aaa');
INSERT INTO foo VALUES ( 1, 2, 'bbb');

PostgreSQL:

CREATE FOREIGN TABLE foo ( a int, b int, c varchar(44) )
SERVER mysql_server OPTIONS (dbname 'test', table_name 'foo');
UPDATE foo set c = 'zzz' WHERE b = 2;
SELECT * FROM foo;
a | b | c
---+---+-----
1 | 1 | zzz
1 | 2 | zzz

I.e. all rows were updated (very dangerous IMO). Works OK if values in 'a'
(the first column) are unique or if the first column is not included in the
foreign table.

BTW, probably not related directly to this issue, but there are also some
strange skips over the first column here
https://github.com/EnterpriseDB/mysql_fdw/blob/e03bc73/mysql_fdw.c#L943
https://github.com/EnterpriseDB/mysql_fdw/blob/e03bc73/mysql_fdw.c#L1244


Reply to this email directly or view it on GitHub
#45.

Ibrar Ahmed
EnterpriseDB http://www.enterprisedb.com

from mysql_fdw.

blazek avatar blazek commented on August 13, 2024

If the first column must be unique, it should be checked when the foreign table is created and it should raise an error if it is not unique.

It should be probably also checked again when an UPDATE is executed because the table in mysql could change since foreign table was created.

from mysql_fdw.

ibrarahmad avatar ibrarahmad commented on August 13, 2024

Agreed, I will add these checks, thanks for reporting.

On Tue, Mar 3, 2015 at 9:55 PM, Radim Blazek [email protected]
wrote:

If the first column must be unique, it should be checked when the foreign
table is created and it should raise an error if it is not unique.

It should be probably also checked again when an UPDATE is executed
because the table in mysql could change since foreign table was created.


Reply to this email directly or view it on GitHub
#45 (comment)
.

Ibrar Ahmed
EnterpriseDB http://www.enterprisedb.com

from mysql_fdw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.