[MDEV-7535] query the metadata of a dynamic column Created: 2015-02-01 Updated: 2015-11-17 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Dynamic Columns |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Golubchik | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The set of SQL functions for dynamic columns is missing a way to query the metadata of a dynamic column. Like, what type a particular column has, number of columns, and so on. There can also be a function to return both the value and a type as an SQL-compatible cast:
|
| Comments |
| Comment by Tom [ 2015-02-01 ] | |||||||||||
|
I think this is nice for completeness but is probably not very practical. I work with the Yii 2.0 Active Record ORM. This ORM has no configuration. It reads a table description from the server and uses it to relate object properties with table column names, datatypes and values. My work attempts to extend this ORM to dynamic columns yii2-dynamic-ar and has three main parts:
2. is the hardest because, unlike normal columns, the ORM doesn't know anything about the content of dyncol_blobs. COLUMN_JSON() is convenient because it can load the whole dyncol_blob at once. But if I rely on it then I have to avoid using BINARY in a dynamic column (JSON can represent only valid Unicode strings) and avoid non-Unicode column names. Let's see how could I use COLUMN_GET_SQL() to overcome this limitation... First the ORM would use COLUMN_LIST() to get dynamic column names. In the next query, it would use a number of COLUMN_GET_SQL() expressions to load datatypes and values. COLUMN_GET_SQL() would somehow indicate if a dynamic column itself contains a dyncol_blob, in which case the ORM makes two more queries to load first the names and then the types/values, and it keeps iterating like this down the data structure tree until it has everything. You can imagine how I don't think this is very practical. Alternatives:
I like the 2. best. 1. requires me to write an SQL parser. 3. Requires standardizing (and probably versioning) the internal blob encoding. 4. is radical. 2 uses current protocols and is easy to live with. Perhaps:
|