Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 22 additions & 1 deletion src/btree_rum.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@

#include "rum.h"

/*
* PostgreSQL's own fallthrough-attribute wrapper is not a stable target:
* it's pg_attribute_fallthrough() (function-call-style) through PG18,
* pg_fallthrough (a bare, parenless macro) from PG19 on -- and even on
* PG18, pg_attribute_fallthrough() is not reliably declared under every
* compiler/build-mode combination (e.g. it's missing under clang's
* -emit-llvm JIT bitcode pass). Rather than keep chasing PostgreSQL's
* internal macro across versions and compilers, detect compiler support
* for the attribute directly and supply our own wrapper. This matches
* exactly what PostgreSQL's own macros expand to, just without relying
* on PostgreSQL to declare it consistently.
*/
#if defined(__has_attribute)
#if __has_attribute(fallthrough)
#define RUM_FALLTHROUGH() __attribute__((fallthrough))
#endif
#endif
#ifndef RUM_FALLTHROUGH
#define RUM_FALLTHROUGH() ((void) 0)
#endif

#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
#include <float.h>
#define isfinite _finite
Expand Down Expand Up @@ -112,7 +133,7 @@ rum_btree_extract_query(FunctionCallInfo fcinfo,
case BTGreaterEqualStrategyNumber:
case BTGreaterStrategyNumber:
*ptr_partialmatch = true;
/*FALLTHROUGH*/
RUM_FALLTHROUGH();
case BTEqualStrategyNumber:
case RUM_DISTANCE:
case RUM_LEFT_DISTANCE:
Expand Down
10 changes: 9 additions & 1 deletion src/rum.h
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,15 @@ rumDataPageLeafRead(char *ptr, OffsetNumber attnum, RumItem * item,
switch (attr->attlen)
{
case sizeof(char):
item->addInfo = Int8GetDatum(*ptr);

/*
* PG19 removed Int8GetDatum() from postgres.h.
* CharGetDatum() performs the identical (Datum) (X)
* byte-value conversion and remains present in every
* supported PostgreSQL version, so use it instead of
* depending on Int8GetDatum()'s continued existence.
*/
item->addInfo = CharGetDatum(*ptr);
break;
case sizeof(int16):
memcpy(&u.i16, ptr, sizeof(int16));
Expand Down
19 changes: 19 additions & 0 deletions src/rumutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@ initRumState(RumState * state, Relation index)
{
state->addAttrs[i] = NULL;
}

/*
* PG19 added a tuple-deformation offset cache to TupleDesc
* (firstNonCachedOffsetAttr) that is only initialized by
* TupleDescFinalize(). Any TupleDesc hand-built via
* CreateTemplateTupleDesc()/TupleDescInitEntry(), as above,
* must now be finalized before it is used to form or read
* tuples, or PG core will hit
* Assert(tupleDesc->firstNonCachedOffsetAttr >= 0) the first
* time it tries to deform one -- exactly what happened here.
*/
#if PG_VERSION_NUM >= 190000
TupleDescFinalize(state->tupdesc[i]);
#endif
}
else
{
Expand Down Expand Up @@ -311,6 +325,11 @@ initRumState(RumState * state, Relation index)
{
state->addAttrs[i] = NULL;
}

/* See comment above the oneCol branch's TupleDescFinalize(). */
#if PG_VERSION_NUM >= 190000
TupleDescFinalize(state->tupdesc[i]);
#endif
}

/*
Expand Down