Hello

We have used Oracle with OpenCA for more than two years on one of our
pilot CAs, the only think that does not work in the DBI module is the
creation of the tables. The DBI trys to detect the existing of the
tables by running a query on them and that does not work with Oracle. To
remedy this I did the following in the DBI.pm module
 Comment out the the table existence checking code in the  initDB sub,
then initialize the db like you would normally do through the we UI of
the CA. You  can uncomment it after you  create the table if you  want.
Other than that everything should work as it suppose to. Look at the
code below which is part of the OpenCA::DBI to find out the part you
need to comment out

 sub initDB {
  ## Generate a new db and initialize it allowing the
  ## DB to keep track of the DB status
 

  my $self = shift;
  my $keys = { @_ };
 

  $self->errno ( $OpenCA::DBI::ERROR->{DO_NOT_COMMIT} );
 

  my $mode   = $keys->{MODE};
 

  $self->debug ("initDB: Entering sub initDB");
  $self->debug ("initDB: MODE: $mode");
 

  ## Accepted modes are
  ## NONE
  ## FORCE  to force table creation
 

  my ($db, $force, $table, $dsn);
  # force ?
  $force = 0;
  if ( $mode =~ /^FORCE$/i ) {
      $force = 1;
  }
  $self->debug ("initDB: force: $force");

 foreach $table (keys %{$OpenCA::DBI::SQL->{TABLE}}) {
    $self->debug ("initDB: table: $table");
    # check for existence
    $self->debug ("initDB: dsn: ".$self->{DSN});
    $self->debug ("initDB: the folloing debugging-output is for DB2");
    $self->debug ("initDB: ld_library_path: ".$ENV{LD_LIBRARY_PATH});
    $self->debug ("initDB: path: ".           $ENV{PATH});
    $self->debug ("initDB: libpath".          $ENV{LIBPATH});
    $self->debug ("initDB: classpath".        $ENV{CLASSPATH});
#    if (defined $self->operateTable (DO=>"exist", TABLE => $table)) {
#      if ($force) {
#        if (not defined $self->operateTable (DO=>"drop", TABLE =>
$table)) {
#          $self->errno ( $OpenCA::DBI::ERROR->{ "CANNOT_REMOVE_".$table
} );
#          $self->rollback ();
#          return undef;
#        }
#      } else {
#        $self->errno ( $OpenCA::DBI::ERROR->{ $table."_TABLE_EXIST" }
);
#        $self->rollback ();
#        return undef;
#      }
#    }
    $self->debug ("initDB: try to create table");
    # create table
    if (not defined $self->operateTable (DO=>"create", TABLE => $table))
{
      $self->errno ( $OpenCA::DBI::ERROR->{ "CANNOT_CREATE_".$table } );
      $self->rollback ();
      return undef;
    }
    $self->debug ("initDB: table created");
  }
 

  if (not defined $self->commit ()) {
    $self->rollback ();
    return undef;
  }
 

  $self->debug ("initDB: initDB successful completed");
  $self->errno ( $OpenCA::DBI::ERROR->{SUCCESS} );
  return 1;
}



> -----Original Message-----
> From: Martin Bartosch [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 06, 2004 9:38 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [OpenCA-Devel] Testing Oracle DB support
> 
> Hi Michael,
> 
> >> I will be running Oracle as the database backend for OpenCA. I
noticed
> >> that Oracle support exists but I remember reading in the docs that
> >> it is not verified if Oracle DB support really works.
> >
> > Yes, somebody requested Oracle support. I coded it but we never
verified
> > it completely because I ahve no Oracle.
> 
> good, so there's soon to be a new supported and verified product
> for OpenCA :-)
> 
> > We can add a file oracle.xml to the OpenCA guide. A guide for
postgresql
> > already exists there. The environment variable can be configured
like
> > for IBM DB2. Please see etc/DBI.conf
> 
> Thanks for the pointer concerning the environment variable. I will
> write a section about Oracle once I've got it working.
> 
> >> DEBUG: OpenCA::DBI->doQuery: entering function
> >> DEBUG: OpenCA::DBI->doQuery: query: select * from ca_certificate
> >> DEBUG: OpenCA::DBI->doQuery: prepare statement
> >> DEBUG: OpenCA::DBI->doQuery: statement nr.: 1
> >> DBD::Oracle::db prepare failed: ORA-00942: table or view does not
exist
> >> (DBD ERROR: error possibly near <*> indicator at char 14 in 'select
*
> >> from
> >> <*>ca_certificate') [for statement ``select * from
ca_certificate''])
> at
> >> /usr/lib/perl5/site_perl/5.8.0/OpenCA/DBI.pm line 2518.
> >
> > This is not an error. This is the way like I try to detect an
already
> > existing table. The former SQL query in "create: ..." is not used.
The
> > really executed query is the select statement to detect an already
> > existing table. If the query fails then the module knows that the
table
> > is not present.
> 
> Yup, I noticed this in the code, too...
> 
> >> DEBUG: OpenCA::DBI->rollback: entering function
> >> DEBUG: OpenCA::DBI->Entering errno ...
> >> DEBUG: OpenCA::DBI->errno: gettext is defined
> >> DEBUG: OpenCA::DBI->errno: returning local errorcode 11111
> >> OpenCA: General error trapped 700: The compilation of the command
> >> cmdGenDB
> >> failed. Can't call method "state" on an undefined value at
> >> /usr/lib/perl5/site_perl/5.8.0/OpenCA/DBI.pm line 2519.<br>
> >> Compilation failed in require at ./openca_start line 62.
> >
> > This is the real bug. Usually a database only compiles a query if
you
> > run prepare but it looks like Oracle performs some checks during
prepare
> > and this is not expected by OpenCA. prepare should not return undef.
The
> > other databases return at minimum a statement handle and I can check
the
> > SQL state of this handle but this is not possible with Oracle if it
> > returns undef. I fixed this in OpenCA::DBI (DBI.pm v1.107).
> 
> Thanks, this was pretty quick!. Will test it in a second...
> 
> [ 10 minutes later... ]
> 
> I think you cleaned up too much of the packaging stuff.
> My build now breaks during RPM creation of the base package (I think).
> I filed a bug on SF, will check the Perl module with manual
> installation...
> 
> cheers
> 
> Martin
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by OSTG. Have you noticed the changes
on
> Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
> one more big change to announce. We are now OSTG- Open Source
Technology
> Group. Come see the changes on the new OSTG site. www.ostg.com
> _______________________________________________
> OpenCA-Devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/openca-devel



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
OpenCA-Devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/openca-devel

Reply via email to