Re: cataloguing NOT NULL constraints - Mailing list pgsql-hackers

From Nikhil Sontakke
Subject Re: cataloguing NOT NULL constraints
Date
Msg-id CANgU5ZewjFSfrMoFCCUV777haH34uJt9s=hfsNCDpCO=_xmRvw@mail.gmail.com
Whole thread Raw
In response to Re: cataloguing NOT NULL constraints  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: cataloguing NOT NULL constraints
Re: cataloguing NOT NULL constraints
List pgsql-hackers
> So after writing the code to handle named NOT NULL constraints for
> tables, I'm thinking that dumpConstraints needs to be fixed thusly:
>
> @@ -12888,6 +12968,27 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
>                         NULL, NULL);
>        }
>    }
> +   else if (coninfo->contype == 'n' && tbinfo)
> +   {
> +       /* NOT NULL constraint on a table */
> +       if (coninfo->separate)
> +       {
> +           write_msg(NULL, "NOT NULL constraints cannot be dumped separately from their owning table\n");
> +           exit_nicely();
> +       }
> +   }
> +   else if (coninfo->contype == 'n' && tbinfo == NULL)
> +   {
> +       /* NOT NULL constraint on a domain */
> +       TypeInfo   *tyinfo = coninfo->condomain;
> +
> +       /* Ignore if not to be dumped separately */
> +       if (coninfo->separate)
> +       {
> +           write_msg(NULL, "NOT NULL constraints cannot be dumped separately from their owning domain\n");
> +           exit_nicely();
> +       }
> +   }
>    else
>    {
>        write_msg(NULL, "unrecognized constraint type: %c\n", coninfo->contype);
>

Some nit-picking.

AFAICS above, we seem to be only using 'tbinfo' to identify the object
type here - 'table' visavis 'domain'. We could probably reduce the
above two elses to a single one and use the check of tbinfo being not
null to decide which object type name to spit out..

Although, it's difficult to see how we could end up marking NOT NULL
constraints as 'separate' ever. So this code will be rarely exercised,
if ever IMO.

Regards,
Nikhils


pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: cataloguing NOT NULL constraints
Next
From: Peter Geoghegan
Date:
Subject: Re: Further news on Clang - spurious warnings