{"id":13513457,"url":"https://github.com/eulerto/wal2json","last_synced_at":"2025-05-14T08:09:38.776Z","repository":{"id":14286186,"uuid":"16994340","full_name":"eulerto/wal2json","owner":"eulerto","description":"JSON output plugin for changeset extraction","archived":false,"fork":false,"pushed_at":"2025-04-09T17:26:44.000Z","size":369,"stargazers_count":1376,"open_issues_count":24,"forks_count":162,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-04-14T19:01:15.824Z","etag":null,"topics":["cdc","json","plugin","postgres","replication"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Jaguar-dart/jaguar_auth","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eulerto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-02-19T18:34:12.000Z","updated_at":"2025-04-14T09:08:45.000Z","dependencies_parsed_at":"2024-01-13T19:23:25.566Z","dependency_job_id":"181da464-8b70-4b48-b978-4353f2fe6df9","html_url":"https://github.com/eulerto/wal2json","commit_stats":{"total_commits":127,"total_committers":16,"mean_commits":7.9375,"dds":0.5039370078740157,"last_synced_commit":"beb9293e9b9e867c7cc32d649e33f15528557d4d"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fwal2json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fwal2json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fwal2json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fwal2json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eulerto","download_url":"https://codeload.github.com/eulerto/wal2json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdc","json","plugin","postgres","replication"],"created_at":"2024-08-01T05:00:26.424Z","updated_at":"2025-05-14T08:09:33.768Z","avatar_url":"https://github.com/eulerto.png","language":"C","funding_links":[],"categories":["C","WAL"],"sub_categories":["Logical Replication"],"readme":"[![Coverity Scan Build Status](https://scan.coverity.com/projects/4832/badge.svg)](https://scan.coverity.com/projects/wal2json)\n\nIntroduction\n============\n\n**wal2json** is an output plugin for logical decoding. It means that the plugin have access to tuples produced by INSERT and UPDATE. Also, UPDATE/DELETE old row versions can be accessed depending on the configured replica identity. Changes can be consumed using the streaming protocol (logical replication slots) or by a special SQL API.\n\n**format version 1** produces a JSON object per transaction. All of the new/old tuples are available in the JSON object. Also, there are options to include properties such as transaction timestamp, schema-qualified, data types, and transaction ids.\n\n**format version 2** produces a JSON object per tuple. Optional JSON object for beginning and end of transaction. Also, there are a variety of options to include properties.\n\nBuild and Install\n=================\n\nThis module is supported on [those platforms](http://www.postgresql.org/docs/current/static/supported-platforms.html) that PostgreSQL is. The installation steps depend on your operating system. [PostgreSQL yum repository](https://yum.postgresql.org) and [PostgreSQL apt repository](https://wiki.postgresql.org/wiki/Apt) provide wal2json packages.\n\nIn Red Hat/CentOS:\n\n```\n$ sudo yum install wal2json_17\n```\n\nIn Debian/Ubuntu:\n\n```\n$ sudo apt-get install postgresql-17-wal2json\n```\n\nYou can also keep up with the latest fixes and features cloning the Git repository.\n\n```\n$ git clone https://github.com/eulerto/wal2json.git\n```\n\nUnix based Operating Systems\n----------------------------\n\nBefore installing **wal2json**, you should have PostgreSQL 9.4+ installed (including the header files). If PostgreSQL is not in your search path, add it. If you are using [PostgreSQL yum repository](https://yum.postgresql.org), install `postgresql17-devel` and add `/usr/pgsql-17/bin` to your search path (yum uses `17, 16, 15, 14, 13, 12, 11, 10, 96 or 95`). If you are using [PostgreSQL apt repository](https://wiki.postgresql.org/wiki/Apt), install `postgresql-server-dev-17` and add `/usr/lib/postgresql/17/bin` to your search path. (apt uses `17, 16, 15, 14, 13, 12, 11, 10, 9.6 or 9.5`).\n\nIf you compile PostgreSQL by yourself and install it in `/home/euler/pg17`:\n\n```\n$ tar -zxf wal2json-wal2json_2_6.tar.gz\n$ cd wal2json-wal2json_2_6\n$ export PATH=/home/euler/pg17/bin:$PATH\n$ make\n$ make install\n```\n\nIf you are using [PostgreSQL yum repository](https://yum.postgresql.org):\n\n```\n$ sudo yum install postgresql17-devel\n$ tar -zxf wal2json-wal2json_2_6.tar.gz\n$ cd wal2json-wal2json_2_6\n$ export PATH=/usr/pgsql-17/bin:$PATH\n$ make\n$ make install\n```\n\nIf you are using [PostgreSQL apt repository](https://wiki.postgresql.org/wiki/Apt):\n\n```\n$ sudo apt-get install postgresql-server-dev-17\n$ tar -zxf wal2json-wal2json_2_6.tar.gz\n$ cd wal2json-wal2json_2_6\n$ export PATH=/usr/lib/postgresql/17/bin:$PATH\n$ make\n$ make install\n```\n\nWindows\n-------\n\nThere are several ways to build **wal2json** on Windows. If you are build PostgreSQL too, you can put **wal2json** directory inside contrib, change the contrib Makefile (variable SUBDIRS) and build it following the [Installation from Source Code on Windows](http://www.postgresql.org/docs/current/static/install-windows.html) instructions. However, if you already have PostgreSQL installed, it is also possible to compile **wal2json** out of the tree. Edit `wal2json.vcxproj` file and change `c:\\pg\\17` to the PostgreSQL prefix directory. The next step is to open this project file in MS Visual Studio and compile it. Final step is to copy `wal2json.dll` to the `pg_config --pkglibdir` directory.\n\nConfiguration\n=============\n\npostgresql.conf\n---------------\n\nYou need to set up at least two parameters at postgresql.conf:\n\n```\nwal_level = logical\n#\n# these parameters only need to set in versions 9.4, 9.5 and 9.6\n# default values are ok in version 10 or later\n#\nmax_replication_slots = 10\nmax_wal_senders = 10\n```\n\nAfter changing these parameters, a restart is needed.\n\nParameters\n----------\n\n* `include-xids`: add _xid_ to each changeset. Default is _false_.\n* `include-timestamp`: add _timestamp_ to each changeset. Default is _false_.\n* `include-schemas`: add _schema_ to each change. Default is _true_.\n* `include-types`: add _type_ to each change. Default is _true_.\n* `include-typmod`: add modifier to types that have it (eg. varchar(20) instead of varchar). Default is _true_.\n* `include-type-oids`: add type oids. Default is _false_.\n* `include-domain-data-type`: replace domain name with the underlying data type. Default is _false_.\n* `include-column-positions`: add column position (_pg_attribute.attnum_). Default is _false_.\n* `include-origin`: add origin of a piece of data. Default is _false_.\n* `include-not-null`: add _not null_ information as _columnoptionals_. Default is _false_.\n* `include-default`: add default expression. Default is _false_.\n* `include-pk`: add _primary key_ information as _pk_. Column name and data type is included. Default is _false_.\n* `numeric-data-types-as-string`: use string for numeric data types. JSON specification does not recognize `Infinity` and `NaN` as valid numeric values. There might be [potential interoperability problems](https://datatracker.ietf.org/doc/html/rfc7159#section-6) for double precision numbers. Default is _false_.\n* `pretty-print`: add spaces and indentation to JSON structures. Default is _false_.\n* `write-in-chunks`: write after every change instead of every changeset. Only used when `format-version` is `1`. Default is _false_.\n* `include-lsn`: add _nextlsn_ to each changeset. Default is _false_.\n* `include-transaction`: emit records denoting the start and end of each transaction. Default is _true_.\n* `include-unchanged-toast` (deprecated): Don't use it. It is deprecated.\n* `filter-origins`: exclude changes from the specified origins. Default is empty which means that no origin will be filtered. It is a comma separated value.\n* `filter-tables`: exclude rows from the specified tables. Default is empty which means that no table will be filtered. It is a comma separated value. The tables should be schema-qualified. `*.foo` means table foo in all schemas and `bar.*` means all tables in schema bar. Special characters (space, single quote, comma, period, asterisk) must be escaped with backslash. Schema and table are case-sensitive. Table `\"public\".\"Foo bar\"` should be specified as `public.Foo\\ bar`.\n* `add-tables`: include only rows from the specified tables. Default is all tables from all schemas. It has the same rules from `filter-tables`.\n* `filter-msg-prefixes`: exclude messages if prefix is in the list. Default is empty which means that no message will be filtered. It is a comma separated value.\n* `add-msg-prefixes`: include only messages if prefix is in the list. Default is all prefixes. It is a comma separated value. `wal2json` applies `filter-msg-prefixes` before this parameter.\n* `format-version`: defines which format to use. Default is _1_.\n* `actions`: define which operations will be sent. Default is all actions (insert, update, delete, and truncate). However, if you are using `format-version` 1, truncate is not enabled (backward compatibility).\n\nExamples\n========\n\nThere are two ways to obtain the changes (JSON objects) from **wal2json** plugin: calling functions via SQL or pg_recvlogical.\n\npg_recvlogical\n--------------\n\nBesides the configuration above, it is necessary to configure a replication connection to use pg_recvlogical. A logical replication connection in version 9.4, 9.5, and 9.6 requires `replication` keyword in the database column. Since version 10, logical replication matches a normal entry with a database name or keywords such as `all`.\n\nFirst, add a replication connection rule at pg_hba.conf (9.4, 9.5, and 9.6):\n\n```\nlocal    replication     myuser                     trust\n```\n\nIf you are using version 10 or later:\n\n```\nlocal    mydatabase      myuser                     trust\n```\n\nAlso, set max_wal_senders at postgresql.conf:\n\n```\nmax_wal_senders = 1\n```\n\nA restart is necessary if you changed max_wal_senders.\n\nYou are ready to try **wal2json**. In one terminal:\n\n```\n$ pg_recvlogical -d postgres --slot test_slot --create-slot -P wal2json\n$ pg_recvlogical -d postgres --slot test_slot --start -o pretty-print=1 -o add-msg-prefixes=wal2json -f -\n```\n\nIn another terminal:\n\n```\n$ cat /tmp/example1.sql\nCREATE TABLE table1_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c));\nCREATE TABLE table1_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT);\n\nBEGIN;\nINSERT INTO table1_with_pk (b, c) VALUES('Backup and Restore', now());\nINSERT INTO table1_with_pk (b, c) VALUES('Tuning', now());\nINSERT INTO table1_with_pk (b, c) VALUES('Replication', now());\nSELECT pg_logical_emit_message(true, 'wal2json', 'this message will be delivered');\nSELECT pg_logical_emit_message(true, 'pgoutput', 'this message will be filtered');\nDELETE FROM table1_with_pk WHERE a \u003c 3;\nSELECT pg_logical_emit_message(false, 'wal2json', 'this non-transactional message will be delivered even if you rollback the transaction');\n\nINSERT INTO table1_without_pk (b, c) VALUES(2.34, 'Tapir');\n-- it is not added to stream because there isn't a pk or a replica identity\nUPDATE table1_without_pk SET c = 'Anta' WHERE c = 'Tapir';\nCOMMIT;\n\nDROP TABLE table1_with_pk;\nDROP TABLE table1_without_pk;\n\n$ psql -At -f /tmp/example1.sql postgres\nCREATE TABLE\nCREATE TABLE\nBEGIN\nINSERT 0 1\nINSERT 0 1\nINSERT 0 1\n3/78BFC828\n3/78BFC880\nDELETE 2\n3/78BFC990\nINSERT 0 1\nUPDATE 1\nCOMMIT\nDROP TABLE\nDROP TABLE\n```\n\nThe output in the first terminal is:\n\n```\n{\n\t\"change\": [\n\t]\n}\n{\n\t\"change\": [\n\t]\n}\n{\n    \"change\": [\n        {\n            \"kind\": \"message\",\n            \"transactional\": false,\n            \"prefix\": \"wal2json\",\n            \"content\": \"this non-transactional message will be delivered even if you rollback the transaction\"\n        }\n    ]\n}\nWARNING:  table \"table1_without_pk\" without primary key or replica identity is nothing\n{\n\t\"change\": [\n\t\t{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [1, \"Backup and Restore\", \"2018-03-27 11:58:28.988414\"]\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [2, \"Tuning\", \"2018-03-27 11:58:28.988414\"]\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [3, \"Replication\", \"2018-03-27 11:58:28.988414\"]\n\t\t}\n        ,{\n            \"kind\": \"message\",\n            \"transactional\": true,\n            \"prefix\": \"wal2json\",\n            \"content\": \"this message will be delivered\"\n        }\n\t\t,{\n\t\t\t\"kind\": \"delete\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_with_pk\",\n\t\t\t\"oldkeys\": {\n\t\t\t\t\"keynames\": [\"a\", \"c\"],\n\t\t\t\t\"keytypes\": [\"integer\", \"timestamp without time zone\"],\n\t\t\t\t\"keyvalues\": [1, \"2018-03-27 11:58:28.988414\"]\n\t\t\t}\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"delete\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_with_pk\",\n\t\t\t\"oldkeys\": {\n\t\t\t\t\"keynames\": [\"a\", \"c\"],\n\t\t\t\t\"keytypes\": [\"integer\", \"timestamp without time zone\"],\n\t\t\t\t\"keyvalues\": [2, \"2018-03-27 11:58:28.988414\"]\n\t\t\t}\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table1_without_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"numeric(5,2)\", \"text\"],\n\t\t\t\"columnvalues\": [1, 2.34, \"Tapir\"]\n\t\t}\n\t]\n}\n{\n    \"change\": [\n    ]\n}\n{\n    \"change\": [\n    ]\n}\n```\n\nDropping the slot in the first terminal:\n\n```\nCtrl+C\n$ pg_recvlogical -d postgres --slot test_slot --drop-slot\n```\n\nSQL functions\n-------------\n\n```\n$ cat /tmp/example2.sql\nCREATE TABLE table2_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c));\nCREATE TABLE table2_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT);\n\nSELECT 'init' FROM pg_create_logical_replication_slot('test_slot', 'wal2json');\n\nBEGIN;\nINSERT INTO table2_with_pk (b, c) VALUES('Backup and Restore', now());\nINSERT INTO table2_with_pk (b, c) VALUES('Tuning', now());\nINSERT INTO table2_with_pk (b, c) VALUES('Replication', now());\nSELECT pg_logical_emit_message(true, 'wal2json', 'this message will be delivered');\nSELECT pg_logical_emit_message(true, 'pgoutput', 'this message will be filtered');\nDELETE FROM table2_with_pk WHERE a \u003c 3;\nSELECT pg_logical_emit_message(false, 'wal2json', 'this non-transactional message will be delivered even if you rollback the transaction');\n\nINSERT INTO table2_without_pk (b, c) VALUES(2.34, 'Tapir');\n-- it is not added to stream because there isn't a pk or a replica identity\nUPDATE table2_without_pk SET c = 'Anta' WHERE c = 'Tapir';\nCOMMIT;\n\nSELECT data FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'pretty-print', '1', 'add-msg-prefixes', 'wal2json');\nSELECT 'stop' FROM pg_drop_replication_slot('test_slot');\n\nDROP TABLE table2_with_pk;\nDROP TABLE table2_without_pk;\n```\n\nThe script above produces the output below:\n\n```\n$ psql -At -f /tmp/example2.sql postgres\nCREATE TABLE\nCREATE TABLE\ninit\nBEGIN\nINSERT 0 1\nINSERT 0 1\nINSERT 0 1\n3/78C2CA50\n3/78C2CAA8\nDELETE 2\n3/78C2CBD8\nINSERT 0 1\nUPDATE 1\nCOMMIT\n{\n    \"change\": [\n        {\n            \"kind\": \"message\",\n            \"transactional\": false,\n            \"prefix\": \"wal2json\",\n            \"content\": \"this non-transactional message will be delivered even if you rollback the transaction\"\n        }\n    ]\n}\npsql:/tmp/example2.sql:17: WARNING:  table \"table2_without_pk\" without primary key or replica identity is nothing\n{\n\t\"change\": [\n\t\t{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [1, \"Backup and Restore\", \"2018-03-27 12:05:29.914496\"]\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [2, \"Tuning\", \"2018-03-27 12:05:29.914496\"]\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_with_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"character varying(30)\", \"timestamp without time zone\"],\n\t\t\t\"columnvalues\": [3, \"Replication\", \"2018-03-27 12:05:29.914496\"]\n\t\t}\n        ,{\n            \"kind\": \"message\",\n            \"transactional\": true,\n            \"prefix\": \"wal2json\",\n            \"content\": \"this message will be delivered\"\n        }\n\t\t,{\n\t\t\t\"kind\": \"delete\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_with_pk\",\n\t\t\t\"oldkeys\": {\n\t\t\t\t\"keynames\": [\"a\", \"c\"],\n\t\t\t\t\"keytypes\": [\"integer\", \"timestamp without time zone\"],\n\t\t\t\t\"keyvalues\": [1, \"2018-03-27 12:05:29.914496\"]\n\t\t\t}\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"delete\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_with_pk\",\n\t\t\t\"oldkeys\": {\n\t\t\t\t\"keynames\": [\"a\", \"c\"],\n\t\t\t\t\"keytypes\": [\"integer\", \"timestamp without time zone\"],\n\t\t\t\t\"keyvalues\": [2, \"2018-03-27 12:05:29.914496\"]\n\t\t\t}\n\t\t}\n\t\t,{\n\t\t\t\"kind\": \"insert\",\n\t\t\t\"schema\": \"public\",\n\t\t\t\"table\": \"table2_without_pk\",\n\t\t\t\"columnnames\": [\"a\", \"b\", \"c\"],\n\t\t\t\"columntypes\": [\"integer\", \"numeric(5,2)\", \"text\"],\n\t\t\t\"columnvalues\": [1, 2.34, \"Tapir\"]\n\t\t}\n\t]\n}\nstop\nDROP TABLE\nDROP TABLE\n```\n\nLet's repeat the same example with `format-version` 2:\n\n```\n$ cat /tmp/example3.sql\nCREATE TABLE table3_with_pk (a SERIAL, b VARCHAR(30), c TIMESTAMP NOT NULL, PRIMARY KEY(a, c));\nCREATE TABLE table3_without_pk (a SERIAL, b NUMERIC(5,2), c TEXT);\n\nSELECT 'init' FROM pg_create_logical_replication_slot('test_slot', 'wal2json');\n\nBEGIN;\nINSERT INTO table3_with_pk (b, c) VALUES('Backup and Restore', now());\nINSERT INTO table3_with_pk (b, c) VALUES('Tuning', now());\nINSERT INTO table3_with_pk (b, c) VALUES('Replication', now());\nSELECT pg_logical_emit_message(true, 'wal2json', 'this message will be delivered');\nSELECT pg_logical_emit_message(true, 'pgoutput', 'this message will be filtered');\nDELETE FROM table3_with_pk WHERE a \u003c 3;\nSELECT pg_logical_emit_message(false, 'wal2json', 'this non-transactional message will be delivered even if you rollback the transaction');\n\nINSERT INTO table3_without_pk (b, c) VALUES(2.34, 'Tapir');\n-- it is not added to stream because there isn't a pk or a replica identity\nUPDATE table3_without_pk SET c = 'Anta' WHERE c = 'Tapir';\nCOMMIT;\n\nSELECT data FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'format-version', '2', 'add-msg-prefixes', 'wal2json');\nSELECT 'stop' FROM pg_drop_replication_slot('test_slot');\n\nDROP TABLE table3_with_pk;\nDROP TABLE table3_without_pk;\n```\n\nThe script above produces the output below:\n\n```\n$ psql -At -f /tmp/example3.sql postgres\nCREATE TABLE\nCREATE TABLE\ninit\nBEGIN\nINSERT 0 1\nINSERT 0 1\nINSERT 0 1\n3/78CB8F30\n3/78CB8F88\nDELETE 2\n3/78CB90B8\nINSERT 0 1\nUPDATE 1\nCOMMIT\npsql:/tmp/example3.sql:20: WARNING:  no tuple identifier for UPDATE in table \"public\".\"table3_without_pk\"\n{\"action\":\"M\",\"transactional\":false,\"prefix\":\"wal2json\",\"content\":\"this non-transactional message will be delivered even if you rollback the transaction\"}\n{\"action\":\"B\"}\n{\"action\":\"I\",\"schema\":\"public\",\"table\":\"table3_with_pk\",\"columns\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":1},{\"name\":\"b\",\"type\":\"character varying(30)\",\"value\":\"Backup and Restore\"},{\"name\":\"c\",\"type\":\"timestamp without time zone\",\"value\":\"2019-12-29 04:58:34.806671\"}]}\n{\"action\":\"I\",\"schema\":\"public\",\"table\":\"table3_with_pk\",\"columns\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":2},{\"name\":\"b\",\"type\":\"character varying(30)\",\"value\":\"Tuning\"},{\"name\":\"c\",\"type\":\"timestamp without time zone\",\"value\":\"2019-12-29 04:58:34.806671\"}]}\n{\"action\":\"I\",\"schema\":\"public\",\"table\":\"table3_with_pk\",\"columns\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":3},{\"name\":\"b\",\"type\":\"character varying(30)\",\"value\":\"Replication\"},{\"name\":\"c\",\"type\":\"timestamp without time zone\",\"value\":\"2019-12-29 04:58:34.806671\"}]}\n{\"action\":\"M\",\"transactional\":true,\"prefix\":\"wal2json\",\"content\":\"this message will be delivered\"}\n{\"action\":\"D\",\"schema\":\"public\",\"table\":\"table3_with_pk\",\"identity\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":1},{\"name\":\"c\",\"type\":\"timestamp without time zone\",\"value\":\"2019-12-29 04:58:34.806671\"}]}\n{\"action\":\"D\",\"schema\":\"public\",\"table\":\"table3_with_pk\",\"identity\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":2},{\"name\":\"c\",\"type\":\"timestamp without time zone\",\"value\":\"2019-12-29 04:58:34.806671\"}]}\n{\"action\":\"I\",\"schema\":\"public\",\"table\":\"table3_without_pk\",\"columns\":[{\"name\":\"a\",\"type\":\"integer\",\"value\":1},{\"name\":\"b\",\"type\":\"numeric(5,2)\",\"value\":2.34},{\"name\":\"c\",\"type\":\"text\",\"value\":\"Tapir\"}]}\n{\"action\":\"C\"}\nstop\nDROP TABLE\nDROP TABLE\n```\n\nLicense\n=======\n\n\u003e Copyright (c) 2013-2024, Euler Taveira de Oliveira\n\u003e All rights reserved.\n\n\u003e Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n\u003e Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n\u003e Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n\u003e Neither the name of the Euler Taveira de Oliveira nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\n\u003e THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feulerto%2Fwal2json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feulerto%2Fwal2json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feulerto%2Fwal2json/lists"}