All fair points - although I don't see any problems with race conditions (which was what had me nervous :-)

Running it without creating the tables first generates the following error ...

Did you run the extended tests on install?

DBIx::Sequence uses 2 tables for its operation, namely the dbix_sequence_state and the dbix_sequence_release tables. Those tables will be created if you run extended tests, if not you will need to create them yourself.

(from the docs)

Creating the tables manually and running a basic loop to get new IDs generates the following error ... The reason for this is that this module doesn't properly fetch all results after executing queries - and this leaves the various statement handles that it creates in an unstable state when used with DBD::Sybase.

That's interesting - I didn't know that you have to retrive all results from a statement handle in DBI. Is this a general thing, or just an issue (bug?) for the Sybase DBD? (I suddenly feel nervous about some of the code I've written to handle paged results.)

Might be nice to submit your Sybase patches to the DBIx::Sequence author.

After patching the code so that it will work with Sybase I ran three concurrent processes that did nothing but fetch new IDs. The result was that only one process actually got any IDs - the other two were effectively locked out. Admittedly this is an extreme use of the module, but it does show the limits that this technique can have.

True. However if you're being forced to write code for a DB without decent transaction support you don't have much choice (and, as you say, it is a somewhat extreme example that wouldn't be common outside of data-loading)

That said, you are completely correct that the best way to do it is with transactions if you have them.


In reply to Re^5: portable mysql auto_increment by adrianh
in thread portable mysql auto_increment by schweini

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.