Skip to content

Commit

Permalink
Start deprecation of PostgreSQL < 12
Browse files Browse the repository at this point in the history
11 is EOL since 9/11/2023 and the ereport() functions has changed in
PostgreSQL 12. Also it's time to modernize code and SMGRelation was
absent in 9.6... so for the new code it'll be easier to manage only
current PostgreSQL versions.

And prepare for pgfincore 2.0.0 !

As we're to deprecated some C functions, we need an upgrade script from
1.3.1 but also a fresh new one for 2.0.0 else PostgreSQL will fail to
apply upgrade path (first try to create pgsysconf will fail for example,
as the shared object don't have this function anymore.
  • Loading branch information
c2main committed Dec 15, 2024
1 parent dd964ee commit 83c3e40
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
- 14
- 13
- 12
- 11
- 10
- 9.6
- 9.5
- 9.4
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
04/12/2023 Cédric Villemain <[email protected]>
* 2.0 - drop support for PostgreSQL < 12

21/09/2023 Cédric Villemain <[email protected]>
* 1.3.1 - drop support for upgrading from "unpackaged"

21/09/2023 Cédric Villemain <[email protected]>
* 1.3 - added support for PostgreSQL 16
- drop support for PostgreSQL < 9.4

2019-10-29 Cédric Villemain <[email protected]>
* 1.2.2 - Fix bad errno usage

22/09/2017 Cédric Villemain <[email protected]>
* 1.2.1 - Fix check on NULL input for drawer function

Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
EXTENSION = pgfincore
EXTVERSION = 1.3.1
EXTVERSION = 2.0.0

MODULES = $(EXTENSION)
MODULEDIR = $(EXTENSION)
DOCS = README.md
DATA = $(EXTENSION)--1.2--1.3.1.sql \
$(EXTENSION)--$(EXTVERSION).sql
DATA = $(wildcard *.sql)

REGRESS = $(EXTENSION)

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ You can grab the latest code with git:

git clone git://git.postgresql.org/git/pgfincore.git
or
git://github.com/klando/pgfincore.git

And the project is on pgfoundry : http://pgfoundry.org/projects/pgfincore
git://github.com/pgfincore/pgfincore.git

## INSTALL

Expand All @@ -48,14 +46,10 @@ From source code:
su
make install

For PostgreSQL >= 9.1, log in your database and:
Log in your database and:

mydb=# CREATE EXTENSION pgfincore;

For other release, create the functions from the sql script (it should be in
your contrib directory):

psql mydb -f pgfincore.sql

PgFincore is also shipped with Debian scripts to build your own package:

Expand Down
Empty file added pgfincore--1.3.1--2.0.0.sql
Empty file.
193 changes: 193 additions & 0 deletions pgfincore--2.0.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
--
-- SYSCONF
--
CREATE OR REPLACE FUNCTION
pgsysconf(OUT os_page_size bigint,
OUT os_pages_free bigint,
OUT os_total_pages bigint)
RETURNS record
AS '$libdir/pgfincore'
LANGUAGE C;

COMMENT ON FUNCTION pgsysconf()
IS 'Get system configuration information at run time:
- os_page_size is _SC_PAGESIZE
- os_pages_free is _SC_AVPHYS_PAGES
- os_total_pages is _SC_PHYS_PAGES
man 3 sysconf for details';


CREATE OR REPLACE FUNCTION
pgsysconf_pretty(OUT os_page_size text,
OUT os_pages_free text,
OUT os_total_pages text)
RETURNS record
AS '
select pg_size_pretty(os_page_size) as os_page_size,
pg_size_pretty(os_pages_free * os_page_size) as os_pages_free,
pg_size_pretty(os_total_pages * os_page_size) as os_total_pages
from pgsysconf()'
LANGUAGE SQL;

COMMENT ON FUNCTION pgsysconf_pretty()
IS 'Pgsysconf() with human readable output';

--
-- PGFADVISE
--
CREATE OR REPLACE FUNCTION
pgfadvise(IN regclass, IN text, IN int,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS '$libdir/pgfincore'
LANGUAGE C;

COMMENT ON FUNCTION pgfadvise(regclass, text, int)
IS 'Predeclare an access pattern for file data';

CREATE OR REPLACE FUNCTION
pgfadvise_willneed(IN regclass,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS 'SELECT pgfadvise($1, ''main'', 10)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfadvise_dontneed(IN regclass,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS 'SELECT pgfadvise($1, ''main'', 20)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfadvise_normal(IN regclass,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS 'SELECT pgfadvise($1, ''main'', 30)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfadvise_sequential(IN regclass,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS 'SELECT pgfadvise($1, ''main'', 40)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfadvise_random(IN regclass,
OUT relpath text,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT os_pages_free bigint)
RETURNS setof record
AS 'SELECT pgfadvise($1, ''main'', 50)'
LANGUAGE SQL;

--
-- PGFADVISE_LOADER
--
CREATE OR REPLACE FUNCTION
pgfadvise_loader(IN regclass, IN text, IN int, IN bool, IN bool, IN varbit,
OUT relpath text,
OUT os_page_size bigint,
OUT os_pages_free bigint,
OUT pages_loaded bigint,
OUT pages_unloaded bigint)
RETURNS setof record
AS '$libdir/pgfincore'
LANGUAGE C;

COMMENT ON FUNCTION pgfadvise_loader(regclass, text, int, bool, bool, varbit)
IS 'Restore cache from the snapshot, options to load/unload each block to/from cache';


CREATE OR REPLACE FUNCTION
pgfadvise_loader(IN regclass, IN int, IN bool, IN bool, IN varbit,
OUT relpath text,
OUT os_page_size bigint,
OUT os_pages_free bigint,
OUT pages_loaded bigint,
OUT pages_unloaded bigint)
RETURNS setof record
AS 'SELECT pgfadvise_loader($1, ''main'', $2, $3, $4, $5)'
LANGUAGE SQL;

--
-- PGFINCORE
--
CREATE OR REPLACE FUNCTION
pgfincore(IN regclass, IN text, IN bool,
OUT relpath text,
OUT segment int,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT pages_mem bigint,
OUT group_mem bigint,
OUT os_pages_free bigint,
OUT databit varbit,
OUT pages_dirty bigint,
OUT group_dirty bigint)
RETURNS setof record
AS '$libdir/pgfincore'
LANGUAGE C;

COMMENT ON FUNCTION pgfincore(regclass, text, bool)
IS 'Utility to inspect and get a snapshot of the system cache';

CREATE OR REPLACE FUNCTION
pgfincore(IN regclass, IN bool,
OUT relpath text,
OUT segment int,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT pages_mem bigint,
OUT group_mem bigint,
OUT os_pages_free bigint,
OUT databit varbit,
OUT pages_dirty bigint,
OUT group_dirty bigint)
RETURNS setof record
AS 'SELECT * from pgfincore($1, ''main'', $2)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfincore(IN regclass,
OUT relpath text,
OUT segment int,
OUT os_page_size bigint,
OUT rel_os_pages bigint,
OUT pages_mem bigint,
OUT group_mem bigint,
OUT os_pages_free bigint,
OUT databit varbit,
OUT pages_dirty bigint,
OUT group_dirty bigint)
RETURNS setof record
AS 'SELECT * from pgfincore($1, ''main'', false)'
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION
pgfincore_drawer(IN varbit,
OUT drawer cstring)
RETURNS cstring
AS '$libdir/pgfincore'
LANGUAGE C;

COMMENT ON FUNCTION pgfincore_drawer(varbit)
IS 'A naive drawing function to visualize page cache per object';
2 changes: 1 addition & 1 deletion pgfincore.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pgfincore extension
comment = 'examine and manage the os buffer cache'
default_version = '1.3.1'
default_version = '2.0.0'
module_pathname = '$libdir/pgfincore'
directory = pgfincore
relocatable = true

0 comments on commit 83c3e40

Please sign in to comment.