Re: Misleading error message in logical decoding for binary plugins
От | Michael Paquier |
---|---|
Тема | Re: Misleading error message in logical decoding for binary plugins |
Дата | |
Msg-id | CAB7nPqQyty1cM_25zJB03cbWE9wOAU23wF7ohK+NVnuFqHAr7A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Misleading error message in logical decoding for binary plugins (Andres Freund <andres@2ndquadrant.com>) |
Ответы |
Re: Misleading error message in logical decoding for
binary plugins
|
Список | pgsql-hackers |
On Fri, Aug 29, 2014 at 11:15 PM, Andres Freund <andres@2ndquadrant.com> wrote:
A textual output plugin can call pg_logical_slot_peek_binary_changes and pg_logical_slot_peek_changes as well,
pg_create_logical_replication_slot
------------------------------------
(foo,0/16C6880)
(1 row)
=# create table aa as select 1;
SELECT 1
=# select substring(encode(data, 'escape'), 1, 20),
substring(data, 1, 20)
FROM pg_logical_slot_peek_binary_changes('foo', NULL, NULL);
substring | substring
----------------------+--------------------------------------------
BEGIN 1000 | \x424547494e2031303030
table public.aa: INS | \x7461626c65207075626c69632e61613a20494e53
COMMIT 1000 | \x434f4d4d49542031303030
(3 rows)
=# select pg_logical_slot_peek_changes('foo', NULL, NULL, 'force-binary', 'true');
ERROR: 0A000: output plugin cannot produce binary output
LOCATION: pg_logical_slot_get_changes_guts, logicalfuncs.c:404
=# select substring(data, 1, 20)
from pg_logical_slot_peek_binary_changes('foo', NULL, NULL, 'force-binary', 'true');
substring
--------------------------------------------
\x424547494e2031303030
\x7461626c65207075626c69632e61613a20494e53
\x434f4d4d49542031303030
(3 rows)
--
Michael
No, a textual output plugin is *NOT* allowed to produce binary
output. That'd violate e.g. pg_logical_slot_peek_changes's return type
because it's only declared to return text.
A textual output plugin can call pg_logical_slot_peek_binary_changes and pg_logical_slot_peek_changes as well,
and a binary output plugin can only call pg_logical_slot_peek_binary_changes, and will error out with pg_logical_slot_peek_changes:
=# select pg_create_logical_replication_slot('foo', 'test_decoding');pg_create_logical_replication_slot
------------------------------------
(foo,0/16C6880)
(1 row)
=# create table aa as select 1;
SELECT 1
=# select substring(encode(data, 'escape'), 1, 20),
substring(data, 1, 20)
FROM pg_logical_slot_peek_binary_changes('foo', NULL, NULL);
substring | substring
----------------------+--------------------------------------------
BEGIN 1000 | \x424547494e2031303030
table public.aa: INS | \x7461626c65207075626c69632e61613a20494e53
COMMIT 1000 | \x434f4d4d49542031303030
(3 rows)
=# select pg_logical_slot_peek_changes('foo', NULL, NULL, 'force-binary', 'true');
ERROR: 0A000: output plugin cannot produce binary output
LOCATION: pg_logical_slot_get_changes_guts, logicalfuncs.c:404
=# select substring(data, 1, 20)
from pg_logical_slot_peek_binary_changes('foo', NULL, NULL, 'force-binary', 'true');
substring
--------------------------------------------
\x424547494e2031303030
\x7461626c65207075626c69632e61613a20494e53
\x434f4d4d49542031303030
(3 rows)
Is that expected?
Michael
В списке pgsql-hackers по дате отправления: