Skip to content

Commit 83c6310

Browse files
authored
Merge branch 'postgres:master' into master
2 parents decf339 + 15d33eb commit 83c6310

File tree

20 files changed

+245
-125
lines changed

20 files changed

+245
-125
lines changed

doc/src/sgml/pgbuffercache.sgml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919
<primary>pg_buffercache_pages</primary>
2020
</indexterm>
2121

22+
<indexterm>
23+
<primary>pg_buffercache_numa</primary>
24+
</indexterm>
25+
2226
<indexterm>
2327
<primary>pg_buffercache_summary</primary>
2428
</indexterm>
2529

30+
<indexterm>
31+
<primary>pg_buffercache_usage_counts</primary>
32+
</indexterm>
33+
2634
<indexterm>
2735
<primary>pg_buffercache_evict</primary>
2836
</indexterm>
@@ -489,7 +497,7 @@
489497
</sect2>
490498

491499
<sect2 id="pgbuffercache-pg-buffercache-evict-relation">
492-
<title>The <structname>pg_buffercache_evict_relation</structname> Function</title>
500+
<title>The <structname>pg_buffercache_evict_relation()</structname> Function</title>
493501
<para>
494502
The <function>pg_buffercache_evict_relation()</function> function is very
495503
similar to the <function>pg_buffercache_evict()</function> function. The
@@ -507,7 +515,7 @@
507515
</sect2>
508516

509517
<sect2 id="pgbuffercache-pg-buffercache-evict-all">
510-
<title>The <structname>pg_buffercache_evict_all</structname> Function</title>
518+
<title>The <structname>pg_buffercache_evict_all()</structname> Function</title>
511519
<para>
512520
The <function>pg_buffercache_evict_all()</function> function is very
513521
similar to the <function>pg_buffercache_evict()</function> function. The

src/backend/access/heap/visibilitymap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
364364
{
365365
*vmbuf = vm_readbuf(rel, mapBlock, false);
366366
if (!BufferIsValid(*vmbuf))
367-
return false;
367+
return (uint8) 0;
368368
}
369369

370370
map = PageGetContents(BufferGetPage(*vmbuf));

src/backend/commands/foreigncmds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,7 @@ ImportForeignSchema(ImportForeignSchemaStmt *stmt)
15881588
pstmt->utilityStmt = (Node *) cstmt;
15891589
pstmt->stmt_location = rs->stmt_location;
15901590
pstmt->stmt_len = rs->stmt_len;
1591+
pstmt->cached_plan_type = PLAN_CACHE_NONE;
15911592

