mirror of
https://github.com/MariaDB/server.git
synced 2025-04-18 21:44:20 +03:00
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.
27 lines
738 B
Plaintext
27 lines
738 B
Plaintext
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;
|