From: Jörn Friedrich Dreyer Date: Thu, 20 Jun 2013 15:42:02 +0000 (+0200) Subject: backport oracle related changes, mostly comments, but also setup related fixes X-Git-Tag: v5.0.8~51^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=761c7e9a513df166a093fa2a72bc43c6ecc5f479;p=nextcloud-server.git backport oracle related changes, mostly comments, but also setup related fixes --- diff --git a/lib/app.php b/lib/app.php index 889d135d7db..2f20256c8cf 100644 --- a/lib/app.php +++ b/lib/app.php @@ -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\''; } diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index e58e584fb41..745523c7a5b 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -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 . '/%'; } diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 360c3066d05..1ffa048d6b2 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -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)) { diff --git a/lib/db.php b/lib/db.php index 02200636b4e..cd010d53104 100644 --- a/lib/db.php +++ b/lib/db.php @@ -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( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $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); diff --git a/lib/setup.php b/lib/setup.php index c4817286b06..5d5ef77899f 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -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);