diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-07-23 19:57:04 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-07-23 19:57:04 +0200 |
commit | c239ca0d25d645069bf5f25c9ccf5bc124b69909 (patch) | |
tree | 2d580862a42af0e1896cbaf30268f18ee839bed0 /lib/db.php | |
parent | 4d46567dc0948cc5edb50b2acf365a3bc3aa9078 (diff) | |
download | nextcloud-server-c239ca0d25d645069bf5f25c9ccf5bc124b69909.tar.gz nextcloud-server-c239ca0d25d645069bf5f25c9ccf5bc124b69909.zip |
Oracle compat: enable appconfig.configvalue to store empty strings (now working)
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/lib/db.php b/lib/db.php index 2dc20001d1f..0a827d032a5 100644 --- a/lib/db.php +++ b/lib/db.php @@ -185,7 +185,7 @@ class OC_DB { } else { $dsn='sqlsrv:Server='.$host.';Database='.$name; } - break; + break; default: return false; } @@ -365,12 +365,12 @@ class OC_DB { $query = self::processQuery( $query ); self::connect(); - + if ($isManipulation === null) { //try to guess, so we return the number of rows on manipulations $isManipulation = self::isManipulation($query); } - + // return the result if(self::$backend==self::BACKEND_MDB2) { // differentiate between query and manipulation @@ -401,11 +401,11 @@ class OC_DB { } return $result; } - + /** * tries to guess the type of statement based on the first 10 characters * the current check allows some whitespace but does not work with IF EXISTS or other more complex statements - * + * * @param string $sql */ static public function isManipulation( $sql ) { @@ -427,7 +427,7 @@ class OC_DB { } return false; } - + /** * @brief gets last value of autoincrement * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix @@ -583,10 +583,35 @@ 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']; + + $installedVersion = \OC_Config::getValue('version', '0.0.0'); + if (version_compare('5.0.15', $installedVersion, '<=')) { + //configvalue in oc_appconfig must be allowed to contain NULL + //because it is a CLOB, we need to move heaven and earth a bit + //i.e. rename it and copy values + $ociHandleAppconfig = true; + + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*appconfig`'); + $result = $query->execute(); + if(\OCP\DB::isError($result)) { + unset($ociHandleAppconfig); + throw new Exception('Cannot read from table appconfig:'. + $result->getMessage()); + } + $ociAppconfigContent = $result->fetchAll(); + + $query = \OCP\DB::prepare('ALTER TABLE `*PREFIX*appconfig` + RENAME COLUMN `configvalue` TO `configvalue_tmp`'); + $result = $query->execute(); + if(\OCP\DB::isError($result)) { + OC_Log::write('core', 'Could not alter appconfig.'. + ', DB upgrade may fail.', OC_Log::WARN); + } + } } // read file @@ -636,6 +661,25 @@ class OC_DB { OC_Log::write('core', $message, OC_Log::FATAL); throw new Exception($message); } + + if(isset($ociHandleAppconfig) && isset($ociAppconfigContent)) { + $query = \OCP\DB::prepare(' + UPDATE `*PREFIX*appconfig` + SET `configvalue` = ? + WHERE + `appid` = ? + AND `configkey` = ? + '); + foreach($ociAppconfigContent as $row) { + $r = $query->execute(array( + $row['configvalue'], $row['appid'], $row['configkey'] + )); + if(\OCP\DB::isError($r)) { + throw new Exception($r->getMessage()); + } + } + } + return true; } @@ -799,11 +843,11 @@ class OC_DB { private static function fixLimitClauseForMSSQL($query) { $limitLocation = stripos ($query, "LIMIT"); - + if ( $limitLocation === false ) { return $query; - } - + } + // total == 0 means all results - not zero results // // First number is either total or offset, locate it by first space @@ -850,7 +894,7 @@ class OC_DB { } return $query; } - + /** * @brief drop a table * @param string $tableName the table to drop @@ -1032,7 +1076,7 @@ class PDOStatementWrapper{ } else { $result = $this->statement->execute(); } - + if ($result === false) { return false; } @@ -1132,7 +1176,7 @@ class PDOStatementWrapper{ die ($entry); } } - + /** * provide numRows */ |