From 0a0ddaedc6620543a5a6e3a21d31a1a197e36282 Mon Sep 17 00:00:00 2001 From: Narek Galstyan Date: Mon, 23 Mar 2026 09:53:53 -0400 Subject: [PATCH] fix: skip recorder and sqlite state creation when vchord extension is not created When vchord is added to shared_preload_libraries without running CREATE EXTENSION, the object_access_hook fires on any DROP TABLE or DROP DATABASE and calls the recorder's get() function, which lazily creates the pgsql_tmp_vchord_sampling/ directory and SQLite files under PGDATA. This is unnecessary and confusing when looking at contents of PGDATA and seeing files from an extension that has never been enabled The commit skips all recorder operations when the extension has never been created (extension does not have an assigned OID) Signed-off-by: Narek Galstyan --- src/recorder/worker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/recorder/worker.rs b/src/recorder/worker.rs index fd942ae0..4cfef92d 100644 --- a/src/recorder/worker.rs +++ b/src/recorder/worker.rs @@ -32,6 +32,12 @@ fn get<'a>() -> Option> { if database_oid == 0 { return None; } + // Skip if vchord extension is not installed in this database + if unsafe { pgrx::pg_sys::get_extension_oid(c"vchord".as_ptr(), true) } + == pgrx::pg_sys::InvalidOid + { + return None; + } let mut connection = CONNECTION.borrow_mut(); if connection.is_none() && let Err(err) = || -> rusqlite::Result<()> {