Skip site navigation (1) Skip section navigation (2)

pgsql: Add checks to TRUNCATE, CLUSTER, and REINDEX to prevent

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add checks to TRUNCATE, CLUSTER, and REINDEX to prevent
Date: 2008-01-30 19:46:48
Message-ID: 20080130194648.ACA8A754108@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Add checks to TRUNCATE, CLUSTER, and REINDEX to prevent performing these
operations when the current transaction has any open references to the
target relation or index (implying it has an active query using the relation).
The need for this was previously recognized in connection with ALTER TABLE,
but anything that summarily eliminates tuples or moves them around would
confuse an active scan.

While this patch does not in itself fix bug #3883 (the deadlock would happen
before the new check fires), it will discourage people from attempting the
sequence of operations that creates a deadlock risk, so it's at least a
partial response to that problem.

In passing, add a previously-missing check to REINDEX to prevent trying to
reindex another backend's temp table.  This isn't a security problem since
only a superuser would get past the schema permission checks, but if we are
testing for this in other utility commands then surely REINDEX should too.

Modified Files:
--------------
    pgsql/src/backend/catalog:
        index.c (r1.291 -> r1.292)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/index.c?r1=1.291&r2=1.292)
    pgsql/src/backend/commands:
        cluster.c (r1.168 -> r1.169)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/cluster.c?r1=1.168&r2=1.169)
        tablecmds.c (r1.240 -> r1.241)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tablecmds.c?r1=1.240&r2=1.241)
    pgsql/src/include/commands:
        tablecmds.h (r1.36 -> r1.37)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/tablecmds.h?r1=1.36&r2=1.37)

Responses

pgsql-committers by date

Next:From: User FxjrDate: 2008-01-30 20:37:19
Subject: npgsql - Npgsql2: Added support for parameters explicit typing on plain
Previous:From: Alvaro HerreraDate: 2008-01-30 18:51:23
Subject: press - pr: First cut of spanish version of features file.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group