Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCvRd-00005L-Kk for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2016 21:32:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cCvRd-0003c3-5i for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2016 21:32:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cCvRb-0003bB-Lv for pgsql-hackers@postgresql.org; Fri, 02 Dec 2016 21:32:35 +0000 Received: from sub4.mail.dreamhost.com ([69.163.253.135] helo=homiemail-a112.g.dreamhost.com) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cCvRY-00019m-Bc for pgsql-hackers@postgresql.org; Fri, 02 Dec 2016 21:32:35 +0000 Received: from homiemail-a112.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a112.g.dreamhost.com (Postfix) with ESMTP id 65C4030002835; Fri, 2 Dec 2016 13:32:28 -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=Ytk0n6hf/hq1uZ XRr6x0fAebuBo=; b=k+wnkDD2a1oP7fHCZ3i/UoZLeKFoFnFaC9gvBtPxObUgEz uUgUB2rlEVDjTuqiocb1gAiSVUo5hoS/yJfJ2SQWLHKfhbwbGpPctObsmrfAX7C+ JxsNgyDJoKHDM5Ez45LW0LgADugJHVvqWcTGxT0a9lmrivruqhJFsEKa+EgUo= 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-a112.g.dreamhost.com (Postfix) with ESMTPSA id AB7DD3000282D; Fri, 2 Dec 2016 13:32:27 -0800 (PST) Date: Fri, 2 Dec 2016 15:32:24 -0600 From: Nico Williams To: Robert Haas Cc: Christian Convey , Petr Jelinek , Pavel Stehule , David Fetter , PostgreSQL Hackers , Tom Lane Subject: Re: Tackling JsonPath support Message-ID: <20161202213223.GJ24797@localhost> References: <20161128162639.GB27143@fetter.org> <20161128192343.GD11117@localhost> <80228378-f5ba-1291-872b-9812e103e37c@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Dec 02, 2016 at 08:53:33AM -0500, Robert Haas wrote: > On Tue, Nov 29, 2016 at 11:50 AM, Christian Convey > wrote: > > I think I can satisfy (3) with a PG extension which provides a function that > > approximately implements JSONPath. My short-term plans are to submit such a > > patch. > > FWIW, I think that's a fine plan. I don't really know whether > JSONPath is the right standard to pick for the task of extracting bits It's not even a standard. Are there particular proposals that the ANSI SQL working group is considering? > of JSON from other bits of JSON, but I think there's some value in > picking something is simple enough that we can implement it in our own > code and not have to rely on a third-party library. Of course, if > somebody feels like adding a configure option for --with-jq and Sure. My main concern is that I don't want to have to parse/format JSON around every such call. I'd rather parsed JSON remain in an internal form for as long as possible. Speaking of which, you could use libjq's jv API and not support the jq language itself. > appropriate interfaces to integrate with JQ, we could consider that, > too, but that imposes a packaging requirement that a home-grown > implementation doesn't. I'd want to hear more than one vote for such What we do in Heimdal, OpenAFS, and other open source projects, some times, is include a copy / git submodule / similar of some such external dependencies. Naturally it's not possible to do this for all external dependencies, but it works well enough. The jv API part of jq is small and simple, and could be ripped out into a library that could be included in PostgreSQL. > a course of action before embracing it. If JQ is a Turing-complete > query language, integrating it might be quite difficult -- for Even if it weren't! (It is.) Consider this expression using a builtin in jq: [range(4503599627370496)] That is, an array of integers from 0 to 4503599627370495, inclusive. That will "halt" given a very, very large computer and a lot of time. (Because jq is Turning-complete, range() can be coded in jq itself, and some variants of range() are.) > example, we'd need a way to make sure that it does periodic > CHECK_FOR_INTERRUPTS() calls, and that it doesn't leak resources or > crash if those calls decide longjmp() away due to an ERROR -- and > would we let people query database tables with it? Would that be > efficient? I think it's fine to have more limited objectives than > what a JQ implementation would apparently entail. Agreed. I think this means that we need either or both of a variant of the C jq_next() function that takes either a timeout parameter, or a jq_intr() function that can cause a running jq_next() to stop. (Tolerating longjmp() is harder to do and I'd rather not.) Other projects, like, say, nginx or similar where there is a per-client or per-connection memory pool to limit memory footprint, might want libjq to get an allocator hook, so that's another enhancement to consider. If that's something that PostgreSQL would need, please let me know. Nico -- -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers