Skip to content

Commit 0a4e5c9

Browse files
authored
Merge pull request #152 from postgres/master
Sync Fork from Upstream Repo
2 parents 0e4132a + c82d59d commit 0a4e5c9

File tree

8 files changed

+49
-37
lines changed

8 files changed

+49
-37
lines changed

contrib/amcheck/t/001_verify_heapam.pl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use PostgresNode;
55
use TestLib;
66

7-
use Test::More tests => 79;
7+
use Test::More tests => 80;
88

99
my ($node, $result);
1010

@@ -47,6 +47,9 @@
4747
#
4848
fresh_test_table('test');
4949
$node->safe_psql('postgres', q(VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) test));
50+
detects_no_corruption(
51+
"verify_heapam('test')",
52+
"all-frozen not corrupted table");
5053
corrupt_first_page('test');
5154
detects_heap_corruption("verify_heapam('test')",
5255
"all-frozen corrupted table");
@@ -92,6 +95,15 @@ sub fresh_test_table
9295
ALTER TABLE $relname ALTER b SET STORAGE external;
9396
INSERT INTO $relname (a, b)
9497
(SELECT gs, repeat('b',gs*10) FROM generate_series(1,1000) gs);
98+
BEGIN;
99+
SAVEPOINT s1;
100+
SELECT 1 FROM $relname WHERE a = 42 FOR UPDATE;
101+
UPDATE $relname SET b = b WHERE a = 42;
102+
RELEASE s1;
103+
SAVEPOINT s1;
104+
SELECT 1 FROM $relname WHERE a = 42 FOR UPDATE;
105+
UPDATE $relname SET b = b WHERE a = 42;
106+
COMMIT;
95107
));
96108
}
97109

contrib/amcheck/verify_heapam.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,6 @@ check_tuple_header_and_visibilty(HeapTupleHeader tuphdr, HeapCheckContext *ctx)
608608
ctx->tuphdr->t_hoff, ctx->lp_len));
609609
header_garbled = true;
610610
}
611-
if ((ctx->tuphdr->t_infomask & HEAP_XMAX_LOCK_ONLY) &&
612-
(ctx->tuphdr->t_infomask2 & HEAP_KEYS_UPDATED))
613-
{
614-
report_corruption(ctx,
615-
pstrdup("tuple is marked as only locked, but also claims key columns were updated"));
616-
header_garbled = true;
617-
}
618611

619612
if ((ctx->tuphdr->t_infomask & HEAP_XMAX_COMMITTED) &&
620613
(ctx->tuphdr->t_infomask & HEAP_XMAX_IS_MULTI))

doc/src/sgml/config.sgml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4503,15 +4503,16 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
45034503
view. The standby will report
45044504
the last write-ahead log location it has written, the last position it
45054505
has flushed to disk, and the last position it has applied.
4506-
This parameter's
4507-
value is the maximum amount of time between reports. Updates are
4508-
sent each time the write or flush positions change, or at least as
4509-
often as specified by this parameter. Thus, the apply position may
4510-
lag slightly behind the true position.
4506+
This parameter's value is the maximum amount of time between reports.
4507+
Updates are sent each time the write or flush positions change, or as
4508+
often as specified by this parameter if set to a non-zero value.
4509+
There are additional cases where updates are sent while ignoring this
4510+
parameter; for example, when processing of the existing WAL completes
4511+
or when <varname>synchronous_commit</varname> is set to
4512+
<literal>remote_apply</literal>.
4513+
Thus, the apply position may lag slightly behind the true position.
45114514
If this value is specified without units, it is taken as seconds.
4512-
The default value is 10 seconds.
4513-
Setting this parameter to zero disables status updates completely.
4514-
This parameter can only be set in
4515+
The default value is 10 seconds. This parameter can only be set in
45154516
the <filename>postgresql.conf</filename> file or on the server
45164517
command line.
45174518
</para>

src/backend/access/heap/README.tuplock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ The following infomask bits are applicable:
146146
FOR UPDATE; this is implemented by the HEAP_KEYS_UPDATED bit.
147147

148148
- HEAP_KEYS_UPDATED
149-
This bit lives in t_infomask2. If set, indicates that the XMAX updated
150-
this tuple and changed the key values, or it deleted the tuple.
151-
It's set regardless of whether the XMAX is a TransactionId or a MultiXactId.
149+
This bit lives in t_infomask2. If set, indicates that the operation(s) done
150+
by the XMAX compromise the tuple key, such as a SELECT FOR UPDATE, an UPDATE
151+
that modifies the columns of the key, or a DELETE. It's set regardless of
152+
whether the XMAX is a TransactionId or a MultiXactId.
152153

