From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Gauthier <davegauthierpg@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: How can I recreate a view in a new schema such that the view def references tables in the new schema ?
Date: Thu, 26 Mar 2020 12:49:48 -0700
Message-ID: <03a6e774-abe2-541f-3663-64fafcfb8089@aklaver.com> (raw)
In-Reply-To: <CAMBRECAZs3q12FF45Yegh8N+2ARys7wmM0ZU-P70zXqjy-Xs=A@mail.gmail.com>
References: <CAMBRECB_0+Rch1CsQ=NyBzbgm7_6cOrmULQSk-80=5hRM+BeCQ@mail.gmail.com>
<6abf5665-d761-c380-07ef-dce28c8fce08@aklaver.com>
<CAMBRECCs-3Leb0GgZJe00VyyVeSqyxu6p_mLBSPo3bO0rNve7w@mail.gmail.com>
<bd63c235-0d24-c725-5e3b-a48445f11ab0@aklaver.com>
<CAMBRECAZs3q12FF45Yegh8N+2ARys7wmM0ZU-P70zXqjy-Xs=A@mail.gmail.com>
On 3/26/20 11:38 AM, David Gauthier wrote:
> sqf-> SELECT sr.project,
> sqf-> sr.sqf_id,
> sqf-> wa.wa_path,
> sqf-> sr.cbwa_type,
> sqf-> sr.status,
> sqf-> sr.nightly_rg_cl,
> sqf-> ( SELECT max(fse.end_datetime) AS max
> sqf(> FROM public.flow_step_events fse
> sqf(> WHERE fse.sqf_id = sr.sqf_id) AS last_sqf_step_end,
> sqf-> ( SELECT DISTINCT f.perl_sub_name
> sqf(> FROM public.flows f,
> sqf(> public.flow_step_events fse
> sqf(> WHERE f.flow_type = fse.flow_type AND fse.sqf_id =
> sr.sqf_id AND f.step_number = (( SELECT max(fse2.step_number) AS max
> sqf(> FROM public.flow_step_events fse2
> sqf(> WHERE fse2.sqf_id = sr.sqf_id))) AS last_step_run
> sqf-> FROM public.sqf_runs sr,
> sqf-> public.workareas wa
> sqf-> WHERE wa.current_user_sqf_id = sr.sqf_id
> sqf-> ORDER BY sr.project, wa.wa_path, (( SELECT max(fse.end_datetime)
> AS max
> sqf(> FROM public.flow_step_events fse
> sqf(> WHERE fse.sqf_id = sr.sqf_id));
> CREATE VIEW
>
> sqf=> \d+ current_workarea_users;
> View "public.current_workarea_users"
> Column | Type | Modifiers | Storage |
> Description
> -------------------+--------------------------+-----------+----------+-------------
> project | text | | extended |
> sqf_id | text | | extended |
> wa_path | text | | extended |
> cbwa_type | text | | extended |
> status | text | | extended |
> nightly_rg_cl | integer | | plain |
> last_sqf_step_end | timestamp with time zone | | plain |
> last_step_run | text | | extended |
> View definition:
> SELECT sr.project,
> sr.sqf_id,
> wa.wa_path,
> sr.cbwa_type,
> sr.status,
> sr.nightly_rg_cl,
> ( SELECT max(fse.end_datetime) AS max
> FROM flow_step_events fse
> WHERE fse.sqf_id = sr.sqf_id) AS last_sqf_step_end,
> ( SELECT DISTINCT f.perl_sub_name
> FROM flows f,
> flow_step_events fse
> WHERE f.flow_type = fse.flow_type AND fse.sqf_id = sr.sqf_id
> AND f.step_number = (( SELECT max(fse2.step_number) AS max
> FROM flow_step_events fse2
> WHERE fse2.sqf_id = sr.sqf_id))) AS last_step_run
> FROM sqf_runs sr,
> workareas wa
> WHERE wa.current_user_sqf_id = sr.sqf_id
> ORDER BY sr.project, wa.wa_path, (( SELECT max(fse.end_datetime) AS max
> FROM flow_step_events fse
> WHERE fse.sqf_id = sr.sqf_id));
>
> sqf=>
>
>
> You can see the "public." refs in the create view, but not echoed in the
> stored view def.
>
See this post:
https://www.postgresql.org/message-id/31367.1572815723%40sss.pgh.pa.us
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, davegauthierpg@gmail.com
Subject: Re: How can I recreate a view in a new schema such that the view def references tables in the new schema ?
In-Reply-To: <03a6e774-abe2-541f-3663-64fafcfb8089@aklaver.com>
References: <CAMBRECB_0+Rch1CsQ=NyBzbgm7_6cOrmULQSk-80=5hRM+BeCQ@mail.gmail.com> <6abf5665-d761-c380-07ef-dce28c8fce08@aklaver.com> <CAMBRECCs-3Leb0GgZJe00VyyVeSqyxu6p_mLBSPo3bO0rNve7w@mail.gmail.com> <bd63c235-0d24-c725-5e3b-a48445f11ab0@aklaver.com> <CAMBRECAZs3q12FF45Yegh8N+2ARys7wmM0ZU-P70zXqjy-Xs=A@mail.gmail.com> <03a6e774-abe2-541f-3663-64fafcfb8089@aklaver.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