Skip to content

Commit 38aa439

Browse files
committed
Resolve issue#1: add ptrack_get_change_stat().
Also bump extversion to 2.2
1 parent dd6fdc0 commit 38aa439

File tree

7 files changed

+41
-20
lines changed

7 files changed

+41
-20
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.deps
22
*.so
33
*.o
4-
ptrack--2.0.sql
54
Dockerfile
6-

Makefile

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
MODULE_big = ptrack
44
OBJS = ptrack.o datapagemap.o engine.o $(WIN32RES)
5-
EXTENSION = ptrack
6-
EXTVERSION = 2.1
7-
DATA = ptrack.sql ptrack--2.0--2.1.sql
8-
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
95
PGFILEDESC = "ptrack - block-level incremental backup engine"
106

11-
EXTRA_CLEAN = $(EXTENSION)--$(EXTVERSION).sql
7+
EXTENSION = ptrack
8+
EXTVERSION = 2.2
9+
DATA = ptrack--2.1.sql ptrack--2.0--2.1.sql ptrack--2.1--2.2.sql
1210

1311
TAP_TESTS = 1
1412

@@ -22,13 +20,3 @@ top_builddir = ../..
2220
include $(top_builddir)/src/Makefile.global
2321
include $(top_srcdir)/contrib/contrib-global.mk
2422
endif
25-
26-
$(EXTENSION)--$(EXTVERSION).sql: ptrack.sql
27-
cat $^ > $@
28-
29-
# temp-install: EXTRA_INSTALL=contrib/ptrack
30-
31-
# check-tap: temp-install
32-
# $(prove_check)
33-
34-
# check: check-tap

ptrack--2.1--2.2.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* ptrack/ptrack--2.1--2.2.sql */
2+
3+
-- Complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\ echo Use "ALTER EXTENSION ptrack UPDATE;" to load this file.\ quit
5+
6+
CREATE FUNCTION ptrack_get_change_stat(start_lsn pg_lsn)
7+
RETURNS TABLE (
8+
files bigint,
9+
pages bigint,
10+
"size, MB" numeric
11+
) AS
12+
$func$
13+
DECLARE
14+
block_size bigint;
15+
BEGIN
16+
block_size := (SELECT setting FROM pg_settings WHERE name = 'block_size');
17+
18+
RETURN QUERY
19+
SELECT changed_files,
20+
changed_pages,
21+
block_size*changed_pages/(1024.0*1024)
22+
FROM
23+
(SELECT count(path) AS changed_files,
24+
sum(
25+
length(replace(right((pagemap)::text, -1)::varbit::text, '0', ''))
26+
) AS changed_pages
27+
FROM ptrack_get_pagemapset(start_lsn)) s;
28+
END
29+
$func$ LANGUAGE plpgsql;

ptrack.sql renamed to ptrack--2.1.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* ptrack/ptrack--2.1.sql */
2+
13
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
24
\echo Use "CREATE EXTENSION ptrack" to load this file. \quit
35

ptrack.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ptrack extension
22
comment = 'block-level incremental backup engine'
3-
default_version = '2.1'
3+
default_version = '2.2'
44
module_pathname = '$libdir/ptrack'
55
relocatable = true

ptrack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "utils/relcache.h"
2323

2424
/* Ptrack version as a string */
25-
#define PTRACK_VERSION "2.1"
25+
#define PTRACK_VERSION "2.2"
2626
/* Ptrack version as a number */
2727
#define PTRACK_VERSION_NUM 220
2828

t/001_basic.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use TestLib;
1111
use Test::More;
1212

13-
plan tests => 23;
13+
plan tests => 24;
1414

1515
my $node;
1616
my $res;
@@ -115,6 +115,10 @@
115115
qr/$rel_oid/,
116116
'ptrack pagemapset should contain new relation oid');
117117

118+
# Check change stats
119+
$res_stdout = $node->safe_psql("postgres", "SELECT pages FROM ptrack_get_change_stat('$flush_lsn')");
120+
is($res_stdout > 0, 1, 'should be able to get aggregated stats of changes');
121+
118122
# We should be able to change ptrack map size (but loose all changes)
119123
$node->append_conf(
120124
'postgresql.conf', q{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy