From ab55c864c3c7a00bfb230812429a76d8f4c4be80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matic=20Perov=C5=A1ek?= Date: Thu, 22 Feb 2024 10:29:04 +0100 Subject: [PATCH 1/2] Make imgsmlr compatible with PostgreSQL 16 --- imgsmlr.c | 3 +++ imgsmlr.h | 10 ++++++++++ imgsmlr_idx.c | 33 ++++++++++++++++++++------------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/imgsmlr.c b/imgsmlr.c index 84ee11f..57378e9 100755 --- a/imgsmlr.c +++ b/imgsmlr.c @@ -13,6 +13,9 @@ *------------------------------------------------------------------------- */ #include "postgres.h" +#ifndef VARDATA_ANY +#include "varatt.h" +#endif #include "c.h" #include "fmgr.h" diff --git a/imgsmlr.h b/imgsmlr.h index 9ee8cae..6810b39 100755 --- a/imgsmlr.h +++ b/imgsmlr.h @@ -37,3 +37,13 @@ typedef struct #define CHECK_SIGNATURE_KEY(key) Assert(VARSIZE_ANY_EXHDR(key) == sizeof(Signature) || VARSIZE_ANY_EXHDR(key) == 2 * sizeof(Signature)); #endif /* IMGSMLR_H */ + + +#ifndef FALSE +#define FALSE (0) +#endif + + +#ifndef TRUE +#define TRUE (!FALSE) +#endif diff --git a/imgsmlr_idx.c b/imgsmlr_idx.c index d85fbd0..0df68b5 100755 --- a/imgsmlr_idx.c +++ b/imgsmlr_idx.c @@ -13,6 +13,10 @@ *------------------------------------------------------------------------- */ #include "postgres.h" +#ifndef VARDATA_ANY +#include "varatt.h" +#endif + #include "fmgr.h" #include "imgsmlr.h" #include "access/gist.h" @@ -77,19 +81,22 @@ signature_compress(PG_FUNCTION_ARGS) Datum signature_decompress(PG_FUNCTION_ARGS) { - GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - bytea *key = DatumGetByteaP(PG_DETOAST_DATUM(entry->key)); - - if (key != DatumGetByteaP(entry->key)) - { - GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY)); - - gistentryinit(*retval, PointerGetDatum(key), - entry->rel, entry->page, - entry->offset, FALSE); - PG_RETURN_POINTER(retval); - } - PG_RETURN_POINTER(entry); + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); + bytea *detoastedKey = DatumGetByteaP(entry->key); + bytea *key = (bytea *) entry->key; + + // Variable key is the original entry->key before detoasting, and it’s compared with the + // detoasted key. If they’re different, a new GISTENTRY is created. Otherwise, the original entry is returned. + if (key != detoastedKey) + { + GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY)); + + gistentryinit(*retval, PointerGetDatum(key), + entry->rel, entry->page, + entry->offset, FALSE); + PG_RETURN_POINTER(retval); + } + PG_RETURN_POINTER(entry); } Datum From badb572e5d98deb95eb022ee7c45c41ea3d09a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matic=20Perov=C5=A1ek?= Date: Thu, 22 Feb 2024 11:30:52 +0100 Subject: [PATCH 2/2] Improve PostgreSQL version check --- imgsmlr.c | 4 +++- imgsmlr_idx.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/imgsmlr.c b/imgsmlr.c index 57378e9..21551e7 100755 --- a/imgsmlr.c +++ b/imgsmlr.c @@ -13,9 +13,11 @@ *------------------------------------------------------------------------- */ #include "postgres.h" -#ifndef VARDATA_ANY +#ifdef PG_VERSION_NUM +#if PG_VERSION_NUM >= 160000 #include "varatt.h" #endif +#endif #include "c.h" #include "fmgr.h" diff --git a/imgsmlr_idx.c b/imgsmlr_idx.c index 0df68b5..81e0c97 100755 --- a/imgsmlr_idx.c +++ b/imgsmlr_idx.c @@ -13,9 +13,12 @@ *------------------------------------------------------------------------- */ #include "postgres.h" -#ifndef VARDATA_ANY + +#ifdef PG_VERSION_NUM +#if PG_VERSION_NUM >= 160000 #include "varatt.h" #endif +#endif #include "fmgr.h" #include "imgsmlr.h" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy