Re: [HACKERS] [PATCH] Generic type subscripting
Tom Lane <tgl@sss.pgh.pa.us>
Andres Freund <andres@anarazel.de> writes: > You might not love me for this suggestion, but I'd like to see the > renaming here split from the rest of the patch. There's a lot of diff > that's just more or less automatic changes, making it hard to see the > actual meaningful changes. Yeah, I'm beginning to wonder if we should do the renaming at all. It's useful for being sure we've found everyplace that needs to change ... but if lots of those places don't actually need more than the name changes, maybe it's just make-work and code thrashing. There's a set of other issues that are starting to bother me. Perhaps it's not in this patch's charter to resolve them, but I think we need to figure out whether that's true. It's a bit hard to explain clearly, but let me see how well I can state these: * The complaint I had about the "container" terminology isn't just terminology. Rather, there is a bunch of knowledge in the system that some data types can be found embedded in other types; for one example, see find_composite_type_dependencies. In the case of standard arrays, it's clear that the array type does contain its element type in this sense, and we'd better be aware of that in situations such as applying DDL that changes the element type. It's much less clear what it means if you say that type X has a subscripting function that yields type Y. I think the issue can be ignored as long as Y is not a type mutable by any provided DDL commands, but is that OK as a permanent restriction? If not, do we need to do anything about it in the v1 patch? If we don't, do we need to enforce some restriction on what Y can be for types other than true arrays? * There are other identifiable array-specific behaviors that people might expect a generic subscripting feature to let them into. For example, if we allow JSONB to be subscripted to obtain TEXT, does that mean a polymorphic function f(x anyarray) should now match JSONB? It's even more fun if you decide that subscripting JSONB should yield JSONB, which is probably a more useful definition than TEXT really. Then ANYARRAY and ANYELEMENT would need to be the same type, which is likely to blow holes in the polymorphic type code, though I've not looked closely for problems. In the same vein, if JSONB is subscriptable, should "x = ANY(y)" work for y of type JSONB? I'm not actually sure that we'd want these sorts of things to happen, even as follow-on extensions. For instance, a polymorphic function f(x anyarray) would very likely think it can apply array_dims(x) or iterate from array_lower(x,1) to array_upper(x,1). Providing it a subscripting function won't get you far if the subscripts aren't consecutive integers. * There's an awful lot of places in the backend that call get_element_type or get_base_element_type or type_is_array or type_is_array_domain, and aren't touched by the patch as it stands. Some of them might represent dependencies that we need to worry about that don't fall under either of the above categories. So just touching the places that mess with ArrayRef isn't getting us real far in terms of being sure we've considered everything that needs considering. regards, tom lane
Commits
-
Throw error when assigning jsonb scalar instead of a composite object
- aa6e46daf530 14.0 landed
-
Filling array gaps during jsonb subscripting
- 81fcc72e6622 14.0 landed
-
Implementation of subscripting for jsonb
- 676887a3b0b8 14.0 landed
-
Allow ALTER TYPE to update an existing type's typsubscript value.
- 8c15a297452e 14.0 landed
-
Allow subscripting of hstore values.
- 0ec5f7e78231 14.0 landed
-
Support subscripting of arbitrary types, not only arrays.
- c7aba7c14efd 14.0 landed
-
jit: Reference function pointer types via llvmjit_types.c.
- df99ddc70b97 14.0 landed
-
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.
- c0549cee07ea 13.2 landed
- 62ee70331336 14.0 landed
- 3470caa21bf8 10.16 landed
- 2f1997b1551a 12.6 landed
- 1f229f4fdcf8 11.11 landed
- 17c77c8c90f7 9.6.21 landed
-
jit: Correct parameter type for generated expression evaluation functions.
- 5da871bfa1ba 14.0 landed
- 1e16ad101459 11.11 landed
- 27b57f806dc2 12.6 landed
- 01c6370a32e5 13.2 landed
-
Renaming for new subscripting mechanism
- 558d77f20e4e 12.0 landed
-
Fix assertion failure for SSL connections.
- ab69ea9feeb9 12.0 cited
-
Teach eval_const_expressions() to handle some more cases.
- 3decd150a2d5 11.0 cited