Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEgH-0006mA-AA for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 15:05:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pNEgG-0007bN-5s for pgsql-general@arkaria.postgresql.org; Wed, 01 Feb 2023 15:05:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEgF-0007b2-Ri for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 15:05:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNEgD-0003tP-S1 for pgsql-general@lists.postgresql.org; Wed, 01 Feb 2023 15:05:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 311F5iBu1369044; Wed, 1 Feb 2023 10:05:44 -0500 From: Tom Lane To: jian he cc: pgsql-general list Subject: Re: 38.10.6. Composite-Type Arguments C-language function code demo works for int, but not for numeric. In-reply-to: References: Comments: In-reply-to jian he message dated "Wed, 01 Feb 2023 16:06:59 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1369042.1675263944.1@sss.pgh.pa.us> Date: Wed, 01 Feb 2023 10:05:44 -0500 Message-ID: <1369043.1675263944@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > column "salary" int data type works fine. But it does not work if the > "salary" column data type is numeric. Your problem is that numeric is not a primitive C type: > PG_RETURN_BOOL(DatumGetNumericCopy(salary) > limit); That is comparing two pointers-to-numerics, not the values of the numerics. You'd need to invoke numeric_cmp() if you want a sensible result. regards, tom lane