postgresql/src/backend/catalog
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
..
.gitignore Remove separate files for the initial contents of pg_(sh)description 2020-01-19 13:54:58 +02:00
aclchk.c Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
catalog.c Move catalog index declarations 2020-11-07 12:26:24 +01:00
Catalog.pm Clarify coding in Catalog::AddDefaultValues. 2020-02-15 15:13:44 -05:00
dependency.c Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
genbki.pl Don't use custom OID symbols in pg_type.dat, either. 2020-10-29 13:33:38 -04:00
heap.c Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
index.c Provide the OR REPLACE option for CREATE TRIGGER. 2020-11-14 17:05:34 -05:00
indexing.c Use multi-inserts for pg_attribute and pg_shdepend 2020-07-31 10:54:26 +09:00
information_schema.sql Add current substring regular expression syntax 2020-06-29 11:05:00 +02:00
Makefile Move catalog index declarations 2020-11-07 12:26:24 +01:00
namespace.c Fix some grammar and typos in comments and docs 2020-11-02 15:14:41 +09:00
objectaccess.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
objectaddress.c Fix some typos 2020-11-14 11:43:10 +09:00
partition.c Plug memory leak in index_get_partition 2020-11-06 22:52:16 -03:00
pg_aggregate.c Remove useless entries for aggregate functions from fmgrtab.c. 2020-11-04 11:25:56 -05:00
pg_cast.c Update copyright year 2020-09-11 12:55:13 -03:00
pg_collation.c Remove pg_collation.collversion. 2020-11-03 00:44:59 +13:00
pg_constraint.c Track collation versions for indexes. 2020-11-03 01:19:50 +13:00
pg_conversion.c Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
pg_db_role_setting.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_depend.c Change get_constraint_index() to use pg_constraint.conindid 2020-12-09 15:41:45 +01:00
pg_enum.c Fix enum errdetail to mention bytes, not chars 2020-10-27 11:50:18 +01:00
pg_inherits.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_largeobject.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_namespace.c Fix some grammar and typos in comments and docs 2020-11-02 15:14:41 +09:00
pg_operator.c Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
pg_proc.c Fix list-munging bug that broke SQL function result coercions. 2020-10-19 14:33:09 -04:00
pg_publication.c Fix relcache reference leak 2020-04-11 09:44:14 +02:00
pg_range.c Switch to multi-inserts when registering dependencies for many code paths 2020-09-05 21:33:53 +09:00
pg_shdepend.c Use multi-inserts for pg_depend 2020-09-05 13:52:47 +09:00
pg_subscription.c Review logical replication tablesync code 2020-10-15 11:35:51 -03:00
pg_type.c Support subscripting of arbitrary types, not only arrays. 2020-12-09 12:40:37 -05:00
sql_feature_packages.txt Cleanup in SQL features files 2020-03-28 08:46:18 +01:00
sql_features.txt Remove undocumented IS [NOT] OF syntax. 2020-11-19 17:39:39 -05:00
storage.c Extend PageIsVerified() to handle more custom options 2020-10-26 09:55:28 +09:00
system_views.sql Track total number of WAL records, FPIs and bytes generated in the cluster. 2020-12-02 13:00:15 +09:00
toasting.c Move catalog toast table declarations 2020-11-07 12:26:24 +01:00