pgsql: Rationalize the APIs of array element/slice access functions. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Rationalize the APIs of array element/slice access functions.
Date
Msg-id E1YNPOw-0002u2-Di@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Rationalize the APIs of array element/slice access functions.

The four functions array_ref, array_set, array_get_slice, array_set_slice
have traditionally declared their array inputs and results as being of type
"ArrayType *".  This is a lie, and has been since Berkeley days, because
they actually also support "fixed-length array" types such as "name" and
"point"; not to mention that the inputs could be toasted.  These values
should be declared Datum instead to avoid confusion.  The current coding
already risks possible misoptimization by compilers, and it'll get worse
when "expanded" array representations become a valid alternative.

However, there's a fair amount of code using array_ref and array_set with
arrays that *are* known to be ArrayType structures, and there might be more
such places in third-party code.  Rather than cluttering those call sites
with PointerGetDatum/DatumGetArrayTypeP cruft, what I did was to rename the
existing functions to array_get_element/array_set_element, fix their
signatures, then reincarnate array_ref/array_set as backwards compatibility
wrappers.

array_get_slice/array_set_slice have no such constituency in the core code,
and probably not in third-party code either, so I just changed their APIs.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e983c4d1aa42d613542cf222e222b034918374b1

Modified Files
--------------
src/backend/executor/execQual.c      |  112 +++++++++++-------------
src/backend/rewrite/rewriteHandler.c |    2 +-
src/backend/utils/adt/arrayfuncs.c   |  158 ++++++++++++++++++++++------------
src/include/utils/array.h            |   21 +++--
src/pl/plpgsql/src/pl_exec.c         |   29 +++----
5 files changed, 180 insertions(+), 142 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: Correct the path of pg_lzcompress.c in doc.
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: In the SSL test suite, use a root CA cert that won't expire (so