Archive

Archive for July, 2011

Drizzle support for phpMyAdmin – week 10

July 31st, 2011 No comments

Long story short – I decided to change my task for this week and write a database interface library working with Drizzle PHP module. After fighting with multiple segmentation faults and working around some of them I pushed working code to my repository. Longer version is below, maybe it will help someone to get started with Drizzle + PHP.

After some more thinking about my task for this week I decided to change it and implement database interface module for Drizzle, so I would have a lot of time to improve it and fix bugs while working on other features. So, I started googling for any information on Drizzle PHP extension and found out that there is currently no documentation available, but fortunately there is one old blog post on Zend Developer Zone (Getting started with Drizzle) and an example of usage provided with the extension itself (drizzle.php). Unfortunately getting the module to work on Windows would be too time consuming, so I had to compile it in my virtual machine (hint – broken build against drizzle PPA bug has information on how to quickly fix configure to work). After all the downloading, installing and compiling was done I could start working on my code.

At first I digged for more information on PHP module’s interface with the nice php --re drizzle command and some reflection code that I wrote:

<?php
function printMethod(ReflectionMethod $method) {
    if ($method->isStatic()) echo '<tt>static</tt> ';
    echo '<b>' . ($method->returnsReference() ? '&' : '') . $method->getName() . '</b>';
    echo ' ( ';
    foreach ($method->getParameters() as $par) {
        /* @var $par ReflectionParameter */
        if ($par->getPosition() > 0) echo ' , ';
        if ($par->isOptional()) echo '<u>';
        echo $par->getClass() . ' ';
        echo '<i>' . ($par->isPassedByReference() ? '&' : '') . '$' . $par->getName() . ($par->isArray() ? '[]' : '') . '</i>';
        if ($par->allowsNull()) {
            echo ' null ';
        }
        if ($par->isDefaultValueAvailable()) {
            echo ' = ';
            var_dump($par->getDefaultValue());
        }
        if ($par->isOptional()) echo '</u>';
    }
    echo ' ) ';
}

function printClass($c)
{
    $rf = new ReflectionClass($c);
?>
<h1><?=$c?></h1>
<div>
    <b>Constants</b>
    <ul>
    <?php foreach ((array)$rf->getConstants() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Default properties</b>
    <ul>
    <?php foreach ((array)$rf->getDefaultProperties() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Properties</b>
    <ul>
    <?php foreach ((array)$rf->getProperties() as $v): ?>
        <li><?php print_r($v) ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<div>
    <b>Constructor</b>
    <ul><li><?php printMethod($rf->getConstructor()) ?></li></ul>
</div>
<div>
    <b>Methods</b>
    <ul>
    <?php foreach ((array)$rf->getMethods() as $v): ?>
        <li><?php printMethod($v); ?></li>
    <?php endforeach; ?>
    </ul>
</div>
<?
}

echo '<hr />';

printClass('Drizzle');
echo '<hr />';
printClass('DrizzleCon');
echo '<hr />';
printClass('DrizzleQuery');
echo '<hr />';
printClass('DrizzleResult');
echo '<hr />';
printClass('DrizzleColumn');

After a few hours I had some code for tests, and then the real trouble began – segmentation faults, in various places and configurations. I was able to get my code to work without crashing PHP in the middle of script processing, but I decided to ignore crashes which happen at shutdown and added some code which hides this problem (flushing on shutdown). While trying to get around it I gathered some information and use cases which later went to PHP module’s bugtracker, so hopefully someday it will get fixed.

The code is in my GIT repository and mostly works, but it’s not ready for use in stable version of phpMyAdmin due to instability of PHP module. For now the code crashes PHP on most pages and has a lot of logging which gives some insight into interaction with drizzle module.

During the next week I will go on with my work on database synchronize.

Categories: phpMyAdmin, Summer of Code 2011 Tags:

Drizzle support for phpMyAdmin – week 9

July 25th, 2011 No comments

This week I worked on getting data import functions of phpMyAdmin to work with Drizzle. After making a few changes everything started to behave correctly, and I had some time for minor changes in master branch.

I didn’t have much time for coding as I was moving to a new flat, and of top of that my computer refused to cooperate and forced me to reinstall everything from scratch. Now I am mostly moved and finishing with my computer’s setup.

During the next week I plan to look at database synchronize feature which I should be able to make work with Drizzle. I am not sure about MySQL <> Drizzle scenario, but I hope to have Drizzle <> Drizzle setup working. I saw a few suspicious warnings from my IDE that concern files related to this feature, so it’s very likely that some changes will go to master too.

Categories: phpMyAdmin, Summer of Code 2011 Tags:

Drizzle support for phpMyAdmin – week 8

July 17th, 2011 No comments

This week I looked at export plugins. At first, I started looking at code in master and changed all SHOW FIELDS queries to my new PMA_DBI_get_columns function. Aside from that, I fixed two bugs:

  • XML plugin couldn’t export any structure,
  • CodeGen couldn’t export table definitions,
  • JSON plugin generated invalid code when table was empty.

Having taken care of these, I improved CodeGen which now tries to convert column name to valid C# identifiers.

After merging these changes with my branch I took care of proper SQL export for Drizzle and took care of all remaining code that was incompatible with Drizzle. Other, smaller changes introduced during this week were:

  • ignore SkipLockedTables option for Drizzle,
  • remove SOUNDEX from supported functions – Drizzle documentation states that it is supported but apparently that’s a mistake,
  • some other small changes.

Drizzle bugs for this week:

During next week I plan to take a look at import plugins.

Categories: phpMyAdmin, Summer of Code 2011 Tags:

Drizzle support for phpMyAdmin – week 7

July 10th, 2011 No comments

During this week I finished looking at table creation, column editing and row insertion forms – all of these should now work correctly with Drizzle. As I mentioned last week, I changed the way MySQL column types are defined so that I was able to add data for Drizzle in a clean way.

Aside from that I made a few fixes in master branch and added a new view for Drizzle Plugin list – now it has a nice list of plugins grouped by plugin type.

Next week I want to concentrate on database and table export.

Categories: phpMyAdmin, Summer of Code 2011 Tags:

Drizzle support for phpMyAdmin – week 6

July 3rd, 2011 No comments

This week I finished checking Operations and Search tabs, so these should now work correctly with Drizzle. After getting that finished, I started looking into some MySQL specific configuration variables that contain MySQL column types and list of functions usable in Insert form. Some work on that is already committed, but I intend to revert this work and proceed with a more clean solution – at first reorganize some phpMyAdmin code in master branch and then proceed to add Drizzle-specific changes to my branch:

  1. move some settings out of config.default.php (AttributeTypes, Functions, RestrictColumnTypes, RestrictFunctions) into a separate file,
  2. load this file only on demand,
  3. introduce a separate data file for Drizzle.

1. and 2. will be committed to master branch while the last point will be done only in my drizzle branch.

Now, this week’s Drizzle bugs 🙂

During next week I want to finish refactoring phpMyAdmin code as I described above and take a look at table creation, column edition and data insert forms.

Categories: phpMyAdmin, Summer of Code 2011 Tags: