Monday, July 30, 2012

GSoC 2012 - 10th Week Progress

        This is my 10th week of GSoC 2012 project. In last week I implemented support for displaying results for multiple SQL query statements and stored routines with multiple queries. SQL query window can be used to both cases above.

      There were some issues in my previous code. So I first moved into fix one issue. It takes bit more time to fix it than I thought.

Then I moved into next feature implementation. Mainly there were two parts in this feature.
1. Syntax highlighting for SQL in PROCESSLIST table in information_schema database
2. Relations inside mysql database

         For the first task, I used a new public property inside PMA_DisplayResults class which contains all the details of columns which need to be apply syntax highlight effect. So that any other table field also can use this feature. Now the SQL field is syntax highlighted in PROCESSLIST table.

                 Second task is not related to actual relations with foreign keys, it means just link data rows to corresponding pages where possible. As an example, User column of db table in mysql database, can be linked to edit user privileges of corresponding user according to the User column value. A new file called mysql_schema_relation.lib.php has introduced which have a global variable with all the column information of tables which needs to be display as links where possible. From each element of this variable (array), one link can be generated.

$GLOBALS['mysql_schema_relation'] = array(
    'db' => array(        // db table in mysql schema
        'db' => array(    // Db column in db table
            // link_params array contains the get params,
            // if array element is string, value of parameter is set as column value
            // if any of array element is array, url param is the first data of the array and value is second data of the array
            'link_params' => array('db'),
            // This represent the page to link
            'default_page' => 'index.php'
        ),

        'user' => array(    // User column of db table
            'link_params' => array('username'),
            'default_page' => 'server_privileges.php'
        )
    ),

    'proc' => array(
        'db' => array(
            'link_params' => array('db'),
            'default_page' => 'index.php'
        )
    ),

);

    Above array is represented as lowercase string array. So when comparing the strings those need to be convert to lowercase. (strtolower() function can be used.)

            Now there can be see several links inside mysql schema. In my next week I'll implement the feature, linking from information_schema to phpmyadmin schema.

Monday, July 23, 2012

GSoC 2012 - 9th Week Progress

        In last week I did some improvements in PMA_DisplayResults class and in test cases. This week I moved into implementation of a feature request. Its on display results for the multiple queries.

         Multiple query execution can be done by using routines ( stored procedures and stored functions) or just executing SQL statement with multiple queries at once. In PMA those could be done by using SQL query window or using routines tab under any table.

          PMA was not supported for executing multiple queries using the SQL query window. While executing it shows the results for the last single query in the multiple SQL statement. That was due to use of mysql_query() function for any case. Since mysql extension is currently not support for the multiple query execution I used mysqli_multi_query() function under mysqli extension. It returns multiple result sets depending on the executed SQL statement. By iterating through the results I displayed this resulted tables in the same page in top to bottom manner. And I made it with very limited operations on the results in same page. Unless it becomes more complex and hard to handle the code. Currently there are two known issue.

1. After executing insert/ edit/ delete query using the query window, page does not show the query window back.
2. After executing multi query SQL statement, browse any table gives notices and some errors.

        After those modifications I moved into routines. That was very cool feature in PMA. But it was not complete. For any routine it shows only one row from only one table. So I improve the behaviour of that feature to return expected outcome according to the routine. Now it shows even multiple results sets with all the needed rows.

        In next week I try to fix those issues in SQL execution mode. And I'll implement new inline transformations for PMA as the next feature implementation.

Monday, July 16, 2012

