BUG #17352: Column CHECK regex error

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: salamsp(at)gmail(dot)com
Subject: BUG #17352: Column CHECK regex error
Date: 2022-01-03 10:38:48
Message-ID: 17352-7564a4d9c118056d@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17352
Logged by: Serge Salamatin
Email address: salamsp(at)gmail(dot)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}$'),
txt citext COLLATE pg_catalog."default" NOT NULL,
ui_id bigint,
action citext COLLATE pg_catalog."default",
tip citext COLLATE pg_catalog."default",
CONSTRAINT mnu_pkey PRIMARY KEY (mnunm, code, txt)
);

INSERT INTO public.mnu (
mnunm , code , txt , ui_id , action , tip
)
OVERRIDING USER VALUE VALUES(
'p977main' , '01' , 'Tables def' , DEFAULT , '' , ''
);

returns ->

"ERROR: new row for relation "mnu" violates check constraint "Only
digits"
DETAIL: Failing row contains (p977main , 01 , Tables def, null, ,
).
SQL state: 23514"

If we drop CONSTRAINT "Only digits" that insert will be done properly.
If we change column into character varying(8) and left CONSTRAINT "Only
digits"
that insert will be done without error.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Francisco Olarte 2022-01-03 11:11:16 Re: BUG #17352: Column CHECK regex error
Previous Message Alexander Lakhin 2022-01-02 19:00:00 Re: BUG #17344: Assert failed on queiring async_capable foreign table with inheritance