Re: [HACKERS] [PATCH] Generic type subscripting - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: [HACKERS] [PATCH] Generic type subscripting |
Date | |
Msg-id | 846.1515629363@sss.pgh.pa.us Whole thread Raw |
In response to | Re: [HACKERS] [PATCH] Generic type subscripting (Andres Freund <andres@anarazel.de>) |
Responses |
Re: [HACKERS] [PATCH] Generic type subscripting
|
List | pgsql-hackers |
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
pgsql-hackers by date: