Skip to content

Commit d556126

Browse files
committed
Sync PostgreSQL master commits dfc15bd3286..62d6c7d3df6
Follow upstream commits to update test files and fix bugs. Modified 12 files across oracle_test, contrib/postgres_fdw, and pl_isql directories: - 8d9a97e0bb6 "Avoid name collision with NOT NULL constraints" * src/oracle_test/regress/sql/create_table.sql * src/oracle_test/regress/expected/create_table.out - 6e045e1a6e3 "Fix SUBSTRING() for toasted multibyte characters" * src/oracle_test/regress/sql/encoding.sql * src/oracle_test/regress/expected/encoding.out - ccc9be800dd "Fix test_valid_server_encoding helper function" * src/oracle_test/regress/sql/encoding.sql * src/oracle_test/regress/expected/encoding.out * src/oracle_test/regress/regress.c - ed57c207c39 "Fix computation of varnullingrels when translating appendrel Var" * src/oracle_test/regress/sql/join.sql * src/oracle_test/regress/expected/join.out - 946b653b7ab "Further stabilize a postgres_fdw test case" * contrib/postgres_fdw/sql/ivy_postgres_fdw.sql * contrib/postgres_fdw/expected/ivy_postgres_fdw.out - ce4b7e3a105 "Fix plpgsql's handling of return simple_record_variable" * src/pl/plisql/src/pl_exec.c * src/pl/plisql/src/sql/plisql_domain.sql * src/pl/plisql/src/expected/plisql_domain.out
1 parent c51aa9c commit d556126

12 files changed

Lines changed: 213 additions & 34 deletions

File tree

contrib/postgres_fdw/expected/ivy_postgres_fdw.out

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7595,20 +7595,31 @@ UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END
75957595
ALTER SERVER loopback OPTIONS (DROP extensions);
75967596
INSERT INTO ft2 (c1,c2,c3)
75977597
SELECT id, id % 10, to_char(id, 'FM00000') FROM generate_series(2001, 2010) id;
7598+
-- this will do a remote seqscan, causing unstable result order, so sort
75987599
EXPLAIN (verbose, costs off)
7599-
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *; -- can't be pushed down
7600-
QUERY PLAN
7601-
----------------------------------------------------------------------------------------------------------
7602-
Update on public.ft2
7603-
Output: c1, c2, c3, c4, c5, c6, c7, c8
7604-
Remote SQL: UPDATE "S 1"."T 1" SET c3 = $2 WHERE ctid = $1 RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
7605-
-> Foreign Scan on public.ft2
7606-
Output: 'bar'::varchar2(1024), ctid, ft2.*
7607-
Filter: (postgres_fdw_abs(ft2.c1) > 2000)
7608-
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8, ctid FROM "S 1"."T 1" FOR UPDATE
7609-
(7 rows)
7600+
WITH cte AS (
7601+
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *
7602+
) SELECT * FROM cte ORDER BY c1; -- can't be pushed down
7603+
QUERY PLAN
7604+
------------------------------------------------------------------------------------------------------------------
7605+
Sort
7606+
Output: cte.c1, cte.c2, cte.c3, cte.c4, cte.c5, cte.c6, cte.c7, cte.c8
7607+
Sort Key: cte.c1
7608+
CTE cte
7609+
-> Update on public.ft2
7610+
Output: ft2.c1, ft2.c2, ft2.c3, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8
7611+
Remote SQL: UPDATE "S 1"."T 1" SET c3 = $2 WHERE ctid = $1 RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
7612+
-> Foreign Scan on public.ft2
7613+
Output: 'bar'::varchar2(1024), ft2.ctid, ft2.*
7614+
Filter: (postgres_fdw_abs(ft2.c1) > 2000)
7615+
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8, ctid FROM "S 1"."T 1" FOR UPDATE
7616+
-> CTE Scan on cte
7617+
Output: cte.c1, cte.c2, cte.c3, cte.c4, cte.c5, cte.c6, cte.c7, cte.c8
7618+
(13 rows)
76107619

