Hi, > This looks pretty good to me. The only point that I think deserves more > discussion is the return type. Does bytea make the most sense here? Or > should we consider int/bigint?
Personally I would choose BYTEA in order to be consistent with sha*() functions. It can be casted to TEXT if user wants a result similar to the one md5() returns: ``` SELECT encode(crc32('PostgreSQL'), 'hex'); ``` ... and somewhat less convenient to BIGINT: ``` SELECT ((get_byte(crc, 0) :: bigint << 24) | (get_byte(crc, 1) << 16) | (get_byte(crc, 2) << 8) | get_byte(crc, 3)) FROM (SELECT crc32('PostgreSQL') AS crc); ``` I don't like the `integer` option because crc32 value is typically considered as an unsigned one and `integer` is not large enough to represent uint32. Perhaps we need get_int4() / get_int8() / get_numeric() as there seems to be a demand [1][2] and it will allow us to easily cast a `bytea` value to `integer` or `bigint`. This is probably another topic though. [1]: https://stackoverflow.com/questions/32944267/postgresql-converting-bytea-to-bigint [2]: https://postgr.es/m/AANLkTikip9xs8iXc8e%2BMgz1T1701i8Xk6QtbVB3KJQzX%40mail.gmail.com -- Best regards, Aleksander Alekseev