Re: [SQL] Possible Bug regarding temp tables (sql or psql?)

2002-07-03 Thread Mark Frazer

Forgot to mention that adding
DROP TABLE v_idx ;
before the END WORK will fix things.  However, I was under the impression that
temporary tables would go away after a transaction in which they were created
was committed.




---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org





[SQL] Possible Bug regarding temp tables (sql or psql?)

2002-07-03 Thread Mark Frazer

When using the attached script in psql, the temp variables disappear as 
far as \distv shows, but running the script a second time fails.

To reproduce, save the following script as bug.sql, then start psql on an
test database.
\i bug.sql
\distv
-- no relations should be shown
\i bug.sql 
-- this will fail.

However, if you run psql again, you can
\i bug.sql
successfully.  It will only fail if run twice in the same script.

cheers
-mark

-- 
Hardy Boys: too easy. Nancy Drew: too hard! - Fry


CREATE TABLE foo (
foo_idx SERIAL PRIMARY KEY,
foo INTEGER ) ;
CREATE TABLE bar (
bar_idx SERIAL PRIMARY KEY,
foo_idx INTEGER REFERENCES foo,
bar INTEGER ) ;
INSERT INTO foo ( foo ) VALUES ( 111 ) ;
INSERT INTO foo ( foo ) VALUES ( 222 ) ;
INSERT INTO foo ( foo ) VALUES ( 333 ) ;

BEGIN WORK ;
SELECT foo_idx INTO TEMP v_idx FROM foo WHERE foo.foo = 222 ;
INSERT INTO bar ( foo_idx, bar ) VALUES ( v_idx.foo_idx, 888 ) ;
END WORK ;

DROP TABLE foo ;
DROP SEQUENCE foo_foo_idx_seq ;
DROP TABLE bar ;
DROP SEQUENCE bar_bar_idx_seq ;



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [SQL] Possible Bug regarding temp tables (sql or psql?)

2002-07-04 Thread Mark Frazer

Any idea why the table can't be seen with \d in psql then?

Christopher Kings-Lynne <[EMAIL PROTECTED]> [02/07/04 00:21]:
> 
> No - they go away at the end of a _connection_.  However, there is now a
> patch floating around on -hackers that would add an ' ON COMMIT DROP;'
> option to CREATE TEMP TABLE.

-- 
In the event of an emergency, my ass can be used as a flotation
device. - Bender



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly





Re: [SQL] Possible Bug regarding temp tables (sql or psql?)

2002-07-05 Thread Mark Frazer



Bruce Momjian <[EMAIL PROTECTED]> [02/07/04 22:10]:
> 
> TODO has:
> 
>   * Allow psql \d to show temporary table structure
> 
> Looks like it works fine now with schemas:
>   
> I will mark the TODO as done.

It doesn't work with select into though:

config=> select 5 into temp v_tmp ;
SELECT
config=> \d v_tmp 
Did not find any relation named "v_tmp".
config=> select 4 into temp v_tmp ;
ERROR:  Relation 'v_tmp' already exists
config=> select version() ;
   version   
-
 PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96


-- 
I heard one time you single-handedly defeated a hoard of rampaging somethings
in the something something system. - Fry



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster