Re: Domain check constraint not honored?

From: Dane Foster <studdugie(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Domain check constraint not honored?
Date: 2015-10-30 00:54:20
Message-ID: CA+WxinK+xrYgB3dmnnmcWCk9W6aQGkwsHXsQDe_=CSOFeLGuzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 29, 2015 at 7:16 PM, Rob Sargent <robjsargent(at)gmail(dot)com> wrote:

> On 10/29/2015 05:01 PM, Tom Lane wrote:
>
> Eric Schwarzenbach <subscriber(at)blackbrook(dot)org> <subscriber(at)blackbrook(dot)org> writes:
>
> ... (Also FWIW, the latest version of
> this regexp is now '^([0-9]+.)*[0-9]+$')
>
> Um, that's not gonna do what you want at all. Outside brackets, a dot
> is a wildcard. (Regex syntax is a mess :-(.)
>
> regards, tom lane
>
>
>
> arg. back to level two of regexpness for me :( I read it as ^[0-9.]+
>

​If I understand your regex needs correctly you want to allow digits
separated by dots (like IPv4 octets) but never start w/ or end w/ a dot nor
any non digit character other than a dot. If that's the case this may work.
I say may because I'm using PCRE syntax and I don't know how much of it
PostgreSQL supports.

^(?>\d+)(?>\.\d+)*$

If there is no support for atomic groups you can try this:
^(?:\d++)(?:\.\d++)*$

And if there is no support for greedy quantifiers nor non capturing groups:
^(\d+)(\.\d++)*$

I hoped that helped.

Good luck,

Dane


In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dane Foster 2015-10-30 00:56:25 Re: mysql_fdw trouble
Previous Message Dane Foster 2015-10-30 00:38:49 Re: mysql_fdw trouble