Обсуждение: Re: [PATCHES] pgstattuple extension for indexes

Поиск
Список
Период
Сортировка

Re: [PATCHES] pgstattuple extension for indexes

От
Tom Lane
Дата:
Bruce Momjian <bruce@momjian.us> writes:
> Patch applied.  Thanks.

For some reason I expected this patch to correct the portability errors
and design problems identified here:
http://archives.postgresql.org/pgsql-patches/2006-07/msg00100.php

Not only has it not fixed anything, it's made things worse:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing-g -fpic -I. -I../../src/include -D_GNU_SOURCE   -c -o pgstattuple.o pgstattuple.c 
pgstattuple.c: In function 'pgstat_btree':
pgstattuple.c:335: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'uint64'
pgstattuple.c:335: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'uint64'
pgstattuple.c:335: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'uint64'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing-g -fpic -I. -I../../src/include -D_GNU_SOURCE   -c -o pgstatindex.o pgstatindex.c 
pgstatindex.c: In function 'bt_page_items':
pgstatindex.c:564: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'
pgstatindex.c:564: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'
ar crs libpgstattuple.a pgstattuple.o pgstatindex.o

The only reason the buildfarm isn't crashing on this contrib module is
that it lacks any regression test to crash on.

            regards, tom lane

Re: [PATCHES] pgstattuple extension for indexes

От
Satoshi Nagayasu
Дата:
Tom Lane wrote:
> gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing-g -fpic -I. -I../../src/include -D_GNU_SOURCE   -c -o pgstatindex.o pgstatindex.c 
> pgstatindex.c: In function 'bt_page_items':
> pgstatindex.c:564: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'
> pgstatindex.c:564: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'

I guess my '%d' should be '%zd', right?
--
NAGAYASU Satoshi <nagayasus@nttdata.co.jp>
Phone: +81-3-3523-8122
*** pgstatindex.c    2006-09-03 02:05:29.000000000 +0900
--- pgstatindex.c.new    2006-09-04 08:22:42.000000000 +0900
***************
*** 561,567 ****
              values[j] = palloc(32);
              snprintf(values[j++], 32, "(%u,%u)", blkno, itup->t_tid.ip_posid);
              values[j] = palloc(32);
!             snprintf(values[j++], 32, "%d", IndexTupleSize(itup));
              values[j] = palloc(32);
              snprintf(values[j++], 32, "%c", IndexTupleHasNulls(itup) ? 't' : 'f');
              values[j] = palloc(32);
--- 561,567 ----
              values[j] = palloc(32);
              snprintf(values[j++], 32, "(%u,%u)", blkno, itup->t_tid.ip_posid);
              values[j] = palloc(32);
!             snprintf(values[j++], 32, "%zd", IndexTupleSize(itup));
              values[j] = palloc(32);
              snprintf(values[j++], 32, "%c", IndexTupleHasNulls(itup) ? 't' : 'f');
              values[j] = palloc(32);

Re: [PATCHES] pgstattuple extension for indexes

От
Tom Lane
Дата:
Satoshi Nagayasu <nagayasus@nttdata.co.jp> writes:
> Tom Lane wrote:
>> pgstatindex.c: In function 'bt_page_items':
>> pgstatindex.c:564: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'

> I guess my '%d' should be '%zd', right?

No, that sounds even less portable :-(

Given the expected range of IndexTupleSize(), it seems sufficient to
cast its result to int and then use %d formatting.  I've done that
in the latest commit.

            regards, tom lane