Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2e480d2
Make EXEC_BACKEND more convenient on Linux and FreeBSD.
michaelpq Feb 8, 2023
3cd80fd
Stop recommending auto-download of DTD files, and indeed disable it.
tglsfdc Feb 8, 2023
bf3ee4c
Disable WindowAgg inverse transitions when subplans are present
david-rowley Feb 13, 2023
48813fb
Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certific…
michaelpq Feb 15, 2023
7cdf8fe
Print the correct aliases for DML target tables in ruleutils.
tglsfdc Feb 17, 2023
6ca8ff5
Fix handling of multi-column BRIN indexes
tvondra Feb 18, 2023
54a8883
pgbench: Prepare commands in pipelines in advance
alvherre Feb 21, 2023
c36369b
Add missing support for the latest SPI status codes.
deanrasheed Feb 22, 2023
c3aab62
Fix snapshot handling in logicalmsg_decode
tvondra Feb 22, 2023
ead09a5
Don't repeatedly register cache callbacks in pgoutput plugin.
tglsfdc Feb 23, 2023
cbce817
Fix mishandling of OLD/NEW references in subqueries in rule actions.
deanrasheed Feb 25, 2023
7edfa9d
Don't force SQL_ASCII/no-locale for installcheck in vcregress.pl
adunstan Feb 26, 2023
40b493c
Harden postgres_fdw tests against unexpected cache flushes.
tglsfdc Feb 27, 2023
8761ea5
Avoid fetching one past the end of translate()'s "to" parameter.
tglsfdc Mar 1, 2023
bee87f8
pageinspect: Fix crash with gist_page_items()
michaelpq Mar 2, 2023
1b0d060
Fix assert failures in parallel SERIALIZABLE READ ONLY.
macdice Mar 6, 2023
d2ce335
Fix more bugs caused by adding columns to the end of a view.
tglsfdc Mar 7, 2023
f45fca3
Fix corruption due to vacuum_defer_cleanup_age underflowing 64bit xids
anarazel Mar 8, 2023
f08cf76
Fix race in SERIALIZABLE READ ONLY.
macdice Mar 9, 2023
e1c98a9
Fix misbehavior in contrib/pg_trgm with an unsatisfiable regex.
tglsfdc Mar 11, 2023
ce31c34
amcheck: Fix ordering bug in update_cached_xid_range()
anarazel Mar 11, 2023
48bb92a
amcheck: Fix FullTransactionIdFromXidAndCtx() for xids before epoch 0
anarazel Mar 11, 2023
6f3249e
Mark unsafe_tests module as not runnable with installcheck
adunstan Mar 12, 2023
3be1c05
Fix inconsistent error handling for GSS encryption in PQconnectPoll()
michaelpq Mar 13, 2023
8917dcb
Remove unnecessary code in dependency_is_compatible_expression().
tglsfdc Mar 14, 2023
90566f8
Fix corner case bug in numeric to_char() some more.
tglsfdc Mar 14, 2023
b87e5c2
Fix waitpid() emulation on Windows.
macdice Mar 15, 2023
4aaa6c4
Fix fractional vacuum_cost_delay.
macdice Mar 15, 2023
37c7f8e
Improve WIN32 port of fstat() to detect more file types
michaelpq Mar 15, 2023
e5428b0
Doc: mention CREATE+ATTACH PARTITION with CREATE TABLE...PARTITION OF.
tglsfdc Mar 16, 2023
2aa9a62
Small tidyup for commit d41a178b.
macdice Mar 16, 2023
9b2e2d1
Small tidyup for commit d41a178b, part II.
macdice Mar 17, 2023
220ecb7
tests: Minimize syslog activity by slapd
anarazel Mar 17, 2023
5ef9103
tests: Prevent syslog activity by slapd, take 2
anarazel Mar 17, 2023
8daf64e
Fix pg_dump for hash partitioning on enum columns.
tglsfdc Mar 17, 2023
92e5620
Doc: fix documentation example for bytea hex output format.
tglsfdc Mar 18, 2023
4662460
Fix memory leak in Memoize cache key evaluation
david-rowley Mar 20, 2023
02cdcd5
Fix netmask handling in inet_minmax_multi_ops
tvondra Mar 20, 2023
38998db
Fix race in parallel hash join batch cleanup, take II.
macdice Mar 21, 2023
11658db
Ignore dropped columns during apply of update/delete.
Mar 21, 2023
3e52039
doc: Add description of some missing monitoring functions
michaelpq Mar 22, 2023
838b39e
Ignore generated columns during apply of update/delete.
Mar 23, 2023
b1baa95
amcheck: Fix verify_heapam for tuples where xmin or xmax is 0.
robertmhaas Mar 23, 2023
b21e7b7
Fix oversights in array manipulation.
tglsfdc Mar 26, 2023
640eb4e
Reject attempts to alter composite types used in indexes.
tglsfdc Mar 27, 2023
c80bda8
doc: Fix XML_CATALOG_FILES env var for Apple Silicon machines
danielgustafsson Mar 27, 2023
d9aeca1
amcheck: In verify_heapam, allows tuples with xmin 0.
robertmhaas Mar 28, 2023
a678c6e
Fix dereference of dangling pointer in GiST index buffering build.
tglsfdc Mar 29, 2023
dc1aa5b
Fix List memory issue in transformColumnDefinition
david-rowley Mar 30, 2023
147d6e6
Ensure acquire_inherited_sample_rows sets its output parameters.
tglsfdc Mar 31, 2023
ad1b535
Reject system columns as elements of foreign keys.
tglsfdc Mar 31, 2023
78b5419
doc: Add more details about pg_stat_get_xact_blocks_{fetched,hit}
michaelpq Apr 4, 2023
0a95d1c
doc: Update error messages in RLS examples
j-naylor Apr 5, 2023
24eb9c7
Fix ts_headline() edge cases for empty query and empty search text.
tglsfdc Apr 6, 2023
5e5a293
Stabilize just-added regression test cases.
tglsfdc Apr 6, 2023
2096d93
For Kerberos testing, disable reverse DNS lookup
sfrost Apr 7, 2023
3ccccaa
For Kerberos testing, disable DNS lookups
sfrost Apr 7, 2023
40fa819
Doc: adjust examples of EXTRACT() output to match current reality.
tglsfdc Apr 10, 2023
a8b7ab6
Doc: add missed entries in BRIN extensibility tables.
tglsfdc Apr 10, 2023
c42082d
Fix detection of unseekable files for fseek() and ftello() with MSVC
michaelpq Apr 12, 2023
b23bd7f
doc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+
danielgustafsson Apr 14, 2023
2fef36b
Avoid trying to write an empty WAL record in log_newpage_range().
tglsfdc Apr 17, 2023
d76f465
ecpg: Fix handling of strings in ORACLE compat code with SQLDA
michaelpq Apr 18, 2023
4249393
Use --strip-unneeded when stripping static libraries with GNU strip.
tglsfdc Apr 20, 2023
e399567
Fix custom validators call in build_local_reloptions()
akorotkov Apr 23, 2023
37e3178
Remove duplicate lines of code
danielgustafsson Apr 24, 2023
7105323
Fix memory leakage in plpgsql DO blocks that use cast expressions.
tglsfdc Apr 24, 2023
752f692
Fix vacuum_cost_delay check for balance calculation.
danielgustafsson Apr 25, 2023
93e904f
Re-add tracking of wait event SLRUFlushSync
michaelpq Apr 25, 2023
2f0cebc
In hstore_plpython, avoid crashing when return value isn't a mapping.
tglsfdc Apr 27, 2023
4e4cb97
Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements
michaelpq Apr 28, 2023
0d94316
Tighten array dimensionality checks in Perl -> SQL array conversion.
tglsfdc Apr 29, 2023
1bf6fcf
doc: Fix typo in pg_amcheck for term "schema"
michaelpq May 2, 2023
b8476c0
Doc: clarify behavior of row-limit arguments in the PLs' SPI wrappers.
tglsfdc May 2, 2023
f8cdf6d
In array_position()/array_positions(), beware of empty input array.
tglsfdc May 4, 2023
203bf50
Fix prove_installcheck when used with PGXS
petere May 5, 2023
0fe678e
Fix typo with wait event for SLRU buffer of commit timestamps
michaelpq May 5, 2023
f9fed44
Adapt regreesion test suite for changes
reshke Jun 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/programs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ AC_DEFUN([PGAC_CHECK_STRIP],

AC_MSG_CHECKING([whether it is possible to strip libraries])
if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
STRIP_STATIC_LIB="$STRIP -x"
STRIP_STATIC_LIB="$STRIP --strip-unneeded"
STRIP_SHARED_LIB="$STRIP --strip-unneeded"
AC_MSG_RESULT(yes)
else
Expand Down
22 changes: 20 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -11814,7 +11814,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is possible to strip libraries" >&5
$as_echo_n "checking whether it is possible to strip libraries... " >&6; }
if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
STRIP_STATIC_LIB="$STRIP -x"
STRIP_STATIC_LIB="$STRIP --strip-unneeded"
STRIP_SHARED_LIB="$STRIP --strip-unneeded"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
Expand Down Expand Up @@ -15802,6 +15802,18 @@ if test "x$ac_cv_func_CRYPTO_lock" = xyes; then :
#define HAVE_CRYPTO_LOCK 1
_ACEOF

