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 1ltsAh-0004FK-D7 for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Jun 2021 13:35:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ltsAg-0000xd-6e for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Jun 2021 13:35:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltsA9-0003j9-Tf for pgsql-hackers@lists.postgresql.org; Thu, 17 Jun 2021 13:34:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltsA5-0003um-CE for pgsql-hackers@lists.postgresql.org; Thu, 17 Jun 2021 13:34:29 +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 15HDY9xo968816; Thu, 17 Jun 2021 09:34:09 -0400 From: Tom Lane To: Boris Kolpackov cc: pgsql-hackers@lists.postgresql.org, alvaro.herrera@2ndquadrant.com Subject: Re: Add version macro to libpq-fe.h In-reply-to: References: Comments: In-reply-to Boris Kolpackov message dated "Thu, 17 Jun 2021 11:04:06 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <968814.1623936849.1@sss.pgh.pa.us> Date: Thu, 17 Jun 2021 09:34:09 -0400 Message-ID: <968815.1623936849@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Boris Kolpackov writes: > I am making use of the new pipeline mode added to libpq in > PostgreSQL 14. At the same time I would still like to support > older libpq versions by not providing the extended functionality > that depends on this mode. Good point. > The natural way to achieve this in C/C++ is to conditionally > enable code that depends on the additional APIs based on the > preprocessor macro. And I could easily do this if libpq-fe.h > provided a macro containing its version. I think putting a version number as such in there is a truly horrid idea. However, I could get behind adding a boolean flag that says specifically whether the pipeline feature exists. Then you'd do something like #ifdef LIBPQ_HAS_PIPELINING rather than embedding knowledge of exactly which release added that. regards, tom lane