Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
database system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
4 Jun 2007 at 12:52 UTC
Updated:
2 Nov 2007 at 08:13 UTC
Jump to comment: Most recent file
The old issue had a way too high s/n ratio. However, the patch was tested and since then only node creation has changed and I checked that. So it's ready. Note that currval of pgsql is per connection so that's not a problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | hey_dude_wheres_my_id.patch | 2.59 KB | chx |
| #3 | db_last_insert_id_13.patch | 30.93 KB | chx |
| db_last_insert_id_12.patch | 26.92 KB | chx |
Comments
Comment #1
chx commentedDries asked to link to the old issue. I am not doing that as it's a waste of time, instead I am listing the raised concerns and the solutions.
Comment #2
dries commentedThe fact that this issue was forked makes me reluctant to commit this patch. I still have to read up on the old issue -- regardless of the summary.
Comment #3
chx commentedKeeping up with HEAD and Dries asked to remove the already obsolete pconnect comment.
Comment #4
dries commentedCommitted to CVS HEAD. Not sure who to credit -- credit is in the other issue. Thanks all! :)
Comment #5
dwwupgrade docs: db_next_id() is now gone, among other developer-visible changes of this patch.
http://drupal.org/node/114774/edit
Comment #6
jvandyk commentedUh. The sequences table is not used only for incrementing database keys. It is also a persistent counter API in Drupal. Now that it's gone, what, people should bloat the variables table with counter variables and implement their own counting?
Comment #7
jvandyk commentedHaving a persistent counter in Drupal is useful. Maybe I want to keep track of the number of times something happens. I can do that by calling db_next_id().
Just because Drupal's emulation of database autoincrementation used db_next_id() does not mean that db_next_id() should be taken out. It simply means that autoincrementation should be done another way.
It's like autoincrementation of database rows is a hamburger. db_next_id() is mustard. So I walk into the cafe and find the mustard gone. When I ask why they no longer have mustard I am told that they are not serving hamburgers anymore. But I was putting mustard on my fries, not on a hamburger.
If db_next_id() is no longer available, and I want to count something and have that count stick, I have the following options. (1) I can do a variable_set(). Great. But now that counter is getting pulled needlessly into memory on every request, even if I only need it sporadically. (2) I can have my own database table. This seems kind of silly. Why reimplement something as simple as a counter table when for years we've already had one in Drupal's core API -- the sequences table.
So what I would like to see is either (a) (preferred) bring back the sequences table and db_next_id(). Just don't use it to emulate autoincrementation of database rows -- use native database autoincrementation for that. (b) get back persistent counter functionality by having variables that are not loaded on every request (145164?) and a drupal_counter($counter_name) function in common.inc.
Comment #8
moshe weitzman commenteda) makes sense to me.
even worse than variables being called into memory on every load, a variable_set() is very expensive and can kill you if your burgers are very popular.
Comment #9
chx commentedComment #10
chx commentedSo, what do you guys think of this?
Comment #11
chx commentedFollowing up on this,
db_next_idwas never a general counter API -- on postgresql where sequences are used, you need to create them either by creating a serial field in a table or explicitly creating the sequence. So, if we want a general counter API, that's totally independent of this issue -- please open another.Comment #12
dwwupgrade docs still need fixing. see #5 above.
Comment #13
hswong3i commenteddocument updated: http://drupal.org/node/114774#db_last_insert_id
Comment #14
(not verified) commented