From c1cc1102815ef83114efbaff0117a18b23a473f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=8C=83?= Date: Mon, 28 Sep 2020 09:59:41 +0800 Subject: [PATCH v1] Mark some formating builtin function as immutable. Immutable function usually has more chances for optimization. --- src/include/catalog/pg_proc.dat | 22 +++++++++---------- src/test/regress/expected/partition_prune.out | 15 +++++-------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index f48f5fb4d9..face1fc6b1 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4432,34 +4432,34 @@ # formatting { oid => '1770', descr => 'format timestamp with time zone to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'timestamptz text', prosrc => 'timestamptz_to_char' }, { oid => '1772', descr => 'format numeric to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'numeric text', prosrc => 'numeric_to_char' }, { oid => '1773', descr => 'format int4 to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'int4 text', prosrc => 'int4_to_char' }, { oid => '1774', descr => 'format int8 to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'int8 text', prosrc => 'int8_to_char' }, { oid => '1775', descr => 'format float4 to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'float4 text', prosrc => 'float4_to_char' }, { oid => '1776', descr => 'format float8 to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'float8 text', prosrc => 'float8_to_char' }, { oid => '1777', descr => 'convert text to numeric', - proname => 'to_number', provolatile => 's', prorettype => 'numeric', + proname => 'to_number', provolatile => 'i', prorettype => 'numeric', proargtypes => 'text text', prosrc => 'numeric_to_number' }, { oid => '1778', descr => 'convert text to timestamp with time zone', - proname => 'to_timestamp', provolatile => 's', prorettype => 'timestamptz', + proname => 'to_timestamp', provolatile => 'i', prorettype => 'timestamptz', proargtypes => 'text text', prosrc => 'to_timestamp' }, { oid => '1780', descr => 'convert text to date', - proname => 'to_date', provolatile => 's', prorettype => 'date', + proname => 'to_date', provolatile => 'i', prorettype => 'date', proargtypes => 'text text', prosrc => 'to_date' }, { oid => '1768', descr => 'format interval to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'interval text', prosrc => 'interval_to_char' }, { oid => '1282', descr => 'quote an identifier for usage in a querystring', @@ -5825,7 +5825,7 @@ proname => 'isfinite', prorettype => 'bool', proargtypes => 'timestamp', prosrc => 'timestamp_finite' }, { oid => '2049', descr => 'format timestamp to text', - proname => 'to_char', provolatile => 's', prorettype => 'text', + proname => 'to_char', provolatile => 'i', prorettype => 'text', proargtypes => 'timestamp text', prosrc => 'timestamp_to_char' }, { oid => '2052', proname => 'timestamp_eq', proleakproof => 't', prorettype => 'bool', diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index 50d2a7e4b9..8753edd4fe 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -1129,16 +1129,11 @@ create table coercepart_ab partition of coercepart for values in ('ab'); create table coercepart_bc partition of coercepart for values in ('bc'); create table coercepart_cd partition of coercepart for values in ('cd'); explain (costs off) select * from coercepart where a in ('ab', to_char(125, '999')); - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- - Append - -> Seq Scan on coercepart_ab coercepart_1 - Filter: ((a)::text = ANY ((ARRAY['ab'::character varying, (to_char(125, '999'::text))::character varying])::text[])) - -> Seq Scan on coercepart_bc coercepart_2 - Filter: ((a)::text = ANY ((ARRAY['ab'::character varying, (to_char(125, '999'::text))::character varying])::text[])) - -> Seq Scan on coercepart_cd coercepart_3 - Filter: ((a)::text = ANY ((ARRAY['ab'::character varying, (to_char(125, '999'::text))::character varying])::text[])) -(7 rows) + QUERY PLAN +----------------------------------------------------- + Seq Scan on coercepart_ab coercepart + Filter: ((a)::text = ANY ('{ab," 125"}'::text[])) +(2 rows) explain (costs off) select * from coercepart where a ~ any ('{ab}'); QUERY PLAN -- 2.21.0