Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBRYD-00047V-Rk for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Nov 2016 19:25:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cBRYD-0005yD-6w for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Nov 2016 19:25:17 +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 1cBRWo-0004Mb-BQ for pgsql-hackers@postgresql.org; Mon, 28 Nov 2016 19:23:50 +0000 Received: from sub4.mail.dreamhost.com ([69.163.253.135] helo=homiemail-a98.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 1cBRWl-0007VU-NC for pgsql-hackers@postgresql.org; Mon, 28 Nov 2016 19:23:49 +0000 Received: from homiemail-a98.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a98.g.dreamhost.com (Postfix) with ESMTP id 628676000A643; Mon, 28 Nov 2016 11:23:46 -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:content-transfer-encoding; s= cryptonector.com; bh=sK6W8RJ6cKt5vOBPjR4xrIONjFI=; b=A+72q4E4HxC dWBjfaMYBFZ3GgfNIxJ1/uTw94OWJp5hY4q6dw56vWEK4Q+xJYUFCGaub0LHQ/Uf XN1dRHv4K21eID4TNxn/P4gOC25BDADXU5TH7k+56RBywkKFRI8y1YZHhdxbX6PJ 7siz9ChKWEn31DO5JCsB7sDhUwLyryKg= 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-a98.g.dreamhost.com (Postfix) with ESMTPSA id C8F5D6000A641; Mon, 28 Nov 2016 11:23:45 -0800 (PST) Date: Mon, 28 Nov 2016 13:23:43 -0600 From: Nico Williams To: Pavel Stehule Cc: David Fetter , Christian Convey , PostgreSQL Hackers , Tom Lane Subject: Re: Tackling JsonPath support Message-ID: <20161128192343.GD11117@localhost> References: <20681.1479057226@sss.pgh.pa.us> <20161128162639.GB27143@fetter.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.5 (-) 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, Nov 28, 2016 at 05:56:41PM +0100, Pavel Stehule wrote: > Dne 28. 11. 2016 17:26 napsal u=C5=BEivatel "David Fetter" : > > There's another option we should also consider: jq > > . It's available under a > > PostgreSQL-compatible license, and has had a LOT of work put into > > correctness and performance. >=20 > we can use it for inspiration. but the syntax of this tool is little bit > too complex and too original against Json path ... jsonpath is relative > simple implementation of xpath to json >=20 > we have one proprietary syntax already, two is maybe too much :-) jq is hardly proprietary :) JSON Path is not expressive enough (last I looked) and can be mapped onto jq if need be anyways. libjq has a number of desirable features, mostly its immutable/COW data structures. In libjq data structures are only mutated when there's only one reference to them, but libjq's jv API is built around immutability, so jv values are always notionally immutable. For example, one writes: jv a =3D jv_array(); a =3D jv_array_append(a, jv_true()); // `a' is notionally new, but since // it had only one reference, its // memory is reused and similarly for objects. One could instead write: jv a =3D jv_array_append(jv_array(), jv_true()); =20=20 or jv a =3D JV_ARRAY(jv_true()); One of the nice things about libjv is that almost every function consumes a reference of every jv value passed in, with very few exceptions. This simplifies memory management, or at least avoidance of double-free and use-after-free (it can be harder to track down leaks though, since tools like valgrind don't understand that jv_copy() call sites can be like allocations). Nico --=20 --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers