Problem/Motivation
The 'DBTNG' introduced in 7.x was incomplete with regards to temporary table creation.
Proposed resolution
Allow temporary tables to be created through db_select()
.
Remaining tasks
User interface changes
None.
API changes
Marks db_query_temporary()
as deprecated for 8.1.
Original report by @hswong3i
Beside using db_query_range() directly, we can also use db_select()->range(); BTW, now we are missing db_select()->temporary() as it is not yet implemented, so db_query_temporary() is our only choice.
This patch add the new method db_select()->temporary(), which also coming with additional simpletest test case. Tested with MySQL + simpletest and pass.
Beta phase evaluation
Issue category | Task |
---|---|
Unfrozen changes | Unfrozen because it only improves the database API, and deprecates an old function for 8.1 |
Comment | File | Size | Author |
---|---|---|---|
#25 | 332353-25--select_execute_temporary.patch | 5.18 KB | drunken monkey |
#20 | interdiff--16-to-20.txt | 565 bytes | drunken monkey |
#20 | interdiff--14-to-16.txt | 1.99 KB | drunken monkey |
#20 | 332353-20--executeTemporary_for_select_class.patch | 6.71 KB | drunken monkey |
Comments
Comment #1
hswong3i CreditAttribution: hswong3i commentedAccording chx's suggestion from #drupal, simplify the
function temporary($tablename = NULL)
as below:Comment #2
Dries CreditAttribution: Dries commentedIt is not clear why you create the temporary table in a separate request. The phpdoc does not explain the 'why'.
Comment #4
lilou CreditAttribution: lilou commentedTest failure : #335122: Test clean HEAD after every commit
Comment #6
Crell CreditAttribution: Crell commentedApropos of the discussion over in #349500: db_query_temporary() should generate a table name, we shouldn't allow callers to specify their own table name. I'm actually thinking it would be better here to have an alternate execute method, executeTemporary() or some such, that takes the built query and makes a temp table out of it and returns the table name it generated, just like db_query_temporary() will after that patch lands. That means this patch is blocked on that one. hswong, can you reroll with that approach as soon as the other patch goes in? Thanks.
Comment #7
Crell CreditAttribution: Crell commentedSigh. I guess this didn't happen. Sadness.
Comment #8
catchDowngrading all D8 criticals to major per http://drupal.org/node/45111
Comment #9
drunken monkeySubscribing.
While probably not used very often, this is one of the (few) holes in the API.
Comment #10
jhedstromPicking this up 4 years later...
Comment #12
jhedstromSince this involves a change to an interface, I'm guessing it might be too late for 8.0?
Comment #14
jhedstromComment #15
jhedstromComment #16
drunken monkeyWhy did you add this? Seems no other database function is deprecated, why should this be? (Or, in any case, that's a different issue.)
Overlong comment lines.
Should also list
NULL
for the error case. Should also list the exception that could be thrown, but it seems that isn't the case anywhere else in this interface either, anyways.Amended patch attached. Otherwise, this looks great, thanks a lot for posting!
I do hope we can still get this in, it seems innocent enough and has been broken for two major versions now. But of course, that's not any argument here …
Comment #17
jhedstromThe
db_query_temporary()
function isn't used at all by core, and because it isn't just a wrapper for this new method, then two different code paths need to be maintained. Seemed reasonable to deprecate and eventually remove.Comment #18
Crell CreditAttribution: Crell commentedmonkey: Please include an interdiff, especially when fixing your own review.
I'm fine with this, including in 8.0. Up to catch if it gets bumped to 8.1.
(I would like to mark all of the db_*() functions deprecated but we can't remove them in 8.x now, sadly.)
Comment #19
alexpottWe can deprecate stuff for 9.x - this issue should deprecate db_query_temporary().
This issue does not fall into the list of unfrozen changes in https://www.drupal.org/core/beta-changes. This issue looks like a good candidate for 8.1
Comment #20
drunken monkeyOK, sorry. Here is an interdiff for my previous patch, and a new patch with the
@deprecated
added again, along with an interdiff.However, in my opinion, we should mark either all or none of these as deprecated, and in a separate issue. This has little to do with the issue at hand.
Comment #22
drunken monkeyActive again, I guess?
Comment #24
drunken monkeyRe-roll and small fix.
Comment #25
drunken monkeydb_query_temporary()
is already marked as deprecated (see #1894396: Mark db_*() wrappers in database.inc as @deprecated for 9.x).Comment #39
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
Tagging for IS update as after so many years I know things are different for D10 and imagine the fix (if any) will be different.
Moving to PNMI if someone could answer if this is still an issue for 10.1 (apologies for not knowing myself just trying to help with the queue)
Comment #41
smustgrave CreditAttribution: smustgrave at Mobomo commentedIf still a valid feature request please reopen updating issue summary per #39
Thanks!