15921593
/* Execute statement */
15931594
ProcessUtility(pstmt, cmd, false,

src/backend/commands/schemacmds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString,
215215
wrapper->utilityStmt = stmt;
216216
wrapper->stmt_location = stmt_location;
217217
wrapper->stmt_len = stmt_len;
218+
wrapper->cached_plan_type = PLAN_CACHE_NONE;
218219

219220
/* do this step */
220221
ProcessUtility(wrapper,

src/backend/executor/execParallel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ ExecSerializePlan(Plan *plan, EState *estate)
189189
pstmt->permInfos = estate->es_rteperminfos;
190190
pstmt->resultRelations = NIL;
191191
pstmt->appendRelations = NIL;
192+
pstmt->cached_plan_type = PLAN_CACHE_NONE;
192193

193194
/*
194195
* Transfer only parallel-safe subplans, leaving a NULL "hole" in the list

src/backend/libpq/auth.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ static int auth_peer(hbaPort *port);
9494

9595
#define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */
9696

97+
/* Work around original Solaris' lack of "const" in the conv_proc signature */
98+
#ifdef _PAM_LEGACY_NONCONST
99+
#define PG_PAM_CONST
100+
#else
101+
#define PG_PAM_CONST const
102+
#endif
103+
97104
static int CheckPAMAuth(Port *port, const char *user, const char *password);
98-
static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
105+
static int pam_passwd_conv_proc(int num_msg,
106+
PG_PAM_CONST struct pam_message **msg,
99107
struct pam_response **resp, void *appdata_ptr);
100108

101109
static struct pam_conv pam_passw_conv = {
@@ -1917,7 +1925,7 @@ auth_peer(hbaPort *port)
19171925
*/
19181926

19191927
static int
1920-
pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
1928+
pam_passwd_conv_proc(int num_msg, PG_PAM_CONST struct pam_message **msg,
19211929
struct pam_response **resp, void *appdata_ptr)
19221930
{
19231931
const char *passwd;

src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
582582
result->utilityStmt = parse->utilityStmt;
583583
result->stmt_location = parse->stmt_location;
584584
result->stmt_len = parse->stmt_len;
585+
result->cached_plan_type = PLAN_CACHE_NONE;
585586

586587
result->jitFlags = PGJIT_NONE;
587588
if (jit_enabled && jit_above_cost >= 0 &&

src/backend/storage/lmgr/generate-lwlocknames.pl

Lines changed: 83 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,24 @@
2727

2828

2929
#
30-
# First, record the predefined LWLocks listed in wait_event_names.txt. We'll
31-
# cross-check those with the ones in lwlocklist.h.
30+
# First, record the predefined LWLocks and built-in tranches listed in
31+
# wait_event_names.txt. We'll cross-check those with the ones in lwlocklist.h.
3232
#
33+
my @wait_event_tranches;
3334
my @wait_event_lwlocks;
3435
my $record_lwlocks = 0;
36+
my $in_tranches = 0;
3537

3638
while (<$wait_event_names>)
3739
{
3840
chomp;
3941

4042
# Check for end marker.
41-
last if /^# END OF PREDEFINED LWLOCKS/;
43+
if (/^# END OF PREDEFINED LWLOCKS/)
44+
{
45+
$in_tranches = 1;
46+
next;
47+
}
4248

4349
# Skip comments and empty lines.
4450
next if /^#/;
@@ -54,13 +60,29 @@
5460
# Go to the next line if we are not yet recording LWLocks.
5561
next if not $record_lwlocks;
5662

63+
# Stop recording if we reach another section.
64+
last if /^Section:/;
65+
5766
# Record the LWLock.
5867
(my $waiteventname, my $waitevendocsentence) = split(/\t/, $_);
59-
push(@wait_event_lwlocks, $waiteventname);
68+
69+
if ($in_tranches)
70+
{
71+
push(@wait_event_tranches, $waiteventname);
72+
}
73+
else
74+
{
75+
push(@wait_event_lwlocks, $waiteventname);
76+
}
6077
}
6178

79+
#
80+
# While gathering the list of predefined LWLocks, cross-check the lists in
81+
# lwlocklist.h with the wait events we just recorded.
82+
#
6283
my $in_comment = 0;
63-
my $i = 0;
84+
my $lwlock_count = 0;
85+
my $tranche_count = 0;
6486
while (<$lwlocklist>)
6587
{
6688
chomp;
@@ -81,38 +103,72 @@
81103
next;
82104
}
83105

84-
die "unable to parse lwlocklist.h line \"$_\""
85-
unless /^PG_LWLOCK\((\d+),\s+(\w+)\)$/;
106+
#
107+
# Gather list of predefined LWLocks and cross-check with the wait events.
108+
#
109+
if (/^PG_LWLOCK\((\d+),\s+(\w+)\)$/)
110+
{
111+
my ($lockidx, $lockname) = ($1, $2);
86112

87-
(my $lockidx, my $lockname) = ($1, $2);
113+
die "lwlocklist.h not in order" if $lockidx < $lastlockidx;
114+
die "lwlocklist.h has duplicates" if $lockidx == $lastlockidx;
88115

89-
die "lwlocklist.h not in order" if $lockidx < $lastlockidx;
90-
die "lwlocklist.h has duplicates" if $lockidx == $lastlockidx;
116+
die "$lockname defined in lwlocklist.h but missing from "
117+
. "wait_event_names.txt"
118+
if $lwlock_count >= scalar @wait_event_lwlocks;
119+
die "lists of predefined LWLocks do not match (first mismatch at "
120+
. "$wait_event_lwlocks[$lwlock_count] in wait_event_names.txt and "
121+
. "$lockname in lwlocklist.h)"
122+
if $wait_event_lwlocks[$lwlock_count] ne $lockname;
91123

92-
die "$lockname defined in lwlocklist.h but missing from "
93-
. "wait_event_names.txt"
94-
if $i >= scalar @wait_event_lwlocks;
95-
die "lists of predefined LWLocks do not match (first mismatch at "
96-
. "$wait_event_lwlocks[$i] in wait_event_names.txt and $lockname in "
97-
. "lwlocklist.h)"
98-
if $wait_event_lwlocks[$i] ne $lockname;
99-
$i++;
124+
$lwlock_count++;
100125

101-
while ($lastlockidx < $lockidx - 1)
126+
while ($lastlockidx < $lockidx - 1)
127+
{
128+
++$lastlockidx;
129+
}
130+
$lastlockidx = $lockidx;
131+
132+
# Add a "Lock" suffix to each lock name, as the C code depends on that.
133+
printf $h "#define %-32s (&MainLWLockArray[$lockidx].lock)\n",
134+
$lockname . "Lock";
135+
136+
next;
137+
}
138+
139+
#
140+
# Cross-check the built-in LWLock tranches with the wait events.
141+
#
142+
if (/^PG_LWLOCKTRANCHE\((\w+),\s+(\w+)\)$/)
102143
{
103-
++$lastlockidx;
144+
my ($tranche_id, $tranche_name) = ($1, $2);
145+
146+
die "$tranche_name defined in lwlocklist.h but missing from "
147+
. "wait_event_names.txt"
148+
if $tranche_count >= scalar @wait_event_tranches;
149+
die
150+
"lists of built-in LWLock tranches do not match (first mismatch at "
151+
. "$wait_event_tranches[$tranche_count] in wait_event_names.txt and "
152+
. "$tranche_name in lwlocklist.h)"
153+
if $wait_event_tranches[$tranche_count] ne $tranche_name;
154+
155+
$tranche_count++;
156+
157+
next;
104158
}
105-
$lastlockidx = $lockidx;
106159

107-
# Add a "Lock" suffix to each lock name, as the C code depends on that
108-
printf $h "#define %-32s (&MainLWLockArray[$lockidx].lock)\n",
109-
$lockname . "Lock";
160+
die "unable to parse lwlocklist.h line \"$_\"";
110161
}
111162

112163
die
113-
"$wait_event_lwlocks[$i] defined in wait_event_names.txt but missing from "
114-
. "lwlocklist.h"
115-
if $i < scalar @wait_event_lwlocks;
164+
"$wait_event_lwlocks[$lwlock_count] defined in wait_event_names.txt but "
165+
. " missing from lwlocklist.h"
166+
if $lwlock_count < scalar @wait_event_lwlocks;
167+
168+
die
169+
"$wait_event_tranches[$tranche_count] defined in wait_event_names.txt but "
170+
. "missing from lwlocklist.h"
171+
if $tranche_count < scalar @wait_event_tranches;
116172

117173
print $h "\n";
118174
printf $h "#define NUM_INDIVIDUAL_LWLOCKS %s\n", $lastlockidx + 1;

src/backend/storage/lmgr/lwlock.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ StaticAssertDecl((LW_VAL_EXCLUSIVE & LW_FLAG_MASK) == 0,
122122
* own tranche. We absorb the names of these tranches from there into
123123
* BuiltinTrancheNames here.
124124
*
125-
* 2. There are some predefined tranches for built-in groups of locks.
126-
* These are listed in enum BuiltinTrancheIds in lwlock.h, and their names
127-
* appear in BuiltinTrancheNames[] below.
125+
* 2. There are some predefined tranches for built-in groups of locks defined
126+
* in lwlocklist.h. We absorb the names of these tranches, too.
128127
*
129128
* 3. Extensions can create new tranches, via either RequestNamedLWLockTranche
130129
* or LWLockRegisterTranche. The names of these that are known in the current
@@ -135,49 +134,10 @@ StaticAssertDecl((LW_VAL_EXCLUSIVE & LW_FLAG_MASK) == 0,
135134
*/
136135
static const char *const BuiltinTrancheNames[] = {
137136
#define PG_LWLOCK(id, lockname) [id] = CppAsString(lockname),
137+
#define PG_LWLOCKTRANCHE(id, lockname) [LWTRANCHE_##id] = CppAsString(lockname),
138138
#include "storage/lwlocklist.h"
139139
#undef PG_LWLOCK
140-
[LWTRANCHE_XACT_BUFFER] = "XactBuffer",
141-
[LWTRANCHE_COMMITTS_BUFFER] = "CommitTsBuffer",
142-
[LWTRANCHE_SUBTRANS_BUFFER] = "SubtransBuffer",
143-
[LWTRANCHE_MULTIXACTOFFSET_BUFFER] = "MultiXactOffsetBuffer",
144-
[LWTRANCHE_MULTIXACTMEMBER_BUFFER] = "MultiXactMemberBuffer",
145-
[LWTRANCHE_NOTIFY_BUFFER] = "NotifyBuffer",
146-
[LWTRANCHE_SERIAL_BUFFER] = "SerialBuffer",
147-
[LWTRANCHE_WAL_INSERT] = "WALInsert",
148-
[LWTRANCHE_BUFFER_CONTENT] = "BufferContent",
149-
[LWTRANCHE_REPLICATION_ORIGIN_STATE] = "ReplicationOriginState",
150-
[LWTRANCHE_REPLICATION_SLOT_IO] = "ReplicationSlotIO",
151-
[LWTRANCHE_LOCK_FASTPATH] = "LockFastPath",
152-
[LWTRANCHE_BUFFER_MAPPING] = "BufferMapping",
153-
[LWTRANCHE_LOCK_MANAGER] = "LockManager",
154-
[LWTRANCHE_PREDICATE_LOCK_MANAGER] = "PredicateLockManager",
155-
[LWTRANCHE_PARALLEL_HASH_JOIN] = "ParallelHashJoin",
156-
[LWTRANCHE_PARALLEL_BTREE_SCAN] = "ParallelBtreeScan",
157-
[LWTRANCHE_PARALLEL_QUERY_DSA] = "ParallelQueryDSA",
158-
[LWTRANCHE_PER_SESSION_DSA] = "PerSessionDSA",
159-
[LWTRANCHE_PER_SESSION_RECORD_TYPE] = "PerSessionRecordType",
160-
[LWTRANCHE_PER_SESSION_RECORD_TYPMOD] = "PerSessionRecordTypmod",
161-
[LWTRANCHE_SHARED_TUPLESTORE] = "SharedTupleStore",
162-
[LWTRANCHE_SHARED_TIDBITMAP] = "SharedTidBitmap",
163-
[LWTRANCHE_PARALLEL_APPEND] = "ParallelAppend",
164-
[LWTRANCHE_PER_XACT_PREDICATE_LIST] = "PerXactPredicateList",
165-
[LWTRANCHE_PGSTATS_DSA] = "PgStatsDSA",
166-
[LWTRANCHE_PGSTATS_HASH] = "PgStatsHash",
167-
[LWTRANCHE_PGSTATS_DATA] = "PgStatsData",
168-
[LWTRANCHE_LAUNCHER_DSA] = "LogicalRepLauncherDSA",
169-
[LWTRANCHE_LAUNCHER_HASH] = "LogicalRepLauncherHash",
170-
[LWTRANCHE_DSM_REGISTRY_DSA] = "DSMRegistryDSA",
171-
[LWTRANCHE_DSM_REGISTRY_HASH] = "DSMRegistryHash",
172-
[LWTRANCHE_COMMITTS_SLRU] = "CommitTsSLRU",
173-
[LWTRANCHE_MULTIXACTOFFSET_SLRU] = "MultiXactOffsetSLRU",
174-
[LWTRANCHE_MULTIXACTMEMBER_SLRU] = "MultiXactMemberSLRU",
175-
[LWTRANCHE_NOTIFY_SLRU] = "NotifySLRU",
176-
[LWTRANCHE_SERIAL_SLRU] = "SerialSLRU",
177-
[LWTRANCHE_SUBTRANS_SLRU] = "SubtransSLRU",
178-
[LWTRANCHE_XACT_SLRU] = "XactSLRU",
179-
[LWTRANCHE_PARALLEL_VACUUM_DSA] = "ParallelVacuumDSA",
180-
[LWTRANCHE_AIO_URING_COMPLETION] = "AioUringCompletion",
140+
#undef PG_LWLOCKTRANCHE
181141
};
182142

183143
StaticAssertDecl(lengthof(BuiltinTrancheNames) ==

src/backend/tcop/postgres.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions,
988988
stmt->stmt_location = query->stmt_location;
989989
stmt->stmt_len = query->stmt_len;
990990
stmt->queryId = query->queryId;
991+
stmt->cached_plan_type = PLAN_CACHE_NONE;
991992
}
992993
else
993994
{

0 commit comments

Comments
 (0)