- Notifications
You must be signed in to change notification settings - Fork28
Commitcf25498
committed
Fix a crash in logical replication
The bug was that determining which columns are part of the replicaidentity index using RelationGetIndexAttrBitmap() would runeval_const_expressions() on index expressions and predicates acrossall indexes of the table, which in turn might require a snapshot, butthere wasn't one set, so it crashes. There were actually two separatebugs, one on the publisher and one on the subscriber.To trigger the bug, a table that is part of a publication orsubscription needs to have an index with a predicate or expressionthat lends itself to constant expressions simplification.The fix is to avoid the constant expressions simplification inRelationGetIndexAttrBitmap(), so that it becomes safe to call in thesecontexts. The constant expressions simplification comes from thecalls to RelationGetIndexExpressions()/RelationGetIndexPredicate() viaBuildIndexInfo(). But RelationGetIndexAttrBitmap() callingBuildIndexInfo() is overkill. The latter just takes pg_index cataloginformation, packs it into the IndexInfo structure, which former thenjust unpacks again and throws away. We can just do this directly withless overhead and skip the troublesome calls toeval_const_expressions(). This also removes the awkwardcross-dependency between relcache.c and index.c.Bug: #15114Reported-by: Петър Славов <pet.slavov@gmail.com>Reviewed-by: Noah Misch <noah@leadboat.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/flat/152110589574.1223.17983600132321618383@wrigleys.postgresql.org/1 parentff9e63c commitcf25498
File tree
2 files changed
+106
-19
lines changed- src
- backend/utils/cache
- test/subscription/t
2 files changed
+106
-19
lines changedLines changed: 41 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
40 | 40 |
| |
41 | 41 |
| |
42 | 42 |
| |
43 |
| - | |
44 | 43 |
| |
45 | 44 |
| |
46 | 45 |
| |
| |||
4700 | 4699 |
| |
4701 | 4700 |
| |
4702 | 4701 |
| |
4703 |
| - | |
| 4702 | + | |
4704 | 4703 |
| |
4705 | 4704 |
| |
4706 | 4705 |
| |
4707 | 4706 |
| |
4708 |
| - | |
| 4707 | + | |
4709 | 4708 |
| |
4710 | 4709 |
| |
4711 | 4710 |
| |
| |||
4715 | 4714 |
| |
4716 | 4715 |
| |
4717 | 4716 |
| |
4718 |
| - | |
| 4717 | + | |
4719 | 4718 |
| |
4720 | 4719 |
| |
4721 | 4720 |
| |
| |||
4861 | 4860 |
| |
4862 | 4861 |
| |
4863 | 4862 |
| |
4864 |
| - | |
| 4863 | + | |
| 4864 | + | |
| 4865 | + | |
| 4866 | + | |
4865 | 4867 |
| |
4866 | 4868 |
| |
4867 | 4869 |
| |
4868 | 4870 |
| |
4869 | 4871 |
| |
4870 | 4872 |
| |
4871 | 4873 |
| |
4872 |
| - | |
4873 |
| - | |
| 4874 | + | |
| 4875 | + | |
| 4876 | + | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
| 4886 | + | |
| 4887 | + | |
| 4888 | + | |
| 4889 | + | |
| 4890 | + | |
| 4891 | + | |
| 4892 | + | |
| 4893 | + | |
| 4894 | + | |
| 4895 | + | |
4874 | 4896 |
| |
4875 | 4897 |
| |
4876 |
| - | |
4877 |
| - | |
4878 |
| - | |
| 4898 | + | |
| 4899 | + | |
| 4900 | + | |
4879 | 4901 |
| |
4880 | 4902 |
| |
4881 | 4903 |
| |
| |||
4884 | 4906 |
| |
4885 | 4907 |
| |
4886 | 4908 |
| |
4887 |
| - | |
| 4909 | + | |
4888 | 4910 |
| |
4889 |
| - | |
| 4911 | + | |
4890 | 4912 |
| |
4891 | 4913 |
| |
4892 | 4914 |
| |
| |||
4901 | 4923 |
| |
4902 | 4924 |
| |
4903 | 4925 |
| |
4904 |
| - | |
| 4926 | + | |
4905 | 4927 |
| |
4906 | 4928 |
| |
4907 | 4929 |
| |
4908 |
| - | |
| 4930 | + | |
4909 | 4931 |
| |
4910 | 4932 |
| |
4911 | 4933 |
| |
4912 |
| - | |
| 4934 | + | |
4913 | 4935 |
| |
4914 | 4936 |
| |
4915 | 4937 |
| |
4916 | 4938 |
| |
4917 | 4939 |
| |
4918 | 4940 |
| |
4919 |
| - | |
| 4941 | + | |
4920 | 4942 |
| |
4921 | 4943 |
| |
4922 |
| - | |
| 4944 | + | |
4923 | 4945 |
| |
4924 | 4946 |
| |
4925 | 4947 |
| |
4926 | 4948 |
| |
4927 |
| - | |
| 4949 | + | |
4928 | 4950 |
| |
4929 | 4951 |
| |
4930 |
| - | |
| 4952 | + | |
4931 | 4953 |
| |
4932 | 4954 |
| |
4933 | 4955 |
| |
|
Lines changed: 65 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + |
0 commit comments
Comments
(0)