Re: BUG #17352: Column CHECK regex error

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: BUG #17352: Column CHECK regex error
Дата
Msg-id 7b75d6b6-f44e-6380-19cf-35736666e24b@postgresfriends.org
обсуждение исходный текст
Ответ на BUG #17352: Column CHECK regex error  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
On 1/3/22 11:38 AM, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      17352
> Logged by:          Serge Salamatin
> Email address:      salamsp@gmail.com
> PostgreSQL version: 13.5
> Operating system:   Ubuntu 13.5-2.pgdg20.04+1
> Description:        
> 
> select '01' ~ '^[\d-]{2,8}$'  -> true, 
> 
> but in next
> 
> CREATE TABLE IF NOT EXISTS public.mnu
> (
>     mnunm character(10) COLLATE pg_catalog."default" NOT NULL,
>     code character(8) COLLATE pg_catalog."default" NOT NULL
>       CONSTRAINT "Only digits" CHECK (code ~ '^[\d-]{2,8}$'),

The bug here is that you are using the character(n) type, which you
shouldn't.  That type has archaic (but standard) behavior that pads the
value with spaces.  Your regex does not account for that.

Don't use that type.  Use text instead.

https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_char.28n.29

-- 
Vik Fearing



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Francisco Olarte
Дата:
Сообщение: Re: BUG #17352: Column CHECK regex error
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Re: BUG #17344: Assert failed on queiring async_capable foreign table with inheritance