MogileFS Oracle support

Jay Buffington jaybuffington at gmail.com
Fri Sep 29 17:03:27 UTC 2006


I'm adding POD to all the packages.  As I went through the source I
marked the places that use MySQL specific features.  For now, I just
plan on adding Oracle support.  If someone down the road wants to add
support for another database, I hope this message will be helpful.

It's too difficult to be database agnostic; you're not able to take
advantage of the facilities and speedups that various dbs offer.  I
think the best approach is to just support the two or three databases
that people want to use.

For places where I need an "if mysql do this, else if oracle do that"
construct I'll use DBI::get_info:

my $db_type = $dbh->get_info( $DBI::Const::GetInfoType{SQL_DBMS_NAME} );
if ($db_type eq "Oracle" ) {
   $MogileFS::Config::DATABASE_TYPE = "oracle";
} elsif ( $db_type eq "MySQL" ) {
   $MogileFS::Config::DATABASE_TYPE = "mysql";
} else {
    die "Sorry, database type '$db_type' isn't supported by mogilefs";
}

Mgd::validate_dbh uses CONNECTION_ID.  I believe using
DBI::connect_cached() in Mgd::get_dbh() will allow us to get rid of
validate_dbh() altogether.

MySQL locks (GET_LOCK and RELEASE_LOCK) are used in a couple of
places.  Replace with a CPAN module like Proc::Lock?  I'm not sure if
Proc::Lock does what we need.  I'll need to benchmark a non-database
locking method (like Proc::Lock) against the MySQL one.  If MySQL
locking is significantly faster, I'll only use it when in Oracle mode,
otherwise, I'll just replace it altogether.

Other MySQL-ism, and how to fix them:
- AUTO_INCREMENT column types.
I'm not sure what to do about this.  Suggestions?

- LIMIT
If oracle use ROW_NUM instead

- UNIX_TIMESTAMP
Use server time instead of database time or query like this
    SELECT (sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400)
AS dt FROM dual;
I could even write a stored procedure called UNIX_TIMESTAMP() that does this.

- INSERT IGNORE
I guess the idea behind this is to ignore duplicate row errors.  I'm
not sure what to do about this in oracle.

- REPLACE INTO
If oracle use MERGE instead

Jay

p.s. would SQLite support be useful?


More information about the mogilefs mailing list