├── .dockerignore ├── sql ├── jsoncdc.sql └── uninstall_jsoncdc.sql ├── src ├── magic.c └── lib.rs ├── util ├── get_version ├── docker ├── checkstyle └── travis ├── jsoncdc.control ├── .gitignore ├── rustfmt.toml ├── .travis.yml ├── test ├── expected │ ├── text.out │ ├── escaping.out │ ├── message.out │ ├── base.out │ ├── tricky.out │ └── toast.out └── sql │ ├── escaping.sql │ ├── text.sql │ ├── base.sql │ ├── bigdata.sql │ ├── tricky.sql │ ├── message.sql │ └── toast.sql ├── licenses ├── apache └── postgres ├── Cargo.toml ├── Dockerfile ├── doc └── jsoncdc.md ├── META.json ├── CONTRIBUTING.md ├── Makefile └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .git/ 3 | -------------------------------------------------------------------------------- /sql/jsoncdc.sql: -------------------------------------------------------------------------------- 1 | --- Do nothing. 2 | -------------------------------------------------------------------------------- /sql/uninstall_jsoncdc.sql: -------------------------------------------------------------------------------- 1 | --- Do nothing. 2 | -------------------------------------------------------------------------------- /src/magic.c: -------------------------------------------------------------------------------- 1 | /* Gain access to Pg_magic_func() */ 2 | 3 | #include "postgres.h" 4 | #include "fmgr.h" 5 | 6 | PG_MODULE_MAGIC; 7 | -------------------------------------------------------------------------------- /util/get_version: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | pg_short_version=pg"`pg_config --version | cut -d' ' -f2 | tr -d . | cut -c-2`" 4 | echo "$pg_short_version" 5 | -------------------------------------------------------------------------------- /jsoncdc.control: -------------------------------------------------------------------------------- 1 | # jsoncdc extension 2 | comment = 'JSON Logical Decoding' 3 | default_version = '0.0.12' 4 | module_pathname = '$libdir/jsoncdc' 5 | relocatable = true 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled files 2 | *.o 3 | *.so 4 | *.rlib 5 | *.dll 6 | 7 | # Executables 8 | *.exe 9 | 10 | # Generated by Cargo 11 | /target/ 12 | *.swp 13 | *.lock 14 | sql/jsoncdc-*.sql 15 | results 16 | -------------------------------------------------------------------------------- /util/docker: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | cat <<-EOF >> $PGDATA/postgresql.conf 5 | max_replication_slots = 1 6 | max_wal_senders = 1 7 | wal_level = logical 8 | EOF 9 | 10 | cat <<-EOF >> $PGDATA/pg_hba.conf 11 | host replication all 0.0.0.0/0 trust 12 | local replication all trust 13 | EOF 14 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | ideal_width = 79 2 | max_width = 79 3 | 4 | fn_single_line = true 5 | struct_lit_width = 50 6 | struct_variant_width = 50 7 | 8 | reorder_imports = false 9 | reorder_imported_names = true 10 | 11 | chain_base_indent = 'Visual' 12 | chain_indent = 'Visual' 13 | chains_overflow_last = false 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | sudo: required 3 | os: 4 | - linux 5 | # - osx 6 | addons: 7 | postgresql: "9.6" 8 | apt: 9 | packages: 10 | - python-pip 11 | - libpq-dev 12 | - postgresql-server-dev-all 13 | - libclang1-3.4 14 | - libclang-3.4-dev 15 | - libclang-common-3.4-dev 16 | - clang-3.4 17 | before_script: util/travis 18 | script: make test 19 | -------------------------------------------------------------------------------- /util/checkstyle: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit -o nounset -o pipefail 3 | 4 | export PATH=~/.cargo/bin:"$PATH" 5 | 6 | find src -type f -name '*.rs.bk' -delete 7 | 8 | cargo fmt -- --write-mode replace 9 | 10 | n=0 11 | while read -d '' -r path 12 | do 13 | [[ -s $path ]] || continue 14 | echo "Not formatted as auto-formatting would: ${path%.bk}" 15 | diff -u "$path" "${path%.bk}" | head -n10 16 | n=$((n + 1)) 17 | done < <(find src -type f -name '*.rs.bk' -print0) 18 | 19 | exit "$n" 20 | -------------------------------------------------------------------------------- /test/expected/text.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | { "schema": [{"i":"integer"},{"s":"text"}], "table": "jsoncdc.test" } 5 | { "insert": {"i":1,"s":"simple text"}, "table": "jsoncdc.test" } 6 | { "insert": {"i":2,"s":"text with \"quoted\" text"}, "table": "jsoncdc.test" } 7 | { "insert": {"i":3,"s":"newlines\nand\r\ncarriage returns"}, "table": "jsoncdc.test" } 8 | { "insert": {"i":4,"s":"quoted text with\n\"newline\""}, "table": "jsoncdc.test" } 9 | 10 | deleted logical replication slot 11 | 12 | -------------------------------------------------------------------------------- /licenses/apache: -------------------------------------------------------------------------------- 1 | Copyright 2016 Alex Newman, Jason Dusek 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this code except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /test/expected/escaping.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | { "schema": [{"i":"integer"}], "table": "jsoncdc.\"****\"" } 5 | { "insert": {"i":1}, "table": "jsoncdc.\"****\"" } 6 | { "insert": {"i":2}, "table": "jsoncdc.\"****\"" } 7 | { "insert": {"i":3}, "table": "jsoncdc.\"****\"" } 8 | { "insert": {"i":4}, "table": "jsoncdc.\"****\"" } 9 | { "insert": {"i":5}, "table": "jsoncdc.\"****\"" } 10 | { "insert": {"i":6}, "table": "jsoncdc.\"****\"" } 11 | { "insert": {"i":7}, "table": "jsoncdc.\"****\"" } 12 | { "insert": {"i":8}, "table": "jsoncdc.\"****\"" } 13 | 14 | deleted logical replication slot 15 | 16 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "jsoncdc" 3 | version = "0.0.12" 4 | authors = ["Alex Newman ", 5 | "Jason Dusek "] 6 | build = "build.rs" 7 | 8 | 9 | [features] 10 | # Enables support for PG 9.6 (and later) logical decoding messages. 11 | pg-ldc-messages = ["serde_json", "base64"] 12 | 13 | [lib] 14 | name = "jsoncdc" 15 | crate-type = ["dylib"] 16 | 17 | [dependencies] 18 | libc = "*" 19 | base64 = { version = "*", optional = true } 20 | rpgffi = "0.3.3" 21 | serde_json = { version = "1.*", optional = true } 22 | 23 | [dev-dependencies] 24 | rustfmt = "*" 25 | 26 | [build-dependencies] 27 | gcc = "*" 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PG_VERSION 2 | 3 | FROM postgres:${PG_VERSION} 4 | 5 | ENV CARGO_HOME /cargo 6 | ENV PATH $CARGO_HOME/bin:$PATH 7 | ENV SRC_PATH /src 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | ca-certificates curl git make gcc gcc-multilib postgresql-server-dev-$PG_MAJOR=$PG_VERSION \ 12 | python-pip python-setuptools \ 13 | && rm -rf /var/lib/apt/lists/* \ 14 | && curl -sf https://static.rust-lang.org/rustup.sh -o rustup.sh \ 15 | && bash rustup.sh --disable-sudo -y --verbose \ 16 | && pip install pgxnclient \ 17 | && cargo install rustfmt \ 18 | && mkdir -p "$CARGO_HOME" 19 | 20 | WORKDIR $SRC_PATH 21 | 22 | VOLUME $SRC_PATH 23 | 24 | COPY util/docker /docker-entrypoint-initdb.d/docker.sh 25 | -------------------------------------------------------------------------------- /test/expected/message.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | visible 5 | 6 | invisible 7 | 8 | non-transactional 9 | 10 | transactional 11 | 12 | non-transactional 13 | 14 | json-recognization 15 | 16 | binary-encoding 17 | 18 | { "prefix": "sent first", "message": "#1", "transactional": false } 19 | { "prefix": "sent third", "message": "#2", "transactional": false } 20 | { "prefix": "sent fifth", "message": "#3", "transactional": false } 21 | { "prefix": "sent fourth", "message": "#4", "transactional": true } 22 | { "prefix": "sent json", "message": {"a":1,"b":[2,2]}, "transactional": true } 23 | { "prefix": "sent binary", "message": {"base64":"AAECAw=="}, "transactional": true } 24 | 25 | deleted logical replication slot 26 | 27 | -------------------------------------------------------------------------------- /licenses/postgres: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Alex Newman & Jason Dusek (hereafter, Authors) 2 | 3 | Permission to use, copy, modify, and distribute this software and its 4 | documentation for any purpose, without fee, and without a written agreement is 5 | hereby granted, provided that the above copyright notice and this paragraph and 6 | the following two paragraphs appear in all copies. 7 | 8 | IN NO EVENT SHALL AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 9 | INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF 10 | THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF AUTHORS HAS BEEN 11 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | 13 | AUTHORS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 15 | THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND AUTHORS HAS NO 16 | OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 17 | MODIFICATIONS. 18 | -------------------------------------------------------------------------------- /test/sql/escaping.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | \t on 4 | \x off 5 | SELECT 'created logical replication slot' 6 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 7 | 8 | BEGIN; 9 | 10 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 11 | SET LOCAL search_path TO jsoncdc, public; 12 | CREATE EXTENSION IF NOT EXISTS hstore; 13 | 14 | CREATE TABLE IF NOT EXISTS "****" ( 15 | i integer PRIMARY KEY 16 | ); 17 | 18 | INSERT INTO "****" (i) SELECT i FROM generate_series(1, 8) AS i; 19 | 20 | CREATE VIEW changedata AS 21 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 22 | 23 | END; 24 | 25 | --- Displays only generated JSON, no replication slot metadata, and omits 26 | --- transaction IDs (which would confuse the testing framework because they 27 | --- vary from run to run). 28 | SELECT * FROM jsoncdc.changedata 29 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 30 | 31 | SELECT 'deleted logical replication slot' 32 | FROM pg_drop_replication_slot('jsoncdc'); 33 | 34 | DROP SCHEMA jsoncdc CASCADE; 35 | -------------------------------------------------------------------------------- /doc/jsoncdc.md: -------------------------------------------------------------------------------- 1 | jsoncdc 2 | ======= 3 | 4 | Synopsis 5 | -------- 6 | 7 | Translates Postgres WAL to JSON with Logical Decoding. 8 | 9 | Description 10 | ----------- 11 | 12 | Inspired by DDP and RethinkDB's changefeeds, the `jsoncdc` extension 13 | provides a schema aware Logical Decoding plugin that translates Postgres WAL 14 | to JSON. 15 | 16 | The JSON for each transaction includes the transaction ID, transaction 17 | timestamp, a `{ "table": ... }` entry describing the schema of each affected 18 | table, and following each table entry, an entry for each `INSERT`, `UPDATE` 19 | and `DELETE` on that table. 20 | 21 | Usage 22 | ----- 23 | 24 | SELECT * FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 25 | --- Wait for some transactions, and then: 26 | SELECT * FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 27 | 28 | Support 29 | ------- 30 | 31 | https://github.com/posix4e/jsoncdc 32 | https://github.com/posix4e/jsoncdc/issues 33 | 34 | Author 35 | ------ 36 | 37 | * [Alex Newman](https://github.com/posix4e) 38 | * [Jason Dusek](https://github.com/solidsnack) 39 | 40 | Copyright and License 41 | --------------------- 42 | 43 | Copyright (c) 2016 Alex Newman, Jason Dusek 44 | 45 | -------------------------------------------------------------------------------- /test/sql/text.sql: -------------------------------------------------------------------------------- 1 | 2 | \set ECHO none 3 | SET client_min_messages TO error; 4 | \t on 5 | \x off 6 | SELECT 'created logical replication slot' 7 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 8 | 9 | BEGIN; 10 | 11 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 12 | SET LOCAL search_path TO jsoncdc, public; 13 | CREATE EXTENSION IF NOT EXISTS hstore; 14 | 15 | CREATE TABLE IF NOT EXISTS test ( 16 | i integer PRIMARY KEY, 17 | s text NOT NULL DEFAULT '' 18 | ); 19 | 20 | INSERT INTO test 21 | VALUES (1, 'simple text'), 22 | (2, E'text with "quoted" text'), 23 | (3, E'newlines\nand\r\ncarriage returns'), 24 | (4, E'quoted text with\n"newline"'); 25 | 26 | CREATE VIEW changedata AS 27 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 28 | 29 | END; 30 | 31 | --- Displays only generated JSON, no replication slot metadata, and omits 32 | --- transaction IDs (which would confuse the testing framework because they 33 | --- vary from run to run). 34 | SELECT * FROM jsoncdc.changedata 35 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 36 | 37 | SELECT 'deleted logical replication slot' 38 | FROM pg_drop_replication_slot('jsoncdc'); 39 | 40 | DROP SCHEMA jsoncdc CASCADE; 41 | -------------------------------------------------------------------------------- /META.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsoncdc", 3 | "abstract": "Translates Postgres WAL to JSON", 4 | "description": "A Rust plugin for Postgres Change Data Capture.", 5 | "version": "0.0.12", 6 | "maintainer": [ 7 | "Alex Newman ", 8 | "Jason Dusek " 9 | ], 10 | "license": { 11 | "PostgreSQL": "http://www.postgresql.org/about/licence", 12 | "Apache": "http://www.apache.org/licenses/LICENSE-2.0" 13 | }, 14 | "provides": { 15 | "jsoncdc": { 16 | "abstract": "Translates Postgres WAL to JSON", 17 | "file": "sql/jsoncdc.sql", 18 | "docfile": "doc/jsoncdc.md", 19 | "version": "0.0.12" 20 | } 21 | }, 22 | "release_status": "unstable", 23 | "resources": { 24 | "bugtracker": { 25 | "web": "https://github.com/posix4e/jsoncdc/issues" 26 | }, 27 | "repository": { 28 | "url": "https://github.com/posix4e/jsoncdc.git", 29 | "web": "https://github.com/posix4e/jsoncdc", 30 | "type": "git" 31 | } 32 | }, 33 | 34 | "generated_by": "Jason Dusek", 35 | 36 | "meta-spec": { 37 | "version": "1.0.0", 38 | "url": "http://pgxn.org/meta/spec.txt" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/sql/base.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | \t on 4 | \x off 5 | SELECT 'created logical replication slot' 6 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 7 | 8 | BEGIN; 9 | 10 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 11 | SET LOCAL search_path TO jsoncdc, public; 12 | CREATE EXTENSION IF NOT EXISTS hstore; 13 | 14 | CREATE TABLE IF NOT EXISTS test ( 15 | i integer PRIMARY KEY, 16 | h hstore NOT NULL DEFAULT '' 17 | ); 18 | 19 | INSERT INTO test (i) SELECT i FROM generate_series(1, 8) AS i; 20 | 21 | CREATE VIEW changedata AS 22 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 23 | 24 | END; 25 | 26 | BEGIN; 27 | SET LOCAL search_path TO jsoncdc, public; 28 | UPDATE test SET i = i * 10 WHERE i % 3 = 0; 29 | UPDATE test SET h = hstore('i', i::text)||hstore('2i', (2*i)::text); 30 | DELETE FROM test WHERE i % 2 = 1; 31 | END; 32 | 33 | --- Displays only generated JSON, no replication slot metadata, and omits 34 | --- transaction IDs (which would confuse the testing framework because they 35 | --- vary from run to run). 36 | SELECT * FROM jsoncdc.changedata 37 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 38 | 39 | SELECT 'deleted logical replication slot' 40 | FROM pg_drop_replication_slot('jsoncdc'); 41 | 42 | DROP SCHEMA jsoncdc CASCADE; 43 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to JSONCDC 2 | ----------------------- 3 | 4 | Please use `cargo fmt` as part of the commit process. (CI and `make test` do a 5 | style check so non-conformance will break the build.) 6 | 7 | Please ensure that contributed Bash, SQL, Python and other files all: 8 | 9 | 1. resemble the surrounding code, and 10 | 11 | 2. contain lines no longer than 79 columns. 12 | 13 | Using Docker for development 14 | ---------------------------- 15 | 16 | You can use the project's [Dockerfile](Dockerfile) to get a working development environment. 17 | 18 | ##### Usage 19 | 20 | Build the image locally: 21 | 22 | ```sh 23 | docker build -t jsoncdc-dev:9.5 --build-arg PG_VERSION=9.5 . 24 | ``` 25 | 26 | Start the container by mapping the source code volume - this should be done on the directory where you've checked out jsoncdc: 27 | 28 | ```sh 29 | docker run --rm -it --name jsoncdc -v $(pwd):/src jsoncdc-dev:9.5 30 | ``` 31 | 32 | Run the test suite on another shell using the `postgres`: 33 | 34 | ```sh 35 | docker exec jsoncdc bash -c 'make install && make test PGUSER=postgres' 36 | ``` 37 | 38 | ##### Environment 39 | 40 | - Cargo binaries are exposed on the `$PATH`. This means that `make test` will be able to run the `style` script correctly. 41 | - Postgres does not need any additional manual configuration. 42 | - The PGXN Client tool (`pgxnclient`) is pre-installed to allow `installcheck` to run correctly. 43 | -------------------------------------------------------------------------------- /test/sql/bigdata.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | \t on 4 | \x off 5 | SELECT 'created logical replication slot' 6 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 7 | 8 | BEGIN; 9 | 10 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 11 | SET LOCAL search_path TO jsoncdc, public; 12 | CREATE EXTENSION IF NOT EXISTS hstore; 13 | 14 | CREATE TABLE IF NOT EXISTS test ( 15 | i integer PRIMARY KEY, 16 | h hstore NOT NULL DEFAULT '' 17 | ); 18 | 19 | INSERT INTO test (i) SELECT i FROM generate_series(1, 1024) AS i; 20 | 21 | CREATE VIEW changedata AS 22 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 23 | 24 | END; 25 | 26 | BEGIN; 27 | SET LOCAL search_path TO jsoncdc, public; 28 | UPDATE test SET h = hstore('i', i::text) 29 | || hstore((SELECT array_agg(n::text) 30 | FROM generate_series(1, i) AS n), 31 | (SELECT array_agg(n::text) 32 | FROM generate_series(1, i) AS n)); 33 | DELETE FROM test WHERE i % 2 = 1; 34 | END; 35 | 36 | --- Displays only generated JSON, no replication slot metadata, and omits 37 | --- transaction IDs (which would confuse the testing framework because they 38 | --- vary from run to run). 39 | SELECT * FROM jsoncdc.changedata 40 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 41 | 42 | SELECT 'deleted logical replication slot' 43 | FROM pg_drop_replication_slot('jsoncdc'); 44 | 45 | DROP SCHEMA jsoncdc CASCADE; 46 | -------------------------------------------------------------------------------- /test/sql/tricky.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | \t on 4 | \x off 5 | SELECT 'created logical replication slot' 6 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 7 | 8 | BEGIN; 9 | 10 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 11 | SET LOCAL search_path TO jsoncdc, public; 12 | CREATE EXTENSION IF NOT EXISTS hstore; 13 | 14 | CREATE TABLE IF NOT EXISTS tab1 ( 15 | i integer PRIMARY KEY, 16 | h hstore NOT NULL DEFAULT '' 17 | ); 18 | 19 | CREATE TABLE IF NOT EXISTS tab2 ( 20 | i integer PRIMARY KEY, 21 | j integer NOT NULL DEFAULT 0 22 | ); 23 | 24 | INSERT INTO tab1 (i) VALUES (1); 25 | INSERT INTO tab2 (i) VALUES (1); 26 | 27 | INSERT INTO tab1 (i) VALUES (2); 28 | INSERT INTO tab2 (i) VALUES (2); 29 | 30 | INSERT INTO tab1 (i) VALUES (3); 31 | INSERT INTO tab2 (i) VALUES (3); 32 | 33 | INSERT INTO tab1 (i) VALUES (4); 34 | INSERT INTO tab2 (i) VALUES (4); 35 | 36 | --- Displays only generated JSON, no replication slot metadata, and omits 37 | --- transaction IDs (which would confuse the testing framework because they 38 | --- vary from run to run). 39 | CREATE VIEW changedata AS 40 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL) 41 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 42 | 43 | END; 44 | 45 | BEGIN; 46 | SET LOCAL search_path TO jsoncdc, public; 47 | UPDATE tab1 SET h = hstore('i', i::text)||hstore('2i', (2*i)::text); 48 | DELETE FROM tab1 WHERE i % 2 = 1; 49 | DELETE FROM tab2 WHERE i % 2 = 1; 50 | END; 51 | 52 | SELECT * FROM jsoncdc.changedata; 53 | 54 | SELECT 'deleted logical replication slot' 55 | FROM pg_drop_replication_slot('jsoncdc'); 56 | 57 | DROP SCHEMA jsoncdc CASCADE; 58 | -------------------------------------------------------------------------------- /test/sql/message.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | SET synchronous_commit = on; 4 | \t on 5 | \x off 6 | SELECT 'created logical replication slot' 7 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 8 | 9 | BEGIN; 10 | 11 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 12 | SET LOCAL search_path TO jsoncdc, public; 13 | 14 | CREATE VIEW changedata AS 15 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 16 | 17 | END; 18 | 19 | BEGIN; 20 | SELECT 'visible' 21 | FROM pg_logical_emit_message(false, 'sent first', '#1'); 22 | SELECT 'invisible' 23 | FROM pg_logical_emit_message(true, 'sent second', 'invisible'); 24 | ROLLBACK; 25 | 26 | BEGIN; 27 | SELECT 'non-transactional' 28 | FROM pg_logical_emit_message(false, 'sent third', '#2'); 29 | SELECT 'transactional' 30 | FROM pg_logical_emit_message(true, 'sent fourth', '#4'); 31 | SELECT 'non-transactional' 32 | FROM pg_logical_emit_message(false, 'sent fifth', '#3'); 33 | SELECT 'json-recognization' 34 | FROM pg_logical_emit_message(true, 'sent json', 35 | '{"a": 1, "b": [2, 2]}'::jsonb::text); 36 | SELECT 'binary-encoding' 37 | FROM pg_logical_emit_message(true, 'sent binary', '\x00010203'::bytea); 38 | COMMIT; 39 | 40 | --- Displays only generated JSON, no replication slot metadata, and omits 41 | --- transaction IDs (which would confuse the testing framework because they 42 | --- vary from run to run). 43 | SELECT * FROM jsoncdc.changedata 44 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 45 | 46 | SELECT 'deleted logical replication slot' 47 | FROM pg_drop_replication_slot('jsoncdc'); 48 | 49 | DROP SCHEMA jsoncdc CASCADE; 50 | -------------------------------------------------------------------------------- /test/expected/base.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.test" } 5 | { "insert": {"i":1,"h":{}}, "table": "jsoncdc.test" } 6 | { "insert": {"i":2,"h":{}}, "table": "jsoncdc.test" } 7 | { "insert": {"i":3,"h":{}}, "table": "jsoncdc.test" } 8 | { "insert": {"i":4,"h":{}}, "table": "jsoncdc.test" } 9 | { "insert": {"i":5,"h":{}}, "table": "jsoncdc.test" } 10 | { "insert": {"i":6,"h":{}}, "table": "jsoncdc.test" } 11 | { "insert": {"i":7,"h":{}}, "table": "jsoncdc.test" } 12 | { "insert": {"i":8,"h":{}}, "table": "jsoncdc.test" } 13 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.test" } 14 | { "update": {"i":30,"h":{}}, "@": {"i":3,"h":null}, "table": "jsoncdc.test" } 15 | { "update": {"i":60,"h":{}}, "@": {"i":6,"h":null}, "table": "jsoncdc.test" } 16 | { "update": {"i":1,"h":{"i": "1", "2i": "2"}}, "table": "jsoncdc.test" } 17 | { "update": {"i":2,"h":{"i": "2", "2i": "4"}}, "table": "jsoncdc.test" } 18 | { "update": {"i":4,"h":{"i": "4", "2i": "8"}}, "table": "jsoncdc.test" } 19 | { "update": {"i":5,"h":{"i": "5", "2i": "10"}}, "table": "jsoncdc.test" } 20 | { "update": {"i":7,"h":{"i": "7", "2i": "14"}}, "table": "jsoncdc.test" } 21 | { "update": {"i":8,"h":{"i": "8", "2i": "16"}}, "table": "jsoncdc.test" } 22 | { "update": {"i":30,"h":{"i": "30", "2i": "60"}}, "table": "jsoncdc.test" } 23 | { "update": {"i":60,"h":{"i": "60", "2i": "120"}}, "table": "jsoncdc.test" } 24 | { "delete": {}, "@": {"i":1,"h":null}, "table": "jsoncdc.test" } 25 | { "delete": {}, "@": {"i":5,"h":null}, "table": "jsoncdc.test" } 26 | { "delete": {}, "@": {"i":7,"h":null}, "table": "jsoncdc.test" } 27 | 28 | deleted logical replication slot 29 | 30 | -------------------------------------------------------------------------------- /test/sql/toast.sql: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | SET client_min_messages TO error; 3 | SET synchronous_commit TO on; 4 | \t on 5 | \x off 6 | 7 | SELECT 'created logical replication slot' 8 | FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 9 | 10 | BEGIN; 11 | 12 | CREATE SCHEMA IF NOT EXISTS jsoncdc; 13 | SET LOCAL search_path TO jsoncdc, public; 14 | 15 | CREATE VIEW changedata AS 16 | SELECT data FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 17 | 18 | END; 19 | 20 | SET search_path TO jsoncdc, public; 21 | 22 | CREATE SEQUENCE xpto_rand_seq START 79 INCREMENT 1499; -- portable "random" 23 | CREATE TABLE xpto ( 24 | id serial PRIMARY KEY, 25 | toasted_col1 text, 26 | rand1 float8 DEFAULT nextval('xpto_rand_seq'), 27 | toasted_col2 text, 28 | rand2 float8 DEFAULT nextval('xpto_rand_seq') 29 | ); 30 | 31 | --- Data that is TOAST but not so large as to be compressed. 32 | INSERT INTO xpto (toasted_col1, toasted_col2) 33 | SELECT string_agg(g.i::text, ''), string_agg((g.i*2)::text, '') 34 | FROM generate_series(1, 2000) g(i); 35 | 36 | SELECT * FROM jsoncdc.changedata 37 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 38 | 39 | --- Data large enough to force compression. 40 | INSERT INTO xpto (toasted_col2) 41 | SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) 42 | FROM generate_series(1, 500) g(i); 43 | 44 | UPDATE xpto 45 | SET toasted_col1 = (SELECT string_agg(g.i::text, '') 46 | FROM generate_series(1, 2000) AS g(i)) 47 | WHERE id = 1; 48 | 49 | DELETE FROM xpto WHERE id = 1; 50 | 51 | SELECT * FROM jsoncdc.changedata 52 | WHERE NOT (data LIKE '{ "begin": %' OR data LIKE '{ "commit": %'); 53 | 54 | SELECT 'deleted logical replication slot' 55 | FROM pg_drop_replication_slot('jsoncdc'); 56 | 57 | DROP SCHEMA jsoncdc CASCADE; 58 | -------------------------------------------------------------------------------- /test/expected/tricky.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.tab1" } 5 | { "insert": {"i":1,"h":{}}, "table": "jsoncdc.tab1" } 6 | { "schema": [{"i":"integer"},{"j":"integer"}], "table": "jsoncdc.tab2" } 7 | { "insert": {"i":1,"j":0}, "table": "jsoncdc.tab2" } 8 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.tab1" } 9 | { "insert": {"i":2,"h":{}}, "table": "jsoncdc.tab1" } 10 | { "schema": [{"i":"integer"},{"j":"integer"}], "table": "jsoncdc.tab2" } 11 | { "insert": {"i":2,"j":0}, "table": "jsoncdc.tab2" } 12 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.tab1" } 13 | { "insert": {"i":3,"h":{}}, "table": "jsoncdc.tab1" } 14 | { "schema": [{"i":"integer"},{"j":"integer"}], "table": "jsoncdc.tab2" } 15 | { "insert": {"i":3,"j":0}, "table": "jsoncdc.tab2" } 16 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.tab1" } 17 | { "insert": {"i":4,"h":{}}, "table": "jsoncdc.tab1" } 18 | { "schema": [{"i":"integer"},{"j":"integer"}], "table": "jsoncdc.tab2" } 19 | { "insert": {"i":4,"j":0}, "table": "jsoncdc.tab2" } 20 | { "schema": [{"i":"integer"},{"h":"jsoncdc.hstore"}], "table": "jsoncdc.tab1" } 21 | { "update": {"i":1,"h":{"i": "1", "2i": "2"}}, "table": "jsoncdc.tab1" } 22 | { "update": {"i":2,"h":{"i": "2", "2i": "4"}}, "table": "jsoncdc.tab1" } 23 | { "update": {"i":3,"h":{"i": "3", "2i": "6"}}, "table": "jsoncdc.tab1" } 24 | { "update": {"i":4,"h":{"i": "4", "2i": "8"}}, "table": "jsoncdc.tab1" } 25 | { "delete": {}, "@": {"i":1,"h":null}, "table": "jsoncdc.tab1" } 26 | { "delete": {}, "@": {"i":3,"h":null}, "table": "jsoncdc.tab1" } 27 | { "schema": [{"i":"integer"},{"j":"integer"}], "table": "jsoncdc.tab2" } 28 | { "delete": {}, "@": {"i":1,"j":null}, "table": "jsoncdc.tab2" } 29 | { "delete": {}, "@": {"i":3,"j":null}, "table": "jsoncdc.tab2" } 30 | 31 | deleted logical replication slot 32 | 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EXTENSION = jsoncdc 2 | EXTVERSION = $(shell egrep '^default_version += +' *.control | cut -d"'" -f2) 3 | 4 | DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql)) 5 | DOCS = $(wildcard doc/*.md) 6 | TESTS = $(wildcard test/sql/*.sql) 7 | REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS)) 8 | REGRESS_OPTS = --inputdir=test --load-language=plpgsql 9 | PG_CONFIG = pg_config 10 | PG91 = $(shell $(PG_CONFIG) --version | \ 11 | grep -qE " 8[.]| 9[.]0" && echo no || echo yes) 12 | PG96 = $(shell $(PG_CONFIG) --version | \ 13 | grep -qE " 8[.]| 9[.][0-5]" && echo no || echo yes) 14 | 15 | ifeq ($(PG91),yes) 16 | all: sql/$(EXTENSION)--$(EXTVERSION).sql 17 | 18 | sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql 19 | cp $< $@ 20 | 21 | EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql 22 | endif 23 | 24 | 25 | # Note that `MODULES = jsoncdc` implies a dependency on `jsoncdc.so`. 26 | MODULES := jsoncdc 27 | PGXX := $(shell util/get_version) 28 | HAZRUST := $(shell which cargo >/dev/null && echo yes || echo no) 29 | 30 | ifeq ($(shell uname -s),Darwin) 31 | LINK_FLAGS := -C link-args='-Wl,-undefined,dynamic_lookup' 32 | endif 33 | 34 | ifeq ($(PG96),yes) 35 | FEATURES := --features pg-ldc-messages 36 | else 37 | REGRESS := $(subst message,,$(REGRESS)) 38 | endif 39 | 40 | ifeq ($(HAZRUST),yes) 41 | .PHONY: cargo 42 | cargo: 43 | cargo rustc $(FEATURES) --release -- $(LINK_FLAGS) 44 | 45 | .PHONY: jsoncdc.so 46 | jsoncdc.so: base := target/release 47 | jsoncdc.so: lib = $(wildcard $(base)/libjsoncdc.so $(base)/libjsoncdc.dylib) 48 | jsoncdc.so: cargo 49 | cp $(lib) $@ 50 | 51 | .PHONY: cargoclean 52 | cargoclean: 53 | find . -name Cargo.lock -exec rm {} \; 54 | cargo clean 55 | else 56 | define CAN_HAZ_RUST 57 | 58 | We need a Rust toolchain (rustc and cargo) to compile this extension. 59 | 60 | See: https://www.rust-lang.org/downloads.html 61 | 62 | 63 | endef 64 | # NB: Not phony so if they build the extension somehow, the rest of the 65 | # install can be completed. 66 | jsoncdc.so: 67 | $(error $(CAN_HAZ_RUST)) 68 | 69 | .PHONY: cargoclean 70 | cargoclean: 71 | $(warning No Rust toolchain so not cleaning anything.) 72 | endif 73 | 74 | PGXS := $(shell $(PG_CONFIG) --pgxs) 75 | include $(PGXS) 76 | 77 | 78 | clean: cargoclean 79 | 80 | all: jsoncdc.so 81 | 82 | .PHONY: test 83 | test: 84 | pgxn check ./ 85 | util/checkstyle 86 | -------------------------------------------------------------------------------- /util/travis: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit -o nounset -o pipefail 3 | 4 | function main { 5 | case "${1:-${TRAVIS_OS_NAME:-}}" in 6 | linux) linux ;; 7 | osx) osx ;; 8 | *) echo "No handler for: ${1:-}" >&2 9 | esac 10 | } 11 | 12 | function tools { 13 | cargo install rustfmt 14 | sudo pip install pgxnclient 15 | } 16 | 17 | function hba { 18 | cat <<\EOF 19 | local replication all trust 20 | host replication all ::1/128 trust 21 | EOF 22 | 23 | } 24 | 25 | function conf { 26 | cat <<\EOF 27 | max_wal_senders = 1 28 | wal_level = logical 29 | max_replication_slots = 1 30 | EOF 31 | } 32 | 33 | function linux { 34 | tools 35 | 36 | VERSION=9.6 37 | PG_DIR=/etc/postgresql/"$VERSION"/main 38 | HBA_CONF="$PG_DIR"/pg_hba.conf 39 | CONF="$PG_DIR"/postgresql.conf 40 | 41 | sudo -E env PATH="$PATH" LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}" make install 42 | sudo pg_ctlcluster "$VERSION" main stop 43 | 44 | msg "Setting $HBA_CONF settings..." 45 | hba | sudo tee -a "$HBA_CONF" 46 | msg "Setting $CONF settings..." 47 | conf | sudo tee -a "$CONF" 48 | sudo pg_ctlcluster "$VERSION" main start 49 | } 50 | 51 | function osx { 52 | tools 53 | 54 | BREW_LOG=brew.log 55 | PG_DIR=/usr/local/var/postgres/ 56 | PG_LOG="$PG_DIR"/server.log 57 | HBA_CONF="$PG_DIR"/pg_hba.conf 58 | CONF="$PG_DIR"/postgresql.conf 59 | TIMEOUT=60 60 | 61 | pg_ctl -D "$PG_DIR" stop -s -m fast -t "$TIMEOUT" || true 62 | msg 'Removing old Postgresql...' 63 | rm -rf "$PG_DIR" 64 | 65 | brew update > "$BREW_LOG" 66 | brew uninstall postgresql --ignore-dependencies >> "$BREW_LOG" 67 | brew upgrade >> "$BREW_LOG" 68 | 69 | make clean all install 70 | 71 | msg "Setting $HBA_CONF settings..." 72 | hba >> "$HBA_CONF" 73 | msg "Setting $CONF settings..." 74 | conf >> "$CONF" 75 | 76 | pg_ctl -D "$PG_DIR" -l "$PG_LOG" -w -t "$TIMEOUT" start 77 | 78 | STARTED=false 79 | while ! "$STARTED" 80 | do 81 | pg_ctl status -D "$PG_DIR" && STARTED=true 82 | sleep 1 83 | done 84 | } 85 | 86 | 87 | ##################################################################### Utilities 88 | 89 | function msg { out "$*" >&2 ;} 90 | function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;} 91 | function out { printf '%s\n' "$*" ;} 92 | 93 | # Handles "no-match" exit code specified by POSIX for filtering tools. 94 | function maybe { "$@" || return $(( $? == 1 ? 0 : $? )) ;} 95 | 96 | 97 | ######################### Delegates to subcommands or runs main, as appropriate 98 | 99 | if declare -f -- "${1:-}" >/dev/null 100 | then "$@" 101 | else main "$@" 102 | fi 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Please Note:** 2 | 3 | JSONCDC is now maintained at, and released to [PGXN] from: 4 | 5 | https://github.com/instructure/jsoncdc 6 | 7 | Pull requests and issues, and feature requests and new ideas, should 8 | be filed there henceforth. 9 | 10 | [PGXN]: https://pgxn.org/dist/jsoncdc/ 11 | 12 | JSONCDC 13 | ======= 14 | 15 | [![Join the chat at https://gitter.im/posix4e/jsoncdc](https://badges.gitter.im/posix4e/jsoncdc.svg)](https://gitter.im/posix4e/jsoncdc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 16 | [![HuBoard badge](http://img.shields.io/badge/Hu-Board-7965cc.svg)](https://huboard.com/posix4e/jsoncdc) 17 | [![Linux Status](https://travis-ci.org/posix4e/jsoncdc.svg?branch=master)](https://travis-ci.org/posix4e/jsoncdc) 18 | [![Chat on Freenode](https://img.shields.io/badge/freenode-%23jsoncdc-brightgreen.svg)](irc://chat.freenode.net/jsoncdc) 19 | 20 | JSONCDC provides change data capture for Postgres, translating the Postgres 21 | write ahead log to JSON. 22 | 23 | It is written in Rust and, being short, is a good skeleton project for other 24 | would be plugin authors who'd like to use Rust to write Postgres extensions. 25 | 26 | Our library Requires rust stable 1.1 or greater. 27 | 28 | 29 | 30 | Copyright and License 31 | --------------------- 32 | 33 | Copyright (c) 2016 Alex Newman, Jason Dusek 34 | 35 | JSONCDC is available under multiple licenses: 36 | 37 | * the same license as Postgres itself (`licenses/postgres`), 38 | 39 | * the Apache 2.0 license (`licenses/apache`). 40 | 41 | 42 | Status 43 | ------ 44 | 45 | JSONCDC is presently installable with `pgxn`, from the unstable channel: 46 | `pgxn install jsoncdc --unstable`. 47 | 48 | 49 | Usage 50 | ----- 51 | 52 | A basic demo: 53 | 54 | SELECT * FROM pg_create_logical_replication_slot('jsoncdc', 'jsoncdc'); 55 | --- Wait for some transactions, and then: 56 | SELECT * FROM pg_logical_slot_get_changes('jsoncdc', NULL, NULL); 57 | 58 | The output format of `jsoncdc` is very regular, consisting of `begin`, 59 | `table`, `insert`, `update`, `delete` and [`message`][1] 60 | clauses as JSON objects, one per line: 61 | 62 | { "begin": } 63 | { "schema": , "table": } 64 | ...inserts, updates and deletes for this table... 65 | { "schema": , "table": } 66 | ...inserts, updates and deletes for next table... 67 | { "prefix": , "message": , "transactional": } 68 | ...messages may be mixed in at any point; they don't belong to a table... 69 | { "commit": , "t": } 70 | 71 | With `pg_recvlogical` and a little shell, you can leverage this very regular 72 | formatting to get each transaction batched into a separate file: 73 | 74 | pg_recvlogical -S jsoncdc -d postgres:/// --start -f - | 75 | while read -r line 76 | do 77 | case "$line" in 78 | '{ "begin": '*) # Close and reopen FD 9 for each new XID 79 | fields=( $line ) 80 | xid="${fields[2]}" 81 | exec 9>&- 82 | exec 9> "txn-${xid}.json" ;; 83 | esac 84 | printf '%s\n' "$line" >&9 # Use printf because echo is non-portable 85 | done 86 | 87 | [1]: https://postgresql.org/message-id/flat/56D36A2C.3070807%402ndquadrant.com 88 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::{CStr, CString}; 2 | use std::fmt; 3 | use std::mem::size_of; 4 | #[cfg(feature = "pg-ldc-messages")] 5 | use std::ops::Deref; 6 | #[cfg(feature = "pg-ldc-messages")] 7 | use std::slice::from_raw_parts; 8 | 9 | #[cfg(feature = "pg-ldc-messages")] 10 | extern crate base64; 11 | extern crate libc; 12 | extern crate rpgffi as pg; 13 | #[cfg(feature = "pg-ldc-messages")] 14 | extern crate serde_json; 15 | 16 | 17 | macro_rules! log { 18 | ($msg:expr) => { 19 | elog(file!(), line!(), "log()", $msg) 20 | } 21 | } 22 | 23 | 24 | // Implementation of initialization and callbacks. 25 | 26 | pub unsafe extern "C" fn init(cb: *mut pg::OutputPluginCallbacks) { 27 | (*cb).startup_cb = Some(startup); 28 | (*cb).begin_cb = Some(begin); 29 | (*cb).change_cb = Some(change); 30 | (*cb).commit_cb = Some(commit); 31 | (*cb).shutdown_cb = Some(shutdown); 32 | #[cfg(feature = "pg-ldc-messages")] 33 | { 34 | (*cb).message_cb = Some(message); 35 | } 36 | } 37 | 38 | unsafe extern "C" fn startup( 39 | ctx: *mut pg::LogicalDecodingContext, 40 | options: *mut pg::OutputPluginOptions, 41 | _is_init: pg::bool_, 42 | ) { 43 | let last_relid = pg::palloc0(size_of::()); 44 | (*ctx).output_plugin_private = last_relid; 45 | (*options).output_type = 46 | pg::OutputPluginOutputType::OUTPUT_PLUGIN_TEXTUAL_OUTPUT; 47 | } 48 | 49 | unsafe extern "C" fn begin( 50 | ctx: *mut pg::LogicalDecodingContext, 51 | txn: *mut pg::ReorderBufferTXN, 52 | ) { 53 | let s = CString::new("{ \"begin\": %u }").unwrap(); 54 | pg::OutputPluginPrepareWrite(ctx, CTRUE); 55 | pg::appendStringInfo((*ctx).out, s.as_ptr(), (*txn).xid); 56 | pg::OutputPluginWrite(ctx, CTRUE); 57 | } 58 | 59 | unsafe extern "C" fn change( 60 | ctx: *mut pg::LogicalDecodingContext, 61 | _txn: *mut pg::ReorderBufferTXN, 62 | relation: pg::Relation, 63 | change: *mut pg::ReorderBufferChange, 64 | ) { 65 | let relid = (*relation).rd_id; 66 | let last_relid: *mut pg::Oid = (*ctx).output_plugin_private as 67 | *mut pg::Oid; 68 | if *last_relid != relid { 69 | pg::OutputPluginPrepareWrite(ctx, CFALSE); 70 | append_schema(relation, (*ctx).out); 71 | pg::OutputPluginWrite(ctx, CFALSE); 72 | *last_relid = relid; 73 | } 74 | pg::OutputPluginPrepareWrite(ctx, CTRUE); 75 | append_change(relation, change, (*ctx).out); 76 | pg::OutputPluginWrite(ctx, CTRUE); 77 | } 78 | 79 | unsafe extern "C" fn commit( 80 | ctx: *mut pg::LogicalDecodingContext, 81 | txn: *mut pg::ReorderBufferTXN, 82 | _lsn: pg::XLogRecPtr, 83 | ) { 84 | let s = CString::new("{ \"commit\": %u, \"t\": \"%s\" }").unwrap(); 85 | let t = pg::timestamptz_to_str((*txn).commit_time); 86 | pg::OutputPluginPrepareWrite(ctx, CTRUE); 87 | pg::appendStringInfo((*ctx).out, s.as_ptr(), (*txn).xid, t); 88 | pg::OutputPluginWrite(ctx, CTRUE); 89 | let last_relid: *mut pg::Oid = (*ctx).output_plugin_private as 90 | *mut pg::Oid; 91 | *last_relid = 0; 92 | } 93 | 94 | unsafe extern "C" fn shutdown(ctx: *mut pg::LogicalDecodingContext) { 95 | pg::pfree((*ctx).output_plugin_private); 96 | } 97 | 98 | #[cfg(feature = "pg-ldc-messages")] 99 | unsafe extern "C" fn message( 100 | ctx: *mut pg::LogicalDecodingContext, 101 | _txn: *mut pg::ReorderBufferTXN, 102 | _lsn: pg::XLogRecPtr, 103 | transactional: pg::bool_, 104 | prefix: *const std::os::raw::c_char, 105 | message_size: pg::Size, 106 | message: *const std::os::raw::c_char, 107 | ) { 108 | pg::OutputPluginPrepareWrite(ctx, CTRUE); 109 | append_message(transactional, prefix, message_size, message, (*ctx).out); 110 | pg::OutputPluginWrite(ctx, CTRUE); 111 | } 112 | 113 | trait PGAppend { 114 | unsafe fn add_str(self, T); 115 | unsafe fn add_json(self, T); 116 | } 117 | 118 | impl<'a> PGAppend<&'a str> for pg::StringInfo { 119 | unsafe fn add_str(self, t: &'a str) { 120 | pg::appendStringInfoString(self, CString::new(t).unwrap().as_ptr()); 121 | } 122 | unsafe fn add_json(self, t: &'a str) { 123 | pg::escape_json(self, CString::new(t).unwrap().as_ptr()); 124 | } 125 | } 126 | 127 | impl PGAppend<*mut i8> for pg::StringInfo { 128 | unsafe fn add_str(self, t: *mut i8) { self.add_str(t as *const i8); } 129 | unsafe fn add_json(self, t: *mut i8) { self.add_json(t as *const i8); } 130 | } 131 | 132 | impl PGAppend<*const i8> for pg::StringInfo { 133 | unsafe fn add_str(self, t: *const i8) { 134 | pg::appendStringInfoString(self, t); 135 | } 136 | unsafe fn add_json(self, t: *const i8) { pg::escape_json(self, t); } 137 | } 138 | 139 | #[cfg(feature = "pg-ldc-messages")] 140 | struct OutputBytesInMostFriendlyWay(*const u8, usize); 141 | 142 | #[cfg(feature = "pg-ldc-messages")] 143 | impl PGAppend for pg::StringInfo { 144 | unsafe fn add_str(self, t: OutputBytesInMostFriendlyWay) { 145 | let bytes: &[u8] = from_raw_parts(t.0, t.1); 146 | let decoded = String::from_utf8_lossy(bytes); 147 | self.add_str(decoded.deref()); 148 | } 149 | unsafe fn add_json(self, t: OutputBytesInMostFriendlyWay) { 150 | let bytes: &[u8] = from_raw_parts(t.0, t.1); 151 | // Although null is allowed in a string, Postgres's internal JSON 152 | // functions do not work well with it (see `escape_json`, which takes a 153 | // C-string) and Postgres does not allow conversion from `bytea` to 154 | // `text` where the `bytea` contains null. 155 | if !bytes.contains(&0) { 156 | if let Ok(ref s) = String::from_utf8(bytes.to_vec()) { 157 | if s.trim_left().starts_with("{") { 158 | let parsed: serde_json::Result = 159 | serde_json::from_str(s); 160 | if let Ok(ref json) = parsed { 161 | self.add_str(json.to_string().deref()); 162 | return; 163 | } 164 | } 165 | // Definitely a string. 166 | self.add_json(s.deref()); 167 | return; 168 | } 169 | } 170 | // Definitely binary. 171 | let as_base64: String = base64::encode(bytes); 172 | self.add_str("{"); 173 | self.add_json("base64"); 174 | self.add_str(":"); 175 | self.add_json(as_base64.deref()); 176 | self.add_str("}"); 177 | } 178 | } 179 | 180 | 181 | struct BufferChangeWrapper(pg::ReorderBufferChangeType); 182 | 183 | impl fmt::Display for BufferChangeWrapper { 184 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 185 | use pg::ReorderBufferChangeType::*; 186 | #[allow(unreachable_patterns)] 187 | let formatted_token = match self.0 { 188 | REORDER_BUFFER_CHANGE_INSERT => "insert", 189 | REORDER_BUFFER_CHANGE_UPDATE => "update", 190 | REORDER_BUFFER_CHANGE_DELETE => "delete", 191 | REORDER_BUFFER_CHANGE_INTERNAL_SNAPSHOT => "internal_snapshot", 192 | REORDER_BUFFER_CHANGE_INTERNAL_COMMAND_ID => "internal_command_id", 193 | REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID => "internal_tuplecid", 194 | #[cfg_attr(rustfmt, rustfmt_skip)] 195 | REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT => 196 | "internal_spec_insert", 197 | _ => "unknown_change_type", // NB: Unreachable after Postgres 9.4 198 | }; 199 | write!(f, "{}", formatted_token) 200 | } 201 | } 202 | 203 | unsafe fn append_change( 204 | relation: pg::Relation, 205 | change: *mut pg::ReorderBufferChange, 206 | out: pg::StringInfo, 207 | ) { 208 | use pg::ReorderBufferChangeType::*; 209 | let relid = (*relation).rd_id; 210 | let name = pg::get_rel_name(relid); 211 | let ns = pg::get_namespace_name(pg::get_rel_namespace(relid)); 212 | let qualified_name = pg::quote_qualified_identifier(ns, name); 213 | let tuple_desc = (*relation).rd_att; 214 | let tuples = (*change).data.tp.as_ref(); 215 | let tuple_new = tuples.newtuple; 216 | let tuple_old = tuples.oldtuple; 217 | let token = match (*change).action { 218 | REORDER_BUFFER_CHANGE_INSERT => "insert", 219 | REORDER_BUFFER_CHANGE_UPDATE => "update", 220 | REORDER_BUFFER_CHANGE_DELETE => "delete", 221 | _ => "unrecognized", 222 | }; 223 | if token == "unrecognized" { 224 | log!( 225 | format!( 226 | "Unrecognized Change Action: [ {} ]", 227 | BufferChangeWrapper((*change).action) 228 | ) 229 | .as_str() 230 | ); 231 | return; 232 | } 233 | out.add_str("{ "); 234 | out.add_json(token); 235 | out.add_str(": "); 236 | append_tuple_buf_as_json(tuple_new, tuple_desc, out); 237 | if !tuple_old.is_null() { 238 | out.add_str(", \"@\": "); 239 | append_tuple_buf_as_json(tuple_old, tuple_desc, out); 240 | } 241 | out.add_str(", "); 242 | out.add_json("table"); 243 | out.add_str(": "); 244 | out.add_json(qualified_name); 245 | out.add_str(" }"); 246 | } 247 | 248 | 249 | unsafe fn append_tuple_buf_as_json( 250 | data: *mut pg::ReorderBufferTupleBuf, 251 | desc: pg::TupleDesc, 252 | out: pg::StringInfo, 253 | ) { 254 | if !data.is_null() { 255 | let heap_tuple = &mut (*data).tuple; 256 | let n = (*desc).natts as usize; 257 | let attrs = (*desc).attrs; 258 | 259 | // Pull out every single field to check for stale TOAST. 260 | let mut datums: Vec = Vec::new(); 261 | let mut nulls: Vec = Vec::new(); 262 | datums.resize(n, 0); 263 | nulls.resize(n, CFALSE); 264 | pg::heap_deform_tuple( 265 | heap_tuple, 266 | desc, 267 | datums.as_mut_ptr(), 268 | nulls.as_mut_ptr(), 269 | ); 270 | 271 | let mut skip: Vec = Vec::with_capacity(n); 272 | 273 | for i in 0..n { 274 | let datum: pg::Datum = datums[i]; 275 | let attr = *attrs.offset(i as isize); 276 | if datum == 0 || (*attr).attnum <= 0 { 277 | continue; 278 | } 279 | if (*attr).attisdropped == CFALSE && is_stale_toast(datum, attr) { 280 | skip.push(attr); 281 | // Mark as NULL to trick heap_form_tuple(). 282 | nulls[i] = CTRUE; 283 | } 284 | } 285 | 286 | // Mark as dropped to trick row_to_json(). 287 | for attr in &mut skip { 288 | (**attr).attisdropped = CTRUE; 289 | } 290 | 291 | let new = 292 | pg::heap_form_tuple(desc, datums.as_mut_ptr(), nulls.as_mut_ptr()); 293 | 294 | let datum = pg::heap_copy_tuple_as_datum(new, desc); 295 | let empty_oid: pg::Oid = 0; 296 | let json = 297 | pg::DirectFunctionCall1Coll(Some(row_to_json), empty_oid, datum); 298 | 299 | // Set back to true because who knows how else these attrs, which are 300 | // part of the passed in tuple description, are being used. 301 | for attr in &mut skip { 302 | (**attr).attisdropped = CFALSE; 303 | } 304 | 305 | let ptr = json as *const pg::varlena; 306 | let text = pg::text_to_cstring(ptr); 307 | pg::appendStringInfoString(out, text); 308 | 309 | if skip.len() > 0 { 310 | out.add_str(", "); 311 | out.add_json("skipped"); 312 | out.add_str(": ["); 313 | for (i, attr) in skip.into_iter().enumerate() { 314 | if i > 0 { 315 | out.add_str(", "); 316 | } 317 | out.add_json((*attr).attname.data.as_mut_ptr()); 318 | } 319 | out.add_str("]"); 320 | } 321 | } else { 322 | out.add_str("{}"); 323 | } 324 | } 325 | 326 | unsafe fn append_schema(relation: pg::Relation, out: pg::StringInfo) { 327 | let relid = (*relation).rd_id; 328 | let tupdesc = (*relation).rd_att; 329 | let name = pg::get_rel_name(relid); 330 | let ns = pg::get_namespace_name(pg::get_rel_namespace(relid)); 331 | let qualified_name = pg::quote_qualified_identifier(ns, name); 332 | out.add_str("{ "); 333 | out.add_json("schema"); 334 | out.add_str(": "); 335 | out.add_str("["); 336 | let mut first: bool = true; 337 | for i in 0..(*tupdesc).natts { 338 | let attr = *(*tupdesc).attrs.offset(i as isize); 339 | let num = (*attr).attnum; 340 | if (*attr).attisdropped == CTRUE || num <= 0 { 341 | continue; 342 | } 343 | let col = pg::get_attname(relid, num); 344 | let typ = pg::format_type_be(pg::get_atttype(relid, num)); 345 | if !first { 346 | out.add_str(","); 347 | } else { 348 | first = false; 349 | } 350 | out.add_str("{"); 351 | out.add_json(col); 352 | out.add_str(":"); 353 | out.add_json(typ); 354 | out.add_str("}"); 355 | } 356 | out.add_str("]"); 357 | out.add_str(", "); 358 | out.add_json("table"); 359 | out.add_str(": "); 360 | out.add_json(qualified_name); 361 | out.add_str(" }"); 362 | } 363 | 364 | #[cfg(feature = "pg-ldc-messages")] 365 | unsafe fn append_message( 366 | transactional: pg::bool_, 367 | prefix: *const std::os::raw::c_char, 368 | message_size: pg::Size, 369 | message: *const std::os::raw::c_char, 370 | out: pg::StringInfo, 371 | ) { 372 | let data = OutputBytesInMostFriendlyWay( 373 | message as *const u8, 374 | message_size as usize, 375 | ); 376 | 377 | out.add_str("{ "); 378 | 379 | out.add_json("prefix"); 380 | out.add_str(": "); 381 | out.add_json(prefix); 382 | out.add_str(", "); 383 | 384 | out.add_json("message"); 385 | out.add_str(": "); 386 | out.add_json(data); 387 | out.add_str(", "); 388 | 389 | out.add_json("transactional"); 390 | out.add_str(": "); 391 | 392 | if transactional == CTRUE { 393 | out.add_str("true"); 394 | } else { 395 | out.add_str("false"); 396 | } 397 | 398 | out.add_str(" }"); 399 | } 400 | 401 | extern "C" fn row_to_json(fcinfo: pg::FunctionCallInfo) -> pg::Datum { 402 | // We wrap the unsafe call to make it safe, so that it can be passed as 403 | // a function pointer to DirectFunctionCall1Coll(). This is a spurious 404 | // artifact of the generated binding. 405 | unsafe { pg::row_to_json(fcinfo) } 406 | } 407 | 408 | /* This is a simulation of `VARATT_IS_EXTERNAL_ONDISK`. 409 | 410 | ```c 411 | #define VARATT_IS_EXTERNAL_ONDISK(PTR) \ 412 | (VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) == VARTAG_ONDISK) 413 | 414 | #define VARATT_IS_EXTERNAL(PTR) VARATT_IS_1B_E(PTR) 415 | 416 | #define VARATT_IS_1B_E(PTR) \ 417 | ((((varattrib_1b *) (PTR))->va_header) == 0x01) 418 | 419 | #define VARTAG_EXTERNAL(PTR) VARTAG_1B_E(PTR) 420 | 421 | #define VARTAG_1B_E(PTR) \ 422 | (((varattrib_1b_e *) (PTR))->va_tag) 423 | ``` 424 | */ 425 | unsafe fn is_stale_toast( 426 | datum: pg::Datum, 427 | attr: pg::Form_pg_attribute, 428 | ) -> bool { 429 | use pg::vartag_external::VARTAG_ONDISK; 430 | let mut o: pg::Oid = 0; // Output function; not used 431 | let mut is_variable_length: pg::bool_ = CFALSE; 432 | pg::getTypeOutputInfo((*attr).atttypid, &mut o, &mut is_variable_length); 433 | if is_variable_length == CTRUE { 434 | // Cast to varlena metadata type. 435 | let v = datum as *const pg::varattrib_1b_e; 436 | if (*v).va_header != 0x01 { 437 | return false; 438 | } 439 | return (*v).va_tag == (VARTAG_ONDISK as u8); 440 | } 441 | return false; 442 | } 443 | 444 | 445 | // Symbols Postgres needs to find. 446 | 447 | #[allow(non_snake_case)] 448 | #[no_mangle] 449 | pub unsafe extern "C" fn _PG_init() {} 450 | 451 | #[allow(non_snake_case)] 452 | #[no_mangle] 453 | pub unsafe extern "C" fn _PG_output_plugin_init( 454 | cb: *mut pg::OutputPluginCallbacks, 455 | ) { 456 | init(cb); 457 | } 458 | 459 | 460 | // Miscellaneous. 461 | 462 | const CTRUE: pg::bool_ = 1; 463 | const CFALSE: pg::bool_ = 0; 464 | 465 | pub unsafe fn elog(file: &str, line: u32, function: &str, msg: &str) { 466 | let level = 15; // The LOG level of logging is normally server-only 467 | pg::elog_start( 468 | CString::new(file).unwrap().as_ptr(), 469 | line as ::std::os::raw::c_int, 470 | CString::new(function).unwrap().as_ptr(), 471 | ); 472 | pg::elog_finish( 473 | level, 474 | CString::new("%s").unwrap().as_ptr(), 475 | CString::new(msg).unwrap().as_ptr(), 476 | ); 477 | } 478 | 479 | pub unsafe fn fmt_name(name: pg::NameData) -> String { 480 | let cstr = CStr::from_ptr(name.data.as_ptr()); 481 | format!("{:?}", cstr.to_owned()) 482 | } 483 | -------------------------------------------------------------------------------- /test/expected/toast.out: -------------------------------------------------------------------------------- 1 | \set ECHO none 2 | created logical replication slot 3 | 4 | { "schema": [{"id":"integer"},{"toasted_col1":"text"},{"rand1":"double precision"},{"toasted_col2":"text"},{"rand2":"double precision"}], "table": "jsoncdc.xpto" } 5 | { "insert": {"id":1,"toasted_col1":"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000","rand1":79,"toasted_col2":"24681012141618202224262830323436384042444648505254565860626466687072747678808284868890929496981001021041061081101121141161181201221241261281301321341361381401421441461481501521541561581601621641661681701721741761781801821841861881901921941961982002022042062082102122142162182202222242262282302322342362382402422442462482502522542562582602622642662682702722742762782802822842862882902922942962983003023043063083103123143163183203223243263283303323343363383403423443463483503523543563583603623643663683703723743763783803823843863883903923943963984004024044064084104124144164184204224244264284304324344364384404424444464484504524544564584604624644664684704724744764784804824844864884904924944964985005025045065085105125145165185205225245265285305325345365385405425445465485505525545565585605625645665685705725745765785805825845865885905925945965986006026046066086106126146166186206226246266286306326346366386406426446466486506526546566586606626646666686706726746766786806826846866886906926946966987007027047067087107127147167187207227247267287307327347367387407427447467487507527547567587607627647667687707727747767787807827847867887907927947967988008028048068088108128148168188208228248268288308328348368388408428448468488508528548568588608628648668688708728748768788808828848868888908928948968989009029049069089109129149169189209229249269289309329349369389409429449469489509529549569589609629649669689709729749769789809829849869889909929949969981000100210041006100810101012101410161018102010221024102610281030103210341036103810401042104410461048105010521054105610581060106210641066106810701072107410761078108010821084108610881090109210941096109811001102110411061108111011121114111611181120112211241126112811301132113411361138114011421144114611481150115211541156115811601162116411661168117011721174117611781180118211841186118811901192119411961198120012021204120612081210121212141216121812201222122412261228123012321234123612381240124212441246124812501252125412561258126012621264126612681270127212741276127812801282128412861288129012921294129612981300130213041306130813101312131413161318132013221324132613281330133213341336133813401342134413461348135013521354135613581360136213641366136813701372137413761378138013821384138613881390139213941396139814001402140414061408141014121414141614181420142214241426142814301432143414361438144014421444144614481450145214541456145814601462146414661468147014721474147614781480148214841486148814901492149414961498150015021504150615081510151215141516151815201522152415261528153015321534153615381540154215441546154815501552155415561558156015621564156615681570157215741576157815801582158415861588159015921594159615981600160216041606160816101612161416161618162016221624162616281630163216341636163816401642164416461648165016521654165616581660166216641666166816701672167416761678168016821684168616881690169216941696169817001702170417061708171017121714171617181720172217241726172817301732173417361738174017421744174617481750175217541756175817601762176417661768177017721774177617781780178217841786178817901792179417961798180018021804180618081810181218141816181818201822182418261828183018321834183618381840184218441846184818501852185418561858186018621864186618681870187218741876187818801882188418861888189018921894189618981900190219041906190819101912191419161918192019221924192619281930193219341936193819401942194419461948195019521954195619581960196219641966196819701972197419761978198019821984198619881990199219941996199820002002200420062008201020122014201620182020202220242026202820302032203420362038204020422044204620482050205220542056205820602062206420662068207020722074207620782080208220842086208820902092209420962098210021022104210621082110211221142116211821202122212421262128213021322134213621382140214221442146214821502152215421562158216021622164216621682170217221742176217821802182218421862188219021922194219621982200220222042206220822102212221422162218222022222224222622282230223222342236223822402242224422462248225022522254225622582260226222642266226822702272227422762278228022822284228622882290229222942296229823002302230423062308231023122314231623182320232223242326232823302332233423362338234023422344234623482350235223542356235823602362236423662368237023722374237623782380238223842386238823902392239423962398240024022404240624082410241224142416241824202422242424262428243024322434243624382440244224442446244824502452245424562458246024622464246624682470247224742476247824802482248424862488249024922494249624982500250225042506250825102512251425162518252025222524252625282530253225342536253825402542254425462548255025522554255625582560256225642566256825702572257425762578258025822584258625882590259225942596259826002602260426062608261026122614261626182620262226242626262826302632263426362638264026422644264626482650265226542656265826602662266426662668267026722674267626782680268226842686268826902692269426962698270027022704270627082710271227142716271827202722272427262728273027322734273627382740274227442746274827502752275427562758276027622764276627682770277227742776277827802782278427862788279027922794279627982800280228042806280828102812281428162818282028222824282628282830283228342836283828402842284428462848285028522854285628582860286228642866286828702872287428762878288028822884288628882890289228942896289829002902290429062908291029122914291629182920292229242926292829302932293429362938294029422944294629482950295229542956295829602962296429662968297029722974297629782980298229842986298829902992299429962998300030023004300630083010301230143016301830203022302430263028303030323034303630383040304230443046304830503052305430563058306030623064306630683070307230743076307830803082308430863088309030923094309630983100310231043106310831103112311431163118312031223124312631283130313231343136313831403142314431463148315031523154315631583160316231643166316831703172317431763178318031823184318631883190319231943196319832003202320432063208321032123214321632183220322232243226322832303232323432363238324032423244324632483250325232543256325832603262326432663268327032723274327632783280328232843286328832903292329432963298330033023304330633083310331233143316331833203322332433263328333033323334333633383340334233443346334833503352335433563358336033623364336633683370337233743376337833803382338433863388339033923394339633983400340234043406340834103412341434163418342034223424342634283430343234343436343834403442344434463448345034523454345634583460346234643466346834703472347434763478348034823484348634883490349234943496349835003502350435063508351035123514351635183520352235243526352835303532353435363538354035423544354635483550355235543556355835603562356435663568357035723574357635783580358235843586358835903592359435963598360036023604360636083610361236143616361836203622362436263628363036323634363636383640364236443646364836503652365436563658366036623664366636683670367236743676367836803682368436863688369036923694369636983700370237043706370837103712371437163718372037223724372637283730373237343736373837403742374437463748375037523754375637583760376237643766376837703772377437763778378037823784378637883790379237943796379838003802380438063808381038123814381638183820382238243826382838303832383438363838384038423844384638483850385238543856385838603862386438663868387038723874387638783880388238843886388838903892389438963898390039023904390639083910391239143916391839203922392439263928393039323934393639383940394239443946394839503952395439563958396039623964396639683970397239743976397839803982398439863988399039923994399639984000","rand2":1578}, "table": "jsoncdc.xpto" } 6 | 7 | { "schema": [{"id":"integer"},{"toasted_col1":"text"},{"rand1":"double precision"},{"toasted_col2":"text"},{"rand2":"double precision"}], "table": "jsoncdc.xpto" } 8 | { "insert": {"id":2,"toasted_col1":null,"rand1":3077,"toasted_col2":"0001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500000100020003000400050006000700080009001000110012001300140015001600170018001900200021002200230024002500260027002800290030003100320033003400350036003700380039004000410042004300440045004600470048004900500051005200530054005500560057005800590060006100620063006400650066006700680069007000710072007300740075007600770078007900800081008200830084008500860087008800890090009100920093009400950096009700980099010001010102010301040105010601070108010901100111011201130114011501160117011801190120012101220123012401250126012701280129013001310132013301340135013601370138013901400141014201430144014501460147014801490150015101520153015401550156015701580159016001610162016301640165016601670168016901700171017201730174017501760177017801790180018101820183018401850186018701880189019001910192019301940195019601970198019902000201020202030204020502060207020802090210021102120213021402150216021702180219022002210222022302240225022602270228022902300231023202330234023502360237023802390240024102420243024402450246024702480249025002510252025302540255025602570258025902600261026202630264026502660267026802690270027102720273027402750276027702780279028002810282028302840285028602870288028902900291029202930294029502960297029802990300030103020303030403050306030703080309031003110312031303140315031603170318031903200321032203230324032503260327032803290330033103320333033403350336033703380339034003410342034303440345034603470348034903500351035203530354035503560357035803590360036103620363036403650366036703680369037003710372037303740375037603770378037903800381038203830384038503860387038803890390039103920393039403950396039703980399040004010402040304040405040604070408040904100411041204130414041504160417041804190420042104220423042404250426042704280429043004310432043304340435043604370438043904400441044204430444044504460447044804490450045104520453045404550456045704580459046004610462046304640465046604670468046904700471047204730474047504760477047804790480048104820483048404850486048704880489049004910492049304940495049604970498049905000001000200030004000500060007000800090010001100120013001400150016001700180019002000210022002300240025002600270028002900300031003200330034003500360037003800390040004100420043004400450046004700480049005000510052005300540055005600570058005900600061006200630064006500660067006800690070007100720073007400750076007700780079008000810082008300840085008600870088008900900091009200930094009500960097009800990100010101020103010401050106010701080109011001110112011301140115011601170118011901200121012201230124012501260127012801290130013101320133013401350136013701380139014001410142014301440145014601470148014901500151015201530154015501560157015801590160016101620163016401650166016701680169017001710172017301740175017601770178017901800181018201830184018501860187018801890190019101920193019401950196019701980199020002010202020302040205020602070208020902100211021202130214021502160217021802190220022102220223022402250226022702280229023002310232023302340235023602370238023902400241024202430244024502460247024802490250025102520253025402550256025702580259026002610262026302640265026602670268026902700271027202730274027502760277027802790280028102820283028402850286028702880289029002910292029302940295029602970298029903000301030203030304030503060307030803090310031103120313031403150316031703180319032003210322032303240325032603270328032903300331033203330334033503360337033803390340034103420343034403450346034703480349035003510352035303540355035603570358035903600361036203630364036503660367036803690370037103720373037403750376037703780379038003810382038303840385038603870388038903900391039203930394039503960397039803990400040104020403040404050406040704080409041004110412041304140415041604170418041904200421042204230424042504260427042804290430043104320433043404350436043704380439044004410442044304440445044604470448044904500451045204530454045504560457045804590460046104620463046404650466046704680469047004710472047304740475047604770478047904800481048204830484048504860487048804890490049104920493049404950496049704980499050000010002000300040005000600070008000900100011001200130014001500160017001800190020002100220023002400250026002700280029003000310032003300340035003600370038003900400041004200430044004500460047004800490050005100520053005400550056005700580059006000610062006300640065006600670068006900700071007200730074007500760077007800790080008100820083008400850086008700880089009000910092009300940095009600970098009901000101010201030104010501060107010801090110011101120113011401150116011701180119012001210122012301240125012601270128012901300131013201330134013501360137013801390140014101420143014401450146014701480149015001510152015301540155015601570158015901600161016201630164016501660167016801690170017101720173017401750176017701780179018001810182018301840185018601870188018901900191019201930194019501960197019801990200020102020203020402050206020702080209021002110212021302140215021602170218021902200221022202230224022502260227022802290230023102320233023402350236023702380239024002410242024302440245024602470248024902500251025202530254025502560257025802590260026102620263026402650266026702680269027002710272027302740275027602770278027902800281028202830284028502860287028802890290029102920293029402950296029702980299030003010302030303040305030603070308030903100311031203130314031503160317031803190320032103220323032403250326032703280329033003310332033303340335033603370338033903400341034203430344034503460347034803490350035103520353035403550356035703580359036003610362036303640365036603670368036903700371037203730374037503760377037803790380038103820383038403850386038703880389039003910392039303940395039603970398039904000401040204030404040504060407040804090410041104120413041404150416041704180419042004210422042304240425042604270428042904300431043204330434043504360437043804390440044104420443044404450446044704480449045004510452045304540455045604570458045904600461046204630464046504660467046804690470047104720473047404750476047704780479048004810482048304840485048604870488048904900491049204930494049504960497049804990500","rand2":4576}, "table": "jsoncdc.xpto" } 9 | { "schema": [{"id":"integer"},{"toasted_col1":"text"},{"rand1":"double precision"},{"toasted_col2":"text"},{"rand2":"double precision"}], "table": "jsoncdc.xpto" } 10 | { "update": {"id":1,"toasted_col1":"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000","rand1":79,"rand2":1578}, "skipped": ["toasted_col2"], "table": "jsoncdc.xpto" } 11 | { "schema": [{"id":"integer"},{"toasted_col1":"text"},{"rand1":"double precision"},{"toasted_col2":"text"},{"rand2":"double precision"}], "table": "jsoncdc.xpto" } 12 | { "delete": {}, "@": {"id":1,"toasted_col1":null,"rand1":null,"toasted_col2":null,"rand2":null}, "table": "jsoncdc.xpto" } 13 | 14 | deleted logical replication slot 15 | 16 | --------------------------------------------------------------------------------