Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjXKP-000796-19 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Sep 2016 19:55:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bjXKO-0001JI-JV for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Sep 2016 19:55:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bjXKM-0001EN-EG for pgsql-hackers@postgresql.org; Mon, 12 Sep 2016 19:55:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bjXKJ-00086u-Pc for pgsql-hackers@postgresql.org; Mon, 12 Sep 2016 19:55:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u8CJtYLO013678; Mon, 12 Sep 2016 15:55:34 -0400 From: Tom Lane To: Mark Dilger cc: PostgreSQL-development Subject: Re: inappropriate use of NameGetDatum macro In-reply-to: References: Comments: In-reply-to Mark Dilger message dated "Mon, 12 Sep 2016 12:39:56 -0700" Date: Mon, 12 Sep 2016 15:55:34 -0400 Message-ID: <13677.1473710134@sss.pgh.pa.us> X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Mark Dilger writes: > there are several places in the code where variables defined as > (char *) or as (const char *) are passed to the NameGetDatum() > macro. I believe it would be better form to use CStringGetDatum() > in these locations. I am aware that these two macros are internally > the same. Hm, I agree, this feels wrong. I suppose you could argue that the called functions are expecting Name pointers not CString pointers, but that type cheat is happening anyway. It would be better form to explicitly pass a CString datum if that's what we're passing. I'm tempted to propose that we redefine NameGetDatum as #define NameGetDatum(X) CStringGetDatum(NameStr(*(X))) which should do the same thing at runtime, but would result in a compile error if what's passed isn't declared as Name (or NameData*). This would be asymmetrical with the way DatumGetName looks, though. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers