Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5372b4

Browse files
committed
Correctly mark pg_subscription_rel.srsublsn as nullable.
The code has always set this column to NULL when it's not valid,but the catalog header's description failed to reflect that,as did the SGML docs, as did some of the code. To prevent futurecoding errors of the same ilk, let's hide the field from C codeas though it were variable-length (which, in a sense, it is).As with commit72eab84, we can only fix this cleanly in HEADand v13; the problem extends further back but we'll need someklugery in the released branches.Discussion:https://postgr.es/m/367660.1595202498@sss.pgh.pa.us
1 parent2f1f189 commite5372b4

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7620,7 +7620,9 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
76207620
<structfield>srsublsn</structfield> <type>pg_lsn</type>
76217621
</para>
76227622
<para>
7623-
End LSN for <literal>s</literal> and <literal>r</literal> states.
7623+
Remote LSN of the state change used for synchronization coordination
7624+
when in <literal>s</literal> or <literal>r</literal> states,
7625+
otherwise null
76247626
</para></entry>
76257627
</row>
76267628
</tbody>

‎src/backend/catalog/pg_subscription.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,20 @@ GetSubscriptionRelations(Oid subid)
451451
{
452452
Form_pg_subscription_relsubrel;
453453
SubscriptionRelState*relstate;
454+
Datumd;
455+
boolisnull;
454456

455457
subrel= (Form_pg_subscription_rel)GETSTRUCT(tup);
456458

457459
relstate= (SubscriptionRelState*)palloc(sizeof(SubscriptionRelState));
458460
relstate->relid=subrel->srrelid;
459461
relstate->state=subrel->srsubstate;
460-
relstate->lsn=subrel->srsublsn;
462+
d=SysCacheGetAttr(SUBSCRIPTIONRELMAP,tup,
463+
Anum_pg_subscription_rel_srsublsn,&isnull);
464+
if (isnull)
465+
relstate->lsn=InvalidXLogRecPtr;
466+
else
467+
relstate->lsn=DatumGetLSN(d);
461468

462469
res=lappend(res,relstate);
463470
}
@@ -503,13 +510,20 @@ GetSubscriptionNotReadyRelations(Oid subid)
503510
{
504511
Form_pg_subscription_relsubrel;
505512
SubscriptionRelState*relstate;
513+
Datumd;
514+
boolisnull;
506515

507516
subrel= (Form_pg_subscription_rel)GETSTRUCT(tup);
508517

509518
relstate= (SubscriptionRelState*)palloc(sizeof(SubscriptionRelState));
510519
relstate->relid=subrel->srrelid;
511520
relstate->state=subrel->srsubstate;
512-
relstate->lsn=subrel->srsublsn;
521+
d=SysCacheGetAttr(SUBSCRIPTIONRELMAP,tup,
522+
Anum_pg_subscription_rel_srsublsn,&isnull);
523+
if (isnull)
524+
relstate->lsn=InvalidXLogRecPtr;
525+
else
526+
relstate->lsn=DatumGetLSN(d);
513527

514528
res=lappend(res,relstate);
515529
}

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO202007191
56+
#defineCATALOG_VERSION_NO202007201
5757

5858
#endif

‎src/include/catalog/pg_subscription_rel.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
3333
Oidsrsubid;/* Oid of subscription */
3434
Oidsrrelid;/* Oid of relation */
3535
charsrsubstate;/* state of the relation in subscription */
36-
XLogRecPtrsrsublsn;/* remote lsn of the state change used for
37-
* synchronization coordination */
36+
37+
/*
38+
* Although srsublsn is a fixed-width type, it is allowed to be NULL, so
39+
* we prevent direct C code access to it just as for a varlena field.
40+
*/
41+
#ifdefCATALOG_VARLEN/* variable-length fields start here */
42+
43+
XLogRecPtrsrsublsnBKI_FORCE_NULL;/* remote LSN of the state change
44+
* used for synchronization
45+
* coordination, or NULL if not
46+
* valid */
47+
#endif
3848
}FormData_pg_subscription_rel;
3949

4050
typedefFormData_pg_subscription_rel*Form_pg_subscription_rel;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp