Re: Test mail for pgsql-hackers

Started by BharatDBabout 1 year ago5 messageshackersbugs
Jump to latest
#1BharatDB
bharatdbpg@gmail.com
hackersbugs

Hi ,

I’ve been exploring logical replication and noticed that if the column
datatypes don’t match between the publisher and subscriber, PostgreSQL
doesn’t give a warning. This can cause unexpected behavior, and I thought
it might be helpful to alert users when this happens.

### **What This Patch Does:**

- Adds a warning when a column's datatype in the subscriber doesn’t match
the publisher.

- Helps users catch issues early instead of running into silent errors

Show quoted text

later.

Why I Think It’s Useful:- Avoids confusion when replication doesn’t work
as expected. - Makes debugging easier by pointing out potential problems.
I’d love to get feedback on whether this is a good idea and if I’ve
approached it correctly. Since I’m still learning, any suggestions for
improvement would be really helpful. I’ve attached the patch—please let me
know what you think!

Thanks, Blessy

Attachments:

Datatype_mismatch_logicalreplication_.patchtext/x-patch; charset=US-ASCII; name=Datatype_mismatch_logicalreplication_.patchDownload+28-1
#2BharatDB
bharatdbpg@gmail.com
In reply to: BharatDB (#1)
hackersbugs
Fwd: Test mail for pgsql-hackers

---------- Forwarded message ---------
From: BharatDB <bharatdbpg@gmail.com>
Date: Tue, Mar 11, 2025 at 6:03 PM
Subject: Re: Test mail for pgsql-hackers
To: pgsql-hackers Owner <pgsql-hackers-owner@lists.postgresql.org>, <
pgsql-hackers@lists.postgresql.org>, <pgsql-hackers@postgresql.org>

Hi ,

I’ve been exploring logical replication and noticed that if the column
datatypes don’t match between the publisher and subscriber, PostgreSQL
doesn’t give a warning. This can cause unexpected behavior, and I thought
it might be helpful to alert users when this happens.

### **What This Patch Does:**

- Adds a warning when a column's datatype in the subscriber doesn’t match
the publisher.

- Helps users catch issues early instead of running into silent errors

Show quoted text

later.

Why I Think It’s Useful:- Avoids confusion when replication doesn’t work
as expected. - Makes debugging easier by pointing out potential problems.
I’d love to get feedback on whether this is a good idea and if I’ve
approached it correctly. Since I’m still learning, any suggestions for
improvement would be really helpful. I’ve attached the patch—please let me
know what you think!

Thanks, Blessy

Attachments:

Datatype_mismatch_logicalreplication_.patchapplication/x-patch; name=Datatype_mismatch_logicalreplication_.patchDownload+28-1
#3Ashutosh Bapat
ashutosh.bapat@enterprisedb.com
In reply to: BharatDB (#1)
hackersbugs

Hi Blessy,

On Tue, Mar 11, 2025 at 6:03 PM BharatDB <bharatdbpg@gmail.com> wrote:

Hi ,

I’ve been exploring logical replication and noticed that if the column datatypes don’t match between the publisher and subscriber, PostgreSQL doesn’t give a warning. This can cause unexpected behavior, and I thought it might be helpful to alert users when this happens.

### **What This Patch Does:**

- Adds a warning when a column's datatype in the subscriber doesn’t match the publisher.

- Helps users catch issues early instead of running into silent errors later.

Why I Think It’s Useful:- Avoids confusion when replication doesn’t work as expected. - Makes debugging easier by pointing out potential problems. I’d love to get feedback on whether this is a good idea and if I’ve approached it correctly. Since I’m still learning, any suggestions for improvement would be really helpful. I’ve attached the patch—please let me know what you think!

Large part of your patch is renaming files which are not related to
this patch. Can you please clean that up.

The code also looks problematic
+    Oid local_typid = TupleDescAttr(tupdesc, i)->atttypid;
+    Oid remote_typid = lrel.atttyps[i];

AFAIK, the attribute positions on the publisher and subscriber need
not match, but this code assumes that the attributes at ith position
on publisher has to be mapped to the attribute at the same position on
the subscriber.

+
+    /* Get human-readable type names */
+    char *local_typname = format_type_be(local_typid);
+    char *remote_typname = format_type_be(remote_typid);

format_type_be() will give the name of the type on the subscriber not
on the publisher. You will need to look up logical replication type
cache for the name of the type on remote. If further assumes that the
OIDs on the same types on the publisher and the subscriber are same,
which may not be.

My memory is hazy as to whether we consider the types with the same
name on publisher and subscriber to be equivalent. If not, then I see
no way to make sure that the mapped columns are of the same type.

--
Best Wishes,
Ashutosh Bapat

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: Ashutosh Bapat (#3)
hackersbugs

On Wednesday, March 12, 2025, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
wrote:

Hi Blessy,

On Tue, Mar 11, 2025 at 6:03 PM BharatDB <bharatdbpg@gmail.com> wrote:

Hi ,

I’ve been exploring logical replication and noticed that if the column

datatypes don’t match between the publisher and subscriber, PostgreSQL
doesn’t give a warning. This can cause unexpected behavior, and I thought
it might be helpful to alert users when this happens.

### **What This Patch Does:**

- Adds a warning when a column's datatype in the subscriber doesn’t

match the publisher.

- Helps users catch issues early instead of running into silent errors

later.

Why I Think It’s Useful:- Avoids confusion when replication doesn’t

work as expected. - Makes debugging easier by pointing out potential
problems. I’d love to get feedback on whether this is a good idea and if
I’ve approached it correctly. Since I’m still learning, any suggestions for
improvement would be really helpful. I’ve attached the patch—please let me
know what you think!

Large part of your patch is renaming files which are not related to
this patch. Can you please clean that up.

If there is really a patch submission happening here I suggest you start a
new thread with a meaningful subject line and proper recipients (one list,
not -owners)

David J.

#5Andres Freund
andres@anarazel.de
In reply to: Ashutosh Bapat (#3)
hackersbugs

On 2025-03-12 15:56:08 +0530, Ashutosh Bapat wrote:

Large part of your patch is renaming files which are not related to
this patch. Can you please clean that up.

Since this has not been fixed, and the patch has not passed CI since at least
mid March, I'll close this CF entry.