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 1whOE3-000C6V-2k for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 09:05:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whOE1-006IzW-37 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 09:05:50 +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.96) (envelope-from ) id 1whOE1-006IzN-0M for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 09:05:50 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1whODx-00000000D6L-3gAl for pgsql-hackers@postgresql.org; Wed, 08 Jul 2026 09:05:49 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 0BD9B7A014C; Wed, 8 Jul 2026 05:05:43 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 08 Jul 2026 05:05:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1783501542; x=1783587942; bh=Nsxsp25OrC2L4My5ichXnSOLjHdIxX13 gjcLMaovi0E=; b=bRSi8MmXB2Vkr/QqDqvOCcGv42Hcy4LL5cEhZCo5veMh3N/n DyIDrhEH3FxJxt9QeDyNdgDiLXkwpkyWpAuYK8cdzSFq5MilhlUfL3kM//BtZ1nM eUtQzXfiZe1R58d81PfIjRd71Af1VyTo7XD/ga3QCXB0lxLoAofmlkjDyU/A340G gz2PrSeXRKu3zlKo01+LkVdWmSZBpDBYG96aLA7BanlbOtv6MNJqZOk+9b2+lzBX oqurZl8VroiAnhcsv3K3LR75B37YikypUsZfPpGPi16yPE7jLAB9+U25ySIcgAy0 8sxl014HfaFSP/yWMtF2GnyEAVdBMZz5hzwm0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1783501542; x= 1783587942; bh=Nsxsp25OrC2L4My5ichXnSOLjHdIxX13gjcLMaovi0E=; b=C qyOa/kGr+NGqwLghb3AI5DEB0C9gWf7ZZvlR8cZAhwssBPPPPK1YUALrPq8rSEmS rcyJGV6/lknc4PRPwSZUU3nswOV5hivddMuYxHcp1e56Obz3waX5SUz9R3ypivl/ nUOKqq9r/xwwVbhuu8TfaCU+8HFDYfZDEPtLuiMLG+WPUE0RY82B2apGrsY76L0V +kNz45Yk+xig8VNL9BnQyQzGZvVN0kjQ68e7YUYcG4dlKWKCr2UWRnC3rPCBxhEp ms9JiyCUwb4mQtYHLdod4o/O+NAlnvMa/Xh5JWI05s2A87IqxbpzwIhD0SVF6UV4 GgWaeDrFKuLZEswg5iFAQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGtMKqH2sdEMmSgzig7nkGgUbO4N9JMxziMGCxYfWrOnU4e7dC17pj9njWoOWgBbk 38yJUW3oSqkx0K6yaeJB4STMi4irNtCWmj+12Od7wueHF3BnUHLSSM9bw4Ar9hH8ZVSRbQ +3rF8FWYgLSDC8+BT8zUtjlB5CwysA3Y++7dFPLDcfMwZqXxagMwTZSTZftaGhJE1aa6oX 8QwPGjnSKCru2mW1M3u0dQOEOzFK1FPjA2NHmqR0twEntBIpB0RlgPRHpEJyaYZY+ji+7U GiS8a+3bflU2q6Q+wd09OemB5ffVt44eYZYf7n9qqedfj4x5wxTV8TNOC1m5UzBjhEQJIS wonRFLPguSGUvVbRz+s+7ffFCF3QcLpoQdEuck8qWFeNHsfkxSNm/LET8qt7jY90GqbCf5 GMO4EOraULLd8c5A+xnN1bfJdHPdZbJynUJ77OwP18wHmjKQJgtr7jppF72J2UUTiAThQA vMDuo6WpkKojs61sbSCTO/eLVoxMftXfpvI9cVlPKB3VCkKQvrvEAA5jzq8TePdTY7qbUe pKXmZ+NL/C1KpkeXZGBqeTiRflqZbS9yBnI+r4fLICt+hV5rvvXyXL6x5IqlrBj31slSk5 kbZA7x8X/F18J9I0+sD8fEq/bCix+tnzX/6wU1o0Gr1/SZK4VXeiv7Ufzhtg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Jul 2026 05:05:41 -0400 (EDT) Message-ID: <517efb40-dcf8-4ff5-bfa6-c2bbf18ff64e@eisentraut.org> Date: Wed, 8 Jul 2026 11:05:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Wrong query result w/ propgraph single lateral col reference To: Ashutosh Bapat , Noah Misch Cc: pgsql-hackers@postgresql.org References: <20260630173053.51.noahmisch@microsoft.com> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.07.26 08:54, Ashutosh Bapat wrote: >>>> --- 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); >>>> } >>>> >>> >>> This matches the pattern in the other expression mutators, and also >>> fixes the problems. Thanks for the report, that was quite subtle. >> >> Fix attached here. > > That's 0003 patch attached here. committed >>>> 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 >>>> >>> >>> I think property's data type should be set to text, not unknown. I >>> think we should combine the fix for this in >>> https://www.postgresql.org/message-id/CAHg+QDcyKNWyzDoKMxiZNjv7C-wAxs8y0ZoNkOV137Y+nk3UXg@mail.gmail.com. >>> >> >> Attaching the fix here. But I will also report it on the other thread >> [2] and discussion can continue there. >> > > The patch in that thread was committed. Attaching fix for this issue > as 0002 patch. committed >>>> 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. >>> >>> We get the same error even if we split the duplicate properties across >>> two commands. >>> CREATE PROPERTY GRAPH g3 VERTEX TABLES (v KEY (id) LABEL lu PROPERTIES (flag)); >>> alter property graph g3 alter vertex table v alter label lu add >>> properties(flag); >>> >>> I think we need to check for duplicate records in >>> pg_propgraph_label_property catalog in insert_property_record(). The >>> function already checks for duplicate records in >>> pg_propgraph_property. Additionally we might need >>> CommandCounterIncrement(). >> > > When investigating this issue I found that duplicate labels also have > the same issue. Fixed both the issues in patch 0001. > > I have added a noop else in insert_label_record() after ereport() > since it ties the following code block well with the if condition. But > we can remove it if it's not improving readability. > > There's slight inconsistency in the error messages for duplicate > labels and properties. In case of labels, we always report "label ... > already exists". But in case of properties we report two different > errors. We report "property \"%s\" specified more than once" when > duplicate properties appear in the same command. But we report > "property \"%s\" already exists" when duplicate properties appear > across commands. I think the difference is minor enough that we can > entirely ignore it and avoid spending more code on it. If we feel > strongly about being consistent, either we can detect duplicate labels > in the same command and report "label ... specified more than once" or > we can make the same error being reported in case of properties in > both the cases. I would like this code to be organized differently. Note that the existing insert_*_record functions don't do any error checking; they are just there to make catalog modifications. There are various check_* functions that pretty much correspond to syntax rule checks, but these are run after the catalog changes, hence the present issue. Maybe we should have a set of "pre-check" functions in addition?