Обсуждение: BUG #5072: User trying to drop an internally dependent object crashes server

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

BUG #5072: User trying to drop an internally dependent object crashes server

От
"Amit Khandekar"
Дата:
The following bug has been logged online:

Bug reference:      5072
Logged by:          Amit Khandekar
Email address:      amit.khandekar@enterprisedb.com
PostgreSQL version: 8.5devel
Operating system:   All
Description:        User trying to drop an internally dependent object
crashes server
Details:

If a DROP command is issued for an object that is actually a part of
internal implementation of another object, then the command crashes the
server.

For e.g. a rule with name "_RETURN" is internally created when a user
creates
a view. This object dependency is stored in pg_depend with deptype
DEPENDENCY_INTERNAL.

postgres=# CREATE VIEW fooview AS SELECT 'foo'::text;
CREATE VIEW
postgres=# DROP RULE "_RETURN" ON fooview;
server closed the connection unexpectedly
    This probably means the server terminated abno
    before or while processing the request.

The function object_address_present() in src/backend/catalog/dependency.c
assumes that the address list is always a non-NULL argument even though the
number of addresses can be zero. Whereas in the above scenario, the address
list is NULL. A simple address check such as below will fix this issue :

bool
object_address_present(const ObjectAddress *object,
                       const ObjectAddresses *addrs)
{
+   if (!addrs)
+       return false;
........
........
}

Re: BUG #5072: User trying to drop an internally dependent object crashes server

От
Tom Lane
Дата:
"Amit Khandekar" <amit.khandekar@enterprisedb.com> writes:
> If a DROP command is issued for an object that is actually a part of
> internal implementation of another object, then the command crashes the
> server.

How embarrassing --- evidently that specific code path never got tested.
Fixed, thanks for the report!

            regards, tom lane