Skip to content

Commit 8725bd1

Browse files
authored
Merge pull request #147 from postgres/master
Sync Fork from Upstream Repo
2 parents 185441f + fe06819 commit 8725bd1

File tree

342 files changed

+27871
-16739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+27871
-16739
lines changed

contrib/amcheck/expected/check_btree.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ SELECT bt_index_parent_check('bttest_b_idx');
9797
SELECT * FROM pg_locks
9898
WHERE relation = ANY(ARRAY['bttest_a', 'bttest_a_idx', 'bttest_b', 'bttest_b_idx']::regclass[])
9999
AND pid = pg_backend_pid();
100-
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
101-
----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-----+------+---------+----------
100+
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath | waitstart
101+
----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-----+------+---------+----------+-----------
102102
(0 rows)
103103

104104
COMMIT;

contrib/amcheck/verify_nbtree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
535535
if (metad->btm_fastroot != metad->btm_root)
536536
ereport(DEBUG1,
537537
(errcode(ERRCODE_NO_DATA),
538-
errmsg("harmless fast root mismatch in index %s",
538+
errmsg_internal("harmless fast root mismatch in index %s",
539539
RelationGetRelationName(rel)),
540540
errdetail_internal("Fast root block %u (level %u) differs from true root block %u (level %u).",
541541
metad->btm_fastroot, metad->btm_fastlevel,
@@ -721,7 +721,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
721721
else
722722
ereport(DEBUG1,
723723
(errcode(ERRCODE_NO_DATA),
724-
errmsg("block %u of index \"%s\" ignored",
724+
errmsg_internal("block %u of index \"%s\" ignored",
725725
current, RelationGetRelationName(state->rel))));
726726
goto nextpage;
727727
}
@@ -979,7 +979,7 @@ bt_recheck_sibling_links(BtreeCheckState *state,
979979
/* Report split in left sibling, not target (or new target) */
980980
ereport(DEBUG1,
981981
(errcode(ERRCODE_INTERNAL_ERROR),
982-
errmsg("harmless concurrent page split detected in index \"%s\"",
982+
errmsg_internal("harmless concurrent page split detected in index \"%s\"",
983983
RelationGetRelationName(state->rel)),
984984
errdetail_internal("Block=%u new right sibling=%u original right sibling=%u.",
985985
leftcurrent, newtargetblock,
@@ -1605,7 +1605,7 @@ bt_right_page_check_scankey(BtreeCheckState *state)
16051605
targetnext = opaque->btpo_next;
16061606
ereport(DEBUG1,
16071607
(errcode(ERRCODE_NO_DATA),
1608-
errmsg("level %u leftmost page of index \"%s\" was found deleted or half dead",
1608+
errmsg_internal("level %u leftmost page of index \"%s\" was found deleted or half dead",
16091609
opaque->btpo.level, RelationGetRelationName(state->rel)),
16101610
errdetail_internal("Deleted page found when building scankey from right sibling.")));
16111611

@@ -1733,7 +1733,7 @@ bt_right_page_check_scankey(BtreeCheckState *state)
17331733
*/
17341734
ereport(DEBUG1,
17351735
(errcode(ERRCODE_NO_DATA),
1736-
errmsg("%s block %u of index \"%s\" has no first data item",
1736+
errmsg_internal("%s block %u of index \"%s\" has no first data item",
17371737
P_ISLEAF(opaque) ? "leaf" : "internal", targetnext,
17381738
RelationGetRelationName(state->rel))));
17391739
return NULL;
@@ -2287,7 +2287,7 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit,
22872287
{
22882288
ereport(DEBUG1,
22892289
(errcode(ERRCODE_NO_DATA),
2290-
errmsg("harmless interrupted page split detected in index %s",
2290+
errmsg_internal("harmless interrupted page split detected in index %s",
22912291
RelationGetRelationName(state->rel)),
22922292
errdetail_internal("Block=%u level=%u left sibling=%u page lsn=%X/%X.",
22932293
blkno, opaque->btpo.level,

contrib/pageinspect/expected/gist.out

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2));
3131

3232
COMMIT;
3333
SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx');
34-
itemoffset | ctid | itemlen | keys
35-
------------+-----------+---------+-------------------
36-
1 | (1,65535) | 40 | (p)=((166,166))
37-
2 | (2,65535) | 40 | (p)=((332,332))
38-
3 | (3,65535) | 40 | (p)=((498,498))
39-
4 | (4,65535) | 40 | (p)=((664,664))
40-
5 | (5,65535) | 40 | (p)=((830,830))
41-
6 | (6,65535) | 40 | (p)=((996,996))
42-
7 | (7,65535) | 40 | (p)=((1000,1000))
34+
itemoffset | ctid | itemlen | dead | keys
35+
------------+-----------+---------+------+-------------------
36+
1 | (1,65535) | 40 | f | (p)=((166,166))
37+
2 | (2,65535) | 40 | f | (p)=((332,332))
38+
3 | (3,65535) | 40 | f | (p)=((498,498))
39+
4 | (4,65535) | 40 | f | (p)=((664,664))
40+
5 | (5,65535) | 40 | f | (p)=((830,830))
41+
6 | (6,65535) | 40 | f | (p)=((996,996))
42+
7 | (7,65535) | 40 | f | (p)=((1000,1000))
4343
(7 rows)
4444

4545
SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 1), 'test_gist_idx') LIMIT 5;
46-
itemoffset | ctid | itemlen | keys
47-
------------+-------+---------+-------------
48-
1 | (0,1) | 40 | (p)=((1,1))
49-
2 | (0,2) | 40 | (p)=((2,2))
50-
3 | (0,3) | 40 | (p)=((3,3))
51-
4 | (0,4) | 40 | (p)=((4,4))
52-
5 | (0,5) | 40 | (p)=((5,5))
46+
itemoffset | ctid | itemlen | dead | keys
47+
------------+-------+---------+------+-------------
48+
1 | (0,1) | 40 | f | (p)=((1,1))
49+
2 | (0,2) | 40 | f | (p)=((2,2))
50+
3 | (0,3) | 40 | f | (p)=((3,3))
51+
4 | (0,4) | 40 | f | (p)=((4,4))
52+
5 | (0,5) | 40 | f | (p)=((5,5))
5353
(5 rows)
5454

5555
-- gist_page_items_bytea prints the raw key data as a bytea. The output of that is

contrib/pageinspect/gistfuncs.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
103103
MemoryContext oldcontext;
104104
Page page;
105105
OffsetNumber offset;
106+
OffsetNumber maxoff = InvalidOffsetNumber;
106107

107108
if (!superuser())
108109
ereport(ERROR,
@@ -135,15 +136,18 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
135136

136137
page = get_page_from_raw(raw_page);
137138

139+
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
138140
if (GistPageIsDeleted(page))
139141
elog(NOTICE, "page is deleted");
142+
else
143+
maxoff = PageGetMaxOffsetNumber(page);
140144

141145
for (offset = FirstOffsetNumber;
142-
offset <= PageGetMaxOffsetNumber(page);
146+
offset <= maxoff;
143147
offset++)
144148
{
145-
Datum values[4];
146-
bool nulls[4];
149+
Datum values[5];
150+
bool nulls[5];
147151
ItemId id;
148152
IndexTuple itup;
149153
bytea *tuple_bytea;
@@ -166,7 +170,8 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
166170
tuple_bytea = (bytea *) palloc(tuple_len + VARHDRSZ);
167171
SET_VARSIZE(tuple_bytea, tuple_len + VARHDRSZ);
168172
memcpy(VARDATA(tuple_bytea), itup, tuple_len);
169-
values[3] = PointerGetDatum(tuple_bytea);
173+
values[3] = BoolGetDatum(ItemIdIsDead(id));
174+
values[4] = PointerGetDatum(tuple_bytea);
170175

171176
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
172177
}
@@ -187,6 +192,7 @@ gist_page_items(PG_FUNCTION_ARGS)
187192
MemoryContext oldcontext;
188193
Page page;
189194
OffsetNumber offset;
195+
OffsetNumber maxoff = InvalidOffsetNumber;
190196

191197
if (!superuser())
192198
ereport(ERROR,
@@ -222,15 +228,18 @@ gist_page_items(PG_FUNCTION_ARGS)
222228

223229
page = get_page_from_raw(raw_page);
224230

231+
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
225232
if (GistPageIsDeleted(page))
226233
elog(NOTICE, "page is deleted");
234+
else
235+
maxoff = PageGetMaxOffsetNumber(page);
227236

228237
for (offset = FirstOffsetNumber;
229-
offset <= PageGetMaxOffsetNumber(page);
238+
offset <= maxoff;
230239
offset++)
231240
{
232-
Datum values[4];
233-
bool nulls[4];
241+
Datum values[5];
242+
bool nulls[5];
234243
ItemId id;
235244
IndexTuple itup;
236245
Datum itup_values[INDEX_MAX_KEYS];
@@ -252,14 +261,15 @@ gist_page_items(PG_FUNCTION_ARGS)
252261
values[0] = DatumGetInt16(offset);
253262
values[1] = ItemPointerGetDatum(&itup->t_tid);
254263
values[2] = Int32GetDatum((int) IndexTupleSize(itup));
264+
values[3] = BoolGetDatum(ItemIdIsDead(id));
255265

256266
key_desc = BuildIndexValueDescription(indexRel, itup_values, itup_isnull);
257267
if (key_desc)
258-
values[3] = CStringGetTextDatum(key_desc);
268+
values[4] = CStringGetTextDatum(key_desc);
259269
else
260270
{
261-
values[3] = (Datum) 0;
262-
nulls[3] = true;
271+
values[4] = (Datum) 0;
272+
nulls[4] = true;
263273
}
264274

265275
tuplestore_putvalues(tupstore, tupdesc, values, nulls);

contrib/pageinspect/pageinspect--1.8--1.9.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CREATE FUNCTION gist_page_items_bytea(IN page bytea,
2222
OUT itemoffset smallint,
2323
OUT ctid tid,
2424
OUT itemlen smallint,
25+
OUT dead boolean,
2526
OUT key_data bytea)
2627
RETURNS SETOF record
2728
AS 'MODULE_PATHNAME', 'gist_page_items_bytea'
@@ -35,6 +36,7 @@ CREATE FUNCTION gist_page_items(IN page bytea,
3536
OUT itemoffset smallint,
3637
OUT ctid tid,
3738
OUT itemlen smallint,
39+
OUT dead boolean,
3840
OUT keys text)
3941
RETURNS SETOF record
4042
AS 'MODULE_PATHNAME', 'gist_page_items'

contrib/pg_prewarm/autoprewarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
697697
apw_state->pid_using_dumpfile = InvalidPid;
698698

699699
ereport(DEBUG1,
700-
(errmsg("wrote block details for %d blocks", num_blocks)));
700+
(errmsg_internal("wrote block details for %d blocks", num_blocks)));
701701
return num_blocks;
702702
}
703703

contrib/pgcrypto/internal-sha2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int_sha2_finish(PX_MD *h, uint8 *dst)
118118
{
119119
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
120120

121-
if (pg_cryptohash_final(ctx, dst) < 0)
121+
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
122122
elog(ERROR, "could not finalize %s context", "SHA2");
123123
}
124124

contrib/pgcrypto/internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int_md5_finish(PX_MD *h, uint8 *dst)
106106
{
107107
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
108108

109-
if (pg_cryptohash_final(ctx, dst) < 0)
109+
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
110110
elog(ERROR, "could not finalize %s context", "MD5");
111111
}
112112

@@ -156,7 +156,7 @@ int_sha1_finish(PX_MD *h, uint8 *dst)
156156
{
157157
pg_cryptohash_ctx *ctx = (pg_cryptohash_ctx *) h->p.ptr;
158158

159-
if (pg_cryptohash_final(ctx, dst) < 0)
159+
if (pg_cryptohash_final(ctx, dst, h->result_size(h)) < 0)
160160
elog(ERROR, "could not finalize %s context", "SHA1");
161161
}
162162

contrib/pgstattuple/pgstattuple.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno,
430430
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
431431
if (P_IGNORE(opaque))
432432
{
433-
/* recyclable page */
433+
/* deleted or half-dead page */
434434
stat->free_space += BLCKSZ;
435435
}
436436
else if (P_ISLEAF(opaque))
@@ -440,7 +440,7 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno,
440440
}
441441
else
442442
{
443-
/* root or node */
443+
/* internal page */
444444
}
445445
}
446446

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,24 @@ SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2
613613

614614
RESET enable_hashjoin;
615615
RESET enable_nestloop;
616+
-- Test executing assertion in estimate_path_cost_size() that makes sure that
617+
-- retrieved_rows for foreign rel re-used to cost pre-sorted foreign paths is
618+
-- a sensible value even when the rel has tuples=0
619+
CREATE TABLE loct_empty (c1 int NOT NULL, c2 text);
620+
CREATE FOREIGN TABLE ft_empty (c1 int NOT NULL, c2 text)
621+
SERVER loopback OPTIONS (table_name 'loct_empty');
622+
INSERT INTO loct_empty
623+
SELECT id, 'AAA' || to_char(id, 'FM000') FROM generate_series(1, 100) id;
624+
DELETE FROM loct_empty;
625+
ANALYZE ft_empty;
626+
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft_empty ORDER BY c1;
627+
QUERY PLAN
628+
-------------------------------------------------------------------------------
629+
Foreign Scan on public.ft_empty
630+
Output: c1, c2
631+
Remote SQL: SELECT c1, c2 FROM public.loct_empty ORDER BY c1 ASC NULLS LAST
632+
(3 rows)
633+
616634
-- ===================================================================
617635
-- WHERE with remotely-executable conditions
618636
-- ===================================================================
@@ -8928,7 +8946,7 @@ DO $d$
89288946
END;
89298947
$d$;
89308948
ERROR: invalid option "password"
8931-
HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size
8949+
HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, sslcrldir, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size
89328950
CONTEXT: SQL statement "ALTER SERVER loopback_nopw OPTIONS (ADD password 'dummypw')"
89338951
PL/pgSQL function inline_code_block line 3 at EXECUTE
89348952
-- If we add a password for our user mapping instead, we should get a different
@@ -9396,5 +9414,26 @@ SELECT COUNT(*) FROM batch_table;
93969414
66
93979415
(1 row)
93989416

9417+
-- Check that enabling batched inserts doesn't interfere with cross-partition
9418+
-- updates
9419+
CREATE TABLE batch_cp_upd_test (a int) PARTITION BY LIST (a);
9420+
CREATE TABLE batch_cp_upd_test1 (LIKE batch_cp_upd_test);
9421+
CREATE FOREIGN TABLE batch_cp_upd_test1_f
9422+
PARTITION OF batch_cp_upd_test
9423+
FOR VALUES IN (1)
9424+
SERVER loopback
9425+
OPTIONS (table_name 'batch_cp_upd_test1', batch_size '10');
9426+
CREATE TABLE batch_cp_up_test1 PARTITION OF batch_cp_upd_test
9427+
FOR VALUES IN (2);
9428+
INSERT INTO batch_cp_upd_test VALUES (1), (2);
9429+
-- The following moves a row from the local partition to the foreign one
9430+
UPDATE batch_cp_upd_test t SET a = 1 FROM (VALUES (1), (2)) s(a) WHERE t.a = s.a;
9431+
SELECT tableoid::regclass, * FROM batch_cp_upd_test;
9432+
tableoid | a
9433+
----------------------+---
9434+
batch_cp_upd_test1_f | 1
9435+
batch_cp_upd_test1_f | 1
9436+
(2 rows)
9437+
93999438
-- Clean up
9400-
DROP TABLE batch_table CASCADE;
9439+
DROP TABLE batch_table, batch_cp_upd_test CASCADE;

0 commit comments

Comments
 (0)