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 1tDSNd-000r6o-IQ for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 17:51:13 +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 1tDSNb-00FauT-Nd for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Nov 2024 17:51:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDSNb-00FauH-9N for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 17:51:11 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDSNY-002jiM-FA for pgsql-hackers@lists.postgresql.org; Tue, 19 Nov 2024 17:51:10 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2fb5740a03bso58789841fa.1 for ; Tue, 19 Nov 2024 09:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732038667; x=1732643467; 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=dqt0dxbMaJw1UuOlDFHinLK3kg4o3HDQ8azcxY5ZDiQ=; b=AQlDd5QxZq+Ql8WfkI0Fi/ppGb1hiXj3B19KghjumFaXJbMgz0PJ3tYmQczCLKS5zZ cDT+SMKnkzW0/v7lJ4ki60HkjQEtNTjHbi1ZLIfUXC8SBNnb8YBTCnP7EvHmhf2ab6j1 sZZGL2YIN1iXiMg5BEagTbe6uTi4uWH6gThrpZIi4P08d7PcOySjwgS+TYrNmmprtTx2 USykjP/hAuqGjoEUmq3EcsYZCvAcBDl1pIxPK3uUHi0KAG30jqBhaeTzX4nLdA5r9GoX lZuZ7RVbaIg4IiBOwqcByEyeFjGwQngpfDEXqLDZI/+4UPhFy2rAbH3nWZfJu9WZsrmW EJCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732038667; x=1732643467; 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=dqt0dxbMaJw1UuOlDFHinLK3kg4o3HDQ8azcxY5ZDiQ=; b=lec/lKMizYfyh6Lw5XfbBOTCFBmIfPmbFdahYT14ls3K3fu+tN2Cwi8T44ataLtpNY Grgciey3LlK8E5279ih+tqSJ1VZtTXQBCf28DfOihL1Y320uJh9XwZBx7TEF1qn4TctL pNyKelnnHdua66oSsX+UWkU8eGw7SnPGWJZVMfqFJE8sRVRimPA1OcZBPK8/yQLYU0ZA VgyA3BHhS2IcCWArRbX9CyEh9cuMowht/CgnJvlqxkomq0JWMxIdiAyjELOmg9joNXmR OoloU69CBr21rC1FAUnvb/mg6RY9sAM13Y9fKwhF8UFeWSXmnQ5b01BFsTAKq/FwxUPi R8qw== X-Gm-Message-State: AOJu0Yw4Oo3nB8XXjVkuwpNOGbE0eWxzLJ+bJZgygaQUmm0qRhc5hOaY GEByZOSuEGvADK/8L19eELYNNrRFpWJgZKBxrZC/fxknZj4qtbqiEU5vPbi0fnK5g7kHmhvpot8 rWCQZBHWErrnr3PYft41PaYRMFJYaeeL2 X-Google-Smtp-Source: AGHT+IHrxZ6gvdkkhob56n83232IyUUGoW4hD8Wl1qNemaDH/DY3bCFrymfYmFTs2rbDNXrh8RsQgYB2c55jI+VtBeE= X-Received: by 2002:a2e:a80f:0:b0:2ff:54ad:b4ac with SMTP id 38308e7fff4ca-2ff6061101fmr73501901fa.5.1732038666169; Tue, 19 Nov 2024 09:51:06 -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: Michel Pelletier Date: Tue, 19 Nov 2024 09:50:29 -0800 Message-ID: Subject: Re: Using Expanded Objects other than Arrays from plpgsql To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000006f3bf9062747adbb" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006f3bf9062747adbb Content-Type: text/plain; charset="UTF-8" > > > 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 the > 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, sorry > 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-TDRZpnCx1KaxePjV8HT6A1JPQtsCw@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 and 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 access the code I'm working with directly and I can just follow along in my project. -Michel --0000000000006f3bf9062747adbb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

So= going back on the assumption I'm somehow not returning the right point= er, 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 r= eturn 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= , sorry for the noise.

A coupl= e years ago I tried to compress what I learned about expanded objects into = a dummy extension that just provides the necessary boilerplate.=C2=A0 It wa= sn't great but a start:

<= br>
Pavel Stehule indicated this might be a good example to put i= nto contrib:


I've updated the repo to include points from our cu= rrent discussion wrt multiple expansions in a plpgsql function, and added s= ome test functions.=C2=A0 The new pgexpanded type just keeps track of the n= umber of times it's been expanded starting from an initialized value.= =C2=A0 While it only stores a flattened integer, it follows the typical pat= tern 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 exp= anded type.

This would also be a good place to sho= wcase and test the support function feature you've described to me.

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

-Michel=
--0000000000006f3bf9062747adbb--