- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit73e8ee9
committed
Don't assume that a tuple's header size is unchanged during toasting.
This assumption can be wrong when the toaster is passed a raw on-disktuple, because the tuple might pre-date an ALTER TABLE ADD COLUMN operationthat added columns without rewriting the table. In such a case the tuple'snatts value is smaller than what we expect from the tuple descriptor, andso its t_hoff value could be smaller too. In fact, the tuple might nothave a null bitmap at all, and yet our current opinion of it is that itcontains some trailing nulls.In such a situation, toast_insert_or_update did the wrong thing, becauseto save a few lines of code it would use the old t_hoff value as the offsetwhere heap_fill_tuple should start filling data. This did not leave enoughroom for the new nulls bitmap, with the result that the first few bytes ofdata could be overwritten with null flag bits, as in a recent report fromHubert Depesz Lubaczewski.The particular case reported requires ALTER TABLE ADD COLUMN followed byCREATE TABLE AS SELECT * FROM ... or INSERT ... SELECT * FROM ..., andfurther requires that there be some out-of-line toasted fields in one ofthe tuples to be copied; else we'll not reach the troublesome code.The problem can only manifest in this form in 8.4 and later, becausebefore commita77eaa6, CREATE TABLE AS orINSERT/SELECT wouldn't result in raw disk tuples getting passed directlyto heap_insert --- there would always have been at least a junkfilter inbetween, and that would reconstitute the tuple header with an up-to-datet_natts and hence t_hoff. But I'm backpatching the tuptoaster change allthe way anyway, because I'm not convinced there are no older code pathsthat present a similar risk.1 parentb24e6ca commit73e8ee9
1 file changed
+52
-30
lines changedLines changed: 52 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
514 | 514 |
| |
515 | 515 |
| |
516 | 516 |
| |
517 |
| - | |
518 | 517 |
| |
519 | 518 |
| |
520 | 519 |
| |
| |||
748 | 747 |
| |
749 | 748 |
| |
750 | 749 |
| |
751 |
| - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
752 | 753 |
| |
753 | 754 |
| |
754 |
| - | |
755 |
| - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
756 | 763 |
| |
757 |
| - | |
| 764 | + | |
758 | 765 |
| |
759 |
| - | |
| 766 | + | |
760 | 767 |
| |
761 |
| - | |
762 |
| - | |
763 |
| - | |
764 |
| - | |
765 |
| - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
766 | 773 |
| |
767 | 774 |
| |
768 | 775 |
| |
769 | 776 |
| |
770 |
| - | |
771 |
| - | |
| 777 | + | |
| 778 | + | |
772 | 779 |
| |
773 | 780 |
| |
774 | 781 |
| |
775 | 782 |
| |
776 | 783 |
| |
777 | 784 |
| |
778 |
| - | |
| 785 | + | |
779 | 786 |
| |
780 |
| - | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
781 | 792 |
| |
| 793 | + | |
782 | 794 |
| |
783 | 795 |
| |
784 | 796 |
| |
785 |
| - | |
| 797 | + | |
786 | 798 |
| |
787 | 799 |
| |
788 | 800 |
| |
| |||
903 | 915 |
| |
904 | 916 |
| |
905 | 917 |
| |
906 |
| - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
907 | 921 |
| |
908 | 922 |
| |
909 | 923 |
| |
| |||
973 | 987 |
| |
974 | 988 |
| |
975 | 989 |
| |
976 |
| - | |
977 |
| - | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
978 | 993 |
| |
979 |
| - | |
| 994 | + | |
980 | 995 |
| |
981 |
| - | |
| 996 | + | |
982 | 997 |
| |
983 |
| - | |
984 |
| - | |
985 |
| - | |
986 |
| - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
987 | 1003 |
| |
988 |
| - | |
| 1004 | + | |
989 | 1005 |
| |
990 | 1006 |
| |
991 |
| - | |
| 1007 | + | |
992 | 1008 |
| |
993 |
| - | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
994 | 1014 |
| |
995 |
| - | |
| 1015 | + | |
| 1016 | + | |
996 | 1017 |
| |
| 1018 | + | |
997 | 1019 |
| |
998 | 1020 |
| |
999 | 1021 |
| |
1000 |
| - | |
| 1022 | + | |
1001 | 1023 |
| |
1002 | 1024 |
| |
1003 | 1025 |
| |
|
0 commit comments
Comments
(0)