I have decided to use MAX(tablename_index)+1 in advance of inserting the
record, as I want to use as little dbms-specific magic as possible and
this matches as close as I can figure the behavior of _seq in mSQL.

I would be doing the following in the same thread in this order:
$id=SELECT MAX(tablename_index)+1;
INSERT into tablename VALUES($id,...);

Would it be prudent to wrap a rw lock around this?

--
 Mark P. Hennessy                                             [EMAIL PROTECTED]

On Wed, 19 Jun 2002, Mark Hennessy wrote:

> Date: Wed, 19 Jun 2002 14:44:49 -0400 (EDT)
> From: Mark Hennessy <[EMAIL PROTECTED]>
> To: Gerald Clark <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Subject: Re: Migration of a database from mSQL 2.x to MySQL 3.23.51
>
> I don't see how AUTO_INCREMENT preserves its value in the output of a
> mysqldump.
>
> --
>  Mark P. Hennessy                                           [EMAIL PROTECTED]
>
> On Wed, 19 Jun 2002, Gerald Clark wrote:
>
> > Date: Wed, 19 Jun 2002 13:33:00 -0500
> > From: Gerald Clark <[EMAIL PROTECTED]>
> > To: Mark Hennessy <[EMAIL PROTECTED]>
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: Migration of a database from mSQL 2.x to MySQL 3.23.51
> >
> > Use AUTO_INCREMENT.
> > Why should there be a problem restoring?
> >
> > Mark Hennessy wrote:
> >
> > >I'm using DBI/DBD with Perl 5.6.1 to send queries to this database.
> > >
> > >I'm a relative newbie to DB design, I have done some basic administration
> > >for clients.  I ask:
> > >
> > >1) In the database I plan on migrating, I have a few simple tables which
> > >use "select _seq" to increment the index value for each table as insert
> > >queries are done.  I looked at AUTO_INCREMENT in MySQL and couldn't see
> > >how one would restore from backup (backups made by mysqldump) the last
> > >AUTO_INCREMENT value for a table.  I am thinking of using:
> > >
> > >select MAX('tablename_index')+1 from tablename
> > >
> > >instead of mucking around with AUTO_INCREMENT.  I plan on making an
> > >insert query with the resulting value in the same session in DBI.  Is it
> > >likely that I need to worry about locking the table for this process?
> > >
> > >I don't want to even think about backfilling, so MAX+1 seems fine for what
> > >I'm doing.
> > >
> > >If I understand correctly, as the field is designated as an index, MAX for
> > >it is a stored value and thus is selected very quickly.
> > >
> > >2) Are there any known problems in 3.23.51 stable that would muck with
> > >something as simple as described above?
> > >
> > >Any suggestions?
> > >
> > >--
> > > Mark P. Hennessy                                        [EMAIL PROTECTED]
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to