Standardize the definition of the subtype field of AlterDomainStmt

Started by Quan Zongliang11 months ago9 messageshackers
Jump to latest
#1Quan Zongliang
quanzongliang@yeah.net

I noticed that the subtype of AlterDomainStmt is directly using
constants in the code. It is not conducive to the maintenance and
reading of the code. Based on the definition of AlterTableType, use
"AD_" as the prefix. Define several macros to replace the original
characters.
The subtype of AlterTableCmd is defined using an enumeration. The
subtypes of AlterDomainStmt are relatively few in number, and the
original definition uses characters. These definitions still use
characters and maintain the values unchanged. If some plugins or tools
are also processing AlterDomainStmt, there will be no errors.

--
Quan Zongliang

Attachments:

alterdomain_subtype.patchtext/plain; charset=UTF-8; name=alterdomain_subtype.patchDownload+22-22
#2Michael Paquier
michael@paquier.xyz
In reply to: Quan Zongliang (#1)
Re: Standardize the definition of the subtype field of AlterDomainStmt

On Tue, May 27, 2025 at 11:06:46AM +0800, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using constants in
the code. It is not conducive to the maintenance and reading of the code.
Based on the definition of AlterTableType, use "AD_" as the prefix. Define
several macros to replace the original characters.
The subtype of AlterTableCmd is defined using an enumeration. The subtypes
of AlterDomainStmt are relatively few in number, and the original definition
uses characters. These definitions still use characters and maintain the
values unchanged. If some plugins or tools are also processing
AlterDomainStmt, there will be no errors.

Sounds like a good idea. As far as I can see after a closer lookup at
the tree, you have updated all the code paths that matter for this
change, and you have added a CF entry:
https://commitfest.postgresql.org/patch/5780/

+#define AD_VaidateConstraint 'V' /* VALIDATE CONSTRAINT */

s/Vaidate/Validate
--
Michael

#3wenhui qiu
qiuwenhuifx@gmail.com
In reply to: Michael Paquier (#2)
Re: Standardize the definition of the subtype field of AlterDomainStmt

HI

I noticed that the subtype of AlterDomainStmt is directly using
constants in the code. It is not conducive to the maintenance and
reading of the code. Based on the definition of AlterTableType, use
"AD_" as the prefix. Define several macros to replace the original
characters.
The subtype of AlterTableCmd is defined using an enumeration. The
subtypes of AlterDomainStmt are relatively few in number, and the
original definition uses characters. These definitions still use
characters and maintain the values unchanged. If some plugins or tools
are also processing AlterDomainStmt, there will be no errors.

Agree ,This makes the code neater and easier to understand

On Tue, May 27, 2025 at 11:55 AM Michael Paquier <michael@paquier.xyz>
wrote:

Show quoted text

On Tue, May 27, 2025 at 11:06:46AM +0800, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using

constants in

the code. It is not conducive to the maintenance and reading of the code.
Based on the definition of AlterTableType, use "AD_" as the prefix.

Define

several macros to replace the original characters.
The subtype of AlterTableCmd is defined using an enumeration. The

subtypes

of AlterDomainStmt are relatively few in number, and the original

definition

uses characters. These definitions still use characters and maintain the
values unchanged. If some plugins or tools are also processing
AlterDomainStmt, there will be no errors.

Sounds like a good idea. As far as I can see after a closer lookup at
the tree, you have updated all the code paths that matter for this
change, and you have added a CF entry:
https://commitfest.postgresql.org/patch/5780/

+#define AD_VaidateConstraint 'V' /* VALIDATE CONSTRAINT */

s/Vaidate/Validate
--
Michael

#4Quan Zongliang
quanzongliang@yeah.net
In reply to: Michael Paquier (#2)
Re: Standardize the definition of the subtype field of AlterDomainStmt

On 2025/5/27 11:54, Michael Paquier wrote:

On Tue, May 27, 2025 at 11:06:46AM +0800, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using constants in
the code. It is not conducive to the maintenance and reading of the code.
Based on the definition of AlterTableType, use "AD_" as the prefix. Define
several macros to replace the original characters.
The subtype of AlterTableCmd is defined using an enumeration. The subtypes
of AlterDomainStmt are relatively few in number, and the original definition
uses characters. These definitions still use characters and maintain the
values unchanged. If some plugins or tools are also processing
AlterDomainStmt, there will be no errors.

Sounds like a good idea. As far as I can see after a closer lookup at
the tree, you have updated all the code paths that matter for this
change, and you have added a CF entry:
https://commitfest.postgresql.org/patch/5780/

+#define AD_VaidateConstraint 'V' /* VALIDATE CONSTRAINT */

Updated
Thank you.

Show quoted text

s/Vaidate/Validate
--
Michael

Attachments:

alterdomain_subtype.patchtext/plain; charset=UTF-8; name=alterdomain_subtype.patchDownload+22-22
#5wenhui qiu
qiuwenhuifx@gmail.com
In reply to: Quan Zongliang (#4)
Re: Standardize the definition of the subtype field of AlterDomainStmt

HI
Thank you for your update ,I marked the path as "Ready for Committer"

Thank

On Wed, May 28, 2025 at 10:27 AM Quan Zongliang <quanzongliang@yeah.net>
wrote:

Show quoted text

On 2025/5/27 11:54, Michael Paquier wrote:

On Tue, May 27, 2025 at 11:06:46AM +0800, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using

constants in

the code. It is not conducive to the maintenance and reading of the

code.

Based on the definition of AlterTableType, use "AD_" as the prefix.

Define

several macros to replace the original characters.
The subtype of AlterTableCmd is defined using an enumeration. The

subtypes

of AlterDomainStmt are relatively few in number, and the original

definition

uses characters. These definitions still use characters and maintain the
values unchanged. If some plugins or tools are also processing
AlterDomainStmt, there will be no errors.

Sounds like a good idea. As far as I can see after a closer lookup at
the tree, you have updated all the code paths that matter for this
change, and you have added a CF entry:
https://commitfest.postgresql.org/patch/5780/

+#define AD_VaidateConstraint 'V' /* VALIDATE CONSTRAINT */

Updated
Thank you.

s/Vaidate/Validate
--
Michael

#6Peter Eisentraut
peter_e@gmx.net
In reply to: Quan Zongliang (#1)
Re: Standardize the definition of the subtype field of AlterDomainStmt

On 27.05.25 05:06, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using
constants in the code. It is not conducive to the maintenance and
reading of the code. Based on the definition of AlterTableType, use
"AD_" as the prefix. Define several macros to replace the original
characters.
The subtype of AlterTableCmd is defined using an enumeration. The
subtypes of AlterDomainStmt are relatively few in number, and the
original definition uses characters. These definitions still use
characters and maintain the values unchanged. If some plugins or tools
are also processing AlterDomainStmt, there will be no errors.

You can still make it an enum and assign the currently in use values to
the new symbols, like

enum AlterDomainType
{
AD_AlterDefault = 'T',
AD_DropNotNull = 'N',
...

I would prefer that.

#7Tender Wang
tndrwang@gmail.com
In reply to: Peter Eisentraut (#6)
Re: Standardize the definition of the subtype field of AlterDomainStmt

Peter Eisentraut <peter@eisentraut.org> 于2025年5月28日周三 19:23写道:

On 27.05.25 05:06, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using
constants in the code. It is not conducive to the maintenance and
reading of the code. Based on the definition of AlterTableType, use
"AD_" as the prefix. Define several macros to replace the original
characters.
The subtype of AlterTableCmd is defined using an enumeration. The
subtypes of AlterDomainStmt are relatively few in number, and the
original definition uses characters. These definitions still use
characters and maintain the values unchanged. If some plugins or tools
are also processing AlterDomainStmt, there will be no errors.

You can still make it an enum and assign the currently in use values to
the new symbols, like

enum AlterDomainType
{
AD_AlterDefault = 'T',
AD_DropNotNull = 'N',
...

I would prefer that.

+1

--
Thanks,
Tender Wang

#8Quan Zongliang
quanzongliang@yeah.net
In reply to: Tender Wang (#7)
Re: Standardize the definition of the subtype field of AlterDomainStmt

Updated

Show quoted text

On 2025/5/28 19:30, Tender Wang wrote:

Peter Eisentraut <peter@eisentraut.org <mailto:peter@eisentraut.org>> 于
2025年5月28日周三 19:23写道:

On 27.05.25 05:06, Quan Zongliang wrote:

I noticed that the subtype of AlterDomainStmt is directly using
constants in the code. It is not conducive to the maintenance and
reading of the code. Based on the definition of AlterTableType, use
"AD_" as the prefix. Define several macros to replace the original
characters.
The subtype of AlterTableCmd is defined using an enumeration. The
subtypes of AlterDomainStmt are relatively few in number, and the
original definition uses characters. These definitions still use
characters and maintain the values unchanged. If some plugins or

tools

are also processing AlterDomainStmt, there will be no errors.

You can still make it an enum and assign the currently in use values to
the new symbols, like

enum AlterDomainType
{
     AD_AlterDefault = 'T',
     AD_DropNotNull = 'N',
     ...

I would prefer that.

+1

--
Thanks,
Tender Wang

Attachments:

alterdomain_subtype-v2.patchtext/plain; charset=UTF-8; name=alterdomain_subtype-v2.patchDownload+25-22
#9Michael Paquier
michael@paquier.xyz
In reply to: Quan Zongliang (#8)
Re: Standardize the definition of the subtype field of AlterDomainStmt

On Thu, May 29, 2025 at 06:09:00AM +0800, Quan Zongliang wrote:

Updated

Applied, with a fixed indentation.
--
Michael