[PATCH]Add a tip to the check mode

Started by Wen Yiover 2 years ago3 messages
#1Wen Yi
wen-yi@qq.com
1 attachment(s)

Hi community,
when I learn the source of PostgreSQL, I think it's better to add a tip to the postgres "check mode", this can help the postgres's user when they check the postgres's data directory.

src/backend/bootstrap/bootstrap.c

if (check_only)
    {
        SetProcessingMode(NormalProcessing);
        CheckerModeMain();
        abort();
    }

Instead of

if (check_only)
    {
        SetProcessingMode(NormalProcessing);
        CheckerModeMain();
        printf("PostgreSQL check success, there's no problem\n");

        abort();
    }

Yours,
Wen Yi

Attachments:

Add-a-tip-to-the-check-mode.patchapplication/octet-stream; charset=ISO-8859-1; name=Add-a-tip-to-the-check-mode.patchDownload
--- ./src/backend/bootstrap/bootstrap.c	2023-06-11 21:49:43.094837279 +0800
+++ ../postgresql/src/backend/bootstrap/bootstrap.c	2023-07-11 15:37:32.513367671 +0800
@@ -334,6 +334,7 @@
 	{
 		SetProcessingMode(NormalProcessing);
 		CheckerModeMain();
+		printf("PostgreSQL check success, there's no problem.\n");
 		abort();
 	}
 
#2Matthias van de Meent
boekewurm+postgres@gmail.com
In reply to: Wen Yi (#1)
Re: [PATCH]Add a tip to the check mode

On Tue, 11 Jul 2023 at 15:11, Wen Yi <wen-yi@qq.com> wrote:

Hi community,
when I learn the source of PostgreSQL, I think it's better to add a tip to the postgres "check mode", this can help the postgres's user when they check the postgres's data directory.

src/backend/bootstrap/bootstrap.c

if (check_only)
{
SetProcessingMode(NormalProcessing);
CheckerModeMain();
abort();
}

Instead of

if (check_only)
{
SetProcessingMode(NormalProcessing);
CheckerModeMain();
printf("PostgreSQL check success, there's no problem\n");
abort();
}

I'm afraid I don't understand the point of your suggestion.
CheckerModeMain doesn't return (it unconditionally calls proc_exit(),
which doesn't return) - it shouldn't hit the abort() clause. If it did
hit the abort() clause, that'd probably be a problem on its own,
right?

--
Kind regards,

Matthias van de Meent
Neon (https://neon.tech)

#3Wen Yi
wen-yi@qq.com
In reply to: Matthias van de Meent (#2)
1 attachment(s)
Re: [PATCH]Add a tip to the check mode

I'm so sorry for my careless, you're right.
But I still think there should add a tip to our user when there's check ok, because when I use the check mode, it didn't give me any message (If there's no error happend) and just exit, like this:

[beginnerc@bogon devel]$ postgres --check -D /home/beginnerc/pgsql/data
[beginnerc@bogon devel]$

[beginnerc@bogon devel]$ echo $?
0

That's confused me, until I print the return value.
So I think we should add this tip.

I fix and recommit the patch, thanks very much for your reply.

Yours,
Wen Yi

------------------&nbsp;Original&nbsp;------------------
From: "Matthias van de Meent" <boekewurm+postgres@gmail.com&gt;;
Date:&nbsp;Tue, Jul 11, 2023 09:44 PM
To:&nbsp;"Wen Yi"<wen-yi@qq.com&gt;;
Cc:&nbsp;"pgsql-hackers"<pgsql-hackers@lists.postgresql.org&gt;;
Subject:&nbsp;Re: [PATCH]Add a tip to the check mode

On Tue, 11 Jul 2023 at 15:11, Wen Yi <wen-yi@qq.com&gt; wrote:
&gt;
&gt; Hi community,
&gt; when I learn the source of PostgreSQL, I think it's better to add a tip to the postgres "check mode", this can help the postgres's user when they check the postgres's data directory.
&gt;
&gt; src/backend/bootstrap/bootstrap.c
&gt;
&gt; if (check_only)
&gt;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetProcessingMode(NormalProcessing);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CheckerModeMain();
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abort();
&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;
&gt; Instead of
&gt;
&gt; if (check_only)
&gt;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetProcessingMode(NormalProcessing);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CheckerModeMain();
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("PostgreSQL check success, there's no problem\n");
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abort();
&gt;&nbsp;&nbsp;&nbsp;&nbsp; }

I'm afraid I don't understand the point of your suggestion.
CheckerModeMain doesn't return (it unconditionally calls proc_exit(),
which doesn't return) - it shouldn't hit the abort() clause. If it did
hit the abort() clause, that'd probably be a problem on its own,
right?

--
Kind regards,

Matthias van de Meent
Neon (https://neon.tech)

Attachments:

Add-a-tip-to-the-check-mode[fix].patchapplication/octet-stream; charset=ISO-8859-1; name="=?ISO-8859-1?B?QWRkLWEtdGlwLXRvLXRoZS1jaGVjay1tb2RlW2ZpeF0ucGF0Y2g=?="Download
--- /home/beginnerc/work/postgres/devel/src/backend/bootstrap/bootstrap.c	2023-07-12 14:56:54.064367635 +0800
+++ /home/beginnerc/work/postgres/original/src/backend/bootstrap/bootstrap.c	2023-07-12 07:26:42.368750251 +0800
@@ -333,7 +333,6 @@
 	if (check_only)
 	{
 		SetProcessingMode(NormalProcessing);
-        printf("PostgreSQL check success, there's no problem\n");
 		CheckerModeMain();
 		abort();
 	}