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 1sz7Dx-004IZ2-RO for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2024 04:25:57 +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 1sz7Dw-00DStr-46 for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2024 04:25:56 +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 1sz7Dv-00DStj-Ri for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2024 04:25:56 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sz7Dt-000JGh-GC for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2024 04:25:54 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7ea5ab4ac73so107145a12.3 for ; Thu, 10 Oct 2024 21:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728620752; x=1729225552; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ziajyQiNwPK776WT63hnPcqlmApsQHCbCTXgcethNVo=; b=cTOVcgXS2qaoydiX/nm2DNHUGADCqCbVBbs5BBFwYZdPfNRydsFRcEaNE6Dl+Vo26H KtpII63iyMLJg3lEcjA21o7DxuKfCZtf/Ri5qKr6BIxTIy7Kx07/yAZ5NaCdmGnu6moz xTa1kLKiXkGkvxRH6pjALCAWlrymmXtaAn9zwWyMQbXYMQdb7o+33zYV9+/R6OumuUuA EjIaCN81c7zjONqGvr3xDHWQtZpRmoa12cl8SGTA9ZbqpWDO3FX0Z5VvPQ/jtVByxjrJ uOrLEB86skz4ualLEaBsBGJAWRwdpvkIouFcyGPLFwtFa+3pKcPZGgsLspOKiWpsLHQc 5SWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728620752; x=1729225552; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ziajyQiNwPK776WT63hnPcqlmApsQHCbCTXgcethNVo=; b=UAlE49lG9pOjauApOX6Rpb9iGtYzqEsb2fGZ9iN5uQwssMUgCPRUsvZ0jkqTxuYHqZ SyJYCLMdQ+d+wIU6UihiDKe7ayhsYnHv6Tz7zwPrpKc4BHTAzML/uKnCPtYttqH7fJm7 0hE9UMxleW36ghmyrLKIiNe4J3y3xZLoHnxWmu/n4ahwsg922ncup/VBQei4ErVv2i0r z7thBg7ZIl8O0TkoBEzIshe/W1RQqH0d6qj8ntoGuhqHEKILgs2DKO4/A6qq10am1DTT uLN7I0+DqYtTPBDqvjCEu84Qu6k1sEBT7pG7jzKMBhawNQZyEXm2RPmfMOpY62H7t0DW 01QA== X-Forwarded-Encrypted: i=1; AJvYcCXV71TpLtu2xyhhernswjEmq29c1VTMm1w9ecE7sqqfKsfbWsVcNTLF9NtuZcxqAl6Ydz/TYniGjGdK@lists.postgresql.org X-Gm-Message-State: AOJu0YxKat2PmAGNOQBICOl6kfqEszAQfcdsuUSWQMIikPnwGeoz6dAE E/mP1q+Y/TKY0IXR2OleL3taPOdtabJgNTKbGjq74GB7xxwhl6GC X-Google-Smtp-Source: AGHT+IFKbKrnt0+aP4snPhlMyDMX4bclstoYPJbNJjg1k/5x+kbHWhZY8KqwV0mcE3Ag1xpHhdgmJw== X-Received: by 2002:a05:6a21:680d:b0:1d5:388f:275c with SMTP id adf61e73a8af0-1d8bcf2c77dmr2151641637.20.1728620751898; Thu, 10 Oct 2024 21:25:51 -0700 (PDT) Received: from [10.10.20.104] (node-sh5.pool-101-109.dynamic.totinternet.net. [101.109.144.41]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2aa939f2sm1833750b3a.131.2024.10.10.21.25.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Oct 2024 21:25:51 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------pyLxNaQu7xk2VNx6x9ayVcfD" Message-ID: <40c8a5c2-0040-4fe6-ab11-6dca23353a07@gmail.com> Date: Fri, 11 Oct 2024 11:25:47 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index To: Richard Guo , Tom Lane Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org References: <18652-deaa782ebcca85d1@postgresql.org> <2527690.1728510183@sss.pgh.pa.us> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------pyLxNaQu7xk2VNx6x9ayVcfD Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/10/24 10:52, Richard Guo wrote: > On Thu, Oct 10, 2024 at 5:43 AM Tom Lane wrote: >> It looks like we are generating a Path tree in which one of the >> inputs to a MergeAppend is a plain unsorted seqscan, which'd >> be all right except it doesn't expose the required sort value >> in its targetlist. > I think this is because find_computable_ec_member() only tries to > match Vars. Maybe we should teach it to also match OpExprs? Why not look if some entry of the TargetList contains the var? Something like attached? If I understand correctly, MergeAppend will still add a resjunk column and Sort according to the column. -- regards, Andrei Lepikhov --------------pyLxNaQu7xk2VNx6x9ayVcfD Content-Type: text/x-patch; charset=UTF-8; name="probe.patch" Content-Disposition: attachment; filename="probe.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL29wdGltaXplci9wYXRoL2VxdWl2Y2xhc3MuYyBi L3NyYy9iYWNrZW5kL29wdGltaXplci9wYXRoL2VxdWl2Y2xhc3MuYwppbmRleCA4ZjZmMDA1 ZWNiLi44OWFiMjlmZThlIDEwMDY0NAotLS0gYS9zcmMvYmFja2VuZC9vcHRpbWl6ZXIvcGF0 aC9lcXVpdmNsYXNzLmMKKysrIGIvc3JjL2JhY2tlbmQvb3B0aW1pemVyL3BhdGgvZXF1aXZj bGFzcy5jCkBAIC04OTksMTEgKzg5OSwxOSBAQCBpc19leHBybGlzdF9tZW1iZXIoRXhwciAq bm9kZSwgTGlzdCAqZXhwcnMpCiAJZm9yZWFjaChsYywgZXhwcnMpCiAJewogCQlFeHByCSAg ICpleHByID0gKEV4cHIgKikgbGZpcnN0KGxjKTsKKwkJTGlzdAkgICAqdGxleHByczsKIAog CQlpZiAoZXhwciAmJiBJc0EoZXhwciwgVGFyZ2V0RW50cnkpKQorCQl7CiAJCQlleHByID0g KChUYXJnZXRFbnRyeSAqKSBleHByKS0+ZXhwcjsKKwkJfQorCisJCXRsZXhwcnMgPSBwdWxs X3Zhcl9jbGF1c2UoKE5vZGUgKikgZXhwciwKKwkJCQkJCQkJICAgUFZDX0lOQ0xVREVfQUdH UkVHQVRFUyB8CisJCQkJCQkJCSAgIFBWQ19JTkNMVURFX1dJTkRPV0ZVTkNTIHwKKwkJCQkJ CQkJICAgUFZDX0lOQ0xVREVfUExBQ0VIT0xERVJTKTsKIAotCQlpZiAoZXF1YWwobm9kZSwg ZXhwcikpCisJCWlmIChsaXN0X21lbWJlcih0bGV4cHJzLCBub2RlKSkKIAkJCXJldHVybiB0 cnVlOwogCX0KIAlyZXR1cm4gZmFsc2U7Cg== --------------pyLxNaQu7xk2VNx6x9ayVcfD--