Thread: Annoying error messages in _dosmaperr

Annoying error messages in _dosmaperr

From
ITAGAKI Takahiro
Date:
Hello,

I found that pg_resetxlog always prints the following message on Windows.
   mapped win32 error code 2 to 2

Can we supress this annoying message? It seems to come from _dosmaperr,
but the error "postmaster.pid is not found" is a *normal* situation
in pg_resetxlog.
   -> open("%s/postmaster.pid", O_RDONLY, 0)   -> pgwin32_open()   -> _dosmaperr()       #ifndef FRONTEND
ereport(DEBUG5,...);       #else           fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);
#endif

DEBUG5 means the messages are completely non-critical. Therefore, client
programs also don't need to report them, no? If possible, I'd like to
remove the #else block (or all of them) from the above routine.

(On the other hand, "unrecognized win32 error code" part should be there.)

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



Re: Annoying error messages in _dosmaperr

From
Tom Lane
Date:
ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
> Can we supress this annoying message? It seems to come from _dosmaperr,
> but the error "postmaster.pid is not found" is a *normal* situation
> in pg_resetxlog.

>     -> open("%s/postmaster.pid", O_RDONLY, 0)
>     -> pgwin32_open()
>     -> _dosmaperr()
>         #ifndef FRONTEND
>             ereport(DEBUG5, ...);
>         #else
>             fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);
>         #endif

> DEBUG5 means the messages are completely non-critical. Therefore, client
> programs also don't need to report them, no? If possible, I'd like to
> remove the #else block (or all of them) from the above routine.

I suppose ideally we'd have some sort of debug-output switch on the
client side and code the #else branch like this
if (debug >= 5)    fprintf(stderr, ...);

It's probably not worth the trouble to do that, but maybe we could just
have a FRONTEND_DEBUG compile time switch:
       #ifndef FRONTEND           ereport(DEBUG5, ...);       #elif FRONTEND_DEBUG           fprintf(stderr, _("mapped
win32error code %lu to %d"), e, errno);       #endif
 

That would at least leave the code in place if anyone needed the
debugging output badly enough to do a custom build.
        regards, tom lane


Re: Annoying error messages in _dosmaperr

From
ITAGAKI Takahiro
Date:
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> It's probably not worth the trouble to do that, but maybe we could just
> have a FRONTEND_DEBUG compile time switch:
> That would at least leave the code in place if anyone needed the
> debugging output badly enough to do a custom build.

It would be a simplest solution.

I grep-ed sources with #ifndef FRONTEND and #ifdef FRONTEND,
but there are no other "DEBUG or stderr" codes. All other codes
are "WARNING/LOG or stderr", so I keep all of them as-is.


Index: src/port/win32error.c
===================================================================
--- src/port/win32error.c    (HEAD)
+++ src/port/win32error.c    (working copy)
@@ -180,7 +180,7 @@            ereport(DEBUG5,                    (errmsg_internal("mapped win32 error code %lu to %d",
                                   e, errno)));
 
-#else
+#elif FRONTEND_DEBUG            fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);#endif
return;


Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center




Re: Annoying error messages in _dosmaperr

From
Tom Lane
Date:
ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
> I grep-ed sources with #ifndef FRONTEND and #ifdef FRONTEND,
> but there are no other "DEBUG or stderr" codes. All other codes
> are "WARNING/LOG or stderr", so I keep all of them as-is.

Looks good, applied.
        regards, tom lane