]> source.dussan.org Git - nextcloud-server.git/commitdiff
backport oracle related changes, mostly comments, but also setup related fixes
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 20 Jun 2013 15:42:02 +0000 (17:42 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 20 Jun 2013 15:42:02 +0000 (17:42 +0200)
lib/app.php
lib/connector/sabre/locks.php
lib/connector/sabre/node.php
lib/db.php
lib/setup.php

index 889d135d7db11511662a018ff401197fb3e5f596..2f20256c8cf43d0989608118c5137d77839523dd 100644 (file)
@@ -174,7 +174,8 @@ class OC_App{
                $apps=array('files');
                $sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
                        .' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
-               if (OC_Config::getValue( 'dbtype', 'sqlite' ) === 'oci') { //FIXME oracle hack
+               if (OC_Config::getValue( 'dbtype', 'sqlite' ) === 'oci') {
+                       //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
                        $sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
                        .' WHERE `configkey` = \'enabled\' AND to_char(`configvalue`)=\'yes\'';
                }
index e58e584fb4117594c5602b12604e5fde497e8cba..745523c7a5b356bab24fa532c6907722dc532a35 100644 (file)
@@ -45,7 +45,12 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
                // but otherwise reading locks from SQLite Databases will return
                // nothing
                $query = 'SELECT * FROM `*PREFIX*locks`'
-                       .' WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( `uri` = ?)';
+                          .' WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( `uri` = ?)';
+               if (OC_Config::getValue( "dbtype") === 'oci') {
+                       //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
+                       $query = 'SELECT * FROM `*PREFIX*locks`'
+                                  .' WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( to_char(`uri`) = ?)';
+               }
                $params = array(OC_User::getUser(), $uri);
 
                // We need to check locks for every part in the uri.
@@ -60,15 +65,24 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
 
                        if ($currentPath) $currentPath.='/';
                        $currentPath.=$part;
-
-                       $query.=' OR (`depth` != 0 AND `uri` = ?)';
+                       //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
+                       if (OC_Config::getValue( "dbtype") === 'oci') {
+                               $query.=' OR (`depth` != 0 AND to_char(`uri`) = ?)';
+                       } else {
+                               $query.=' OR (`depth` != 0 AND `uri` = ?)';
+                       }
                        $params[] = $currentPath;
 
                }
 
                if ($returnChildLocks) {
 
-                       $query.=' OR (`uri` LIKE ?)';
+                       //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
+                       if (OC_Config::getValue( "dbtype") === 'oci') {
+                               $query.=' OR (to_char(`uri`) LIKE ?)';
+                       } else {
+                               $query.=' OR (`uri` LIKE ?)';
+                       }
                        $params[] = $uri . '/%';
 
                }
index 360c3066d05086e2687b139f8a80a705683d1251..1ffa048d6b23b8725538ee5c80673ae18ea6cb93 100644 (file)
@@ -101,7 +101,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
 
        /**
         * @brief Ensure that the fileinfo cache is filled
-        & @note Uses OC_FileCache or a direct stat
+        * @note Uses OC_FileCache or a direct stat
         */
        protected function getFileinfoCache() {
                if (!isset($this->fileinfo_cache)) {
index 02200636b4e733a4bd681f7f11af0c60b7967ff4..cd010d531044ed0b465f6fb76d21cbb47a401b7e 100644 (file)
@@ -406,14 +406,13 @@ class OC_DB {
                        $query = self::prepare('SELECT lastval() AS id');
                        $row = $query->execute()->fetchRow();
                        return $row['id'];
-               }
-               if( $type == 'mssql' || $type == 'oci' ) {
+               } else if( $type === 'mssql' || $type === 'oci') {
                        if($table !== null) {
                                $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
                                $table = str_replace( '*PREFIX*', $prefix, $table );
                        }
                        return self::$connection->lastInsertId($table);
-               }else{
+               } else {
                        if($table !== null) {
                                $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
                                $suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
@@ -545,6 +544,11 @@ class OC_DB {
                $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
 
                self::connectScheme();
+               
+               if(OC_Config::getValue('dbtype', 'sqlite')==='oci') {
+                       //set dbname, it is unset because oci uses 'service' to connect
+                       self::$schema->db->database_name=self::$schema->db->dsn['username'];
+               }
 
                // read file
                $content = file_get_contents( $file );
@@ -574,6 +578,12 @@ class OC_DB {
                        $content = str_replace( '<default>0000-00-00 00:00:00</default>',
                                '<default>CURRENT_TIMESTAMP</default>', $content );
                }
+               if(OC_Config::getValue('dbtype', 'sqlite')==='oci') {
+                       unset($previousSchema['charset']); //or MDB2 tries SHUTDOWN IMMEDIATE
+                       $oldname = $previousSchema['name'];
+                       $previousSchema['name']=OC_Config::getValue( "dbuser", $oldname );
+                       //TODO check identifiers are at most 30 chars long
+               }
                file_put_contents( $file2, $content );
                $op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
 
index c4817286b066244d563a1ddf432b3a24eae85d87..5d5ef77899f29b7f452722bdff1161e69fbd9b01 100644 (file)
@@ -139,12 +139,15 @@ class OC_Setup {
                                $dbuser = $options['dbuser'];
                                $dbpass = $options['dbpass'];
                                $dbname = $options['dbname'];
-                               $dbtablespace = $options['dbtablespace'];
+                               if (array_key_exists('dbtablespace', $options)) {
+                                       $dbtablespace = $options['dbtablespace'];
+                               } else {
+                                       $dbtablespace = 'USERS';
+                               }
                                $dbhost = isset($options['dbhost'])?$options['dbhost']:'';
                                $dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
 
                                OC_Config::setValue('dbname', $dbname);
-                               OC_Config::setValue('dbtablespace', $dbtablespace);
                                OC_Config::setValue('dbhost', $dbhost);
                                OC_Config::setValue('dbtableprefix', $dbtableprefix);