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 1tDTED-000xFG-HT for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 18:45:33 +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 1tDTEB-00Fz1x-58 for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 18:45:31 +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 1tDTEA-00Fz1i-NK for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 18:45:30 +0000 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDTE7-002nGb-Lx for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 18:45:29 +0000 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-6ee994218d9so21475237b3.0 for ; Tue, 19 Nov 2024 10:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732041926; x=1732646726; 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=M8lbkK14KoEcv9ydGyuoWfVozj/fQxFgdoXyfZxv/zQ=; b=J3axLMuylM5jM3aduk5RL7oaP9isyl3o3GEIONzBnUGuVRrIVCb3Yx2Qoko+EcuJS/ nK8ZbW5DVGMoOKMBYW96JJH1j+0fI4B3f/hdFdAAELDfzrHLSEenl9Szc5M/PH33CN/t g95WgsjMV0ruKwOu3xRm88M+E68NDYj/A7X1TH4XrJZ9kD9gmovVA8OupROMLV1h4YHx wW7Fsh1ElNx/rBqvvJ3G3VbZZR+Rstvs93t5wPn4/WgxjH32RhgCGEPe7u0DI/ktOxBh eKjyOnMeEp05TvzSC/wTcGs88twEzLceqWF2pmnB6Y9R7A/yPHxA5rqGvGZoG5bc4njt 6n5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732041926; x=1732646726; 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=M8lbkK14KoEcv9ydGyuoWfVozj/fQxFgdoXyfZxv/zQ=; b=ahHNmeDJ/b9oNPu7Dcf92QUkuYiuH5qcT9aSrCmyna3+iAehi7JV5z0U3x/EhIf/xQ WNr7gMesE0tGRja/ea1/LJPq5RyR8NceDpjs0grgB4kwNSQ1dUh55JXYp+L/cWZFLDTb 6mufpHMAP1E+GeJ5LMNybRUus/9sAGbIPbV3zc2rdCdZcmorEbNCdhQmSWelqebNxv8I IC+DlPimPdnY/Gw74gO9GEbGQYlx3DE/6jdU6ZPURLNTRMH5AQd/9E+sV2OiXj2LnSl1 SoWTrbUBqZeuEeWF1Scem+YlHtszra/sogIdvFsSFE1InhnIe2gQ34C8L8O8xutruxRm f1tw== X-Forwarded-Encrypted: i=1; AJvYcCV/BkGsgR5bK9+h6E4HH7wE/ZpN5lm5ladZSWrGhgb3gyJB5xjn3eJr13X6RJ557IbPPDDVLPq+etMBqYhu@lists.postgresql.org X-Gm-Message-State: AOJu0YyrtvHbhtSTGIQ46bYFwwGDDXVLUSnvSqQQImVvq0Fb/PZlnSt7 X2HqT1CyN9etVMdnyOEzxHhHGu82E/9DdEb9XZfg/2ri+0dRawIzzCv8ifMHD6D6dWbzI4Fl5by PAqCNO53P7rINZ/2vU6Cf96NHH6Q= X-Google-Smtp-Source: AGHT+IHkB5KcyEOdUnTivIr/yZ4B4sq2sunCtv9Tbis6SOV4tzEYOgc1wWeSGGTVrYtzcHvS2umXBm5toUR/5qmTpr4= X-Received: by 2002:a05:690c:8f19:b0:6ee:6241:ac9d with SMTP id 00721157ae682-6ee6241f3a5mr137885497b3.28.1732041925745; Tue, 19 Nov 2024 10:45:25 -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> In-Reply-To: From: Pavel Stehule Date: Tue, 19 Nov 2024 19:44:49 +0100 Message-ID: Subject: Re: Using Expanded Objects other than Arrays from plpgsql To: Michel Pelletier Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b867b20627486fcf" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b867b20627486fcf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =C3=BAt 19. 11. 2024 v 18:51 odes=C3=ADlatel Michel Pelletier < pelletier.michel@gmail.com> napsal: > >> So going back on the assumption I'm somehow not returning the right >> pointer, but digging into the array code I'm pretty sure I'm following t= he >> same pattern and tracing my code path is calling EOHPGetRWDatum when I >> return the object, I can't get it to stop on DeleteExpandedObject, so I >> don't think plpgsql is deleting it, I'm going to keep investigating, sor= ry >> for the noise. >> > > A couple years ago I tried to compress what I learned about expanded > objects into a dummy extension that just provides the necessary > boilerplate. It wasn't great but a start: > > https://github.com/michelp/pgexpanded > > Pavel Stehule indicated this might be a good example to put into contrib: > > > https://www.postgresql.org/message-id/CAFj8pRDnAnsm8pMosEys-TDRZpnCx1Kaxe= PjV8HT6A1JPQtsCw@mail.gmail.com > > I've updated the repo to include points from our current discussion wrt > multiple expansions in a plpgsql function, and added some test functions. > The new pgexpanded type just keeps track of the number of times it's been > expanded starting from an initialized value. While it only stores a > flattened integer, it follows the typical pattern of pallocing the value > and pfreeing it with a memory context callback, so it should be covering > most of the boilerplate needed to start a new expanded type. > > This would also be a good place to showcase and test the support function > feature you've described to me. > > It occurs to me that including this example in contrib would be an easier > way for us to collaborate on my existing issue instead of punting back an= d > forth on the list and would benefit all future expanded object developers= . > Do you think that's a good idea? If this were in contrib you could acces= s > the code I'm working with directly and I can just follow along in my > project. > another position can be src/test/modules - I think so your example is "similar" to plsample Regards Pavel > > -Michel > --000000000000b867b20627486fcf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
=C3=BAt 19. 11. 2024 v=C2=A018:51 ode= s=C3=ADlatel Michel Pelletier <pelletier.michel@gmail.com> napsal:

So going back on the assumption I'm some= how not returning the right pointer, but digging into the array code I'= m pretty sure I'm following the same pattern and tracing my code path i= s calling EOHPGetRWDatum when I return the object, I can't get it to st= op on DeleteExpandedObject, so I don't think plpgsql is deleting it, I&= #39;m going to keep investigating, sorry for the noise.

A couple years ago I tried to compress what I lea= rned about expanded objects into a dummy extension that just provides the n= ecessary boilerplate.=C2=A0 It wasn't great but a start:

=

Pavel Steh= ule indicated this might be a good example to put into contrib:
<= br>

I've updated the repo to= include points from our current discussion wrt multiple expansions in a pl= pgsql function, and added some test functions.=C2=A0 The new pgexpanded typ= e just keeps track of the number of times it's been expanded starting f= rom an initialized value.=C2=A0 While it only stores a flattened integer, i= t follows the typical pattern of pallocing the value and pfreeing it with a= memory context callback, so it should be covering most of the boilerplate = needed to start a new expanded type.

This would al= so be a good place to showcase and test the support function feature you= 9;ve described to me.

It occurs to me that includi= ng this example in contrib would be an easier way for us to collaborate on = my existing issue instead of punting back and forth on the list and would b= enefit all future expanded object developers.=C2=A0 Do you think that's= a good idea?=C2=A0 If this were in contrib you could access the code I'= ;m working with directly and I can just follow along in my project.

another position can be src/test= /modules - I think so your example is "similar" to plsample
=

Regards

Pavel
=C2=A0=

-Michel
--000000000000b867b20627486fcf--