From: Marek T. <ma...@gn...> - 2003-02-14 09:32:47
|
Hi Mitra, yes this is a MySQL autoincrement behaviour. For any autoincrement field, MySql keeps little pointer which contains the highest value. This is being updated every time you INSERT/UPDATE the record, regardles you specify the value for the autoincremented field or not. I don't think it's MySQL specific - I'd expect any SQL engine should behave like this. I can't think about any easy solution for this. That's the pain of merging autoincrements between two systems. BTW, maybe i should mention it here because recently Honza told me that even he wasn't aware of what was originally behind the decision to use long IDs. It was: 1) Every long ID is unique (in practice) 2) Some SQL databases don't have autoincrement (MySQL was one of them when we started creating AA ). We wanted to keep the code universal for any database system The 2 has already been broken for various other reasons and also turned out not to be such an important issue (but may come back to consideration again with the spread of AA). So - I also hate long IDs, especially packed ones, but there is something about it. I'm not sure wheather I'm getting it righ but you seem to already have some proposal for changing view IDs at the moment of transfering them between two systems. So you must have sorted out the problem of changing stuff like "cmd[383]" in all aliases definitions, format strings and shtml pages. If you can do this, than why don't you just count how many views you will need for the import and than generate them as auotincrement, while keeping track on what the new IDs are ? Best Marek > -----Original Message----- > From: Mitra [mailto:mi...@ea...] > Sent: 13. února 2003 22:56 > To: Marek Tichy > Subject: RE: [Apc-aa-coders] Inserting Views with out-of-sequence ids > > > Sorry, lets see if I've understood you correctly, a typical example > might be .... > > MySQL creates id's 1-10 for new records > I add records specifically at 1001-1023 > MySQL then creates the next id as 1024 > > Is that what you mean? > > That unfortunately is not very good behavior because part of the > point of putting the added ids at 10001... > is to get them out of the way of the auto-created ids. So that if a > second import is done from the same slice they can safely overwrite > using the same algorithm - e.g. adding 10,000 > > Is this APC-AA behavior, or something built into MySQL? > > - Mitra > > > At 12:46 PM +0100 13/2/03, Marek Tichy wrote: > >Hi, > > > >> As part of importing / exporting, I've got a problem with shortids. > >> > >> Lets take views for example - they have shortids which are an > >> auto-increment field, > >> > >> When I import from one system to another, I want to add an offset to > >> avoid clashes, for example I might add 1000 so that I can a) do it in > >> emacs and b) understand the result and fix mistakes. > >> > >> Will this cause problems with the autoincrement field in any way? For > >> example there might be views 1-10 and 1001 -1024, so will the next > >> auto-incremented view by 11 ? And what happens when it > > > auto-increments to 1000? > > > >It will always start from 1024. > > > -- > Mitra Technology Consulting - www.mitra.biz - mi...@mi... > 02-6684-8096 or 0414-648-0722 > > Life is a Mystery to be Lived, not a Problem to be Solved > |