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 1t6eoH-00EZph-OK for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 23:42:37 +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 1t6eoD-0075pa-UO for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 23:42:34 +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 1t6eoD-0075pS-J3 for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 23:42:33 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t6eo7-0045X4-0v for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 23:42:33 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2fb3da341c9so14405601fa.2 for ; Thu, 31 Oct 2024 16:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730418146; x=1731022946; 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=sfpvxPwt7Ler1FK6ynGdc3NVExDuInXy7VQEHpxgxDI=; b=YXOfLjIaOstlh6JxBMr0autJruBbUSRAwdsA+7EYdgFFJ5ftXDh//9o6gKxPqkWT9E MmKA2YICOjGuVWW/WRpkERqvidOIRjOovS0KojP9y/O5NSUK0onzm7zAD8krpY+/G7XD 1+6fefQegViyr8pltFIm0zZYKVUrahuFjh/KXQvzpcwbNbehyqbYsnGg8NiFw2xsjhX3 J58BD9yC+X1nQeuSkxhn6w+wB4FSw7Xhih7pfqBcIUCS7ThWG44zFIoV5RZ73yaxHo77 apccz8O+YlB+bl6SGCC4MT0TNx5JhXU2+hFQkircc3/wsMxe1hTjboNbDsbDUJqda16p p3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730418146; x=1731022946; 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=sfpvxPwt7Ler1FK6ynGdc3NVExDuInXy7VQEHpxgxDI=; b=oPYS5Zp8FwqD0UheMCWPoG5wR47r025yuiUFNfOQk1DYx8e+vrArtACq1pSKzJwdAg 7uYzPIiuVhjuyK/zsuAW25oHy4ZZKws6KSCL/VspTYX6UlpwgOTtktddC4eHpfD3h7md eNsmYQ/mDzZGNwbNvIGdlPku6F5NdQoYWG/WYCCfFXvDkNNE40IR7v338fsD2J4HiR4o brTw2gRqEjAKXkAVtqKNIlDNtX5BZ8oKvQ2pQfGjRH+C+cvNBiQ8fYgql3T4YWePgiTn knfjPoRZqhNc0+U6EUK9bzEAG8l0/kM7iB19Mpq9dW8x2CTsIBoF5z5gDeTb7qeCYkPh 4b+g== X-Gm-Message-State: AOJu0Yxhe1Tty512mP4dXgN+Y5dfHnKhTXMq1hKJSB+ShtTTB2iuvH9S SeLVYFjLxIVcxwFCgnq44eyc/9FI4XJfrIcvE02F3/A68iuqaLC6qyCIFwQENhaNLnmKuC5Gokg 1wmeOheJ8O0gDlXHN4Ch3m+KDcsuEpLrf X-Google-Smtp-Source: AGHT+IEWI1DGh1Fdzg1Je6CLTjYHPBokJZEInYc9QJeP+JL9FgYjmH8qyAB9Jal+dNDcCRUmh/+DSGgg4++U3Q4ftFY= X-Received: by 2002:a05:651c:19ab:b0:2ef:243b:6dce with SMTP id 38308e7fff4ca-2fedb770dfdmr9472411fa.10.1730418145285; Thu, 31 Oct 2024 16:42:25 -0700 (PDT) MIME-Version: 1.0 References: <1342498.1729444411@sss.pgh.pa.us> <1445998.1729482404@sss.pgh.pa.us> <2062830.1729625620@sss.pgh.pa.us> <2259890.1729696885@sss.pgh.pa.us> <2351536.1729735831@sss.pgh.pa.us> In-Reply-To: <2351536.1729735831@sss.pgh.pa.us> From: Michel Pelletier Date: Thu, 31 Oct 2024 16:41:48 -0700 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="000000000000dcdf210625ce5e70" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dcdf210625ce5e70 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Here's two backtraces from gdb from this function: CREATE OR REPLACE FUNCTION test2(graph matrix) RETURNS bigint LANGUAGE plpgsql AS $$ BEGIN perform set_element(graph, 1, 1, 1); RETURN nvals(graph); end; $$; https://gist.githubusercontent.com/michelp/d02e3e300710443454357222077f9ded= /raw/86d9c2c3de3f9b4740065a7b8c29a3e1c54b1cac/gistfile1.txt Both traces are in that file split on the hyphens line 44. I'm still puzzling it out, could it have something to do with the volatility of the functions? I'm not entirely clear on how to interpret function volatility with expanded objects, nvals is STRICT, but set_element is STABLE. I think my logic there was because it's a mutation. This is likely another misunderstanding of mine. -Michel On Wed, Oct 23, 2024 at 7:10=E2=80=AFPM Tom Lane wrote: > Michel Pelletier writes: > > On Wed, Oct 23, 2024 at 8:21=E2=80=AFAM Tom Lane wr= ote: > >> Another thing that confuses me is why there's a second flatten_matrix > >> operation happening here. Shouldn't set_element return its result > >> as a R/W expanded object? > > > That confuses me too, and my default assumption is always that I'm doin= g > it > > wrong. set_element does return a R/W object afaict, here is the return= : > > https://github.com/OneSparse/OneSparse/blob/main/src/matrix.c#L1726 > > Hmph. That seems right. Can you add errbacktrace() to your logging > ereports, in hopes of seeing how we're getting to flatten_matrix? > Or break there with gdb for a more complete/reliable stack trace. > > regards, tom lane > --000000000000dcdf210625ce5e70 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here's two backtraces from gdb from this function:
CREATE OR REPLACE FUNCTION test2(graph matrix)
=C2=A0 = =C2=A0 RETURNS bigint LANGUAGE plpgsql AS
=C2=A0 =C2=A0 $$
=C2=A0 =C2= =A0 BEGIN
=C2=A0 =C2=A0 perform set_element(graph, 1, 1, 1);
=C2=A0 = =C2=A0 RETURN nvals(graph);
=C2=A0 =C2=A0 end;
=C2=A0 =C2=A0 $$;
<= /div>


Both traces are in that file split = on the hyphens line 44.=C2=A0 I'm still puzzling it out, could it have = something to do with the volatility of the functions?=C2=A0 I'm not ent= irely clear on how to interpret function volatility with expanded=C2=A0obje= cts, nvals is STRICT, but set_element is STABLE.=C2=A0 I think my logic the= re was because it's a mutation.=C2=A0 This is likely another misunderst= anding of mine.

-Michel

On Wed, Oct 23, 2024= at 7:10=E2=80=AFPM Tom Lane <tgl@s= ss.pgh.pa.us> wrote:
Michel Pelletier <pelletier.michel@gmail.com> writes:
> On Wed, Oct 23, 2024 at 8:21=E2=80=AFAM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Another thing that confuses me is why there's a second flatten= _matrix
>> operation happening here.=C2=A0 Shouldn't set_element return i= ts result
>> as a R/W expanded object?

> That confuses me too, and my default assumption is always that I'm= doing it
> wrong.=C2=A0 set_element does return a R/W object afaict, here is the = return:
> https://github.com/OneSparse= /OneSparse/blob/main/src/matrix.c#L1726

Hmph.=C2=A0 That seems right.=C2=A0 Can you add errbacktrace() to your logg= ing
ereports, in hopes of seeing how we're getting to flatten_matrix?
Or break there with gdb for a more complete/reliable stack trace.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--000000000000dcdf210625ce5e70--