Planet Midgard: Archive
2008-04-30 - 2008-05-30
MySQL doesn't support TEXT type
Posted on 2008-05-08 12:46:56 GMT.
Yes, it does not. But you could say:
- "oh no, Piotras, it does, please read this part of manual"
Oh, yes indeed. They mention "The four TEXT types", but it doesn't seem to help me even a bit. Why? Bergie and Solt reported quite weird issue. Text value ( text type in database ) has been returned as array on PHP bindings for Midgard.
I started to investigate it from the very beginning, to catch why text type becomes an array:
- Parameter class has value member of longtext type.
- Database column for this property has longtext column type.
- GDA library with MySQL provider uses MySQL column types to determine what value should be initialized on C level.
- GDA gets BLOB type.
- GDA initializes its own GdaBinary type( GdaBinary is GBoxed derived type ).
- PHP bindings for midgard and especially GValue and zval converter gets boxed type.
- We support only array type of gboxed one so zend array is initialized and returned.
Not easy to fetch at first glance, isn't it?
I was wondering and checked GDA sources ,and indeed MySQL provider implementation is not aware of something like TEXT or LONGTEXT. Later on I checked MySQL's headers and supported column types.
So, there is support for strings (char and varchar):
- MYSQL_TYPE_VAR_STRING
- MYSQL_TYPE_STRING
And for blobs:
- MYSQL_TYPE_TINY_BLOB
- MYSQL_TYPE_MEDIUM_BLOB
- MYSQL_TYPE_LONG_BLOB
- MYSQL_TYPE_BLOB
And what about TEXT and LONGTEXT? And what about those 4 mentioned text types? Nothing. There's completely nothing. How can I know if retrieved data is binary or text type then? Use randomized type? Maybe for you blob type is the same as longtext, but for me plain text book stored in field is quite different thing than compressed image file.
