From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Mark Zellers <markz@adaptiveinsights.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Migrating an application with Oracle temporary tables
Date: Fri, 03 May 2019 08:19:21 +0200
Message-ID: <556ca13c06e96fe165ee03d297f42bb405807bed.camel@cybertec.at> (raw)
In-Reply-To: <BYAPR06MB4536CDB7B2EB82AF102ECB8AD5340@BYAPR06MB4536.namprd06.prod.outlook.com>
References: <BYAPR06MB45364F6A71EB19D4F4BEEA9FD53B0@BYAPR06MB4536.namprd06.prod.outlook.com>
<9abb9aaf36ac04389f67b8d8e0ea6840f0f69f1e.camel@cybertec.at>
<BYAPR06MB4536CDB7B2EB82AF102ECB8AD5340@BYAPR06MB4536.namprd06.prod.outlook.com>
On Thu, 2019-05-02 at 16:55 +0000, Mark Zellers wrote:
> I thought I needed the prototype table to be able to define functions and procedures that refer to the temporary table but do not create it.
>
> Perhaps my assumption that I need the table to exist (whether as a temporary table or as a permanent table) in
> order to define the function/procedure is incorrect. I'll take a look at that.
You don't need the table to exist at function definition time.
The following works just fine, even if the table does not exist:
CREATE FUNCTION f() RETURNS void LANGUAGE plpgsql AS $$BEGIN PERFORM * FROM notexists; END;$$;
This is because functions are not parsed when they are defined.
> I did find a scenario where this approach does run into trouble. That is, if the function/procedure is executed
> against the permanent table and then you go to run it against a temporary table. In that case, I do get the
> wrong answer, and I haven't yet figured out how to reset that without dropping the procedure and re-defining it.
> For my purposes, that is "good enough" -- I can promise not to run such procedures against the temporary table.
Yes, that would cause a problem.
The SQL statement "DISCARD PLANS" should fix the problem.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.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: laurenz.albe@cybertec.at, markz@adaptiveinsights.com
Subject: Re: Migrating an application with Oracle temporary tables
In-Reply-To: <556ca13c06e96fe165ee03d297f42bb405807bed.camel@cybertec.at>
References: <BYAPR06MB45364F6A71EB19D4F4BEEA9FD53B0@BYAPR06MB4536.namprd06.prod.outlook.com> <9abb9aaf36ac04389f67b8d8e0ea6840f0f69f1e.camel@cybertec.at> <BYAPR06MB4536CDB7B2EB82AF102ECB8AD5340@BYAPR06MB4536.namprd06.prod.outlook.com> <556ca13c06e96fe165ee03d297f42bb405807bed.camel@cybertec.at>
* 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