Обсуждение: Temp table woes

Поиск
Список
Период
Сортировка

Temp table woes

От
Heikki Linnakangas
Дата:
This only works as a superuser, but it's wrong nevertheless:

Session 1:

postgres=# CREATE temp table foo (x int);
CREATE TABLE

Session 2:
postgres=# SELECT * FROM pg_temp_1.foo;
  x
---
(0 rows)

postgres=# INSERT INTO pg_temp_1.foo values (1);
INSERT 0 1

The insert in session 2 goes to a buffer in the shared buffer cache,
which causes problems at the next checkpoint:

ERROR:  could not open relation 1663/11502/24576: No such file or directory
CONTEXT:  writing block 0 of relation 1663/11502/24576
WARNING:  could not write block 0 of 1663/11502/24576
DETAIL:  Multiple failures --- write error might be permanent.

Without superuser rights, you'll get a permission denied error trying to
access the table from another session.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Re: Temp table woes

От
Tom Lane
Дата:
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> This only works as a superuser, but it's wrong nevertheless:

> Session 1:
> postgres=# CREATE temp table foo (x int);
> CREATE TABLE

> Session 2:
> postgres=# INSERT INTO pg_temp_1.foo values (1);
> INSERT 0 1

I can't get excited about preventing that --- it looks to me like a
superuser deliberately trying to break the system, and there are plenty
of other ways he can do that.

            regards, tom lane