mirror of
https://github.com/MariaDB/server.git
synced 2025-04-26 11:49:09 +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.
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
SET sql_mode=ORACLE;
|
|
#
|
|
# MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode
|
|
#
|
|
CREATE TABLE t1 (replacement VARCHAR(10));
|
|
INSERT INTO t1 VALUES (NULL), ('');
|
|
SELECT replacement, REGEXP_REPLACE('abba','a',replacement) FROM t1 ORDER BY replacement;
|
|
replacement REGEXP_REPLACE('abba','a',replacement)
|
|
NULL bb
|
|
bb
|
|
DROP TABLE t1;
|
|
SELECT REGEXP_REPLACE('abba','a',null);
|
|
REGEXP_REPLACE('abba','a',null)
|
|
bb
|
|
EXPLAIN EXTENDED SELECT REPLACE('abba','a',null) ;
|
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
|
Warnings:
|
|
Note 1003 select replace('abba','a',NULL) AS "REPLACE('abba','a',null)"
|
|
CREATE VIEW v1 AS SELECT REPLACE('abba','a',null) ;
|
|
SHOW CREATE VIEW v1;
|
|
View Create View character_set_client collation_connection
|
|
v1 CREATE VIEW "v1" AS select replace('abba','a',NULL) AS "REPLACE('abba','a',null)" latin1 latin1_swedish_ci
|
|
SELECT * FROM v1;
|
|
REPLACE('abba','a',null)
|
|
bb
|
|
SET sql_mode=DEFAULT;
|
|
SHOW CREATE VIEW v1;
|
|
View Create View character_set_client collation_connection
|
|
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select oracle_schema.replace('abba','a',NULL) AS `REPLACE('abba','a',null)` latin1 latin1_swedish_ci
|
|
SELECT * FROM v1;
|
|
REPLACE('abba','a',null)
|
|
bb
|
|
DROP VIEW v1;
|