-- Setup
CREATE TABLE t (c) AS
SELECT n::varchar(8) FROM generate_series(1,10000000) gen(n);

-- 1 call to varchar_exemptor(); skips 600,000,000 calls to varchar()
-- 226.8s master, 166.6s patched
SELECT count(c::varchar(9)) FROM (
	SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
	UNION ALL SELECT c FROM t
) t_all;
