EnterpriseDB / mysql_fdw

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

Add placeholder BeginForeignInsert function to prevent crash #208

Closed ibarwick closed 3 years ago

ibarwick commented 3 years ago

Beginning with PostgreSQL 11, inserts resulting from a COPY FROM operation or partition tuple routing need to be handled, even if only an error message is raised indicating the functionality is not available.

Without this, a server crash will occur, e.g.:

postgres=# \d my_instest 
                       Foreign table "public.my_instest"
 Column |         Type          | Collation | Nullable | Default | FDW options 
--------+-----------------------+-----------+----------+---------+-------------
 id     | integer               |           |          |         | 
 val    | character varying(30) |           |          |         | 
Server: mysql_server
FDW options: (dbname 'test', table_name 'instest')

postgres=# COPY my_instest FROM STDIN WITH (format 'csv');
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 1,foo
2,bar
\.>> >> 
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

This patch results in an error being raised:

postgres=# COPY my_instest FROM STDIN WITH (format 'csv');
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 1,foo
2,bar
\.>> >> 
ERROR:  COPY and foreign partition routing not supported
ibarwick commented 3 years ago

Thanks for the patch, closing this now.