Re: [PATCH][PROPOSAL] Add enum releation option type - Mailing list pgsql-hackers

From Alvaro Herrera from 2ndQuadrant
Subject Re: [PATCH][PROPOSAL] Add enum releation option type
Date
Msg-id 20190905154227.GA5287@alvherre.pgsql
Whole thread Raw
In response to Re: [PATCH][PROPOSAL] Add enum releation option type  (Nikolay Shaplov <dhyan@nataraj.su>)
Responses Re: [PATCH][PROPOSAL] Add enum releation option type
List pgsql-hackers
After looking closer once again, I don't like this patch.

I think the FOOBAR_ENUM_DEF defines serve no purpose, other than
source-code placement next to the enum value definitions.  I think for
example check_option, living in reloptions.c, should look like this:

    {
        {
            "check_option",
                "View has WITH CHECK OPTION defined (local or cascaded).",
                RELOPT_KIND_VIEW,
                AccessExclusiveLock
        },
        {
            { "local", VIEW_OPTION_CHECK_OPTION_LOCAL },
            { "cascaded", VIEW_OPTION_CHECK_OPTION_CASCADED },
            { NULL }
        },
        "Valid values are \"local\" and \"cascaded\"."
    },

Note the relopt_enum is pretty much the same you have, except we also
have a const char *valid_values_errdetail; and the ugly #define no
longer exists but instead we put it in enumRelOpts.

rel.h ends up like this:

/*
 * Values for ViewOptions->check_option.
 */
typedef enum
{
    VIEWOPTIONS_CHECK_OPTION_NOTSET,
    VIEWOPTIONS_CHECK_OPTION_LOCAL,
    VIEWOPTIONS_CHECK_OPTION_CASCADED
} ViewOpts_CheckOptionValues;

/*
 * ViewOptions
 *        Contents of rd_options for views
 */
typedef struct ViewOptions
{
    int32        vl_len_;        /* varlena header (do not touch directly!) */
    bool        security_barrier;
    ViewOpts_CheckOptionValues check_option;
} ViewOptions;

I'm marking this Waiting on Author.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Alvaro Herrera from 2ndQuadrant
Date:
Subject: Re: [PATCH] Add support for ON UPDATE/DELETE actions on ALTERCONSTRAINT
Next
From: Tom Lane
Date:
Subject: Re: CVE-2017-7484-induced bugs, or, btree cmp functions are not leakproof?