- Notifications
You must be signed in to change notification settings - Fork16
Pbckp 278 cfs ptrack#25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
76 changes: 76 additions & 0 deletionsengine.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletionsengine.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
42 changes: 31 additions & 11 deletionsptrack.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletionsptrack.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletionst/002_cfs_compatibility.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| use strict; | ||
| use warnings; | ||
| use Test::More; | ||
| my $pg_15_modules; | ||
| BEGIN | ||
| { | ||
| $pg_15_modules = eval | ||
| { | ||
| require PostgreSQL::Test::Cluster; | ||
| require PostgreSQL::Test::Utils; | ||
| return 1; | ||
| }; | ||
| unless (defined $pg_15_modules) | ||
| { | ||
| $pg_15_modules = 0; | ||
| require PostgresNode; | ||
| require TestLib; | ||
| } | ||
| } | ||
| note('PostgreSQL 15 modules are used: ' . ($pg_15_modules ? 'yes' : 'no')); | ||
| my $node; | ||
| my $res_stdout; | ||
| my $res_stderr; | ||
| # Create node. | ||
| # Older versions of PostgreSQL modules use get_new_node function. | ||
| # Newer use standard perl object constructor syntax. | ||
| eval | ||
| { | ||
| if ($pg_15_modules) | ||
| { | ||
| $node = PostgreSQL::Test::Cluster->new("node"); | ||
| } | ||
| else | ||
| { | ||
| $node = PostgresNode::get_new_node("node"); | ||
| } | ||
| }; | ||
| note "Test for handling a ptrack map in compressed relations"; | ||
| my $psql_stdout; | ||
| # Starting the node | ||
| $node->init; | ||
| # Could not load ptrack module after postmaster start | ||
| my $cfs_tblspc1 = $node->basedir."/cfs_tblspc1"; | ||
| my $cfs_tblspc2 = $node->basedir."/cfs_tblspc2"; | ||
| mkdir $cfs_tblspc1 or die; | ||
| mkdir $cfs_tblspc2 or die; | ||
| my $no_cfs_tblspc1 = $node->basedir."/no_cfs_tblspc1"; | ||
| my $no_cfs_tblspc2 = $node->basedir."/no_cfs_tblspc2"; | ||
| mkdir $no_cfs_tblspc1 or die; | ||
| mkdir $no_cfs_tblspc2 or die; | ||
| $node->append_conf('postgresql.conf', qq{ | ||
| shared_preload_libraries = 'ptrack' | ||
| ptrack.map_size = 16 | ||
| wal_level = 'replica' | ||
| }); | ||
| $node->start; | ||
| # check cfs availability first | ||
| my $cfs_available = $node->safe_psql('postgres', | ||
| "select count(oid) from pg_proc where proname = 'cfs_version'"); | ||
| if($cfs_available eq "0") { | ||
| $node->stop; | ||
| plan skip_all => "CFS is not supported by this PostgreSQL build"; | ||
| } else { | ||
| plan tests => 2; | ||
| } | ||
| # Creating content | ||
| $node->safe_psql('postgres', qq| | ||
| create tablespace cfs_tblspc1 location '$cfs_tblspc1' with (compression=true); | ||
| create tablespace cfs_tblspc2 location '$cfs_tblspc2' with (compression=true); | ||
| create tablespace no_cfs_tblspc1 location '$no_cfs_tblspc1'; | ||
| create tablespace no_cfs_tblspc2 location '$no_cfs_tblspc2'; | ||
| create database testing_cfs tablespace cfs_tblspc1; | ||
| create database testing_no_cfs tablespace no_cfs_tblspc1; | ||
| |); | ||
| $node->safe_psql('testing_cfs', qq{ | ||
| create table testing(i int, text varchar); | ||
| insert into testing select 1, '1111111111111111111111111' from generate_series(1,10000000); | ||
| }); | ||
| $node->safe_psql('testing_no_cfs', qq{ | ||
| create table testing_no(i int, text varchar); | ||
| insert into testing_no select 1, '1111111111111111111111111' from generate_series(1,10000000); | ||
| }); | ||
| # creating ptrack | ||
| $node->safe_psql('postgres', "create extension ptrack"); | ||
| # obtaining init lsn for further usage in ptrack_get_pagemapset | ||
| my $init_lsn = $node->safe_psql('postgres', 'select ptrack_init_lsn()'); | ||
| # forcing copydir() hook by altering dbs tablespaces | ||
| $node->safe_psql('postgres', "alter database testing_cfs set tablespace cfs_tblspc2;"); | ||
| $node->safe_psql('postgres', "alter database testing_no_cfs set tablespace no_cfs_tblspc2;"); | ||
| # obtaining relpath for cfs table | ||
| my $cfs_relpath = $node->safe_psql('testing_cfs', "select pg_relation_filepath('testing');"); | ||
| # obtaining relpath for no-cfs table | ||
| my $no_cfs_relpath = $node->safe_psql('testing_no_cfs', "select pg_relation_filepath('testing_no');"); | ||
| # select the pagecount sums and compare them (should be equal) | ||
| my $pagecount_sum_cfs = $node->safe_psql('postgres', | ||
| "select sum(pagecount) from ptrack_get_pagemapset('$init_lsn'::pg_lsn) where path like '%$cfs_relpath%';"); | ||
| my $pagecount_sum_no_cfs = $node->safe_psql('postgres', | ||
| "select sum(pagecount) from ptrack_get_pagemapset('$init_lsn'::pg_lsn) where path like '%$no_cfs_relpath%';"); | ||
| is($pagecount_sum_cfs, $pagecount_sum_no_cfs, "pagecount sums don't match"); | ||
| # forcing copydir() hook by altering dbs tablespaces back | ||
| $node->safe_psql('postgres', "alter database testing_cfs set tablespace cfs_tblspc1;"); | ||
| $node->safe_psql('postgres', "alter database testing_no_cfs set tablespace no_cfs_tblspc1;"); | ||
| # obtaining new relpath for cfs table | ||
| $cfs_relpath = $node->safe_psql('testing_cfs', "select pg_relation_filepath('testing');"); | ||
| # obtaining new relpath for no-cfs table | ||
| $no_cfs_relpath = $node->safe_psql('testing_no_cfs', "select pg_relation_filepath('testing_no');"); | ||
| # select the pagecount sums and compare them (again, they should be equal) | ||
| $pagecount_sum_cfs = $node->safe_psql('postgres', | ||
| "select sum(pagecount) from ptrack_get_pagemapset('$init_lsn'::pg_lsn) where path like '%$cfs_relpath%';"); | ||
| $pagecount_sum_no_cfs = $node->safe_psql('postgres', | ||
| "select sum(pagecount) from ptrack_get_pagemapset('$init_lsn'::pg_lsn) where path like '%$no_cfs_relpath%';"); | ||
| is($pagecount_sum_cfs, $pagecount_sum_no_cfs, "pagecount sums don't match"); | ||
| $node->stop; | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.