Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tUArj-00EfwR-43 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2025 20:35:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tUArh-00DBGp-HL for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2025 20:35:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tUArh-00DBFo-4F for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2025 20:35:20 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tUArf-000Euk-0f for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2025 20:35:20 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-540215984f0so13865460e87.1 for ; Sat, 04 Jan 2025 12:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736022917; x=1736627717; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=H7dIXoBddPF4S6VpbKqWGIowgHstVbc8nCJ2u9nCJ9Q=; b=LRFACM8iYkwRF2cTnSt8zm8sDIttWRUCJ0T7nVvpSS+M0Gk1N/7pHB08KRL3OAxupO 4WqPxibNYTTKQq0IkhI3RP5d0dH6HBeIXSHWz27MxnQ2yec2X/pvn19gmo/oZdWxoWMu Q8DKgQg/TZUSwiiBRYKI7OmYCTBrrc84yHjR9HHNoQJZ+7KK7F2oqhIHF2EUOEygSlU8 dHHoOB+931ZMODagaP2Un7XF9vH/xzQJJmmIFMp6iL4VcnE3oKIRzIVIyhPgZ62ZMz4n xvv9QiBckoIQuVpJX7D5J9ggN68XWxsQTGF1PMx+acNHoeV9MsbzucCzN4dCt7IcNgy6 +oEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736022917; x=1736627717; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H7dIXoBddPF4S6VpbKqWGIowgHstVbc8nCJ2u9nCJ9Q=; b=HDDV5YEo4fdeqBRR48fY8LYSEdxsAOnZX6zoPv8j7qpUstKBpC7say4H30/w11US1t mj4/qUnOrfNjQAoYRx18EdqX7r3cTG1QVprQTfnmikNeU2JBCD/Tis4sflHiUsjzZiQf IvGx2/qJQOfW/n+qhIwmhRNftdDAyuG0PDforyM4XK4g6oxjQs8x7yJjnHn3SU4b0QDB +rM80fCVi6561GFTZuMo5h1JtM+oPXmKRMAIydRTWGxpHU9mm/vdKdh944MsBl1Su1tG HLnxzP5GcStfOAsUIh7o15uofX/Yql1GItFC1whpC5r1bPMDgxFQuEYtK0iXhFU29l7X xf8g== X-Forwarded-Encrypted: i=1; AJvYcCUV6y2ySOTCIJtk1vRRZCUPxPJ2TMqKk7kwjo4uPo0jxfuiU6HfABB6nM4OhJ/+lzdYLMfKIjUqzS14BV7u@lists.postgresql.org X-Gm-Message-State: AOJu0YwufvbkbBsxwil9DtQbVNF8jPxJc8ytSMFIWa9OCm4RhurM2q57 sa3HxZhOl/NK1eJapuSHxiuf2EEAQ2vlRX4Z9QiBUIKpgF0wgZrNQYtqo5lfIwV8Ol2rud4W6+f jv/WjyEgIXXh14hxCCEUYJdXqxDM= X-Gm-Gg: ASbGnctM1LZthBJRja7GTRFtCT4VcPZsAywDl9OhRQbWmaQA1g4y136EoSpOXvF1dkI F6kFnGIGkciMWeW7ZYCQ5nefH7wPSg5igyOsyTj4= X-Google-Smtp-Source: AGHT+IFbcxhVOkkteFitGRt4GaqNWIh2KTjkT8YDBT+wNcRKNag4oi+ZIXes/tJUYeAZLFEFl8zrHGOH3fyBuNsDawE= X-Received: by 2002:a05:6512:1055:b0:542:232a:7b2c with SMTP id 2adb3069b0e04-54229548e22mr15225043e87.29.1736022916908; Sat, 04 Jan 2025 12:35:16 -0800 (PST) MIME-Version: 1.0 References: <1342498.1729444411@sss.pgh.pa.us> <1445998.1729482404@sss.pgh.pa.us> <2062830.1729625620@sss.pgh.pa.us> <2265411.1729699470@sss.pgh.pa.us> <2354718.1729737539@sss.pgh.pa.us> <2581216.1729794746@sss.pgh.pa.us> <1948345.1730500073@sss.pgh.pa.us> <3797606.1732045516@sss.pgh.pa.us> <647219.1736019347@sss.pgh.pa.us> In-Reply-To: <647219.1736019347@sss.pgh.pa.us> From: Michel Pelletier Date: Sat, 4 Jan 2025 12:34:40 -0800 Message-ID: Subject: Re: Using Expanded Objects other than Arrays from plpgsql To: Tom Lane Cc: Pavel Stehule , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000048cfa8062ae755b3" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000048cfa8062ae755b3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jan 4, 2025 at 11:35=E2=80=AFAM Tom Lane wrote: > Michel Pelletier writes: > > I've circled back on this task to do some work improving the skeleton > code, > > but going back through our thread I landed on this point Tom made about > > usefulness vs pure skeleton and my natural desire is to make a simple > > expanded object that is also useful, so I brainstormed a bit and decide= d > to > > try something relatively simple but also (IMO) quite useful, an expande= d > > datum that wraps sqlite's serialize/derserialize API: > > https://github.com/michelp/postgres-sqlite > > I think the odds that we'd accept a module with a dependency on sqlite > are negligible. It's too big of a build dependency for too little > return. That's fair, I wasn't sure if contrib modules could have optional build dependencies that just skip building that module if they are not installed. If this were the case for users who want to study the approach they can look at the code, and users who want to use the feature can install the dependency or maybe require a configuration flag like --with-sqlite. > Also, I'm sure that a module defined like that would be a > pretty poor example/starting point for other expanded-object > applications: there'd be too many aspects that have only to do with > interfacing to sqlite, making it hard to see the expanded-object > forest for the sqlite trees. > I don't agree it would be a poor example, there are really only two touch points with sqlite that matter, the call to sqlite3_serialize in the flattening function and sqlite3_deserialize in the expander and consist of a simple pointer exchange and memcpy. That code is in its own file, separate from the exec/query/dump code which can be effectively ignored by someone looking to understand the expansion life cycle. > I have to admit though that the forest-v-trees aspect makes it fairly > hard to think of any suitable example module that would serve much > real-world purpose. Likely scenarios for expanded objects just have > a lot of functionality in them. Agree that an expanded object is only useful if it provides functionality. My original pgexpanded extension from way back provided a dumb dense matrix to do matrix multiplication, but I trimmed it out to just be the counter as posted earlier in this thread, and you in turn mentioned maybe it should just be a malloc'ed string, but in either case the pointlessness of it bothers me a bit so I was hoping to find something that just crosses the line into useful while still being a really simply expanded example. -Michel --00000000000048cfa8062ae755b3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Jan 4, 2025 at 11:35=E2=80=AFAM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
Michel Pelletier <pelletier.michel@gmail.com> writes:
> I've circled back on this task to do some work improving the skele= ton code,
> but going back through our thread I landed on this point Tom made abou= t
> usefulness vs pure skeleton and my natural desire is to make a simple<= br> > expanded object that is also useful, so I brainstormed a bit and decid= ed to
> try something relatively simple but also (IMO) quite useful, an expand= ed
> datum that wraps sqlite's serialize/derserialize API:
>
https://github.com/michelp/postgres-sqlite

I think the odds that we'd accept a module with a dependency on sqlite<= br> are negligible.=C2=A0 It's too big of a build dependency for too little=
return.=C2=A0

That's fair, I wasn't= sure if contrib modules could have optional build dependencies that just s= kip building that module if they are not installed.=C2=A0 If this were the = case for users who want to study the approach they can look at the code, an= d users who want to use the feature can install the dependency or maybe req= uire a configuration flag like --with-sqlite.
=C2=A0
Also, I'm sure that a modul= e defined like that would be a
pretty poor example/starting point for other expanded-object
applications: there'd be too many aspects that have only to do with
interfacing to sqlite, making it hard to see the expanded-object
forest for the sqlite trees.

I don'= t agree it would be a=C2=A0poor example, there are really only two touch po= ints with sqlite that matter, the call to sqlite3_serialize in the flatteni= ng function and sqlite3_deserialize in the expander and consist of a simple= pointer exchange and memcpy.=C2=A0 That code is in its own file, separate = from the exec/query/dump code which can be effectively ignored by someone l= ooking to understand the expansion life cycle.
=C2=A0
I have to admit though that the forest-v-trees aspect makes it fairly
hard to think of any suitable example module that would serve much
real-world purpose.=C2=A0 Likely scenarios for expanded objects just have a lot of functionality in them.=C2=A0
=C2=A0
Agr= ee that an expanded object is only useful if it provides functionality.=C2= =A0 My original pgexpanded extension from way back provided a dumb dense ma= trix to do matrix multiplication, but I trimmed it out to just be the count= er as posted earlier in this thread, and you in turn mentioned maybe it sho= uld just be a malloc'ed string, but in either case the pointlessness of= it bothers me a bit so I was hoping to find something that just crosses th= e line into useful while still being a really simply expanded example.
=C2=A0
-Michel
--00000000000048cfa8062ae755b3--