Hi,

I get the error `can not find file ""` when I hack the bgworkers, the
root case is a zero initialized bgworker was registered. It's not
interesting, but I'd like to refine the error message a bit.

Thanks.

-- 
Adam Lee
>From 5f78d92b2c2b9ed0b3cbfdfe09e1461fbe05196d Mon Sep 17 00:00:00 2001
From: Adam Lee <adam8...@gmail.com>
Date: Tue, 11 Feb 2020 13:50:35 +0800
Subject: [PATCH] Sanity check BackgroundWorker's function entry

Without this, the error we got would be "can not find file/function" in
the load_external_function(), which is not obvious enough.
---
 src/backend/postmaster/bgworker.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/backend/postmaster/bgworker.c 
b/src/backend/postmaster/bgworker.c
index 75fc0d5d33..85f5d84783 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -637,6 +637,14 @@ SanityCheckBackgroundWorker(BackgroundWorker *worker, int 
elevel)
        if (strcmp(worker->bgw_type, "") == 0)
                strcpy(worker->bgw_type, worker->bgw_name);
 
+       if (!worker->bgw_library_name[0] || !worker->bgw_function_name[0])
+       {
+               ereport(elevel,
+                       (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                        errmsg("background worker: invalid entry function")));
+               return false;
+       }
+
        return true;
 }
 
-- 
2.25.0

Reply via email to