X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FSql%2FSqloracle.php;fp=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FSql%2FSqloracle.php;h=399c219f98003cdbf23daa0abd9957458d9877e9;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drush/drush/lib/Drush/Sql/Sqloracle.php b/vendor/drush/drush/lib/Drush/Sql/Sqloracle.php new file mode 100644 index 000000000..399c219f9 --- /dev/null +++ b/vendor/drush/drush/lib/Drush/Sql/Sqloracle.php @@ -0,0 +1,92 @@ +db_spec['username'] . '/' . $this->db_spec['password'] . ($this->db_spec['host'] == 'USETNS' ? '@' . $this->db_spec['database'] : '@//' . $this->db_spec['host'] . ':' . ($db_spec['port'] ? $db_spec['port'] : '1521') . '/' . $this->db_spec['database']); + } + + public function createdb_sql($dbname) { + return drush_log("Unable to generate CREATE DATABASE sql for $dbname", LogLevel::ERROR); + } + + // @todo $suffix = '.sql'; + public function query_format($query) { + // remove trailing semicolon from query if we have it + $query = preg_replace('/\;$/', '', $query); + + // some sqlplus settings + $settings[] = "set TRIM ON"; + $settings[] = "set FEEDBACK OFF"; + $settings[] = "set UNDERLINE OFF"; + $settings[] = "set PAGES 0"; + $settings[] = "set PAGESIZE 50000"; + + // are we doing a describe ? + if (!preg_match('/^ *desc/i', $query)) { + $settings[] = "set LINESIZE 32767"; + } + + // are we doing a show tables ? + if (preg_match('/^ *show tables/i', $query)) { + $settings[] = "set HEADING OFF"; + $query = "select object_name from user_objects where object_type='TABLE' order by object_name asc"; + } + + // create settings string + $sqlp_settings = implode("\n", $settings) . "\n"; + + // important for sqlplus to exit correctly + return "${sqlp_settings}${query};\nexit;\n"; + } + + public function listTables() { + $return = $this->query("SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME NOT IN ('BLOBS','LONG_IDENTIFIERS')"); + $tables = drush_shell_exec_output(); + if (!empty($tables)) { + // Shift off the header of the column of data returned. + array_shift($tables); + return $tables; + } + } + + // @todo $file is no longer provided. We are supposed to return bash that can be piped to gzip. + // Probably Oracle needs to override dump() entirely - http://stackoverflow.com/questions/2236615/oracle-can-imp-exp-go-to-stdin-stdout. + public function dumpCmd($table_selection) { + $create_db = drush_get_option('create-db'); + $exec = 'exp ' . $this->creds(); + // Change variable '$file' by reference in order to get drush_log() to report. + if (!$file) { + $file = $this->db_spec['username'] . '.dmp'; + } + $exec .= ' file=' . $file; + + if (!empty($tables)) { + $exec .= ' tables="(' . implode(',', $tables) . ')"'; + } + $exec .= ' owner=' . $this->db_spec['username']; + if ($option = drush_get_option('extra', $this->query_extra)) { + $exec .= " $option"; + } + return array($exec, $file); + } +}