153154
We currently never set the HEAP_XMAX_COMMITTED when the HEAP_XMAX_IS_MULTI bit
154155
is set.

src/backend/access/heap/hio.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ RelationPutHeapTuple(Relation relation,
4949

5050
/*
5151
* Do not allow tuples with invalid combinations of hint bits to be placed
52-
* on a page. These combinations are detected as corruption by the
53-
* contrib/amcheck logic, so if you disable one or both of these
54-
* assertions, make corresponding changes there.
52+
* on a page. This combination is detected as corruption by the
53+
* contrib/amcheck logic, so if you disable this assertion, make
54+
* corresponding changes there.
5555
*/
56-
Assert(!((tuple->t_data->t_infomask & HEAP_XMAX_LOCK_ONLY) &&
57-
(tuple->t_data->t_infomask2 & HEAP_KEYS_UPDATED)));
5856
Assert(!((tuple->t_data->t_infomask & HEAP_XMAX_COMMITTED) &&
5957
(tuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI)));
6058

src/backend/optimizer/path/allpaths.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,10 +3019,11 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
30193019
join_search_one_level(root, lev);
30203020

30213021
/*
3022-
* Run generate_partitionwise_join_paths() and generate_gather_paths()
3023-
* for each just-processed joinrel. We could not do this earlier
3024-
* because both regular and partial paths can get added to a
3025-
* particular joinrel at multiple times within join_search_one_level.
3022+
* Run generate_partitionwise_join_paths() and
3023+
* generate_useful_gather_paths() for each just-processed joinrel. We
3024+
* could not do this earlier because both regular and partial paths
3025+
* can get added to a particular joinrel at multiple times within
3026+
* join_search_one_level.
30263027
*
30273028
* After that, we're done creating paths for the joinrel, so run
30283029
* set_cheapest().

src/backend/optimizer/plan/planner.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7212,14 +7212,14 @@ create_partial_grouping_paths(PlannerInfo *root,
72127212
* Generate Gather and Gather Merge paths for a grouping relation or partial
72137213
* grouping relation.
72147214
*
7215-
* generate_gather_paths does most of the work, but we also consider a special
7216-
* case: we could try sorting the data by the group_pathkeys and then applying
7217-
* Gather Merge.
7215+
* generate_useful_gather_paths does most of the work, but we also consider a
7216+
* special case: we could try sorting the data by the group_pathkeys and then
7217+
* applying Gather Merge.
72187218
*
72197219
* NB: This function shouldn't be used for anything other than a grouped or
72207220
* partially grouped relation not only because of the fact that it explicitly
72217221
* references group_pathkeys but we pass "true" as the third argument to
7222-
* generate_gather_paths().
7222+
* generate_useful_gather_paths().
72237223
*/
72247224
static void
72257225
gather_grouping_paths(PlannerInfo *root, RelOptInfo *rel)
@@ -7379,10 +7379,11 @@ apply_scanjoin_target_to_paths(PlannerInfo *root,
73797379
* variations. So we drop old paths and thereby force the work to be done
73807380
* below the Append, except in the case of a non-parallel-safe target.
73817381
*
7382-
* Some care is needed, because we have to allow generate_gather_paths to
7383-
* see the old partial paths in the next stanza. Hence, zap the main
7384-
* pathlist here, then allow generate_gather_paths to add path(s) to the
7385-
* main list, and finally zap the partial pathlist.
7382+
* Some care is needed, because we have to allow
7383+
* generate_useful_gather_paths to see the old partial paths in the next
7384+
* stanza. Hence, zap the main pathlist here, then allow
7385+
* generate_useful_gather_paths to add path(s) to the main list, and
7386+
* finally zap the partial pathlist.
73867387
*/
73877388
if (rel_is_partitioned)
73887389
rel->pathlist = NIL;

src/backend/regex/regc_nfa.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,13 @@ checkmatchall_recurse(struct nfa *nfa, struct state *s,
30823082
{
30833083
/* We found an all-RAINBOW path to the post state */
30843084
result = true;
3085+
/* ... which should not be adjacent to the pre state */
3086+
if (depth < 0)
3087+
{
3088+
NERR(REG_ASSERT);
3089+
return false;
3090+
}
30853091
/* Record potential match lengths */
3086-
assert(depth >= 0);
30873092
hasmatch[depth] = true;
30883093
if (foundloop)
30893094
{

0 commit comments

Comments
 (0)