Re: BUG #19429: An issue regarding the processing of Oid as an int type in ecpg

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: fairyfar@msn.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2026-03-15T23:00:28Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> Part of the code caches and calculates the Oid as an int type in ecpg.
> We know that Oid is unsigned int. When the Oid value is greater than or
> equal to 2^31, it exceeds the value range of the int type. There are
> potential problems in processing Oid with the int type. For example, when
> formatting Oid with "%d", negative values may occur.

> Through analysis and testing, it is found that the ecpg part of the code has
> not caused any problems so far, but it is running in an obscure way.

Yeah, it does work as-is, but it's relying on undocumented details
about what the server will do with something like "oid=-1".

I reviewed your patch and pushed it.  For future reference, it's not
great to send patches via our bug report form; whitespace gets mangled
and it's quite painful to reconstruct.  Better to just send email to
pgsql-hackers with the patch in an attachment.

			regards, tom lane



Commits

  1. Be more careful about int vs. Oid in ecpglib.