On Thu, Feb 16, 2023 8:48 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Mon, Jan 30, 2023 at 4:19 PM Melih Mutlu <m.melihmu...@gmail.com> > wrote: > > > > Logical replication between different types like int and smallint is > > already not > working properly on HEAD too. > > Yes, the scenario you shared looks like working. But you didn't create the > subscription with binary=true. The patch did not change subscription with > binary=false case. I believe what you should experiment is binary=true case > which already fails in the apply phase on HEAD. > > > > Well, with this patch, it will begin to fail in the table copy phase. But I > > don't > think this is a problem because logical replication in binary format is > already > broken for replications between different data types. > > > > So, doesn't this mean that there is no separate failure mode during > the initial copy? I am clarifying this to see if the patch really > needs a separate copy_format option for initial sync? >
In the case that the data type doesn't have binary output function, for apply phase, the column will be sent in text format (see logicalrep_write_tuple()) and it works fine. But with copy_format = binary, the walsender exits with an error. For example: -- create table on publisher and subscriber CREATE TYPE myvarchar; CREATE FUNCTION myvarcharin(cstring, oid, integer) RETURNS myvarchar LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharin'; CREATE FUNCTION myvarcharout(myvarchar) RETURNS cstring LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharout'; CREATE TYPE myvarchar ( input = myvarcharin, output = myvarcharout, alignment = integer, storage = main ); CREATE TABLE tbl1 (a myvarchar); -- create publication and insert some data on publisher create publication pub for table tbl1; INSERT INTO tbl1 values ('a'); -- create subscription on subscriber create subscription sub connection 'dbname=postgres port=5432' publication pub with(binary, copy_format = binary); Then I got the following error in the publisher log. walsender ERROR: no binary output function available for type public.myvarchar walsender STATEMENT: COPY public.tbl1 (a) TO STDOUT WITH (FORMAT binary) Regards, Shi Yu