mysql_fdw
mysql_fdw copied to clipboard
Support ON CONFLICT DO NOTHING
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:
- Only DO_NOTHING is supported without an inference specification. update mysql_deparse_insert() for DO_NOTHING case
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)
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?