Search code examples
viewmariadbsimplification

How to prevent MariaDB from simplfiying logical expressions


I'm having a very weird problem with MariaDB 10, it simplify automaticaly some logical expression !! here's an example

    CREATE VIEW test AS
  SELECT 1
  FROM test_table
  WHERE NOT (1 < 2 OR 3 > 4);

SHOW CREATE VIEW test;

CREATE ALGORITHM = UNDEFINED
  DEFINER =`root`@`localhost`
  SQL SECURITY DEFINER VIEW `test` AS
  SELECT 1 AS `1`
  FROM `test_table`
  WHERE ((1 >= 2) AND (3 <= 4))

as you see it has transformed the expression NOT (1 < 2 OR 3 > 4) to ((1 >= 2) AND (3 <= 4)) because it's not correct in intervals cases


Solution

  • MariaDB applied one of the http://en.wikipedia.org/wiki/De_Morgan%27s_laws . Why do you think it is not correct?