Commit 52bb4efc authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

regexp worked only with the default character set.

Now it can work with any character set.
parent efd94f5b
...@@ -52,3 +52,27 @@ select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [ ...@@ -52,3 +52,27 @@ select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [
xxx xxx
this is some text: to test - out.reg exp (22/45) this is some text: to test - out.reg exp (22/45)
drop table t1; drop table t1;
select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin
1
select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin
0
select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin
0
select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin
1
select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
_latin1 0xF7 regexp _latin1 '[[:alpha:]]'
0
select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
_koi8r 0xF7 regexp _koi8r '[[:alpha:]]'
1
select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
_latin1'a' regexp _latin1'A' collate latin1_general_ci
1
select _latin1'a' regexp _latin1'A' collate latin1_bin;
_latin1'a' regexp _latin1'A' collate latin1_bin
0
...@@ -45,3 +45,17 @@ create table t1 (xxx char(128)); ...@@ -45,3 +45,17 @@ create table t1 (xxx char(128));
insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)'); insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)');
select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$'; select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$';
drop table t1; drop table t1;
#
# Check with different character sets and collations
#
select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
select _latin1'a' regexp _latin1'A' collate latin1_bin;
...@@ -18,4 +18,5 @@ extern struct cclass { ...@@ -18,4 +18,5 @@ extern struct cclass {
const char *name; const char *name;
const char *chars; const char *chars;
const char *multis; const char *multis;
uint mask;
} cclasses[]; } cclasses[];
...@@ -36,19 +36,19 @@ struct parse { ...@@ -36,19 +36,19 @@ struct parse {
static char nuls[10]; /* place to point scanner in event of error */ static char nuls[10]; /* place to point scanner in event of error */
struct cclass cclasses[CCLASS_LAST+1]= { struct cclass cclasses[CCLASS_LAST+1]= {
{ "alnum", "","" }, { "alnum", "","", _U | _L | _NMR},
{ "alpha", "","" }, { "alpha", "","", _U | _L },
{ "blank", "","" }, { "blank", "","", _B },
{ "cntrl", "","" }, { "cntrl", "","", _CTR },
{ "digit", "","" }, { "digit", "","", _NMR },
{ "graph", "","" }, { "graph", "","", _PNT | _U | _L | _NMR},
{ "lower", "","" }, { "lower", "","", _L },
{ "print", "","" }, { "print", "","", _PNT | _U | _L | _NMR | _B },
{ "punct", "","" }, { "punct", "","", _PNT },
{ "space", "","" }, { "space", "","", _SPC },
{ "upper", "","" }, { "upper", "","", _U },
{ "xdigit", "","" }, { "xdigit", "","", _X },
{ NULL,NULL,NULL } { NULL,NULL,NULL, 0 }
}; };
/* /*
...@@ -747,9 +747,7 @@ register cset *cs; ...@@ -747,9 +747,7 @@ register cset *cs;
register char *sp = p->next; register char *sp = p->next;
register struct cclass *cp; register struct cclass *cp;
register size_t len; register size_t len;
register char *u;
register char c;
while (MORE() && my_isalpha(p->charset,PEEK())) while (MORE() && my_isalpha(p->charset,PEEK()))
NEXT(); NEXT();
len = p->next - sp; len = p->next - sp;
...@@ -762,11 +760,26 @@ register cset *cs; ...@@ -762,11 +760,26 @@ register cset *cs;
return; return;
} }
u = (char*) cp->chars; #ifndef USE_ORIG_REGEX_CODE
while ((c = *u++) != '\0') {
CHadd(cs, c); register size_t i;
for (u = (char*) cp->multis; *u != '\0'; u += strlen(u) + 1) for (i=1 ; i<256 ; i++)
MCadd(p, cs, u); if (p->charset->ctype[i+1] & cp->mask)
CHadd(cs, i);
}
#else
{
register char *u = (char*) cp->chars;
register char c;
while ((c = *u++) != '\0')
CHadd(cs, c);
for (u = (char*) cp->multis; *u != '\0'; u += strlen(u) + 1)
MCadd(p, cs, u);
}
#endif
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment