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 1mK1fo-0006BD-OG for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Aug 2021 16:59:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mK1fn-0001dA-Kp for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Aug 2021 16:59:15 +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 1mK1fn-0001d2-CR for pgsql-bugs@lists.postgresql.org; Sat, 28 Aug 2021 16:59:15 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mK1fl-0001r9-0c for pgsql-bugs@lists.postgresql.org; Sat, 28 Aug 2021 16:59:14 +0000 Received: by mail-lf1-x12a.google.com with SMTP id c8so8831116lfi.3 for ; Sat, 28 Aug 2021 09:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=WzzN7POnDl4TWVr45llPgaxBcMm4NHSYM8m2tneIdTA=; b=tlZNV7oclHbJl93TUOANu+dUeGMtiX86kyh3uflqawYQB9p5sh6OPiBRmnrncGUKEd DkkRrt1c+won0Ph9btxAgUrgXjWmxWBSunJcinUxz8sywwnksg3s6oiqGIfeWGn2Ex36 rRhNZZfjCKWCqvBBC0ahKu9ZAEjJonjYYhQ2ER8osm2V5fwF4PcI4RgcRgWk4REg7iJJ /oulCczFpI5R9Cswg4Q6QWWtqZDVQD5TAFKzffpZ3234wR9vWea4A/ercE7wv6oRczG3 xUwf6etxKrM/Q+HLbqGaoR06933s2JM+q1eXUIl9OF9WL/r9My1iGITTyVx+xUtETl6h fiZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=WzzN7POnDl4TWVr45llPgaxBcMm4NHSYM8m2tneIdTA=; b=hXYq7awdmR7/oLodX+20sIUA5bjo3D704hkCFMG4/D81Z7UCsTluhy3A6ZS5sg7psx hIZzsaq++ivJRxl3Kg2YO6eJHXyWztklIgLQmkVUIZvRUd7eQhM1E6HsKHUrVvRUfi3d 2xnsof/pQDGlSHSiCfbdEIs4WWuEH5B6tqi4/J8IX/R5Ckneal0rG+u50bJJuDwCbPnx VgkKBRYs3Bu3ydyOKH9krlRGycjVZteJ9NqQRhnGhe1fCxJczBW5qAyH0dxrQ6WJqcxk 9ZPChexWUv1wv1diIEA+QVWyVaKY166WfT0KnxpQ1gsaR18bZqCCQQBSwcQDdklxQMxu sZGA== X-Gm-Message-State: AOAM5301ecJ7OiK4tkHW8hDGNOv2EVuZbh8eQHWRXglyeGd1MJ6IDimT zok63FlefbPGdr2MTjbJiJ8IiIy/0GM= X-Google-Smtp-Source: ABdhPJxXrHbLViSe7ETHz8jVEG++Wz7cUA6DIrOjwsOKEqfqfkbh8J9vT3yjcLHo0Vv7xAUbXEFu/g== X-Received: by 2002:a05:6512:2205:: with SMTP id h5mr11436155lfu.398.1630169950709; Sat, 28 Aug 2021 09:59:10 -0700 (PDT) Received: from [1.0.0.7] ([178.155.6.221]) by smtp.gmail.com with ESMTPSA id y9sm1125654ljm.5.2021.08.28.09.59.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Aug 2021 09:59:10 -0700 (PDT) Subject: Re: BUG #17161: Assert failed on opening a relation that exists in two schemas via the LANGUAGE SQL function To: pgsql-bugs@lists.postgresql.org References: <17161-048a1cdff8422800@postgresql.org> From: Alexander Lakhin Message-ID: <25f71277-c45a-8ef2-ef9a-9054c3d6e0b0@gmail.com> Date: Sat, 28 Aug 2021 19:59:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <17161-048a1cdff8422800@postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 25.08.2021 23:00, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 17161 > Logged by: Alexander Lakhin > Email address: exclusion@gmail.com > PostgreSQL version: 14beta3 > Operating system: Ubuntu 20.04 > Description: > > When executing the following query (based on the create_function_3 test): > CREATE TABLE functest2 (a int, b int); > > CREATE SCHEMA temp_func_test; > SET search_path TO temp_func_test, public; > CREATE TABLE functest2 (a int, b int); > > CREATE FUNCTION functest_sri1() RETURNS SETOF int > LANGUAGE SQL > STABLE > RETURN (SELECT count(a) FROM functest2); > > SELECT * FROM functest_sri1(); > My initial conclusion was incorrect. Duplicate relation is not needed in the second schema. It's sufficient to just change search_path to another schema: CREATE TABLE functest2 (a int, b int); CREATE SCHEMA temp_func_test; SET search_path TO temp_func_test, public; CREATE FUNCTION functest_sri1() RETURNS SETOF int     LANGUAGE SQL     STABLE         RETURN (SELECT count(a) FROM functest2); SELECT * FROM functest_sri1(); Best regards, Alexander