Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 871ec0e

Browse files
committed
pageinspect: More type-sanity surgery on the new hash index code.
Uniformly expose unsigned quantities using the next-wider signed integer type (since we have no unsigned types at the SQL level). At the SQL level, this results a change to report itemoffset as int4 rather than int2. Also at the SQL level, report one value that is an OID as type oid. Under the hood, uniformly use macros that match the SQL output type as to both width and signedness.
1 parent e759854 commit 871ec0e

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

contrib/pageinspect/hashfuncs.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ hash_page_items(PG_FUNCTION_ARGS)
346346
MemSet(nulls, 0, sizeof(nulls));
347347

348348
j = 0;
349-
values[j++] = UInt16GetDatum(uargs->offset);
349+
values[j++] = Int32GetDatum((int32) uargs->offset);
350350
values[j++] = PointerGetDatum(&itup->t_tid);
351351

352352
hashkey = _hash_get_indextuple_hashkey(itup);
353-
values[j] = UInt64GetDatum((uint64) hashkey);
353+
values[j] = Int64GetDatum((int64) hashkey);
354354

355355
tuple = heap_form_tuple(fctx->attinmeta->tupdesc, values, nulls);
356356
result = HeapTupleGetDatum(tuple);
@@ -466,7 +466,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
466466
MemSet(nulls, 0, sizeof(nulls));
467467

468468
j = 0;
469-
values[j++] = UInt64GetDatum((uint64) bitmapblkno);
469+
values[j++] = Int64GetDatum((int64) bitmapblkno);
470470
values[j++] = Int32GetDatum(bitmapbit);
471471
values[j++] = BoolGetDatum(bit);
472472

@@ -515,30 +515,30 @@ hash_metapage_info(PG_FUNCTION_ARGS)
515515
MemSet(nulls, 0, sizeof(nulls));
516516

517517
j = 0;
518-
values[j++] = UInt64GetDatum(metad->hashm_magic);
519-
values[j++] = UInt64GetDatum(metad->hashm_version);
518+
values[j++] = Int64GetDatum((int64) metad->hashm_magic);
519+
values[j++] = Int64GetDatum((int64) metad->hashm_version);
520520
values[j++] = Float8GetDatum(metad->hashm_ntuples);
521-
values[j++] = UInt32GetDatum(metad->hashm_ffactor);
522-
values[j++] = UInt32GetDatum(metad->hashm_bsize);
523-
values[j++] = UInt32GetDatum(metad->hashm_bmsize);
524-
values[j++] = UInt32GetDatum(metad->hashm_bmshift);
525-
values[j++] = UInt64GetDatum(metad->hashm_maxbucket);
526-
values[j++] = UInt64GetDatum(metad->hashm_highmask);
527-
values[j++] = UInt64GetDatum(metad->hashm_lowmask);
528-
values[j++] = UInt64GetDatum(metad->hashm_ovflpoint);
529-
values[j++] = UInt64GetDatum(metad->hashm_firstfree);
530-
values[j++] = UInt64GetDatum(metad->hashm_nmaps);
531-
values[j++] = UInt32GetDatum(metad->hashm_procid);
521+
values[j++] = Int32GetDatum((int32) metad->hashm_ffactor);
522+
values[j++] = Int32GetDatum((int32) metad->hashm_bsize);
523+
values[j++] = Int32GetDatum((int32) metad->hashm_bmsize);
524+
values[j++] = Int32GetDatum((int32) metad->hashm_bmshift);
525+
values[j++] = Int64GetDatum((int64) metad->hashm_maxbucket);
526+
values[j++] = Int64GetDatum((int64) metad->hashm_highmask);
527+
values[j++] = Int64GetDatum((int64) metad->hashm_lowmask);
528+
values[j++] = Int64GetDatum((int64) metad->hashm_ovflpoint);
529+
values[j++] = Int64GetDatum((int64) metad->hashm_firstfree);
530+
values[j++] = Int64GetDatum((int64) metad->hashm_nmaps);
531+
values[j++] = ObjectIdGetDatum((Oid) metad->hashm_procid);
532532

533533
for (i = 0; i < HASH_MAX_SPLITPOINTS; i++)
534-
spares[i] = UInt64GetDatum(metad->hashm_spares[i]);
534+
spares[i] = Int64GetDatum((int8) metad->hashm_spares[i]);
535535
values[j++] = PointerGetDatum(construct_array(spares,
536536
HASH_MAX_SPLITPOINTS,
537537
INT8OID,
538538
8, FLOAT8PASSBYVAL, 'd'));
539539

540540
for (i = 0; i < HASH_MAX_BITMAPS; i++)
541-
mapp[i] = UInt64GetDatum(metad->hashm_mapp[i]);
541+
mapp[i] = Int64GetDatum((int64) metad->hashm_mapp[i]);
542542
values[j++] = PointerGetDatum(construct_array(mapp,
543543
HASH_MAX_BITMAPS,
544544
INT8OID,

contrib/pageinspect/pageinspect--1.5--1.6.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ LANGUAGE C STRICT PARALLEL SAFE;
3535
-- hash_page_items()
3636
--
3737
CREATE FUNCTION hash_page_items(IN page bytea,
38-
OUT itemoffset smallint,
38+
OUT itemoffset int4,
3939
OUT ctid tid,
4040
OUT data int8)
4141
RETURNS SETOF record
@@ -70,7 +70,7 @@ CREATE FUNCTION hash_metapage_info(IN page bytea,
7070
OUT ovflpoint int8,
7171
OUT firstfree int8,
7272
OUT nmaps int8,
73-
OUT procid int4,
73+
OUT procid oid,
7474
OUT spares int8[],
7575
OUT mapp int8[])
7676
AS 'MODULE_PATHNAME', 'hash_metapage_info'

0 commit comments

Comments
 (0)