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 1luFEr-00085c-OJ for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jun 2021 14:12:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1luFEq-0002DM-Fp for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jun 2021 14:12:52 +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 1luFEq-0002DE-86 for pgsql-hackers@lists.postgresql.org; Fri, 18 Jun 2021 14:12:52 +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 1luFEo-0007IB-4S for pgsql-hackers@lists.postgresql.org; Fri, 18 Jun 2021 14:12:51 +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 15IECYew1100326; Fri, 18 Jun 2021 10:12:34 -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: <968815.1623936849@sss.pgh.pa.us> Comments: In-reply-to Boris Kolpackov message dated "Fri, 18 Jun 2021 15:52:41 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1100324.1624025554.1@sss.pgh.pa.us> Date: Fri, 18 Jun 2021 10:12:34 -0400 Message-ID: <1100325.1624025554@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Boris Kolpackov writes: > Tom Lane writes: >> 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. > That would be even better, but I agree with what others have > said: we would have to keep adding such feature test macros > going forward. Yes, and I think that is a superior solution. I think the argument that it's too much effort is basically nonsense. > I think ideally you would want to have both since the version > macro could still be helpful in dealing with "features" that you > did not plan to add (aka bugs). I really doubt that a version number appearing in libpq-fe.h would be helpful for deciding whether you need to work around a bug. The problem again is version skew: how well does the libpq.so you are running against today match up with the header you compiled against (possibly months ago, possibly on a different machine)? What you'd want for that sort of thing is a runtime test, i.e. consult PQlibVersion(). That point, along with the previously-discussed point about confusion between server and libpq versions, nicely illustrates another reason why I'm resistant to just adding a version number to libpq-fe.h. If we do that, application programmers will be presented with THREE different Postgres version numbers, and it seems inevitable that people will make mistakes and consult the wrong one for a particular purpose. I think we can at least reduce the confusion by handling the question of which-features-are-visible-in-the-include-file in a different style. regards, tom lane