|Reported by:||jtv||Owned by:||jtv|
Description (last modified by jtv)
At the moment arrays can only be manipulated and queried in SQL, or generated and parsed as text. It would be nice to help users get around the latter if we can.
Container and stream interfaces seem the most appropriate. We'd want to be able to construct input arrays from either a field or a string.
There are a few gotchas:
- Separators between array elements are defined by the contained type. Usually the comma separates elements, but the Box type for example uses a semicolon. It could be anything. We'll have to query that at runtime, and cache the information somehow.
- Arrays can be nested. We'd probably want to check that all elements are arrays (or nulls) before going into deeper nesting levels.
- Quoting of array elements may be awkward--we'd have to have separate "treatments" just like we do for prepared statements.
- How do we specify nulls when creating an array?
- There is no real "end" to an array: there just comes a point where all else is null. On the C++ end we'd probably want more C++-like semantics, setting end() just past the last non-null element. But what if the last element in an array is null? Programs may break if they hit an unexpected end. We'd need more tolerant semantics: X.end()+1==X.end() and X.end()->is_null()==true.
- It would be nice to allow direct array indexing in a result ("r[row][col][i]") but it does complicate the result class a bit further.
- Array lengths aren't enforced by the backend (at least not in 8.2). It's tempting to stick to an array's declared length, but if we do, we must still accept out-of-bounds addressing.
Finally there is the encoding problem in the case of arrays of strings (or arrays of arrays of strings etc.). Parsing a string as an array of strings can go haywire in multibyte encodings that allow byte values equivalent to the closing quote inside a multibyte character. To get around that we'd need to know at least where the character boundaries are--which in turn depends on the encoding being used.
Change History (12)
comment:1 Changed 9 years ago by jtv
- Description modified (diff)
- Status changed from new to assigned
comment:11 Changed 22 months ago by RichardWef
- version set to 3.0