pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedtemporary tables, plpgsql and yes i bet this has been asked before
12+ messages / 4 participants
[nested] [flat]
* temporary tables, plpgsql and yes i bet this has been asked before
@ 2002-02-04 10:32 Murray Prior Hobbs <murray@efone.com>
0 siblings, 2 replies; 12+ messages in thread
From: Murray Prior Hobbs @ 2002-02-04 10:32 UTC (permalink / raw)
To: pgsql-sql
in a plpgsql function
create temporary table X
....
drop table X
then in another function
loop
call the other function
end loop
i get the problem that the second time the table is created (ie in the
second call) it is not visible
now yes i could declare the table in the calling funtion but then the
original function is less useful to me
any clues?
murray
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 14:13 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Murray Prior Hobbs <murray@efone.com>
1 sibling, 1 reply; 12+ messages in thread
From: Bruce Momjian @ 2002-02-04 14:13 UTC (permalink / raw)
To: Murray Prior Hobbs <murray@efone.com>; +Cc: pgsql-sql
Murray Prior Hobbs wrote:
>
> in a plpgsql function
>
> create temporary table X
>
> ....
>
>
> drop table X
>
>
> then in another function
>
> loop
>
> call the other function
>
> end loop
>
>
> i get the problem that the second time the table is created (ie in the
> second call) it is not visible
>
> now yes i could declare the table in the calling funtion but then the
> original function is less useful to me
Interesting. Can you recreate the problem in psql without the functions
and show an example? I am confused how this could be failing.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked before
@ 2002-02-04 15:47 Tom Lane <tgl@sss.pgh.pa.us>
parent: Murray Prior Hobbs <murray@efone.com>
1 sibling, 0 replies; 12+ messages in thread
From: Tom Lane @ 2002-02-04 15:47 UTC (permalink / raw)
To: Murray Prior Hobbs <murray@efone.com>; +Cc: pgsql-sql
Murray Prior Hobbs <murray@efone.com> writes:
> in a plpgsql function
> create temporary table X
> ....
> drop table X
You need to use EXECUTE for all accesses to the temp table, in order
to defeat plpgsql's attempts to cache plans for those queries.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:06 Jan Wieck <janwieck@yahoo.com>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 12+ messages in thread
From: Jan Wieck @ 2002-02-04 20:06 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Bruce Momjian wrote:
> Murray Prior Hobbs wrote:
> >
> > in a plpgsql function
> >
> > create temporary table X
> >
> > ....
> >
> >
> > drop table X
> >
> >
> > then in another function
> >
> > loop
> >
> > call the other function
> >
> > end loop
> >
> >
> > i get the problem that the second time the table is created (ie in the
> > second call) it is not visible
> >
> > now yes i could declare the table in the calling funtion but then the
> > original function is less useful to me
>
> Interesting. Can you recreate the problem in psql without the functions
> and show an example? I am confused how this could be failing.
I bet he's using the temp table without EXECUTE. That
would've failed even without the other "calling" function
around it, as soon as he uses it more than once per session.
SPI still needs to learn how to determine if a query uses
temp tables somewhere in order to silently re-prepare queries
when required. And I am absolutely sure this is not an issue
we should address in PL/pgSQL. It has to be solved on the SPI
level.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:15 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Jan Wieck <janwieck@yahoo.com>
1 sibling, 0 replies; 12+ messages in thread
From: Bruce Momjian @ 2002-02-04 20:15 UTC (permalink / raw)
To: Jan Wieck <janwieck@yahoo.com>; +Cc: Murray Prior Hobbs <murray@efone.com>; pgsql-sql
> I bet he's using the temp table without EXECUTE. That
> would've failed even without the other "calling" function
> around it, as soon as he uses it more than once per session.
>
> SPI still needs to learn how to determine if a query uses
> temp tables somewhere in order to silently re-prepare queries
> when required. And I am absolutely sure this is not an issue
> we should address in PL/pgSQL. It has to be solved on the SPI
> level.
Will this still be an issue with schemas? I am thinking no.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:25 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jan Wieck <janwieck@yahoo.com>
1 sibling, 2 replies; 12+ messages in thread
From: Tom Lane @ 2002-02-04 20:25 UTC (permalink / raw)
To: Jan Wieck <janwieck@yahoo.com>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Jan Wieck <janwieck@yahoo.com> writes:
> SPI still needs to learn how to determine if a query uses
> temp tables somewhere in order to silently re-prepare queries
> when required. And I am absolutely sure this is not an issue
> we should address in PL/pgSQL. It has to be solved on the SPI
> level.
Temp tables are the wrong way to think about it. *Any* invalidation
of schema data referred to in a query plan should cause replanning.
We have a TODO item covering this already, don't we?
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:27 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 12+ messages in thread
From: Bruce Momjian @ 2002-02-04 20:27 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Tom Lane wrote:
> Jan Wieck <janwieck@yahoo.com> writes:
> > SPI still needs to learn how to determine if a query uses
> > temp tables somewhere in order to silently re-prepare queries
> > when required. And I am absolutely sure this is not an issue
> > we should address in PL/pgSQL. It has to be solved on the SPI
> > level.
>
> Temp tables are the wrong way to think about it. *Any* invalidation
> of schema data referred to in a query plan should cause replanning.
> We have a TODO item covering this already, don't we?
If we do, I don't see it. Care to give me one? I am not sure how to
word it.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:39 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2002-02-04 20:39 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> Temp tables are the wrong way to think about it. *Any* invalidation
>> of schema data referred to in a query plan should cause replanning.
>> We have a TODO item covering this already, don't we?
> If we do, I don't see it. Care to give me one?
Hmm, I don't see one either. Odd, we've sure discussed it often enough.
How about
* Flush cached query plans when their underlying catalog data changes
Probably belongs under "DEPENDENCY CHECKING".
BTW, I was slightly startled to read this under URGENT:
* Allow row re-use without vacuum (Tom)
I don't consider this urgent or even likely ever to happen, and
I certainly have not taken responsibility to do it.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:43 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: Bruce Momjian @ 2002-02-04 20:43 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Temp tables are the wrong way to think about it. *Any* invalidation
> >> of schema data referred to in a query plan should cause replanning.
> >> We have a TODO item covering this already, don't we?
>
> > If we do, I don't see it. Care to give me one?
>
> Hmm, I don't see one either. Odd, we've sure discussed it often enough.
> How about
>
> * Flush cached query plans when their underlying catalog data changes
Yes, under DEPENDENCIE CHECKING. Done.
> Probably belongs under "DEPENDENCY CHECKING".
>
>
> BTW, I was slightly startled to read this under URGENT:
>
> * Allow row re-use without vacuum (Tom)
>
> I don't consider this urgent or even likely ever to happen, and
> I certainly have not taken responsibility to do it.
Well, a name doesn't mean someone claimed it but rather the _expert_ on
the item. I added this item assuming it was going to be accomplished
with some type of auto-vacuum. I will clearify it to mention
auto-vacuum, if that is OK.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:47 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2002-02-04 20:47 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> * Allow row re-use without vacuum (Tom)
> Well, a name doesn't mean someone claimed it but rather the _expert_ on
> the item. I added this item assuming it was going to be accomplished
> with some type of auto-vacuum. I will clearify it to mention
> auto-vacuum, if that is OK.
"Clarify"? How about "replace completely"?
* Provide automatic scheduling of background vacuum
Still not sure that I'd classify it as URGENT.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 20:50 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 12+ messages in thread
From: Bruce Momjian @ 2002-02-04 20:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >> * Allow row re-use without vacuum (Tom)
>
> > Well, a name doesn't mean someone claimed it but rather the _expert_ on
> > the item. I added this item assuming it was going to be accomplished
> > with some type of auto-vacuum. I will clearify it to mention
> > auto-vacuum, if that is OK.
>
> "Clarify"? How about "replace completely"?
>
> * Provide automatic scheduling of background vacuum
>
> Still not sure that I'd classify it as URGENT.
OK, moved to VACUUM section with your new wording. It used to be urgent
before 7.2. :-)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: temporary tables, plpgsql and yes i bet this has been asked
@ 2002-02-04 21:13 Jan Wieck <janwieck@yahoo.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 12+ messages in thread
From: Jan Wieck @ 2002-02-04 21:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jan Wieck <janwieck@yahoo.com>; Bruce Momjian <pgman@candle.pha.pa.us>; Murray Prior Hobbs <murray@efone.com>; pgsql-sql
Tom Lane wrote:
> Jan Wieck <janwieck@yahoo.com> writes:
> > SPI still needs to learn how to determine if a query uses
> > temp tables somewhere in order to silently re-prepare queries
> > when required. And I am absolutely sure this is not an issue
> > we should address in PL/pgSQL. It has to be solved on the SPI
> > level.
>
> Temp tables are the wrong way to think about it. *Any* invalidation
> of schema data referred to in a query plan should cause replanning.
> We have a TODO item covering this already, don't we?
Of course, still. Nothing changed on that since we discussed
it the last time ;-P
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2002-02-04 21:13 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-04 10:32 temporary tables, plpgsql and yes i bet this has been asked before Murray Prior Hobbs <murray@efone.com>
2002-02-04 14:13 ` Re: temporary tables, plpgsql and yes i bet this has been asked Bruce Momjian <pgman@candle.pha.pa.us>
2002-02-04 20:06 ` Re: temporary tables, plpgsql and yes i bet this has been asked Jan Wieck <janwieck@yahoo.com>
2002-02-04 20:15 ` Re: temporary tables, plpgsql and yes i bet this has been asked Bruce Momjian <pgman@candle.pha.pa.us>
2002-02-04 20:25 ` Re: temporary tables, plpgsql and yes i bet this has been asked Tom Lane <tgl@sss.pgh.pa.us>
2002-02-04 20:27 ` Re: temporary tables, plpgsql and yes i bet this has been asked Bruce Momjian <pgman@candle.pha.pa.us>
2002-02-04 20:39 ` Re: temporary tables, plpgsql and yes i bet this has been asked Tom Lane <tgl@sss.pgh.pa.us>
2002-02-04 20:43 ` Re: temporary tables, plpgsql and yes i bet this has been asked Bruce Momjian <pgman@candle.pha.pa.us>
2002-02-04 20:47 ` Re: temporary tables, plpgsql and yes i bet this has been asked Tom Lane <tgl@sss.pgh.pa.us>
2002-02-04 20:50 ` Re: temporary tables, plpgsql and yes i bet this has been asked Bruce Momjian <pgman@candle.pha.pa.us>
2002-02-04 21:13 ` Re: temporary tables, plpgsql and yes i bet this has been asked Jan Wieck <janwieck@yahoo.com>
2002-02-04 15:47 ` Tom Lane <tgl@sss.pgh.pa.us>
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