diff --git a/pgxn/neon/Makefile b/pgxn/neon/Makefile index e88901ed78..1ed1409f98 100644 --- a/pgxn/neon/Makefile +++ b/pgxn/neon/Makefile @@ -20,7 +20,7 @@ SHLIB_LINK_INTERNAL = $(libpq) SHLIB_LINK = -lcurl EXTENSION = neon -DATA = neon--1.0.sql +DATA = neon--1.0.sql neon--1.0--1.1.sql PGFILEDESC = "neon - cloud storage for PostgreSQL" diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 3ec953d8c5..01c6d11ccd 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -32,11 +32,13 @@ #include "storage/latch.h" #include "storage/ipc.h" #include "storage/lwlock.h" +#include "utils/builtins.h" #include "utils/dynahash.h" #include "utils/guc.h" #include "storage/fd.h" #include "storage/pg_shmem.h" #include "storage/buf_internals.h" +#include "pgstat.h" /* * Local file cache is used to temporary store relations pages in local file system. @@ -496,6 +498,7 @@ lfc_read(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, { /* Page is not cached */ lfc_ctl->misses += 1; /* race condition here, but precise value is not needed */ + pgBufferUsage.file_cache.misses += 1; LWLockRelease(lfc_lock); return false; } @@ -521,6 +524,7 @@ lfc_read(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, { Assert(LFC_ENABLED()); lfc_ctl->hits += 1; + pgBufferUsage.file_cache.hits += 1; Assert(entry->access_count > 0); if (--entry->access_count == 0) dlist_push_tail(&lfc_ctl->lru, &entry->lru_node); @@ -650,25 +654,27 @@ typedef struct } LocalCachePagesContext; -PG_FUNCTION_INFO_V1(local_cache_hits); +PG_FUNCTION_INFO_V1(neon_get_stat); Datum -local_cache_hits(PG_FUNCTION_ARGS) +neon_get_stat(PG_FUNCTION_ARGS) { - if (lfc_ctl) - PG_RETURN_INT64(lfc_ctl->hits); - else - PG_RETURN_NULL(); -} - - -PG_FUNCTION_INFO_V1(local_cache_misses); -Datum -local_cache_misses(PG_FUNCTION_ARGS) -{ - if (lfc_ctl) - PG_RETURN_INT64(lfc_ctl->misses); - else - PG_RETURN_NULL(); + char *key = text_to_cstring(PG_GETARG_TEXT_PP(0)); + if (strcmp(key, "file_cache_misses") == 0) + { + if (lfc_ctl) + PG_RETURN_INT64(lfc_ctl->misses); + } + else if (strcmp(key, "file_cache_hits") == 0) + { + if (lfc_ctl) + PG_RETURN_INT64(lfc_ctl->hits); + } + else if (strcmp(key, "file_cache_used") == 0) + { + if (lfc_ctl) + PG_RETURN_INT64(lfc_ctl->used); + } + PG_RETURN_NULL(); } diff --git a/pgxn/neon/neon--1.0.sql b/pgxn/neon/neon--1.0.sql index 81f68dafef..6cf111ea6a 100644 --- a/pgxn/neon/neon--1.0.sql +++ b/pgxn/neon/neon--1.0.sql @@ -22,16 +22,6 @@ AS 'MODULE_PATHNAME', 'backpressure_throttling_time' LANGUAGE C STRICT PARALLEL UNSAFE; -CREATE FUNCTION local_cache_hits() RETURNS bigint -AS 'MODULE_PATHNAME', 'local_cache_hits' -LANGUAGE C PARALLEL SAFE; - - -CREATE FUNCTION local_cache_misses() RETURNS bigint -AS 'MODULE_PATHNAME', 'local_cache_misses' -LANGUAGE C PARALLEL SAFE; - - CREATE FUNCTION local_cache_pages() RETURNS SETOF RECORD AS 'MODULE_PATHNAME', 'local_cache_pages' diff --git a/pgxn/neon/neon.control b/pgxn/neon/neon.control index 84f79881c1..c110437c3e 100644 --- a/pgxn/neon/neon.control +++ b/pgxn/neon/neon.control @@ -1,4 +1,4 @@ # neon extension comment = 'cloud storage for PostgreSQL' -default_version = '1.0' +default_version = '1.1' module_pathname = '$libdir/neon' diff --git a/vendor/postgres-v14 b/vendor/postgres-v14 index 5d5cfee127..80932ee1ae 160000 --- a/vendor/postgres-v14 +++ b/vendor/postgres-v14 @@ -1 +1 @@ -Subproject commit 5d5cfee12783f0989a9c9fe13bb40b5585812568 +Subproject commit 80932ee1ae0b8e645390546ed104c357cddc7d0c diff --git a/vendor/postgres-v15 b/vendor/postgres-v15 index 74cfe3e681..327f4e5e7d 160000 --- a/vendor/postgres-v15 +++ b/vendor/postgres-v15 @@ -1 +1 @@ -Subproject commit 74cfe3e681836747a31fdbd47bdd14b3d81b0772 +Subproject commit 327f4e5e7db1050ce1b79e19f3d27ef1cff7acca diff --git a/vendor/postgres-v16 b/vendor/postgres-v16 index 389ce36b4b..e6c1ece2ef 160000 --- a/vendor/postgres-v16 +++ b/vendor/postgres-v16 @@ -1 +1 @@ -Subproject commit 389ce36b4b3da7aa654a25e1b3f10b641319a87f +Subproject commit e6c1ece2efbf52277565936925ae43599ce51730 diff --git a/vendor/revisions.json b/vendor/revisions.json index d08cb25f43..e061e846c1 100644 --- a/vendor/revisions.json +++ b/vendor/revisions.json @@ -1,5 +1,5 @@ { - "postgres-v16": "389ce36b4b3da7aa654a25e1b3f10b641319a87f", - "postgres-v15": "74cfe3e681836747a31fdbd47bdd14b3d81b0772", - "postgres-v14": "5d5cfee12783f0989a9c9fe13bb40b5585812568" + "postgres-v16": "e6c1ece2efbf52277565936925ae43599ce51730", + "postgres-v15": "327f4e5e7db1050ce1b79e19f3d27ef1cff7acca", + "postgres-v14": "80932ee1ae0b8e645390546ed104c357cddc7d0c" }