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 1vBy4P-007PXx-1u for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 16:21:44 +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 1vBy4N-00ABR0-DE for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 16:21:42 +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 1vBy4M-00ABQs-WD for pgsql-hackers@lists.postgresql.org; Thu, 23 Oct 2025 16:21:42 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vBy4J-003NdY-1C for pgsql-hackers@lists.postgresql.org; Thu, 23 Oct 2025 16:21:40 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b4c89df6145so179369466b.3 for ; Thu, 23 Oct 2025 09:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garret-ru.20230601.gappssmtp.com; s=20230601; t=1761236495; x=1761841295; darn=lists.postgresql.org; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=UnCOLi+m50UxxqUyM8ot8oR88ffkiRzm+u+jxxxHk2M=; b=0oIwOFoPtRwVWHct9GpCdir4e41McrCqMX3ugxYGWrQTVVVqY1XF0XpGpu+QsIxb+l pkbZXsN1WgkuAN/95j+1YUJH6I7NkzAMYBk+UWljoESjgpF5O9JuP8xCxFnoGPDQXJyB 5v2T5rHaHRaX0KpjyjIPq+btnR7Gm37QmsyfTrbHT5+CRHZIIN9V+2KCFy5Ta4xLXNAB P1fydYAecC/A0dka0QJYOnbqI+c2rhnNINfqK2bXCFrkSB4aDVZD1xvR7y9FeD64PNiT cCGNhN6AsjUZ8eCdG23ZrImNT81MGLxCVFuWknGylXlwVxbKy4iMyomXn1hYuciBnFTH 8S3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761236495; x=1761841295; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=UnCOLi+m50UxxqUyM8ot8oR88ffkiRzm+u+jxxxHk2M=; b=aE6OjnfCEDSN3oh62IarL4Avrg7tBIFh/8ZlyQcVMscPiYbGXUuVyHMAfeAmO0N96f gJn/n2+u8MBRJOUHHiIqltN1218QV5rNynmO5HspZTrUsqj5L313dt7qT3hhJnHKtvuj kRT3gPjzf6djWD054nri18HG0ybQMDIVYo4S3lP1Yud4WQPD3hTK8z8PMbstAIFCAh6e cNq0moegW4i0kjJhUKdSXOam20TKTlNJSe2D4fRRNWNl6696CTu0U/WSL3/6HqQTQSQJ HBz7XFZQia96o1xuwiVOay5WERs2ZCieOG2YzObpgIPG3vGekSCPmHSU55lPFe/wRk5c xkWA== X-Gm-Message-State: AOJu0YyjgMAz7BWGUEYP2EZrs2m6pAXKIZ5AAIE39jQBOIgjL83F7X/P 4PduB3mg+rIRTdl/G+7DVP13FvKucxgg4sXuZQEphbG/Px7IyTvSqH8V/FwipBtHhAy/AkFayn3 uatf7XA== X-Gm-Gg: ASbGncsYu8TLub0uyOXAdpDdDNT0/wav9mrQB+XouNobAjCX3c5IPdjWqBYvpsvwM+g 8bYOgF7U5IihmT+hU05CeJYx6yU452oeYQfIIFVhgZparnNtjkMCTYYhTe3dMHZC8Cb65DZHMss 48OaN0wklX+rwtyFBh+2EWkRz/WrlsuZFZud0zNMLAqVTlyoijrsHwdIVVHCuNt94qMPAQh0sHV leRM9VJpeR6WlLfWWusmuiNK46/XJIAfEYnQwuF1iUPCyca4susKbiymNvVBib6gPT4uWQQ2N2J nEGci+3azPQZ0OEnepSkzuRgPTggLgsOk3/xSpZclq1INU6EoA8e5DxOht1ICZsJJt1Kr0rRSDE gwj6RX+U/DA5L7EcbvbmrOSrfc2J+mfqDAEc3yGzAx15xLIeY0Z4b7jBPalYgtmAkUh+kBt27mh nFN2wH8TEYzLgaSJvgKQmp X-Google-Smtp-Source: AGHT+IHIxrwYAb8x85xr6ML1UqKDk/abqRoNt1IbYdtD1ehY4o1T3rKvhut1yi0R6p+as2IdMCFdvg== X-Received: by 2002:a17:907:1b0c:b0:b6d:2f32:844a with SMTP id a640c23a62f3a-b6d2f328766mr795759266b.22.1761236495149; Thu, 23 Oct 2025 09:21:35 -0700 (PDT) Received: from [10.248.37.148] ([130.41.208.2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b6d511d41a4sm258977966b.9.2025.10.23.09.21.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Oct 2025 09:21:34 -0700 (PDT) Message-ID: <2b91e358-0d99-43f7-be44-d2d4dbce37b3@garret.ru> Date: Thu, 23 Oct 2025 19:21:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: PostgreSQL Hackers From: Konstantin Knizhnik Subject: Bug in pg_stat_statements Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi hackers. In PG18 gthere is bug either in pg_stat_statements.c, either in queryjumblefuncs.c. Repro (you need Postgres build with asserts and pg_stat_statements included in shared_preload_librarties: create function f(a integer[], out x integer, out y integer) returns record as $$            begin        x = a[1];        y = a[2];    end; $$ language plpgsql; create table t(x integer); select ((f(array[1,2]))).* from t; The problems is caused by ((...)).* which cause to include the same array literal twice in JumbleQuery. But pg_stat_stataement assumes that any occurrence of constant is unique and it cause assertion failure here:         /* Copy next chunk (what precedes the next constant) */         len_to_wrt = off - last_off;         len_to_wrt -= last_tok_len;         Assert(len_to_wrt >= 0); So we should either exclude duplicates in RecordConstLocation (queryjumblefuncs.c) either in generate_normalized_query in pg_stat_statements.c What is considered to be more correct?