Re: cataloguing NOT NULL constraints

From: Nikhil Sontakke <nikkhils(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: cataloguing NOT NULL constraints
Date: 2011-08-04 08:23:59
Message-ID: CANgU5ZewjFSfrMoFCCUV777haH34uJt9s=hfsNCDpCO=_xmRvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2011-08-04 08:52:52 Re: WIP: Fast GiST index build
Previous Message Dean Rasheed 2011-08-04 07:57:11 Re: cataloguing NOT NULL constraints