Thread: [PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

[PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

From
ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Hi hackers,

I just noticed that when contrib/seg was converted to V1 calling
convention (commit 389bb2818f4), the PG_GETARG_SEG_P() macro got defined
in terms of PG_GETARG_POINTER().  But it itself calls DatumGetPointer(),
so shouldn't it be using PG_GETARG_DATUM()?

Attached is a patch that fixes it, and brings it in line with all the
other PG_GETARG_FOO_P() macros.

- ilmari
-- 
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen

From 122440c96c7584988ed1ae1195ad7164f4b8b86e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Sat, 2 Nov 2019 22:46:23 +0000
Subject: [PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

DatumGetPointer() needs a Datum argument, not a pointer.
---
 contrib/seg/seg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index 4e34fba7c7..f87456405c 100644
--- a/contrib/seg/seg.c
+++ b/contrib/seg/seg.c
@@ -19,7 +19,7 @@
 
 
 #define DatumGetSegP(X) ((SEG *) DatumGetPointer(X))
-#define PG_GETARG_SEG_P(n) DatumGetSegP(PG_GETARG_POINTER(n))
+#define PG_GETARG_SEG_P(n) DatumGetSegP(PG_GETARG_DATUM(n))
 
 
 /*
-- 
2.22.0


Re: [PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

From
Tom Lane
Date:
ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> I just noticed that when contrib/seg was converted to V1 calling
> convention (commit 389bb2818f4), the PG_GETARG_SEG_P() macro got defined
> in terms of PG_GETARG_POINTER().  But it itself calls DatumGetPointer(),
> so shouldn't it be using PG_GETARG_DATUM()?

Yup, I agree.  Pushed.

            regards, tom lane



Re: [PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

From
ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Tom Lane <tgl@sss.pgh.pa.us> writes:

> ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
>> I just noticed that when contrib/seg was converted to V1 calling
>> convention (commit 389bb2818f4), the PG_GETARG_SEG_P() macro got defined
>> in terms of PG_GETARG_POINTER().  But it itself calls DatumGetPointer(),
>> so shouldn't it be using PG_GETARG_DATUM()?
>
> Yup, I agree.  Pushed.

Thanks!

>             regards, tom lane

- ilmari
-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law



Re: [PATCH] contrib/seg: Fix PG_GETARG_SEG_P definition

From
Andres Freund
Date:
Hi,

On 2019-11-04 11:30:23 +0000, Dagfinn Ilmari Mannsåker wrote:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
> 
> > ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> >> I just noticed that when contrib/seg was converted to V1 calling
> >> convention (commit 389bb2818f4), the PG_GETARG_SEG_P() macro got defined
> >> in terms of PG_GETARG_POINTER().  But it itself calls DatumGetPointer(),
> >> so shouldn't it be using PG_GETARG_DATUM()?
> >
> > Yup, I agree.  Pushed.
> 
> Thanks!

Thanks both of you.

- Andres