fi
done

# Function introduced in OpenSSL 1.1.1.
for ac_func in X509_get_signature_info
do :
ac_fn_c_check_func "$LINENO" "X509_get_signature_info" "ac_cv_func_X509_get_signature_info"
if test "x$ac_cv_func_X509_get_signature_info" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_X509_GET_SIGNATURE_INFO 1
_ACEOF

fi
done

Expand Down Expand Up @@ -16895,7 +16907,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
fi


for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/event.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/tas.h sys/uio.h sys/un.h termios.h ucred.h wctype.h
for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/tas.h sys/uio.h sys/un.h termios.h ucred.h wctype.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
Expand Down Expand Up @@ -20416,6 +20428,12 @@ esac
;;
esac

case " $LIBOBJS " in
*" win32common.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS win32common.$ac_objext"
;;
esac

case " $LIBOBJS " in
*" win32env.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS win32env.$ac_objext"
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,8 @@ if test "$with_ssl" = openssl ; then
# thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
# function was removed.
AC_CHECK_FUNCS([CRYPTO_lock])
# Function introduced in OpenSSL 1.1.1.
AC_CHECK_FUNCS([X509_get_signature_info])
AC_DEFINE([USE_OPENSSL], 1, [Define to 1 to build with OpenSSL support. (--with-ssl=openssl)])
elif test "$with_ssl" != no ; then
AC_MSG_ERROR([--with-ssl must specify openssl])
Expand Down Expand Up @@ -1904,6 +1906,7 @@ AC_CHECK_HEADERS(m4_normalize([
sys/epoll.h
sys/event.h
sys/ipc.h
sys/personality.h
sys/prctl.h
sys/procctl.h
sys/pstat.h
Expand Down Expand Up @@ -2518,6 +2521,7 @@ if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(kill)
AC_LIBOBJ(open)
AC_LIBOBJ(system)
AC_LIBOBJ(win32common)
AC_LIBOBJ(win32env)
AC_LIBOBJ(win32error)
AC_LIBOBJ(win32security)
Expand Down
44 changes: 37 additions & 7 deletions contrib/amcheck/verify_heapam.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ check_tuple_visibility(HeapCheckContext *ctx)
switch (get_xid_status(xmin, ctx, &xmin_status))
{
case XID_INVALID:
/* Could be the result of a speculative insertion that aborted. */
return false;
case XID_BOUNDS_OK:
break;
case XID_IN_FUTURE:
Expand Down Expand Up @@ -1110,6 +1112,9 @@ check_tuple_visibility(HeapCheckContext *ctx)
xmax = HeapTupleHeaderGetRawXmax(tuphdr);
switch (get_xid_status(xmax, ctx, &xmax_status))
{
case XID_INVALID:
ctx->tuple_could_be_pruned = false;
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
Expand All @@ -1132,7 +1137,6 @@ check_tuple_visibility(HeapCheckContext *ctx)
XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
break;
}

Expand Down Expand Up @@ -1577,14 +1581,40 @@ check_tuple(HeapCheckContext *ctx)
static FullTransactionId
FullTransactionIdFromXidAndCtx(TransactionId xid, const HeapCheckContext *ctx)
{
uint32 epoch;
uint64 nextfxid_i;
int32 diff;
FullTransactionId fxid;

Assert(TransactionIdIsNormal(ctx->next_xid));
Assert(FullTransactionIdIsNormal(ctx->next_fxid));
Assert(XidFromFullTransactionId(ctx->next_fxid) == ctx->next_xid);

if (!TransactionIdIsNormal(xid))
return FullTransactionIdFromEpochAndXid(0, xid);
epoch = EpochFromFullTransactionId(ctx->next_fxid);
if (xid > ctx->next_xid)
epoch--;
return FullTransactionIdFromEpochAndXid(epoch, xid);

nextfxid_i = U64FromFullTransactionId(ctx->next_fxid);

/* compute the 32bit modulo difference */
diff = (int32) (ctx->next_xid - xid);

/*
* In cases of corruption we might see a 32bit xid that is before epoch
* 0. We can't represent that as a 64bit xid, due to 64bit xids being
* unsigned integers, without the modulo arithmetic of 32bit xid. There's
* no really nice way to deal with that, but it works ok enough to use
* FirstNormalFullTransactionId in that case, as a freshly initdb'd
* cluster already has a newer horizon.
*/
if (diff > 0 && (nextfxid_i - FirstNormalTransactionId) < (int64) diff)
{
Assert(EpochFromFullTransactionId(ctx->next_fxid) == 0);
fxid = FirstNormalFullTransactionId;
}
else
fxid = FullTransactionIdFromU64(nextfxid_i - diff);

Assert(FullTransactionIdIsNormal(fxid));
return fxid;
}

/*
Expand All @@ -1600,8 +1630,8 @@ update_cached_xid_range(HeapCheckContext *ctx)
LWLockRelease(XidGenLock);

/* And compute alternate versions of the same */
ctx->oldest_fxid = FullTransactionIdFromXidAndCtx(ctx->oldest_xid, ctx);
ctx->next_xid = XidFromFullTransactionId(ctx->next_fxid);
ctx->oldest_fxid = FullTransactionIdFromXidAndCtx(ctx->oldest_xid, ctx);
}

/*
Expand Down
11 changes: 11 additions & 0 deletions contrib/hstore_plpython/expected/hstore_plpython.out
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ INFO: [('aa', 'bb'), ('cc', None)]
2
(1 row)

-- test that a non-mapping result is correctly rejected
CREATE FUNCTION test1bad() RETURNS hstore
LANGUAGE plpythonu
TRANSFORM FOR TYPE hstore
AS $$
return "foo"
$$;
SELECT test1bad();
ERROR: not a Python mapping
CONTEXT: while creating return value
PL/Python function "test1bad"
-- test hstore[] -> python
CREATE FUNCTION test1arr(val hstore[]) RETURNS int
LANGUAGE plpythonu
Expand Down
8 changes: 7 additions & 1 deletion contrib/hstore_plpython/hstore_plpython.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
HStore *volatile out;

dict = (PyObject *) PG_GETARG_POINTER(0);
if (!PyMapping_Check(dict))

/*
* As of Python 3, PyMapping_Check() is unreliable unless one first checks
* that the object isn't a sequence. (Cleaner solutions exist, but not
* before Python 3.10, which we're not prepared to require yet.)
*/
if (PySequence_Check(dict) || !PyMapping_Check(dict))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("not a Python mapping")));
Expand Down
11 changes: 11 additions & 0 deletions contrib/hstore_plpython/sql/hstore_plpython.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ $$;
SELECT test1n('aa=>bb, cc=>NULL'::hstore);


-- test that a non-mapping result is correctly rejected
CREATE FUNCTION test1bad() RETURNS hstore
LANGUAGE plpythonu
TRANSFORM FOR TYPE hstore
AS $$
return "foo"
$$;

SELECT test1bad();


-- test hstore[] -> python
CREATE FUNCTION test1arr(val hstore[]) RETURNS int
LANGUAGE plpythonu
Expand Down
8 changes: 5 additions & 3 deletions contrib/pageinspect/expected/brin.out
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
1 | 0 | 1 | f | f | f | {1 .. 1}
(1 row)

-- Failure for non-BRIN index.
-- Mask DETAIL messages as these are not portable across architectures.
\set VERBOSITY terse
-- Failures for non-BRIN index.
CREATE INDEX test1_a_btree ON test1 (a);
SELECT brin_page_items(get_raw_page('test1_a_btree', 0), 'test1_a_btree');
ERROR: "test1_a_btree" is not a BRIN index
-- Mask DETAIL messages as these are not portable across architectures.
\set VERBOSITY terse
SELECT brin_page_items(get_raw_page('test1_a_btree', 0), 'test1_a_idx');
ERROR: input page is not a valid BRIN page
-- Invalid special area size
SELECT brin_page_type(get_raw_page('test1', 0));
ERROR: input page is not a valid BRIN page
Expand Down
10 changes: 6 additions & 4 deletions contrib/pageinspect/expected/gist.out
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ SELECT itemoffset, ctid, itemlen FROM gist_page_items_bytea(get_raw_page('test_g
2 | (2,65535) | 40
(2 rows)

-- Failure with non-GiST index.
-- Suppress the DETAIL message, to allow the tests to work across various
-- page sizes and architectures.
\set VERBOSITY terse
-- Failures with non-GiST index.
CREATE INDEX test_gist_btree on test_gist(t);
SELECT gist_page_items(get_raw_page('test_gist_btree', 0), 'test_gist_btree');
ERROR: "test_gist_btree" is not a GiST index
SELECT gist_page_items(get_raw_page('test_gist_btree', 0), 'test_gist_idx');
ERROR: input page is not a valid GiST page
-- Failure with various modes.
-- Suppress the DETAIL message, to allow the tests to work across various
-- page sizes and architectures.
\set VERBOSITY terse
-- invalid page size
SELECT gist_page_items_bytea('aaa'::bytea);
ERROR: invalid page size
Expand Down
82 changes: 40 additions & 42 deletions contrib/pageinspect/gistfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,20 @@ PG_FUNCTION_INFO_V1(gist_page_items_bytea);
#define ItemPointerGetDatum(X) PointerGetDatum(X)


Datum
gist_page_opaque_info(PG_FUNCTION_ARGS)
static Page verify_gist_page(bytea *raw_page);

/*
* Verify that the given bytea contains a GIST page or die in the attempt.
* A pointer to the page is returned.
*/
static Page
verify_gist_page(bytea *raw_page)
{
bytea *raw_page = PG_GETARG_BYTEA_P(0);
TupleDesc tupdesc;
Page page;
Page page = get_page_from_raw(raw_page);
GISTPageOpaque opaq;
HeapTuple resultTuple;
Datum values[4];
bool nulls[4];
Datum flags[16];
int nflags = 0;
uint16 flagbits;

if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));

page = get_page_from_raw(raw_page);

if (PageIsNew(page))
PG_RETURN_NULL();
return page;

/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GISTPageOpaqueData)))
Expand All @@ -76,12 +67,38 @@ gist_page_opaque_info(PG_FUNCTION_ARGS)
GIST_PAGE_ID,
opaq->gist_page_id)));

return page;
}

Datum
gist_page_opaque_info(PG_FUNCTION_ARGS)
{
bytea *raw_page = PG_GETARG_BYTEA_P(0);
TupleDesc tupdesc;
Page page;
HeapTuple resultTuple;
Datum values[4];
bool nulls[4];
Datum flags[16];
int nflags = 0;
uint16 flagbits;

if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));

page = verify_gist_page(raw_page);

if (PageIsNew(page))
PG_RETURN_NULL();

/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");

/* Convert the flags bitmask to an array of human-readable names */
flagbits = opaq->flags;
flagbits = GistPageGetOpaque(page)->flags;
if (flagbits & F_LEAF)
flags[nflags++] = CStringGetTextDatum("leaf");
if (flagbits & F_DELETED)
Expand All @@ -103,7 +120,7 @@ gist_page_opaque_info(PG_FUNCTION_ARGS)

values[0] = LSNGetDatum(PageGetLSN(page));
values[1] = LSNGetDatum(GistPageGetNSN(page));
values[2] = Int64GetDatum(opaq->rightlink);
values[2] = Int64GetDatum(GistPageGetOpaque(page)->rightlink);
values[3] = PointerGetDatum(construct_array(flags, nflags,
TEXTOID,
-1, false, TYPALIGN_INT));
Expand All @@ -124,7 +141,6 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
Tuplestorestate *tupstore;
MemoryContext oldcontext;
Page page;
GISTPageOpaque opaq;
OffsetNumber offset;
OffsetNumber maxoff = InvalidOffsetNumber;

Expand Down Expand Up @@ -157,29 +173,11 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)

MemoryContextSwitchTo(oldcontext);

page = get_page_from_raw(raw_page);
page = verify_gist_page(raw_page);

if (PageIsNew(page))
PG_RETURN_NULL();

/* verify the special space has the expected size */
if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GISTPageOpaqueData)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));

opaq = (GISTPageOpaque) PageGetSpecialPointer(page);
if (opaq->gist_page_id != GIST_PAGE_ID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));

/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
if (GistPageIsDeleted(page))
elog(NOTICE, "page is deleted");
Expand Down Expand Up @@ -276,7 +274,7 @@ gist_page_items(PG_FUNCTION_ARGS)
errmsg("\"%s\" is not a %s index",
RelationGetRelationName(indexRel), "GiST")));

page = get_page_from_raw(raw_page);
page = verify_gist_page(raw_page);

if (PageIsNew(page))
{
Expand Down
Loading
Loading