GSoC 2012 - 8th Week Progress

       I'm pretty sure that most of the GSoCers are very happy in the 8th week of their GSoC project. Because of the happiness of gone through the mid evaluation. In last week I break some functions into more sub functions and introduce global variables (class variables) and __get, __set magic methods for PMA_DisplayResults class with the suggestion of Michal. As well some improvements in tests also done.

         According to last week modifications in PMA_DisplayResults class, initialization of the global variables in that class were done inside getTable() method. But as suggested from Michal, I did that initialization part in a separate method called setProperties() and call that function from the sql.php file just before call the getTable() method.

                          As well I found a issue with my code with the print view screen. I fix those issues both in vertical display mode and horizontal display mode. Then I move into improve unit tests. There were several errors in tests related to PMA_DisplayResults class due to my recent changes. The problem was, needed property values were not set at the run time of tests. I modified those tests to set those properties using magic __set() method. But that was not worked. After searching this issue, I found that, there is a problem with using php property_exists() method is not properly working with the magic methods. So that I introduce a new property $_property_array which contains all the previous properties except $_common_functions. Then I remove previous properties which represent in $_property_array and use php array_key_exists() method inside magic methods.

           It takes lot of time to run the all tests in PMA. So that I try to run tests with individual file by giving arguments in command line. But it gives errors again and again due to missing required files and undefined variables, constants etc. After that, I edit phpunit.xml.dist file in order to just run the needed file. With that modification I could run those tests quickly. At the moment previous errors in tests related to PMA_DisplayResults class were fixed.

            In next week I'll move into start the work I suggested after mid evaluation. I'll start implementation of display multiple query results.

Monday, July 9, 2012

GSoC 2012 - 7th Week Progress

       This is seventh week of the GSoC 2012 projects. As well this week we need to submit our mid evaluation. So this is a key point of GSoC 2012. Last week I merge the code with master which had Alex's major changes related to his project. And did some modifications regarding mime default function. As well I started to write tests for PMA_DisplayResults class.

       In this week I continued writing tests for PMA_DisplayResults class. While those improvements Michal assign me another two tasks.

1. Reduce the large number of parameters passing to functions in PMA_DisplayResults class by storing the variable states inside the class itself

2. Break some functions to more small functions

          So, first I did the 2nd task. With that I introduce several sub functions by breaking _getTableHeaders(), _getTableBody() and getTable() functions.

        Then I moved into 1st task. I stored the commonly used fields as private properties of the class. There are around 25 private fields in that class now. Since those properties are not initialized when creating the object of this class, most of them were initialized inside the getTable() function.

         After I again moved into improving tests. At this point most of the existed tests were failed with the new changes. So I introduce __get() and __set() method for access any private field in PMA_DisplayResult class by out side. Then I use those functions to set private properties while improving tests. But still the failures are remaining in some tests. Apart from that setCommonFunctions() function was removed from PMA_DisplayResults class due not use of that method.

          In next week I'll continue test cases as much a possible. But before that I'll do some modifications to PMA_DisplayResults class which was suggested by Michal recently.

Monday, July 2, 2012

GSoC 2012 - 6th Week Progress

     In last week I almost finish the implementing class behavior of PMA_CommonFunctions.class.php but not committed due to some conflicts while merging the code to with master branch.

         In this week also I got lots of conflicts while merging the code. Since the functions inside PMA_CommonFunctions class (in master common.lib.php file)  were used in many places over the PMA the possibility of occurring a conflict is high. With the merge of Alex's code I again got many conflicts. As well I had to do more modifications because Alex has introduced several new files and they have used the functions in common.lib.php . After did those modifications I committed the code with 4 known issues in master. At the moment two are already fixed in master branch. Others are,

1. When the session expires, after click logout I get following notice,
Notice in ./libraries/relation.lib.php#35
Undefined index: controllink

2. When incorrect login, following warning raised, 
Warning in ./libraries/dbi/mysqli.dbi.lib.php#97
mysqli_real_connect(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES)

         After that I moved into finding the possibility of using PMA_mimeDefaultFunction() function which is currently inside the core.lib.php file as a global function, inside the PMA_DisplayaResults class. This function is only used by the functions in PMA_DisplayResults class indirectly with the help of a variable. I moved the PMA_mimeDefaultFunction() function from core.lib.php file to PMA_DisplayResults class and renamed as _mimeDefaultFunction(). The places where calls this function indirectly were modified by adding '$this->' suffix ($default_function = '_mimeDefaultFunction'; $this->$default_function()).

          After those improvements I moved into implement tests for the functions in PMA_DisplayResults class. Yasitha has already implemented some tests for some functions. I started to continue that work and finished some tests.

         In next week as the major task I'm intending to implement tests for remaining functions in PMA_DisplayResults class. If possible I'll be do some minor improvements in PMA_CommonFunction.class.php