From ec4f02475269482035d1e3ca4e2e5ab193872eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E6=96=87=E5=81=A5?= Date: Mon, 20 Jan 2025 09:14:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ewal2json=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Third_Party_Open_Source_Software_Notice | 29 + contrib/wal2json/LICENSE | 27 + contrib/wal2json/Makefile | 40 + contrib/wal2json/README.md | 396 +++ contrib/wal2json/check_wal2json.sh | 100 + contrib/wal2json/expected/actions.out | 141 + contrib/wal2json/expected/bytea.out | 108 + contrib/wal2json/expected/cmdline.out | 103 + contrib/wal2json/expected/default.out | 82 + contrib/wal2json/expected/delete1.out | 165 + contrib/wal2json/expected/delete2.out | 202 ++ contrib/wal2json/expected/delete3.out | 216 ++ contrib/wal2json/expected/delete4.out | 117 + contrib/wal2json/expected/filtertable.out | 295 ++ .../expected/include_domain_data_type.out | 228 ++ contrib/wal2json/expected/include_lsn.out | 58 + .../wal2json/expected/include_timestamp.out | 57 + contrib/wal2json/expected/include_xids.out | 57 + contrib/wal2json/expected/insert1.out | 168 + contrib/wal2json/expected/message.out | 69 + contrib/wal2json/expected/pk.out | 266 ++ contrib/wal2json/expected/position.out | 104 + contrib/wal2json/expected/savepoint.out | 60 + contrib/wal2json/expected/selecttable.out | 195 ++ contrib/wal2json/expected/specialvalue.out | 88 + contrib/wal2json/expected/toast.out | 154 + contrib/wal2json/expected/truncate.out | 102 + contrib/wal2json/expected/typmod.out | 153 + contrib/wal2json/expected/update1.out | 209 ++ contrib/wal2json/expected/update2.out | 229 ++ contrib/wal2json/expected/update3.out | 207 ++ contrib/wal2json/expected/update4.out | 126 + contrib/wal2json/sql/actions.sql | 23 + contrib/wal2json/sql/bytea.sql | 25 + contrib/wal2json/sql/cmdline.sql | 42 + contrib/wal2json/sql/default.sql | 24 + contrib/wal2json/sql/delete1.sql | 87 + contrib/wal2json/sql/delete2.sql | 91 + contrib/wal2json/sql/delete3.sql | 94 + contrib/wal2json/sql/delete4.sql | 42 + contrib/wal2json/sql/filtertable.sql | 65 + .../wal2json/sql/include_domain_data_type.sql | 50 + contrib/wal2json/sql/include_lsn.sql | 25 + contrib/wal2json/sql/include_timestamp.sql | 25 + contrib/wal2json/sql/include_xids.sql | 25 + contrib/wal2json/sql/insert1.sql | 89 + contrib/wal2json/sql/message.sql | 33 + contrib/wal2json/sql/pk.sql | 54 + contrib/wal2json/sql/position.sql | 25 + contrib/wal2json/sql/savepoint.sql | 28 + contrib/wal2json/sql/selecttable.sql | 38 + contrib/wal2json/sql/specialvalue.sql | 21 + contrib/wal2json/sql/toast.sql | 36 + contrib/wal2json/sql/truncate.sql | 28 + contrib/wal2json/sql/typmod.sql | 40 + contrib/wal2json/sql/update1.sql | 91 + contrib/wal2json/sql/update2.sql | 91 + contrib/wal2json/sql/update3.sql | 92 + contrib/wal2json/sql/update4.sql | 44 + contrib/wal2json/wal2json.c | 2892 +++++++++++++++++ 60 files changed, 8771 insertions(+) create mode 100644 contrib/wal2json/LICENSE create mode 100644 contrib/wal2json/Makefile create mode 100644 contrib/wal2json/README.md create mode 100644 contrib/wal2json/check_wal2json.sh create mode 100644 contrib/wal2json/expected/actions.out create mode 100644 contrib/wal2json/expected/bytea.out create mode 100644 contrib/wal2json/expected/cmdline.out create mode 100644 contrib/wal2json/expected/default.out create mode 100644 contrib/wal2json/expected/delete1.out create mode 100644 contrib/wal2json/expected/delete2.out create mode 100644 contrib/wal2json/expected/delete3.out create mode 100644 contrib/wal2json/expected/delete4.out create mode 100644 contrib/wal2json/expected/filtertable.out create mode 100644 contrib/wal2json/expected/include_domain_data_type.out create mode 100644 contrib/wal2json/expected/include_lsn.out create mode 100644 contrib/wal2json/expected/include_timestamp.out create mode 100644 contrib/wal2json/expected/include_xids.out create mode 100644 contrib/wal2json/expected/insert1.out create mode 100644 contrib/wal2json/expected/message.out create mode 100644 contrib/wal2json/expected/pk.out create mode 100644 contrib/wal2json/expected/position.out create mode 100644 contrib/wal2json/expected/savepoint.out create mode 100644 contrib/wal2json/expected/selecttable.out create mode 100644 contrib/wal2json/expected/specialvalue.out create mode 100644 contrib/wal2json/expected/toast.out create mode 100644 contrib/wal2json/expected/truncate.out create mode 100644 contrib/wal2json/expected/typmod.out create mode 100644 contrib/wal2json/expected/update1.out create mode 100644 contrib/wal2json/expected/update2.out create mode 100644 contrib/wal2json/expected/update3.out create mode 100644 contrib/wal2json/expected/update4.out create mode 100644 contrib/wal2json/sql/actions.sql create mode 100644 contrib/wal2json/sql/bytea.sql create mode 100644 contrib/wal2json/sql/cmdline.sql create mode 100644 contrib/wal2json/sql/default.sql create mode 100644 contrib/wal2json/sql/delete1.sql create mode 100644 contrib/wal2json/sql/delete2.sql create mode 100644 contrib/wal2json/sql/delete3.sql create mode 100644 contrib/wal2json/sql/delete4.sql create mode 100644 contrib/wal2json/sql/filtertable.sql create mode 100644 contrib/wal2json/sql/include_domain_data_type.sql create mode 100644 contrib/wal2json/sql/include_lsn.sql create mode 100644 contrib/wal2json/sql/include_timestamp.sql create mode 100644 contrib/wal2json/sql/include_xids.sql create mode 100644 contrib/wal2json/sql/insert1.sql create mode 100644 contrib/wal2json/sql/message.sql create mode 100644 contrib/wal2json/sql/pk.sql create mode 100644 contrib/wal2json/sql/position.sql create mode 100644 contrib/wal2json/sql/savepoint.sql create mode 100644 contrib/wal2json/sql/selecttable.sql create mode 100644 contrib/wal2json/sql/specialvalue.sql create mode 100644 contrib/wal2json/sql/toast.sql create mode 100644 contrib/wal2json/sql/truncate.sql create mode 100644 contrib/wal2json/sql/typmod.sql create mode 100644 contrib/wal2json/sql/update1.sql create mode 100644 contrib/wal2json/sql/update2.sql create mode 100644 contrib/wal2json/sql/update3.sql create mode 100644 contrib/wal2json/sql/update4.sql create mode 100644 contrib/wal2json/wal2json.c diff --git a/Third_Party_Open_Source_Software_Notice b/Third_Party_Open_Source_Software_Notice index f9448b7a4..4eff0a435 100644 --- a/Third_Party_Open_Source_Software_Notice +++ b/Third_Party_Open_Source_Software_Notice @@ -47,3 +47,32 @@ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +Software: wal2json 1.0 +Copyright notice:Copyright (c) 2013-2020, Euler Taveira de Oliveira +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +- Neither the name of the Euler Taveira de Oliveira nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/wal2json/LICENSE b/contrib/wal2json/LICENSE new file mode 100644 index 000000000..4e12addd4 --- /dev/null +++ b/contrib/wal2json/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013-2020, Euler Taveira de Oliveira +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of the Euler Taveira de Oliveira nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/wal2json/Makefile b/contrib/wal2json/Makefile new file mode 100644 index 000000000..7a487b753 --- /dev/null +++ b/contrib/wal2json/Makefile @@ -0,0 +1,40 @@ +MODULES = wal2json + +REGRESS = cmdline insert1 update1 update2 update3 update4 delete1 delete2 \ + delete3 delete4 savepoint specialvalue toast bytea message typmod \ + filtertable selecttable include_timestamp include_lsn include_xids \ + include_domain_data_type truncate actions position default pk + +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) + +# message API is available in 9.6+ +ifneq (,$(findstring $(MAJORVERSION),9.4 9.5)) +REGRESS := $(filter-out message, $(REGRESS)) +endif + +# truncate API is available in 11+ +ifneq (,$(findstring $(MAJORVERSION),9.4 9.5 9.6 10)) +REGRESS := $(filter-out truncate, $(REGRESS)) +endif + +# actions API is available in 11+ +# this test should be executed in prior versions, however, truncate will fail. +ifneq (,$(findstring $(MAJORVERSION),9.4 9.5 9.6 10)) +REGRESS := $(filter-out actions, $(REGRESS)) +endif + +override CPPFLAGS :=$(filter-out -fPIE, $(CPPFLAGS)) -fPIC -I$(CODE_BASE)/src/include + +check: + sh check_wal2json.sh +# make installcheck +# +# It can be run but you need to add the following parameters to +# postgresql.conf: +# +# wal_level = logical +# max_replication_slots = 10 +# +# Also, you should start the server before executing it. diff --git a/contrib/wal2json/README.md b/contrib/wal2json/README.md new file mode 100644 index 000000000..d4ae232d0 --- /dev/null +++ b/contrib/wal2json/README.md @@ -0,0 +1,396 @@ +[![Coverity Scan Build Status](https://scan.coverity.com/projects/4832/badge.svg)](https://scan.coverity.com/projects/wal2json) + +Introduction +============ + +This project is a fork from [wal2json](https://github.com/eulerto/wal2json),a compatibility version for openGuass. + +**wal2json** is an output plugin for logical decoding. It means that the plugin have access to tuples produced by INSERT and UPDATE. Also, UPDATE/DELETE old row versions can be accessed depending on the configured replica identity. Changes can be consumed using the streaming protocol (logical replication slots) or by a special SQL API. + +**format version 1** produces a JSON object per transaction. All of the new/old tuples are available in the JSON object. Also, there are options to include properties such as transaction timestamp, schema-qualified, data types, and transaction ids. + +**format version 2** produces a JSON object per tuple. Optional JSON object for beginning and end of transaction. Also, there are a variety of options to include properties. + +Build and Install +================= + +This extension only supported openGuass 1.0.1. + +You can also keep up with the latest fixes and features cloning the Git repository. + +``` +$ git clone https://gitee.com/enmotech/wal2json +``` + +Unix based Operating Systems +---------------------------- + +Before installing **wal2json**, you should have openGuass 1.0.1 installed(https://opengauss.org). + +If you compile PostgreSQL by yourself and install it in `/home/euler/pg13`: + +``` +$ tar -zxf wal2json-wal2json_2_3.tar.gz +$ cd wal2json-wal2json_2_3 +$ export PATH=/home/omm/openGuass/bin:$PATH +$ make +$ make install +``` + +Configuration +============= + +postgresql.conf +--------------- + +You need to set up at least two parameters at postgresql.conf: + +``` +wal_level = logical +# +# these parameters only need to set in versions 9.4, 9.5 and 9.6 +# default values are ok in version 10 or later +# +max_replication_slots = 10 +max_wal_senders = 10 +``` + +After changing these parameters, a restart is needed. + +Parameters +---------- + +* `include-xids`: add _xid_ to each changeset. Default is _false_. +* `include-timestamp`: add _timestamp_ to each changeset. Default is _false_. +* `include-schemas`: add _schema_ to each change. Default is _true_. +* `include-types`: add _type_ to each change. Default is _true_. +* `include-typmod`: add modifier to types that have it (eg. varchar(20) instead of varchar). Default is _true_. +* `include-type-oids`: add type oids. Default is _false_. +* `include-domain-data-type`: replace domain name with the underlying data type. Default is _false_. +* `include-column-positions`: add column position (_pg_attribute.attnum_). Default is _false_. +* `include-not-null`: add _not null_ information as _columnoptionals_. Default is _false_. +* `include-default`: add default expression. Default is _false_. +* `include-pk`: add _primary key_ information as _pk_. Column name and data type is included. Default is _false_. +* `pretty-print`: add spaces and indentation to JSON structures. Default is _false_. +* `write-in-chunks`: write after every change instead of every changeset. Default is _false_. +* `include-lsn`: add _nextlsn_ to each changeset. Default is _false_. +* `include-unchanged-toast` (deprecated): Don't use it. It is deprecated. +* `filter-origins`: exclude changes from the specified origins. Default is empty which means that no origin will be filtered. It is a comma separated value. +* `filter-tables`: exclude rows from the specified tables. Default is empty which means that no table will be filtered. It is a comma separated value. The tables should be schema-qualified. `*.foo` means table foo in all schemas and `bar.*` means all tables in schema bar. Special characters (space, single quote, comma, period, asterisk) must be escaped with backslash. Schema and table are case-sensitive. Table `"public"."Foo bar"` should be specified as `public.Foo\ bar`. +* `add-tables`: include only rows from the specified tables. Default is all tables from all schemas. It has the same rules from `filter-tables`. +* `filter-msg-prefixes`: exclude messages if prefix is in the list. Default is empty which means that no message will be filtered. It is a comma separated value. +* `add-msg-prefixes`: include only messages if prefix is in the list. Default is all prefixes. It is a comma separated value. `wal2json` applies `filter-msg-prefixes` before this parameter. +* `format-version`: defines which format to use. Default is _1_. +* `actions`: define which operations will be sent. Default is all actions (insert, update, delete, and truncate). However, if you are using `format-version` 1, truncate is not enabled (backward compatibility). + +Examples +======== + +There are two ways to obtain the changes (JSON objects) from **wal2json** plugin: calling functions via SQL or pg_recvlogical. + +pg_recvlogical +-------------- + +Besides the configuration above, it is necessary to configure a replication connection to use pg_recvlogical. A logical replication connection in version 9.4, 9.5, and 9.6 requires `replication` keyword in the database column. Since version 10, logical replication matches a normal entry with a database name or keywords such as `all`. + +First, add a replication connection rule at pg_hba.conf (9.4, 9.5, and 9.6): + +``` +local replication myuser trust +``` + +If you are using version 10 or later: + +``` +local mydatabase myuser trust +``` + +Also, set max_wal_senders at postgresql.conf: + +``` +max_wal_senders = 1 +``` + +A restart is necessary if you changed max_wal_senders. + +You are ready to try **wal2json**. In one terminal: + +``` +$ pg_recvlogical -d postgres --slot test_slot --create-slot -P wal2json +$ pg_recvlogical -d postgres --slot test_slot --start -o pretty-print=1 -f - +``` + +In another terminal: + +``` +$ cat /tmp/example1.sql +CREATE TABLE table_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c)); +CREATE TABLE table_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT); + +BEGIN; +INSERT INTO table_with_pk (b, c) VALUES('Backup and Restore', now()); +INSERT INTO table_with_pk (b, c) VALUES('Tuning', now()); +INSERT INTO table_with_pk (b, c) VALUES('Replication', now()); +DELETE FROM table_with_pk WHERE a < 3; + +INSERT INTO table_without_pk (b, c) VALUES(2.34, 'Tapir'); +-- it is not added to stream because there isn't a pk or a replica identity +UPDATE table_without_pk SET c = 'Anta' WHERE c = 'Tapir'; +COMMIT; + +$ psql -At -f /tmp/example1.sql postgres +CREATE TABLE +CREATE TABLE +BEGIN +INSERT 0 1 +INSERT 0 1 +INSERT 0 1 +DELETE 2 +INSERT 0 1 +UPDATE 1 +COMMIT +``` + +The output in the first terminal is: + +``` +{ + "change": [ + ] +} +{ + "change": [ + ] +} +WARNING: table "table_without_pk" without primary key or replica identity is nothing +{ + "change": [ + { + "kind": "insert", + "schema": "public", + "table": "table_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [1, "Backup and Restore", "2018-03-27 11:58:28.988414"] + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [2, "Tuning", "2018-03-27 11:58:28.988414"] + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [3, "Replication", "2018-03-27 11:58:28.988414"] + } + ,{ + "kind": "delete", + "schema": "public", + "table": "table_with_pk", + "oldkeys": { + "keynames": ["a", "c"], + "keytypes": ["integer", "timestamp without time zone"], + "keyvalues": [1, "2018-03-27 11:58:28.988414"] + } + } + ,{ + "kind": "delete", + "schema": "public", + "table": "table_with_pk", + "oldkeys": { + "keynames": ["a", "c"], + "keytypes": ["integer", "timestamp without time zone"], + "keyvalues": [2, "2018-03-27 11:58:28.988414"] + } + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table_without_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "numeric(5,2)", "text"], + "columnvalues": [1, 2.34, "Tapir"] + } + ] +} +``` + +Dropping the slot in the first terminal: + +``` +Ctrl+C +$ pg_recvlogical -d postgres --slot test_slot --drop-slot +``` + +SQL functions +------------- + +``` +$ cat /tmp/example2.sql +CREATE TABLE table2_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c)); +CREATE TABLE table2_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT); + +SELECT 'init' FROM pg_create_logical_replication_slot('test_slot', 'wal2json'); + +BEGIN; +INSERT INTO table2_with_pk (b, c) VALUES('Backup and Restore', now()); +INSERT INTO table2_with_pk (b, c) VALUES('Tuning', now()); +INSERT INTO table2_with_pk (b, c) VALUES('Replication', now()); +DELETE FROM table2_with_pk WHERE a < 3; + +INSERT INTO table2_without_pk (b, c) VALUES(2.34, 'Tapir'); +-- it is not added to stream because there isn't a pk or a replica identity +UPDATE table2_without_pk SET c = 'Anta' WHERE c = 'Tapir'; +COMMIT; + +SELECT data FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'pretty-print', '1'); +SELECT 'stop' FROM pg_drop_replication_slot('test_slot'); +``` + +The script above produces the output below: + +``` +$ psql -At -f /tmp/example2.sql postgres +CREATE TABLE +CREATE TABLE +init +BEGIN +INSERT 0 1 +INSERT 0 1 +INSERT 0 1 +DELETE 2 +INSERT 0 1 +UPDATE 1 +COMMIT +psql:/tmp/example2.sql:17: WARNING: table "table2_without_pk" without primary key or replica identity is nothing +{ + "change": [ + { + "kind": "insert", + "schema": "public", + "table": "table2_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [1, "Backup and Restore", "2018-03-27 12:05:29.914496"] + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table2_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [2, "Tuning", "2018-03-27 12:05:29.914496"] + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table2_with_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "character varying(30)", "timestamp without time zone"], + "columnvalues": [3, "Replication", "2018-03-27 12:05:29.914496"] + } + ,{ + "kind": "delete", + "schema": "public", + "table": "table2_with_pk", + "oldkeys": { + "keynames": ["a", "c"], + "keytypes": ["integer", "timestamp without time zone"], + "keyvalues": [1, "2018-03-27 12:05:29.914496"] + } + } + ,{ + "kind": "delete", + "schema": "public", + "table": "table2_with_pk", + "oldkeys": { + "keynames": ["a", "c"], + "keytypes": ["integer", "timestamp without time zone"], + "keyvalues": [2, "2018-03-27 12:05:29.914496"] + } + } + ,{ + "kind": "insert", + "schema": "public", + "table": "table2_without_pk", + "columnnames": ["a", "b", "c"], + "columntypes": ["integer", "numeric(5,2)", "text"], + "columnvalues": [1, 2.34, "Tapir"] + } + ] +} +stop +``` + +Let's repeat the same example with `format-version` 2: + +``` +$ cat /tmp/example3.sql +CREATE TABLE table2_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c)); +CREATE TABLE table2_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT); + +SELECT 'init' FROM pg_create_logical_replication_slot('test_slot', 'wal2json'); + +BEGIN; +INSERT INTO table2_with_pk (b, c) VALUES('Backup and Restore', now()); +INSERT INTO table2_with_pk (b, c) VALUES('Tuning', now()); +INSERT INTO table2_with_pk (b, c) VALUES('Replication', now()); +DELETE FROM table2_with_pk WHERE a < 3; + +INSERT INTO table2_without_pk (b, c) VALUES(2.34, 'Tapir'); +-- it is not added to stream because there isn't a pk or a replica identity +UPDATE table2_without_pk SET c = 'Anta' WHERE c = 'Tapir'; +COMMIT; + +SELECT data FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('test_slot'); +``` + +The script above produces the output below: + +``` +$ psql -At -f /tmp/example3.sql postgres +CREATE TABLE +CREATE TABLE +init +BEGIN +INSERT 0 1 +INSERT 0 1 +INSERT 0 1 +DELETE 2 +INSERT 0 1 +UPDATE 1 +COMMIT +psql:/tmp/example3.sql:17: WARNING: no tuple identifier for UPDATE in table "public"."table2_without_pk" +{"action":"B"} +{"action":"I","schema":"public","table":"table2_with_pk","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"character varying(30)","value":"Backup and Restore"},{"name":"c","type":"timestamp without time zone","value":"2019-12-29 04:58:34.806671"}]} +{"action":"I","schema":"public","table":"table2_with_pk","columns":[{"name":"a","type":"integer","value":2},{"name":"b","type":"character varying(30)","value":"Tuning"},{"name":"c","type":"timestamp without time zone","value":"2019-12-29 04:58:34.806671"}]} +{"action":"I","schema":"public","table":"table2_with_pk","columns":[{"name":"a","type":"integer","value":3},{"name":"b","type":"character varying(30)","value":"Replication"},{"name":"c","type":"timestamp without time zone","value":"2019-12-29 04:58:34.806671"}]} +{"action":"D","schema":"public","table":"table2_with_pk","identity":[{"name":"a","type":"integer","value":1},{"name":"c","type":"timestamp without time zone","value":"2019-12-29 04:58:34.806671"}]} +{"action":"D","schema":"public","table":"table2_with_pk","identity":[{"name":"a","type":"integer","value":2},{"name":"c","type":"timestamp without time zone","value":"2019-12-29 04:58:34.806671"}]} +{"action":"I","schema":"public","table":"table2_without_pk","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"numeric(5,2)","value":2.34},{"name":"c","type":"text","value":"Tapir"}]} +{"action":"C"} +stop +``` + +License +======= + +> Copyright (c) 2013-2020, Euler Taveira de Oliveira +> All rights reserved. + +> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +> Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +> Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +> Neither the name of the Euler Taveira de Oliveira nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/wal2json/check_wal2json.sh b/contrib/wal2json/check_wal2json.sh new file mode 100644 index 000000000..e0f11eb04 --- /dev/null +++ b/contrib/wal2json/check_wal2json.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +function delete() +{ + rm -rf test_wal2json + rm -rf $PGTMPDATA +} + +function database_install() +{ + echo "init gaussdb database" + gs_initdb -D $PGTMPDATA --nodename=single_node1 -w Test@123 > init.log 2>&1 + if [ $? -ne 0 ] + then + echo "init failed, see init.log for detail information" + delete + exit 1 + else + echo "init success, begin to start" + fi + if [ $PGTEMPPORT ];then + echo "PGTEMPPORT = $PGTEMPPORT, IF THE PORT BE OCCUPIED, PLEASE EXPORT PGTEMPPORT DIFFERENT PORT!" + else + echo "PGTEMPPORT IS NOT EXISTS, PLEASE SET PGTEMPPORT, IT IS REGRESSION TEST PORT" + delete + exit 1 + fi + echo "port = $PGTEMPPORT" >> $PGTMPDATA/postgresql.conf + echo "most_available_sync = on" >> $PGTMPDATA/postgresql.conf + echo "replconninfo1 = 'localhost=127.0.0.1 localport=12001 localheartbeatport=12004 remotehost=127.0.0.1 remoteport=12002 remoteheartbeatport=12005'" >> $PGTMPDATA/postgresql.conf + sed -i 's/wal_level = hot_standby/wal_level = logical/g' $PGTMPDATA/postgresql.conf + sed -i 's/max_replication_slots = 8/max_replication_slots = 10/g' $PGTMPDATA/postgresql.conf + sed -i 's/max_wal_senders = 4/max_wal_senders = 10/g' $PGTMPDATA/postgresql.conf + gs_ctl start -D $PGTMPDATA -M primary > start.log 2>&1 + if [ $? -ne 0 ] + then + echo "start failed,see start.log for detail information" + delete + exit 1 + else + echo "OpenGauss start success,the port is $PGTEMPPORT" + fi +} + +function run_check() +{ + gsql -d postgres -p $PGTEMPPORT -c "create database regression;" + if [ $? -ne 0 ] + then + echo "create database failed" + delete + exit 1 + fi + if [ ! -d "result" ]; then + mkdir result + fi + + for sql_flle in $( ls sql/|awk -F '.' '{print $1;}') + do + gsql -d regression -p $PGTEMPPORT -a < sql/$sql_flle.sql > result/$sql_flle.out 2>&1 + done + + if [ -e "diff.log" ]; then + rm diff.log + fi + + for out_file in $(ls expected) + do + diff -u --ignore-matching-lines="WARNING: Due to DDL in the same top transaction, partial modification may be lost for *" expected/$out_file result/$out_file >> diff.log + done + + if [[ `cat diff.log |wc -l` -eq 0 ]] + then + echo -e "\033[32m OK \033[0m" + else + echo -e "\033[31m FAILED \033[0m" + fi + pid=$(ps ux | grep "$PGTMPDATA" | grep -v "grep" | tr -s ' ' | cut -d ' ' -f 2) + echo "The gaussdb server pid is $pid" + kill -9 $pid + sleep 0.5 + pid_check=$(ps ux | grep "gaussdb" | grep -v "grep" | tr -s ' ' | cut -d ' ' -f 2) + if [ $pid_check ] + then + echo "The gaussdb server $pid has not been killed" + else + echo "The gaussdb server $pid has been killed" + fi + delete + rm init.log + rm start.log +} + +function main() +{ + database_install + run_check +} + +main $@ diff --git a/contrib/wal2json/expected/actions.out b/contrib/wal2json/expected/actions.out new file mode 100644 index 000000000..caf9c8e24 --- /dev/null +++ b/contrib/wal2json/expected/actions.out @@ -0,0 +1,141 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- actions +CREATE TABLE actions (a integer primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "actions_pkey" for table "actions" +CREATE TABLE +INSERT INTO actions (a) VALUES(1); +INSERT 0 1 +UPDATE actions SET a = 2 WHERE a = 1; +UPDATE 1 +DELETE FROM actions WHERE a = 2; +DELETE 1 +TRUNCATE TABLE actions; +TRUNCATE TABLE +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert, foo, delete'); +ERROR: could not parse value "foo" for parameter "actions" +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"change":[]} + {"change":[{"kind":"insert","schema":"public","table":"actions","columnnames":["a"],"columntypes":["integer"],"columnvalues":[1]}]} + {"change":[{"kind":"update","schema":"public","table":"actions","columnnames":["a"],"columntypes":["integer"],"columnvalues":[2],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} + {"change":[{"kind":"delete","schema":"public","table":"actions","oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[2]}}]} + {"change":[]} +(5 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"actions","identity":[{"name":"a","type":"integer","value":2}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(13 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert'); + data +-------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(11 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(11 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'delete'); + data +--------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"actions","identity":[{"name":"a","type":"integer","value":2}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(11 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'truncate'); + data +---------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(10 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update, truncate'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"actions","columns":[{"name":"a","type":"integer","value":2}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(11 rows) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/bytea.out b/contrib/wal2json/expected/bytea.out new file mode 100644 index 000000000..efba365fd --- /dev/null +++ b/contrib/wal2json/expected/bytea.out @@ -0,0 +1,108 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS xpto; +NOTICE: table "xpto" does not exist, skipping +DROP TABLE +DROP SEQUENCE IF EXISTS xpto_rand_seq; +NOTICE: sequence "xpto_rand_seq" does not exist, skipping +DROP SEQUENCE + +CREATE SEQUENCE xpto_rand_seq START 11 INCREMENT 997; +CREATE SEQUENCE +CREATE TABLE xpto ( +id serial primary key, +rand1 float8 DEFAULT nextval('xpto_rand_seq'), +bincol bytea +); +NOTICE: CREATE TABLE will create implicit sequence "xpto_id_seq" for serial column "xpto.id" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "xpto_pkey" for table "xpto" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO xpto (bincol) SELECT decode(string_agg(to_char(round(g.i * 0.08122019), 'FM0000'), ''), 'hex') FROM generate_series(500, 5000) g(i); +INSERT 0 1 +UPDATE xpto SET rand1 = 123.456 WHERE id = 1; +UPDATE 1 +DELETE FROM xpto WHERE id = 1; +DELETE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "rand1", "bincol"], + + "columntypes": ["int4", "float8", "bytea"], + + "columnvalues": [1, 11, "0041004100410041004100410041004100410041004100420042004200420042004200420042004200420042004200420043004300430043004300430043004300430043004300430044004400440044004400440044004400440044004400440045004500450045004500450045004500450045004500450045004600460046004600460046004600460046004600460046004700470047004700470047004700470047004700470047004800480048004800480048004800480048004800480048004800490049004900490049004900490049004900490049004900500050005000500050005000500050005000500050005000510051005100510051005100510051005100510051005100510052005200520052005200520052005200520052005200520053005300530053005300530053005300530053005300530054005400540054005400540054005400540054005400540054005500550055005500550055005500550055005500550055005600560056005600560056005600560056005600560056005700570057005700570057005700570057005700570057005800580058005800580058005800580058005800580058005800590059005900590059005900590059005900590059005900600060006000600060006000600060006000600060006000610061006100610061006100610061006100610061006100610062006200620062006200620062006200620062006200620063006300630063006300630063006300630063006300630064006400640064006400640064006400640064006400640064006500650065006500650065006500650065006500650065006600660066006600660066006600660066006600660066006700670067006700670067006700670067006700670067006700680068006800680068006800680068006800680068006800690069006900690069006900690069006900690069006900700070007000700070007000700070007000700070007000700071007100710071007100710071007100710071007100710072007200720072007200720072007200720072007200720073007300730073007300730073007300730073007300730074007400740074007400740074007400740074007400740074007500750075007500750075007500750075007500750075007600760076007600760076007600760076007600760076007700770077007700770077007700770077007700770077007700780078007800780078007800780078007800780078007800790079007900790079007900790079007900790079007900800080008000800080008000800080008000800080008000800081008100810081008100810081008100810081008100810082008200820082008200820082008200820082008200820083008300830083008300830083008300830083008300830083008400840084008400840084008400840084008400840084008500850085008500850085008500850085008500850085008600860086008600860086008600860086008600860086008600870087008700870087008700870087008700870087008700880088008800880088008800880088008800880088008800890089008900890089008900890089008900890089008900900090009000900090009000900090009000900090009000900091009100910091009100910091009100910091009100910092009200920092009200920092009200920092009200920093009300930093009300930093009300930093009300930093009400940094009400940094009400940094009400940094009500950095009500950095009500950095009500950095009600960096009600960096009600960096009600960096009600970097009700970097009700970097009700970097009700980098009800980098009800980098009800980098009800990099009900990099009900990099009900990099009900990100010001000100010001000100010001000100010001000101010101010101010101010101010101010101010101010102010201020102010201020102010201020102010201020102010301030103010301030103010301030103010301030103010401040104010401040104010401040104010401040104010501050105010501050105010501050105010501050105010601060106010601060106010601060106010601060106010601070107010701070107010701070107010701070107010701080108010801080108010801080108010801080108010801090109010901090109010901090109010901090109010901090110011001100110011001100110011001100110011001100111011101110111011101110111011101110111011101110112011201120112011201120112011201120112011201120112011301130113011301130113011301130113011301130113011401140114011401140114011401140114011401140114011501150115011501150115011501150115011501150115011501160116011601160116011601160116011601160116011601170117011701170117011701170117011701170117011701180118011801180118011801180118011801180118011801190119011901190119011901190119011901190119011901190120012001200120012001200120012001200120012001200121012101210121012101210121012101210121012101210122012201220122012201220122012201220122012201220122012301230123012301230123012301230123012301230123012401240124012401240124012401240124012401240124012501250125012501250125012501250125012501250125012501260126012601260126012601260126012601260126012601270127012701270127012701270127012701270127012701280128012801280128012801280128012801280128012801280129012901290129012901290129012901290129012901290130013001300130013001300130013001300130013001300131013101310131013101310131013101310131013101310131013201320132013201320132013201320132013201320132013301330133013301330133013301330133013301330133013401340134013401340134013401340134013401340134013501350135013501350135013501350135013501350135013501360136013601360136013601360136013601360136013601370137013701370137013701370137013701370137013701380138013801380138013801380138013801380138013801380139013901390139013901390139013901390139013901390140014001400140014001400140014001400140014001400141014101410141014101410141014101410141014101410141014201420142014201420142014201420142014201420142014301430143014301430143014301430143014301430143014401440144014401440144014401440144014401440144014401450145014501450145014501450145014501450145014501460146014601460146014601460146014601460146014601470147014701470147014701470147014701470147014701470148014801480148014801480148014801480148014801480149014901490149014901490149014901490149014901490150015001500150015001500150015001500150015001500151015101510151015101510151015101510151015101510151015201520152015201520152015201520152015201520152015301530153015301530153015301530153015301530153015401540154015401540154015401540154015401540154015401550155015501550155015501550155015501550155015501560156015601560156015601560156015601560156015601570157015701570157015701570157015701570157015701570158015801580158015801580158015801580158015801580159015901590159015901590159015901590159015901590160016001600160016001600160016001600160016001600160016101610161016101610161016101610161016101610161016201620162016201620162016201620162016201620162016301630163016301630163016301630163016301630163016301640164016401640164016401640164016401640164016401650165016501650165016501650165016501650165016501660166016601660166016601660166016601660166016601670167016701670167016701670167016701670167016701670168016801680168016801680168016801680168016801680169016901690169016901690169016901690169016901690170017001700170017001700170017001700170017001700170017101710171017101710171017101710171017101710171017201720172017201720172017201720172017201720172017301730173017301730173017301730173017301730173017301740174017401740174017401740174017401740174017401750175017501750175017501750175017501750175017501760176017601760176017601760176017601760176017601760177017701770177017701770177017701770177017701770178017801780178017801780178017801780178017801780179017901790179017901790179017901790179017901790179018001800180018001800180018001800180018001800180018101810181018101810181018101810181018101810181018201820182018201820182018201820182018201820182018301830183018301830183018301830183018301830183018301840184018401840184018401840184018401840184018401850185018501850185018501850185018501850185018501860186018601860186018601860186018601860186018601860187018701870187018701870187018701870187018701870188018801880188018801880188018801880188018801880189018901890189018901890189018901890189018901890189019001900190019001900190019001900190019001900190019101910191019101910191019101910191019101910191019201920192019201920192019201920192019201920192019201930193019301930193019301930193019301930193019301940194019401940194019401940194019401940194019401950195019501950195019501950195019501950195019501950196019601960196019601960196019601960196019601960197019701970197019701970197019701970197019701970198019801980198019801980198019801980198019801980199019901990199019901990199019901990199019901990199020002000200020002000200020002000200020002000200020102010201020102010201020102010201020102010201020202020202020202020202020202020202020202020202020202030203020302030203020302030203020302030203020302040204020402040204020402040204020402040204020402050205020502050205020502050205020502050205020502050206020602060206020602060206020602060206020602060207020702070207020702070207020702070207020702070208020802080208020802080208020802080208020802080208020902090209020902090209020902090209020902090209021002100210021002100210021002100210021002100210021102110211021102110211021102110211021102110211021102120212021202120212021202120212021202120212021202130213021302130213021302130213021302130213021302140214021402140214021402140214021402140214021402150215021502150215021502150215021502150215021502150216021602160216021602160216021602160216021602160217021702170217021702170217021702170217021702170218021802180218021802180218021802180218021802180218021902190219021902190219021902190219021902190219022002200220022002200220022002200220022002200220022102210221022102210221022102210221022102210221022102220222022202220222022202220222022202220222022202230223022302230223022302230223022302230223022302240224022402240224022402240224022402240224022402240225022502250225022502250225022502250225022502250226022602260226022602260226022602260226022602260227022702270227022702270227022702270227022702270227022802280228022802280228022802280228022802280228022902290229022902290229022902290229022902290229023002300230023002300230023002300230023002300230023102310231023102310231023102310231023102310231023102320232023202320232023202320232023202320232023202330233023302330233023302330233023302330233023302340234023402340234023402340234023402340234023402340235023502350235023502350235023502350235023502350236023602360236023602360236023602360236023602360237023702370237023702370237023702370237023702370237023802380238023802380238023802380238023802380238023902390239023902390239023902390239023902390239024002400240024002400240024002400240024002400240024002410241024102410241024102410241024102410241024102420242024202420242024202420242024202420242024202430243024302430243024302430243024302430243024302430244024402440244024402440244024402440244024402440245024502450245024502450245024502450245024502450246024602460246024602460246024602460246024602460247024702470247024702470247024702470247024702470247024802480248024802480248024802480248024802480248024902490249024902490249024902490249024902490249025002500250025002500250025002500250025002500250025002510251025102510251025102510251025102510251025102520252025202520252025202520252025202520252025202530253025302530253025302530253025302530253025302530254025402540254025402540254025402540254025402540255025502550255025502550255025502550255025502550256025602560256025602560256025602560256025602560256025702570257025702570257025702570257025702570257025802580258025802580258025802580258025802580258025902590259025902590259025902590259025902590259025902600260026002600260026002600260026002600260026002610261026102610261026102610261026102610261026102620262026202620262026202620262026202620262026202630263026302630263026302630263026302630263026302630264026402640264026402640264026402640264026402640265026502650265026502650265026502650265026502650266026602660266026602660266026602660266026602660266026702670267026702670267026702670267026702670267026802680268026802680268026802680268026802680268026902690269026902690269026902690269026902690269026902700270027002700270027002700270027002700270027002710271027102710271027102710271027102710271027102720272027202720272027202720272027202720272027202720273027302730273027302730273027302730273027302730274027402740274027402740274027402740274027402740275027502750275027502750275027502750275027502750275027602760276027602760276027602760276027602760276027702770277027702770277027702770277027702770277027802780278027802780278027802780278027802780278027902790279027902790279027902790279027902790279027902800280028002800280028002800280028002800280028002810281028102810281028102810281028102810281028102820282028202820282028202820282028202820282028202820283028302830283028302830283028302830283028302830284028402840284028402840284028402840284028402840285028502850285028502850285028502850285028502850285028602860286028602860286028602860286028602860286028702870287028702870287028702870287028702870287028802880288028802880288028802880288028802880288028802890289028902890289028902890289028902890289028902900290029002900290029002900290029002900290029002910291029102910291029102910291029102910291029102910292029202920292029202920292029202920292029202920293029302930293029302930293029302930293029302930294029402940294029402940294029402940294029402940295029502950295029502950295029502950295029502950295029602960296029602960296029602960296029602960296029702970297029702970297029702970297029702970297029802980298029802980298029802980298029802980298029802990299029902990299029902990299029902990299029903000300030003000300030003000300030003000300030003010301030103010301030103010301030103010301030103010302030203020302030203020302030203020302030203020303030303030303030303030303030303030303030303030304030403040304030403040304030403040304030403040304030503050305030503050305030503050305030503050305030603060306030603060306030603060306030603060306030703070307030703070307030703070307030703070307030703080308030803080308030803080308030803080308030803090309030903090309030903090309030903090309030903100310031003100310031003100310031003100310031003110311031103110311031103110311031103110311031103110312031203120312031203120312031203120312031203120313031303130313031303130313031303130313031303130314031403140314031403140314031403140314031403140314031503150315031503150315031503150315031503150315031603160316031603160316031603160316031603160316031703170317031703170317031703170317031703170317031703180318031803180318031803180318031803180318031803190319031903190319031903190319031903190319031903200320032003200320032003200320032003200320032003200321032103210321032103210321032103210321032103210322032203220322032203220322032203220322032203220323032303230323032303230323032303230323032303230324032403240324032403240324032403240324032403240324032503250325032503250325032503250325032503250325032603260326032603260326032603260326032603260326032703270327032703270327032703270327032703270327032703280328032803280328032803280328032803280328032803290329032903290329032903290329032903290329032903300330033003300330033003300330033003300330033003300331033103310331033103310331033103310331033103310332033203320332033203320332033203320332033203320333033303330333033303330333033303330333033303330333033403340334033403340334033403340334033403340334033503350335033503350335033503350335033503350335033603360336033603360336033603360336033603360336033603370337033703370337033703370337033703370337033703380338033803380338033803380338033803380338033803390339033903390339033903390339033903390339033903400340034003400340034003400340034003400340034003400341034103410341034103410341034103410341034103410342034203420342034203420342034203420342034203420343034303430343034303430343034303430343034303430343034403440344034403440344034403440344034403440344034503450345034503450345034503450345034503450345034603460346034603460346034603460346034603460346034603470347034703470347034703470347034703470347034703480348034803480348034803480348034803480348034803490349034903490349034903490349034903490349034903490350035003500350035003500350035003500350035003500351035103510351035103510351035103510351035103510352035203520352035203520352035203520352035203520352035303530353035303530353035303530353035303530353035403540354035403540354035403540354035403540354035503550355035503550355035503550355035503550355035603560356035603560356035603560356035603560356035603570357035703570357035703570357035703570357035703580358035803580358035803580358035803580358035803590359035903590359035903590359035903590359035903590360036003600360036003600360036003600360036003600361036103610361036103610361036103610361036103610362036203620362036203620362036203620362036203620362036303630363036303630363036303630363036303630363036403640364036403640364036403640364036403640364036503650365036503650365036503650365036503650365036503660366036603660366036603660366036603660366036603670367036703670367036703670367036703670367036703680368036803680368036803680368036803680368036803680369036903690369036903690369036903690369036903690370037003700370037003700370037003700370037003700371037103710371037103710371037103710371037103710372037203720372037203720372037203720372037203720372037303730373037303730373037303730373037303730373037403740374037403740374037403740374037403740374037503750375037503750375037503750375037503750375037503760376037603760376037603760376037603760376037603770377037703770377037703770377037703770377037703780378037803780378037803780378037803780378037803780379037903790379037903790379037903790379037903790380038003800380038003800380038003800380038003800381038103810381038103810381038103810381038103810381038203820382038203820382038203820382038203820382038303830383038303830383038303830383038303830383038403840384038403840384038403840384038403840384038403850385038503850385038503850385038503850385038503860386038603860386038603860386038603860386038603870387038703870387038703870387038703870387038703880388038803880388038803880388038803880388038803880389038903890389038903890389038903890389038903890390039003900390039003900390039003900390039003900391039103910391039103910391039103910391039103910391039203920392039203920392039203920392039203920392039303930393039303930393039303930393039303930393039403940394039403940394039403940394039403940394039403950395039503950395039503950395039503950395039503960396039603960396039603960396039603960396039603970397039703970397039703970397039703970397039703970398039803980398039803980398039803980398039803980399039903990399039903990399039903990399039903990400040004000400040004000400040004000400040004000400040104010401040104010401040104010401040104010401040204020402040204020402040204020402040204020402040304030403040304030403040304030403040304030403040404040404040404040404040404040404040404040404040404050405040504050405040504050405040504050405040504060406040604060406040604060406"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "rand1", "bincol"], + + "columntypes": ["int4", "float8", "bytea"], + + "columnvalues": [1, 123.456, "0041004100410041004100410041004100410041004100420042004200420042004200420042004200420042004200420043004300430043004300430043004300430043004300430044004400440044004400440044004400440044004400440045004500450045004500450045004500450045004500450045004600460046004600460046004600460046004600460046004700470047004700470047004700470047004700470047004800480048004800480048004800480048004800480048004800490049004900490049004900490049004900490049004900500050005000500050005000500050005000500050005000510051005100510051005100510051005100510051005100510052005200520052005200520052005200520052005200520053005300530053005300530053005300530053005300530054005400540054005400540054005400540054005400540054005500550055005500550055005500550055005500550055005600560056005600560056005600560056005600560056005700570057005700570057005700570057005700570057005800580058005800580058005800580058005800580058005800590059005900590059005900590059005900590059005900600060006000600060006000600060006000600060006000610061006100610061006100610061006100610061006100610062006200620062006200620062006200620062006200620063006300630063006300630063006300630063006300630064006400640064006400640064006400640064006400640064006500650065006500650065006500650065006500650065006600660066006600660066006600660066006600660066006700670067006700670067006700670067006700670067006700680068006800680068006800680068006800680068006800690069006900690069006900690069006900690069006900700070007000700070007000700070007000700070007000700071007100710071007100710071007100710071007100710072007200720072007200720072007200720072007200720073007300730073007300730073007300730073007300730074007400740074007400740074007400740074007400740074007500750075007500750075007500750075007500750075007600760076007600760076007600760076007600760076007700770077007700770077007700770077007700770077007700780078007800780078007800780078007800780078007800790079007900790079007900790079007900790079007900800080008000800080008000800080008000800080008000800081008100810081008100810081008100810081008100810082008200820082008200820082008200820082008200820083008300830083008300830083008300830083008300830083008400840084008400840084008400840084008400840084008500850085008500850085008500850085008500850085008600860086008600860086008600860086008600860086008600870087008700870087008700870087008700870087008700880088008800880088008800880088008800880088008800890089008900890089008900890089008900890089008900900090009000900090009000900090009000900090009000900091009100910091009100910091009100910091009100910092009200920092009200920092009200920092009200920093009300930093009300930093009300930093009300930093009400940094009400940094009400940094009400940094009500950095009500950095009500950095009500950095009600960096009600960096009600960096009600960096009600970097009700970097009700970097009700970097009700980098009800980098009800980098009800980098009800990099009900990099009900990099009900990099009900990100010001000100010001000100010001000100010001000101010101010101010101010101010101010101010101010102010201020102010201020102010201020102010201020102010301030103010301030103010301030103010301030103010401040104010401040104010401040104010401040104010501050105010501050105010501050105010501050105010601060106010601060106010601060106010601060106010601070107010701070107010701070107010701070107010701080108010801080108010801080108010801080108010801090109010901090109010901090109010901090109010901090110011001100110011001100110011001100110011001100111011101110111011101110111011101110111011101110112011201120112011201120112011201120112011201120112011301130113011301130113011301130113011301130113011401140114011401140114011401140114011401140114011501150115011501150115011501150115011501150115011501160116011601160116011601160116011601160116011601170117011701170117011701170117011701170117011701180118011801180118011801180118011801180118011801190119011901190119011901190119011901190119011901190120012001200120012001200120012001200120012001200121012101210121012101210121012101210121012101210122012201220122012201220122012201220122012201220122012301230123012301230123012301230123012301230123012401240124012401240124012401240124012401240124012501250125012501250125012501250125012501250125012501260126012601260126012601260126012601260126012601270127012701270127012701270127012701270127012701280128012801280128012801280128012801280128012801280129012901290129012901290129012901290129012901290130013001300130013001300130013001300130013001300131013101310131013101310131013101310131013101310131013201320132013201320132013201320132013201320132013301330133013301330133013301330133013301330133013401340134013401340134013401340134013401340134013501350135013501350135013501350135013501350135013501360136013601360136013601360136013601360136013601370137013701370137013701370137013701370137013701380138013801380138013801380138013801380138013801380139013901390139013901390139013901390139013901390140014001400140014001400140014001400140014001400141014101410141014101410141014101410141014101410141014201420142014201420142014201420142014201420142014301430143014301430143014301430143014301430143014401440144014401440144014401440144014401440144014401450145014501450145014501450145014501450145014501460146014601460146014601460146014601460146014601470147014701470147014701470147014701470147014701470148014801480148014801480148014801480148014801480149014901490149014901490149014901490149014901490150015001500150015001500150015001500150015001500151015101510151015101510151015101510151015101510151015201520152015201520152015201520152015201520152015301530153015301530153015301530153015301530153015401540154015401540154015401540154015401540154015401550155015501550155015501550155015501550155015501560156015601560156015601560156015601560156015601570157015701570157015701570157015701570157015701570158015801580158015801580158015801580158015801580159015901590159015901590159015901590159015901590160016001600160016001600160016001600160016001600160016101610161016101610161016101610161016101610161016201620162016201620162016201620162016201620162016301630163016301630163016301630163016301630163016301640164016401640164016401640164016401640164016401650165016501650165016501650165016501650165016501660166016601660166016601660166016601660166016601670167016701670167016701670167016701670167016701670168016801680168016801680168016801680168016801680169016901690169016901690169016901690169016901690170017001700170017001700170017001700170017001700170017101710171017101710171017101710171017101710171017201720172017201720172017201720172017201720172017301730173017301730173017301730173017301730173017301740174017401740174017401740174017401740174017401750175017501750175017501750175017501750175017501760176017601760176017601760176017601760176017601760177017701770177017701770177017701770177017701770178017801780178017801780178017801780178017801780179017901790179017901790179017901790179017901790179018001800180018001800180018001800180018001800180018101810181018101810181018101810181018101810181018201820182018201820182018201820182018201820182018301830183018301830183018301830183018301830183018301840184018401840184018401840184018401840184018401850185018501850185018501850185018501850185018501860186018601860186018601860186018601860186018601860187018701870187018701870187018701870187018701870188018801880188018801880188018801880188018801880189018901890189018901890189018901890189018901890189019001900190019001900190019001900190019001900190019101910191019101910191019101910191019101910191019201920192019201920192019201920192019201920192019201930193019301930193019301930193019301930193019301940194019401940194019401940194019401940194019401950195019501950195019501950195019501950195019501950196019601960196019601960196019601960196019601960197019701970197019701970197019701970197019701970198019801980198019801980198019801980198019801980199019901990199019901990199019901990199019901990199020002000200020002000200020002000200020002000200020102010201020102010201020102010201020102010201020202020202020202020202020202020202020202020202020202030203020302030203020302030203020302030203020302040204020402040204020402040204020402040204020402050205020502050205020502050205020502050205020502050206020602060206020602060206020602060206020602060207020702070207020702070207020702070207020702070208020802080208020802080208020802080208020802080208020902090209020902090209020902090209020902090209021002100210021002100210021002100210021002100210021102110211021102110211021102110211021102110211021102120212021202120212021202120212021202120212021202130213021302130213021302130213021302130213021302140214021402140214021402140214021402140214021402150215021502150215021502150215021502150215021502150216021602160216021602160216021602160216021602160217021702170217021702170217021702170217021702170218021802180218021802180218021802180218021802180218021902190219021902190219021902190219021902190219022002200220022002200220022002200220022002200220022102210221022102210221022102210221022102210221022102220222022202220222022202220222022202220222022202230223022302230223022302230223022302230223022302240224022402240224022402240224022402240224022402240225022502250225022502250225022502250225022502250226022602260226022602260226022602260226022602260227022702270227022702270227022702270227022702270227022802280228022802280228022802280228022802280228022902290229022902290229022902290229022902290229023002300230023002300230023002300230023002300230023102310231023102310231023102310231023102310231023102320232023202320232023202320232023202320232023202330233023302330233023302330233023302330233023302340234023402340234023402340234023402340234023402340235023502350235023502350235023502350235023502350236023602360236023602360236023602360236023602360237023702370237023702370237023702370237023702370237023802380238023802380238023802380238023802380238023902390239023902390239023902390239023902390239024002400240024002400240024002400240024002400240024002410241024102410241024102410241024102410241024102420242024202420242024202420242024202420242024202430243024302430243024302430243024302430243024302430244024402440244024402440244024402440244024402440245024502450245024502450245024502450245024502450246024602460246024602460246024602460246024602460247024702470247024702470247024702470247024702470247024802480248024802480248024802480248024802480248024902490249024902490249024902490249024902490249025002500250025002500250025002500250025002500250025002510251025102510251025102510251025102510251025102520252025202520252025202520252025202520252025202530253025302530253025302530253025302530253025302530254025402540254025402540254025402540254025402540255025502550255025502550255025502550255025502550256025602560256025602560256025602560256025602560256025702570257025702570257025702570257025702570257025802580258025802580258025802580258025802580258025902590259025902590259025902590259025902590259025902600260026002600260026002600260026002600260026002610261026102610261026102610261026102610261026102620262026202620262026202620262026202620262026202630263026302630263026302630263026302630263026302630264026402640264026402640264026402640264026402640265026502650265026502650265026502650265026502650266026602660266026602660266026602660266026602660266026702670267026702670267026702670267026702670267026802680268026802680268026802680268026802680268026902690269026902690269026902690269026902690269026902700270027002700270027002700270027002700270027002710271027102710271027102710271027102710271027102720272027202720272027202720272027202720272027202720273027302730273027302730273027302730273027302730274027402740274027402740274027402740274027402740275027502750275027502750275027502750275027502750275027602760276027602760276027602760276027602760276027702770277027702770277027702770277027702770277027802780278027802780278027802780278027802780278027902790279027902790279027902790279027902790279027902800280028002800280028002800280028002800280028002810281028102810281028102810281028102810281028102820282028202820282028202820282028202820282028202820283028302830283028302830283028302830283028302830284028402840284028402840284028402840284028402840285028502850285028502850285028502850285028502850285028602860286028602860286028602860286028602860286028702870287028702870287028702870287028702870287028802880288028802880288028802880288028802880288028802890289028902890289028902890289028902890289028902900290029002900290029002900290029002900290029002910291029102910291029102910291029102910291029102910292029202920292029202920292029202920292029202920293029302930293029302930293029302930293029302930294029402940294029402940294029402940294029402940295029502950295029502950295029502950295029502950295029602960296029602960296029602960296029602960296029702970297029702970297029702970297029702970297029802980298029802980298029802980298029802980298029802990299029902990299029902990299029902990299029903000300030003000300030003000300030003000300030003010301030103010301030103010301030103010301030103010302030203020302030203020302030203020302030203020303030303030303030303030303030303030303030303030304030403040304030403040304030403040304030403040304030503050305030503050305030503050305030503050305030603060306030603060306030603060306030603060306030703070307030703070307030703070307030703070307030703080308030803080308030803080308030803080308030803090309030903090309030903090309030903090309030903100310031003100310031003100310031003100310031003110311031103110311031103110311031103110311031103110312031203120312031203120312031203120312031203120313031303130313031303130313031303130313031303130314031403140314031403140314031403140314031403140314031503150315031503150315031503150315031503150315031603160316031603160316031603160316031603160316031703170317031703170317031703170317031703170317031703180318031803180318031803180318031803180318031803190319031903190319031903190319031903190319031903200320032003200320032003200320032003200320032003200321032103210321032103210321032103210321032103210322032203220322032203220322032203220322032203220323032303230323032303230323032303230323032303230324032403240324032403240324032403240324032403240324032503250325032503250325032503250325032503250325032603260326032603260326032603260326032603260326032703270327032703270327032703270327032703270327032703280328032803280328032803280328032803280328032803290329032903290329032903290329032903290329032903300330033003300330033003300330033003300330033003300331033103310331033103310331033103310331033103310332033203320332033203320332033203320332033203320333033303330333033303330333033303330333033303330333033403340334033403340334033403340334033403340334033503350335033503350335033503350335033503350335033603360336033603360336033603360336033603360336033603370337033703370337033703370337033703370337033703380338033803380338033803380338033803380338033803390339033903390339033903390339033903390339033903400340034003400340034003400340034003400340034003400341034103410341034103410341034103410341034103410342034203420342034203420342034203420342034203420343034303430343034303430343034303430343034303430343034403440344034403440344034403440344034403440344034503450345034503450345034503450345034503450345034603460346034603460346034603460346034603460346034603470347034703470347034703470347034703470347034703480348034803480348034803480348034803480348034803490349034903490349034903490349034903490349034903490350035003500350035003500350035003500350035003500351035103510351035103510351035103510351035103510352035203520352035203520352035203520352035203520352035303530353035303530353035303530353035303530353035403540354035403540354035403540354035403540354035503550355035503550355035503550355035503550355035603560356035603560356035603560356035603560356035603570357035703570357035703570357035703570357035703580358035803580358035803580358035803580358035803590359035903590359035903590359035903590359035903590360036003600360036003600360036003600360036003600361036103610361036103610361036103610361036103610362036203620362036203620362036203620362036203620362036303630363036303630363036303630363036303630363036403640364036403640364036403640364036403640364036503650365036503650365036503650365036503650365036503660366036603660366036603660366036603660366036603670367036703670367036703670367036703670367036703680368036803680368036803680368036803680368036803680369036903690369036903690369036903690369036903690370037003700370037003700370037003700370037003700371037103710371037103710371037103710371037103710372037203720372037203720372037203720372037203720372037303730373037303730373037303730373037303730373037403740374037403740374037403740374037403740374037503750375037503750375037503750375037503750375037503760376037603760376037603760376037603760376037603770377037703770377037703770377037703770377037703780378037803780378037803780378037803780378037803780379037903790379037903790379037903790379037903790380038003800380038003800380038003800380038003800381038103810381038103810381038103810381038103810381038203820382038203820382038203820382038203820382038303830383038303830383038303830383038303830383038403840384038403840384038403840384038403840384038403850385038503850385038503850385038503850385038503860386038603860386038603860386038603860386038603870387038703870387038703870387038703870387038703880388038803880388038803880388038803880388038803880389038903890389038903890389038903890389038903890390039003900390039003900390039003900390039003900391039103910391039103910391039103910391039103910391039203920392039203920392039203920392039203920392039303930393039303930393039303930393039303930393039403940394039403940394039403940394039403940394039403950395039503950395039503950395039503950395039503960396039603960396039603960396039603960396039603970397039703970397039703970397039703970397039703970398039803980398039803980398039803980398039803980399039903990399039903990399039903990399039903990400040004000400040004000400040004000400040004000400040104010401040104010401040104010401040104010401040204020402040204020402040204020402040204020402040304030403040304030403040304030403040304030403040404040404040404040404040404040404040404040404040404050405040504050405040504050405040504050405040504060406040604060406040604060406"],+ + "oldkeys": { + + "keynames": ["id"], + + "keytypes": ["int4"], + + "keyvalues": [1] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "xpto", + + "oldkeys": { + + "keynames": ["id"], + + "keytypes": ["int4"], + + "keyvalues": [1] + + } + + } + + ] + + } +(3 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":1},{"name":"rand1","type":"double precision","value":11},{"name":"bincol","type":"bytea","value":"0041004100410041004100410041004100410041004100420042004200420042004200420042004200420042004200420043004300430043004300430043004300430043004300430044004400440044004400440044004400440044004400440045004500450045004500450045004500450045004500450045004600460046004600460046004600460046004600460046004700470047004700470047004700470047004700470047004800480048004800480048004800480048004800480048004800490049004900490049004900490049004900490049004900500050005000500050005000500050005000500050005000510051005100510051005100510051005100510051005100510052005200520052005200520052005200520052005200520053005300530053005300530053005300530053005300530054005400540054005400540054005400540054005400540054005500550055005500550055005500550055005500550055005600560056005600560056005600560056005600560056005700570057005700570057005700570057005700570057005800580058005800580058005800580058005800580058005800590059005900590059005900590059005900590059005900600060006000600060006000600060006000600060006000610061006100610061006100610061006100610061006100610062006200620062006200620062006200620062006200620063006300630063006300630063006300630063006300630064006400640064006400640064006400640064006400640064006500650065006500650065006500650065006500650065006600660066006600660066006600660066006600660066006700670067006700670067006700670067006700670067006700680068006800680068006800680068006800680068006800690069006900690069006900690069006900690069006900700070007000700070007000700070007000700070007000700071007100710071007100710071007100710071007100710072007200720072007200720072007200720072007200720073007300730073007300730073007300730073007300730074007400740074007400740074007400740074007400740074007500750075007500750075007500750075007500750075007600760076007600760076007600760076007600760076007700770077007700770077007700770077007700770077007700780078007800780078007800780078007800780078007800790079007900790079007900790079007900790079007900800080008000800080008000800080008000800080008000800081008100810081008100810081008100810081008100810082008200820082008200820082008200820082008200820083008300830083008300830083008300830083008300830083008400840084008400840084008400840084008400840084008500850085008500850085008500850085008500850085008600860086008600860086008600860086008600860086008600870087008700870087008700870087008700870087008700880088008800880088008800880088008800880088008800890089008900890089008900890089008900890089008900900090009000900090009000900090009000900090009000900091009100910091009100910091009100910091009100910092009200920092009200920092009200920092009200920093009300930093009300930093009300930093009300930093009400940094009400940094009400940094009400940094009500950095009500950095009500950095009500950095009600960096009600960096009600960096009600960096009600970097009700970097009700970097009700970097009700980098009800980098009800980098009800980098009800990099009900990099009900990099009900990099009900990100010001000100010001000100010001000100010001000101010101010101010101010101010101010101010101010102010201020102010201020102010201020102010201020102010301030103010301030103010301030103010301030103010401040104010401040104010401040104010401040104010501050105010501050105010501050105010501050105010601060106010601060106010601060106010601060106010601070107010701070107010701070107010701070107010701080108010801080108010801080108010801080108010801090109010901090109010901090109010901090109010901090110011001100110011001100110011001100110011001100111011101110111011101110111011101110111011101110112011201120112011201120112011201120112011201120112011301130113011301130113011301130113011301130113011401140114011401140114011401140114011401140114011501150115011501150115011501150115011501150115011501160116011601160116011601160116011601160116011601170117011701170117011701170117011701170117011701180118011801180118011801180118011801180118011801190119011901190119011901190119011901190119011901190120012001200120012001200120012001200120012001200121012101210121012101210121012101210121012101210122012201220122012201220122012201220122012201220122012301230123012301230123012301230123012301230123012401240124012401240124012401240124012401240124012501250125012501250125012501250125012501250125012501260126012601260126012601260126012601260126012601270127012701270127012701270127012701270127012701280128012801280128012801280128012801280128012801280129012901290129012901290129012901290129012901290130013001300130013001300130013001300130013001300131013101310131013101310131013101310131013101310131013201320132013201320132013201320132013201320132013301330133013301330133013301330133013301330133013401340134013401340134013401340134013401340134013501350135013501350135013501350135013501350135013501360136013601360136013601360136013601360136013601370137013701370137013701370137013701370137013701380138013801380138013801380138013801380138013801380139013901390139013901390139013901390139013901390140014001400140014001400140014001400140014001400141014101410141014101410141014101410141014101410141014201420142014201420142014201420142014201420142014301430143014301430143014301430143014301430143014401440144014401440144014401440144014401440144014401450145014501450145014501450145014501450145014501460146014601460146014601460146014601460146014601470147014701470147014701470147014701470147014701470148014801480148014801480148014801480148014801480149014901490149014901490149014901490149014901490150015001500150015001500150015001500150015001500151015101510151015101510151015101510151015101510151015201520152015201520152015201520152015201520152015301530153015301530153015301530153015301530153015401540154015401540154015401540154015401540154015401550155015501550155015501550155015501550155015501560156015601560156015601560156015601560156015601570157015701570157015701570157015701570157015701570158015801580158015801580158015801580158015801580159015901590159015901590159015901590159015901590160016001600160016001600160016001600160016001600160016101610161016101610161016101610161016101610161016201620162016201620162016201620162016201620162016301630163016301630163016301630163016301630163016301640164016401640164016401640164016401640164016401650165016501650165016501650165016501650165016501660166016601660166016601660166016601660166016601670167016701670167016701670167016701670167016701670168016801680168016801680168016801680168016801680169016901690169016901690169016901690169016901690170017001700170017001700170017001700170017001700170017101710171017101710171017101710171017101710171017201720172017201720172017201720172017201720172017301730173017301730173017301730173017301730173017301740174017401740174017401740174017401740174017401750175017501750175017501750175017501750175017501760176017601760176017601760176017601760176017601760177017701770177017701770177017701770177017701770178017801780178017801780178017801780178017801780179017901790179017901790179017901790179017901790179018001800180018001800180018001800180018001800180018101810181018101810181018101810181018101810181018201820182018201820182018201820182018201820182018301830183018301830183018301830183018301830183018301840184018401840184018401840184018401840184018401850185018501850185018501850185018501850185018501860186018601860186018601860186018601860186018601860187018701870187018701870187018701870187018701870188018801880188018801880188018801880188018801880189018901890189018901890189018901890189018901890189019001900190019001900190019001900190019001900190019101910191019101910191019101910191019101910191019201920192019201920192019201920192019201920192019201930193019301930193019301930193019301930193019301940194019401940194019401940194019401940194019401950195019501950195019501950195019501950195019501950196019601960196019601960196019601960196019601960197019701970197019701970197019701970197019701970198019801980198019801980198019801980198019801980199019901990199019901990199019901990199019901990199020002000200020002000200020002000200020002000200020102010201020102010201020102010201020102010201020202020202020202020202020202020202020202020202020202030203020302030203020302030203020302030203020302040204020402040204020402040204020402040204020402050205020502050205020502050205020502050205020502050206020602060206020602060206020602060206020602060207020702070207020702070207020702070207020702070208020802080208020802080208020802080208020802080208020902090209020902090209020902090209020902090209021002100210021002100210021002100210021002100210021102110211021102110211021102110211021102110211021102120212021202120212021202120212021202120212021202130213021302130213021302130213021302130213021302140214021402140214021402140214021402140214021402150215021502150215021502150215021502150215021502150216021602160216021602160216021602160216021602160217021702170217021702170217021702170217021702170218021802180218021802180218021802180218021802180218021902190219021902190219021902190219021902190219022002200220022002200220022002200220022002200220022102210221022102210221022102210221022102210221022102220222022202220222022202220222022202220222022202230223022302230223022302230223022302230223022302240224022402240224022402240224022402240224022402240225022502250225022502250225022502250225022502250226022602260226022602260226022602260226022602260227022702270227022702270227022702270227022702270227022802280228022802280228022802280228022802280228022902290229022902290229022902290229022902290229023002300230023002300230023002300230023002300230023102310231023102310231023102310231023102310231023102320232023202320232023202320232023202320232023202330233023302330233023302330233023302330233023302340234023402340234023402340234023402340234023402340235023502350235023502350235023502350235023502350236023602360236023602360236023602360236023602360237023702370237023702370237023702370237023702370237023802380238023802380238023802380238023802380238023902390239023902390239023902390239023902390239024002400240024002400240024002400240024002400240024002410241024102410241024102410241024102410241024102420242024202420242024202420242024202420242024202430243024302430243024302430243024302430243024302430244024402440244024402440244024402440244024402440245024502450245024502450245024502450245024502450246024602460246024602460246024602460246024602460247024702470247024702470247024702470247024702470247024802480248024802480248024802480248024802480248024902490249024902490249024902490249024902490249025002500250025002500250025002500250025002500250025002510251025102510251025102510251025102510251025102520252025202520252025202520252025202520252025202530253025302530253025302530253025302530253025302530254025402540254025402540254025402540254025402540255025502550255025502550255025502550255025502550256025602560256025602560256025602560256025602560256025702570257025702570257025702570257025702570257025802580258025802580258025802580258025802580258025902590259025902590259025902590259025902590259025902600260026002600260026002600260026002600260026002610261026102610261026102610261026102610261026102620262026202620262026202620262026202620262026202630263026302630263026302630263026302630263026302630264026402640264026402640264026402640264026402640265026502650265026502650265026502650265026502650266026602660266026602660266026602660266026602660266026702670267026702670267026702670267026702670267026802680268026802680268026802680268026802680268026902690269026902690269026902690269026902690269026902700270027002700270027002700270027002700270027002710271027102710271027102710271027102710271027102720272027202720272027202720272027202720272027202720273027302730273027302730273027302730273027302730274027402740274027402740274027402740274027402740275027502750275027502750275027502750275027502750275027602760276027602760276027602760276027602760276027702770277027702770277027702770277027702770277027802780278027802780278027802780278027802780278027902790279027902790279027902790279027902790279027902800280028002800280028002800280028002800280028002810281028102810281028102810281028102810281028102820282028202820282028202820282028202820282028202820283028302830283028302830283028302830283028302830284028402840284028402840284028402840284028402840285028502850285028502850285028502850285028502850285028602860286028602860286028602860286028602860286028702870287028702870287028702870287028702870287028802880288028802880288028802880288028802880288028802890289028902890289028902890289028902890289028902900290029002900290029002900290029002900290029002910291029102910291029102910291029102910291029102910292029202920292029202920292029202920292029202920293029302930293029302930293029302930293029302930294029402940294029402940294029402940294029402940295029502950295029502950295029502950295029502950295029602960296029602960296029602960296029602960296029702970297029702970297029702970297029702970297029802980298029802980298029802980298029802980298029802990299029902990299029902990299029902990299029903000300030003000300030003000300030003000300030003010301030103010301030103010301030103010301030103010302030203020302030203020302030203020302030203020303030303030303030303030303030303030303030303030304030403040304030403040304030403040304030403040304030503050305030503050305030503050305030503050305030603060306030603060306030603060306030603060306030703070307030703070307030703070307030703070307030703080308030803080308030803080308030803080308030803090309030903090309030903090309030903090309030903100310031003100310031003100310031003100310031003110311031103110311031103110311031103110311031103110312031203120312031203120312031203120312031203120313031303130313031303130313031303130313031303130314031403140314031403140314031403140314031403140314031503150315031503150315031503150315031503150315031603160316031603160316031603160316031603160316031703170317031703170317031703170317031703170317031703180318031803180318031803180318031803180318031803190319031903190319031903190319031903190319031903200320032003200320032003200320032003200320032003200321032103210321032103210321032103210321032103210322032203220322032203220322032203220322032203220323032303230323032303230323032303230323032303230324032403240324032403240324032403240324032403240324032503250325032503250325032503250325032503250325032603260326032603260326032603260326032603260326032703270327032703270327032703270327032703270327032703280328032803280328032803280328032803280328032803290329032903290329032903290329032903290329032903300330033003300330033003300330033003300330033003300331033103310331033103310331033103310331033103310332033203320332033203320332033203320332033203320333033303330333033303330333033303330333033303330333033403340334033403340334033403340334033403340334033503350335033503350335033503350335033503350335033603360336033603360336033603360336033603360336033603370337033703370337033703370337033703370337033703380338033803380338033803380338033803380338033803390339033903390339033903390339033903390339033903400340034003400340034003400340034003400340034003400341034103410341034103410341034103410341034103410342034203420342034203420342034203420342034203420343034303430343034303430343034303430343034303430343034403440344034403440344034403440344034403440344034503450345034503450345034503450345034503450345034603460346034603460346034603460346034603460346034603470347034703470347034703470347034703470347034703480348034803480348034803480348034803480348034803490349034903490349034903490349034903490349034903490350035003500350035003500350035003500350035003500351035103510351035103510351035103510351035103510352035203520352035203520352035203520352035203520352035303530353035303530353035303530353035303530353035403540354035403540354035403540354035403540354035503550355035503550355035503550355035503550355035603560356035603560356035603560356035603560356035603570357035703570357035703570357035703570357035703580358035803580358035803580358035803580358035803590359035903590359035903590359035903590359035903590360036003600360036003600360036003600360036003600361036103610361036103610361036103610361036103610362036203620362036203620362036203620362036203620362036303630363036303630363036303630363036303630363036403640364036403640364036403640364036403640364036503650365036503650365036503650365036503650365036503660366036603660366036603660366036603660366036603670367036703670367036703670367036703670367036703680368036803680368036803680368036803680368036803680369036903690369036903690369036903690369036903690370037003700370037003700370037003700370037003700371037103710371037103710371037103710371037103710372037203720372037203720372037203720372037203720372037303730373037303730373037303730373037303730373037403740374037403740374037403740374037403740374037503750375037503750375037503750375037503750375037503760376037603760376037603760376037603760376037603770377037703770377037703770377037703770377037703780378037803780378037803780378037803780378037803780379037903790379037903790379037903790379037903790380038003800380038003800380038003800380038003800381038103810381038103810381038103810381038103810381038203820382038203820382038203820382038203820382038303830383038303830383038303830383038303830383038403840384038403840384038403840384038403840384038403850385038503850385038503850385038503850385038503860386038603860386038603860386038603860386038603870387038703870387038703870387038703870387038703880388038803880388038803880388038803880388038803880389038903890389038903890389038903890389038903890390039003900390039003900390039003900390039003900391039103910391039103910391039103910391039103910391039203920392039203920392039203920392039203920392039303930393039303930393039303930393039303930393039403940394039403940394039403940394039403940394039403950395039503950395039503950395039503950395039503960396039603960396039603960396039603960396039603970397039703970397039703970397039703970397039703970398039803980398039803980398039803980398039803980399039903990399039903990399039903990399039903990400040004000400040004000400040004000400040004000400040104010401040104010401040104010401040104010401040204020402040204020402040204020402040204020402040304030403040304030403040304030403040304030403040404040404040404040404040404040404040404040404040404050405040504050405040504050405040504050405040504060406040604060406040604060406"}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":1},{"name":"rand1","type":"double precision","value":123.456},{"name":"bincol","type":"bytea","value":"0041004100410041004100410041004100410041004100420042004200420042004200420042004200420042004200420043004300430043004300430043004300430043004300430044004400440044004400440044004400440044004400440045004500450045004500450045004500450045004500450045004600460046004600460046004600460046004600460046004700470047004700470047004700470047004700470047004800480048004800480048004800480048004800480048004800490049004900490049004900490049004900490049004900500050005000500050005000500050005000500050005000510051005100510051005100510051005100510051005100510052005200520052005200520052005200520052005200520053005300530053005300530053005300530053005300530054005400540054005400540054005400540054005400540054005500550055005500550055005500550055005500550055005600560056005600560056005600560056005600560056005700570057005700570057005700570057005700570057005800580058005800580058005800580058005800580058005800590059005900590059005900590059005900590059005900600060006000600060006000600060006000600060006000610061006100610061006100610061006100610061006100610062006200620062006200620062006200620062006200620063006300630063006300630063006300630063006300630064006400640064006400640064006400640064006400640064006500650065006500650065006500650065006500650065006600660066006600660066006600660066006600660066006700670067006700670067006700670067006700670067006700680068006800680068006800680068006800680068006800690069006900690069006900690069006900690069006900700070007000700070007000700070007000700070007000700071007100710071007100710071007100710071007100710072007200720072007200720072007200720072007200720073007300730073007300730073007300730073007300730074007400740074007400740074007400740074007400740074007500750075007500750075007500750075007500750075007600760076007600760076007600760076007600760076007700770077007700770077007700770077007700770077007700780078007800780078007800780078007800780078007800790079007900790079007900790079007900790079007900800080008000800080008000800080008000800080008000800081008100810081008100810081008100810081008100810082008200820082008200820082008200820082008200820083008300830083008300830083008300830083008300830083008400840084008400840084008400840084008400840084008500850085008500850085008500850085008500850085008600860086008600860086008600860086008600860086008600870087008700870087008700870087008700870087008700880088008800880088008800880088008800880088008800890089008900890089008900890089008900890089008900900090009000900090009000900090009000900090009000900091009100910091009100910091009100910091009100910092009200920092009200920092009200920092009200920093009300930093009300930093009300930093009300930093009400940094009400940094009400940094009400940094009500950095009500950095009500950095009500950095009600960096009600960096009600960096009600960096009600970097009700970097009700970097009700970097009700980098009800980098009800980098009800980098009800990099009900990099009900990099009900990099009900990100010001000100010001000100010001000100010001000101010101010101010101010101010101010101010101010102010201020102010201020102010201020102010201020102010301030103010301030103010301030103010301030103010401040104010401040104010401040104010401040104010501050105010501050105010501050105010501050105010601060106010601060106010601060106010601060106010601070107010701070107010701070107010701070107010701080108010801080108010801080108010801080108010801090109010901090109010901090109010901090109010901090110011001100110011001100110011001100110011001100111011101110111011101110111011101110111011101110112011201120112011201120112011201120112011201120112011301130113011301130113011301130113011301130113011401140114011401140114011401140114011401140114011501150115011501150115011501150115011501150115011501160116011601160116011601160116011601160116011601170117011701170117011701170117011701170117011701180118011801180118011801180118011801180118011801190119011901190119011901190119011901190119011901190120012001200120012001200120012001200120012001200121012101210121012101210121012101210121012101210122012201220122012201220122012201220122012201220122012301230123012301230123012301230123012301230123012401240124012401240124012401240124012401240124012501250125012501250125012501250125012501250125012501260126012601260126012601260126012601260126012601270127012701270127012701270127012701270127012701280128012801280128012801280128012801280128012801280129012901290129012901290129012901290129012901290130013001300130013001300130013001300130013001300131013101310131013101310131013101310131013101310131013201320132013201320132013201320132013201320132013301330133013301330133013301330133013301330133013401340134013401340134013401340134013401340134013501350135013501350135013501350135013501350135013501360136013601360136013601360136013601360136013601370137013701370137013701370137013701370137013701380138013801380138013801380138013801380138013801380139013901390139013901390139013901390139013901390140014001400140014001400140014001400140014001400141014101410141014101410141014101410141014101410141014201420142014201420142014201420142014201420142014301430143014301430143014301430143014301430143014401440144014401440144014401440144014401440144014401450145014501450145014501450145014501450145014501460146014601460146014601460146014601460146014601470147014701470147014701470147014701470147014701470148014801480148014801480148014801480148014801480149014901490149014901490149014901490149014901490150015001500150015001500150015001500150015001500151015101510151015101510151015101510151015101510151015201520152015201520152015201520152015201520152015301530153015301530153015301530153015301530153015401540154015401540154015401540154015401540154015401550155015501550155015501550155015501550155015501560156015601560156015601560156015601560156015601570157015701570157015701570157015701570157015701570158015801580158015801580158015801580158015801580159015901590159015901590159015901590159015901590160016001600160016001600160016001600160016001600160016101610161016101610161016101610161016101610161016201620162016201620162016201620162016201620162016301630163016301630163016301630163016301630163016301640164016401640164016401640164016401640164016401650165016501650165016501650165016501650165016501660166016601660166016601660166016601660166016601670167016701670167016701670167016701670167016701670168016801680168016801680168016801680168016801680169016901690169016901690169016901690169016901690170017001700170017001700170017001700170017001700170017101710171017101710171017101710171017101710171017201720172017201720172017201720172017201720172017301730173017301730173017301730173017301730173017301740174017401740174017401740174017401740174017401750175017501750175017501750175017501750175017501760176017601760176017601760176017601760176017601760177017701770177017701770177017701770177017701770178017801780178017801780178017801780178017801780179017901790179017901790179017901790179017901790179018001800180018001800180018001800180018001800180018101810181018101810181018101810181018101810181018201820182018201820182018201820182018201820182018301830183018301830183018301830183018301830183018301840184018401840184018401840184018401840184018401850185018501850185018501850185018501850185018501860186018601860186018601860186018601860186018601860187018701870187018701870187018701870187018701870188018801880188018801880188018801880188018801880189018901890189018901890189018901890189018901890189019001900190019001900190019001900190019001900190019101910191019101910191019101910191019101910191019201920192019201920192019201920192019201920192019201930193019301930193019301930193019301930193019301940194019401940194019401940194019401940194019401950195019501950195019501950195019501950195019501950196019601960196019601960196019601960196019601960197019701970197019701970197019701970197019701970198019801980198019801980198019801980198019801980199019901990199019901990199019901990199019901990199020002000200020002000200020002000200020002000200020102010201020102010201020102010201020102010201020202020202020202020202020202020202020202020202020202030203020302030203020302030203020302030203020302040204020402040204020402040204020402040204020402050205020502050205020502050205020502050205020502050206020602060206020602060206020602060206020602060207020702070207020702070207020702070207020702070208020802080208020802080208020802080208020802080208020902090209020902090209020902090209020902090209021002100210021002100210021002100210021002100210021102110211021102110211021102110211021102110211021102120212021202120212021202120212021202120212021202130213021302130213021302130213021302130213021302140214021402140214021402140214021402140214021402150215021502150215021502150215021502150215021502150216021602160216021602160216021602160216021602160217021702170217021702170217021702170217021702170218021802180218021802180218021802180218021802180218021902190219021902190219021902190219021902190219022002200220022002200220022002200220022002200220022102210221022102210221022102210221022102210221022102220222022202220222022202220222022202220222022202230223022302230223022302230223022302230223022302240224022402240224022402240224022402240224022402240225022502250225022502250225022502250225022502250226022602260226022602260226022602260226022602260227022702270227022702270227022702270227022702270227022802280228022802280228022802280228022802280228022902290229022902290229022902290229022902290229023002300230023002300230023002300230023002300230023102310231023102310231023102310231023102310231023102320232023202320232023202320232023202320232023202330233023302330233023302330233023302330233023302340234023402340234023402340234023402340234023402340235023502350235023502350235023502350235023502350236023602360236023602360236023602360236023602360237023702370237023702370237023702370237023702370237023802380238023802380238023802380238023802380238023902390239023902390239023902390239023902390239024002400240024002400240024002400240024002400240024002410241024102410241024102410241024102410241024102420242024202420242024202420242024202420242024202430243024302430243024302430243024302430243024302430244024402440244024402440244024402440244024402440245024502450245024502450245024502450245024502450246024602460246024602460246024602460246024602460247024702470247024702470247024702470247024702470247024802480248024802480248024802480248024802480248024902490249024902490249024902490249024902490249025002500250025002500250025002500250025002500250025002510251025102510251025102510251025102510251025102520252025202520252025202520252025202520252025202530253025302530253025302530253025302530253025302530254025402540254025402540254025402540254025402540255025502550255025502550255025502550255025502550256025602560256025602560256025602560256025602560256025702570257025702570257025702570257025702570257025802580258025802580258025802580258025802580258025902590259025902590259025902590259025902590259025902600260026002600260026002600260026002600260026002610261026102610261026102610261026102610261026102620262026202620262026202620262026202620262026202630263026302630263026302630263026302630263026302630264026402640264026402640264026402640264026402640265026502650265026502650265026502650265026502650266026602660266026602660266026602660266026602660266026702670267026702670267026702670267026702670267026802680268026802680268026802680268026802680268026902690269026902690269026902690269026902690269026902700270027002700270027002700270027002700270027002710271027102710271027102710271027102710271027102720272027202720272027202720272027202720272027202720273027302730273027302730273027302730273027302730274027402740274027402740274027402740274027402740275027502750275027502750275027502750275027502750275027602760276027602760276027602760276027602760276027702770277027702770277027702770277027702770277027802780278027802780278027802780278027802780278027902790279027902790279027902790279027902790279027902800280028002800280028002800280028002800280028002810281028102810281028102810281028102810281028102820282028202820282028202820282028202820282028202820283028302830283028302830283028302830283028302830284028402840284028402840284028402840284028402840285028502850285028502850285028502850285028502850285028602860286028602860286028602860286028602860286028702870287028702870287028702870287028702870287028802880288028802880288028802880288028802880288028802890289028902890289028902890289028902890289028902900290029002900290029002900290029002900290029002910291029102910291029102910291029102910291029102910292029202920292029202920292029202920292029202920293029302930293029302930293029302930293029302930294029402940294029402940294029402940294029402940295029502950295029502950295029502950295029502950295029602960296029602960296029602960296029602960296029702970297029702970297029702970297029702970297029802980298029802980298029802980298029802980298029802990299029902990299029902990299029902990299029903000300030003000300030003000300030003000300030003010301030103010301030103010301030103010301030103010302030203020302030203020302030203020302030203020303030303030303030303030303030303030303030303030304030403040304030403040304030403040304030403040304030503050305030503050305030503050305030503050305030603060306030603060306030603060306030603060306030703070307030703070307030703070307030703070307030703080308030803080308030803080308030803080308030803090309030903090309030903090309030903090309030903100310031003100310031003100310031003100310031003110311031103110311031103110311031103110311031103110312031203120312031203120312031203120312031203120313031303130313031303130313031303130313031303130314031403140314031403140314031403140314031403140314031503150315031503150315031503150315031503150315031603160316031603160316031603160316031603160316031703170317031703170317031703170317031703170317031703180318031803180318031803180318031803180318031803190319031903190319031903190319031903190319031903200320032003200320032003200320032003200320032003200321032103210321032103210321032103210321032103210322032203220322032203220322032203220322032203220323032303230323032303230323032303230323032303230324032403240324032403240324032403240324032403240324032503250325032503250325032503250325032503250325032603260326032603260326032603260326032603260326032703270327032703270327032703270327032703270327032703280328032803280328032803280328032803280328032803290329032903290329032903290329032903290329032903300330033003300330033003300330033003300330033003300331033103310331033103310331033103310331033103310332033203320332033203320332033203320332033203320333033303330333033303330333033303330333033303330333033403340334033403340334033403340334033403340334033503350335033503350335033503350335033503350335033603360336033603360336033603360336033603360336033603370337033703370337033703370337033703370337033703380338033803380338033803380338033803380338033803390339033903390339033903390339033903390339033903400340034003400340034003400340034003400340034003400341034103410341034103410341034103410341034103410342034203420342034203420342034203420342034203420343034303430343034303430343034303430343034303430343034403440344034403440344034403440344034403440344034503450345034503450345034503450345034503450345034603460346034603460346034603460346034603460346034603470347034703470347034703470347034703470347034703480348034803480348034803480348034803480348034803490349034903490349034903490349034903490349034903490350035003500350035003500350035003500350035003500351035103510351035103510351035103510351035103510352035203520352035203520352035203520352035203520352035303530353035303530353035303530353035303530353035403540354035403540354035403540354035403540354035503550355035503550355035503550355035503550355035603560356035603560356035603560356035603560356035603570357035703570357035703570357035703570357035703580358035803580358035803580358035803580358035803590359035903590359035903590359035903590359035903590360036003600360036003600360036003600360036003600361036103610361036103610361036103610361036103610362036203620362036203620362036203620362036203620362036303630363036303630363036303630363036303630363036403640364036403640364036403640364036403640364036503650365036503650365036503650365036503650365036503660366036603660366036603660366036603660366036603670367036703670367036703670367036703670367036703680368036803680368036803680368036803680368036803680369036903690369036903690369036903690369036903690370037003700370037003700370037003700370037003700371037103710371037103710371037103710371037103710372037203720372037203720372037203720372037203720372037303730373037303730373037303730373037303730373037403740374037403740374037403740374037403740374037503750375037503750375037503750375037503750375037503760376037603760376037603760376037603760376037603770377037703770377037703770377037703770377037703780378037803780378037803780378037803780378037803780379037903790379037903790379037903790379037903790380038003800380038003800380038003800380038003800381038103810381038103810381038103810381038103810381038203820382038203820382038203820382038203820382038303830383038303830383038303830383038303830383038403840384038403840384038403840384038403840384038403850385038503850385038503850385038503850385038503860386038603860386038603860386038603860386038603870387038703870387038703870387038703870387038703880388038803880388038803880388038803880388038803880389038903890389038903890389038903890389038903890390039003900390039003900390039003900390039003900391039103910391039103910391039103910391039103910391039203920392039203920392039203920392039203920392039303930393039303930393039303930393039303930393039403940394039403940394039403940394039403940394039403950395039503950395039503950395039503950395039503960396039603960396039603960396039603960396039603970397039703970397039703970397039703970397039703970398039803980398039803980398039803980398039803980399039903990399039903990399039903990399039903990400040004000400040004000400040004000400040004000400040104010401040104010401040104010401040104010401040204020402040204020402040204020402040204020402040304030403040304030403040304030403040304030403040404040404040404040404040404040404040404040404040404050405040504050405040504050405040504050405040504060406040604060406040604060406"}],"identity":[{"name":"id","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"xpto","identity":[{"name":"id","type":"integer","value":1}]} + {"action":"C"} +(9 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/cmdline.out b/contrib/wal2json/expected/cmdline.out new file mode 100644 index 000000000..aeb09eb59 --- /dev/null +++ b/contrib/wal2json/expected/cmdline.out @@ -0,0 +1,103 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'nosuchopt', '42'); +ERROR: option "nosuchopt" = "42" is unknown + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-unchanged-toast', '1'); +ERROR: parameter "include-unchanged-toast" was deprecated + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'filter-origins', '16, 27, 123'); + data +------ +(0 rows) + + +-- don't include not-null constraint by default +CREATE TABLE table_optional ( +a smallserial, +b integer, +c boolean not null, +PRIMARY KEY(a) +); +NOTICE: CREATE TABLE will create implicit sequence "table_optional_a_seq" for serial column "table_optional.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_optional_pkey" for table "table_optional" +CREATE TABLE +INSERT INTO table_optional (b, c) VALUES(NULL, TRUE); +INSERT 0 1 +UPDATE table_optional SET b = 123 WHERE a = 1; +UPDATE 1 +DELETE FROM table_optional WHERE a = 1; +DELETE 1 +DROP TABLE table_optional; +DROP TABLE +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0', 'include-not-null', '1'); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"change":[]} + {"change":[{"kind":"insert","schema":"public","table":"table_optional","columnnames":["a","b","c"],"columntypes":["smallint","integer","boolean"],"columnoptionals":[false,true,false],"columnvalues":[1,null,true]}]} + {"change":[{"kind":"update","schema":"public","table":"table_optional","columnnames":["a","b","c"],"columntypes":["smallint","integer","boolean"],"columnoptionals":[false,true,false],"columnvalues":[1,123,true],"oldkeys":{"keynames":["a"],"keytypes":["smallint"],"keyvalues":[1]}}]} + {"change":[{"kind":"delete","schema":"public","table":"table_optional","oldkeys":{"keynames":["a"],"keytypes":["smallint"],"keyvalues":[1]}}]} + {"change":[]} +(5 rows) + + +-- By default don't write in chunks +CREATE TABLE x (); +ERROR: must have at least one column +DROP TABLE x; +ERROR: table "x" does not exist +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0'); + data +------ +(0 rows) + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0', 'write-in-chunks', '1'); + data +------ +(0 rows) + + +-- By default don't write xids +CREATE TABLE gimmexid (id integer PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "gimmexid_pkey" for table "gimmexid" +CREATE TABLE +INSERT INTO gimmexid values (1); +INSERT 0 1 +DROP TABLE gimmexid; +DROP TABLE +SELECT max(((data::json) -> 'xid')::text::int) < txid_current() FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '1'); + ?column? +---------- + t +(1 row) + +SELECT max(((data::json) -> 'xid')::text::int) + 10 > txid_current() FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '1'); + ?column? +---------- + t +(1 row) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL) where ((data::json) -> 'xid') IS NOT NULL; + data +------ +(0 rows) + + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/default.out b/contrib/wal2json/expected/default.out new file mode 100644 index 000000000..62799a673 --- /dev/null +++ b/contrib/wal2json/expected/default.out @@ -0,0 +1,82 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +CREATE TABLE w2j_default (a serial, b integer DEFAULT 6, c text DEFAULT 'wal2json', d timestamp DEFAULT '2020-07-12 11:55:30', e integer DEFAULT NULL, f integer, PRIMARY KEY(a)); +NOTICE: CREATE TABLE will create implicit sequence "w2j_default_a_seq" for serial column "w2j_default.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "w2j_default_pkey" for table "w2j_default" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO w2j_default (b, c ,d, e, f) VALUES(2, 'test', '2020-03-01 08:09:00', 80, 10); +INSERT 0 1 +INSERT INTO w2j_default DEFAULT VALUES; +INSERT 0 1 +UPDATE w2j_default SET b = 3 WHERE a = 1; +UPDATE 1 + +-- without include-default parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); + data +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"change":[{"kind":"insert","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columnvalues":[1,2,"test","2020-03-01 08:09:00",80,10]}]} + {"change":[{"kind":"insert","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columnvalues":[2,6,"wal2json","2020-07-12 11:55:30",null,null]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columnvalues":[1,3,"test","2020-03-01 08:09:00",80,10],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} +(3 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"integer","value":2},{"name":"c","type":"text","value":"test"},{"name":"d","type":"timestamp without time zone","value":"2020-03-01 08:09:00"},{"name":"e","type":"integer","value":80},{"name":"f","type":"integer","value":10}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":2},{"name":"b","type":"integer","value":6},{"name":"c","type":"text","value":"wal2json"},{"name":"d","type":"timestamp without time zone","value":"2020-07-12 11:55:30"},{"name":"e","type":"integer","value":null},{"name":"f","type":"integer","value":null}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"integer","value":3},{"name":"c","type":"text","value":"test"},{"name":"d","type":"timestamp without time zone","value":"2020-03-01 08:09:00"},{"name":"e","type":"integer","value":80},{"name":"f","type":"integer","value":10}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} +(9 rows) + + +-- with include-default parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-default', '1'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"change":[{"kind":"insert","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columndefaults":["nextval('w2j_default_a_seq'::regclass)","6","'wal2json'::text","'2020-07-12 11:55:30'::timestamp without time zone",null,null],"columnvalues":[1,2,"test","2020-03-01 08:09:00",80,10]}]} + {"change":[{"kind":"insert","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columndefaults":["nextval('w2j_default_a_seq'::regclass)","6","'wal2json'::text","'2020-07-12 11:55:30'::timestamp without time zone",null,null],"columnvalues":[2,6,"wal2json","2020-07-12 11:55:30",null,null]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_default","columnnames":["a","b","c","d","e","f"],"columntypes":["integer","integer","text","timestamp without time zone","integer","integer"],"columndefaults":["nextval('w2j_default_a_seq'::regclass)","6","'wal2json'::text","'2020-07-12 11:55:30'::timestamp without time zone",null,null],"columnvalues":[1,3,"test","2020-03-01 08:09:00",80,10],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} +(3 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-default', '1'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":1,"default":"nextval('w2j_default_a_seq'::regclass)"},{"name":"b","type":"integer","value":2,"default":"6"},{"name":"c","type":"text","value":"test","default":"'wal2json'::text"},{"name":"d","type":"timestamp without time zone","value":"2020-03-01 08:09:00","default":"'2020-07-12 11:55:30'::timestamp without time zone"},{"name":"e","type":"integer","value":80,"default":null},{"name":"f","type":"integer","value":10,"default":null}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":2,"default":"nextval('w2j_default_a_seq'::regclass)"},{"name":"b","type":"integer","value":6,"default":"6"},{"name":"c","type":"text","value":"wal2json","default":"'wal2json'::text"},{"name":"d","type":"timestamp without time zone","value":"2020-07-12 11:55:30","default":"'2020-07-12 11:55:30'::timestamp without time zone"},{"name":"e","type":"integer","value":null,"default":null},{"name":"f","type":"integer","value":null,"default":null}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_default","columns":[{"name":"a","type":"integer","value":1,"default":"nextval('w2j_default_a_seq'::regclass)"},{"name":"b","type":"integer","value":3,"default":"6"},{"name":"c","type":"text","value":"test","default":"'wal2json'::text"},{"name":"d","type":"timestamp without time zone","value":"2020-03-01 08:09:00","default":"'2020-07-12 11:55:30'::timestamp without time zone"},{"name":"e","type":"integer","value":80,"default":null},{"name":"f","type":"integer","value":10,"default":null}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} +(9 rows) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + +DROP TABLE w2j_default; +DROP TABLE diff --git a/contrib/wal2json/expected/delete1.out b/contrib/wal2json/expected/delete1.out new file mode 100644 index 000000000..f60446bf2 --- /dev/null +++ b/contrib/wal2json/expected/delete1.out @@ -0,0 +1,165 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS table_with_pk; +NOTICE: table "table_with_pk" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +NOTICE: table "table_without_pk" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +NOTICE: table "table_with_unique" does not exist, skipping +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- DELETE: no pk +DELETE FROM table_without_pk WHERE b = 1; +DELETE 1 + +-- DELETE: pk +DELETE FROM table_with_pk WHERE b = 1; +DELETE 1 + +-- DELETE: unique +DELETE FROM table_with_unique WHERE b = 1; +DELETE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +----------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_without_pk" } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk", + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"],+ + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_unique" } + + ] + + } +(3 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +WARNING: no tuple identifier for DELETE in table "public"."table_without_pk" +WARNING: no tuple identifier for DELETE in table "public"."table_with_unique" + data +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"table_with_pk","identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(7 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/delete2.out b/contrib/wal2json/expected/delete2.out new file mode 100644 index 000000000..4a6932742 --- /dev/null +++ b/contrib/wal2json/expected/delete2.out @@ -0,0 +1,202 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- DELETE: REPLICA IDENTITY NOTHING +ALTER TABLE table_with_pk REPLICA IDENTITY NOTHING; +ALTER TABLE +DELETE FROM table_with_pk WHERE b = 1; +DELETE 1 +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_without_pk REPLICA IDENTITY NOTHING; +ALTER TABLE +DELETE FROM table_without_pk WHERE b = 1; +DELETE 1 +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_with_unique REPLICA IDENTITY NOTHING; +ALTER TABLE +DELETE FROM table_with_unique WHERE b = 1; +DELETE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk" }+ + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_without_pk" }+ + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_unique" }+ + ] + + } + { + + "change": [ + + ] + + } +(9 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +WARNING: no tuple identifier for DELETE in table "public"."table_with_pk" +WARNING: no tuple identifier for DELETE in table "public"."table_without_pk" +WARNING: no tuple identifier for DELETE in table "public"."table_with_unique" + data +---------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(18 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/delete3.out b/contrib/wal2json/expected/delete3.out new file mode 100644 index 000000000..333e80547 --- /dev/null +++ b/contrib/wal2json/expected/delete3.out @@ -0,0 +1,216 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- DELETE: REPLICA IDENTITY FULL +ALTER TABLE table_with_pk REPLICA IDENTITY FULL; +ALTER TABLE +DELETE FROM table_with_pk WHERE b = 1; +DELETE 1 +DELETE FROM table_with_pk WHERE n = true; +DELETE 1 +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_without_pk REPLICA IDENTITY FULL; +ALTER TABLE +DELETE FROM table_without_pk WHERE b = 1; +DELETE 1 +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_with_unique REPLICA IDENTITY FULL; +ALTER TABLE +DELETE FROM table_with_unique WHERE b = 1; +DELETE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk", + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk", + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [2, 4, 5, 6, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_without_pk", + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_unique", + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } +(10 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +ERROR: table does not have primary key or replica identity +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/delete4.out b/contrib/wal2json/expected/delete4.out new file mode 100644 index 000000000..13f876d12 --- /dev/null +++ b/contrib/wal2json/expected/delete4.out @@ -0,0 +1,117 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', false, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 4.56, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- DELETE: REPLICA IDENTITY INDEX +ALTER TABLE table_with_unique REPLICA IDENTITY USING INDEX table_with_unique_g_n_key; +ALTER TABLE +DELETE FROM table_with_unique WHERE b = 1; +DELETE 1 +DELETE FROM table_with_unique WHERE n = true; +DELETE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +----------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_unique", + + "oldkeys": { + + "keynames": ["g", "n"], + + "keytypes": ["float8", "bool"],+ + "keyvalues": [1.23, false] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_unique", + + "oldkeys": { + + "keynames": ["g", "n"], + + "keytypes": ["float8", "bool"],+ + "keyvalues": [4.56, true] + + } + + } + + ] + + } + { + + "change": [ + + ] + + } +(4 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"table_with_unique","identity":[{"name":"g","type":"double precision","value":1.23},{"name":"n","type":"boolean","value":false}]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"table_with_unique","identity":[{"name":"g","type":"double precision","value":4.56},{"name":"n","type":"boolean","value":true}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(10 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/filtertable.out b/contrib/wal2json/expected/filtertable.out new file mode 100644 index 000000000..70d3eac53 --- /dev/null +++ b/contrib/wal2json/expected/filtertable.out @@ -0,0 +1,295 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS filter_table_1; +NOTICE: table "filter_table_1" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS filter_table_2; +NOTICE: table "filter_table_2" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS filter_table_3; +NOTICE: table "filter_table_3" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS filter_table_4; +NOTICE: table "filter_table_4" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "Filter_table_5"; +NOTICE: table "Filter_table_5" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "filter table_6"; +NOTICE: table "filter table_6" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "filter.table_7"; +NOTICE: table "filter.table_7" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "filter,table_8"; +NOTICE: table "filter,table_8" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "filter""table_9"; +NOTICE: table "filter"table_9" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS " filter_table_10"; +NOTICE: table " filter_table_10" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS "*"; +NOTICE: table "*" does not exist, skipping +DROP TABLE +DROP SCHEMA IF EXISTS filter_schema_1 CASCADE; +NOTICE: schema "filter_schema_1" does not exist, skipping +DROP SCHEMA +DROP SCHEMA IF EXISTS filter_schema_2 CASCADE; +NOTICE: schema "filter_schema_2" does not exist, skipping +DROP SCHEMA +DROP SCHEMA IF EXISTS "*" CASCADE; +NOTICE: schema "*" does not exist, skipping +DROP SCHEMA + +CREATE SCHEMA filter_schema_1; +CREATE SCHEMA +CREATE SCHEMA filter_schema_2; +CREATE SCHEMA +CREATE SCHEMA "*"; +CREATE SCHEMA + +CREATE TABLE filter_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_1_pkey" for table "filter_table_1" +CREATE TABLE +CREATE TABLE filter_schema_1.filter_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_1_pkey" for table "filter_table_1" +CREATE TABLE +CREATE TABLE filter_schema_1.filter_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_2_pkey" for table "filter_table_2" +CREATE TABLE +CREATE TABLE filter_schema_2.filter_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_1_pkey" for table "filter_table_1" +CREATE TABLE +CREATE TABLE filter_schema_2.filter_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_2_pkey" for table "filter_table_2" +CREATE TABLE +CREATE TABLE filter_schema_2.filter_table_3 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_3_pkey" for table "filter_table_3" +CREATE TABLE +CREATE TABLE filter_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_2_pkey" for table "filter_table_2" +CREATE TABLE +CREATE TABLE filter_table_3 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_3_pkey" for table "filter_table_3" +CREATE TABLE +CREATE TABLE filter_table_4 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_4_pkey" for table "filter_table_4" +CREATE TABLE +CREATE TABLE "Filter_table_5" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "Filter_table_5_pkey" for table "Filter_table_5" +CREATE TABLE +CREATE TABLE "filter table_6" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter table_6_pkey" for table "filter table_6" +CREATE TABLE +CREATE TABLE "filter.table_7" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter.table_7_pkey" for table "filter.table_7" +CREATE TABLE +CREATE TABLE "filter,table_8" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter,table_8_pkey" for table "filter,table_8" +CREATE TABLE +CREATE TABLE "filter""table_9" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter"table_9_pkey" for table "filter"table_9" +CREATE TABLE +CREATE TABLE " filter_table_10" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index " filter_table_10_pkey" for table " filter_table_10" +CREATE TABLE +CREATE TABLE "*" (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "*_pkey" for table "*" +CREATE TABLE +CREATE TABLE "*".filter_table_0 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filter_table_0_pkey" for table "filter_table_0" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO filter_table_1 (a, b) VALUES(1, 'public.filter_table_1'); +INSERT 0 1 +INSERT INTO filter_schema_1.filter_table_1 (a, b) VALUES(1, 'filter_schema_1.filter_table_1'); +INSERT 0 1 +INSERT INTO filter_schema_1.filter_table_2 (a, b) VALUES(1, 'filter_schema_1.filter_table_2'); +INSERT 0 1 +INSERT INTO filter_schema_2.filter_table_1 (a, b) VALUES(1, 'filter_schema_2.filter_table_1'); +INSERT 0 1 +INSERT INTO filter_schema_2.filter_table_2 (a, b) VALUES(1, 'filter_schema_2.filter_table_2'); +INSERT 0 1 +INSERT INTO filter_schema_2.filter_table_3 (a, b) VALUES(1, 'filter_schema_2.filter_table_3'); +INSERT 0 1 +INSERT INTO filter_table_2 (a, b) VALUES(1, 'public.filter_table_2'); +INSERT 0 1 +INSERT INTO filter_table_3 (a, b) VALUES(1, 'public.filter_table_3'); +INSERT 0 1 +INSERT INTO filter_table_4 (a, b) VALUES(1, 'public.filter_table_4'); +INSERT 0 1 +INSERT INTO "Filter_table_5" (a, b) VALUES(1, 'public.Filter_table_5'); +INSERT 0 1 +INSERT INTO "filter table_6" (a, b) VALUES(1, 'public.filter table_6'); +INSERT 0 1 +INSERT INTO "filter.table_7" (a, b) VALUES(1, 'public.filter.table_7'); +INSERT 0 1 +INSERT INTO "filter,table_8" (a, b) VALUES(1, 'public.filter,table_8'); +INSERT 0 1 +INSERT INTO "filter""table_9" (a, b) VALUES(1, 'public.filter"table_9'); +INSERT 0 1 +INSERT INTO " filter_table_10" (a, b) VALUES(1, 'public. filter_table_10'); +INSERT 0 1 +INSERT INTO "*" (a, b) VALUES(1, 'public.*'); +INSERT 0 1 +INSERT INTO "*".filter_table_0 (a, b) VALUES(1, '*.filter_table_0'); +INSERT 0 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'filter-tables', ' foo.bar,*.filter_table_1 ,filter_schema_2.* , public.filter_table_3 , public.Filter_table_5, public.filter\ table_6, public.filter\.table_7 , public.filter\,table_8 , public.filter"table_9, *.\ filter_table_10 , public.\* , \*.filter_table_0 '); + data +------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "filter_schema_1", + + "table": "filter_table_2", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "filter_schema_1.filter_table_2"]+ + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "filter_table_2", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "public.filter_table_2"] + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "filter_table_4", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "public.filter_table_4"] + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } +(17 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'filter-tables', ' foo.bar,*.filter_table_1 ,filter_schema_2.* , public.filter_table_3 , public.Filter_table_5, public.filter\ table_6, public.filter\.table_7 , public.filter\,table_8 , public.filter"table_9, *.\ filter_table_10 , public.\* , \*.filter_table_0 '); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"filter_schema_1","table":"filter_table_2","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"filter_schema_1.filter_table_2"}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"filter_table_2","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"public.filter_table_2"}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"filter_table_4","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"public.filter_table_4"}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(37 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/include_domain_data_type.out b/contrib/wal2json/expected/include_domain_data_type.out new file mode 100644 index 000000000..b441a91c2 --- /dev/null +++ b/contrib/wal2json/expected/include_domain_data_type.out @@ -0,0 +1,228 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +CREATE DOMAIN wal2json_domain_1 AS bigint; +CREATE DOMAIN +CREATE DOMAIN wal2json_domain_2 AS numeric(5,3); +CREATE DOMAIN +CREATE DOMAIN wal2json_domain_3 AS varchar(30); +CREATE DOMAIN +CREATE DOMAIN wal2json_domain_4 AS bit varying(20); +CREATE DOMAIN + +CREATE TABLE test_wal2json_5 ( +a smallserial, +b smallint, +c int, +d wal2json_domain_1, +e wal2json_domain_2, +f real not null, +g double precision, +h char(10), +i wal2json_domain_3, +j text, +k wal2json_domain_4, +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "test_wal2json_5_a_seq" for serial column "test_wal2json_5.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_wal2json_5_pkey" for table "test_wal2json_5" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO test_wal2json_5 (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +UPDATE test_wal2json_5 SET f = -f WHERE b = 1; +UPDATE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "wal2json_domain_1", "wal2json_domain_2", "real", "double precision", "character(10)", "wal2json_domain_3", "text", "wal2json_domain_4", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, "3", "3.540", 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "wal2json_domain_1", "wal2json_domain_2", "real", "double precision", "character(10)", "wal2json_domain_3", "text", "wal2json_domain_4", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, "3", "3.540", -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["smallint", "integer", "wal2json_domain_1"], + + "keyvalues": [1, 2, "3"] + + } + + } + + ] + + } +(2 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1'); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["smallint", "integer", "bigint"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } +(2 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0', 'include-typmod', '0'); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "wal2json_domain_1", "wal2json_domain_2", "float4", "float8", "bpchar", "wal2json_domain_3", "text", "wal2json_domain_4", "timestamp", "timestamp", "bool", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, "3", "3.540", 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "wal2json_domain_1", "wal2json_domain_2", "float4", "float8", "bpchar", "wal2json_domain_3", "text", "wal2json_domain_4", "timestamp", "timestamp", "bool", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, "3", "3.540", -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "wal2json_domain_1"], + + "keyvalues": [1, 2, "3"] + + } + + } + + ] + + } +(2 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1', 'include-typmod', '0'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "test_wal2json_5", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"],+ + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } +(2 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '0'); + data +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_domain_1","value":"3"},{"name":"e","type":"wal2json_domain_2","value":"3.540"},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"wal2json_domain_3","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"wal2json_domain_4","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_domain_1","value":"3"},{"name":"e","type":"wal2json_domain_2","value":"3.540"},{"name":"f","type":"real","value":-876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"wal2json_domain_3","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"wal2json_domain_4","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"wal2json_domain_1","value":"3"}]} + {"action":"C"} +(6 rows) + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '1'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"},{"name":"e","type":"numeric(5,3)","value":"3.540"},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"test_wal2json_5","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"},{"name":"e","type":"numeric(5,3)","value":"3.540"},{"name":"f","type":"real","value":-876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":"3"}]} + {"action":"C"} +(6 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + +DROP TABLE test_wal2json_5; +DROP TABLE +DROP DOMAIN wal2json_domain_1; +ERROR: DOMAIN is not yet supported. +DROP DOMAIN wal2json_domain_2; +ERROR: DOMAIN is not yet supported. +DROP DOMAIN wal2json_domain_3; +ERROR: DOMAIN is not yet supported. +DROP DOMAIN wal2json_domain_4; +ERROR: DOMAIN is not yet supported. diff --git a/contrib/wal2json/expected/include_lsn.out b/contrib/wal2json/expected/include_lsn.out new file mode 100644 index 000000000..b42aa19e1 --- /dev/null +++ b/contrib/wal2json/expected/include_lsn.out @@ -0,0 +1,58 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS tbl; +NOTICE: table "tbl" does not exist, skipping +DROP TABLE +CREATE TABLE tbl (id int); +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- One row should have one record and one nextlsn +INSERT INTO tbl VALUES (1); +INSERT 0 1 +SELECT count(*) = 1, count(distinct ((data::json)->'nextlsn')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows should have two records and two nextlsns +INSERT INTO tbl VALUES (2); +INSERT 0 1 +INSERT INTO tbl VALUES (3); +INSERT 0 1 +SELECT count(*) = 2, count(distinct ((data::json)->'nextlsn')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows in one transaction should have one record and one nextlsn +INSERT INTO tbl VALUES (4), (5); +INSERT 0 2 +SELECT count(*) = 1, count(distinct ((data::json)->'nextlsn')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + diff --git a/contrib/wal2json/expected/include_timestamp.out b/contrib/wal2json/expected/include_timestamp.out new file mode 100644 index 000000000..1e10c59c5 --- /dev/null +++ b/contrib/wal2json/expected/include_timestamp.out @@ -0,0 +1,57 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS tbl; +DROP TABLE +CREATE TABLE tbl (id int); +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- One row should have one record and one timestmap +INSERT INTO tbl VALUES (1); +INSERT 0 1 +SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows should have two records and two timestamps +INSERT INTO tbl VALUES (2); +INSERT 0 1 +INSERT INTO tbl VALUES (3); +INSERT 0 1 +SELECT count(*) = 2, count(distinct ((data::json)->'timestamp')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows in one transaction should have one record and one timestamp +INSERT INTO tbl VALUES (4), (5); +INSERT 0 2 +SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + diff --git a/contrib/wal2json/expected/include_xids.out b/contrib/wal2json/expected/include_xids.out new file mode 100644 index 000000000..a41fee7d6 --- /dev/null +++ b/contrib/wal2json/expected/include_xids.out @@ -0,0 +1,57 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS tbl; +DROP TABLE +CREATE TABLE tbl (id int); +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- One row should have one record and one xids +INSERT INTO tbl VALUES (1); +INSERT 0 1 +SELECT count(*) = 1, count(distinct ((data::json)->'xid')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows should have two records and two xids +INSERT INTO tbl VALUES (2); +INSERT 0 1 +INSERT INTO tbl VALUES (3); +INSERT 0 1 +SELECT count(*) = 2, count(distinct ((data::json)->'xid')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + ?column? | ?column? +----------+---------- + t | t +(1 row) + + +-- Two rows in one transaction should have one record and one xid +INSERT INTO tbl VALUES (4), (5); +INSERT 0 2 +SELECT count(*) = 2, count(distinct ((data::json)->'xid')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + ?column? | ?column? +----------+---------- + f | t +(1 row) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + diff --git a/contrib/wal2json/expected/insert1.out b/contrib/wal2json/expected/insert1.out new file mode 100644 index 000000000..f7cdc89ae --- /dev/null +++ b/contrib/wal2json/expected/insert1.out @@ -0,0 +1,168 @@ +-- this is the first test (CREATE EXTENSION, no DROP TABLE) +LOAD 'test_decoding'; +ERROR: LOAD statement is not yet supported. + +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq1" for serial column "table_with_pk.a" +ERROR: relation "table_with_pk" already exists in schema "public" + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq1" for serial column "table_without_pk.a" +ERROR: relation "table_without_pk" already exists in schema "public" + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq1" for serial column "table_with_unique.a" +ERROR: relation "table_with_unique" already exists in schema "public" + +CREATE SCHEMA "test ""schema"; +CREATE SCHEMA + +CREATE TABLE "test ""schema"."test "" with 'quotes'" ( + id serial primary key, + "col spaces" int, + "col""quotes" int +); +NOTICE: CREATE TABLE will create implicit sequence "test " with 'quotes'_id_seq" for serial column "test " with 'quotes'.id" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test " with 'quotes'_pkey" for table "test " with 'quotes'" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- INSERT +BEGIN; +BEGIN +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO "test ""schema"."test "" with 'quotes'" VALUES (1, 2, 3); +INSERT 0 1 +COMMIT; +COMMIT + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [3, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "table_without_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [2, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [3, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + ,{ + + "kind": "insert", + + "schema": "test \"schema", + + "table": "test \" with 'quotes'", + + "columnnames": ["id", "col spaces", "col\"quotes"], + + "columntypes": ["int4", "int4", "int4"], + + "columnvalues": [1, 2, 3] + + } + + ] + + } +(1 row) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"table_with_pk","columns":[{"name":"a","type":"smallint","value":3},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}]} + {"action":"I","schema":"public","table":"table_without_pk","columns":[{"name":"a","type":"smallint","value":2},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}]} + {"action":"I","schema":"public","table":"table_with_unique","columns":[{"name":"a","type":"smallint","value":3},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}]} + {"action":"I","schema":"test \"schema","table":"test \" with 'quotes'","columns":[{"name":"id","type":"integer","value":1},{"name":"col spaces","type":"integer","value":2},{"name":"col\"quotes","type":"integer","value":3}]} + {"action":"C"} +(6 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/message.out b/contrib/wal2json/expected/message.out new file mode 100644 index 000000000..bc58e29f0 --- /dev/null +++ b/contrib/wal2json/expected/message.out @@ -0,0 +1,69 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +SELECT 'msg1' FROM pg_logical_emit_message(true, 'wal2json', 'this is a\ message'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 20 +SELECT 'msg2' FROM pg_logical_emit_message(false, 'wal2json', 'this is "another" message'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 20 + +SELECT 'msg3' FROM pg_logical_emit_message(false, 'wal2json', E'\\x546170697275732074657272657374726973'::bytea); +ERROR: function pg_logical_emit_message(boolean, unknown, bytea) does not exist at character 20 +SELECT 'msg4' FROM pg_logical_emit_message(false, 'wal2json', E'\\x5072696f646f6e746573206d6178696d7573'::bytea); +ERROR: function pg_logical_emit_message(boolean, unknown, bytea) does not exist at character 20 +SELECT 'msg5' FROM pg_logical_emit_message(false, 'wal2json', E'\\x436172796f6361722062726173696c69656e7365'::bytea); +ERROR: function pg_logical_emit_message(boolean, unknown, bytea) does not exist at character 20 + +BEGIN; +BEGIN +SELECT 'msg6' FROM pg_logical_emit_message(true, 'wal2json', 'this message will not be printed'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 20 +SELECT 'msg7' FROM pg_logical_emit_message(false, 'wal2json', 'this message will be printed even if the transaction is rollbacked'); +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +ROLLBACK; +ROLLBACK + +BEGIN; +BEGIN +SELECT 'msg8' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #1'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 20 +SELECT 'msg9' FROM pg_logical_emit_message(false, 'wal2json', 'this message will be printed before message #1'); +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +SELECT 'msg10' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #2'); +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +COMMIT; +ROLLBACK + +SELECT 'msg11' FROM pg_logical_emit_message(true, 'filtered', 'this message will be filtered'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 21 +SELECT 'msg12' FROM pg_logical_emit_message(true, 'added1', 'this message will be printed'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 21 +SELECT 'msg13' FROM pg_logical_emit_message(true, 'added2', 'this message will be filtered'); +ERROR: function pg_logical_emit_message(boolean, unknown, unknown) does not exist at character 21 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'filter-msg-prefixes', 'foo, filtered, bar', 'add-msg-prefixes', 'added1, added3, wal2json'); + data +------ +(0 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'filter-msg-prefixes', 'foo, filtered, bar', 'add-msg-prefixes', 'added1, added3, wal2json'); + data +------ +(0 rows) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/pk.out b/contrib/wal2json/expected/pk.out new file mode 100644 index 000000000..dcf37539a --- /dev/null +++ b/contrib/wal2json/expected/pk.out @@ -0,0 +1,266 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +CREATE TABLE w2j_pk_with_pk ( +a int, +b timestamp, +c text, +d boolean, +e numeric(5,3), +PRIMARY KEY(b, d, e) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "w2j_pk_with_pk_pkey" for table "w2j_pk_with_pk" +CREATE TABLE + +CREATE TABLE w2j_pk_without_pk ( +a int, +b timestamp, +c text, +d boolean, +e numeric(5,3) +); +CREATE TABLE + +CREATE TABLE w2j_pk_with_ri ( +a int NOT NULL, +b timestamp, +c text, +d boolean, +e numeric(5,3), +UNIQUE(a) +); +NOTICE: CREATE TABLE / UNIQUE will create implicit index "w2j_pk_with_ri_a_key" for table "w2j_pk_with_ri" +CREATE TABLE +ALTER TABLE w2j_pk_with_ri REPLICA IDENTITY USING INDEX w2j_pk_with_ri_a_key; +ALTER TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO w2j_pk_with_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56); +INSERT 0 1 +UPDATE w2j_pk_with_pk SET a = 456, c = 'Panthera Onca', d = false; +UPDATE 1 +DELETE FROM w2j_pk_with_pk; +DELETE 1 + +INSERT INTO w2j_pk_without_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56); +INSERT 0 1 +UPDATE w2j_pk_without_pk SET a = 456, c = 'Panthera Onca', d = false; +UPDATE 1 +DELETE FROM w2j_pk_without_pk; +DELETE 1 + +INSERT INTO w2j_pk_with_ri (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Inia Araguaiaensis', true, 4.56); +INSERT 0 1 +UPDATE w2j_pk_with_ri SET a = 456, c = 'Panthera Onca', d = false; +UPDATE 1 +DELETE FROM w2j_pk_with_ri; +DELETE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0', 'include-pk', '1'); + data +---------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "w2j_pk_with_pk", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [123, "2020-04-26 16:23:59", "Melanosuchus Niger", true, 4.560],+ + "pk": { + + "pknames": ["b", "d", "e"], + + "pktypes": ["timestamp", "bool", "numeric"] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "w2j_pk_with_pk", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [456, "2020-04-26 16:23:59", "Panthera Onca", false, 4.560], + + "pk": { + + "pknames": ["b", "d", "e"], + + "pktypes": ["timestamp", "bool", "numeric"] + + }, + + "oldkeys": { + + "keynames": ["b", "d", "e"], + + "keytypes": ["timestamp", "bool", "numeric"], + + "keyvalues": ["2020-04-26 16:23:59", true, 4.560] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "w2j_pk_with_pk", + + "pk": { + + "pknames": ["b", "d", "e"], + + "pktypes": ["timestamp", "bool", "numeric"] + + }, + + "oldkeys": { + + "keynames": ["b", "d", "e"], + + "keytypes": ["timestamp", "bool", "numeric"], + + "keyvalues": ["2020-04-26 16:23:59", false, 4.560] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "w2j_pk_without_pk", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [123, "2020-04-26 16:23:59", "Melanosuchus Niger", true, 4.560] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "w2j_pk_without_pk", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [456, "2020-04-26 16:23:59", "Panthera Onca", false, 4.560], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e"], + + "keytypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "keyvalues": [456, "2020-04-26 16:23:59", "Panthera Onca", false, 4.560]+ + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "w2j_pk_without_pk" } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "w2j_pk_with_ri", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [123, "2020-04-26 16:23:59", "Inia Araguaiaensis", true, 4.560],+ + "pk": { + + "pknames": ["a"], + + "pktypes": ["int4"] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "w2j_pk_with_ri", + + "columnnames": ["a", "b", "c", "d", "e"], + + "columntypes": ["int4", "timestamp", "text", "bool", "numeric"], + + "columnvalues": [456, "2020-04-26 16:23:59", "Panthera Onca", false, 4.560], + + "pk": { + + "pknames": ["a"], + + "pktypes": ["int4"] + + }, + + "oldkeys": { + + "keynames": ["a"], + + "keytypes": ["int4"], + + "keyvalues": [123] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "w2j_pk_with_ri", + + "pk": { + + "pknames": ["a"], + + "pktypes": ["int4"] + + }, + + "oldkeys": { + + "keynames": ["a"], + + "keytypes": ["int4"], + + "keyvalues": [456] + + } + + } + + ] + + } +(9 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-pk', '1'); +WARNING: no tuple identifier for UPDATE in table "public"."w2j_pk_without_pk" +WARNING: no tuple identifier for DELETE in table "public"."w2j_pk_without_pk" + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_pk_with_pk","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"c","type":"text","value":"Melanosuchus Niger"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_pk_with_pk","columns":[{"name":"a","type":"integer","value":456},{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"c","type":"text","value":"Panthera Onca"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"identity":[{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"w2j_pk_with_pk","identity":[{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_pk_without_pk","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"c","type":"text","value":"Melanosuchus Niger"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_pk_with_ri","columns":[{"name":"a","type":"integer","value":123},{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"c","type":"text","value":"Inia Araguaiaensis"},{"name":"d","type":"boolean","value":true},{"name":"e","type":"numeric(5,3)","value":4.560}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_pk_with_ri","columns":[{"name":"a","type":"integer","value":456},{"name":"b","type":"timestamp without time zone","value":"2020-04-26 16:23:59"},{"name":"c","type":"text","value":"Panthera Onca"},{"name":"d","type":"boolean","value":false},{"name":"e","type":"numeric(5,3)","value":4.560}],"identity":[{"name":"a","type":"integer","value":123}],"pk":[]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"w2j_pk_with_ri","identity":[{"name":"a","type":"integer","value":456}],"pk":[]} + {"action":"C"} +(25 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + +DROP TABLE w2j_pk_with_pk; +DROP TABLE +DROP TABLE w2j_pk_without_pk; +DROP TABLE +DROP TABLE w2j_pk_with_ri; +DROP TABLE diff --git a/contrib/wal2json/expected/position.out b/contrib/wal2json/expected/position.out new file mode 100644 index 000000000..290c1294c --- /dev/null +++ b/contrib/wal2json/expected/position.out @@ -0,0 +1,104 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +CREATE TABLE w2j_position (a integer, b integer, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "w2j_position_pkey" for table "w2j_position" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO w2j_position (a, b) VALUES(1,2); +INSERT 0 1 +UPDATE w2j_position SET b = 3 WHERE a = 1; +UPDATE 1 +ALTER TABLE w2j_position ADD COLUMN c integer; +ALTER TABLE +ALTER TABLE w2j_position DROP COLUMN b; +ALTER TABLE +INSERT INTO w2j_position (a, c) VALUES(5,6); +INSERT 0 1 +UPDATE w2j_position SET c = 7 WHERE a = 5; +UPDATE 1 + +-- without include-column-position parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"change":[{"kind":"insert","schema":"public","table":"w2j_position","columnnames":["a","b"],"columntypes":["integer","integer"],"columnvalues":[1,2]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_position","columnnames":["a","b"],"columntypes":["integer","integer"],"columnvalues":[1,3],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} + {"change":[]} + {"change":[]} + {"change":[{"kind":"insert","schema":"public","table":"w2j_position","columnnames":["a","c"],"columntypes":["integer","integer"],"columnvalues":[5,6]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_position","columnnames":["a","c"],"columntypes":["integer","integer"],"columnvalues":[5,7],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[5]}}]} +(6 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"integer","value":2}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"integer","value":3}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":5},{"name":"c","type":"integer","value":6}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":5},{"name":"c","type":"integer","value":7}],"identity":[{"name":"a","type":"integer","value":5}]} + {"action":"C"} +(16 rows) + + +-- with include-column-position parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-column-positions', '1'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"change":[{"kind":"insert","schema":"public","table":"w2j_position","columnnames":["a","b"],"columntypes":["integer","integer"],"columnpositions":[1,2],"columnvalues":[1,2]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_position","columnnames":["a","b"],"columntypes":["integer","integer"],"columnpositions":[1,2],"columnvalues":[1,3],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[1]}}]} + {"change":[]} + {"change":[]} + {"change":[{"kind":"insert","schema":"public","table":"w2j_position","columnnames":["a","c"],"columntypes":["integer","integer"],"columnpositions":[1,3],"columnvalues":[5,6]}]} + {"change":[{"kind":"update","schema":"public","table":"w2j_position","columnnames":["a","c"],"columntypes":["integer","integer"],"columnpositions":[1,3],"columnvalues":[5,7],"oldkeys":{"keynames":["a"],"keytypes":["integer"],"keyvalues":[5]}}]} +(6 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-column-positions', '1'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":1,"position":1},{"name":"b","type":"integer","value":2,"position":2}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":1,"position":1},{"name":"b","type":"integer","value":3,"position":2}],"identity":[{"name":"a","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":5,"position":1},{"name":"c","type":"integer","value":6,"position":3}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"w2j_position","columns":[{"name":"a","type":"integer","value":5,"position":1},{"name":"c","type":"integer","value":7,"position":3}],"identity":[{"name":"a","type":"integer","value":5}]} + {"action":"C"} +(16 rows) + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/savepoint.out b/contrib/wal2json/expected/savepoint.out new file mode 100644 index 000000000..e0f2fc4f5 --- /dev/null +++ b/contrib/wal2json/expected/savepoint.out @@ -0,0 +1,60 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +CREATE TABLE xpto (a SERIAL PRIMARY KEY, b text); +NOTICE: CREATE TABLE will create implicit sequence "xpto_a_seq" for serial column "xpto.a" +ERROR: relation "xpto" already exists in schema "public" + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO xpto (b) VALUES('john'); +ERROR: column "b" of relation "xpto" does not exist at character 19 +INSERT INTO xpto (b) VALUES('smith'); +ERROR: column "b" of relation "xpto" does not exist at character 19 +INSERT INTO xpto (b) VALUES('robert'); +ERROR: column "b" of relation "xpto" does not exist at character 19 + +BEGIN; +BEGIN +INSERT INTO xpto (b) VALUES('marie'); +ERROR: column "b" of relation "xpto" does not exist at character 19 +SAVEPOINT sp1; +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +INSERT INTO xpto (b) VALUES('ernesto'); +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +SAVEPOINT sp2; +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +INSERT INTO xpto (b) VALUES('peter'); -- discard +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +SAVEPOINT sp3; +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +INSERT INTO xpto (b) VALUES('albert'); -- discard +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +ROLLBACK TO SAVEPOINT sp2; +ERROR: no such savepoint +RELEASE SAVEPOINT sp1; +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +INSERT INTO xpto (b) VALUES('francisco'); +ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q] +END; +ROLLBACK + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +------ +(0 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/selecttable.out b/contrib/wal2json/expected/selecttable.out new file mode 100644 index 000000000..627f7b6c4 --- /dev/null +++ b/contrib/wal2json/expected/selecttable.out @@ -0,0 +1,195 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS select_table_1; +NOTICE: table "select_table_1" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS select_table_2; +NOTICE: table "select_table_2" does not exist, skipping +DROP TABLE +DROP TABLE IF EXISTS select_table_3; +NOTICE: table "select_table_3" does not exist, skipping +DROP TABLE +DROP SCHEMA IF EXISTS select_schema_1 CASCADE; +NOTICE: schema "select_schema_1" does not exist, skipping +DROP SCHEMA +DROP SCHEMA IF EXISTS select_schema_2 CASCADE; +NOTICE: schema "select_schema_2" does not exist, skipping +DROP SCHEMA + +CREATE SCHEMA select_schema_1; +CREATE SCHEMA +CREATE SCHEMA select_schema_2; +CREATE SCHEMA + +CREATE TABLE select_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_1_pkey" for table "select_table_1" +CREATE TABLE +CREATE TABLE select_schema_1.select_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_1_pkey" for table "select_table_1" +CREATE TABLE +CREATE TABLE select_schema_1.select_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_2_pkey" for table "select_table_2" +CREATE TABLE +CREATE TABLE select_schema_2.select_table_1 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_1_pkey" for table "select_table_1" +CREATE TABLE +CREATE TABLE select_schema_2.select_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_2_pkey" for table "select_table_2" +CREATE TABLE +CREATE TABLE select_schema_2.select_table_3 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_3_pkey" for table "select_table_3" +CREATE TABLE +CREATE TABLE select_table_2 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_2_pkey" for table "select_table_2" +CREATE TABLE +CREATE TABLE select_table_3 (a integer, b text, primary key(a)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "select_table_3_pkey" for table "select_table_3" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO select_table_1 (a, b) VALUES(1, 'public.select_table_1'); +INSERT 0 1 +INSERT INTO select_schema_1.select_table_1 (a, b) VALUES(1, 'select_schema_1.select_table_1'); +INSERT 0 1 +INSERT INTO select_schema_1.select_table_2 (a, b) VALUES(1, 'select_schema_1.select_table_2'); +INSERT 0 1 +INSERT INTO select_schema_2.select_table_1 (a, b) VALUES(1, 'select_schema_2.select_table_1'); +INSERT 0 1 +INSERT INTO select_schema_2.select_table_2 (a, b) VALUES(1, 'select_schema_2.select_table_2'); +INSERT 0 1 +INSERT INTO select_schema_2.select_table_3 (a, b) VALUES(1, 'select_schema_2.select_table_3'); +INSERT 0 1 +INSERT INTO select_table_2 (a, b) VALUES(1, 'public.select_table_2'); +INSERT 0 1 +INSERT INTO select_table_3 (a, b) VALUES(1, 'public.select_table_3'); +INSERT 0 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'add-tables', ' foo.bar,*.select_table_1 ,select_schema_2.* , public.select_table_3 '); + data +------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "select_table_1", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "public.select_table_1"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "select_schema_1", + + "table": "select_table_1", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "select_schema_1.select_table_1"]+ + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "select_schema_2", + + "table": "select_table_1", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "select_schema_2.select_table_1"]+ + } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "select_schema_2", + + "table": "select_table_2", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "select_schema_2.select_table_2"]+ + } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "select_schema_2", + + "table": "select_table_3", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "select_schema_2.select_table_3"]+ + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "select_table_3", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"], + + "columnvalues": [1, "public.select_table_3"] + + } + + ] + + } +(8 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'add-tables', ' foo.bar,*.select_table_1 ,select_schema_2.* , public.select_table_3 '); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"I","schema":"public","table":"select_table_1","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"public.select_table_1"}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"select_schema_1","table":"select_table_1","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"select_schema_1.select_table_1"}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"select_schema_2","table":"select_table_1","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"select_schema_2.select_table_1"}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"select_schema_2","table":"select_table_2","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"select_schema_2.select_table_2"}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"select_schema_2","table":"select_table_3","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"select_schema_2.select_table_3"}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"select_table_3","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"public.select_table_3"}]} + {"action":"C"} +(22 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + + diff --git a/contrib/wal2json/expected/specialvalue.out b/contrib/wal2json/expected/specialvalue.out new file mode 100644 index 000000000..3059f0a09 --- /dev/null +++ b/contrib/wal2json/expected/specialvalue.out @@ -0,0 +1,88 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS xpto; +DROP TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +CREATE TABLE xpto (a SERIAL PRIMARY KEY, b bool, c varchar(60), d real); +NOTICE: CREATE TABLE will create implicit sequence "xpto_a_seq" for serial column "xpto.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "xpto_pkey" for table "xpto" +CREATE TABLE +COMMIT; +WARNING: there is no transaction in progress +COMMIT + +BEGIN; +BEGIN +INSERT INTO xpto (b, c, d) VALUES('t', 'test1', '+inf'); +INSERT 0 1 +INSERT INTO xpto (b, c, d) VALUES('f', 'test2', 'nan'); +INSERT 0 1 +INSERT INTO xpto (b, c, d) VALUES(NULL, 'null', '-inf'); +INSERT 0 1 +INSERT INTO xpto (b, c, d) VALUES(TRUE, E'valid: '' " \\ / \b \f \n \r \t \u207F \u967F invalid: \\g \\k end', 123.456); +INSERT 0 1 +COMMIT; +COMMIT + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["a", "b", "c", "d"], + + "columntypes": ["int4", "bool", "varchar", "float4"], + + "columnvalues": [1, true, "test1", null] + + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["a", "b", "c", "d"], + + "columntypes": ["int4", "bool", "varchar", "float4"], + + "columnvalues": [2, false, "test2", null] + + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["a", "b", "c", "d"], + + "columntypes": ["int4", "bool", "varchar", "float4"], + + "columnvalues": [3, null, "null", null] + + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["a", "b", "c", "d"], + + "columntypes": ["int4", "bool", "varchar", "float4"], + + "columnvalues": [4, true, "valid: ' \" \\ / \b \f \n \r \t ⁿ 陿 invalid: \\g \\k end", 123.456]+ + } + + ] + + } +(2 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/toast.out b/contrib/wal2json/expected/toast.out new file mode 100644 index 000000000..6cdaf30e5 --- /dev/null +++ b/contrib/wal2json/expected/toast.out @@ -0,0 +1,154 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS xpto; +DROP TABLE +DROP SEQUENCE IF EXISTS xpto_rand_seq; +DROP SEQUENCE + +CREATE SEQUENCE xpto_rand_seq START 11 INCREMENT 997; +CREATE SEQUENCE +CREATE TABLE xpto ( +id serial primary key, +toasted_col1 text, +rand1 float8 DEFAULT nextval('xpto_rand_seq'), +toasted_col2 text, +rand2 float8 DEFAULT nextval('xpto_rand_seq') +); +NOTICE: CREATE TABLE will create implicit sequence "xpto_id_seq" for serial column "xpto.id" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "xpto_pkey" for table "xpto" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- uncompressed external toast data +INSERT INTO xpto (toasted_col1, toasted_col2) SELECT string_agg(g.i::text, ''), string_agg((g.i*2)::text, '') FROM generate_series(1, 2000) g(i); +INSERT 0 1 + +-- compressed external toast data +INSERT INTO xpto (toasted_col2) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i); +INSERT 0 1 + +-- update of existing column +UPDATE xpto SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i)) WHERE id = 1; +UPDATE 1 + +UPDATE xpto SET rand1 = 123.456 WHERE id = 1; +UPDATE 1 + +DELETE FROM xpto WHERE id = 1; +DELETE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "toasted_col1", "rand1", "toasted_col2", "rand2"], + + "columntypes": ["int4", "text", "float8", "text", "float8"], + + "columnvalues": [1, "12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000", 11, "24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000", 1008] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "toasted_col1", "rand1", "toasted_col2", "rand2"], + + "columntypes": ["int4", "text", "float8", "text", "float8"], + + "columnvalues": [2, null, 2005, "0001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500", 3002]+ + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "toasted_col1", "rand1", "toasted_col2", "rand2"], + + "columntypes": ["int4", "text", "float8", "text", "float8"], + + "columnvalues": [1, "12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000", 11, "24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000", 1008], + + "oldkeys": { + + "keynames": ["id"], + + "keytypes": ["int4"], + + "keyvalues": [1] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "xpto", + + "columnnames": ["id", "toasted_col1", "rand1", "toasted_col2", "rand2"], + + "columntypes": ["int4", "text", "float8", "text", "float8"], + + "columnvalues": [1, "12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000", 123.456, "24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000", 1008], + + "oldkeys": { + + "keynames": ["id"], + + "keytypes": ["int4"], + + "keyvalues": [1] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "xpto", + + "oldkeys": { + + "keynames": ["id"], + + "keytypes": ["int4"], + + "keyvalues": [1] + + } + + } + + ] + + } +(5 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"action":"B"} + {"action":"I","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":1},{"name":"toasted_col1","type":"text","value":"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000"},{"name":"rand1","type":"double precision","value":11},{"name":"toasted_col2","type":"text","value":"24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000"},{"name":"rand2","type":"double precision","value":1008}]} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":2},{"name":"toasted_col1","type":"text","value":null},{"name":"rand1","type":"double precision","value":2005},{"name":"toasted_col2","type":"text","value":"0001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500"},{"name":"rand2","type":"double precision","value":3002}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":1},{"name":"toasted_col1","type":"text","value":"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000"},{"name":"rand1","type":"double precision","value":11},{"name":"toasted_col2","type":"text","value":"24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000"},{"name":"rand2","type":"double precision","value":1008}],"identity":[{"name":"id","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"xpto","columns":[{"name":"id","type":"integer","value":1},{"name":"toasted_col1","type":"text","value":"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000"},{"name":"rand1","type":"double precision","value":123.456},{"name":"toasted_col2","type":"text","value":"24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000"},{"name":"rand2","type":"double precision","value":1008}],"identity":[{"name":"id","type":"integer","value":1}]} + {"action":"C"} + {"action":"B"} + {"action":"D","schema":"public","table":"xpto","identity":[{"name":"id","type":"integer","value":1}]} + {"action":"C"} +(15 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/truncate.out b/contrib/wal2json/expected/truncate.out new file mode 100644 index 000000000..2015ade28 --- /dev/null +++ b/contrib/wal2json/expected/truncate.out @@ -0,0 +1,102 @@ +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +CREATE TABLE table_truncate_1 (a integer, b text); +CREATE TABLE +CREATE TABLE table_truncate_2 (a integer, b text); +CREATE TABLE +CREATE TABLE table_truncate_3 (a integer, b text); +CREATE TABLE +CREATE TABLE table_truncate_4 (a integer, b text); +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +TRUNCATE table_truncate_1; +TRUNCATE TABLE + +BEGIN; +BEGIN +TRUNCATE table_truncate_2; +TRUNCATE TABLE +INSERT INTO table_truncate_1 (a, b) VALUES(1, 'test1'); +INSERT 0 1 +INSERT INTO table_truncate_3 (a, b) VALUES(2, 'test2'); +INSERT 0 1 +TRUNCATE table_truncate_3; +TRUNCATE TABLE +INSERT INTO table_truncate_3 (a, b) VALUES(3, 'test3'); +INSERT 0 1 +COMMIT; +COMMIT + +BEGIN; +BEGIN +TRUNCATE table_truncate_4; +TRUNCATE TABLE +ROLLBACK; +ROLLBACK + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1'); + data +------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "table_truncate_1", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"],+ + "columnvalues": [1, "test1"] + + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "table_truncate_3", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"],+ + "columnvalues": [2, "test2"] + + } + + ,{ + + "kind": "insert", + + "schema": "public", + + "table": "table_truncate_3", + + "columnnames": ["a", "b"], + + "columntypes": ["integer", "text"],+ + "columnvalues": [3, "test3"] + + } + + ] + + } +(2 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"I","schema":"public","table":"table_truncate_1","columns":[{"name":"a","type":"integer","value":1},{"name":"b","type":"text","value":"test1"}]} + {"action":"I","schema":"public","table":"table_truncate_3","columns":[{"name":"a","type":"integer","value":2},{"name":"b","type":"text","value":"test2"}]} + {"action":"I","schema":"public","table":"table_truncate_3","columns":[{"name":"a","type":"integer","value":3},{"name":"b","type":"text","value":"test3"}]} + {"action":"C"} +(7 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/typmod.out b/contrib/wal2json/expected/typmod.out new file mode 100644 index 000000000..400ca971c --- /dev/null +++ b/contrib/wal2json/expected/typmod.out @@ -0,0 +1,153 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +UPDATE table_with_pk SET f = -f WHERE b = 1; +UPDATE 1 + +-- UPDATE: pk change +DELETE FROM table_with_pk WHERE b = 1; +DELETE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1'); + data +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["smallint", "smallint", "integer", "bigint", "numeric(5,3)", "real", "double precision", "character(10)", "character varying(30)", "text", "bit varying(20)", "timestamp without time zone", "timestamp(0) without time zone", "boolean", "json", "tsvector"],+ + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["smallint", "integer", "bigint"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk", + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["smallint", "integer", "bigint"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } +(3 rows) + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + { + + "change": [ + + { + + "kind": "insert", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"] + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"],+ + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "delete", + + "schema": "public", + + "table": "table_with_pk", + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } +(3 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/update1.out b/contrib/wal2json/expected/update1.out new file mode 100644 index 000000000..46567647b --- /dev/null +++ b/contrib/wal2json/expected/update1.out @@ -0,0 +1,209 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- UPDATE: no pk +UPDATE table_without_pk SET f = -f WHERE b = 1; +UPDATE 1 + +-- UPDATE: no pk change +UPDATE table_with_pk SET f = -f WHERE b = 1; +UPDATE 1 + +-- UPDATE: pk change +UPDATE table_with_pk SET b = -b WHERE b = 1; +UPDATE 1 + +-- UPDATE: unique +UPDATE table_with_unique SET n = false WHERE b = 1; +UPDATE 1 + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_without_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, -1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["b", "c", "d"], + + "keytypes": ["int2", "int4", "int8"], + + "keyvalues": [1, 2, 3] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", false, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", false, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } +(4 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +WARNING: no tuple identifier for UPDATE in table "public"."table_without_pk" +WARNING: no tuple identifier for UPDATE in table "public"."table_with_unique" + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"table_with_pk","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":-876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"table_with_pk","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":-1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":-876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":2},{"name":"d","type":"bigint","value":3}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(10 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/update2.out b/contrib/wal2json/expected/update2.out new file mode 100644 index 000000000..bc28ca444 --- /dev/null +++ b/contrib/wal2json/expected/update2.out @@ -0,0 +1,229 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- UPDATE: REPLICA IDENTITY NOTHING +ALTER TABLE table_with_pk REPLICA IDENTITY NOTHING; +ALTER TABLE +UPDATE table_with_pk SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_without_pk REPLICA IDENTITY NOTHING; +ALTER TABLE +UPDATE table_without_pk SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_with_unique REPLICA IDENTITY NOTHING; +ALTER TABLE +UPDATE table_with_unique SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_without_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } +(9 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +WARNING: no tuple identifier for UPDATE in table "public"."table_with_pk" +WARNING: no tuple identifier for UPDATE in table "public"."table_without_pk" +WARNING: no tuple identifier for UPDATE in table "public"."table_with_unique" + data +---------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(18 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/update3.out b/contrib/wal2json/expected/update3.out new file mode 100644 index 000000000..16131b44b --- /dev/null +++ b/contrib/wal2json/expected/update3.out @@ -0,0 +1,207 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_pk_a_seq" for serial column "table_with_pk.a" +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "table_with_pk_pkey" for table "table_with_pk" +CREATE TABLE + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); +NOTICE: CREATE TABLE will create implicit sequence "table_without_pk_a_seq" for serial column "table_without_pk.a" +CREATE TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- UPDATE: REPLICA IDENTITY FULL +ALTER TABLE table_with_pk REPLICA IDENTITY FULL; +ALTER TABLE +UPDATE table_with_pk SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_without_pk REPLICA IDENTITY FULL; +ALTER TABLE +UPDATE table_without_pk SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; +ALTER TABLE + +ALTER TABLE table_with_unique REPLICA IDENTITY FULL; +ALTER TABLE +UPDATE table_with_unique SET f = -f WHERE b = 1; +UPDATE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_without_pk", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, 2, 3, 3.540, -876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "keytypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "keyvalues": [1, 1, 2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"]+ + } + + } + + ] + + } + { + + "change": [ + + ] + + } +(9 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +ERROR: table does not have primary key or replica identity +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/expected/update4.out b/contrib/wal2json/expected/update4.out new file mode 100644 index 000000000..bf6af2cac --- /dev/null +++ b/contrib/wal2json/expected/update4.out @@ -0,0 +1,126 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET +SET extra_float_digits = 0; +SET + +DROP TABLE IF EXISTS table_with_unique; +DROP TABLE + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); +NOTICE: CREATE TABLE will create implicit sequence "table_with_unique_a_seq" for serial column "table_with_unique.a" +NOTICE: CREATE TABLE / UNIQUE will create implicit index "table_with_unique_g_n_key" for table "table_with_unique" +CREATE TABLE + +-- INSERT +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', false, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 4.56, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT 0 1 + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + ?column? +---------- + init +(1 row) + + +-- UPDATE: REPLICA IDENTITY USING INDEX +ALTER TABLE table_with_unique REPLICA IDENTITY USING INDEX table_with_unique_g_n_key; +ALTER TABLE +-- FIXME não apresenta valor correto de g +UPDATE table_with_unique SET c = -c WHERE b = 1; +UPDATE 1 +UPDATE table_with_unique SET g = -g WHERE n = true; +UPDATE 1 +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; +ALTER TABLE + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + { + + "change": [ + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [1, 1, -2, 3, 3.540, 876.5635, 1.23, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", false, "{ \"a\": 123 }", "'Old' 'Parr'"],+ + "oldkeys": { + + "keynames": ["g", "n"], + + "keytypes": ["float8", "bool"], + + "keyvalues": [1.23, false] + + } + + } + + ] + + } + { + + "change": [ + + { + + "kind": "update", + + "schema": "public", + + "table": "table_with_unique", + + "columnnames": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"], + + "columntypes": ["int2", "int2", "int4", "int8", "numeric", "float4", "float8", "bpchar", "varchar", "text", "varbit", "timestamp", "timestamp", "bool", "json", "tsvector"], + + "columnvalues": [2, 4, 5, 6, 3.540, 876.5635, -4.56, "teste ", "testando", "um texto longo", "001110010101010", "2013-11-02 17:30:52", "2013-02-04 00:00:00", true, "{ \"a\": 123 }", "'Old' 'Parr'"], + + "oldkeys": { + + "keynames": ["g", "n"], + + "keytypes": ["float8", "bool"], + + "keyvalues": [4.56, true] + + } + + } + + ] + + } + { + + "change": [ + + ] + + } +(4 rows) + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + data +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"action":"B"} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"table_with_unique","columns":[{"name":"a","type":"smallint","value":1},{"name":"b","type":"smallint","value":1},{"name":"c","type":"integer","value":-2},{"name":"d","type":"bigint","value":3},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":1.23},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":false},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"g","type":"double precision","value":1.23},{"name":"n","type":"boolean","value":false}]} + {"action":"C"} + {"action":"B"} + {"action":"U","schema":"public","table":"table_with_unique","columns":[{"name":"a","type":"smallint","value":2},{"name":"b","type":"smallint","value":4},{"name":"c","type":"integer","value":5},{"name":"d","type":"bigint","value":6},{"name":"e","type":"numeric(5,3)","value":3.540},{"name":"f","type":"real","value":876.5635},{"name":"g","type":"double precision","value":-4.56},{"name":"h","type":"character(10)","value":"teste "},{"name":"i","type":"character varying(30)","value":"testando"},{"name":"j","type":"text","value":"um texto longo"},{"name":"k","type":"bit varying(20)","value":"001110010101010"},{"name":"l","type":"timestamp without time zone","value":"2013-11-02 17:30:52"},{"name":"m","type":"timestamp(0) without time zone","value":"2013-02-04 00:00:00"},{"name":"n","type":"boolean","value":true},{"name":"o","type":"json","value":"{ \"a\": 123 }"},{"name":"p","type":"tsvector","value":"'Old' 'Parr'"}],"identity":[{"name":"g","type":"double precision","value":4.56},{"name":"n","type":"boolean","value":true}]} + {"action":"C"} + {"action":"B"} + {"action":"C"} +(10 rows) + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + ?column? +---------- + stop +(1 row) + diff --git a/contrib/wal2json/sql/actions.sql b/contrib/wal2json/sql/actions.sql new file mode 100644 index 000000000..86745e8d6 --- /dev/null +++ b/contrib/wal2json/sql/actions.sql @@ -0,0 +1,23 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- actions +CREATE TABLE actions (a integer primary key); +INSERT INTO actions (a) VALUES(1); +UPDATE actions SET a = 2 WHERE a = 1; +DELETE FROM actions WHERE a = 2; +TRUNCATE TABLE actions; +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert, foo, delete'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'insert'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'delete'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'truncate'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'actions', 'update, truncate'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/bytea.sql b/contrib/wal2json/sql/bytea.sql new file mode 100644 index 000000000..0be948518 --- /dev/null +++ b/contrib/wal2json/sql/bytea.sql @@ -0,0 +1,25 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS xpto; +DROP SEQUENCE IF EXISTS xpto_rand_seq; + +CREATE SEQUENCE xpto_rand_seq START 11 INCREMENT 997; +CREATE TABLE xpto ( +id serial primary key, +rand1 float8 DEFAULT nextval('xpto_rand_seq'), +bincol bytea +); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO xpto (bincol) SELECT decode(string_agg(to_char(round(g.i * 0.08122019), 'FM0000'), ''), 'hex') FROM generate_series(500, 5000) g(i); +UPDATE xpto SET rand1 = 123.456 WHERE id = 1; +DELETE FROM xpto WHERE id = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/cmdline.sql b/contrib/wal2json/sql/cmdline.sql new file mode 100644 index 000000000..7cc4ace13 --- /dev/null +++ b/contrib/wal2json/sql/cmdline.sql @@ -0,0 +1,42 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'nosuchopt', '42'); + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-unchanged-toast', '1'); + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'filter-origins', '16, 27, 123'); + +-- don't include not-null constraint by default +CREATE TABLE table_optional ( +a smallserial, +b integer, +c boolean not null, +PRIMARY KEY(a) +); +INSERT INTO table_optional (b, c) VALUES(NULL, TRUE); +UPDATE table_optional SET b = 123 WHERE a = 1; +DELETE FROM table_optional WHERE a = 1; +DROP TABLE table_optional; +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0', 'include-not-null', '1'); + +-- By default don't write in chunks +CREATE TABLE x (); +DROP TABLE x; +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0'); +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '0', 'write-in-chunks', '1'); + +-- By default don't write xids +CREATE TABLE gimmexid (id integer PRIMARY KEY); +INSERT INTO gimmexid values (1); +DROP TABLE gimmexid; +SELECT max(((data::json) -> 'xid')::text::int) < txid_current() FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '1'); +SELECT max(((data::json) -> 'xid')::text::int) + 10 > txid_current() FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL) where ((data::json) -> 'xid') IS NOT NULL; + + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/default.sql b/contrib/wal2json/sql/default.sql new file mode 100644 index 000000000..8d3d107ef --- /dev/null +++ b/contrib/wal2json/sql/default.sql @@ -0,0 +1,24 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +CREATE TABLE w2j_default (a serial, b integer DEFAULT 6, c text DEFAULT 'wal2json', d timestamp DEFAULT '2020-07-12 11:55:30', e integer DEFAULT NULL, f integer, PRIMARY KEY(a)); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO w2j_default (b, c ,d, e, f) VALUES(2, 'test', '2020-03-01 08:09:00', 80, 10); +INSERT INTO w2j_default DEFAULT VALUES; +UPDATE w2j_default SET b = 3 WHERE a = 1; + +-- without include-default parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + +-- with include-default parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-default', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-default', '1'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + +DROP TABLE w2j_default; diff --git a/contrib/wal2json/sql/delete1.sql b/contrib/wal2json/sql/delete1.sql new file mode 100644 index 000000000..ae1354370 --- /dev/null +++ b/contrib/wal2json/sql/delete1.sql @@ -0,0 +1,87 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- DELETE: no pk +DELETE FROM table_without_pk WHERE b = 1; + +-- DELETE: pk +DELETE FROM table_with_pk WHERE b = 1; + +-- DELETE: unique +DELETE FROM table_with_unique WHERE b = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/delete2.sql b/contrib/wal2json/sql/delete2.sql new file mode 100644 index 000000000..002357476 --- /dev/null +++ b/contrib/wal2json/sql/delete2.sql @@ -0,0 +1,91 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- DELETE: REPLICA IDENTITY NOTHING +ALTER TABLE table_with_pk REPLICA IDENTITY NOTHING; +DELETE FROM table_with_pk WHERE b = 1; +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_without_pk REPLICA IDENTITY NOTHING; +DELETE FROM table_without_pk WHERE b = 1; +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_with_unique REPLICA IDENTITY NOTHING; +DELETE FROM table_with_unique WHERE b = 1; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/delete3.sql b/contrib/wal2json/sql/delete3.sql new file mode 100644 index 000000000..8c696e46e --- /dev/null +++ b/contrib/wal2json/sql/delete3.sql @@ -0,0 +1,94 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- DELETE: REPLICA IDENTITY FULL +ALTER TABLE table_with_pk REPLICA IDENTITY FULL; +DELETE FROM table_with_pk WHERE b = 1; +DELETE FROM table_with_pk WHERE n = true; +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_without_pk REPLICA IDENTITY FULL; +DELETE FROM table_without_pk WHERE b = 1; +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_with_unique REPLICA IDENTITY FULL; +DELETE FROM table_with_unique WHERE b = 1; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/delete4.sql b/contrib/wal2json/sql/delete4.sql new file mode 100644 index 000000000..20eebee3a --- /dev/null +++ b/contrib/wal2json/sql/delete4.sql @@ -0,0 +1,42 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', false, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 4.56, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- DELETE: REPLICA IDENTITY INDEX +ALTER TABLE table_with_unique REPLICA IDENTITY USING INDEX table_with_unique_g_n_key; +DELETE FROM table_with_unique WHERE b = 1; +DELETE FROM table_with_unique WHERE n = true; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/filtertable.sql b/contrib/wal2json/sql/filtertable.sql new file mode 100644 index 000000000..9ebd9bf52 --- /dev/null +++ b/contrib/wal2json/sql/filtertable.sql @@ -0,0 +1,65 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS filter_table_1; +DROP TABLE IF EXISTS filter_table_2; +DROP TABLE IF EXISTS filter_table_3; +DROP TABLE IF EXISTS filter_table_4; +DROP TABLE IF EXISTS "Filter_table_5"; +DROP TABLE IF EXISTS "filter table_6"; +DROP TABLE IF EXISTS "filter.table_7"; +DROP TABLE IF EXISTS "filter,table_8"; +DROP TABLE IF EXISTS "filter""table_9"; +DROP TABLE IF EXISTS " filter_table_10"; +DROP TABLE IF EXISTS "*"; +DROP SCHEMA IF EXISTS filter_schema_1 CASCADE; +DROP SCHEMA IF EXISTS filter_schema_2 CASCADE; +DROP SCHEMA IF EXISTS "*" CASCADE; + +CREATE SCHEMA filter_schema_1; +CREATE SCHEMA filter_schema_2; +CREATE SCHEMA "*"; + +CREATE TABLE filter_table_1 (a integer, b text, primary key(a)); +CREATE TABLE filter_schema_1.filter_table_1 (a integer, b text, primary key(a)); +CREATE TABLE filter_schema_1.filter_table_2 (a integer, b text, primary key(a)); +CREATE TABLE filter_schema_2.filter_table_1 (a integer, b text, primary key(a)); +CREATE TABLE filter_schema_2.filter_table_2 (a integer, b text, primary key(a)); +CREATE TABLE filter_schema_2.filter_table_3 (a integer, b text, primary key(a)); +CREATE TABLE filter_table_2 (a integer, b text, primary key(a)); +CREATE TABLE filter_table_3 (a integer, b text, primary key(a)); +CREATE TABLE filter_table_4 (a integer, b text, primary key(a)); +CREATE TABLE "Filter_table_5" (a integer, b text, primary key(a)); +CREATE TABLE "filter table_6" (a integer, b text, primary key(a)); +CREATE TABLE "filter.table_7" (a integer, b text, primary key(a)); +CREATE TABLE "filter,table_8" (a integer, b text, primary key(a)); +CREATE TABLE "filter""table_9" (a integer, b text, primary key(a)); +CREATE TABLE " filter_table_10" (a integer, b text, primary key(a)); +CREATE TABLE "*" (a integer, b text, primary key(a)); +CREATE TABLE "*".filter_table_0 (a integer, b text, primary key(a)); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO filter_table_1 (a, b) VALUES(1, 'public.filter_table_1'); +INSERT INTO filter_schema_1.filter_table_1 (a, b) VALUES(1, 'filter_schema_1.filter_table_1'); +INSERT INTO filter_schema_1.filter_table_2 (a, b) VALUES(1, 'filter_schema_1.filter_table_2'); +INSERT INTO filter_schema_2.filter_table_1 (a, b) VALUES(1, 'filter_schema_2.filter_table_1'); +INSERT INTO filter_schema_2.filter_table_2 (a, b) VALUES(1, 'filter_schema_2.filter_table_2'); +INSERT INTO filter_schema_2.filter_table_3 (a, b) VALUES(1, 'filter_schema_2.filter_table_3'); +INSERT INTO filter_table_2 (a, b) VALUES(1, 'public.filter_table_2'); +INSERT INTO filter_table_3 (a, b) VALUES(1, 'public.filter_table_3'); +INSERT INTO filter_table_4 (a, b) VALUES(1, 'public.filter_table_4'); +INSERT INTO "Filter_table_5" (a, b) VALUES(1, 'public.Filter_table_5'); +INSERT INTO "filter table_6" (a, b) VALUES(1, 'public.filter table_6'); +INSERT INTO "filter.table_7" (a, b) VALUES(1, 'public.filter.table_7'); +INSERT INTO "filter,table_8" (a, b) VALUES(1, 'public.filter,table_8'); +INSERT INTO "filter""table_9" (a, b) VALUES(1, 'public.filter"table_9'); +INSERT INTO " filter_table_10" (a, b) VALUES(1, 'public. filter_table_10'); +INSERT INTO "*" (a, b) VALUES(1, 'public.*'); +INSERT INTO "*".filter_table_0 (a, b) VALUES(1, '*.filter_table_0'); + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'filter-tables', ' foo.bar,*.filter_table_1 ,filter_schema_2.* , public.filter_table_3 , public.Filter_table_5, public.filter\ table_6, public.filter\.table_7 , public.filter\,table_8 , public.filter"table_9, *.\ filter_table_10 , public.\* , \*.filter_table_0 '); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'filter-tables', ' foo.bar,*.filter_table_1 ,filter_schema_2.* , public.filter_table_3 , public.Filter_table_5, public.filter\ table_6, public.filter\.table_7 , public.filter\,table_8 , public.filter"table_9, *.\ filter_table_10 , public.\* , \*.filter_table_0 '); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/include_domain_data_type.sql b/contrib/wal2json/sql/include_domain_data_type.sql new file mode 100644 index 000000000..6d63309c0 --- /dev/null +++ b/contrib/wal2json/sql/include_domain_data_type.sql @@ -0,0 +1,50 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +CREATE DOMAIN wal2json_domain_1 AS bigint; +CREATE DOMAIN wal2json_domain_2 AS numeric(5,3); +CREATE DOMAIN wal2json_domain_3 AS varchar(30); +CREATE DOMAIN wal2json_domain_4 AS bit varying(20); + +CREATE TABLE test_wal2json_5 ( +a smallserial, +b smallint, +c int, +d wal2json_domain_1, +e wal2json_domain_2, +f real not null, +g double precision, +h char(10), +i wal2json_domain_3, +j text, +k wal2json_domain_4, +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO test_wal2json_5 (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +UPDATE test_wal2json_5 SET f = -f WHERE b = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '0', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-domain-data-type', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '0'); +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-domain-data-type', '1'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + +DROP TABLE test_wal2json_5; +DROP DOMAIN wal2json_domain_1; +DROP DOMAIN wal2json_domain_2; +DROP DOMAIN wal2json_domain_3; +DROP DOMAIN wal2json_domain_4; diff --git a/contrib/wal2json/sql/include_lsn.sql b/contrib/wal2json/sql/include_lsn.sql new file mode 100644 index 000000000..3a9bb8d62 --- /dev/null +++ b/contrib/wal2json/sql/include_lsn.sql @@ -0,0 +1,25 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS tbl; +CREATE TABLE tbl (id int); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- One row should have one record and one nextlsn +INSERT INTO tbl VALUES (1); +SELECT count(*) = 1, count(distinct ((data::json)->'nextlsn')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + +-- Two rows should have two records and two nextlsns +INSERT INTO tbl VALUES (2); +INSERT INTO tbl VALUES (3); +SELECT count(*) = 2, count(distinct ((data::json)->'nextlsn')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + +-- Two rows in one transaction should have one record and one nextlsn +INSERT INTO tbl VALUES (4), (5); +SELECT count(*) = 1, count(distinct ((data::json)->'nextlsn')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-lsn', '1'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + diff --git a/contrib/wal2json/sql/include_timestamp.sql b/contrib/wal2json/sql/include_timestamp.sql new file mode 100644 index 000000000..14aa80db4 --- /dev/null +++ b/contrib/wal2json/sql/include_timestamp.sql @@ -0,0 +1,25 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS tbl; +CREATE TABLE tbl (id int); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- One row should have one record and one timestmap +INSERT INTO tbl VALUES (1); +SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + +-- Two rows should have two records and two timestamps +INSERT INTO tbl VALUES (2); +INSERT INTO tbl VALUES (3); +SELECT count(*) = 2, count(distinct ((data::json)->'timestamp')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + +-- Two rows in one transaction should have one record and one timestamp +INSERT INTO tbl VALUES (4), (5); +SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + diff --git a/contrib/wal2json/sql/include_xids.sql b/contrib/wal2json/sql/include_xids.sql new file mode 100644 index 000000000..110b6346f --- /dev/null +++ b/contrib/wal2json/sql/include_xids.sql @@ -0,0 +1,25 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS tbl; +CREATE TABLE tbl (id int); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- One row should have one record and one xids +INSERT INTO tbl VALUES (1); +SELECT count(*) = 1, count(distinct ((data::json)->'xid')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + +-- Two rows should have two records and two xids +INSERT INTO tbl VALUES (2); +INSERT INTO tbl VALUES (3); +SELECT count(*) = 2, count(distinct ((data::json)->'xid')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + +-- Two rows in one transaction should have one record and one xid +INSERT INTO tbl VALUES (4), (5); +SELECT count(*) = 2, count(distinct ((data::json)->'xid')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-xids', '1'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + diff --git a/contrib/wal2json/sql/insert1.sql b/contrib/wal2json/sql/insert1.sql new file mode 100644 index 000000000..fbb514a24 --- /dev/null +++ b/contrib/wal2json/sql/insert1.sql @@ -0,0 +1,89 @@ +-- this is the first test (CREATE EXTENSION, no DROP TABLE) +LOAD 'test_decoding'; + +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +CREATE SCHEMA "test ""schema"; + +CREATE TABLE "test ""schema"."test "" with 'quotes'" ( + id serial primary key, + "col spaces" int, + "col""quotes" int +); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- INSERT +BEGIN; +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO "test ""schema"."test "" with 'quotes'" VALUES (1, 2, 3); +COMMIT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/message.sql b/contrib/wal2json/sql/message.sql new file mode 100644 index 000000000..b762a8ae1 --- /dev/null +++ b/contrib/wal2json/sql/message.sql @@ -0,0 +1,33 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +SELECT 'msg1' FROM pg_logical_emit_message(true, 'wal2json', 'this is a\ message'); +SELECT 'msg2' FROM pg_logical_emit_message(false, 'wal2json', 'this is "another" message'); + +SELECT 'msg3' FROM pg_logical_emit_message(false, 'wal2json', E'\\x546170697275732074657272657374726973'::bytea); +SELECT 'msg4' FROM pg_logical_emit_message(false, 'wal2json', E'\\x5072696f646f6e746573206d6178696d7573'::bytea); +SELECT 'msg5' FROM pg_logical_emit_message(false, 'wal2json', E'\\x436172796f6361722062726173696c69656e7365'::bytea); + +BEGIN; +SELECT 'msg6' FROM pg_logical_emit_message(true, 'wal2json', 'this message will not be printed'); +SELECT 'msg7' FROM pg_logical_emit_message(false, 'wal2json', 'this message will be printed even if the transaction is rollbacked'); +ROLLBACK; + +BEGIN; +SELECT 'msg8' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #1'); +SELECT 'msg9' FROM pg_logical_emit_message(false, 'wal2json', 'this message will be printed before message #1'); +SELECT 'msg10' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #2'); +COMMIT; + +SELECT 'msg11' FROM pg_logical_emit_message(true, 'filtered', 'this message will be filtered'); +SELECT 'msg12' FROM pg_logical_emit_message(true, 'added1', 'this message will be printed'); +SELECT 'msg13' FROM pg_logical_emit_message(true, 'added2', 'this message will be filtered'); + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'filter-msg-prefixes', 'foo, filtered, bar', 'add-msg-prefixes', 'added1, added3, wal2json'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'filter-msg-prefixes', 'foo, filtered, bar', 'add-msg-prefixes', 'added1, added3, wal2json'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/pk.sql b/contrib/wal2json/sql/pk.sql new file mode 100644 index 000000000..160454f15 --- /dev/null +++ b/contrib/wal2json/sql/pk.sql @@ -0,0 +1,54 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +CREATE TABLE w2j_pk_with_pk ( +a int, +b timestamp, +c text, +d boolean, +e numeric(5,3), +PRIMARY KEY(b, d, e) +); + +CREATE TABLE w2j_pk_without_pk ( +a int, +b timestamp, +c text, +d boolean, +e numeric(5,3) +); + +CREATE TABLE w2j_pk_with_ri ( +a int NOT NULL, +b timestamp, +c text, +d boolean, +e numeric(5,3), +UNIQUE(a) +); +ALTER TABLE w2j_pk_with_ri REPLICA IDENTITY USING INDEX w2j_pk_with_ri_a_key; + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO w2j_pk_with_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56); +UPDATE w2j_pk_with_pk SET a = 456, c = 'Panthera Onca', d = false; +DELETE FROM w2j_pk_with_pk; + +INSERT INTO w2j_pk_without_pk (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Melanosuchus Niger', true, 4.56); +UPDATE w2j_pk_without_pk SET a = 456, c = 'Panthera Onca', d = false; +DELETE FROM w2j_pk_without_pk; + +INSERT INTO w2j_pk_with_ri (a, b, c, d, e) VALUES(123, '2020-04-26 16:23:59', 'Inia Araguaiaensis', true, 4.56); +UPDATE w2j_pk_with_ri SET a = 456, c = 'Panthera Onca', d = false; +DELETE FROM w2j_pk_with_ri; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0', 'include-pk', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-pk', '1'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + +DROP TABLE w2j_pk_with_pk; +DROP TABLE w2j_pk_without_pk; +DROP TABLE w2j_pk_with_ri; diff --git a/contrib/wal2json/sql/position.sql b/contrib/wal2json/sql/position.sql new file mode 100644 index 000000000..ef984c362 --- /dev/null +++ b/contrib/wal2json/sql/position.sql @@ -0,0 +1,25 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +CREATE TABLE w2j_position (a integer, b integer, primary key(a)); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO w2j_position (a, b) VALUES(1,2); +UPDATE w2j_position SET b = 3 WHERE a = 1; +ALTER TABLE w2j_position ADD COLUMN c integer; +ALTER TABLE w2j_position DROP COLUMN b; +INSERT INTO w2j_position (a, c) VALUES(5,6); +UPDATE w2j_position SET c = 7 WHERE a = 5; + +-- without include-column-position parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); + +-- with include-column-position parameter +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-column-positions', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'include-column-positions', '1'); + +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/savepoint.sql b/contrib/wal2json/sql/savepoint.sql new file mode 100644 index 000000000..78789ea99 --- /dev/null +++ b/contrib/wal2json/sql/savepoint.sql @@ -0,0 +1,28 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +CREATE TABLE xpto (a SERIAL PRIMARY KEY, b text); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO xpto (b) VALUES('john'); +INSERT INTO xpto (b) VALUES('smith'); +INSERT INTO xpto (b) VALUES('robert'); + +BEGIN; +INSERT INTO xpto (b) VALUES('marie'); +SAVEPOINT sp1; +INSERT INTO xpto (b) VALUES('ernesto'); +SAVEPOINT sp2; +INSERT INTO xpto (b) VALUES('peter'); -- discard +SAVEPOINT sp3; +INSERT INTO xpto (b) VALUES('albert'); -- discard +ROLLBACK TO SAVEPOINT sp2; +RELEASE SAVEPOINT sp1; +INSERT INTO xpto (b) VALUES('francisco'); +END; + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/selecttable.sql b/contrib/wal2json/sql/selecttable.sql new file mode 100644 index 000000000..64fcd0e40 --- /dev/null +++ b/contrib/wal2json/sql/selecttable.sql @@ -0,0 +1,38 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS select_table_1; +DROP TABLE IF EXISTS select_table_2; +DROP TABLE IF EXISTS select_table_3; +DROP SCHEMA IF EXISTS select_schema_1 CASCADE; +DROP SCHEMA IF EXISTS select_schema_2 CASCADE; + +CREATE SCHEMA select_schema_1; +CREATE SCHEMA select_schema_2; + +CREATE TABLE select_table_1 (a integer, b text, primary key(a)); +CREATE TABLE select_schema_1.select_table_1 (a integer, b text, primary key(a)); +CREATE TABLE select_schema_1.select_table_2 (a integer, b text, primary key(a)); +CREATE TABLE select_schema_2.select_table_1 (a integer, b text, primary key(a)); +CREATE TABLE select_schema_2.select_table_2 (a integer, b text, primary key(a)); +CREATE TABLE select_schema_2.select_table_3 (a integer, b text, primary key(a)); +CREATE TABLE select_table_2 (a integer, b text, primary key(a)); +CREATE TABLE select_table_3 (a integer, b text, primary key(a)); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO select_table_1 (a, b) VALUES(1, 'public.select_table_1'); +INSERT INTO select_schema_1.select_table_1 (a, b) VALUES(1, 'select_schema_1.select_table_1'); +INSERT INTO select_schema_1.select_table_2 (a, b) VALUES(1, 'select_schema_1.select_table_2'); +INSERT INTO select_schema_2.select_table_1 (a, b) VALUES(1, 'select_schema_2.select_table_1'); +INSERT INTO select_schema_2.select_table_2 (a, b) VALUES(1, 'select_schema_2.select_table_2'); +INSERT INTO select_schema_2.select_table_3 (a, b) VALUES(1, 'select_schema_2.select_table_3'); +INSERT INTO select_table_2 (a, b) VALUES(1, 'public.select_table_2'); +INSERT INTO select_table_3 (a, b) VALUES(1, 'public.select_table_3'); + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'add-tables', ' foo.bar,*.select_table_1 ,select_schema_2.* , public.select_table_3 '); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2', 'add-tables', ' foo.bar,*.select_table_1 ,select_schema_2.* , public.select_table_3 '); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); + diff --git a/contrib/wal2json/sql/specialvalue.sql b/contrib/wal2json/sql/specialvalue.sql new file mode 100644 index 000000000..3c65bd305 --- /dev/null +++ b/contrib/wal2json/sql/specialvalue.sql @@ -0,0 +1,21 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS xpto; + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +CREATE TABLE xpto (a SERIAL PRIMARY KEY, b bool, c varchar(60), d real); +COMMIT; + +BEGIN; +INSERT INTO xpto (b, c, d) VALUES('t', 'test1', '+inf'); +INSERT INTO xpto (b, c, d) VALUES('f', 'test2', 'nan'); +INSERT INTO xpto (b, c, d) VALUES(NULL, 'null', '-inf'); +INSERT INTO xpto (b, c, d) VALUES(TRUE, E'valid: '' " \\ / \b \f \n \r \t \u207F \u967F invalid: \\g \\k end', 123.456); +COMMIT; + +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/toast.sql b/contrib/wal2json/sql/toast.sql new file mode 100644 index 000000000..5c96a341b --- /dev/null +++ b/contrib/wal2json/sql/toast.sql @@ -0,0 +1,36 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS xpto; +DROP SEQUENCE IF EXISTS xpto_rand_seq; + +CREATE SEQUENCE xpto_rand_seq START 11 INCREMENT 997; +CREATE TABLE xpto ( +id serial primary key, +toasted_col1 text, +rand1 float8 DEFAULT nextval('xpto_rand_seq'), +toasted_col2 text, +rand2 float8 DEFAULT nextval('xpto_rand_seq') +); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- uncompressed external toast data +INSERT INTO xpto (toasted_col1, toasted_col2) SELECT string_agg(g.i::text, ''), string_agg((g.i*2)::text, '') FROM generate_series(1, 2000) g(i); + +-- compressed external toast data +INSERT INTO xpto (toasted_col2) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i); + +-- update of existing column +UPDATE xpto SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i)) WHERE id = 1; + +UPDATE xpto SET rand1 = 123.456 WHERE id = 1; + +DELETE FROM xpto WHERE id = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/truncate.sql b/contrib/wal2json/sql/truncate.sql new file mode 100644 index 000000000..121b735f1 --- /dev/null +++ b/contrib/wal2json/sql/truncate.sql @@ -0,0 +1,28 @@ +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +CREATE TABLE table_truncate_1 (a integer, b text); +CREATE TABLE table_truncate_2 (a integer, b text); +CREATE TABLE table_truncate_3 (a integer, b text); +CREATE TABLE table_truncate_4 (a integer, b text); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +TRUNCATE table_truncate_1; + +BEGIN; +TRUNCATE table_truncate_2; +INSERT INTO table_truncate_1 (a, b) VALUES(1, 'test1'); +INSERT INTO table_truncate_3 (a, b) VALUES(2, 'test2'); +TRUNCATE table_truncate_3; +INSERT INTO table_truncate_3 (a, b) VALUES(3, 'test3'); +COMMIT; + +BEGIN; +TRUNCATE table_truncate_4; +ROLLBACK; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/typmod.sql b/contrib/wal2json/sql/typmod.sql new file mode 100644 index 000000000..dc4141eb7 --- /dev/null +++ b/contrib/wal2json/sql/typmod.sql @@ -0,0 +1,40 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS table_with_pk; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +UPDATE table_with_pk SET f = -f WHERE b = 1; + +-- UPDATE: pk change +DELETE FROM table_with_pk WHERE b = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1'); +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/update1.sql b/contrib/wal2json/sql/update1.sql new file mode 100644 index 000000000..062390e2e --- /dev/null +++ b/contrib/wal2json/sql/update1.sql @@ -0,0 +1,91 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- UPDATE: no pk +UPDATE table_without_pk SET f = -f WHERE b = 1; + +-- UPDATE: no pk change +UPDATE table_with_pk SET f = -f WHERE b = 1; + +-- UPDATE: pk change +UPDATE table_with_pk SET b = -b WHERE b = 1; + +-- UPDATE: unique +UPDATE table_with_unique SET n = false WHERE b = 1; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/update2.sql b/contrib/wal2json/sql/update2.sql new file mode 100644 index 000000000..3d3a12279 --- /dev/null +++ b/contrib/wal2json/sql/update2.sql @@ -0,0 +1,91 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- UPDATE: REPLICA IDENTITY NOTHING +ALTER TABLE table_with_pk REPLICA IDENTITY NOTHING; +UPDATE table_with_pk SET f = -f WHERE b = 1; +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_without_pk REPLICA IDENTITY NOTHING; +UPDATE table_without_pk SET f = -f WHERE b = 1; +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_with_unique REPLICA IDENTITY NOTHING; +UPDATE table_with_unique SET f = -f WHERE b = 1; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/update3.sql b/contrib/wal2json/sql/update3.sql new file mode 100644 index 000000000..d476c99d8 --- /dev/null +++ b/contrib/wal2json/sql/update3.sql @@ -0,0 +1,92 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS table_with_pk; +DROP TABLE IF EXISTS table_without_pk; +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +PRIMARY KEY(b, c, d) +); + +CREATE TABLE table_without_pk ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3), +f real not null, +g double precision, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector +); + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_without_pk (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- UPDATE: REPLICA IDENTITY FULL +ALTER TABLE table_with_pk REPLICA IDENTITY FULL; +UPDATE table_with_pk SET f = -f WHERE b = 1; +ALTER TABLE table_with_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_without_pk REPLICA IDENTITY FULL; +UPDATE table_without_pk SET f = -f WHERE b = 1; +ALTER TABLE table_without_pk REPLICA IDENTITY DEFAULT; + +ALTER TABLE table_with_unique REPLICA IDENTITY FULL; +UPDATE table_with_unique SET f = -f WHERE b = 1; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/sql/update4.sql b/contrib/wal2json/sql/update4.sql new file mode 100644 index 000000000..5d18ce80a --- /dev/null +++ b/contrib/wal2json/sql/update4.sql @@ -0,0 +1,44 @@ +\set VERBOSITY terse + +-- predictability +SET synchronous_commit = on; +SET extra_float_digits = 0; + +DROP TABLE IF EXISTS table_with_unique; + +CREATE TABLE table_with_unique ( +a smallserial, +b smallint, +c int, +d bigint, +e numeric(5,3) not null, +f real not null, +g double precision not null, +h char(10), +i varchar(30), +j text, +k bit varying(20), +l timestamp, +m date, +n boolean not null, +o json, +p tsvector, +UNIQUE(g, n) +); + +-- INSERT +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(1, 2, 3, 3.54, 876.563452345, 1.23, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', false, '{ "a": 123 }', 'Old Old Parr'::tsvector); +INSERT INTO table_with_unique (b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VALUES(4, 5, 6, 3.54, 876.563452345, 4.56, 'teste', 'testando', 'um texto longo', B'001110010101010', '2013-11-02 17:30:52', '2013-02-04', true, '{ "a": 123 }', 'Old Old Parr'::tsvector); + +SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json'); + +-- UPDATE: REPLICA IDENTITY USING INDEX +ALTER TABLE table_with_unique REPLICA IDENTITY USING INDEX table_with_unique_g_n_key; +-- FIXME não apresenta valor correto de g +UPDATE table_with_unique SET c = -c WHERE b = 1; +UPDATE table_with_unique SET g = -g WHERE n = true; +ALTER TABLE table_with_unique REPLICA IDENTITY DEFAULT; + +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '1', 'pretty-print', '1', 'include-typmod', '0'); +SELECT data FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'format-version', '2'); +SELECT 'stop' FROM pg_drop_replication_slot('regression_slot'); diff --git a/contrib/wal2json/wal2json.c b/contrib/wal2json/wal2json.c new file mode 100644 index 000000000..05af81bab --- /dev/null +++ b/contrib/wal2json/wal2json.c @@ -0,0 +1,2892 @@ +/*------------------------------------------------------------------------- + * + * wal2json.c + * JSON output plugin for changeset extraction + * + * Copyright (c) 2013-2020, Euler Taveira de Oliveira + * + * IDENTIFICATION + * contrib/wal2json/wal2json.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" +#include "knl/knl_variable.h" +#include "access/genam.h" +#include "access/heapam.h" +#include "catalog/indexing.h" +#include "catalog/pg_attrdef.h" +#include "catalog/pg_type.h" +#include "nodes/parsenodes_common.h" +#include "replication/logical.h" + +#include "utils/builtins.h" +#include "utils/fmgroids.h" +#include "utils/guc.h" +#include "utils/json.h" +#include "utils/lsyscache.h" +#include "utils/memutils.h" +#include "utils/pg_lsn.h" +#include "utils/rel.h" +#include "utils/syscache.h" + +#define WAL2JSON_FORMAT_VERSION 2 +#define WAL2JSON_FORMAT_MIN_VERSION 1 +#define MAXPG_LSNLEN 17 +PG_MODULE_MAGIC; + +extern "C" void _PG_init(void); +extern "C" void _PG_output_plugin_init(OutputPluginCallbacks* cb); + + +//deal with magic number: +const static uint32 format_version_2 = 2; +const static uint32 format_version_1 = 1; +const static int nkeys_2 = 2; +const static size_t len_3 = 3; +const static size_t len_8 = 8; +const static size_t len_9 = 9; +const static size_t count_3 = 3; + +typedef struct { + bool insert; + bool update; + bool delete_gs;/* dup name with c++ keyword */ + bool truncate; +} JsonAction; + +typedef struct { + MemoryContext context; + bool include_transaction; /* BEGIN and COMMIT objects (v2) */ + bool include_xids; /* include transaction ids */ + bool include_timestamp; /* include transaction timestamp */ + bool include_origin; /* replication origin */ + bool include_schemas; /* qualify tables */ + bool include_types; /* include data types */ + bool include_type_oids; /* include data type oids */ + bool include_typmod; /* include typmod in types */ + bool include_domain_data_type; /* include underlying data type of the domain */ + bool include_column_positions; /* include column numbers */ + bool include_not_null; /* include not-null constraints */ + bool include_default; /* include default expressions */ + bool include_pk; /* include primary key */ + + bool pretty_print; /* pretty-print JSON? */ + bool write_in_chunks; /* write in chunks? */ + + JsonAction actions; /* output only these actions */ + + List *filter_origins; /* filter out origins */ + List *filter_tables; /* filter out tables */ + List *add_tables; /* add only these tables */ + List *filter_msg_prefixes; /* filter by message prefixes */ + List *add_msg_prefixes; /* add only messages with these prefixes */ + + int format_version; /* support different formats */ + + /* + * LSN pointing to the end of commit record + 1 (txn->end_lsn) + * It is useful for tools that wants a position to restart from. + */ + bool include_lsn; /* include LSNs */ + + uint64 nr_changes; /* # of passes in pg_decode_change() */ + /* FIXME replace with txn->nentries */ + + /* pretty print */ + char ht[2]; /* horizontal tab, if pretty print */ + char nl[2]; /* new line, if pretty print */ + char sp[2]; /* space, if pretty print */ +} JsonDecodingData; + +typedef enum { + PGOUTPUTJSON_CHANGE, + PGOUTPUTJSON_IDENTITY, + PGOUTPUTJSON_PK +} PGOutputJsonKind; + +typedef struct SelectTable { + char *schemaname; + char *tablename; + bool allschemas; /* true means any schema */ + bool alltables; /* true means any table */ +} SelectTable; + +/* These must be available to pg_dlsym() */ +static void pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is_init); +static void pg_decode_shutdown(LogicalDecodingContext *ctx); +static void pg_decode_begin_txn(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn); +static void pg_decode_commit_txn(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr commit_lsn); +static void pg_decode_abort_txn(LogicalDecodingContext* ctx, ReorderBufferTXN* txn); +static void pg_decode_prepare_txn(LogicalDecodingContext* ctx, ReorderBufferTXN* txn); + +static void pg_decode_change(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, Relation rel, + ReorderBufferChange *change); +static bool pg_filter_by_origin(LogicalDecodingContext *ctx, RepOriginId origin_id); + +static void pg_decode_message(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr lsn, + bool transactional, const char *prefix, + Size content_size, const char *content); + +static void columns_to_stringinfo(LogicalDecodingContext *ctx, + TupleDesc tupdesc, HeapTuple tuple, bool addcomma, Oid reloid); +static void tuple_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, + HeapTuple tuple, TupleDesc indexdesc, bool replident, bool addcomma, Oid reloid); +static void pk_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, + HeapTuple tuple, TupleDesc indexdesc, bool addcomma); +static bool parse_table_identifier(List *qualified_tables, char separator, List **select_tables); +static bool string_to_SelectTable(char *rawstring, char separator, List **select_tables); +static bool split_string_to_list(char *rawstring, char separator, List **sl); +static bool split_string_to_oid_list(char *rawstring, char separator, List **sl); + +/* version 1 */ +static void pg_decode_begin_txn_v1(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn); +static void pg_decode_commit_txn_v1(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr commit_lsn); +static void pg_decode_change_v1(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, Relation rel, + ReorderBufferChange *change); + +static void pg_decode_message_v1(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr lsn, + bool transactional, const char *prefix, + Size content_size, const char *content); + +/* version 2 */ +static void pg_decode_begin_txn_v2(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn); +static void pg_decode_commit_txn_v2(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr commit_lsn); +static void pg_decode_write_value(LogicalDecodingContext *ctx, Datum value, bool isnull, Oid typid); +static void pg_decode_write_tuple(LogicalDecodingContext *ctx, Relation relation, HeapTuple tuple, + PGOutputJsonKind kind); +static void pg_decode_write_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + Relation relation, ReorderBufferChange *change); +static void pg_decode_change_v2(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, Relation rel, + ReorderBufferChange *change); + +static void pg_decode_message_v2(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr lsn, + bool transactional, const char *prefix, + Size content_size, const char *content); + +static Datum pg_lsn_out(PG_FUNCTION_ARGS); +/* + * Backward compatibility. + * + * This macro is only available in 9.6+. + */ + + +static Datum pg_lsn_out(PG_FUNCTION_ARGS) +{ + XLogRecPtr lsn = PG_GETARG_LSN(0); + char buf[MAXPG_LSNLEN + 1]; + char *result; + uint32 id; + uint32 off; + const static uint32 offset_helper = 32; + /* Decode ID and offset */ + id = (uint32) (lsn >> offset_helper); + off = (uint32) lsn; + snprintf(buf, sizeof buf, "%X/%X", id, off); + result = pstrdup(buf); + PG_RETURN_CSTRING(result); +} + +void _PG_init(void) { +} + +/* Specify output plugin callbacks */ +void _PG_output_plugin_init(OutputPluginCallbacks *cb) +{ + AssertVariableIsOfType(&_PG_output_plugin_init, LogicalOutputPluginInit); + + cb->startup_cb = pg_decode_startup; + cb->begin_cb = pg_decode_begin_txn; + cb->change_cb = pg_decode_change; + cb->commit_cb = pg_decode_commit_txn; + cb->abort_cb = pg_decode_abort_txn; + cb->prepare_cb = pg_decode_prepare_txn; + cb->shutdown_cb = pg_decode_shutdown; + cb->filter_by_origin_cb = pg_filter_by_origin; +} + +/* Initialize this plugin */ +static void pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is_init) +{ + ListCell *option; + JsonDecodingData *data; + SelectTable *t; + + data = (JsonDecodingData*) palloc0(sizeof(JsonDecodingData)); + data->context = AllocSetContextCreate(ctx->context, + "wal2json output context", + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); + data->include_transaction = true; + data->include_xids = false; + data->include_timestamp = false; + data->include_pk = false; + data->include_origin = false; + data->include_schemas = true; + data->include_types = true; + data->include_type_oids = false; + data->include_typmod = true; + data->include_domain_data_type = false; + data->include_column_positions = false; + data->pretty_print = false; + data->write_in_chunks = false; + data->include_lsn = false; + data->include_not_null = false; + data->include_default = false; + data->filter_origins = NIL; + data->filter_tables = NIL; + data->filter_msg_prefixes = NIL; + data->add_msg_prefixes = NIL; + + data->format_version = 1; + + /* default actions */ + if (WAL2JSON_FORMAT_VERSION == 1) { + data->actions.insert = true; + data->actions.update = true; + data->actions.delete_gs = true; + data->actions.truncate = false; /* backward compatibility */ + } else { + data->actions.insert = true; + data->actions.update = true; + data->actions.delete_gs = true; + data->actions.truncate = true; + } + + /* pretty print */ + strcpy(data->ht, ""); + strcpy(data->nl, ""); + strcpy(data->sp, ""); + + /* add all tables in all schemas by default */ + t = (SelectTable*)palloc0(sizeof(SelectTable)); + t->allschemas = true; + t->alltables = true; + data->add_tables = lappend(data->add_tables, t); + + data->nr_changes = 0; + + ctx->output_plugin_private = data; + + opt->output_type = OUTPUT_PLUGIN_TEXTUAL_OUTPUT; + + foreach(option, ctx->output_plugin_options) { + DefElem *elem = (DefElem*)lfirst(option); + + Assert(elem->arg == NULL || IsA(elem->arg, String)); + + if (strcmp(elem->defname, "include-transaction") == 0) { + /* if option value is NULL then assume that value is true */ + if (elem->arg == NULL) + data->include_transaction = true; + else if (!parse_bool(strVal(elem->arg), &data->include_transaction)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-xids") == 0) { + /* If option does not provide a value, it means its value is true */ + if (elem->arg == NULL) { + elog(DEBUG1, "include-xids argument is null"); + data->include_xids = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_xids)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-timestamp") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-timestamp argument is null"); + data->include_timestamp = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_timestamp)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-pk") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-pk argument is null"); + data->include_pk = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_pk)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-origin") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-origin argument is null"); + data->include_origin = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_origin)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-schemas") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-schemas argument is null"); + data->include_schemas = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_schemas)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-types") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-types argument is null"); + data->include_types = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_types)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-type-oids") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-type-oids argument is null"); + data->include_type_oids = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_type_oids)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-typmod") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-typmod argument is null"); + data->include_typmod = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_typmod)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-domain-data-type") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-types argument is null"); + data->include_domain_data_type = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_domain_data_type)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-column-positions") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-column-positions argument is null"); + data->include_column_positions = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_column_positions)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-not-null") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-not-null argument is null"); + data->include_not_null = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_not_null)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-default") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-default argument is null"); + data->include_default = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_default)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "pretty-print") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "pretty-print argument is null"); + data->pretty_print = true; + } else if (!parse_bool(strVal(elem->arg), &data->pretty_print)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + + if (data->pretty_print) { + strncpy(data->ht, "\t", 1); + strncpy(data->nl, "\n", 1); + strncpy(data->sp, " ", 1); + } + } else if (strcmp(elem->defname, "write-in-chunks") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "write-in-chunks argument is null"); + data->write_in_chunks = true; + } else if (!parse_bool(strVal(elem->arg), &data->write_in_chunks)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-lsn") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "include-lsn argument is null"); + data->include_lsn = true; + } else if (!parse_bool(strVal(elem->arg), &data->include_lsn)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } else if (strcmp(elem->defname, "include-unchanged-toast") == 0) { + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("parameter \"%s\" was deprecated", elem->defname))); + } else if (strcmp(elem->defname, "actions") == 0) { + char *rawstr; + + if (elem->arg == NULL) { + elog(DEBUG1, "actions argument is null"); + /* argument null means default; nothing to do here */ + } else { + List *selected_actions = NIL; + ListCell *lc; + + rawstr = pstrdup(strVal(elem->arg)); + if (!split_string_to_list(rawstr, ',', &selected_actions)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + + data->actions.insert = false; + data->actions.update = false; + data->actions.delete_gs = false; + data->actions.truncate = false; + + foreach(lc, selected_actions) { + char *p = (char*)lfirst(lc); + + if (strcmp(p, "insert") == 0) + data->actions.insert = true; + else if (strcmp(p, "update") == 0) + data->actions.update = true; + else if (strcmp(p, "delete") == 0) + data->actions.delete_gs = true; + else if (strcmp(p, "truncate") == 0) + data->actions.truncate = true; + else + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + p, elem->defname))); + } + + pfree(rawstr); + list_free(selected_actions); + } + } else if (strcmp(elem->defname, "filter-origins") == 0) { + char *rawstr; + + if (elem->arg == NULL) { + elog(DEBUG1, "filter-origins argument is null"); + data->filter_origins = NIL; + } else { + rawstr = pstrdup(strVal(elem->arg)); + if (!split_string_to_oid_list(rawstr, ',', &data->filter_origins)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + pfree(rawstr); + } + } else if (strcmp(elem->defname, "filter-tables") == 0) { + char *rawstr; + + if (elem->arg == NULL) { + elog(DEBUG1, "filter-tables argument is null"); + data->filter_tables = NIL; + } else { + rawstr = pstrdup(strVal(elem->arg)); + if (!string_to_SelectTable(rawstr, ',', &data->filter_tables)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + pfree(rawstr); + } + } else if (strcmp(elem->defname, "add-tables") == 0) { + char *rawstr; + + /* + * If this parameter is specified, remove 'all tables in all + * schemas' value from list. + */ + list_free_deep(data->add_tables); + data->add_tables = NIL; + + if (elem->arg == NULL) { + elog(DEBUG1, "add-tables argument is null"); + data->add_tables = NIL; + } else { + rawstr = pstrdup(strVal(elem->arg)); + if (!string_to_SelectTable(rawstr, ',', &data->add_tables)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + pfree(rawstr); + } + } else if (strcmp(elem->defname, "filter-msg-prefixes") == 0) { + char *rawstr; + + if (elem->arg == NULL) { + elog(DEBUG1, "filter-msg-prefixes argument is null"); + data->filter_msg_prefixes = NIL; + } else { + rawstr = pstrdup(strVal(elem->arg)); + if (!split_string_to_list(rawstr, ',', &data->filter_msg_prefixes)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + pfree(rawstr); + } + } else if (strcmp(elem->defname, "add-msg-prefixes") == 0) { + char *rawstr; + + if (elem->arg == NULL) { + elog(DEBUG1, "add-msg-prefixes argument is null"); + data->add_msg_prefixes = NIL; + } else { + rawstr = pstrdup(strVal(elem->arg)); + if (!split_string_to_list(rawstr, ',', &data->add_msg_prefixes)) { + pfree(rawstr); + ereport(ERROR, + (errcode(ERRCODE_INVALID_NAME), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + } + pfree(rawstr); + } + } else if (strcmp(elem->defname, "format-version") == 0) { + if (elem->arg == NULL) { + elog(DEBUG1, "format-version argument is null"); + data->format_version = WAL2JSON_FORMAT_VERSION; + } else if (!parse_int(strVal(elem->arg), &data->format_version, 0, NULL)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("could not parse value \"%s\" for parameter \"%s\"", + strVal(elem->arg), elem->defname))); + + if (data->format_version > WAL2JSON_FORMAT_VERSION) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("client sent format_version=%d but we only support format %d or lower", + data->format_version, WAL2JSON_FORMAT_VERSION))); + + if (data->format_version < WAL2JSON_FORMAT_MIN_VERSION) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("client sent format_version=%d but we only support format %d or higher", + data->format_version, WAL2JSON_FORMAT_MIN_VERSION))); + } else { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("option \"%s\" = \"%s\" is unknown", + elem->defname, + elem->arg ? strVal(elem->arg) : "(null)"))); + } + } + + elog(DEBUG2, "format version: %d", data->format_version); +} + +/* cleanup this plugin's resources */ +static void pg_decode_shutdown(LogicalDecodingContext *ctx) +{ + JsonDecodingData *data = (JsonDecodingData*) ctx->output_plugin_private; + MemoryContextDelete(data->context); + /* cleanup our own resources via memory context reset */ +} + + +/* BEGIN callback */ +static void pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) +{ + JsonDecodingData *data = (JsonDecodingData*) ctx->output_plugin_private; + + if (data->format_version == format_version_2) + pg_decode_begin_txn_v2(ctx, txn); + else if (data->format_version == format_version_1) + pg_decode_begin_txn_v1(ctx, txn); + else + elog(ERROR, "format version %d is not supported", data->format_version); +} + +static void pg_decode_begin_txn_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + data->nr_changes = 0; + + /* Transaction starts */ + OutputPluginPrepareWrite(ctx, true); + + appendStringInfo(ctx->out, "{%s", data->nl); + + if (data->include_xids) + appendStringInfo(ctx->out, "%s\"xid\":%s%lu,%s", data->ht, data->sp, txn->xid, data->nl); + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn))); + + appendStringInfo(ctx->out, "%s\"nextlsn\":%s\"%s\",%s", data->ht, data->sp, lsn_str, data->nl); + + pfree(lsn_str); + } + + if (data->include_timestamp) + appendStringInfo(ctx->out, "%s\"timestamp\":%s\"%s\",%s", data->ht, data->sp, + timestamptz_to_str(txn->commit_time), data->nl); + +#if PG_VERSION_NUM >= 90500 + if (data->include_origin) + appendStringInfo(ctx->out, "%s\"origin\":%s%u,%s", data->ht, data->sp, txn->origin_id, data->nl); +#endif + + appendStringInfo(ctx->out, "%s\"change\":%s[", data->ht, data->sp); + + if (data->write_in_chunks) + OutputPluginWrite(ctx, true); +} + +static void pg_decode_begin_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + /* don't include BEGIN object */ + if (!data->include_transaction) { + return; + } + OutputPluginPrepareWrite(ctx, true); + appendStringInfoString(ctx->out, "{\"action\":\"B\""); + if (data->include_xids) { + appendStringInfo(ctx->out, ",\"xid\":%lu", txn->xid); + } + + if (data->include_timestamp) { + appendStringInfo(ctx->out, ",\"timestamp\":\"%s\"", timestamptz_to_str(txn->commit_time)); + } + +#if PG_VERSION_NUM >= 90500 + if (data->include_origin) { + appendStringInfo(ctx->out, ",\"origin\":%u", txn->origin_id); + } + +#endif + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->final_lsn))); + appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str); + pfree(lsn_str); + + lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn))); + appendStringInfo(ctx->out, ",\"nextlsn\":\"%s\"", lsn_str); + pfree(lsn_str); + } + + appendStringInfoChar(ctx->out, '}'); + OutputPluginWrite(ctx, true); +} + +/* COMMIT callback */ +static void pg_decode_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr commit_lsn) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + +#if PG_VERSION_NUM >= 130000 + if (rbtxn_has_catalog_changes(txn)) +#else + if (txn->has_catalog_changes) +#endif + elog(DEBUG2, "txn has catalog changes: yes"); + else + elog(DEBUG2, "txn has catalog changes: no"); + elog(DEBUG2, "my change counter: " UINT64_FORMAT " ; # of changes: " UINT64_FORMAT \ + " ; # of changes in memory: " UINT64_FORMAT, data->nr_changes, txn->nentries, txn->nentries_mem); + elog(DEBUG2, "# of subxacts: %d", txn->nsubtxns); + + if (data->format_version == format_version_2) + pg_decode_commit_txn_v2(ctx, txn, commit_lsn); + else if (data->format_version == format_version_1) + pg_decode_commit_txn_v1(ctx, txn, commit_lsn); + else + elog(ERROR, "format version %d is not supported", data->format_version); +} + +static void pg_decode_commit_txn_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr commit_lsn) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + /* Transaction ends */ + if (data->write_in_chunks) + OutputPluginPrepareWrite(ctx, true); + + /* if we don't write in chunks, we need a newline here */ + if (!data->write_in_chunks) + appendStringInfo(ctx->out, "%s", data->nl); + + appendStringInfo(ctx->out, "%s]%s}", data->ht, data->nl); + + OutputPluginWrite(ctx, true); +} + +static void pg_decode_commit_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr commit_lsn) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + /* don't include COMMIT object */ + if (!data->include_transaction) { + return; + } + + OutputPluginPrepareWrite(ctx, true); + appendStringInfoString(ctx->out, "{\"action\":\"C\""); + if (data->include_xids) + appendStringInfo(ctx->out, ",\"xid\":%lu", txn->xid); + if (data->include_timestamp) + appendStringInfo(ctx->out, ",\"timestamp\":\"%s\"", timestamptz_to_str(txn->commit_time)); + +#if PG_VERSION_NUM >= 90500 + if (data->include_origin) + appendStringInfo(ctx->out, ",\"origin\":%u", txn->origin_id); +#endif + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(commit_lsn))); + appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str); + pfree(lsn_str); + + lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn))); + appendStringInfo(ctx->out, ",\"nextlsn\":\"%s\"", lsn_str); + pfree(lsn_str); + } + + appendStringInfoChar(ctx->out, '}'); + OutputPluginWrite(ctx, true); +} + +/* ABORT callback */ +static void pg_decode_abort_txn(LogicalDecodingContext* ctx, ReorderBufferTXN* txn) +{ + PluginTestDecodingData* data = (PluginTestDecodingData*)ctx->output_plugin_private; + + if (data->skip_empty_xacts && !data->xact_wrote_changes) { + return; + } + OutputPluginPrepareWrite(ctx, true); + if (data->include_xids) + appendStringInfo(ctx->out, "ABORT %lu", txn->xid); + else + appendStringInfoString(ctx->out, "ABORT"); + + if (data->include_timestamp) + appendStringInfo(ctx->out, " (at %s)", timestamptz_to_str(txn->commit_time)); + + OutputPluginWrite(ctx, true); +} + +/* PREPARE callback */ +static void pg_decode_prepare_txn(LogicalDecodingContext* ctx, ReorderBufferTXN* txn) +{ + PluginTestDecodingData* data = (PluginTestDecodingData*)ctx->output_plugin_private; + + if (data->skip_empty_xacts && !data->xact_wrote_changes) { + return; + } + + OutputPluginPrepareWrite(ctx, true); + if (data->include_xids) + appendStringInfo(ctx->out, "PREPARE %lu", txn->xid); + else + appendStringInfoString(ctx->out, "PREPARE"); + + if (data->include_timestamp) + appendStringInfo(ctx->out, " (at %s)", timestamptz_to_str(txn->commit_time)); + + OutputPluginWrite(ctx, true); +} + + +/* + * Accumulate tuple information and stores it at the end + * + * replident: is this tuple a replica identity? + */ +static void tuple_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, + HeapTuple tuple, TupleDesc indexdesc, bool replident, bool addcomma, Oid reloid) +{ + JsonDecodingData *data; + int natt; + + StringInfoData colnames; + StringInfoData coltypes; + StringInfoData coltypeoids; + StringInfoData colpositions; + StringInfoData colnotnulls; + StringInfoData coldefaults; + StringInfoData colvalues; + char comma[3] = ""; + + Relation defrel = NULL; + + data = (JsonDecodingData*) ctx->output_plugin_private; + + initStringInfo(&colnames); + initStringInfo(&coltypes); + if (data->include_type_oids) { + initStringInfo(&coltypeoids); + } + if (data->include_column_positions) { + initStringInfo(&colpositions); + } + if (data->include_not_null) { + initStringInfo(&colnotnulls); + } + if (data->include_default) { + initStringInfo(&coldefaults); + } + initStringInfo(&colvalues); + + /* + * If replident is true, it will output info about replica identity. In this + * case, there are special JSON objects for it. Otherwise, it will print new + * tuple data. + */ + if (replident) { + appendStringInfo(&colnames, "%s%s%s\"oldkeys\":%s{%s", data->ht, data->ht, data->ht, data->sp, data->nl); + appendStringInfo(&colnames, "%s%s%s%s\"keynames\":%s[", data->ht, data->ht, data->ht, data->ht, data->sp); + appendStringInfo(&coltypes, "%s%s%s%s\"keytypes\":%s[", data->ht, data->ht, data->ht, data->ht, data->sp); + if (data->include_type_oids) { + appendStringInfo(&coltypeoids, "%s%s%s%s\"keytypeoids\":%s[", data->ht, data->ht, + data->ht, data->ht, data->sp); + } + appendStringInfo(&colvalues, "%s%s%s%s\"keyvalues\":%s[", data->ht, data->ht, data->ht, data->ht, data->sp); + } else { + appendStringInfo(&colnames, "%s%s%s\"columnnames\":%s[", data->ht, data->ht, data->ht, data->sp); + appendStringInfo(&coltypes, "%s%s%s\"columntypes\":%s[", data->ht, data->ht, data->ht, data->sp); + if (data->include_type_oids) { + appendStringInfo(&coltypeoids, "%s%s%s\"columntypeoids\":%s[", data->ht, data->ht, data->ht, data->sp); + } + if (data->include_column_positions) { + appendStringInfo(&colpositions, "%s%s%s\"columnpositions\":%s[", data->ht, data->ht, data->ht, data->sp); + } + + if (data->include_not_null) { + appendStringInfo(&colnotnulls, "%s%s%s\"columnoptionals\":%s[", data->ht, data->ht, data->ht, data->sp); + } + if (data->include_default) { + appendStringInfo(&coldefaults, "%s%s%s\"columndefaults\":%s[", data->ht, data->ht, data->ht, data->sp); + } + appendStringInfo(&colvalues, "%s%s%s\"columnvalues\":%s[", data->ht, data->ht, data->ht, data->sp); + } + if (!replident && data->include_default) { +#if PG_VERSION_NUM >= 120000 + defrel = table_open(AttrDefaultRelationId, AccessShareLock); +#else + defrel = heap_open(AttrDefaultRelationId, AccessShareLock); +#endif + } + /* Print column information (name, type, value) */ + for (natt = 0; natt < tupdesc->natts; natt++) { + Form_pg_attribute attr; /* the attribute itself */ + Oid typid; /* type of current attribute */ + HeapTuple type_tuple; /* information about a type */ + Oid typoutput; /* output function */ + bool typisvarlena; + Datum origval; /* possibly toasted Datum */ + Datum val; /* definitely detoasted Datum */ + char *outputstr = NULL; + bool isnull; /* column is null? */ + + /* + * Commit d34a74dd064af959acd9040446925d9d53dff15b introduced + * TupleDescAttr() in back branches. If the version supports + * this macro, use it. Version 10 and later already support it. + */ +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || \ +(PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || (PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + attr = tupdesc->attrs[natt]; +#else + attr = TupleDescAttr(tupdesc, natt); +#endif + elog(DEBUG1, "attribute \"%s\" (%d/%d)", NameStr(attr->attname), natt, tupdesc->natts); + /* Do not print dropped or system columns */ + if (attr->attisdropped || attr->attnum < 0) + continue; + + /* Search indexed columns in whole heap tuple */ + if (indexdesc != NULL) { + int j; + bool found_col = false; + for (j = 0; j < indexdesc->natts; j++) { + Form_pg_attribute iattr; + + /* See explanation a few lines above. */ +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || \ +(PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || (PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + iattr = indexdesc->attrs[j]; +#else + iattr = TupleDescAttr(indexdesc, j); +#endif + if (strcmp(NameStr(attr->attname), NameStr(iattr->attname)) == 0) + found_col = true; + } + + /* Print only indexed columns */ + if (!found_col) + continue; + } + + /* Get Datum from tuple */ + origval = heap_getattr(tuple, natt + 1, tupdesc, &isnull); + + /* Skip nulls iif printing key/identity */ + if (isnull && replident) + continue; + + typid = attr->atttypid; + + /* Figure out type name */ + type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + if (!HeapTupleIsValid(type_tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + + /* Get information needed for printing values of a type */ + getTypeOutputInfo(typid, &typoutput, &typisvarlena); + + /* XXX Unchanged TOAST Datum does not need to be output */ + if (!isnull && typisvarlena && VARATT_IS_EXTERNAL_ONDISK(origval)) { + elog(DEBUG1, "column \"%s\" has an unchanged TOAST", NameStr(attr->attname)); + continue; + } + + /* Accumulate each column info */ + appendStringInfo(&colnames, "%s", comma); + escape_json(&colnames, NameStr(attr->attname)); + + if (data->include_types) { + char *type_str; + Form_pg_type type_form = (Form_pg_type) GETSTRUCT(type_tuple); + /* + * It is a domain. Replace domain name with base data type if + * include_domain_data_type is enabled. + */ + if (type_form->typtype == TYPTYPE_DOMAIN && data->include_domain_data_type) { + typid = type_form->typbasetype; + if (data->include_typmod) { + getTypeOutputInfo(typid, &typoutput, &typisvarlena); + type_str = format_type_with_typemod(type_form->typbasetype, type_form->typtypmod); + } else { + /* + * Since we are not using a format function, grab base type + * name from Form_pg_type. + */ + type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + if (!HeapTupleIsValid(type_tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + type_form = (Form_pg_type) GETSTRUCT(type_tuple); + type_str = pstrdup(NameStr(type_form->typname)); + } + } else { + if (data->include_typmod) + type_str = TextDatumGetCString(DirectFunctionCall2(format_type, attr->atttypid, attr->atttypmod)); + else + type_str = pstrdup(NameStr(type_form->typname)); + } + + appendStringInfo(&coltypes, "%s", comma); + escape_json(&coltypes, type_str); + + pfree(type_str); + + /* oldkeys doesn't print not-null constraints */ + if (!replident && data->include_not_null) { + if (attr->attnotnull) + appendStringInfo(&colnotnulls, "%sfalse", comma); + else + appendStringInfo(&colnotnulls, "%strue", comma); + } + } + + if (data->include_type_oids) + appendStringInfo(&coltypeoids, "%s%u", comma, typid); + + ReleaseSysCache(type_tuple); + + if (!replident && data->include_column_positions) + appendStringInfo(&colpositions, "%s%d", comma, attr->attnum); + + /* + * Print default for columns. + */ + if (!replident && data->include_default) { +#if PG_VERSION_NUM >= 120000 + if (attr->atthasdef && attr->attgenerated == '\0') +#else + if (attr->atthasdef) +#endif +{ + ScanKeyData scankeys[2]; + SysScanDesc scan; + HeapTuple def_tuple; + Datum def_value; + bool isnull; + char *result; + + ScanKeyInit(&scankeys[0], + Anum_pg_attrdef_adrelid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(reloid)); + ScanKeyInit(&scankeys[1], + Anum_pg_attrdef_adnum, + BTEqualStrategyNumber, F_INT2EQ, + Int16GetDatum(attr->attnum)); + + scan = systable_beginscan(defrel, AttrDefaultIndexId, true, + SnapshotNow, nkeys_2, scankeys); + + def_tuple = systable_getnext(scan); + if (HeapTupleIsValid(def_tuple)) { + def_value = fastgetattr(def_tuple, Anum_pg_attrdef_adbin, defrel->rd_att, &isnull); + + if (!isnull) { + result = TextDatumGetCString(DirectFunctionCall2(pg_get_expr, + def_value, + ObjectIdGetDatum(tuple->t_tableOid))); + + appendStringInfo(&coldefaults, "%s\"%s\"", comma, result); + pfree(result); + } else { + /* + * null means that default was not set. Is it possible? + * atthasdef shouldn't be set. + */ + appendStringInfo(&coldefaults, "%snull", comma); + } + } + + systable_endscan(scan); + } else { + /* + * no DEFAULT clause implicitly means that the default is NULL + */ + appendStringInfo(&coldefaults, "%snull", comma); + } + } + + if (isnull) { + appendStringInfo(&colvalues, "%snull", comma); + } else { + if (typisvarlena) + val = PointerGetDatum(PG_DETOAST_DATUM(origval)); + else + val = origval; + + /* Finally got the value */ + outputstr = OidOutputFunctionCall(typoutput, val); + + /* + * Data types are printed with quotes unless they are number, true, + * false, null, an array or an object. + * + * The NaN and Infinity are not valid JSON symbols. Hence, + * regardless of sign they are represented as the string null. + */ + switch (typid) { + case INT2OID: + case INT4OID: + case INT8OID: + case OIDOID: + case FLOAT4OID: + case FLOAT8OID: + case NUMERICOID: + if (pg_strncasecmp(outputstr, "NaN", len_3) == 0 || + pg_strncasecmp(outputstr, "Infinity", len_8) == 0 || + pg_strncasecmp(outputstr, "-Infinity", len_9) == 0) { + appendStringInfo(&colvalues, "%snull", comma); + elog(DEBUG1, "attribute \"%s\" is special: %s", NameStr(attr->attname), outputstr); + } else if (strspn(outputstr, "0123456789+-eE.") == strlen(outputstr)) { + if ((*outputstr)=='.') { + appendStringInfo(&colvalues, "%s0%s", comma, outputstr); + } else { + appendStringInfo(&colvalues, "%s%s", comma, outputstr); + } + } else { + elog(ERROR, "%s is not a number", outputstr); + } + break; + case BOOLOID: + if (strcmp(outputstr, "t") == 0) { + appendStringInfo(&colvalues, "%strue", comma); + } else { + appendStringInfo(&colvalues, "%sfalse", comma); + } + break; + case BYTEAOID: + appendStringInfo(&colvalues, "%s", comma); + /* string is "\x54617069727573", start after "\x" */ + escape_json(&colvalues, (outputstr + 2)); + break; + default: + appendStringInfo(&colvalues, "%s", comma); + escape_json(&colvalues, outputstr); + break; + } + } + + /* The first column does not have comma */ + if (strcmp(comma, "") == 0) + snprintf(comma, count_3, ",%s", data->sp); + } + + if (!replident && data->include_default) { +#if PG_VERSION_NUM >= 120000 + table_close(defrel, AccessShareLock); +#else + heap_close(defrel, AccessShareLock); +#endif + } + + /* Column info ends */ + if (replident) { + appendStringInfo(&colnames, "],%s", data->nl); + if (data->include_types) + appendStringInfo(&coltypes, "],%s", data->nl); + if (data->include_type_oids) + appendStringInfo(&coltypeoids, "],%s", data->nl); + appendStringInfo(&colvalues, "]%s", data->nl); + appendStringInfo(&colvalues, "%s%s%s}%s", data->ht, data->ht, data->ht, data->nl); + } else { + appendStringInfo(&colnames, "],%s", data->nl); + if (data->include_types) + appendStringInfo(&coltypes, "],%s", data->nl); + if (data->include_type_oids) + appendStringInfo(&coltypeoids, "],%s", data->nl); + if (data->include_column_positions) + appendStringInfo(&colpositions, "],%s", data->nl); + if (data->include_not_null) + appendStringInfo(&colnotnulls, "],%s", data->nl); + if (data->include_default) + appendStringInfo(&coldefaults, "],%s", data->nl); + if (addcomma) + appendStringInfo(&colvalues, "],%s", data->nl); + else + appendStringInfo(&colvalues, "]%s", data->nl); + } + + /* Print data */ + appendStringInfoString(ctx->out, colnames.data); + if (data->include_types) + appendStringInfoString(ctx->out, coltypes.data); + if (data->include_type_oids) + appendStringInfoString(ctx->out, coltypeoids.data); + if (data->include_column_positions) + appendStringInfoString(ctx->out, colpositions.data); + if (data->include_not_null) + appendStringInfoString(ctx->out, colnotnulls.data); + if (data->include_default) + appendStringInfoString(ctx->out, coldefaults.data); + appendStringInfoString(ctx->out, colvalues.data); + + pfree(colnames.data); + pfree(coltypes.data); + if (data->include_type_oids) + pfree(coltypeoids.data); + if (data->include_column_positions) + pfree(colpositions.data); + if (data->include_not_null) + pfree(colnotnulls.data); + if (data->include_default) + pfree(coldefaults.data); + pfree(colvalues.data); +} + +/* Print columns information */ +static void columns_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, HeapTuple tuple, + bool addcomma, Oid reloid) +{ + tuple_to_stringinfo(ctx, tupdesc, tuple, NULL, false, addcomma, reloid); +} + +/* Print replica identity information */ +static void identity_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, + HeapTuple tuple, TupleDesc indexdesc) +{ + /* Last parameter does not matter */ + tuple_to_stringinfo(ctx, tupdesc, tuple, indexdesc, true, false, InvalidOid); +} + +/* Print primary key information */ +static void pk_to_stringinfo(LogicalDecodingContext *ctx, TupleDesc tupdesc, HeapTuple tuple, + TupleDesc indexdesc, bool addcomma) +{ + JsonDecodingData *data; + int natt; + char comma[3] = ""; + + StringInfoData pknames; + StringInfoData pktypes; + + data = (JsonDecodingData*)ctx->output_plugin_private; + + /* no primary key */ + if (indexdesc == NULL) { + return; + } + initStringInfo(&pknames); + initStringInfo(&pktypes); + appendStringInfo(&pknames, "%s%s%s\"pk\":%s{%s", data->ht, data->ht, data->ht, data->sp, data->nl); + appendStringInfo(&pknames, "%s%s%s%s\"pknames\":%s[", data->ht, data->ht, data->ht, data->ht, data->sp); + appendStringInfo(&pktypes, "%s%s%s%s\"pktypes\":%s[", data->ht, data->ht, data->ht, data->ht, data->sp); + + /* Print column information (name, type, value) */ + for (natt = 0; natt < tupdesc->natts; natt++) { + Form_pg_attribute attr; /* the attribute itself */ + Oid typid; /* type of current attribute */ + HeapTuple type_tuple; /* information about a type */ + + /* + * Commit d34a74dd064af959acd9040446925d9d53dff15b introduced + * TupleDescAttr() in back branches. If the version supports + * this macro, use it. Version 10 and later already support it. + */ +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || \ +(PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + attr = tupdesc->attrs[natt]; +#else + attr = TupleDescAttr(tupdesc, natt); +#endif + /* Do not print dropped or system columns */ + if (attr->attisdropped || attr->attnum < 0) + continue; + + /* Search pk columns in whole heap tuple */ + if (indexdesc != NULL) { + int j; + bool found_col = false; + + for (j = 0; j < indexdesc->natts; j++) { + Form_pg_attribute iattr; + /* See explanation a few lines above. */ +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || \ +(PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + iattr = indexdesc->attrs[j]; +#else + iattr = TupleDescAttr(indexdesc, j); +#endif + if (strcmp(NameStr(attr->attname), NameStr(iattr->attname)) == 0) + found_col = true; + } + /* Print only indexed columns */ + if (!found_col) + continue; + } + + typid = attr->atttypid; + + /* Figure out type name */ + type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + if (!HeapTupleIsValid(type_tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + + /* Accumulate each column info */ + appendStringInfo(&pknames, "%s", comma); + escape_json(&pknames, NameStr(attr->attname)); + if (data->include_types) { + char *type_str; + Form_pg_type type_form = (Form_pg_type) GETSTRUCT(type_tuple); + /* + * It is a domain. Replace domain name with base data type if + * include_domain_data_type is enabled. + */ + if (type_form->typtype == TYPTYPE_DOMAIN && data->include_domain_data_type) { + typid = type_form->typbasetype; + if (data->include_typmod) { + type_str = format_type_with_typemod(type_form->typbasetype, type_form->typtypmod); + } else { + /* + * Since we are not using a format function, grab base type + * name from Form_pg_type. + */ + type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); + if (!HeapTupleIsValid(type_tuple)) + elog(ERROR, "cache lookup failed for type %u", typid); + type_form = (Form_pg_type) GETSTRUCT(type_tuple); + type_str = pstrdup(NameStr(type_form->typname)); + } + } else { + if (data->include_typmod) + type_str = TextDatumGetCString(DirectFunctionCall2(format_type, attr->atttypid, attr->atttypmod)); + else + type_str = pstrdup(NameStr(type_form->typname)); + } + + appendStringInfo(&pktypes, "%s", comma); + escape_json(&pktypes, type_str); + + pfree(type_str); + } + + ReleaseSysCache(type_tuple); + + /* The first column does not have comma */ + if (strcmp(comma, "") == 0) + snprintf(comma, count_3, ",%s", data->sp); + } + + appendStringInfo(&pknames, "],%s", data->nl); + appendStringInfo(&pktypes, "]%s", data->nl); + if (addcomma) + appendStringInfo(&pktypes, "%s%s%s},%s", data->ht, data->ht, data->ht, data->nl); + else + appendStringInfo(&pktypes, "%s%s%s}%s", data->ht, data->ht, data->ht, data->nl); + + appendStringInfoString(ctx->out, pknames.data); + appendStringInfoString(ctx->out, pktypes.data); + + pfree(pknames.data); + pfree(pktypes.data); +} + +/* Callback for individual changed tuples */ +static void pg_decode_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + Relation relation, ReorderBufferChange *change) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + if (data->format_version == format_version_2) + pg_decode_change_v2(ctx, txn, relation, change); + else if (data->format_version == format_version_1) + pg_decode_change_v1(ctx, txn, relation, change); + else + elog(ERROR, "format version %d is not supported", data->format_version); +} + +static void pg_decode_change_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + Relation relation, ReorderBufferChange *change) +{ + JsonDecodingData *data; + Form_pg_class class_form; + TupleDesc tupdesc; + MemoryContext old; + + Relation indexrel; + TupleDesc indexdesc; + + Relation pkrel = NULL; + TupleDesc pkdesc = NULL; + + char *schemaname; + char *tablename; + + AssertVariableIsOfType(&pg_decode_change, LogicalDecodeChangeCB); + + data = (JsonDecodingData*)ctx->output_plugin_private; + + if (change->action == REORDER_BUFFER_CHANGE_INSERT && !data->actions.insert) { + elog(DEBUG3, "ignore INSERT"); + return; + } + if (change->action == REORDER_BUFFER_CHANGE_UPDATE && !data->actions.update) { + elog(DEBUG3, "ignore UPDATE"); + return; + } + if (change->action == REORDER_BUFFER_CHANGE_DELETE && !data->actions.delete_gs) { + elog(DEBUG3, "ignore DELETE"); + return; + } + + class_form = RelationGetForm(relation); + tupdesc = RelationGetDescr(relation); + + /* Avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + /* schema and table names are used for select tables */ + schemaname = get_namespace_name(class_form->relnamespace); + tablename = NameStr(class_form->relname); + + if (data->write_in_chunks) + OutputPluginPrepareWrite(ctx, true); + + /* Make sure rd_replidindex is set */ + RelationGetIndexList(relation); + + /* Filter tables, if available */ + if (list_length(data->filter_tables) > 0) { + ListCell *lc; + bool skip = false; + + foreach(lc, data->filter_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was filtered out", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + skip = true; + } + } + } + + /* table was found */ + if (skip) { + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + } + + /* Add tables */ + if (list_length(data->add_tables) > 0) { + ListCell *lc; + bool skip = true; + + /* all tables in all schemas are added by default */ + foreach(lc, data->add_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was added", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + skip = false; + } + } + } + + /* table was not found */ + if (skip) { + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + } + + /* Sanity checks */ + if (0) { + switch (change->action) { + case REORDER_BUFFER_CHANGE_INSERT: + if (change->data.tp.newtuple == NULL) { + elog(WARNING, "no tuple data for INSERT in table \"%s\"", NameStr(class_form->relname)); + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + break; + case REORDER_BUFFER_CHANGE_UPDATE: + /* + * Bail out iif: + * (i) doesn't have a pk and replica identity is not full; + * (ii) replica identity is nothing. + */ + if (!OidIsValid(relation->rd_replidindex) && relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL) { + /* FIXME this sentence is imprecise */ + elog(WARNING, "table \"%s\" without primary key or replica identity is nothing", + NameStr(class_form->relname)); + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + + if (change->data.tp.newtuple == NULL) { + elog(WARNING, "no tuple data for UPDATE in table \"%s\"", + NameStr(class_form->relname)); + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + break; + case REORDER_BUFFER_CHANGE_DELETE: + /* + * Bail out iif: + * (i) doesn't have a pk and replica identity is not full; + * (ii) replica identity is nothing. + */ + if (!OidIsValid(relation->rd_replidindex) && relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL) { + /* FIXME this sentence is imprecise */ + elog(WARNING, "table \"%s\" without primary key or replica identity is nothing", + NameStr(class_form->relname)); + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + + if (change->data.tp.oldtuple == NULL) { + elog(WARNING, "no tuple data for DELETE in table \"%s\"", NameStr(class_form->relname)); + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + break; + default: + Assert(false); + } + } + + /* Change counter */ + data->nr_changes++; + + /* if we don't write in chunks, we need a newline here */ + if (!data->write_in_chunks) + appendStringInfo(ctx->out, "%s", data->nl); + + appendStringInfo(ctx->out, "%s%s", data->ht, data->ht); + + if (data->nr_changes > 1) + appendStringInfoChar(ctx->out, ','); + + appendStringInfo(ctx->out, "{%s", data->nl); + + /* Print change kind */ + switch (change->action) { + case REORDER_BUFFER_CHANGE_INSERT: + appendStringInfo(ctx->out, "%s%s%s\"kind\":%s\"insert\",%s", data->ht, data->ht, + data->ht, data->sp, data->nl); + break; + case REORDER_BUFFER_CHANGE_UPDATE: + appendStringInfo(ctx->out, "%s%s%s\"kind\":%s\"update\",%s", data->ht, data->ht, + data->ht, data->sp, data->nl); + break; + case REORDER_BUFFER_CHANGE_DELETE: + appendStringInfo(ctx->out, "%s%s%s\"kind\":%s\"delete\",%s", data->ht, data->ht, + data->ht, data->sp, data->nl); + break; + default: + Assert(false); + } + + /* Print table name (possibly) qualified */ + if (data->include_schemas) { + appendStringInfo(ctx->out, "%s%s%s\"schema\":%s", data->ht, data->ht, data->ht, data->sp); + escape_json(ctx->out, get_namespace_name(class_form->relnamespace)); + appendStringInfo(ctx->out, ",%s", data->nl); + } + appendStringInfo(ctx->out, "%s%s%s\"table\":%s", data->ht, data->ht, data->ht, data->sp); + escape_json(ctx->out, NameStr(class_form->relname)); + if (data->include_pk) { + if (OidIsValid(relation->rd_replidindex)) { + pkrel = RelationIdGetRelation(relation->rd_replidindex); + pkdesc = RelationGetDescr(pkrel); + } + } + + switch (change->action) { + case REORDER_BUFFER_CHANGE_INSERT: + /* Print the new tuple */ + appendStringInfo(ctx->out, ",%s", data->nl); + if (data->include_pk && pkrel != NULL) { + columns_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, true, + change->data.tp.relnode.relNode); + pk_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, pkdesc, false); + } else { + columns_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, false, + change->data.tp.relnode.relNode); + } + break; + case REORDER_BUFFER_CHANGE_UPDATE: + /* Print the new tuple */ + appendStringInfo(ctx->out, ",%s", data->nl); + columns_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, + true, change->data.tp.relnode.relNode); + if (data->include_pk && pkrel != NULL) + pk_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, pkdesc, true); + + /* + * The old tuple is available when: + * (i) pk changes; + * (ii) replica identity is full; + * (iii) replica identity is index and indexed column changes. + * + * FIXME if old tuple is not available we must get only the indexed + * columns (the whole tuple is printed). + */ + if (change->data.tp.oldtuple == NULL) { + elog(DEBUG1, "old tuple is null"); + + indexrel = RelationIdGetRelation(relation->rd_replidindex); + if (indexrel != NULL) { + indexdesc = RelationGetDescr(indexrel); + identity_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, indexdesc); + RelationClose(indexrel); + } else { + identity_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, NULL); + } + } else { + elog(DEBUG1, "old tuple is not null"); + identity_to_stringinfo(ctx, tupdesc, &change->data.tp.oldtuple->tuple, NULL); + } + break; + case REORDER_BUFFER_CHANGE_DELETE: + if (change->data.tp.oldtuple == NULL) {break;}; + appendStringInfo(ctx->out, ",%s", data->nl); + if (data->include_pk && pkrel != NULL) + pk_to_stringinfo(ctx, tupdesc, &change->data.tp.newtuple->tuple, pkdesc, true); + + /* Print the replica identity */ + indexrel = RelationIdGetRelation(relation->rd_replidindex); + if (indexrel != NULL) { + indexdesc = RelationGetDescr(indexrel); + identity_to_stringinfo(ctx, tupdesc, &change->data.tp.oldtuple->tuple, indexdesc); + RelationClose(indexrel); + } else { + identity_to_stringinfo(ctx, tupdesc, &change->data.tp.oldtuple->tuple, NULL); + } + + if (change->data.tp.oldtuple == NULL) + elog(DEBUG1, "old tuple is null"); + else + elog(DEBUG1, "old tuple is not null"); + break; + default: + Assert(false); + } + + if (data->include_pk && pkrel != NULL) + RelationClose(pkrel); + + appendStringInfo(ctx->out, "%s%s}", data->ht, data->ht); + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + + if (data->write_in_chunks) + OutputPluginWrite(ctx, true); +} + +static void pg_decode_write_value(LogicalDecodingContext *ctx, Datum value, bool isnull, Oid typid) +{ + Oid typoutfunc; + bool isvarlena; + char *outstr; + + if (isnull) { + appendStringInfoString(ctx->out, "null"); + return; + } + + /* get type information and call its output function */ + getTypeOutputInfo(typid, &typoutfunc, &isvarlena); + + /* XXX dead code? check is one level above. */ + if (isvarlena && VARATT_IS_EXTERNAL_ONDISK(value)) { + elog(DEBUG1, "unchanged TOAST Datum"); + return; + } + + /* if value is varlena, detoast Datum */ + if (isvarlena) { + Datum detoastedval; + + detoastedval = PointerGetDatum(PG_DETOAST_DATUM(value)); + outstr = OidOutputFunctionCall(typoutfunc, detoastedval); + } else { + outstr = OidOutputFunctionCall(typoutfunc, value); + } + + /* + * Data types are printed with quotes unless they are number, true, false, + * null, an array or an object. + * + * The NaN an Infinity are not valid JSON symbols. Hence, regardless of + * sign they are represented as the string null. + */ + switch (typid) { + case INT2OID: + case INT4OID: + case INT8OID: + case OIDOID: + case FLOAT4OID: + case FLOAT8OID: + case NUMERICOID: + if (pg_strncasecmp(outstr, "NaN", len_3) == 0 || + pg_strncasecmp(outstr, "Infinity", len_8) == 0 || + pg_strncasecmp(outstr, "-Infinity", len_9) == 0) { + appendStringInfoString(ctx->out, "null"); + elog(DEBUG1, "special value: %s", outstr); + } else if (strspn(outstr, "0123456789+-eE.") == strlen(outstr)) { + appendStringInfo(ctx->out, "%s", outstr); + } else { + elog(ERROR, "%s is not a number", outstr); + } + break; + case BOOLOID: + if (strcmp(outstr, "t") == 0) + appendStringInfoString(ctx->out, "true"); + else + appendStringInfoString(ctx->out, "false"); + break; + case BYTEAOID: + /* string is "\x54617069727573", start after \x */ + escape_json(ctx->out, (outstr + 2)); + break; + default: + escape_json(ctx->out, outstr); + break; + } + + pfree(outstr); +} + +static void pg_decode_write_tuple(LogicalDecodingContext *ctx, + Relation relation, HeapTuple tuple, PGOutputJsonKind kind) +{ + JsonDecodingData *data; + TupleDesc tupdesc; + Relation defrel = NULL; + Relation idxrel; + TupleDesc idxdesc = NULL; + int i; + Datum *values; + bool *nulls; + bool need_sep = false; + + data = (JsonDecodingData*)ctx->output_plugin_private; + + tupdesc = RelationGetDescr(relation); + values = (Datum *) palloc(tupdesc->natts * sizeof(Datum)); + nulls = (bool *) palloc(tupdesc->natts * sizeof(bool)); + + /* break down the tuple into fields */ + heap_deform_tuple(tuple, tupdesc, values, nulls); + + /* figure out replica identity columns */ + if (kind == PGOUTPUTJSON_IDENTITY) { + if (OidIsValid(relation->rd_replidindex)) /* REPLICA IDENTITY INDEX */ { + idxrel = RelationIdGetRelation(relation->rd_replidindex); + idxdesc = RelationGetDescr(idxrel); + } else if (relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL) { + elog(ERROR, "table does not have primary key or replica identity"); + } + } else if (kind == PGOUTPUTJSON_PK) { + if (OidIsValid(relation->rd_replidindex)) /* 10+ */ { + idxrel = RelationIdGetRelation(relation->rd_replidindex); + idxdesc = RelationGetDescr(idxrel); + } + } + + /* open pg_attrdef in preparation to get default values from columns */ + if (kind == PGOUTPUTJSON_CHANGE && data->include_default) { +#if PG_VERSION_NUM >= 120000 + defrel = table_open(AttrDefaultRelationId, AccessShareLock); +#else + defrel = heap_open(AttrDefaultRelationId, AccessShareLock); +#endif + } + + for (i = 0; i < tupdesc->natts; i++) { + Form_pg_attribute attr; + int j; + bool found = false; + char *type_str; + +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || \ +(PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + attr = tupdesc->attrs[i]; +#else + attr = TupleDescAttr(tupdesc, i); +#endif + /* skip dropped or system columns */ + if (attr->attisdropped || attr->attnum < 0) + continue; + /* + * oldtuple contains NULL on those values that are not defined by + * REPLICA IDENTITY. In this case, print only non-null values. + */ + if (nulls[i] && (kind == PGOUTPUTJSON_PK || kind == PGOUTPUTJSON_IDENTITY)) + continue; + + /* don't send unchanged TOAST Datum */ + if (!nulls[i] && attr->attlen == -1 && VARATT_IS_EXTERNAL_ONDISK(values[i])) + continue; + /* + * Is it replica identity column? Print only those columns or all + * columns if REPLICA IDENTITY FULL is set. + */ + if (kind == PGOUTPUTJSON_PK || + (kind == PGOUTPUTJSON_IDENTITY && relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL)) { + for (j = 0; j < idxdesc->natts; j++) { + Form_pg_attribute iattr; +#if (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM < 90605) || (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90509) || \ +(PG_VERSION_NUM >= 90400 && PG_VERSION_NUM < 90414) + iattr = idxdesc->attrs[j]; +#else + iattr = TupleDescAttr(idxdesc, j); +#endif + if (strcmp(NameStr(attr->attname), NameStr(iattr->attname)) == 0) + found = true; + } + + if (!found) + continue; + } + if (need_sep) + appendStringInfoChar(ctx->out, ','); + need_sep = true; + + appendStringInfoChar(ctx->out, '{'); + appendStringInfoString(ctx->out, "\"name\":"); + escape_json(ctx->out, NameStr(attr->attname)); + + /* type name (with typmod, if available) */ + if (data->include_types) { + HeapTuple type_tuple; + Form_pg_type type_form; + type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(attr->atttypid)); + type_form = (Form_pg_type) GETSTRUCT(type_tuple); + /* + * It is a domain. Replace domain name with base data type if + * include_domain_data_type is enabled. + */ + if (type_form->typtype == TYPTYPE_DOMAIN && data->include_domain_data_type) + type_str = format_type_with_typemod(type_form->typbasetype, type_form->typtypmod); + else + type_str = format_type_with_typemod(attr->atttypid, attr->atttypmod); + appendStringInfoString(ctx->out, ",\"type\":"); + appendStringInfo(ctx->out, "\"%s\"", type_str); + pfree(type_str); + ReleaseSysCache(type_tuple); + } + + if (kind != PGOUTPUTJSON_PK) { + appendStringInfoString(ctx->out, ",\"value\":"); + pg_decode_write_value(ctx, values[i], nulls[i], attr->atttypid); + } + + /* + * Print optional for columns. This information is redundant for + * replica identity (index) because all attributes are not null. + */ + if (kind == PGOUTPUTJSON_CHANGE && data->include_not_null) { + if (attr->attnotnull) + appendStringInfoString(ctx->out, ",\"optional\":false"); + else + appendStringInfoString(ctx->out, ",\"optional\":true"); + } + + /* + * Print position for columns. Positions are only available for new + * tuple (INSERT, UPDATE). + */ + if (kind == PGOUTPUTJSON_CHANGE && data->include_column_positions) { + appendStringInfoString(ctx->out, ",\"position\":"); + appendStringInfo(ctx->out, "%d", attr->attnum); + } + + /* + * Print default for columns. + */ + if (kind == PGOUTPUTJSON_CHANGE && data->include_default) { +#if PG_VERSION_NUM >= 120000 + if (attr->atthasdef && attr->attgenerated == '\0') { +#else + if (attr->atthasdef) { +#endif + ScanKeyData scankeys[2]; + SysScanDesc scan; + HeapTuple def_tuple; + Datum def_value; + bool isnull; + char *result; + + ScanKeyInit(&scankeys[0], + Anum_pg_attrdef_adrelid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(relation->rd_id)); + ScanKeyInit(&scankeys[1], + Anum_pg_attrdef_adnum, + BTEqualStrategyNumber, F_INT2EQ, + Int16GetDatum(attr->attnum)); + + scan = systable_beginscan(defrel, AttrDefaultIndexId, true, + SnapshotNow, nkeys_2, scankeys); + + def_tuple = systable_getnext(scan); + if (HeapTupleIsValid(def_tuple)) { + def_value = fastgetattr(def_tuple, Anum_pg_attrdef_adbin, defrel->rd_att, &isnull); + + if (!isnull) { + result = TextDatumGetCString(DirectFunctionCall2(pg_get_expr, + def_value, + ObjectIdGetDatum(relation->rd_id))); + + appendStringInfoString(ctx->out, ",\"default\":"); + appendStringInfo(ctx->out, "\"%s\"", result); + pfree(result); + } else { + /* + * null means that default was not set. Is it possible? + * atthasdef shouldn't be set. + */ + appendStringInfoString(ctx->out, ",\"default\":null"); + } + } + + systable_endscan(scan); + } else { + /* + * no DEFAULT clause implicitly means that the default is NULL + */ + appendStringInfoString(ctx->out, ",\"default\":null"); + } + } + + appendStringInfoChar(ctx->out, '}'); + } + + /* close pg_attrdef */ + if (kind == PGOUTPUTJSON_CHANGE && data->include_default) { +#if PG_VERSION_NUM >= 120000 + table_close(defrel, AccessShareLock); +#else + heap_close(defrel, AccessShareLock); +#endif + } + + pfree(values); + pfree(nulls); +} + +static void pg_decode_write_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + Relation relation, ReorderBufferChange *change) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + /* make sure rd_pkindex and rd_replidindex are set */ + RelationGetIndexList(relation); + /* sanity checks */ + switch (change->action) { + case REORDER_BUFFER_CHANGE_INSERT: + if (change->data.tp.newtuple == NULL) { + elog(WARNING, "no tuple data for INSERT in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + return; + } + break; + case REORDER_BUFFER_CHANGE_UPDATE: + if (change->data.tp.newtuple == NULL) { + elog(WARNING, "no tuple data for UPDATE in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + return; + } + if (change->data.tp.oldtuple == NULL) { + if (!OidIsValid(relation->rd_replidindex) && relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL) { + elog(WARNING, "no tuple identifier for UPDATE in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + return; + } + } + break; + case REORDER_BUFFER_CHANGE_DELETE: + if (change->data.tp.oldtuple == NULL) { + if (!OidIsValid(relation->rd_replidindex) && relation->rd_rel->relreplident != REPLICA_IDENTITY_FULL) { + elog(WARNING, "no tuple identifier for DELETE in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + return; + } + } + break; + default: + Assert(false); + } + + OutputPluginPrepareWrite(ctx, true); + + appendStringInfoChar(ctx->out, '{'); + + switch (change->action) { + case REORDER_BUFFER_CHANGE_INSERT: + appendStringInfoString(ctx->out, "\"action\":\"I\""); + break; + case REORDER_BUFFER_CHANGE_UPDATE: + appendStringInfoString(ctx->out, "\"action\":\"U\""); + break; + case REORDER_BUFFER_CHANGE_DELETE: + appendStringInfoString(ctx->out, "\"action\":\"D\""); + break; + default: + Assert(false); + } + + if (data->include_xids) + appendStringInfo(ctx->out, ",\"xid\":%lu", txn->xid); + + if (data->include_timestamp) + appendStringInfo(ctx->out, ",\"timestamp\":\"%s\"", timestamptz_to_str(txn->commit_time)); + +#if PG_VERSION_NUM >= 90500 + if (data->include_origin) + appendStringInfo(ctx->out, ",\"origin\":%u", txn->origin_id); +#endif + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn))); + appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str); + pfree(lsn_str); + } + + if (data->include_schemas) { + appendStringInfo(ctx->out, ",\"schema\":"); + escape_json(ctx->out, get_namespace_name(RelationGetNamespace(relation))); + } + + appendStringInfo(ctx->out, ",\"table\":"); + escape_json(ctx->out, RelationGetRelationName(relation)); + + /* print new tuple (INSERT, UPDATE) */ + if (change->data.tp.newtuple != NULL) { + appendStringInfoString(ctx->out, ",\"columns\":["); + pg_decode_write_tuple(ctx, relation, &change->data.tp.newtuple->tuple, PGOUTPUTJSON_CHANGE); + appendStringInfoChar(ctx->out, ']'); + } + + /* + * Print old tuple (UPDATE, DELETE) + * + * old tuple is available when: + * (1) primary key changes; + * (2) replica identity is index and one of the indexed columns changes; + * (3) replica identity is full. + * + * If old tuple is not available (because (a) primary key does not change + * or (b) replica identity is index and none of indexed columns does not + * change) identity is obtained from new tuple (because it doesn't change). + * + */ + if (change->data.tp.oldtuple != NULL) { + appendStringInfoString(ctx->out, ",\"identity\":["); + pg_decode_write_tuple(ctx, relation, &change->data.tp.oldtuple->tuple, PGOUTPUTJSON_IDENTITY); + appendStringInfoChar(ctx->out, ']'); + } else { + /* + * Old tuple is not available, however, identity can be obtained from + * new tuple (because it doesn't change). + */ + if (change->action == REORDER_BUFFER_CHANGE_UPDATE) { + elog(DEBUG2, "old tuple is null on UPDATE"); + + /* + * Before v10, there is not rd_pkindex then rely on REPLICA + * IDENTITY DEFAULT to obtain primary key. + */ +#if PG_VERSION_NUM >= 100000 + if (OidIsValid(relation->rd_pkindex) || OidIsValid(relation->rd_replidindex)) +#else + if (OidIsValid(relation->rd_replidindex)) +#endif + { + elog(DEBUG1, "REPLICA IDENTITY: obtain old tuple using new tuple"); + appendStringInfoString(ctx->out, ",\"identity\":["); + pg_decode_write_tuple(ctx, relation, &change->data.tp.newtuple->tuple, PGOUTPUTJSON_IDENTITY); + appendStringInfoChar(ctx->out, ']'); + } else { + /* old tuple is not available and can't be obtained, report it */ + elog(WARNING, "no old tuple data for UPDATE in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + } + } + + /* old tuple is not available and can't be obtained, report it */ + if (change->action == REORDER_BUFFER_CHANGE_DELETE) { + elog(WARNING, "no old tuple data for DELETE in table \"%s\".\"%s\"", + get_namespace_name(RelationGetNamespace(relation)), + RelationGetRelationName(relation)); + } + } + + if (data->include_pk) { + appendStringInfoString(ctx->out, ",\"pk\":["); +#if PG_VERSION_NUM >= 100000 + if (OidIsValid(relation->rd_pkindex)) +#else + if (OidIsValid(relation->rd_replidindex) && relation->rd_rel->relreplident == REPLICA_IDENTITY_DEFAULT) +#endif + { + if (change->data.tp.oldtuple != NULL) + pg_decode_write_tuple(ctx, relation, &change->data.tp.oldtuple->tuple, PGOUTPUTJSON_PK); + else + pg_decode_write_tuple(ctx, relation, &change->data.tp.newtuple->tuple, PGOUTPUTJSON_PK); + } + appendStringInfoChar(ctx->out, ']'); + } + + appendStringInfoChar(ctx->out, '}'); + + OutputPluginWrite(ctx, true); +} + +static void pg_decode_change_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + Relation relation, ReorderBufferChange *change) +{ + JsonDecodingData *data = (JsonDecodingData*) ctx->output_plugin_private; + MemoryContext old; + + char *schemaname; + char *tablename; + + if (change->action == REORDER_BUFFER_CHANGE_INSERT && !data->actions.insert) { + elog(DEBUG3, "ignore INSERT"); + return; + } + if (change->action == REORDER_BUFFER_CHANGE_UPDATE && !data->actions.update) { + elog(DEBUG3, "ignore UPDATE"); + return; + } + if (change->action == REORDER_BUFFER_CHANGE_DELETE && !data->actions.delete_gs) { + elog(DEBUG3, "ignore DELETE"); + return; + } + + /* avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + /* schema and table names are used for chosen tables */ + schemaname = get_namespace_name(RelationGetNamespace(relation)); + tablename = RelationGetRelationName(relation); + + /* Exclude tables, if available */ + if (list_length(data->filter_tables) > 0) { + ListCell *lc; + bool skip = false; + + foreach(lc, data->filter_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was filtered out", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + skip = true; + } + } + } + + /* table was found */ + if (skip) { + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + } + + /* Add tables */ + if (list_length(data->add_tables) > 0) { + ListCell *lc; + bool skip = true; + + /* all tables in all schemas are added by default */ + foreach(lc, data->add_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was added", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + skip = false; + } + } + } + + /* table was not found */ + if (skip) { + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + return; + } + } + + pg_decode_write_change(ctx, txn, relation, change); + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); +} + +#if PG_VERSION_NUM >= 90600 +/* Callback for generic logical decoding messages */ +static void pg_decode_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr lsn, bool transactional, const char *prefix, Size + content_size, const char *content) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + /* Filter message prefixes, if available */ + if (list_length(data->filter_msg_prefixes) > 0) { + ListCell *lc; + + foreach(lc, data->filter_msg_prefixes) { + char *p = (char*)lfirst(lc); + + if (strcmp(p, prefix) == 0) { + elog(DEBUG2, "message prefix \"%s\" was filtered out", p); + return; + } + } + } + + /* Add messages by prefix */ + if (list_length(data->add_msg_prefixes) > 0) { + ListCell *lc; + bool skip = true; + + foreach(lc, data->add_msg_prefixes) { + char *p = (char*)lfirst(lc); + + if (strcmp(p, prefix) == 0) + skip = false; + } + + if (skip) { + elog(DEBUG2, "message prefix \"%s\" was skipped", prefix); + return; + } + } + + if (data->format_version == format_version_2) + pg_decode_message_v2(ctx, txn, lsn, transactional, prefix, content_size, content); + else if (data->format_version == format_version_1) + pg_decode_message_v1(ctx, txn, lsn, transactional, prefix, content_size, content); + else + elog(ERROR, "format version %d is not supported", data->format_version); +} + +static void pg_decode_message_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr lsn, bool transactional, const char *prefix, Size + content_size, const char *content) +{ + JsonDecodingData *data; + MemoryContext old; + char *content_str; + + data = (JsonDecodingData*)ctx->output_plugin_private; + + /* Avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + /* + * write immediately iif (i) write-in-chunks=1 or (ii) non-transactional + * messages. + */ + if (data->write_in_chunks || !transactional) + OutputPluginPrepareWrite(ctx, true); + + /* + * increment counter only for transactional messages because + * non-transactional message has only one object. + */ + if (transactional) + data->nr_changes++; + + /* if we don't write in chunks, we need a newline here */ + if (!data->write_in_chunks && transactional) + appendStringInfo(ctx->out, "%s", data->nl); + + /* build a complete JSON object for non-transactional message */ + if (!transactional) + appendStringInfo(ctx->out, "{%s%s\"change\":%s[%s", data->nl, data->ht, data->sp, data->nl); + + appendStringInfo(ctx->out, "%s%s", data->ht, data->ht); + + if (data->nr_changes > 1) + appendStringInfoChar(ctx->out, ','); + + appendStringInfo(ctx->out, "{%s%s%s%s\"kind\":%s\"message\",%s", data->nl, data->ht, data->ht, + data->ht, data->sp, data->nl); + + if (transactional) + appendStringInfo(ctx->out, "%s%s%s\"transactional\":%strue,%s", data->ht, data->ht, + data->ht, data->sp, data->nl); + else + appendStringInfo(ctx->out, "%s%s%s\"transactional\":%sfalse,%s", data->ht, data->ht, + data->ht, data->sp, data->nl); + + appendStringInfo(ctx->out, "%s%s%s\"prefix\":%s", data->ht, data->ht, data->ht, data->sp); + escape_json(ctx->out, prefix); + appendStringInfo(ctx->out, ",%s%s%s%s\"content\":%s", data->nl, data->ht, data->ht, data->ht, data->sp); + + content_str = (char *) palloc0((content_size + 1) * sizeof(char)); + strncpy(content_str, content, content_size); + escape_json(ctx->out, content_str); + pfree(content_str); + + appendStringInfo(ctx->out, "%s%s%s}", data->nl, data->ht, data->ht); + + /* build a complete JSON object for non-transactional message */ + if (!transactional) + appendStringInfo(ctx->out, "%s%s]%s}", data->nl, data->ht, data->nl); + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + + if (data->write_in_chunks || !transactional) + OutputPluginWrite(ctx, true); +} + +static void pg_decode_message_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr lsn, bool transactional, const char *prefix, Size + content_size, const char *content) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + MemoryContext old; + char *content_str; + + /* Avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + OutputPluginPrepareWrite(ctx, true); + appendStringInfoChar(ctx->out, '{'); + appendStringInfoString(ctx->out, "\"action\":\"M\""); + + if (data->include_xids) { + /* + * Non-transactional messages can have no xid, hence, assigns null in + * this case. Assigns null for xid in non-transactional messages + * because in some cases there isn't an assigned xid. + * This same logic is valid for timestamp and origin. + */ + if (transactional) + appendStringInfo(ctx->out, ",\"xid\":%lu", txn->xid); + + else + appendStringInfoString(ctx->out, ",\"xid\":null"); + } + + if (data->include_timestamp) { + if (transactional) + appendStringInfo(ctx->out, ",\"timestamp\":\"%s\"", timestamptz_to_str(txn->commit_time)); + else + appendStringInfoString(ctx->out, ",\"timestamp\":null"); + } + + if (data->include_origin) { + if (transactional) + appendStringInfo(ctx->out, ",\"origin\":%u", txn->origin_id); + else + appendStringInfo(ctx->out, ",\"origin\":null"); + } + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(lsn))); + appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str); + pfree(lsn_str); + } + + if (transactional) + appendStringInfoString(ctx->out, ",\"transactional\":true"); + else + appendStringInfoString(ctx->out, ",\"transactional\":false"); + + appendStringInfoString(ctx->out, ",\"prefix\":"); + escape_json(ctx->out, prefix); + + appendStringInfoString(ctx->out, ",\"content\":"); + content_str = (char *) palloc0((content_size + 1) * sizeof(char)); + strncpy(content_str, content, content_size); + escape_json(ctx->out, content_str); + pfree(content_str); + + appendStringInfoChar(ctx->out, '}'); + OutputPluginWrite(ctx, true); + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); +} +#endif + +#if PG_VERSION_NUM >= 110000 +/* Callback for TRUNCATE command */ +static void pg_decode_truncate(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, int n, Relation relations[], + ReorderBufferChange *change) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + + if (data->format_version == format_version_2) + pg_decode_truncate_v2(ctx, txn, n, relations, change); + else if (data->format_version == format_version_1) + pg_decode_truncate_v1(ctx, txn, n, relations, change); + else + elog(ERROR, "format version %d is not supported", data->format_version); +} + +static void pg_decode_truncate_v1(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, int n, Relation relations[], + ReorderBufferChange *change) +{ +#ifdef _NOT_USED + JsonDecodingData *data; + MemoryContext old; + int i; + + data = (JsonDecodingData*)ctx->output_plugin_private; + + if (!data->actions.truncate) { + elog(DEBUG3, "ignore TRUNCATE"); + return; + } + + /* Avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + if (data->write_in_chunks) + OutputPluginPrepareWrite(ctx, true); + + /* + * increment counter only for transactional messages because + * non-transactional message has only one object. + */ + data->nr_changes++; + + /* if we don't write in chunks, we need a newline here */ + if (!data->write_in_chunks) + appendStringInfo(ctx->out, "%s", data->nl); + + appendStringInfo(ctx->out, "%s%s", data->ht, data->ht); + + if (data->nr_changes > 1) + appendStringInfoChar(ctx->out, ','); + + appendStringInfo(ctx->out, "{%s%s%s%s\"kind\":%s\"truncate\",%s", data->nl, data->ht, data->ht, + data->ht, data->sp, data->nl); + + if (data->include_xids) + appendStringInfo(ctx->out, "%s%s%s\"xid\":%s%lu,%s", data->ht, data->ht, data->ht, + data->sp, txn->xid, data->nl); + + if (data->include_timestamp) + appendStringInfo(ctx->out, "%s%s%s\"timestamp\":%s\"%s\",%s", data->ht, data->ht, + data->ht, data->sp, timestamptz_to_str(txn->commit_time), data->nl); + + if (data->include_origin) + appendStringInfo(ctx->out, "%s%s%s\"origin\":%s%u,%s", data->ht, data->ht, data->ht, + data->sp, txn->origin_id, data->nl); + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn))); + appendStringInfo(ctx->out, "%s%s%s\"lsn\":%s\"%s\",%s", data->ht, data->ht, + data->ht, data->sp, lsn_str, data->nl); + pfree(lsn_str); + } + + for (i = 0; i < n; i++) { + if (data->include_schemas) { + appendStringInfo(ctx->out, "%s%s%s\"schema\":%s", data->ht, data->ht, data->ht, data->sp); + escape_json(ctx->out, get_namespace_name(RelationGetNamespace(relations[i]))); + appendStringInfo(ctx->out, ",%s", data->nl); + } + + appendStringInfo(ctx->out, "%s%s%s\"table\":%s", data->ht, data->ht, data->ht, data->sp); + escape_json(ctx->out, RelationGetRelationName(relations[i])); + } + + appendStringInfo(ctx->out, "%s%s%s}", data->nl, data->ht, data->ht); + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); + + if (data->write_in_chunks) + OutputPluginWrite(ctx, true); +#endif +} + +static void pg_decode_truncate_v2(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, int n, Relation relations[], + ReorderBufferChange *change) +{ + JsonDecodingData *data = (JsonDecodingData*)ctx->output_plugin_private; + MemoryContext old; + int i; + + if (!data->actions.truncate) { + elog(DEBUG3, "ignore TRUNCATE"); + return; + } + + /* avoid leaking memory by using and resetting our own context */ + old = MemoryContextSwitchTo(data->context); + + for (i = 0; i < n; i++) { + char *schemaname; + char *tablename; + + /* schema and table names are used for chosen tables */ + schemaname = get_namespace_name(RelationGetNamespace(relations[i])); + tablename = RelationGetRelationName(relations[i]); + + /* Exclude tables, if available */ + if (list_length(data->filter_tables) > 0) { + ListCell *lc; + + foreach(lc, data->filter_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was filtered out", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + continue; + } + } + } + } + + /* Add tables */ + if (list_length(data->add_tables) > 0) { + ListCell *lc; + bool skip = true; + + /* all tables in all schemas are added by default */ + foreach(lc, data->add_tables) { + SelectTable *t = (SelectTable*)lfirst(lc); + + if (t->allschemas || strcmp(t->schemaname, schemaname) == 0) { + if (t->alltables || strcmp(t->tablename, tablename) == 0) { + elog(DEBUG2, "\"%s\".\"%s\" was added", + ((t->allschemas) ? "*" : t->schemaname), + ((t->alltables) ? "*" : t->tablename)); + skip = false; + } + } + } + + /* table was not found */ + if (skip) + continue; + } + + OutputPluginPrepareWrite(ctx, true); + appendStringInfoChar(ctx->out, '{'); + appendStringInfoString(ctx->out, "\"action\":\"T\""); + + if (data->include_xids) + appendStringInfo(ctx->out, ",\"xid\":%lu", txn->xid); + + if (data->include_timestamp) + appendStringInfo(ctx->out, ",\"timestamp\":\"%s\"", timestamptz_to_str(txn->commit_time)); + + if (data->include_origin) + appendStringInfo(ctx->out, ",\"origin\":%u", txn->origin_id); + + if (data->include_lsn) { + char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn))); + appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str); + pfree(lsn_str); + } + + if (data->include_schemas) { + appendStringInfo(ctx->out, ",\"schema\":"); + escape_json(ctx->out, schemaname); + } + + appendStringInfo(ctx->out, ",\"table\":"); + escape_json(ctx->out, tablename); + + appendStringInfoChar(ctx->out, '}'); + OutputPluginWrite(ctx, true); + } + + MemoryContextSwitchTo(old); + MemoryContextReset(data->context); +} +#endif + +static bool parse_table_identifier(List *qualified_tables, char separator, List **select_tables) +{ + ListCell *lc; + + foreach(lc, qualified_tables) { + char *str = (char*)lfirst(lc); + char *startp; + char *nextp; + int len; + SelectTable *t = (SelectTable*)palloc0(sizeof(SelectTable)); + + /* + * Detect a special character that means all schemas. There could be a + * schema named "*" thus this test should be before we remove the + * escape character. + */ + if (str[0] == '*' && str[1] == '.') + t->allschemas = true; + else + t->allschemas = false; + + startp = nextp = str; + while (*nextp && *nextp != separator) { + /* remove escape character */ + if (*nextp == '\\') + memmove(nextp, nextp + 1, strlen(nextp)); + nextp++; + } + len = nextp - startp; + + /* if separator was not found, schema was not informed */ + if (*nextp == '\0') { + pfree(t); + return false; + } else { + /* schema name */ + t->schemaname = (char *) palloc0((len + 1) * sizeof(char)); + strncpy(t->schemaname, startp, len); + + nextp++; /* jump separator */ + startp = nextp; /* start new identifier (table name) */ + + /* + * Detect a special character that means all tables. There could be + * a table named "*" thus this test should be before that we remove + * the escape character. + */ + if (startp[0] == '*' && startp[1] == '\0') + t->alltables = true; + else + t->alltables = false; + + while (*nextp) { + /* remove escape character */ + if (*nextp == '\\') + memmove(nextp, nextp + 1, strlen(nextp)); + nextp++; + } + len = nextp - startp; + + /* table name */ + t->tablename = (char *) palloc0((len + 1) * sizeof(char)); + strncpy(t->tablename, startp, len); + } + + *select_tables = lappend(*select_tables, t); + } + + return true; +} + +static bool string_to_SelectTable(char *rawstring, char separator, List **select_tables) +{ + char *nextp; + bool done = false; + List *qualified_tables = NIL; + + nextp = rawstring; + + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace */ + } + + if (*nextp == '\0') { + return true; /* allow empty string */ + } + /* At the top of the loop, we are at start of a new identifier. */ + do { + char *curname; + char *endp; + char *qname; + + curname = nextp; + while (*nextp && *nextp != separator && !isspace(*nextp)) { + if (*nextp == '\\') { + nextp++; /* ignore next character because of escape */ + } + nextp++; + } + endp = nextp; + if (curname == nextp) + return false; /* empty unquoted name not allowed */ + + while (isspace(*nextp)) { + nextp++; /* skip trailing whitespace */ + } + if (*nextp == separator) { + nextp++; + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace for next */ + } + /* we expect another name, so done remains false */ + } else if (*nextp == '\0') { + done = true; + } else { + return false; /* invalid syntax */ + } + /* Now safe to overwrite separator with a null */ + *endp = '\0'; + /* + * Finished isolating current name --- add it to list + */ + qname = pstrdup(curname); + qualified_tables = lappend(qualified_tables, qname); + + /* Loop back if we didn't reach end of string */ + } while (!done); + + if (!parse_table_identifier(qualified_tables, '.', select_tables)) + return false; + list_free_deep(qualified_tables); + return true; +} + +static bool split_string_to_list(char *rawstring, char separator, List **sl) +{ + char *nextp; + bool done = false; + + nextp = rawstring; + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace */ + } + if (*nextp == '\0') { + return true; /* allow empty string */ + } + /* At the top of the loop, we are at start of a new identifier. */ + do { + char *curname; + char *endp; + char *pname; + curname = nextp; + while (*nextp && *nextp != separator && !isspace(*nextp)) { + if (*nextp == '\\') { + nextp++; /* ignore next character because of escape */ + } + nextp++; + } + endp = nextp; + if (curname == nextp) { + return false; /* empty unquoted name not allowed */ + } + + while (isspace(*nextp)) { + nextp++; /* skip trailing whitespace */ + } + if (*nextp == separator) { + nextp++; + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace for next */ + } + /* we expect another name, so done remains false */ + } else if (*nextp == '\0') { + done = true; + } else { + return false; /* invalid syntax */ + } + /* Now safe to overwrite separator with a null */ + *endp = '\0'; + /* + * Finished isolating current name --- add it to list + */ + pname = pstrdup(curname); + *sl = lappend(*sl, pname); + /* Loop back if we didn't reach end of string */ + } while (!done); + + return true; +} + +/* + * Convert a string into a list of Oids + */ +static bool split_string_to_oid_list(char *rawstring, char separator, List **sl) +{ + char *nextp; + bool done = false; + + nextp = rawstring; + + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace */ + } + + if (*nextp == '\0') { + return true; /* allow empty string */ + } + + /* At the top of the loop, we are at start of a new identifier. */ + do { + char *tok; + char *endp; + Oid originid; + tok = nextp; + while (*nextp && *nextp != separator && !isspace(*nextp)) { + if (*nextp == '\\') { + nextp++; /* ignore next character because of escape */ + } + nextp++; + } + endp = nextp; + while (isspace(*nextp)) { + nextp++; /* skip trailing whitespace */ + } + if (*nextp == separator) { + nextp++; + while (isspace(*nextp)) { + nextp++; /* skip leading whitespace for next */ + } + /* we expect another name, so done remains false */ + } else if (*nextp == '\0') { + done = true; + } else { + return false; /* invalid syntax */ + } + /* Now safe to overwrite separator with a null */ + *endp = '\0'; + /* + * Finished isolating origin id --- add it to list + */ + originid = (Oid) atoi(tok); + *sl = lappend_oid(*sl, originid); + /* Loop back if we didn't reach end of string */ + } while (!done); + return true; +} +static bool pg_filter_by_origin(LogicalDecodingContext *ctx, RepOriginId origin_id) +{ + JsonDecodingData *data = (JsonDecodingData*) ctx->output_plugin_private; + elog(DEBUG3, "origin: %u", origin_id); + /* changes produced locally are never filtered */ + if (origin_id == InvalidRepOriginId) { + return false; + } + /* Filter origins, if available */ + if (list_length(data->filter_origins) > 0 && list_member_oid(data->filter_origins, origin_id)) { + elog(DEBUG2, "origin \"%u\" was filtered out", origin_id); + return true; + } + + /* + * * There isn't a list of origins to filter or origin is not contained in + * * the filter list hence forward to all subscribers. + * */ + return false; +} -- Gitee