Greg Stark <gsstark@mit.edu> writes:
> I guess arrays must be some deep voodoo. [] doesn't show up in the list of
> operators. I would be happy if there was at least some way to trick the parser
> into doing the right thing. I'm surprised something like this doesn't work:
> slo=> select (b[0])[0] from t;
> ERROR: parser: parse error at or near "[" at character 14
Yeah, that was my first thought too. It might not be difficult to make
it work --- there's no production in gram.y to accept this, but if there
were then I think that the rest of the code would do the right thing.
> If [] were a normal operator then other datatypes could define operations
> similar to point and box, but I imagine it's the way it is for some good
> reason in the parser level.
You can make arrays of whatever datatype you want. The issue here
is just that there's a syntactic ambiguity between subscripting an
N-dimensional array and subscripting the element datatype of an
N-1-dimensional array ...
regards, tom lane