phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.schema_proc_pgsql.inc.php [Version


From: Sigurd Nes
Subject: [Phpgroupware-cvs] phpgwapi/inc class.schema_proc_pgsql.inc.php [Version-0_9_16-branch]
Date: Thu, 20 Apr 2006 06:47:04 +0000

CVSROOT:        /sources/phpgwapi
Module name:    phpgwapi
Branch:         Version-0_9_16-branch
Changes by:     Sigurd Nes <address@hidden>     06/04/20 06:47:04

Modified files:
        inc            : class.schema_proc_pgsql.inc.php 

Log message:
        rename sequence when renaming table and keep start value

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/phpgwapi/inc/class.schema_proc_pgsql.inc.php.diff?only_with_tag=Version-0_9_16-branch&tr1=1.5.2.15&tr2=1.5.2.16&r1=text&r2=text

Patches:
Index: phpgwapi/inc/class.schema_proc_pgsql.inc.php
diff -u phpgwapi/inc/class.schema_proc_pgsql.inc.php:1.5.2.15 
phpgwapi/inc/class.schema_proc_pgsql.inc.php:1.5.2.16
--- phpgwapi/inc/class.schema_proc_pgsql.inc.php:1.5.2.15       Mon Mar 20 
14:20:39 2006
+++ phpgwapi/inc/class.schema_proc_pgsql.inc.php        Thu Apr 20 06:47:04 2006
@@ -12,7 +12,7 @@
        * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License
        * @package phpgwapi
        * @subpackage database
-       * @version $Id: class.schema_proc_pgsql.inc.php,v 1.5.2.15 2006/03/20 
14:20:39 sigurdne Exp $
+       * @version $Id: class.schema_proc_pgsql.inc.php,v 1.5.2.16 2006/04/20 
06:47:04 sigurdne Exp $
        * @link http://www.greatbridge.org/project/phppgadmin
        * @internal SQL for table properties taken from phpPgAdmin Version 2.2.1
        */
@@ -429,6 +429,7 @@
                function RenameTable($oProc, &$aTables, $sOldTableName, 
$sNewTableName)
                {
                        global $DEBUG;
+                       if ($DEBUG) { echo '<br>RenameTable():' . 
$sOldTableName . 'to: '. $sNewTableName; }
                        if ($DEBUG) { echo '<br>RenameTable(): Fetching old 
sequence for: ' . $sOldTableName; }
                        
$this->GetSequenceForTable($oProc,$sOldTableName,$sSequenceName);
                        if ($DEBUG) { echo ' - ' . $sSequenceName; }
@@ -442,9 +443,6 @@
                                $oProc->m_odb->next_record();
                                $lastval = $oProc->m_odb->f(0);
 
-                               if ($DEBUG) { echo '<br>RenameTable(): dropping 
old sequence: ' . $sSequenceName . ' used on field: ' . $sField; }
-                               
$this->DropSequenceForTable($oProc,$sOldTableName);
-
                                if ($lastval)
                                {
                                        $lastval = ' start ' . $lastval;
@@ -453,9 +451,18 @@
                                if ($DEBUG) { echo '<br>RenameTable(): Making 
new sequence using: ' . $sSequenceSQL . $lastval; }
                                $oProc->m_odb->query($sSequenceSQL . 
$lastval,__LINE__,__FILE__);
                                if ($DEBUG) { echo '<br>RenameTable(): Altering 
column default for: ' . $sField; }
-                               $oProc->m_odb->query("ALTER TABLE 
$sOldTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . 
"')",__LINE__,__FILE__);
                        }
 
+                       $oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME 
TO $sNewTableName");                    
+                       if ($sSequenceName)
+                       {
+                               $Ok = !!($oProc->m_odb->query("ALTER TABLE 
$sNewTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . 
"')"));
+                               
$this->DropSequenceForTable($oProc,$sOldTableName);
+                       }
+                       
+                       return $Ok;
+
+               /* todo - fix index-renaming.
                        $indexnames = $oProc->m_odb->index_names();
                        while(list($key,$val) = @each($indexnames))
                        {
@@ -469,8 +476,10 @@
                        {
                                $oProc->m_odb->query('ALTER TABLE 
'.$sOldTableName.'_pkey RENAME TO '.$sNewTableName.'_pkey');
                        }
+               
 
                        return !!($oProc->m_odb->query("ALTER TABLE 
$sOldTableName RENAME TO $sNewTableName"));
+               */
                }
 
                function RenameColumn($oProc, &$aTables, $sTableName, 
$sOldColumnName, $sNewColumnName, $bCopyData = true)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]