7611-
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;
7620+
WITH cte AS (
7621+
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *
7622+
) SELECT * FROM cte ORDER BY c1;
76127623
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
76137624
------+----+-----+----+----+----+------------+----
76147625
2001 | 1 | bar | | | | ft2 |

contrib/postgres_fdw/sql/ivy_postgres_fdw.sql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,9 +1677,15 @@ UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END
16771677
ALTER SERVER loopback OPTIONS (DROP extensions);
16781678
INSERT INTO ft2 (c1,c2,c3)
16791679
SELECT id, id % 10, to_char(id, 'FM00000') FROM generate_series(2001, 2010) id;
1680+
1681+
-- this will do a remote seqscan, causing unstable result order, so sort
16801682
EXPLAIN (verbose, costs off)
1681-
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *; -- can't be pushed down
1682-
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;
1683+
WITH cte AS (
1684+
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *
1685+
) SELECT * FROM cte ORDER BY c1; -- can't be pushed down
1686+
WITH cte AS (
1687+
UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *
1688+
) SELECT * FROM cte ORDER BY c1;
16831689
EXPLAIN (verbose, costs off)
16841690
UPDATE ft2 SET c3 = 'baz'
16851691
FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)

src/oracle_test/regress/expected/create_table.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ ALTER TABLE remember_node_subid ALTER c TYPE bigint;
161161
SAVEPOINT q; DROP TABLE remember_node_subid; ROLLBACK TO q;
162162
COMMIT;
163163
DROP TABLE remember_node_subid;
164+
-- generated NOT NULL constraint names must not collide with explicitly named constraints
165+
CREATE TABLE two_not_null_constraints (
166+
col integer NOT NULL,
167+
CONSTRAINT two_not_null_constraints_col_not_null CHECK (col IS NOT NULL)
168+
);
169+
DROP TABLE two_not_null_constraints;
164170
--
165171
-- Partitioned tables
166172
--

src/oracle_test/regress/expected/encoding.out

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ SELECT reverse(good) FROM regress_encoding;
6969
-- invalid short mb character = error
7070
SELECT length(truncated) FROM regress_encoding;
7171
ERROR: invalid byte sequence for encoding "UTF8": 0xc3
72-
SELECT substring(truncated, 1, 1) FROM regress_encoding;
72+
SELECT substring(truncated, 1, 3) FROM regress_encoding;
73+
substring
74+
-----------
75+
caf
76+
(1 row)
77+
78+
SELECT substring(truncated, 1, 4) FROM regress_encoding;
7379
ERROR: invalid byte sequence for encoding "UTF8": 0xc3
7480
SELECT reverse(truncated) FROM regress_encoding;
7581
ERROR: invalid byte sequence for encoding "UTF8": 0xc3
@@ -382,9 +388,47 @@ NOTICE: MULE_INTERNAL LC2: \x908283 -> {9470595} -> \x908283 = OK
382388
t
383389
(1 row)
384390

