-
- Downloads
Switch to CRC-32C in WAL and other places.
The old algorithm was found to not be the usual CRC-32 algorithm, used by Ethernet et al. We were using a non-reflected lookup table with code meant for a reflected lookup table. That's a strange combination that AFAICS does not correspond to any bit-wise CRC calculation, which makes it difficult to reason about its properties. Although it has worked well in practice, seems safer to use a well-known algorithm. Since we're changing the algorithm anyway, we might as well choose a different polynomial. The Castagnoli polynomial has better error-correcting properties than the traditional CRC-32 polynomial, even if we had implemented it correctly. Another reason for picking that is that some new CPUs have hardware support for calculating CRC-32C, but not CRC-32, let alone our strange variant of it. This patch doesn't add any support for such hardware, but a future patch could now do that. The old algorithm is kept around for tsquery and pg_trgm, which use the values in indexes that need to remain compatible so that pg_upgrade works. While we're at it, share the old lookup table for CRC-32 calculation between hstore, ltree and core. They all use the same table, so might as well.
Showing
- contrib/hstore/Makefile 1 addition, 1 deletioncontrib/hstore/Makefile
- contrib/hstore/crc32.c 0 additions, 106 deletionscontrib/hstore/crc32.c
- contrib/hstore/crc32.h 0 additions, 13 deletionscontrib/hstore/crc32.h
- contrib/hstore/hstore_gist.c 15 additions, 1 deletioncontrib/hstore/hstore_gist.c
- contrib/ltree/crc32.c 21 additions, 93 deletionscontrib/ltree/crc32.c
- contrib/pg_trgm/trgm_op.c 3 additions, 3 deletionscontrib/pg_trgm/trgm_op.c
- src/backend/access/transam/twophase.c 12 additions, 12 deletionssrc/backend/access/transam/twophase.c
- src/backend/access/transam/xlog.c 25 additions, 25 deletionssrc/backend/access/transam/xlog.c
- src/backend/access/transam/xlogreader.c 6 additions, 6 deletionssrc/backend/access/transam/xlogreader.c
- src/backend/replication/logical/snapbuild.c 14 additions, 14 deletionssrc/backend/replication/logical/snapbuild.c
- src/backend/replication/slot.c 10 additions, 10 deletionssrc/backend/replication/slot.c
- src/backend/utils/adt/tsgistidx.c 3 additions, 3 deletionssrc/backend/utils/adt/tsgistidx.c
- src/backend/utils/adt/tsquery.c 6 additions, 6 deletionssrc/backend/utils/adt/tsquery.c
- src/backend/utils/cache/relmapper.c 8 additions, 8 deletionssrc/backend/utils/cache/relmapper.c
- src/bin/pg_controldata/pg_controldata.c 6 additions, 6 deletionssrc/bin/pg_controldata/pg_controldata.c
- src/bin/pg_resetxlog/pg_resetxlog.c 15 additions, 15 deletionssrc/bin/pg_resetxlog/pg_resetxlog.c
- src/include/access/xlog_internal.h 1 addition, 1 deletionsrc/include/access/xlog_internal.h
- src/include/catalog/catversion.h 1 addition, 1 deletionsrc/include/catalog/catversion.h
- src/include/utils/pg_crc.h 79 additions, 14 deletionssrc/include/utils/pg_crc.h
- src/include/utils/pg_crc_tables.h 74 additions, 3 deletionssrc/include/utils/pg_crc_tables.h
Loading
Please register or sign in to comment