https://github.com/ildus/logical_helpers
https://github.com/ildus/logical_helpers
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ildus/logical_helpers
- Owner: ildus
- Created: 2015-02-15T22:38:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-15T22:57:20.000Z (almost 11 years ago)
- Last Synced: 2025-03-15T08:03:56.285Z (10 months ago)
- Language: C
- Size: 117 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Logical decoding helper functions
## pg_logical_slot_confirm_lsn
Removes (confirms) all records from logical slot until specified LSN
### Installing
```
make
sudo make install
```
### Using
```
dlr=# create function confirm_lsn(cstring, pg_lsn) returns pg_lsn as 'logical_helpers.so', 'pg_logical_slot_confirm_lsn' language c strict;
CREATE FUNCTION
dlr=# insert into test1 values (46, 'bb');
INSERT 0 1
dlr=# insert into test1 values (47, 'bb');
INSERT 0 1
dlr=# select * from pg_logical_slot_peek_changes('custom_slot', NULL, NULL, 'include_transaction', 'on');
location | xid | data
-----------+------+------------------------------------------------------
0/2E8BF90 | 3568 | begin
0/2E8BF90 | 3568 | {"a":0,"d":{"id":46,"name":"bb"},"r":"public.test1"}
0/2E8C078 | 3568 | commit
0/2E8C078 | 3569 | begin
0/2E8C078 | 3569 | {"a":0,"d":{"id":47,"name":"bb"},"r":"public.test1"}
0/2E8C148 | 3569 | commit
(6 rows)
dlr=# select confirm_lsn('custom_slot', '0/2E8C148');
confirm_lsn
-------------
0/2E8C148
(1 row)
dlr=# select * from pg_logical_slot_peek_changes('custom_slot', NULL, NULL, 'include_transaction', 'on');
location | xid | data
----------+-----+------
(0 rows)
```