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 1pMaOm-0003Vb-9c for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Jan 2023 20:05:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pMaOl-0002QC-8A for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Jan 2023 20:05:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMaOk-0002Q3-Jh for pgsql-bugs@lists.postgresql.org; Mon, 30 Jan 2023 20:05:03 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pMaOi-0005O0-7E for pgsql-bugs@lists.postgresql.org; Mon, 30 Jan 2023 20:05:01 +0000 Received: by mail-qt1-x82f.google.com with SMTP id v17so1394906qto.3 for ; Mon, 30 Jan 2023 12:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=aENZhXaCu437mgWa7TVUrhBMBAaBl0sx4Q/0a205nQw=; b=ZQWn1SkzZlNdpU0+Ce0nFa/QVb7K88p5PbbTmzjLuYRsbLiAgv4Mjx+eiFcZq29B1U UJDP8hdEp95inEA4ZTDXWA6I3EdeMaoaR8nQI1xhnx8el7jtaJ31xDaiOkTWC16Rx0t3 GpoKsj8NYmPiATBiNtEwPM4sFIXZLuGocoMcsaUJuztF4bN3mGGHDIOIwmre5OCeK93t EiIvMN+kxJMASaO+lCAQXmjUuXBkFImDIhcCarJ7wyxDStUQADDq589c/4/Ha6fwvUR8 6AdVICaJobtJPzOgX2UzbQH1wQL2tBOf0RwM0eAsdskh4TX2wOP0tUvXHoG9MsIJnFno 0ekQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aENZhXaCu437mgWa7TVUrhBMBAaBl0sx4Q/0a205nQw=; b=qCDzT9J8WvOFhmr4oxj1QPTTyejMIxtr/mDlQXogvdLd4dhA11+rc7yUTAZxLVMXlc I/n2f3Lh1pq6WDfp2V+qtPIt5M1u/xM44XbuhKnLUgR3kc+/9Q6DhNMX0CGgKVzzZ9dj iOWodet6EkQ8SwZzfnn2AZ3caKxGNoO1nruZwIuvTA/71nlt8pxxH7LX96TQRUP7ICGF u3ITw0SGKQdJGUzy5pBKsavdwmEnq5JKh156e29ZFzvnrNFJVcQy8ucXyKSl730GRZt+ 03yVgZukuMBmxImOy7+JeQNFVnTlixJB5rm+OKDxL7ePMkBsKqNT1eoGSLQzrRfR6SA+ MkvA== X-Gm-Message-State: AO0yUKVHatEQnnMv75vKMG3oX6HqeZOs+X10QfmxPy1/+ZV/gWcNuO4j ot2je/SQHA2wjzeWqJhWyE1Pwg== X-Google-Smtp-Source: AK7set9A/JtJnnC2ALHAVZBokIlCt8PeXbpZCB66dEj7sjh4z1xq71UWvTrD5HufSAZuMLQPTiUpAw== X-Received: by 2002:ac8:5889:0:b0:3b6:471f:3e88 with SMTP id t9-20020ac85889000000b003b6471f3e88mr16696070qta.50.1675109099185; Mon, 30 Jan 2023 12:04:59 -0800 (PST) Received: from [192.168.4.41] (162-239-31-113.lightspeed.dybhfl.sbcglobal.net. [162.239.31.113]) by smtp.gmail.com with ESMTPSA id e17-20020a05620a015100b0072396cb73cdsm1017842qkn.13.2023.01.30.12.04.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jan 2023 12:04:58 -0800 (PST) Message-ID: <1f2cbcbd-25fa-9da0-ae0d-a4783aad966a@joeconway.com> Date: Mon, 30 Jan 2023 15:04:58 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: Pete Storer , Christophe Pettus Cc: Tom Lane , Bruce Momjian , "pgsql-bugs@lists.postgresql.org" References: <2957101.1674746628@sss.pgh.pa.us> <2961799.1674749201@sss.pgh.pa.us> <490923.1675096173@sss.pgh.pa.us> From: Joe Conway Subject: Re: Query execution failure 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 1/30/23 13:24, Pete Storer wrote: > Makes sense - but I'm using the PG substring function here. > > LEFT OUTER JOIN main.ship_event se ON (se.ship_event_nm = substring(dp.shipevent from 6 for 5)) > > In this case, the dp.shipevent is in the fdw-accessed MySql table. Shouldn't that force the sort to be local? Looking at the mysql-fdw source (which looks pretty much the same as postgres-fdw at first glance): 8<------------- /* We don't support cases where there are any SRFs in the targetlist */ if (parse->hasTargetSRFs) return; 8<------------- Based on that, perhaps a kluge (and completely untested) workaround is to: 1/ create an SRF that returns one column, one row constant 2/ add the SRF to your targetlist The SRF likely needs to be plpgsql to avoid inlining, maybe something like: 8<------------- CREATE OR REPLACE FUNCTION theanswer() RETURNS setof int as $$ BEGIN RETURN NEXT 42; END; $$ LANGUAGE plpgsql; 8<------------- HTH, -- Joe Conway PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com