mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode
Turning REGEXP_REPLACE into two schema-qualified functions: - mariadb_schema.regexp_replace() - oracle_schema.regexp_replace() Fixing oracle_schema.regexp_replace(subj,pattern,replacement) to treat NULL in "replacement" as an empty string. Adding new classes implementing oracle_schema.regexp_replace(): - Item_func_regexp_replace_oracle - Create_func_regexp_replace_oracle Adding helper methods: - String *Item::val_str_null_to_empty(String *to) - String *Item::val_str_null_to_empty(String *to, bool null_to_empty) and reusing these methods in both Item_func_replace and Item_func_regexp_replace.
This commit is contained in:
26
mysql-test/suite/compat/oracle/t/func_regexp_replace.test
Normal file
26
mysql-test/suite/compat/oracle/t/func_regexp_replace.test
Normal file
@ -0,0 +1,26 @@
|
||||
SET sql_mode=ORACLE;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode
|
||||
--echo #
|
||||
|
||||
#SELECT REGEXP_REPLACE(null,'a','b') ;
|
||||
#SELECT REGEXP_REPLACE('ab',null,'b') ;
|
||||
#SELECT REGEXP_REPLACE('ab','a',null) ;
|
||||
#SELECT REGEXP_REPLACE('ab',null,null) ;
|
||||
|
||||
CREATE TABLE t1 (replacement VARCHAR(10));
|
||||
INSERT INTO t1 VALUES (NULL), ('');
|
||||
SELECT replacement, REGEXP_REPLACE('abba','a',replacement) FROM t1 ORDER BY replacement;
|
||||
DROP TABLE t1;
|
||||
|
||||
SELECT REGEXP_REPLACE('abba','a',null);
|
||||
EXPLAIN EXTENDED SELECT REPLACE('abba','a',null) ;
|
||||
|
||||
CREATE VIEW v1 AS SELECT REPLACE('abba','a',null) ;
|
||||
SHOW CREATE VIEW v1;
|
||||
SELECT * FROM v1;
|
||||
SET sql_mode=DEFAULT;
|
||||
SHOW CREATE VIEW v1;
|
||||
SELECT * FROM v1;
|
||||
DROP VIEW v1;
|
Reference in New Issue
Block a user