Re: WIP patch for Oid formatting in printf/elog strings

From: Mark Dilger <hornschnorter(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: WIP patch for Oid formatting in printf/elog strings
Date: 2014-12-11 21:40:54
Message-ID: CAE-h2Topay9sbTt86OrEzmkApoTbuaSwsCO_9e7FW_6tEFRU2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)com>
wrote:

>
>
> On Thu, Dec 11, 2014 at 12:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Mark Dilger <hornschnorter(at)gmail(dot)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
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2014-12-11 21:40:57 Re: WIP patch for Oid formatting in printf/elog strings
Previous Message Bruce Momjian 2014-12-11 21:40:16 Re: Commitfest problems