Piotras' blog: Archive

2008-05-01 - 2008-05-31

MySQL doesn't support TEXT type

Posted on 2008-05-08 14:46:56 UTC.

Yes, it does not. But you could say:

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:

  1. Parameter class has value member of longtext type.
  2. Database column for this property has longtext column type.
  3. GDA library with MySQL provider uses MySQL column types to determine what value should be initialized on C level.
  4. GDA gets BLOB type.
  5. GDA initializes its own GdaBinary type( GdaBinary is GBoxed derived type ).
  6. PHP bindings for midgard and especially GValue and zval converter gets boxed type.
  7. 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.

PEAR registry, where are you?

Posted on 2008-05-19 12:19:13 UTC.

I wrote this simple script to clear my local pear setup and to have clean pear instalation for Midgard.

apt-get remove php-pear
rm -rf /usr/share/php/PEAR
rm /root/.pearrc
rm -rf /etc/pear
rm -rf /tmp/pear
apt-get -y install php-pear

So, when I cleaned my pear ,imagine, how much confused I was when I saw this in my terminal:

MIDGARD SETUP: Role_Web - installed: 1.1.1 available: 1.1.1

wtf?

pear list-files pearified/role_web
Installed Files For pearified/role_web
======================================
Type Install Path
php  /usr/share/php/PEAR/Installer/Role/Web.php
php  /usr/share/php/PEAR/Installer/Role/Web.xml
php  /usr/share/php/Pearified/Role/Web/setup.php

ls -l /usr/share/php/PEAR/Installer/Role/Web.php
ls: /usr/share/php/PEAR/Installer/Role/Web.php: No such file or directory

PEAR registry...where are you?

Updated: I found registry and channel files under /usr/share/php. So on debian these two lines must be added additionally:

rm -rf /usr/share/php/.registry 
rm -rf /usr/share/php/.channels

Voices in my head

Posted on 2008-05-19 22:15:37 UTC.

rs.jpg

It was last sunday.  And there are still "Voices in my head". Riverside guys made real show in best studio in Poland, and it's quite obvious as they recorded live DVD at the same time. Probably this DVD is going to be in stores this winter. Damn!  So long time. 

First time I heared them in LizardKing pub in Łódź. It was February, this Year. Since then, I am addicted. There is no single word that can be said about this event. No one seems to want to comment it. Only few of them appears from time to time on different forums: perfect.  

"Join in the shadow dance"

When metadata creator is empty

Posted on 2008-05-23 13:49:48 UTC.

Quite major bug has been found today. 1.8.7 Midgard release doesn't populate metadata_creator guid. Midgard news page has a note about this.

I wrote additional script which should help with database upgrade if needed:

#!/bin/sh

DB="midgard"
MYSQLCMD="/usr/bin/mysql"

THEADER="Tables_in_${DB}"
MIDGARD_TABLES=`$MYSQLCMD -D $DB -e 'show tables' | grep -Ev '(_i\s*\|?\s*$)|repligard|sitegroup|Tables_in_.+'`

for TABLE in $MIDGARD_TABLES; do

    QUERY="UPDATE ${TABLE} SET metadata_creator=REPLACE(metadata_authors, '|' ,'')  WHERE metadata_creator='' AND metadata_authors<>'' AND metadata_authors<>'||' AND LENGTH(metadata_authors) < 39"
    echo "Fixing table: ${TABLE}"
    $MYSQLCMD -D ${DB} -e "${QUERY}"

    echo "Looking for multiple authors"
    QUERY="SELECT guid from ${TABLE} WHERE LENGTH(metadata_authors) > 38 AND metadata_creator='' AND metadata_authors<>'||' AND metadata_authors<>''"
    $MYSQLCMD -D ${DB} -e "${QUERY}"

done

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS