Allow casting between bytea and integer types.
authorDean Rasheed <[email protected]>
Fri, 7 Mar 2025 09:31:18 +0000 (09:31 +0000)
committerDean Rasheed <[email protected]>
Fri, 7 Mar 2025 09:31:18 +0000 (09:31 +0000)
commit6da469badaffec32f8a804181cca279561467378
tree7d0ab3f88e0eec27a9377e53901a720d8b0e1403
parentd611f8b1587b8f30caa7c0da99ae5d28e914d54f
Allow casting between bytea and integer types.

This allows smallint, integer, and bigint values to be cast to and
from bytea. The bytea value is the two's complement representation of
the integer, with the most significant byte first. For example:

  1234::bytea -> \x000004d2
  (-1234)::bytea -> \xfffffb2e

Author: Aleksander Alekseev <[email protected]>
Reviewed-by: Joel Jacobson <[email protected]>
Reviewed-by: Yugo Nagata <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Reviewed-by: Dean Rasheed <[email protected]>
Discussion: https://postgr.es/m/CAJ7c6TPtOp6%2BkFX5QX3fH1SVr7v65uHr-7yEJ%3DGMGQi5uhGtcA%40mail.gmail.com
doc/src/sgml/func.sgml
src/backend/utils/adt/varlena.c
src/include/catalog/catversion.h
src/include/catalog/pg_cast.dat
src/include/catalog/pg_proc.dat
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/strings.out
src/test/regress/sql/strings.sql