Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l56Ss-0006e0-F4 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Jan 2021 12:31:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l56Sr-0000pJ-E4 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Jan 2021 12:31:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l56Sq-0000pC-Kb for pgsql-hackers@lists.postgresql.org; Thu, 28 Jan 2021 12:31:57 +0000 Received: from forward3-smtp.messagingengine.com ([66.111.4.237]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l56Sm-0001pn-QO for pgsql-hackers@lists.postgresql.org; Thu, 28 Jan 2021 12:31:56 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.nyi.internal (Postfix) with ESMTP id BDE601952198; Thu, 28 Jan 2021 07:31:49 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 28 Jan 2021 07:31:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=sRUKKdkpG+4HGFUP3JxYdOax06wyBXtwOjxRDtdAZ fI=; b=p5QUf7bkqMcbFKA/jgy6NgPquj2dflB/xlZR3FhQOieoaYq2u7Y6FVVqP nK/Y5DVWRWiT2aU3vO8sr/U1q9RBOE3YottBWEs32ons6ON1+Hwkp52cwdO0F1lt TsJazYr0e5SAHUW6sP4dYJErTQP6pGLyS7u5i77VBUAIqNHKRr8urB3N03PpAgyT yv/V7XYMKZo6b3rOp9oxLFSPFqge5jBVKJRQBG7u9Nha6b10lxEMuXbPdKZpXLua cSAgxGBkEMQ/Z8wRwNtdKF9rFiDryP1Up3+jsz2xlNH5Ujy1glFL3et3peQkpSuB KX0p+fU9BNe609n7bq/fLRsfKFqvQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtgdeflecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhohfkffgfgggjtgfgsehtje ertddtfeehnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghr rdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomheqnecuggftrfgrth htvghrnhepveeuteelvdeuudfggfevudegudfhvdekgeeufefhtdeguedugefhheeugeef hfeinecuffhomhgrihhnpedvnhguqhhurggurhgrnhhtrdgtohhmnecukfhppeekjedrud ejjedrieelrddugedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhhtsedvnhguqhhurggurhgrnhhtrd gtohhm X-ME-Proxy: Received: from april.pezone.net (p57b1458c.dip0.t-ipconnect.de [87.177.69.140]) by mail.messagingengine.com (Postfix) with ESMTPA id C3EE724005D; Thu, 28 Jan 2021 07:31:48 -0500 (EST) Subject: Re: BUG #16583: merge join on tables with different DB collation behind postgres_fdw fails To: Tom Lane , pgsql-hackers@lists.postgresql.org References: <16583-4dc8f6c3b8ed24fa@postgresql.org> <1072831.1597678008@sss.pgh.pa.us> <1156217.1597703867@sss.pgh.pa.us> <1311836.1597781384@sss.pgh.pa.us> Cc: jurafejfar@gmail.com From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Thu, 28 Jan 2021 13:31:46 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1311836.1597781384@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-08-18 22:09, Tom Lane wrote: > Here's a full patch addressing this issue. I decided that the best > way to address the test-instability problem is to explicitly give > collations to all the foreign-table columns for which it matters > in the postgres_fdw test. (For portability's sake, that has to be > "C" or "POSIX"; I mostly used "C".) Aside from ensuring that the > test still passes with some other prevailing locale, this seems like > a good idea since we'll then be testing the case we are encouraging > users to use. I have studied this patch and this functionality. I don't think collation differences between remote and local instances are handled sufficiently. This bug report and patch addresses one particular case, where the database-wide collation of the remote and local instance are different. But it doesn't handle cases like the same collation name doing different things, having different versions, or different attributes. This probably works currently because the libc collations don't have much functionality like that, but there is a variety of work conceived (or, in the case of version tracking, already done since the bug was first discussed) that would break that. Taking a step back, I think there are only two ways this could really work: Either, the admin makes a promise that all the collations match on all the instances; then the planner can take advantage of that. Or, there is no such promise, and then the planner can't. I don't understand what the currently implemented approach is. It appears to be something in the middle, where certain representations are made that certain things might match, and then there is some nontrivial code that analyzes expressions whether they conform to those rules. As you said, the description of the import_collate option is kind of hand-wavy about all this. -- Peter Eisentraut 2ndQuadrant, an EDB company https://www.2ndquadrant.com/