Re: [HACKERS] cast result of copyNode() - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: [HACKERS] cast result of copyNode()
Date
Msg-id 20170307232712.10866.40453.pgcf@coridan.postgresql.org
Whole thread Raw
In response to Re: [HACKERS] cast result of copyObject()  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: [HACKERS] cast result of copyNode()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] cast result of copyNode()  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  tested, passed
Implements feature:       not tested
Spec compliant:           not tested
Documentation:            not tested

Hi Peter,

I like the patch so far, and it passes all the regression tests for me on both mac and linux. I
am very much in favor of having more compiler type checking, so +1 from me.

You appear to be using a #define macro to wrap a function of the same name
with the code:

#define copyObject(obj) ((typeof(obj)) copyObject(obj))

I don't necessarily have a problem with that, but it struck me as a bit odd, and
grep'ing through the sources, I don't see anywhere else in the project where that
is done for a function of the same number of arguments, and only one other
place where it is done at all:

$ find src/ -type f -name "*.h" -or -name "*.c" | xargs cat | perl -e 'while(<>) { print if (/^#define
(\w+)\b.*\b\1\s*\(\b/);}'
 
#define copyObject(obj) ((typeof(obj)) copyObject(obj))
#define mkdir(a,b)    mkdir(a)

I'm just flagging that for discussion if anybody thinks it is too magical.

pgsql-hackers by date:

Previous
From: Neha Khatri
Date:
Subject: Re: [HACKERS] [NOVICE] opr_charset rule in gram.y
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Bizarre choice of case for RELKIND_PARTITIONED_TABLE