MogileFS Oracle support

Hanks, Dan dhanks at corp.untd.com
Fri Sep 29 17:48:23 UTC 2006


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

One of two options--both involve creating a sequence for any table in
which auto-increment functionality is needed which you will use to
generate new id values:

1) 'Select sequence.nextval from dual' and insert that along with the
rest of the values for the new row.

E.g.:
 $new_id = select sequence.nextval from dual;
  Insert into table (id, col1) values ($new_id, col1_value)

2) Create a before-insert trigger on the table that selects the nextval
for you and puts it into the new row. The problem with this is there is
no last_insert_id in Oracle, so if you need to know the new id, then
method 1 is probably preferable.

CREATE TRIGGER bef_ins_my_table
BEFORE INSERT ON my_table
FOR EACH ROW
WHEN (new.id IS NULL)
BEGIN
  Select my_sequence.nextval INTO :new.id;
END;

> 
> - LIMIT
> If oracle use ROW_NUM instead

Yep, but be aware of the quirks that accompany the use of rownum. See 

http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

> 
> - 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.

INSERT IGNORE does a little more than just avoid duplicate rows. If you
try to insert an invalid datatype, MySQL will quietly "do its best" to
cram what you gave it into the field. My guess is the dup rows thing is
mainly what's at stake here, though.

The workaround? Select first, then insert, but watch out for race
considtions?

> p.s. would SQLite support be useful?

For folks wanting a quick one-box eval, perhaps, yes. 

I think if we covered MySQL, Postgres, Oracle, and SQLite, we'd have a
good start.

HTH,

-- Dan


More information about the mogilefs mailing list