Monday, August 20, 2012

GSoC 2012 - 13th Week Progress

         This is the last week we interact with the coding and documenting under GSoC 2012 official time line. In my last week I implemented the feature request simple sort for process list. And improved some tests for PMA_DisplayResults class.

                In this week I did some improvements in tests of PMA_DisplayResults class. As the documentation, there were not much things to mention as details in Documentation.html. I only mentioned about the feature of displaying multiple results for queries as well as stored procedures. While I'm implementing the functions phpdoc comments and block comments were improved. So those things make me easy in documenting session. A feature request I proposed to do at the end of the last week was already fixed (My patch has been accepted for that). So I didn't involve with that.

   Dieter has suggested to change the class structure for PMA_CommomFunctions class. After discussing in mailing list I decided to make any change after the GSoC 2012 session. I will be stop my further work related to code and documentation improvements under GSoC 2012 session by today.

    In next week I'll submit my evaluation form. I wish all GSoCers who passed the mid evaluations to get success this Great event GSoC 2012 with Open source :)

Monday, August 13, 2012

GSoC 2012 - 12th Week Progress

      Its more one week to do the remaining work of GSoC 2012 project. Last week I introduced new links inside information_schema database with modifying a previous code for showing links inside mysql database. As well support for MIME transformations in query results and VIEWs were implemented. More improvements related to VIEWs were done.

           In this week I implement the feature request simple sort for process list. That was little older feature request and the description of the feature request itself suggested the fix. But with the time those files were changed and renamed. So I improve the behavior of server_status.php file to do the required thing. Since the sorting needs to specify the table, I used prcesslist table of information_schema database. Apart from these I did some test implementations for the functions in PMA_DisplayResults class.

           In my next week I'm intending to improve some tests for PMA_DisplayResults classwhile doing any remaining minor improvements in my codes.

Monday, August 6, 2012

GSoC 2012 - 11th Week Progress

             This is my 11th week of GSoC 2012 project. Its one more week to active work in code level. Last week I did some improvements on showing syntax highlighted SQL statement in PROCESSLIST table in information_schema database and introduce some links inside mysql database related to displaying data fields.

            This week as the first task I introduce some links inside information_schema database. In previous week I implement same kind of thing but in more specific way to that task. So I change the previous implementation where it can be used to my new task. I changed the structure of the global variable $GLOBALS['mysql_schema_relation'] and renamed it as $GLOBALS['special_schema_links'] and renamed the file as special_schema_links.lib.php. The new structure of the array can be represented by following snippet.

$GLOBALS['special_schema_links'] = array( 
    // Database name is the major element
    'mysql' => array(
        // Table name
        'db' => array(
            // Column name
            'user' => array(
                // Main url param (can be an array where represent sql)
                'link_param' => 'username',
                // Other url params
                'link_dependancy_params' => array(
                    0 => array(
                        // URL parameter name
                        // (can be array where url param has static value)
                        'param_info' => 'hostname',
                        // Column name related to url param
                        'column_name' => 'host'                        
                    )
                ),
                // Page to link
                'default_page' => 'server_privileges.php'
            )
        )
    )
);

By using this array, links can be generated where needed specially inside schema like mysql, information_schema etc.

          Next I moved into implement feature request for support MIME transformations in query results. Some of the query results which show only field with transformation and large data (blob fields etc) were not displayed their expected transformation in results. PMA has avoided that kind large data comparisons for SQL queries. So that, $where_clause parameter is not generating properly. So, assuming the length of the data fields will not same, I used the length of the data field to generate proper $where_clause and compare inside SQL query. Now query results display the expected out put with their transformations if any.

            Then I moved into give the support for transformed data for VIEWs. In PMA the columns with any transformation are stored inside column_info table of phpmyadmin database. But the problem was these information were not stored in column_info table while creating VIEWs. So I did some changes to store needed details of transformations in VIEWs whie creating them by the link (create view) in browse mode of a result set. A new file called tbl_views.lib.php was introduce to place related functions.

        As well when deleting a column, table, view or database the related information on transformations were not deleted from the column_info table. So I implement a function to delete relevant entries and placed the necessary places to do the work.

In my next week I intend to implement the feature request on simple sort for server_processlist.php.


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.