BitKeeper patch

Ashley Jones <ajones-tp0iMJ/[email protected]> Thu, 2 Dec 2004 16:04:55 -0800
Newsgroups gmane.comp.cms.xaraya.patches
Message-ID <[email protected]>
This BitKeeper patch contains the following changesets:
ajones-V/[email protected]|ChangeSet|20041203000127|53978

# ID:	[email protected]|ChangeSet|20020928131446|19176|e333bc156eae828a
# User:	ajones
# Host:	schwabfoundation.org
# Root:	/home/ajones/vanilla-core

# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
[email protected]|ChangeSet|20020928131446|19176|e333bc156eae828a
[email protected]|ChangeSet|20041201135014|52004
D 1.1984 04/12/02 16:01:27-08:00 ajones-V/[email protected] +2 -0
B [email protected]|ChangeSet|20020928131446|19176|e333bc156eae828a
C
c added case statements for modify in alterTable so you could drop and add null.  tested on mysql and postgres, unable to test oracle. rejects any modify commands that aren't changing null.
K 53978
P ChangeSet
------------------------------------------------

0a0
> BK|html/includes/pnTableDDL.php|19700101030959|01170|e86bc060406ca8cb ajones-V/[email protected]|html/includes/xarTableDDL.php|20041203000117|51748
> [email protected]|BitKeeper/etc/logging_ok|20020928132559|02556|36872ac13653ac68 ajones-V/[email protected]|BitKeeper/etc/logging_ok|20041203000126|30314

== html/includes/xarTableDDL.php ==
BK|html/includes/pnTableDDL.php|19700101030959|01170|e86bc060406ca8cb
[email protected]|html/includes/xarTableDDL.php|20040611185942|44309
D 1.63 04/12/02 16:01:17-08:00 ajones-V/[email protected] +191 -1
B [email protected]|ChangeSet|20020928131446|19176|e333bc156eae828a
C
c added case statements for modify in alterTable so you could drop and add null.  tested on mysql and postgres, unable to test oracle. rejects any modify commands that aren't changing null.
K 51748
O -rw-rw-r--
P html/includes/xarTableDDL.php
------------------------------------------------

D123 1
I123 1
    
I462 65
        case 'modify':
        
            // ************************* TO DO TO DO *************************
            // this modify case ONLY adds or drops NULL to a column.  All other functionality
            // per the below args needs to be added
            // 11.30.04 - mrjones - ajones-tp0iMJ/[email protected]
            // ************************* TO DO TO DO *************************
            
            
            // We need to account for all the possible args that are passed:
            // * @param args['type'] column type
            // * @param args['size'] size of column if varying data
            // * @param args['default'] default value of data
            // * @param args['null'] null or not null (true/false)
            // * @param args['unsigned'] allow unsigned data (true/false)
            // * @param args['increment'] auto incrementing files
            // * @param args['primary_key'] primary key
            
            // make sure we have the colunm we're altering
            if (empty($args['field'])) {
                $msg = xarML('Invalid args (field key must be set.)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            // check to make sure we have an action to perform on the colunm
            if (!empty($args['type']) || !empty($args['size']) || !empty($args['default']) || !empty($args['unsigned']) || !empty($args['increment']) || !empty($args['primary_key'])) {
                $msg = xarML('Modify does not currently support: type, size, default, unsigned, increment, or primary_key)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            
            // check to make sure we have an action to perform on the colunm
            if (empty($args['null']) && $args['null']!=FALSE) {
                $msg = xarML('Invalid args (type,size,default,null, unsigned, increment, or primary_key must be set)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            // prep the first part of the query
            $sql = 'ALTER TABLE `'.$tableName.'` MODIFY `'.$args['field'].'` ';
            
            //since we don't allow type to be passed, check the db for type and derive type from
            // the existing schema. Also b/c the fetch mode may or may not be set to NUM, set it to 
            // ASSOC so we don't have to loop through the entire returned array looking for are our one 
            // field and field type
            $dbconn =& xarDBGetConn();
            $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
            $tableInfoArray = $dbconn->metacolumns($tableName); 
            $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM;
            if (!empty($tableInfoArray[strtoupper($args['field'])]->type)){
                $sql.=$tableInfoArray[strtoupper($args['field'])]->type;
            }
            if (!empty($tableInfoArray[strtoupper($args['field'])]->max_length) && $tableInfoArray[strtoupper($args['field'])]->max_length!="-1"){
                $sql.='('.$tableInfoArray[strtoupper($args['field'])]->max_length.')';
            }
            
            // see if the want to add null
            if ($args['null']==TRUE){
                $sql.=' NOT NULL ';
            }
            
            // break out of the case to return the modify sql
            break;
I512 54
        case 'modify':
        
            // ************************* TO DO TO DO *************************
            // this modify case ONLY adds or drops NULL to a column.  All other functionality
            // per the below args needs to be added
            // 11.30.04 - mrjones - ajones-tp0iMJ/[email protected]
            // ************************* TO DO TO DO *************************
            
            
            // We need to account for all the possible args that are passed:
            // * @param args['type'] column type
            // * @param args['size'] size of column if varying data
            // * @param args['default'] default value of data
            // * @param args['null'] null or not null (true/false)
            // * @param args['unsigned'] allow unsigned data (true/false)
            // * @param args['increment'] auto incrementing files
            // * @param args['primary_key'] primary key
            
            // make sure we have the colunm we're altering
            if (empty($args['field'])) {
                $msg = xarML('Invalid args (field key must be set.)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            // check to make sure we have an action to perform on the colunm
            if (!empty($args['type']) || !empty($args['size']) || !empty($args['default']) || !empty($args['unsigned']) || !empty($args['increment']) || !empty($args['primary_key'])) {
                $msg = xarML('Modify does not currently support: type, size, default, unsigned, increment, or primary_key)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return $msg;
            }
            
            // check to make sure we have an action to perform on the colunm
            if (empty($args['null']) && $args['null']!=FALSE) {
                $msg = xarML('Invalid args (type,size,default,null, unsigned, increment, or primary_key must be set)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            
            // prep the first part of the query
            $sql = 'ALTER TABLE '.$tableName.' ALTER COLUMN '.$args['field'].' ';
            
            // see if the want to add or remove null
            if ($args['null']==FALSE){
                $sql.='DROP NOT NULL';
            }
            if ($args['null']==TRUE){
                $sql.='SET NOT NULL';
            }
            
            // break out of the case to return the modify sql
            break;
I562 71
            break;
        case 'modify':
        
            // ************************* TO DO TO DO *************************
            // this modify case ONLY adds or drops NULL to a column.  All other functionality
            // per the below args needs to be added
            // 11.30.04 - mrjones - ajones-tp0iMJ/[email protected]
            // ************************* TO DO TO DO *************************
            
            
            // We need to account for all the possible args that are passed:
            // * @param args['type'] column type
            // * @param args['size'] size of column if varying data
            // * @param args['default'] default value of data
            // * @param args['null'] null or not null (true/false)
            // * @param args['unsigned'] allow unsigned data (true/false)
            // * @param args['increment'] auto incrementing files
            // * @param args['primary_key'] primary key
            
            // make sure we have the colunm we're altering
            if (empty($args['field'])) {
                $msg = xarML('Invalid args (field key must be set.)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            // check to make sure we have an action to perform on the colunm
            if (!empty($args['type']) || !empty($args['size']) || !empty($args['default']) || !empty($args['unsigned']) || !empty($args['increment']) || !empty($args['primary_key'])) {
                $msg = xarML('Modify does not currently support: type, size, default, unsigned, increment, or primary_key)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            
            // check to make sure we have an action to perform on the colunm
            if (empty($args['null']) && $args['null']!=FALSE) {
                $msg = xarML('Invalid args (type,size,default,null, unsigned, increment, or primary_key must be set)');
                xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM',
                               new SystemException(__FILE__.'('.__LINE__.'): '.$msg));
                return;
            }
            // prep the first part of the query
            $sql = 'ALTER TABLE '.$tableName.' MODIFY ('.$args['field'].' ';
            
            //since we don't allow type to be passed, check the db for type and derive type from
            // the existing schema. Also b/c the fetch mode may or may not be set to NUM, set it to 
            // ASSOC so we don't have to loop through the entire returned array looking for are our one 
            // field and field type
            $dbconn =& xarDBGetConn();
            $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
            $tableInfoArray = $dbconn->metacolumns($tableName); 
            $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM;
            if (!empty($tableInfoArray[strtoupper($args['field'])]->type)){
                $sql.=$tableInfoArray[strtoupper($args['field'])]->type;
            }
            if (!empty($tableInfoArray[strtoupper($args['field'])]->max_length) && $tableInfoArray[strtoupper($args['field'])]->max_length!="-1"){
                $sql.='('.$tableInfoArray[strtoupper($args['field'])]->max_length.')';
            }
            
            // see if the want to add null
            if ($args['null']==FALSE){
                $sql.=' NULL ';
            }
            if ($args['null']==TRUE){
                $sql.=' NOT NULL ';
            }
            
            // add on closing paren
            $sql.=")";
            
            // break out of the case to return the modify sql

== BitKeeper/etc/logging_ok ==
[email protected]|BitKeeper/etc/logging_ok|20020928132559|02556|36872ac13653ac68
mcortez-zpM2aoG8xahU3wYF/[email protected]|BitKeeper/etc/logging_ok|20041115213301|26732
D 1.179 04/12/02 16:01:26-08:00 ajones-V/[email protected] +1 -0
B [email protected]|ChangeSet|20020928131446|19176|e333bc156eae828a
C
c Logging to [email protected] accepted
K 30314
O -rw-rw-r--
P BitKeeper/etc/logging_ok
------------------------------------------------

I18 1
ajones-V/[email protected]

# Patch checksum=5500a378