public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dean Rasheed <[email protected]>
To: [email protected]
Subject: pgsql: Allow casting between bytea and integer types.
Date: Fri, 07 Mar 2025 09:35:16 +0000
Message-ID: <[email protected]> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6da469badaffec32f8a804181cca279561467378

Modified Files
--------------
doc/src/sgml/func.sgml                   |  17 ++++++
src/backend/utils/adt/varlena.c          |  96 +++++++++++++++++++++++++++++
src/include/catalog/catversion.h         |   2 +-
src/include/catalog/pg_cast.dat          |  14 +++++
src/include/catalog/pg_proc.dat          |  19 ++++++
src/test/regress/expected/opr_sanity.out |   3 +
src/test/regress/expected/strings.out    | 102 +++++++++++++++++++++++++++++++
src/test/regress/sql/strings.sql         |  29 +++++++++
8 files changed, 281 insertions(+), 1 deletion(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Allow casting between bytea and integer types.
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox