EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
521 stars 160 forks source link

Support ON CONFLICT DO NOTHING #246

Open MinhLA1410 opened 2 years ago

MinhLA1410 commented 2 years ago

Currently, we already Support on conflict do nothing like postgres_fdw. I would like to contribute them into repository and community. If you have interest? I will create pull request for share this feature.

Summary modification:

Reference testcase of postgres_fdw.sql in postgres_fdw:

-- On MySQL server
mysql -h $MYSQL_HOST -u $MYSQL_USER_NAME -D $MYSQL_PORT -D mysql_fdw_post -e "CREATE TABLE t1_constraint (c1 int primary key, c2 int NOT NULL check (c2 >= 0), c3 text, c4 timestamp, c5 timestamp, c6 varchar(10), c7 char(10), c8 text check (c8 IN ('foo','bar', 'buz')));"

'-- On PostgreSQL server
CREATE FOREIGN TABLE ft1_constraint (
    c1 int OPTIONS (key 'true'),
    c2 int NOT NULL,
    c3 text,
    c4 timestamp,
    c5 timestamp,
    c6 varchar(10),
    c7 char(10) default 'ft1',
    c8 text
) SERVER mysql_svr OPTIONS (dbname 'mysql_fdw_post', table_name 't1_constraint');

INSERT INTO ft1_constraint SELECT * FROM ft1 ON CONFLICT DO NOTHING; -- c2 must be greater than or equal to 0, so this case is ignored.

INSERT INTO ft1_constraint(c1, c2) VALUES (2222, -2) ON CONFLICT DO NOTHING; -- ignore, do nothing

SELECT c1, c2 FROM ft1_constraint WHERE c1 = 2222 or c2 = -2; -- empty result
 c1 | c2 
----+----
(0 rows)
surajkharage19 commented 1 year ago

Thanks.

We have added the ON CONFLICT DO NOTHING support in mysql_fdw after your request. Can you please check if that is useful for you and share your feedback? If you are happy with the latest addition, then can you please close the case from your end?