Re: WIP patch for Oid formatting in printf/elog strings - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: WIP patch for Oid formatting in printf/elog strings
Date
Msg-id CAE-h2Topay9sbTt86OrEzmkApoTbuaSwsCO_9e7FW_6tEFRU2g@mail.gmail.com
Whole thread Raw
In response to Re: WIP patch for Oid formatting in printf/elog strings  (Mark Dilger <hornschnorter@gmail.com>)
Responses Re: WIP patch for Oid formatting in printf/elog strings  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
I spoke too soon.  Actually, the Oid definition is in src/include/postgres_ext.h,
which I'm sure you all know.  But I'm changing other typedefs too, not
just for Oid.

I've been going through a copy of the code and replacing int32 and uint32
with the appropriate type such as Oid, TransactionId, and such, and have
created my own typedef for TypeModType, in order to help chase through
the code and figure out what functions handle what kind of data.  By
defining TypeModType to int64, for example, I get lots of compiler errors
when passing a TypeModType * into a function that takes int32 *, and that
lets me know that the callers of that function think of it as a typemod argument,
even if it does not have any clear documentation to that effect.

The exercise is a bit tedious, as I have to change lots of strings like
"the value %d is out of bounds" to something like
"the value " TYPEMODTYPE_FORMAT " is out of bounds", but the clarity
I get from it helps enough that it is useful to me.

I hope to eventually be able to simply pass switches to configure like
--64bit-oids and have the whole system work with Oid defined as 64-bits.
Likewise for varlena headers.

I ported the whole of postgres to 64-bit Oids and 64-bit varlena headers
once before, and it worked and passed all the regression tests and such,
but I did it by replacing lots of instances of int32 with instances of int64,
so it didn't help clarify the meaning of anything.  This time, I'm hoping that
I can keep in sync with all the commits so that I can build a 32-bit or a
64-bit postgres at a moments notice.


Mark Dilger

On Thu, Dec 11, 2014 at 1:25 PM, Mark Dilger <hornschnorter@gmail.com> wrote:


On Thu, Dec 11, 2014 at 12:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Mark Dilger <hornschnorter@gmail.com> writes:
> The attached patch changes the type of chunk_seq to int32,
> rather than changing the %d formatting.  The other changes
> are the same as in the previous patch.

BTW, how are you finding these?  If it's some automated tool, what?
(If you're finding them by hand, I'm in awe of your scan rate.)

                        regards, tom lane

I've been advised to hoodwink you and say that I have found them all
by hand.  Actually, I am changing the typedef in src/include/c.h and then
recompiling, and watching for compiler warnings telling me that I am
passing a uint64 to a %d.  Of course, I get lots of warnings about
passing a uint64 to a %u, but I can filter through those easily enough.

Also, the macros in outfuncs.c tend to complain in a similar way, and
I can check that output, too.

mark

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Commitfest problems
Next
From: Bruce Momjian
Date:
Subject: Re: WIP patch for Oid formatting in printf/elog strings