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

Commit0fa0b48

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 parentd5daae4 commit0fa0b48

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
@@ -7631,7 +7631,9 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
76317631
<structfield>srsublsn</structfield> <type>pg_lsn</type>
76327632
</para>
76337633
<para>
7634-
End LSN for <literal>s</literal> and <literal>r</literal> states.
7634+
Remote LSN of the state change used for synchronization coordination
7635+
when in <literal>s</literal> or <literal>r</literal> states,
7636+
otherwise null
76357637
</para></entry>
76367638
</row>
76377639
</tbody>

‎src/backend/catalog/pg_subscription.c

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

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

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

463470
res=lappend(res,relstate);
464471
}
@@ -504,13 +511,20 @@ GetSubscriptionNotReadyRelations(Oid subid)
504511
{
505512
Form_pg_subscription_relsubrel;
506513
SubscriptionRelState*relstate;
514+
Datumd;
515+
boolisnull;
507516

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

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

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

‎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_NO202007192
56+
#defineCATALOG_VERSION_NO202007202
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