Skip to content

Commit 8a9275e

Browse files
committed
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)
1 parent ff5dbda commit 8a9275e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/recorder/worker.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ fn get<'a>() -> Option<RefMut<'a, rusqlite::Connection>> {
3232
if database_oid == 0 {
3333
return None;
3434
}
35+
// Skip if vchord extension is not installed in this database
36+
if unsafe { pgrx::pg_sys::get_extension_oid(c"vchord".as_ptr(), true) }
37+
== pgrx::pg_sys::InvalidOid
38+
{
39+
return None;
40+
}
3541
let mut connection = CONNECTION.borrow_mut();
3642
if connection.is_none()
3743
&& let Err(err) = || -> rusqlite::Result<()> {

0 commit comments

Comments
 (0)