> I found out that regexp when use in H2 mysql compatibility mode is
> case sensitive whereas it is not in mysql. Is this the expected
> behavior?
Yes, it is expected. H2 is not 100% compatible to all other databases
- if it would, then it would be 100 times larger I guess. H2 just
tries to be compatible where possible and where it makes sense.
> I also realize that H2 mysql mode does not recognize the
> RLIKE token is this also an expected behaviour?
Yes it is expected.
Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
I just found out all comparisons in MySQL are case insensitive. H2
also supports this mode (using "set ignorecase true"), however you
need to set it before creating any tables. I will document this.
Example:
drop table test;
set ignorecase true;
create table test(name varchar(255));
insert into test values('Hello');
select * from test where name like 'hello';
select * from test where name = 'hello';
select * from test where name regexp 'hello';
Regards,
Thomas
I will document:
Text comparison in MySQL is case insensitive by default, while in H2
it is case sensitive (as in most other databases). H2 does support
case insensitive text comparison, but it needs to be set separately,
using SET IGNORECASE TRUE. This affects comparison using =, LIKE,
REGEXP.
Regards,
Thomas
Hi,I just found out all comparisons in MySQL are case insensitive.
> May I suggest that case insensitivity be automatically set when MySQL
> mode is being used in H2 instead of doing it explicitly this would
> make H2's MySQL mode better matches the actual behavior of MySQL.
That's an option, but it would mean you can't enable the MySQL mode if
there are already tables in the database (see the SET IGNORECASE
documenation).
Instead, I will improve the documentation.
> am using hibernate 3.6 to generate all the tables, any tip how do I
> add the SET IGNORECASE TRUE in hibernate?
Yes, you could add it to the database URL:
jdbc:h2:~/test;MODE=MySQL;IGNORECASE=TRUE
Regards,
Thomas
IGNORECASE=TRUE ist no applied to already existing tables, you have to
recreate your table for it to work
g
Dario
The setting makes all column in new tables 'varchar_ignorecase'. Example:
create table test(id int, name varchar);
insert into test values(1, 'HelloWorld');
select * from test where name regexp 'HELLOWORLD';
However, the setting doesn't apply to text literals itself, so 'Hello'
in a literal isn't 'ignorecase'. I guess you could say it's a bug... I
will check if there are any side effects if I change the behavior.
Regards,
Thomas
On Tue, May 31, 2011 at 5:54 PM, chungonn <chun...@gmail.com> wrote:
After running a few tests, I decided not to change the behavior
currently. Instead, I will document the current behavior:
String literals and parameters are still considered case sensitive
even if the IGNORECASE option is set.
The main reason is that the database would behave differently when
using parameters versus using literals.
Regards,
Thomas