Ignore:
Timestamp:
2013/08/02 13:22:57 (13 years ago)
Author:
Seasoft
Message:

#2322 (セッションのGC処理がエラーとなる)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/MDB2/Driver/Reverse/mysql.php

    r20764 r23022  
    4343// +----------------------------------------------------------------------+ 
    4444// 
    45 // $Id: mysql.php,v 1.80 2008/03/26 21:15:37 quipo Exp $ 
     45// $Id: mysql.php 327310 2012-08-27 15:16:18Z danielc $ 
    4646// 
    4747 
     
    7070    function getTableFieldDefinition($table_name, $field_name) 
    7171    { 
    72         $db =& $this->getDBInstance(); 
    73         if (PEAR::isError($db)) { 
     72        $db = $this->getDBInstance(); 
     73        if (MDB2::isError($db)) { 
    7474            return $db; 
    7575        } 
    7676 
    7777        $result = $db->loadModule('Datatype', null, true); 
    78         if (PEAR::isError($result)) { 
     78        if (MDB2::isError($result)) { 
    7979            return $result; 
    8080        } 
     
    8585        $query = "SHOW FULL COLUMNS FROM $table LIKE ".$db->quote($field_name); 
    8686        $columns = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); 
    87         if (PEAR::isError($columns)) { 
     87        if (MDB2::isError($columns)) { 
    8888            return $columns; 
    8989        } 
     
    103103            if ($field_name == $column['name']) { 
    104104                $mapped_datatype = $db->datatype->mapNativeDatatype($column); 
    105                 if (PEAR::isError($mapped_datatype)) { 
     105                if (MDB2::isError($mapped_datatype)) { 
    106106                    return $mapped_datatype; 
    107107                } 
     
    114114                if (array_key_exists('default', $column)) { 
    115115                    $default = $column['default']; 
    116                     if (is_null($default) && $notnull) { 
     116                    if ((null === $default) && $notnull) { 
    117117                        $default = ''; 
    118118                    } 
    119119                } 
     120                $definition[0] = array( 
     121                    'notnull' => $notnull, 
     122                    'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type']) 
     123                ); 
    120124                $autoincrement = false; 
    121                 if (!empty($column['extra']) && $column['extra'] == 'auto_increment') { 
    122                     $autoincrement = true; 
     125                if (!empty($column['extra'])) { 
     126                    if ($column['extra'] == 'auto_increment') { 
     127                        $autoincrement = true; 
     128                    } else { 
     129                        $definition[0]['extra'] = $column['extra']; 
     130                    } 
    123131                } 
    124132                $collate = null; 
     
    128136                } 
    129137 
    130                 $definition[0] = array( 
    131                     'notnull' => $notnull, 
    132                     'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type']) 
    133                 ); 
    134                 if (!is_null($length)) { 
     138                if (null !== $length) { 
    135139                    $definition[0]['length'] = $length; 
    136140                } 
    137                 if (!is_null($unsigned)) { 
     141                if (null !== $unsigned) { 
    138142                    $definition[0]['unsigned'] = $unsigned; 
    139143                } 
    140                 if (!is_null($fixed)) { 
     144                if (null !== $fixed) { 
    141145                    $definition[0]['fixed'] = $fixed; 
    142146                } 
     
    147151                    $definition[0]['autoincrement'] = $autoincrement; 
    148152                } 
    149                 if (!is_null($collate)) { 
     153                if (null !== $collate) { 
    150154                    $definition[0]['collate'] = $collate; 
    151155                    $definition[0]['charset'] = $charset; 
     
    182186    function getTableIndexDefinition($table_name, $index_name) 
    183187    { 
    184         $db =& $this->getDBInstance(); 
    185         if (PEAR::isError($db)) { 
     188        $db = $this->getDBInstance(); 
     189        if (MDB2::isError($db)) { 
    186190            return $db; 
    187191        } 
     
    193197        $index_name_mdb2 = $db->getIndexName($index_name); 
    194198        $result = $db->queryRow(sprintf($query, $db->quote($index_name_mdb2))); 
    195         if (!PEAR::isError($result) && !is_null($result)) { 
     199        if (!MDB2::isError($result) && (null !== $result)) { 
    196200            // apply 'idxname_format' only if the query succeeded, otherwise 
    197201            // fallback to the given $index_name, without transformation 
     
    199203        } 
    200204        $result = $db->query(sprintf($query, $db->quote($index_name))); 
    201         if (PEAR::isError($result)) { 
     205        if (MDB2::isError($result)) { 
    202206            return $result; 
    203207        } 
     
    257261    function getTableConstraintDefinition($table_name, $constraint_name) 
    258262    { 
    259         $db =& $this->getDBInstance(); 
    260         if (PEAR::isError($db)) { 
     263        $db = $this->getDBInstance(); 
     264        if (MDB2::isError($db)) { 
    261265            return $db; 
    262266        } 
     
    270274            $constraint_name_mdb2 = $db->getIndexName($constraint_name); 
    271275            $result = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2))); 
    272             if (!PEAR::isError($result) && !is_null($result)) { 
     276            if (!MDB2::isError($result) && (null !== $result)) { 
    273277                // apply 'idxname_format' only if the query succeeded, otherwise 
    274278                // fallback to the given $index_name, without transformation 
     
    277281        } 
    278282        $result = $db->query(sprintf($query, $db->quote($constraint_name))); 
    279         if (PEAR::isError($result)) { 
     283        if (MDB2::isError($result)) { 
    280284            return $result; 
    281285        } 
     
    357361    function _getTableFKConstraintDefinition($table, $constraint_name, $definition) 
    358362    { 
    359         $db =& $this->getDBInstance(); 
    360         if (PEAR::isError($db)) { 
     363        $db = $this->getDBInstance(); 
     364        if (MDB2::isError($db)) { 
    361365            return $db; 
    362366        } 
     367        //Use INFORMATION_SCHEMA instead? 
     368        //SELECT * 
     369        //  FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS 
     370        // WHERE CONSTRAINT_SCHEMA = '$dbname' 
     371        //   AND TABLE_NAME = '$table' 
     372        //   AND CONSTRAINT_NAME = '$constraint_name'; 
    363373        $query = 'SHOW CREATE TABLE '. $db->escape($table); 
    364374        $constraint = $db->queryOne($query, 'text', 1); 
    365         if (!PEAR::isError($constraint) && !empty($constraint)) { 
     375        if (!MDB2::isError($constraint) && !empty($constraint)) { 
    366376            if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { 
    367377                if ($db->options['field_case'] == CASE_LOWER) { 
     
    373383            $constraint_name_original = $constraint_name; 
    374384            $constraint_name = $db->getIndexName($constraint_name); 
    375             $pattern = '/\bCONSTRAINT\s+'.$constraint_name.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^ ]+) \(([^\)]+)\)/i'; 
     385            $pattern = '/\bCONSTRAINT\s+'.$constraint_name.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^\s]+) \(([^\)]+)\)(?: ON DELETE ([^\s]+))?(?: ON UPDATE ([^\s]+))?/i'; 
    376386            if (!preg_match($pattern, str_replace('`', '', $constraint), $matches)) { 
    377387                //fallback to original constraint name 
    378                 $pattern = '/\bCONSTRAINT\s+'.$constraint_name_original.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^ ]+) \(([^\)]+)\)/i'; 
     388                $pattern = '/\bCONSTRAINT\s+'.$constraint_name_original.'\s+FOREIGN KEY\s+\(([^\)]+)\) \bREFERENCES\b ([^\s]+) \(([^\)]+)\)(?: ON DELETE ([^\s]+))?(?: ON UPDATE ([^\s]+))?/i'; 
    379389            } 
    380390            if (preg_match($pattern, str_replace('`', '', $constraint), $matches)) { 
     
    398408                    ); 
    399409                } 
    400                 $definition['onupdate'] = 'NO ACTION'; 
    401                 $definition['ondelete'] = 'NO ACTION'; 
     410                $definition['ondelete'] = empty($matches[4]) ? 'RESTRICT' : strtoupper($matches[4]); 
     411                $definition['onupdate'] = empty($matches[5]) ? 'RESTRICT' : strtoupper($matches[5]); 
    402412                $definition['match']    = 'SIMPLE'; 
    403413                return $definition; 
     
    425435    function getTriggerDefinition($trigger) 
    426436    { 
    427         $db =& $this->getDBInstance(); 
    428         if (PEAR::isError($db)) { 
     437        $db = $this->getDBInstance(); 
     438        if (MDB2::isError($db)) { 
    429439            return $db; 
    430440        } 
     
    445455        ); 
    446456        $def = $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC); 
    447         if (PEAR::isError($def)) { 
     457        if (MDB2::isError($def)) { 
    448458            return $def; 
    449459        } 
     
    477487        } 
    478488 
    479         $db =& $this->getDBInstance(); 
    480         if (PEAR::isError($db)) { 
     489        $db = $this->getDBInstance(); 
     490        if (MDB2::isError($db)) { 
    481491            return $db; 
    482492        } 
     
    507517        for ($i = 0; $i < $count; $i++) { 
    508518            $res[$i] = array( 
    509                 'table' => $case_func(@mysql_field_table($resource, $i)), 
    510                 'name'  => $case_func(@mysql_field_name($resource, $i)), 
    511                 'type'  => @mysql_field_type($resource, $i), 
    512                 'length'   => @mysql_field_len($resource, $i), 
    513                 'flags' => @mysql_field_flags($resource, $i), 
     519                'table'  => $case_func(@mysql_field_table($resource, $i)), 
     520                'name'   => $case_func(@mysql_field_name($resource, $i)), 
     521                'type'   => @mysql_field_type($resource, $i), 
     522                'length' => @mysql_field_len($resource, $i), 
     523                'flags'  => @mysql_field_flags($resource, $i), 
    514524            ); 
    515525            if ($res[$i]['type'] == 'string') { 
     
    519529            } 
    520530            $mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]); 
    521             if (PEAR::isError($mdb2type_info)) { 
     531            if (MDB2::isError($mdb2type_info)) { 
    522532               return $mdb2type_info; 
    523533            } 
Note: See TracChangeset for help on using the changeset viewer.