maria-discuss team mailing list archive
Mailing list archive
Re: The future of Dynamic Columns
On 28.01.15 23:01, Tom Worster wrote:
While functions for getting and setting via json might be useful, I
think they are peripheral to the core datatype problem here.
AFAIK we lack only boolean type and arrays (could be emulated now but
you can't say if it is array or object with numeric keys) to fit json types.
The interface to dynamic columns in Maria is SQL. The internal
datatypes are SQLish. We can be completely sure of what was set, in
SQL terms, by a COLUMN_CREATE(). But if we use a JSON getter then we
might get something different because JSON datatypes don't match SQL
datatypes. Sometimes it's no problem but not in general -- depends on
the datatypes involved and the application's tolerance of differences.
column_create/alter do not require type (detect automatically), so type
there can be mentioned to enforce some encoding you want (store dates as
dates but not string)
column_get() require type of output, if you do not care use CHAR. But
this is required by SQL expression implementation. There is json output
which do not need type of columns.
What's missing is a getter that tells us the value and datatype of a
dynamic column, a getter that tells us what was set.
What if we had a getter that returns a string like:
>> "CAST(123.456 AS DECIMAL(11,3))"
And Maria promises us that we could use that expression to write the
value back and the result will be the exact same thing. A sort of
idempotency promise (kinda).
This doesn't make the interface any less clunky (on the contrary) but
I have resigned myself to a clunky interface. The only alternative is
to forget all this and start something different. SQL is an insanely
clunky old language and that's why we use some kind of abstraction
software to make it nicer. If we're going to use SQL we may as well
try to use what's there.
Something like this COLUMN_GET_SQL() would at least allow the
application the possibility to get back what it put in.
I am not sure that I understand what you need. Is it ability to know
internal storage type?