Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cDxJS-0005Bu-FH for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Dec 2016 17:44:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cDxJS-0003w7-28 for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Dec 2016 17:44:26 +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 1cDxI2-0002LF-Mj for pgsql-hackers@postgresql.org; Mon, 05 Dec 2016 17:42:58 +0000 Received: from sub4.mail.dreamhost.com ([69.163.253.135] helo=homiemail-a105.g.dreamhost.com) by makus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cDxHz-0002uF-Ob for pgsql-hackers@postgresql.org; Mon, 05 Dec 2016 17:42:57 +0000 Received: from homiemail-a105.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a105.g.dreamhost.com (Postfix) with ESMTP id 72F8F30002A2D; Mon, 5 Dec 2016 09:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=cryptonector.com; bh=+Nh2xwmzG2i8gf /fUeLc0qJ+k+4=; b=Se29xIVXdd92Xw7PB5dklOgKyOwyVm4WbI4vXew3vYCng9 Sx5Z3DaVcfHgsu8vK1UpPGdHGtryO7lFDSdWdB+0sFZUoN9hlfb7zrr1nDI1RCsP dUn75nhbJRu0VT1eSFpqpnosGDBa1/ISZvflfjAPsSGMLECuyCKDnDbSTOMks= Received: from localhost (cpe-70-123-158-140.austin.res.rr.com [70.123.158.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a105.g.dreamhost.com (Postfix) with ESMTPSA id BC3C730002A26; Mon, 5 Dec 2016 09:42:48 -0800 (PST) Date: Mon, 5 Dec 2016 11:42:43 -0600 From: Nico Williams To: Tom Lane Cc: Robert Haas , Christian Convey , Petr Jelinek , Pavel Stehule , David Fetter , PostgreSQL Hackers Subject: Re: Tackling JsonPath support Message-ID: <20161205174242.GB32541@localhost> References: <80228378-f5ba-1291-872b-9812e103e37c@2ndquadrant.com> <20161202213223.GJ24797@localhost> <18951.1480956777@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18951.1480956777@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) X-Pg-Spam-Score: -2.0 (--) 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 On Mon, Dec 05, 2016 at 11:52:57AM -0500, Tom Lane wrote: > Another point here is that packagers such as Red Hat strenuously dislike > such source-code-level wrapping of other projects, because that means that > they have to rebuild multiple packages to fix any bugs found in the > wrapped code. If I were still packaging Postgres for Red Hat, and such > a distribution landed in my inbox, the very first thing I'd be looking > to do is rip out the borrowed code and replace it with a runtime > shared-library dependency on the upstream project's official library. I'm quite aware :( I used to work at Sun on Solaris. We too hated duplication. OpenSSL was a particularly problematic case... There is a real tension between the release trains of many distinct open source projects and those of their consumers, and those of distros/OSes. Some projects, such as SQLite3, explicitly recommend copying their source or statically linking them into dependents; distros/vendors never like this. My best advice on this (PG might benefit from it), informed by years of experience dealing with this, is that there's no perfect answer, but that nonetheless library developers should always follow these best practices so as to help those who end up having to deal with multiple versions of those libraries: - prefer dynamic linking (because dynamic linking semantics are superior to static linking semantics) - make libraries self-initialize and self-finalize! (pthread_once() and Win32's ExecuteOnce* are your friends, as are atexit()/on_exit(), pthread_key_create(), and DllMain() on Windows) (otherwise calling your library from another library gets tricky) - make it so that as long as you change SONAMEs you can have multiple versions of the library loaded in one process, specifically: - don't use POSIX file locking (but the new non-POSIX OFD locks are OK) (or use them for files that wouldn't be shared across multiple versions in one process) (e.g., SQLite3 uses POSIX file locking safely, but it's not likely that two consumers of different SQLite3 versions in one process would access the same DB files, so it kinda works) - be backwards- and forwards-compatible as to any config file formats and other state that will be shared by multiple versions - generally: mind backwards compatibility, both source and binary, so as to make it easy to upgrade - this means applying good API design best practices that I won't go into here - write thread-safe code, and preferably fork-safe code too For example, I've seen OpenSSL built with different SONAMEs to support multiple versions of OpenSSL coexisting in a single program/process. That actually works. > Having said that ... we have a *really bad* track record of deciding which > outside projects we want to depend on, or maybe we've just outlived a lot > of them. Aside from Robert's examples, there's uuid-ossp and libxml2, > which are external code but have caused us headaches anyway. So I think > there's a lot to be said for avoiding dependencies on libraries that may > or may not still be getting actively maintained ten years from now. I'm not at all surprised. One codebase I help develop and maintain, Heimdal, includes SQLite3 and libeditline, and parts of Heimdal should really be separate projects (e.g., its ASN.1 compiler and library, and several supporting libraries like libroken (a portability layer)) because they could be useful to others outside Heimdal. Finding the right balance is not trivial. Nico -- -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers