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.96) (envelope-from ) id 1wecIX-004u8a-2L for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jun 2026 17:31:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wecIW-009Q23-1t for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jun 2026 17:31:00 +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.96) (envelope-from ) id 1wecIW-009Q1t-00 for pgsql-hackers@lists.postgresql.org; Tue, 30 Jun 2026 17:31:00 +0000 Received: from mail-dy1-x1330.google.com ([2607:f8b0:4864:20::1330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wecIT-00000000wws-1w5y for pgsql-hackers@postgresql.org; Tue, 30 Jun 2026 17:30:58 +0000 Received: by mail-dy1-x1330.google.com with SMTP id 5a478bee46e88-30ec1ddd510so3369320eec.1 for ; Tue, 30 Jun 2026 10:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1782840656; x=1783445456; darn=postgresql.org; h=user-agent:content-disposition:mime-version:message-id:subject:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=MoXtlzCzieJXmcuaCz6FDgxt4AyuYC8urIicqaVQ6Ok=; b=N0obc3AHIKpfKlh63JmwQqC2pbhv3IY8CSTXX8LaoYEyuj19bf8aFjWv9JTR95Qi4x XXOwWwE6vrPYOlmJ0rxarbe6993JyR4hb9siLfj9oaNQhBxCdmu56ye21wKViKyjhU/O A8cuywpk7FBtBV/BgIpUX3tD9IGf8tFTEKqKU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782840656; x=1783445456; h=user-agent:content-disposition:mime-version:message-id:subject:to :from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MoXtlzCzieJXmcuaCz6FDgxt4AyuYC8urIicqaVQ6Ok=; b=DVjFyKa79q0W7xvGinY4vzAxCkRIWYGxpZgjT54DA4csCNN6A5TBLajFNNna8qqIAf 8BE5942pDn/nL5kIxYf8t8MXYZYJM9y/F+2/ZbAjaS4ZhP9i6wRodeC//9EHiNcvl16Y Alx1Ts8+N0zzQqANEdXkBHup1Hgjoen6qQ6A/+ynpSSVrDwjuz5d2H0unD+tfcbak+QS 7gW9XckkWcZ+h1hUlJYMdhNWsAJpY23on6G9WxjiPGLBcq8SXeb9JSW5fhuI/4v0VZNA eF8i/D42noL7ffPORZQ44r617NfuBNmDoZll+hFw6wc/FSNh5ZhEu/QU2Mk6XYH8XYak yYKg== X-Forwarded-Encrypted: i=1; AFNElJ/3RCrmd+lNTCzAAx7zey1xclHvZGoaTA6PJZdKxq5MbEm4713e5Rv0LRFI7KhQCpcIpcN0ge5a18gQY0Vm@postgresql.org X-Gm-Message-State: AOJu0YwmBy2ubAQcbjNU4qfFaqFtVAZO5tLMieaJERiSnHCcF4//OLUk g00baBcjtLcS90i7ImI8PZ3lo/g53msQ8r9UVUNzBTudtKnwEtxFhXabmHo4Q/YVmg== X-Gm-Gg: AfdE7clv7EcbAG/Z+JHYMJ2YTDujdsJuP5hxYNfI/emyeU/RkV7WAWN+07laJcOjoK5 y4hWj5LcrAd/Fm2uGGCLVm1zeIGCn+zsiwSrcYG36SCQdQTWcEN4cvZ6LfyvFsNwK6Gd2QDFy5/ +bcm2vGViqW7DsjGrXkj4WAx4e0gxnTtpfUZfDfmLPSGiDBGnuMBU+9hBeUK86EejOa7Ot9t2qd zFIpCQ41RpRuctyyHUaQYUnxWmG4ITh2p7o7vyWt/w65m0Gp+fMXHt6q8fmE51OOKsTk1rTNTcr WIvOmwaTzMc87ZWV4IzRsIvMhJDIga8bxRBbVi/6KhpE+TXx3gJyL+81FuZ0HCPqD+vHX283MPV NZQVhIoEdxPc2EgYxBZjxKSYMUCm6u4N3nmFbdJhCQZNizTNsSQeGYi+hQlBzfwtEIgqTSKnotv XsEf15S4vgVWp7LjrP02/qHNFcE7J0dekFHMw020c6oYSWt2xnd0ZpwXQ= X-Received: by 2002:a05:7301:1f13:b0:30c:536e:3a87 with SMTP id 5a478bee46e88-30ef07ccab1mr1094499eec.3.1782840656132; Tue, 30 Jun 2026 10:30:56 -0700 (PDT) Received: from microsoft.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30ee2f584bdsm10751375eec.4.2026.06.30.10.30.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2026 10:30:55 -0700 (PDT) Date: Tue, 30 Jun 2026 10:30:53 -0700 From: Noah Misch To: Peter Eisentraut , Ashutosh Bapat , pgsql-hackers@postgresql.org Subject: Wrong query result w/ propgraph single lateral col reference Message-ID: <20260630173053.51.noahmisch@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.3.0 (2026-01-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I had Opus 4.8 look for user-visible defects in SQL/PGQ (commit 2f094e7). Setup: CREATE TABLE v (flag boolean, id int PRIMARY KEY, name text); INSERT INTO v VALUES (true,1,'a'), (false,2,'b'), (true,3,'c'); CREATE PROPERTY GRAPH g VERTEX TABLES (v KEY (id) LABEL l PROPERTIES (id, flag, name)); Findings: 0. A WHERE clause that is a single lateral col reference gives wrong query results: SELECT t.b, gt.name FROM (VALUES (false)) AS t(b), GRAPH_TABLE (g MATCH (x IS l) WHERE t.b COLUMNS (x.name AS name)) gt; -- got 2 rows, want 0 Adding "AND true" corrects the result: SELECT t.b, gt.name FROM (VALUES (false)) AS t(b), GRAPH_TABLE (g MATCH (x IS l) WHERE t.b AND true COLUMNS (x.name AS name)) gt; -- got 0 rows, want 0 1. A WHERE clause that is a single property reference gives a spurious error: SELECT name FROM GRAPH_TABLE (g MATCH (x IS l) WHERE x.flag COLUMNS (x.name)); -- ERROR: unrecognized node type: 63 Adding "AND true" again corrects the result: SELECT name FROM GRAPH_TABLE (g MATCH (x IS l) WHERE x.flag AND true COLUMNS (x.name)); -- got 2 rows, want 2 For (0) and (1), Opus's opinion is that the right fix is: --- a/src/backend/rewrite/rewriteGraphTable.c +++ b/src/backend/rewrite/rewriteGraphTable.c @@ replace_property_refs(Oid propgraphid, Node *node, const List *mappings) context.mappings = mappings; context.propgraphid = propgraphid; - return expression_tree_mutator(node, replace_property_refs_mutator, &context); + return replace_property_refs_mutator(node, &context); } 2. A property whose value is an untyped literal stays type unknown. CREATE PROPERTY GRAPH gu VERTEX TABLES (v KEY (id) LABEL lu PROPERTIES ('hi' AS p)); SELECT p FROM GRAPH_TABLE (gu MATCH (n IS lu) COLUMNS (n.p)); -- ERROR: failed to find conversion function from unknown to text 3. [cosmetic] Invalid DROP PROPERTIES diagnosed via internal error message CREATE PROPERTY GRAPH g2 VERTEX TABLES ( v KEY (id) LABEL la PROPERTIES (flag) LABEL lb PROPERTIES (name)); ALTER PROPERTY GRAPH g2 ALTER VERTEX TABLE v ALTER LABEL la DROP PROPERTIES (name); -- ERROR: could not find tuple for label property 0 Opus says propoid is found graph wide, but the label property oid is not checked before performDeletion(), so the intended "label has no property" error never fires. 4. [cosmetic] Duplicate property names found only via catalog unique key CREATE PROPERTY GRAPH g3 VERTEX TABLES (v KEY (id) LABEL lu PROPERTIES (flag, flag)); -- ERROR: duplicate key value violates unique constraint "pg_propgraph_property_name_index" Opus thinks this is unintentional and cites lack of CommandCounterIncrement() between property inserts.