391+
-- substring fetches a slice of a toasted value; unused tail of that slice is
392+
-- an incomplete char (bug #19406)
393+
CREATE TABLE toast_3b_utf8 (c text);
394+
INSERT INTO toast_3b_utf8 VALUES (repeat(U&'\2026', 4000));
395+
SELECT SUBSTRING(c FROM 1 FOR 1) FROM toast_3b_utf8;
396+
substring
397+
-----------
398+
399+
(1 row)
400+
401+
SELECT SUBSTRING(c FROM 4001 FOR 1) FROM toast_3b_utf8;
402+
substring
403+
-----------
404+
405+
(1 row)
406+
407+
-- diagnose incomplete char iff within the substring
408+
UPDATE toast_3b_utf8 SET c = c || test_bytea_to_text('\xe280');
409+
SELECT SUBSTRING(c FROM 4000 FOR 1) FROM toast_3b_utf8;
410+
substring
411+
-----------
412+
413+
(1 row)
414+
415+
SELECT SUBSTRING(c FROM 4001 FOR 1) FROM toast_3b_utf8;
416+
ERROR: invalid byte sequence for encoding "UTF8": 0xe2 0x80
417+
-- substring needing last byte of its slice_size
418+
ALTER TABLE toast_3b_utf8 RENAME TO toast_4b_utf8;
419+
UPDATE toast_4b_utf8 SET c = repeat(U&'\+01F680', 3000);
420+
SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8;
421+
substring
422+
-----------
423+
🚀
424+
(1 row)
425+
385426
DROP TABLE encoding_tests;
427+
DROP TABLE toast_4b_utf8;
386428
DROP FUNCTION test_encoding;
429+
DROP FUNCTION test_wchars_to_text;
387430
DROP FUNCTION test_text_to_wchars;
431+
DROP FUNCTION test_valid_server_encoding;
388432
DROP FUNCTION test_mblen_func;
389433
DROP FUNCTION test_bytea_to_text;
390434
DROP FUNCTION test_text_to_bytea;

src/oracle_test/regress/expected/join.out

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,57 @@ where ss.x is null;
44154415
Output: 'bar'::text
44164416
(12 rows)
44174417

4418+
-- Test computation of varnullingrels when translating appendrel Var
4419+
begin;
4420+
create temp table t_append (a int not null, b int);
4421+
insert into t_append values (1, 1);
4422+
insert into t_append values (2, 3);
4423+
explain (verbose, costs off)
4424+
select t1.a, s.a from t_append t1
4425+
left join t_append t2 on t1.a = t2.b
4426+
join lateral (
4427+
select t1.a as a union all select t2.a as a
4428+
) s on true
4429+
where s.a is not null;
4430+
QUERY PLAN
4431+
---------------------------------------------------
4432+
Nested Loop
4433+
Output: t1.a, (t1.a)
4434+
-> Merge Left Join
4435+
Output: t1.a, t2.a
4436+
Merge Cond: (t1.a = t2.b)
4437+
-> Sort
4438+
Output: t1.a
4439+
Sort Key: t1.a
4440+
-> Seq Scan on pg_temp.t_append t1
4441+
Output: t1.a
4442+
-> Sort
4443+
Output: t2.a, t2.b
4444+
Sort Key: t2.b
4445+
-> Seq Scan on pg_temp.t_append t2
4446+
Output: t2.a, t2.b
4447+
-> Append
4448+
-> Result
4449+
Output: t1.a
4450+
-> Result
4451+
Output: t2.a
4452+
One-Time Filter: (t2.a IS NOT NULL)
4453+
(21 rows)
4454+
4455+
select t1.a, s.a from t_append t1
4456+
left join t_append t2 on t1.a = t2.b
4457+
join lateral (
4458+
select t1.a as a union all select t2.a as a
4459+
) s on true
4460+
where s.a is not null;
4461+
a | a
4462+
---+---
4463+
1 | 1
4464+
1 | 1
4465+
2 | 2
4466+
(3 rows)
4467+
4468+
rollback;
44184469
--
44194470
-- test inlining of immutable functions
44204471
--

src/oracle_test/regress/regress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ PG_FUNCTION_INFO_V1(test_valid_server_encoding);
11271127
Datum
11281128
test_valid_server_encoding(PG_FUNCTION_ARGS)
11291129
{
1130-
return pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0)));
1130+
PG_RETURN_BOOL(pg_valid_server_encoding(text_to_cstring(PG_GETARG_TEXT_PP(0))) >= 0);
11311131
}
11321132

11331133
/* Provide SQL access to IsBinaryCoercible() */

src/oracle_test/regress/sql/create_table.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ SAVEPOINT q; DROP TABLE remember_node_subid; ROLLBACK TO q;
105105
COMMIT;
106106
DROP TABLE remember_node_subid;
107107

108+
-- generated NOT NULL constraint names must not collide with explicitly named constraints
109+
CREATE TABLE two_not_null_constraints (
110+
col integer NOT NULL,
111+
CONSTRAINT two_not_null_constraints_col_not_null CHECK (col IS NOT NULL)
112+
);
113+
DROP TABLE two_not_null_constraints;
114+
108115
--
109116
-- Partitioned tables
110117
--

src/oracle_test/regress/sql/encoding.sql

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ SELECT reverse(good) FROM regress_encoding;
4646

