I get the next error when trying to use

drush pm-enable views

on a drupal 7.2 core installed with an oracle 10 backend:

Command pm-enable needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to[error]
run this command.
The drush command 'pm-enable views' could not be executed.                                                                       [error]
Drush was not able to start (bootstrap) the Drupal database.                                                                     [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have a configured
database.

Drush was attempting to connect to :
  Drupal version    : 7.2
  Site URI          : http://default
  Database driver   : oracle
  Database hostname : localhost
  Database username : DRUPAL
  Database name     : XE
  Default theme     : garland
  Administration theme: garland
  PHP configuration : /etc/php.ini
  Drush version     : 4.4
  Drush configuration:
  Drush alias files :
  Drupal root       : /opt/workspace/drupal-7.2
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  File directory path: sites/default/files
  %paths            : Array

You can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command
line or $options['uri'] in your drushrc.php file.

This is the same error i get if i try to use pm-enable on a folder with an unfinished installation of Drupal.

Has drush support been tested?
Is drush able to use the driver?

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aaaristo’s picture

Assigned: Unassigned » aaaristo

no i think actually it cannot use the driver. It was working with drupal 6.x. I've not looked at it too mutch yet...

sionescu’s picture

any pointers on where to start looking? i'll try to look into this but i got as far as drush_get_context_options - i don't realy know where to go from there

aaaristo’s picture

may be you can try asking on the drush project.. i'dont know drush very well, in my experience syslog() and debug_backtrace() functions are really usefull tools to understand how a piece of php code works.

sionescu’s picture

Thanks, i'll move the issue to drush then.

sionescu’s picture

Project: Oracle Driver » Drush
Version: 7.x-1.6 » 7.x-4.4
Component: Code » PM (dl, en, up ...)
Assigned: aaaristo » Unassigned
jonhattan’s picture

Version: 7.x-4.4 »
Component: PM (dl, en, up ...) » Base system (internal API)

Look at drush_valid_db_credentials() in includes/environment.inc

greg.1.anderson’s picture

Yes; drush supports mysql, pgsql, sqllite, and sql server support is in progress. Oracle is unsupported; some work, including but not limited to #6 would be required to get it to work.

sionescu’s picture

Version: » 7.x-4.4
Component: Base system (internal API) » PM (dl, en, up ...)
Status: Active » Patch (to be ported)
FileSize
1.8 KB

This is the patch file that will enable drush to connect with the oracle driver.
It fixes the pdo type ('oci' not 'oracle') and it creates the connection string.

sionescu’s picture

The next error i got after doing the patch was:

Could not login with user ID #0. This is typically caused by importing a MySQL database dump from a faulty tool     [error]
which re-numbered the anonymous user ID in the users table. See http://drupal.org/node/1029506 for help recovering
from this situation.

This was because the null entry into the users table had the id:36 - this is probably because some issues with oracle sequences. I got past that by updating the uid to 0 but this should probably be fixed in the install procedure of drupal.

jonhattan’s picture

Version: 7.x-4.4 »
Component: PM (dl, en, up ...) » Base system (internal API)
Status: Patch (to be ported) » Needs work

@sionescu we only accept new functionality primarily in the 5.x branch, and after it gets in it may be backported to 4.x. Also see this issues for reference: #1050030: sqlsrv PDO driver uses invalid connection string

ps. you need to set "needs review" when you post a patch.

greg.1.anderson’s picture

Version: » 7.x-4.4
Component: Base system (internal API) » PM (dl, en, up ...)
Category: bug » feature

I don't know what to say about #9, but the code in #8 looks good in concept. It needs to be rolled against the master branch (drush-5.x), and should support both Drupal-6.x and Drupal-7.x prior to commit. This won't get you sql-dump et. al., but we could start here.

greg.1.anderson’s picture

Version: 7.x-4.4 »
sionescu’s picture

Category: feature » bug
Status: Needs work » Needs review

I checked against 5.x-dev and there seem to be no issues in the environment.inc file but this will need to be properly reviewed.
Thank you!

sionescu’s picture

Category: bug » feature
greg.1.anderson’s picture

Status: Needs review » Needs work

@sionescu: Maintainers are a lazy bunch; when we see something like Hunk #1 FAILED at 1215. from the patch command, we usually want the original submitter to reroll (recreate) the patch so that it applies to the most recent version without errors. Your patch does not apply to the head of the 7.x-4.x or the master branch, or even to the 7.x-4.4 branch. Please submit a new patch against master.

sionescu’s picture

The patch was created from two local files. I didn't work with git before, so could the issue be that the patch was not created against a drush repo?

sionescu’s picture

Status: Needs work » Needs review
FileSize
2.37 KB

This is the patch against master. Thanks.

jonhattan’s picture

Status: Needs review » Needs work

@sionescu please see issue #1050030: sqlsrv PDO driver uses invalid connection string where support for other database (sqlsrv) was implemented. There're other places of drush where code is needed to fulfill oracle support.

Also, review your code to not include trailing whitespaces.

sionescu’s picture

@jonhattan thanks for the info, i will probably be able to address those other issues as i run into them so i'm not making a commitment on following this to the end. My goal was to have pm-enable pm-disable working at this point.

i will remove trailing white spaces from future patches.

thanks.

chrisschaub’s picture

I've created a new patch that builds on the work in comments/patches #17 and #18. I tried to incorporate the method used to bring in sqlsrv support as much as possible. The following drush commands work for me with Oracle 11.2 :

drush sql-query (with special help for describe and show tables queries)
drush sql-cli
drush status
drush pm ... (enable modules etc)
drush ws (watchdog stuff)

Many of the other features work as well. I've also put some time into best guess formatting for output from sqlq queries.

I didn't get sql-dump or sql-drop working, mostly due to the complexities of Oracle's constraints -- and that it would have to integrate the exp and imp utilities. I'll try to add those in a bit, I have my own scripts to do those functions that could probably be worked into drush. I haven't tested the sync stuff yet either and am sure it won't work because table dropping is not implemented.

I haven't tested Drupal 7 yet, and I'm sure work will need to be done there. I've also added support for rlwrap which gives readline support if you have rlwrap installed (unix only, sorry).

This patch is against the latest 5.x master. Use at your own risk, I'm posting this just to keep the development going, not ready for production sytems! Hope it moves us further along.

chrisschaub’s picture

Status: Needs work » Needs review

Setting status to Needs Review for patch in comment #20.

moshe weitzman’s picture

Title: drush isn't abble to access the oracle database » drush isn't able to access the oracle database
Status: Needs review » Needs work
+++ b/commands/sql/sql.drush.inc
@@ -225,6 +225,15 @@ function _drush_sql_connect($db_spec = NULL) {
+      } else {

else must use 2 lines per drupal coding standards.

+++ b/commands/sql/sql.drush.inc
@@ -890,6 +911,13 @@ function _drush_sql_get_credentials($db_spec = NULL) {
+      // Some drush commands (e.g. site-install) want to connect to the
+      // server, but not the database.  Connect to the built-in database.
+      return ' ' . $db_spec['username'].'/'.$db_spec['password'].'@//'.$db_spec['host'].':'.$db_spec['port'].'/'.$db_spec['database'];

comment does not match code?

+++ b/commands/sql/sql.drush.inc
@@ -975,6 +1003,37 @@ function drush_sql_show_tables_pgsql() {
+ ¶

leading space

+++ b/includes/filesystem.inc
@@ -344,6 +344,15 @@ function drush_tempnam($pattern, $tmp_dir = NULL) {
+
+  // oracle needs .sql extensions
+  $creds = drush_get_context('DRUSH_DB_CREDENTIALS');

oracle cares about file extension?????

chrisschaub’s picture

I'll re-roll patch #20 with those corretions, thanks Moshe. But yes, oracle does care about scripts ending in .sql. You can set the extension, but I could not find a way to say "no extension" -- it has to be something. That comment was repeated throughout for the other cases, I'll just edit it.

chrisschaub’s picture

Status: Needs work » Needs review
FileSize
6.53 KB

I've re-rolled this patch against the latest "master". I think the issues are fixed from #22. I cannot find a way to get around the file extension issue with oracle, I think it's a legacy thing.

greg.1.anderson’s picture

Status: Needs review » Needs work

Sorry I didn't review the earlier patches sooner, but I just took a look at #24 and came up with a necessary change:

@@ -344,6 +344,16 @@ function drush_tempnam($pattern, $tmp_dir = NULL) {
     $tmp_dir = drush_find_tmp();
   }
   $tmp_file = tempnam($tmp_dir, $pattern);
+
+  // Oracle seems to need .sql extensions
+  // I have not found a way to specify no extension
+  $creds = drush_get_context('DRUSH_DB_CREDENTIALS');
+  $type = $creds['driver'];
+  if ($type == 'oracle') {
+    rename($tmp_file, $tmp_file.'.sql');
+    $tmp_file .= '.sql';
+  }

I don't like using the DRUSH_DB_CREDENTIALS context to alter the behavior of drush_tempnam. This code could cause an undesirable side-effect in callers that are using drush_tempnam for purposes other than an sql import. While there is no operational problem with a spurious ".sql" on the end of a temp file, it could be confusing to see it there. I also would not want to see this coding style spread to other parts of the code where the impact might be greater.

Instead, the function prototype of drush_tempnam should be altered:

function drush_tempnam($pattern, $tmp_dir = NULL, $extension = '')

Insure that any code path that calls drush_tempnam from a context where it will end up being used with Oracle passes '.sql' for $extension.

chrisschaub’s picture

Do you want me to resubmit a patch for drush that changes the prototype for drush_tempnam? I don't want to overstep.

greg.1.anderson’s picture

Yes. If you provide a default parameter as shown above, you will not break existing code. I think that the enhancement is generally useful.

aaaristo’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
6.33 KB

refactored cschaub patch... probably we don't need to change drush_tempnam.
tested against the master branch

Thanks cschaub!

moshe weitzman’s picture

Status: Needs work » Reviewed & tested by the community

Looks good to me. Lets wait a couple days for feedback.

chrisschaub’s picture

I'll test it out, thanks! I was not able to find time to rewrite the tempnam stuff.

jonhattan’s picture

Status: Needs work » Reviewed & tested by the community

re #20 if sql-dump and sql-drop are not supported, the user should be informed. At execution time better than in the help.

aaaristo’s picture

starting from my patch sql-dump and sql-drop are supported

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

I made the tempnam changes and committed this.

moshe weitzman’s picture

Title: drush isn't able to access the oracle database » Add Oracle support

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aaaristo’s picture

Category: feature » bug
Status: Closed (fixed) » Needs review
FileSize
808 bytes

Cannot bootstrap oracle in Drupal 6, moved PDO driver name translation only for drupal >=7

moshe weitzman’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aaaristo’s picture

Status: Closed (fixed) » Needs review
FileSize
7.87 KB

Added sql-sync support for oracle

greg.1.anderson’s picture

Status: Needs review » Needs work

Looks pretty good. Note that $create_db_file is not cleaned up on the remote machine, in cases where the target is remote; it is only cleaned up on the source machine. Temp files should be cleaned up in all locations where they are written.

aaaristo’s picture

Status: Needs work » Needs review
FileSize
8.12 KB

fixed it

moshe weitzman’s picture

The table creation code is so verbose!

I have been OK with the messiness for a while but it would be really nice if we could move DB suport engine system and let oracle/sqlserver live in Contrib. I guess thats a future patch.

Also, it would be nice if someone ran the test suite with sqlserv and/or oracle and fixed any failures. At one point, the suite passed with pgsql and mysql so it can be done.

Would be ideal if someone could verify that this patch works.

chrisschaub’s picture

I'm seeing some strange behaviour enabling modules. With my patch, modules enable correctly, and they do from the web interface as well. When I enable them with this latest version, the wrong modules get enabled! Devel gets enabled, openid, etc ... and I'm just enabling webfm or a custom feature. I think there is something amiss.

moshe weitzman’s picture

Status: Needs review » Needs work
hswong3i’s picture

Status: Needs work » Needs review
FileSize
4.78 KB

During development a new version of pdo_oci driver (http://drupal.org/project/pdo_oci), I found that Drupal installation works but drush fail. It is because:

  1. We are using $creds['database'] but not $creds['name']
  2. charset=AL32UTF8 will no long works with php-5.4
  3. Most switch cases just take care about 'oracle' (which is incorrect with pdo_* style), but wrongly ignore cases for 'oci' (i.e. the correct style for pdo_*)

A quick fix attached with a bit coding style clean, too.

Also fork to github as https://github.com/pantarei/drupal-drush/tree/7.x-5.x-1180240

supermp’s picture

Version: » 7.x-5.9

I'm very interested in seeing Drush fully support Oracle, When can we expect these fixes to be merged back into the main branch?

greg.1.anderson’s picture

Version: 7.x-5.9 » 8.x-6.x-dev
Status: Needs review » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.