From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Misleading error message in logical decoding for binary plugins |
Date: | 2014-08-29 14:39:57 |
Message-ID: | 20140829143957.GB10109@awork2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2014-08-29 23:31:49 +0900, Michael Paquier wrote:
> On Fri, Aug 29, 2014 at 11:15 PM, Andres Freund <andres(at)2ndquadrant(dot)com>
> wrote:
>
> > 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,
Well, for one a output plugin doesn't call
pg_logical_slot_peek_binary_changes, it's the other way round. And sure:
Every text is also "binary". So that's just fine.
> 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?
Yes. The output plugin declares whether it requires the *output method*
to support binary data. pg_logical_slot_peek_changes *can not* support
binary data because it outputs data as
text. pg_logical_slot_peek_binary_changes *can* support binary data
because it returns bytea (and thus it also can output text, because
that's essentially a subset of binary data).
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-08-29 14:40:02 | Re: Question about coding of free space map |
Previous Message | Tom Lane | 2014-08-29 14:33:45 | Re: LIMIT for UPDATE and DELETE |