From: Rob Sargent <robjsargent@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: specifying table in function args
Date: Thu, 28 Feb 2019 13:56:40 -0700
Message-ID: <c043e1fe-d40a-4033-0f24-23462e7219f5@gmail.com> (raw)
In-Reply-To: <CAKFQuwZJ7en+NSd3n4qVjpmrzrPUHoOda-j5o5vLuevYDJL7AQ@mail.gmail.com>
References: <be24ead6-fee6-8bbb-3407-23a5538588ba@gmail.com>
<CAKFQuwZJ7en+NSd3n4qVjpmrzrPUHoOda-j5o5vLuevYDJL7AQ@mail.gmail.com>
On 2/28/19 12:27 PM, David G. Johnston wrote:
> On Thursday, February 28, 2019, Rob Sargent <robjsargent@gmail.com
> <mailto: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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, david.g.johnston@gmail.com
Subject: Re: specifying table in function args
In-Reply-To: <c043e1fe-d40a-4033-0f24-23462e7219f5@gmail.com>
References: <be24ead6-fee6-8bbb-3407-23a5538588ba@gmail.com> <CAKFQuwZJ7en+NSd3n4qVjpmrzrPUHoOda-j5o5vLuevYDJL7AQ@mail.gmail.com> <c043e1fe-d40a-4033-0f24-23462e7219f5@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox