mirror of https://github.com/postgres/postgres
This change allows these functions to be called using named-argument notation, which can be helpful for readability, particularly for the ones with many arguments. There was considerable debate about exactly which names to use, but in the end we settled on the names already shown in our documentation table 9.10. The citext extension provides citext-aware versions of some of these functions, so add argument names to those too. In passing, fix table 9.10's syntax synopses for regexp_match, which were slightly wrong about which combinations of arguments are allowed. Jian He, reviewed by Dian Fay and others Discussion: https://postgr.es/m/CACJufxG3NFKKsh6x4fRLv8h3V-HvN4W5dA=zNKMxsNcDwOKang@mail.gmail.compull/170/head
parent
05faf06e9c
commit
580f8727ca
@ -0,0 +1,45 @@ |
||||
/* contrib/citext/citext--1.6--1.7.sql */ |
||||
|
||||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION |
||||
\echo Use "ALTER EXTENSION citext UPDATE TO '1.7'" to load this file. \quit |
||||
|
||||
-- add function argument names |
||||
CREATE OR REPLACE FUNCTION regexp_match(string citext, pattern citext) RETURNS TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_match( $1::pg_catalog.text, $2::pg_catalog.text, 'i' ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_match(string citext, pattern citext, flags text) RETURNS TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_match( $1::pg_catalog.text, $2::pg_catalog.text, CASE WHEN pg_catalog.strpos($3, 'c') = 0 THEN $3 || 'i' ELSE $3 END ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_matches(string citext, pattern citext) RETURNS SETOF TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_matches( $1::pg_catalog.text, $2::pg_catalog.text, 'i' ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE ROWS 1; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_matches(string citext, pattern citext, flags text) RETURNS SETOF TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_matches( $1::pg_catalog.text, $2::pg_catalog.text, CASE WHEN pg_catalog.strpos($3, 'c') = 0 THEN $3 || 'i' ELSE $3 END ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE ROWS 10; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_replace(string citext, pattern citext, replacement text) returns TEXT AS $$ |
||||
SELECT pg_catalog.regexp_replace( $1::pg_catalog.text, $2::pg_catalog.text, $3, 'i'); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_replace(string citext, pattern citext, replacement text, flags text) returns TEXT AS $$ |
||||
SELECT pg_catalog.regexp_replace( $1::pg_catalog.text, $2::pg_catalog.text, $3, CASE WHEN pg_catalog.strpos($4, 'c') = 0 THEN $4 || 'i' ELSE $4 END); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_split_to_array(string citext, pattern citext) RETURNS TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_split_to_array( $1::pg_catalog.text, $2::pg_catalog.text, 'i' ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_split_to_array(string citext, pattern citext, flags text) RETURNS TEXT[] AS $$ |
||||
SELECT pg_catalog.regexp_split_to_array( $1::pg_catalog.text, $2::pg_catalog.text, CASE WHEN pg_catalog.strpos($3, 'c') = 0 THEN $3 || 'i' ELSE $3 END ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_split_to_table(string citext, pattern citext) RETURNS SETOF TEXT AS $$ |
||||
SELECT pg_catalog.regexp_split_to_table( $1::pg_catalog.text, $2::pg_catalog.text, 'i' ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
||||
|
||||
CREATE OR REPLACE FUNCTION regexp_split_to_table(string citext, pattern citext, flags text) RETURNS SETOF TEXT AS $$ |
||||
SELECT pg_catalog.regexp_split_to_table( $1::pg_catalog.text, $2::pg_catalog.text, CASE WHEN pg_catalog.strpos($3, 'c') = 0 THEN $3 || 'i' ELSE $3 END ); |
||||
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE; |
@ -1,6 +1,6 @@ |
||||
# citext extension |
||||
comment = 'data type for case-insensitive character strings' |
||||
default_version = '1.6' |
||||
default_version = '1.7' |
||||
module_pathname = '$libdir/citext' |
||||
relocatable = true |
||||
trusted = true |
||||
|
Loading…
Reference in new issue