postgresql/src/backend
Tom Lane c7aba7c14e Support subscripting of arbitrary types, not only arrays.
This patch generalizes the subscripting infrastructure so that any
data type can be subscripted, if it provides a handler function to
define what that means.  Traditional variable-length (varlena) arrays
all use array_subscript_handler(), while the existing fixed-length
types that support subscripting use raw_array_subscript_handler().
It's expected that other types that want to use subscripting notation
will define their own handlers.  (This patch provides no such new
features, though; it only lays the foundation for them.)

To do this, move the parser's semantic processing of subscripts
(including coercion to whatever data type is required) into a
method callback supplied by the handler.  On the execution side,
replace the ExecEvalSubscriptingRef* layer of functions with direct
calls to callback-supplied execution routines.  (Thus, essentially
no new run-time overhead should be caused by this patch.  Indeed,
there is room to remove some overhead by supplying specialized
execution routines.  This patch does a little bit in that line,
but more could be done.)

Additional work is required here and there to remove formerly
hard-wired assumptions about the result type, collation, etc
of a SubscriptingRef expression node; and to remove assumptions
that the subscript values must be integers.

One useful side-effect of this is that we now have a less squishy
mechanism for identifying whether a data type is a "true" array:
instead of wiring in weird rules about typlen, we can look to see
if pg_type.typsubscript == F_ARRAY_SUBSCRIPT_HANDLER.  For this
to be bulletproof, we have to forbid user-defined types from using
that handler directly; but there seems no good reason for them to
do so.

This patch also removes assumptions that the number of subscripts
is limited to MAXDIM (6), or indeed has any hard-wired limit.
That limit still applies to types handled by array_subscript_handler
or raw_array_subscript_handler, but to discourage other dependencies
on this constant, I've moved it from c.h to utils/array.h.

Dmitry Dolgov, reviewed at various times by Tom Lane, Arthur Zakirov,
Peter Eisentraut, Pavel Stehule

Discussion: https://postgr.es/m/CA+q6zcVDuGBv=M0FqBYX8DPebS3F_0KQ6OVFobGJPM507_SZ_w@mail.gmail.com
Discussion: https://postgr.es/m/CA+q6zcVovR+XY4mfk-7oNk-rF91gH0PebnNfuUjuuDsyHjOcVA@mail.gmail.com
2020-12-09 12:40:37 -05:00
..
access Avoid using tuple from syscache for update of pg_database.datfrozenxid 2020-12-08 12:13:19 +09:00
bootstrap Fix some stray whitespace in parser files 2020-11-11 17:37:18 +01:00
catalog Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
commands Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
executor Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
foreign Small code simplifications 2020-12-03 11:44:13 +01:00
jit Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
lib Use pg_bitutils for HyperLogLog. 2020-07-30 09:14:23 -07:00
libpq Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
main Remove -o option to postmaster 2020-11-10 13:15:01 +01:00
nodes Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
optimizer Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
parser Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
partitioning Do not return NULL for error cases in satisfies_hash_partition(). 2020-11-16 16:39:59 -05:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Fix -Wcast-function-type warnings on Windows/MinGW 2020-10-21 08:17:51 +02:00
postmaster Speed up rechecking if relation needs to be vacuumed or analyze in autovacuum. 2020-12-08 23:59:39 +09:00
regex Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
replication Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
rewrite Improve wording of two error messages related to generated columns. 2020-11-23 11:15:12 -05:00
snowball code: replace most remaining uses of 'master'. 2020-07-08 13:24:35 -07:00
statistics Improve estimation of ANDs under ORs using extended statistics. 2020-12-08 20:10:11 +00:00
storage Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
tcop Refactor CLUSTER and REINDEX grammar to use DefElem for option lists 2020-12-03 10:13:21 +09:00
tsearch Improve behavior of tsearch_readline(), and remove t_readline(). 2020-09-23 20:26:58 -04:00
utils Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00