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 1jZinI-00087u-Sf for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 22:27: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 1jZinH-0005sY-Qy for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 22:27:03 +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 1jZinH-0005qk-JD for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 22:27:03 +0000 Received: from mail-il1-x143.google.com ([2607:f8b0:4864:20::143]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jZinF-000157-EU for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 22:27:03 +0000 Received: by mail-il1-x143.google.com with SMTP id c20so1963556ilk.6 for ; Fri, 15 May 2020 15:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=pxF9FkHyIGbNn/Gn/x4XHU/Cwq0d6GjlP3WcttyZ4Hg=; b=Pmc1qBhm0z41LehS3RtPvI2LZviIXK3YMztXi1E28FHzuVarLQMvveV4KNETTsE8g5 OU5aUV96/qhyttYRXZOdGat+2XUSUDgyYuPeQZxnfbVYZqqgOqiCut9BkpvguSe1oBqI xtVCxGXorrbPEOyKGkW0KRKW5e/zbXJpjiLU2aotOKYtrRTCXN1iHNk7//uDP0UXvECF i7v+yxFR9hlRyfByyJYWTEEyDmY6BGo13yE1MLRAYvfhpmEjnOFMdVYfZK8o4n0iNaLK nE4b6ELDsx6vFH1y/uoRy2dao93i24XjO7iNF3dmRZCucnSCpSbJ4OR6uggCUNpzkSZZ UJrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=pxF9FkHyIGbNn/Gn/x4XHU/Cwq0d6GjlP3WcttyZ4Hg=; b=AQTdX9djswIYZsBq5yPJpMA73Gqh2+KqxDmhtzF41WtybJnfaC94htW42NKcdXzJQo suwBsbYTY0O6Am4Uh1q52WGMejE2t6D7BkrbdqMOOkMPDqo6c4nSK79788rDNaTKElkV vMR5dcsF+SScA8czSL8V1k7dCi3FBoNYWIt5pXjbD4y7h08V5FN8wbIPD8d1Tic67fZc PhVc9t5gs48TmMoEDKeENJyWZIKsXhEhKA2GwYhU/RkS+5lUQxu4x0YD8mt3sNPy5Aqf 0zcdd6e4yXz0NOcxM8MeSISWSsE2AX/s9qatOBRniYuAFGC9EVcp2+kBUYORy0B7LBDs 4VRw== X-Gm-Message-State: AOAM532xLMN+UzVwYo0tiw+JLN8MmBUlGtgzCL5A3HvCHMPmKi/IaLN8 AP6Z/FZekmINvgCoG5ISUxihePqA X-Google-Smtp-Source: ABdhPJwvTWpLJiAkTnGKeIatla52C8zVu7xm1vf6LuF2UtB82FuP0WQrarnygb8FqtuAHqgT6P6XnA== X-Received: by 2002:a92:dc85:: with SMTP id c5mr5489223iln.270.1589581619685; Fri, 15 May 2020 15:26:59 -0700 (PDT) Received: from ?IPv6:2601:681:5500:dde0:f120:2f2:891d:e9fe? ([2601:681:5500:dde0:f120:2f2:891d:e9fe]) by smtp.gmail.com with ESMTPSA id b1sm1152260ioe.46.2020.05.15.15.26.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 May 2020 15:26:59 -0700 (PDT) To: pgsql-general@lists.postgresql.org From: Rob Sargent Subject: schema agnostic functions in language sql Message-ID: Date: Fri, 15 May 2020 16:26:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------ABCF23F99D39DA4FA25B5287" Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------ABCF23F99D39DA4FA25B5287 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit I'm using postgres 12.2, with multiple identical schema per database (each with a matching role).  I can write public plpgsql functions without using a schema identifier and let the runtime search_path find the correct schema-dependent table.  The same does not appear to be true for plain sql functions.  The 'parser'? does not recognize the tables (sans schema qualifier): ERROR:  relation "" does not exist. I would rather not have to duplicate these across multiple schema - I'll use plpgsql instead unless I've overlooked some other avenue. I've found that I can create the function, in public, if I set the search_path containing one schema (of course) and then successfully access the function after resetting the search path to use a second schema.  My "build the world" scripting has so far avoided needing to know/use any specific role.  Another pipe dream vaporized? Thanks, rjs --------------ABCF23F99D39DA4FA25B5287 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit I'm using postgres 12.2, with multiple identical schema per database (each with a matching role).  I can write public plpgsql functions without using a schema identifier and let the runtime search_path find the correct schema-dependent table.  The same does not appear to be true for plain sql functions.  The 'parser'? does not recognize the tables (sans schema qualifier):
ERROR:  relation "<tablename>" does not exist. 
I would rather not have to duplicate these across multiple schema - I'll use plpgsql instead unless I've overlooked some other avenue.

I've found that I can create the function, in public, if I set the search_path containing one schema (of course) and then successfully access the function after resetting the search path to use a second schema.  My "build the world" scripting has so far avoided needing to know/use any specific role.  Another pipe dream vaporized?

Thanks,
rjs


--------------ABCF23F99D39DA4FA25B5287--