Re: User defined data types in Logical Replication - Mailing list pgsql-hackers

From Dang Minh Huong
Subject Re: User defined data types in Logical Replication
Date
Msg-id 0ec082ce-8c06-bfdb-788c-13e15ba0ba17@gmail.com
Whole thread Raw
In response to Re: Re: User defined data types in Logical Replication  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: User defined data types in Logical Replication  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers

Hi Sawada-san,

Sorry for my late response.

On 2017/12/05 0:11, Masahiko Sawada wrote:
There is one more case that user-defined data type is not supported in Logical Replication.
That is when remote data type's name does not exist in SUBSCRIBE.

In relation.c:logicalrep_typmap_gettypname
We search OID in syscache by remote's data type name and mapping it, if it does not exist in syscache
We will be faced with the bellow error.
       if (!OidIsValid(entry->typoid))               ereport(ERROR,                               (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),                                errmsg("data type \"%s.%s\" required for logical replication does not exist",                                               entry->nspname, entry->typname)));

I think, it is not necessary to check typoid here in order to avoid above case, is that right?
I think it's not right. We should end up with an error in the case where the same type name doesn't exist on subscriber. With your proposed patch, logicalrep_typmap_gettypname() can return an invalid string (entry->typname) in that case, which can be a cause of SEGV.
Thanks, I think you are right.
# I thought that entry->typname was received from walsender, and it is already be qualified in logicalrep_write_typ.
# But we also need check it in subscriber, because it could be lost info in transmission.
Also we do not need to fix for the case above too, because user can change type name by ALTER TYPE statement.
I attached the patch, which based on your patch with a bit of modified messages.

--- 
Thanks and best regards, 
Dang Minh Huong 


Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ALTER TABLE ADD COLUMN fast default
Next
From: Andrew Dunstan
Date:
Subject: Re: ALTER TABLE ADD COLUMN fast default