... - Mailing list pgsql-bugs

From Alexei A.Romanenko
Subject ...
Date
Msg-id Pine.SGI.4.10.10006281142370.188925-100000@Sky.inp.nsk.su
Whole thread Raw
Responses Re:  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Your name               : Alexei A. Romanenko
Your email address      : A.A.Romanenko@inp.nsk.su


System Configuration
---------------------
  Architecture (example: Intel Pentium)         : Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.12 ELF

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.2

  Compiler used (example:  gcc 2.8.0)           :


Please enter a FULL description of your problem:
------------------------------------------------
It seems to me there is a problem with regular expressions.
When i create table and try to insert some restriction for
a fields, system accept it. Then, whem i insert something, which
dont match to regexp, it inserted anyway or backwards.

Maybe i am do something wrong, but...


Please describe a way to repeat the problem.   Please try to
provide a concise reproducible example, if at all possible:
----------------------------------------------------------------------
arom> psql
1.
arom=> create table vv (v char(10) CHECK (v ~*
'^[a-z]+\@[a-z]+'));
CREATE
arom=> INSERT INTO vv VALUES ('aq@wwww');
INSERT 19863 1
arom=> INSERT INTO vv VALUES (' aq@wwww');
ERROR:  ExecAppend: rejected due to CHECK constraint vv_v
arom=> INSERT INTO vv VALUES ('aq@2wwww');
ERROR:  ExecAppend: rejected due to CHECK constraint vv_v
arom=> INSERT INTO vv VALUES ('aq@wwww        ');
INSERT 19864 1
arom=> drop table vv;
DROP
arom=> create table vv (v char(10) CHECK (v ~* '^[a-z]+$'));
CREATE
arom=> INSERT INTO vv VALUES ('aq');
ERROR:  ExecAppend: rejected due to CHECK constraint vv_v

In POSIX standart symbol '$' means END OF LINE. Right?

2.

arom=> create table vv (v char(10) CHECK (v ~* '[:alnum:]+'));
CREATE
arom=> INSERT INTO vv VALUES ('12345');
ERROR:  ExecAppend: rejected due to CHECK constraint vv_v
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
arom=> INSERT INTO vv VALUES ('abcd');
INSERT 19895 1
arom=> INSERT INTO vv VALUES ('123abcd');
INSERT 19896 1
arom=> drop table vv;
DROP

[:alnum:] means [:alpha:] and [:digit:].
But [a-z0-9] works correct

If you know how this problem might be fixed, list the solution
below:
---------------------------------------------------------------------

pgsql-bugs by date:

Previous
From: Sergei Laskavy
Date:
Subject: compilation of PostgreSQL 7.0.2 fails on Sun Solaris 2.5.1 using gcc 2.95.2 in interfaces/libpq++ if GNU ld is first in the $PATH
Next
From: Tom Lane
Date:
Subject: Re: \d* won't work in 7.0.2?