Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzSjm-00033q-PI for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 20:57:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzSjl-0004PV-9V for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 20:57:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzSjk-0004JR-T8 for pgsql-general@lists.postgresql.org; Thu, 28 Feb 2019 20:57:01 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzSjV-00068a-4z for pgsql-general@postgresql.org; Thu, 28 Feb 2019 20:57:00 +0000 Received: by mail-pf1-x441.google.com with SMTP id i19so10310179pfd.0 for ; Thu, 28 Feb 2019 12:56:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=UwbW441+p/SD1i8HN/YvLcpppJkyPWOYzY8E5ZJGgW4=; b=K98kXXbYvU7RBBYJqFHxZ/hAPIClWrZ6n8tULf7ibCy9NDvx0l1ZhZZSE3YFtvC/DG 6IewUUNFMHkDb1vqqz5HGO/Oeke2xN2YaGX7PJAZF/uxsGzdHSviewoQ4k2ex1FwIsOJ n6QnmUspjxb5QAjHIVmKB7AG8uOCiYPoNcMUgIMp2ZqMa4bZ+/8EykkjKN1UbSBZplQ0 Ek7YQ3mOAof/siAus+U3gF7Fn98xxLos9BAYG+DyXQf5pWcdmyGCa8WjdmO0PMEPrne4 PkyLqXshLC/9xyow4ZqM5vzADjUZ/34Uoq31SkDFwA5BKlZ5rpfKrk63dUAzmBQaZm5d CpKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=UwbW441+p/SD1i8HN/YvLcpppJkyPWOYzY8E5ZJGgW4=; b=UMm6Cq1bPdWjEUIbNcVCR0lDOA2WLcWTthfVzAKrL4P+bn98ITpi3X7xlA5LaUwxou FA8chBN+LVOtU4m0r62j/rcv3KWtt6jSpQnJaWHEvQjkA59OPEKaq2u22M2ZkWSFDNDC AQ0/bBu7G4ab1novyDdrJlTe7gfK7xOQ1tiTe68lVgbAyq1QM5lrytvVfWXdP0U77gov sEUP+Y5OkOl0dYL9UdXa0uyMf9BiaMo4bNT4YtJb9hI9aeJnmkLV6kX/RmJ2E5SV4sqa VzuQZN5jTvVka7Bmi1sTXssXn1E4C0RXQxAP+6/X2KatcrVTKN6he+8j3yvDQxK+6sEK GBvA== X-Gm-Message-State: APjAAAWyX2q/ERlg5q1cjqUYkmIuuRVc7w0jZs+/GH0VSIepYJIqj2Ey KR8MpMiNxSIOWosInDjTjtjz4xxC X-Google-Smtp-Source: APXvYqyZ+hyzWoFtpFD6SghjB2Ai+st9Tw+UoyeZtWPLS5ZoteMbUqF73kr4tlm+aX93QQ8TK+sa1Q== X-Received: by 2002:a65:4b83:: with SMTP id t3mr1061189pgq.417.1551387401813; Thu, 28 Feb 2019 12:56:41 -0800 (PST) Received: from [10.104.134.14] ([155.100.47.6]) by smtp.gmail.com with ESMTPSA id l10sm37886025pfc.90.2019.02.28.12.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 12:56:41 -0800 (PST) Subject: Re: specifying table in function args To: "David G. Johnston" Cc: "pgsql-general@postgresql.org" References: From: Rob Sargent Message-ID: Date: Thu, 28 Feb 2019 13:56:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------9527508766CD2DD460C272D8" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------9527508766CD2DD460C272D8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/28/19 12:27 PM, David G. Johnston wrote: > On Thursday, February 28, 2019, Rob Sargent > wrote: > > but this fails in one of two ways:  either the create function > call fails lacking a definition of "segment" or, if I create a > public.segment table, create the function, set search_path to > include a project's schema then drop public.segment fails because > pvr() relies on it. > > > CREATE TYPE? > > David J. Not yet. Using just a shell type I from create or replace function public.pvr(seg segment, plus float default 1.0) I get psql:functions/pvr.sql:19: NOTICE:  argument type segment is only a shell psql:functions/pvr.sql:19: ERROR:  PL/pgSQL functions cannot accept type segment (same for SQL function) Using a fleshed-out segment type I get  \df public.pvr                                          List of functions  Schema | Name | Result data type |                  Argument data types                  |  Type --------+------+------------------+-------------------------------------------------------+--------  public | pvr  | double precision | seg public.segment, plus double precision DEFAULT 1.0 | normal (1 row) and the schema qualifier on the argument is a killer camp=# set search_path = base,mm,public; SET Time: 0.810 ms camp=# select pvr(s.*) from mm.segment s limit 5; ERROR:  function pvr(segment) does not exist LINE 1: select pvr(s.*) from mm.segment s limit 5;                ^ HINT:  No function matches the given name and argument types. You might need to add explicit type casts. --------------9527508766CD2DD460C272D8 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


On 2/28/19 12:27 PM, David G. Johnston wrote:
On Thursday, February 28, 2019, Rob Sargent <robjsargent@gmail.com> wrote:

but this fails in one of two ways:  either the create function call fails lacking a definition of "segment" or, if I create a public.segment table, create the function, set search_path to include a project's schema then drop public.segment fails because pvr() relies on it.


CREATE TYPE?

David J.

Not yet.

Using just a shell type I from create or replace function public.pvr(seg segment, plus float default 1.0) I get

psql:functions/pvr.sql:19: NOTICE:  argument type segment is only a shell
psql:functions/pvr.sql:19: ERROR:  PL/pgSQL functions cannot accept type segment (same for SQL function)

Using a fleshed-out segment type I get

 \df public.pvr
                                         List of functions
 Schema | Name | Result data type |                  Argument data types                  |  Type 
--------+------+------------------+-------------------------------------------------------+--------
 public | pvr  | double precision | seg public.segment, plus double precision DEFAULT 1.0 | normal
(1 row)

and the schema qualifier on the argument is a killer

camp=# set search_path = base,mm,public;
SET
Time: 0.810 ms
camp=# select pvr(s.*) from mm.segment s limit 5;
ERROR:  function pvr(segment) does not exist
LINE 1: select pvr(s.*) from mm.segment s limit 5;
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.



--------------9527508766CD2DD460C272D8--