Re: Again about temporary table - Mailing list pgsql-general

From Richard Huxton
Subject Re: Again about temporary table
Date
Msg-id 200308272101.11524.dev@archonet.com
Whole thread Raw
In response to Again about temporary table  ("Juris Krumins" <juriskr@komin.lv>)
List pgsql-general
On Wednesday 27 August 2003 08:39, Juris Krumins wrote:
> Couple a weeks ago (19.08.03 Subject: Temporaty tables) I've posted message
> with question about errors I'm getting while using create temporaty table
> command.
> So I'm start digging in src code as Tom Lane did and found about 4 places
> where such kind pf errors could happend

> So any ideas why I'm getting errors like:
> Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: cache lookup of
> relation 149064743 failed . in table.php on line 169
> The query on line 169 is :
>
> CREATE TEMP TABLE tmp_table1 AS SELECT advert.time_create, (SELECT
> employer.fullname FROM employer WHERE advert.empid=employer.id) as
> emp_name, (CASE WHEN advert.status1 = 'A' THEN advert.postname1 ELSE
> advert.postname2 END) as postname, advert.enddate, advert.id as id FROM
> good_adv as advert
>
> And right ahead
>
> Warning: pg_exec()[function.pg-exec]:Query failed: ERROR: Relation
> "tmp_table1" does not exist.
>
> On query like :
>
> SELECT * FROM tmp_table1

I can't find your previous post at the moment, but I sort of remember it.
It looks like the root of the problem is the failure to create the temp table
on line 169 - that would explain why it's not visible later on.

A few things it might be worth trying with that query:
1. select oid,* from pg_class where oid=149064743;
   This should show you which relation it's failing to find.
   If the number keeps failing, it's presumably failing to find the temp table
   (which is odd)
2. Create the temp table then INSERT INTO tmp_table1 SELECT...
3. Does it work if you use a permanent instead of temp table?
4. Does it work as a straightforward SELECT?
5. What happens if you don't alias good_adv?

I'm shooting in the dark here by the way - hoping one of these will point to
what's happening.

HTH
--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: elein
Date:
Subject: Clarifying File System Syncs
Next
From: Tom Lane
Date:
Subject: Re: Replication Ideas