Segmentation fault in pg_dumpall from master down to 9.1 and other bug introduced by RLS

Поиск
Список
Период
Сортировка
От Gilles Darold
Тема Segmentation fault in pg_dumpall from master down to 9.1 and other bug introduced by RLS
Дата
Msg-id 5464DA46.3000209@dalibo.com
обсуждение исходный текст
Ответы Re: Segmentation fault in pg_dumpall from master down to 9.1 and other bug introduced by RLS  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Segmentation fault in pg_dumpall from master down to 9.1 and other bug introduced by RLS  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

There's a segfault when trying to dump global object from a running
7.4.27 with a pg_dumpall of version 9.3.5 but also 9.2.9.

$ pg_dumpall  -g -h localhost -p 5474

    column number -1 is out of range 0..12
    Segmentation fault (core dumped)

The problem comes from the first columns of the query in function
dumpRoles(PGconn *conn) that has no alias name. Fixing it with

    SELECT 0 **as oid**, ...;

Fix the issue. This bug affect all versions of PostgreSQL from master
down to 9.1, I mean 9.1 is working.

In the same query there is an other bug introduced by commit 491c029
that add Row-Level Security Policies.  Current master code has a broken
pg_dumpall when trying to dump from a backend lower than 8.1. Here is
the error:

    ERROR:  each UNION query must have the same number of columns

The query sent to the database is the following:

    SELECT 0, usename as rolname, usesuper as rolsuper, true as
rolinherit, usesuper as rolcreaterole, usecreatedb as rolcreatedb, true
as rolcanlogin, -1 as rolconnlimit, passwd as rolpassword, valuntil as
rolvaliduntil, false as rolreplication, null as rolcomment, usename =
current_user AS is_current_user FROM pg_shadow UNION ALL SELECT 0,
groname as rolname, false as rolsuper, true as rolinherit, false as
rolcreaterole, false as rolcreatedb, false as rolcanlogin, -1 as
rolconnlimit, null::text as rolpassword, null::abstime as rolvaliduntil,
false as rolreplication, false as rolbypassrls, null as rolcomment,
false FROM pg_group WHERE NOT EXISTS (SELECT 1 FROM pg_shadow  WHERE
usename = groname) ORDER BY 2;

The column rolbypassrls is missing in the first UNION query. As this is
the same query as previous issue the first column of the query need the
same alias: oid.

I've attached a patch against master that fix the two issues but for
older branch, only alias to the first column of the query might be
applied. Let me know if it need other work.

Best regards,

--
Gilles Darold
http://dalibo.com - http://dalibo.org


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: controlling psql's use of the pager a bit more
Следующее
От: Robert Haas
Дата:
Сообщение: Re: REINDEX CONCURRENTLY 2.0