4747
-- invalid short mb character = error
4848
SELECT length(truncated) FROM regress_encoding;
49-
SELECT substring(truncated, 1, 1) FROM regress_encoding;
49+
SELECT substring(truncated, 1, 3) FROM regress_encoding;
50+
SELECT substring(truncated, 1, 4) FROM regress_encoding;
5051
SELECT reverse(truncated) FROM regress_encoding;
5152
-- invalid short mb character = silently dropped
5253
SELECT regexp_replace(truncated, '^caf(.)$', '\1') FROM regress_encoding;
@@ -219,9 +220,27 @@ INSERT INTO encoding_tests VALUES
219220
SELECT COUNT(test_encoding(encoding, description, input)) > 0
220221
FROM encoding_tests;
221222

223+
-- substring fetches a slice of a toasted value; unused tail of that slice is
224+
-- an incomplete char (bug #19406)
225+
CREATE TABLE toast_3b_utf8 (c text);
226+
INSERT INTO toast_3b_utf8 VALUES (repeat(U&'\2026', 4000));
227+
SELECT SUBSTRING(c FROM 1 FOR 1) FROM toast_3b_utf8;
228+
SELECT SUBSTRING(c FROM 4001 FOR 1) FROM toast_3b_utf8;
229+
-- diagnose incomplete char iff within the substring
230+
UPDATE toast_3b_utf8 SET c = c || test_bytea_to_text('\xe280');
231+
SELECT SUBSTRING(c FROM 4000 FOR 1) FROM toast_3b_utf8;
232+
SELECT SUBSTRING(c FROM 4001 FOR 1) FROM toast_3b_utf8;
233+
-- substring needing last byte of its slice_size
234+
ALTER TABLE toast_3b_utf8 RENAME TO toast_4b_utf8;
235+
UPDATE toast_4b_utf8 SET c = repeat(U&'\+01F680', 3000);
236+
SELECT SUBSTRING(c FROM 3000 FOR 1) FROM toast_4b_utf8;
237+
222238
DROP TABLE encoding_tests;
239+
DROP TABLE toast_4b_utf8;
223240
DROP FUNCTION test_encoding;
241+
DROP FUNCTION test_wchars_to_text;
224242
DROP FUNCTION test_text_to_wchars;
243+
DROP FUNCTION test_valid_server_encoding;
225244
DROP FUNCTION test_mblen_func;
226245
DROP FUNCTION test_bytea_to_text;
227246
DROP FUNCTION test_text_to_bytea;

src/oracle_test/regress/sql/join.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,30 @@ select * from int4_tbl left join (
14831483
) ss(x) on true
14841484
where ss.x is null;
14851485

1486+
-- Test computation of varnullingrels when translating appendrel Var
1487+
begin;
1488+
1489+
create temp table t_append (a int not null, b int);
1490+
insert into t_append values (1, 1);
1491+
insert into t_append values (2, 3);
1492+
1493+
explain (verbose, costs off)
1494+
select t1.a, s.a from t_append t1
1495+
left join t_append t2 on t1.a = t2.b
1496+
join lateral (
1497+
select t1.a as a union all select t2.a as a
1498+
) s on true
1499+
where s.a is not null;
1500+
1501+
select t1.a, s.a from t_append t1
1502+
left join t_append t2 on t1.a = t2.b
1503+
join lateral (
1504+
select t1.a as a union all select t2.a as a
1505+
) s on true
1506+
where s.a is not null;
1507+
1508+
rollback;
1509+
14861510
--
14871511
-- test inlining of immutable functions
14881512
--

src/pl/plisql/src/expected/plisql_domain.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,17 @@ SELECT * FROM test_assign_ordered_named_pairs(1,2,0); -- should fail someday
417417
{"(1,2)"}
418418
(1 row)
419419

420+
CREATE FUNCTION test_null_ordered_named_pair()
421+
RETURNS ordered_named_pair AS $$
422+
declare v ordered_named_pair;
423+
begin
424+
return v;
425+
end
426+
$$ LANGUAGE plisql;
427+
/
428+
SELECT * FROM test_null_ordered_named_pair();
429+
i | j
430+
---+---
431+
|
432+
(1 row)
433+

0 commit comments

Comments
 (0)