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 1rzcEK-005Kqt-2r for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Apr 2024 13:00:08 +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 1rzcEI-00F6ZP-65 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Apr 2024 13:00:06 +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 1rzcEH-00F6ZF-U1 for pgsql-bugs@lists.postgresql.org; Wed, 24 Apr 2024 13:00:05 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rzcEF-002hyA-D2 for pgsql-bugs@lists.postgresql.org; Wed, 24 Apr 2024 13:00:05 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5196c755e82so9586087e87.0 for ; Wed, 24 Apr 2024 06:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713963602; x=1714568402; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=o6FkYIavRoyXcWAJnm9a4tCrrhqhbJT5EwmOURXsaNA=; b=bwHifyh9pV2q1ZjwlEPd02Ltcs+jA9IfXdJTukSQxlkFrFHjnUTfam5gVIpg5CEDPE xm1W4HUx3mbIba8+AZ9r98XL3cYhFuJ4tBUt7tF3lc9XS9XIZNAgMHrz/UP8oAwXSIG5 pWeZWHCYbDsdgtbYNXZ7erDyDepCeZt87Nw189mlYVAKGOEcM+VlVT1n796EnMOHqzvZ blVVWbibKj2EuYFw8EbnM4y8anepKTEuC+vxz0CBB2gsrEmKwp5OaNW+tdOkMMAg5BCT ePGIFZOG11Lb/r+I4pfj7datH1ZKI7iTB/PSdH+kkSZ7hvWlUhb0NubWntblJ6oYJgLE onXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713963602; x=1714568402; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o6FkYIavRoyXcWAJnm9a4tCrrhqhbJT5EwmOURXsaNA=; b=e+8XVYOgIwKwcrMHGOkGNevwA4gTU4cM4LY60CrUY5eRmfxOtNwFe096Ced1yog7C2 PtMYn/dJwqicdi5vwXWZ092cLnOYh+R/438o/S0Mu9KWJ7t18+3g/Cf/tt4uKvO0pFyJ 58x4MYto5UFwDUbwKM9PWpM6nG5RMv0WYhHIG6XMtZH4OfKZdBDs2lbovoa6VrNH6gii uOWKOdXF7w07a6M3O31ZAsgTuArT23SHxfNQdYU/FL6+wRh/p7/yf6MmW46WrFiZb+5W taB+yeStjywMJwZpAFI9HzwjF8mYFXohxocmwp5nyigvF9wXU51zObMtMtAAOp5gDprT Gj5w== X-Gm-Message-State: AOJu0YxphgY/lAkGUS/QZI3G31FzE/YMhoTzFc0kRIGQ5mCUDU56LbZ+ Jn/0yhNgZkDGcoaM0i4ZIipK9bYvHMFR42m/cUiGAZJERonlcGPu X-Google-Smtp-Source: AGHT+IFXgxVEh13OrUhr9QViR0p9bmmxvroB5fVQ1zWOb/1Vp4ZzTL+8pLPUG2YEe44nKdoPqw/j8g== X-Received: by 2002:a05:6512:3995:b0:51a:c3a6:9209 with SMTP id j21-20020a056512399500b0051ac3a69209mr2042927lfu.68.1713963602018; Wed, 24 Apr 2024 06:00:02 -0700 (PDT) Received: from [1.0.0.7] ([91.185.78.237]) by smtp.gmail.com with ESMTPSA id q24-20020ac246f8000000b005130ece9099sm2377649lfo.277.2024.04.24.06.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 06:00:01 -0700 (PDT) Message-ID: <178d5d4c-969b-da9f-37a9-34bf6693d1ea@gmail.com> Date: Wed, 24 Apr 2024 16:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #17855: Uninitialised memory used when the name type value processed in binary mode of Memoize Content-Language: en-US To: David Rowley , Robert Haas Cc: pgsql-bugs@lists.postgresql.org References: <17855-5f523e0f9769a566@postgresql.org> From: Alexander Lakhin In-Reply-To: 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 Hello David. 24.04.2024 05:25, David Rowley wrote: > On Sat, 9 Sept 2023 at 20:00, Alexander Lakhin wrote: >> I've stumbled upon this issue one more time. With a query like this: >> CREATE TABLE t(id integer, node name); >> CREATE INDEX t_id_node_idx ON t(id, node); >> INSERT INTO t VALUES (1, 'node1'); >> >> (Note that this time the error is triggered without the Memoize node.) > Yeah, it's really not a Memoize bug. It's an Index Only Scan bug. > I've added Robert to get his views. > >> Maybe it makes sense to register the proposed patch on the commitfest at >> least to keep it in sight? > I've attached another patch which uses another method to fix this, per > an idea from Andres Freund. I'd class it as a hack, but I don't have > any better ideas aside from the mammoth task of making name variable > length. Indexes on name typed columns simply don't store all 64 bytes > of the name, so it's not safe to have code that assumes a name Datum > points to 64 bytes. The patch makes it so such a Datum *will* point to > 64 bytes. I've tried to do this as cheaply as possible by saving the > indexes to name columns in a new array in IndexOnlyScanState. That > should make the overhead very small when indexes don't contain any > name-typed columns. I've tested this patch with an additional #include in nodeIndexonlyscan.c (for namestrcpy), it works, but I'm unsure about the check for NAMEOID — it seems like the fix could break for a type based on name. Say, with: CREATE DOMAIN named AS name; CREATE TABLE t(id integer, node named); CREATE INDEX t_id_node_idx ON t(id, node); INSERT INTO t VALUES (1, 'node1'); SELECT array_agg(node ORDER BY node) AS node_list FROM t GROUP BY id; I still get the Valgrind complaint. Best regards, Alexander