Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6eeb67

Browse files
committed
Fix a bunch more portability bugs in commit08bf6e5.
It seems like somebody used a dartboard while choosing integer widthsfor the various values taken and returned by these functions ... andthen threw a fresh set of darts while writing the SQL declarations.This patch brings the C code into line with what the SQL declarationssay, which is enough to make it not dump core on the particular 32-bitmachine I'm testing on. But I think we could do with another roundof looking at what the datum widths *should* be. For instance, it'snot all that sensible that hash_bitmap_info decided to use int64 torepresent a BlockNumber input when get_raw_page doesn't do it that way.There's also a remaining problem that the expected outputs from thetest script are platform-dependent, but I'll leave that issue forsomebody else.Per buildfarm.
1 parented807fd commitc6eeb67

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

‎contrib/pageinspect/hashfuncs.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ hash_page_items(PG_FUNCTION_ARGS)
360360
values[j++]=PointerGetDatum(&itup->t_tid);
361361

362362
hashkey=_hash_get_indextuple_hashkey(itup);
363-
values[j]=UInt32GetDatum(hashkey);
363+
values[j]=UInt64GetDatum((uint64)hashkey);
364364

365365
tuple=heap_form_tuple(fctx->attinmeta->tupdesc,values,nulls);
366366
result=HeapTupleGetDatum(tuple);
@@ -388,7 +388,7 @@ Datum
388388
hash_bitmap_info(PG_FUNCTION_ARGS)
389389
{
390390
OidindexRelid=PG_GETARG_OID(0);
391-
BlockNumberovflblkno= (BlockNumber)PG_GETARG_INT64(1);
391+
uint64ovflblkno=PG_GETARG_INT64(1);
392392
HashMetaPagemetap;
393393
Bufferbuf,
394394
metabuf;
@@ -422,13 +422,14 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
422422
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
423423
errmsg("cannot access temporary tables of other sessions")));
424424

425-
if (RelationGetNumberOfBlocks(indexRel) <= (BlockNumber) (ovflblkno))
425+
if (ovflblkno >=RelationGetNumberOfBlocks(indexRel))
426426
ereport(ERROR,
427427
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
428-
errmsg("block number%u is out of range for relation \"%s\"",
428+
errmsg("block number"UINT64_FORMAT" is out of range for relation \"%s\"",
429429
ovflblkno,RelationGetRelationName(indexRel))));
430430

431-
buf=ReadBufferExtended(indexRel,MAIN_FORKNUM,ovflblkno,RBM_NORMAL,NULL);
431+
buf=ReadBufferExtended(indexRel,MAIN_FORKNUM, (BlockNumber)ovflblkno,
432+
RBM_NORMAL,NULL);
432433
LockBuffer(buf,BUFFER_LOCK_SHARE);
433434
_hash_checkpage(indexRel,buf,LH_PAGE_TYPE);
434435
page=BufferGetPage(buf);
@@ -451,7 +452,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
451452
metap=HashPageGetMeta(BufferGetPage(metabuf));
452453

453454
/* Identify overflow bit number */
454-
ovflbitno=_hash_ovflblkno_to_bitno(metap,ovflblkno);
455+
ovflbitno=_hash_ovflblkno_to_bitno(metap,(BlockNumber)ovflblkno);
455456

456457
bitmappage=ovflbitno >>BMPG_SHIFT(metap);
457458
bitmapbit=ovflbitno&BMPG_MASK(metap);
@@ -475,7 +476,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
475476
MemSet(nulls,0,sizeof(nulls));
476477

477478
j=0;
478-
values[j++]=UInt32GetDatum(bitmapblkno);
479+
values[j++]=UInt64GetDatum((uint64)bitmapblkno);
479480
values[j++]=Int32GetDatum(bitmapbit);
480481
values[j++]=BoolGetDatum(bit);
481482

@@ -524,34 +525,34 @@ hash_metapage_info(PG_FUNCTION_ARGS)
524525
MemSet(nulls,0,sizeof(nulls));
525526

526527
j=0;
527-
values[j++]=UInt32GetDatum(metad->hashm_magic);
528-
values[j++]=UInt32GetDatum(metad->hashm_version);
528+
values[j++]=UInt64GetDatum(metad->hashm_magic);
529+
values[j++]=UInt64GetDatum(metad->hashm_version);
529530
values[j++]=Float8GetDatum(metad->hashm_ntuples);
530-
values[j++]=UInt16GetDatum(metad->hashm_ffactor);
531-
values[j++]=UInt16GetDatum(metad->hashm_bsize);
532-
values[j++]=UInt16GetDatum(metad->hashm_bmsize);
533-
values[j++]=UInt16GetDatum(metad->hashm_bmshift);
534-
values[j++]=UInt32GetDatum(metad->hashm_maxbucket);
535-
values[j++]=UInt32GetDatum(metad->hashm_highmask);
536-
values[j++]=UInt32GetDatum(metad->hashm_lowmask);
537-
values[j++]=UInt32GetDatum(metad->hashm_ovflpoint);
538-
values[j++]=UInt32GetDatum(metad->hashm_firstfree);
539-
values[j++]=UInt32GetDatum(metad->hashm_nmaps);
540-
values[j++]=UInt16GetDatum(metad->hashm_procid);
531+
values[j++]=UInt32GetDatum(metad->hashm_ffactor);
532+
values[j++]=UInt32GetDatum(metad->hashm_bsize);
533+
values[j++]=UInt32GetDatum(metad->hashm_bmsize);
534+
values[j++]=UInt32GetDatum(metad->hashm_bmshift);
535+
values[j++]=UInt64GetDatum(metad->hashm_maxbucket);
536+
values[j++]=UInt64GetDatum(metad->hashm_highmask);
537+
values[j++]=UInt64GetDatum(metad->hashm_lowmask);
538+
values[j++]=UInt64GetDatum(metad->hashm_ovflpoint);
539+
values[j++]=UInt64GetDatum(metad->hashm_firstfree);
540+
values[j++]=UInt64GetDatum(metad->hashm_nmaps);
541+
values[j++]=UInt32GetDatum(metad->hashm_procid);
541542

542543
for (i=0;i<HASH_MAX_SPLITPOINTS;i++)
543-
spares[i]=UInt32GetDatum(metad->hashm_spares[i]);
544+
spares[i]=UInt64GetDatum(metad->hashm_spares[i]);
544545
values[j++]=PointerGetDatum(construct_array(spares,
545546
HASH_MAX_SPLITPOINTS,
546547
INT8OID,
547-
8,true,'d'));
548+
8,FLOAT8PASSBYVAL,'d'));
548549

549550
for (i=0;i<HASH_MAX_BITMAPS;i++)
550-
mapp[i]=UInt32GetDatum(metad->hashm_mapp[i]);
551+
mapp[i]=UInt64GetDatum(metad->hashm_mapp[i]);
551552
values[j++]=PointerGetDatum(construct_array(mapp,
552553
HASH_MAX_BITMAPS,
553554
INT8OID,
554-
8,true,'d'));
555+
8,FLOAT8PASSBYVAL,'d'));
555556

556557
tuple=heap_form_tuple(tupleDesc,values,nulls);
557558

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp