Skip to main content
May 18, 2011
Question

Duplicate() breaks in CF9 when duplicating a query returned from a multiple-result stored procedure

  • May 18, 2011
  • 1 reply
  • 280 views

Please advise on this bug.  It should be considered critical, I believe, as causes some major issues, and breaks applicaitons completely.

Duplicate() breaks in CF9 when duplicating a query returned from a multiple-result stored procedure.  This does not occur in ColdFusion

8.

Example Code:

The behavior of Duplicate and CFTHREAD are broken.
<br><br>

Call a stored procedure that returns multiple result sets.
<br>
<pre>
CREATE PROCEDURE test_proc
AS
BEGIN

SELECT 1 AS col1_a

SELECT 2 AS col1_b

SELECT 3 AS col1_c

END
</pre>
<br>

<cfstoredproc procedure="test_proc" datasource="cns">

<cfprocresult resultset="1" name="r1">
<cfprocresult resultset="2" name="r2">
<cfprocresult resultset="3" name="r3">
</cfstoredproc>

Dump the results, and observe that the values are correct:
<br>
Value Should Be: 1
<cfdump var="#r1#">

Value Should Be: 2
<cfdump var="#r2#">

Value Should Be: 3
<cfdump var="#r3#">

<br><br>
Duplicate each result and then dump again, observing that the values are now incorrect -
they've somehow all become the same as the third result set.  This same thing happens
if we just duplicate the first result set too - it's value after the duplicate() call is
the value of the 3rd result.

<cfset d1 = Duplicate(r1)>
<cfset d2 = Duplicate(r2)>
<cfset d3 = Duplicate(r3)>

<br>

Value Should Be: 1 (but it says 3)
<cfdump var="#d1#">

Value Should Be: 2 (but it says 3)
<cfdump var="#d2#">

Value Should Be: 3 (but it says 3)
<cfdump var="#d3#">

<br><br>

This same thing happens if we call the procedure and then pass its results to CFTHREAD as an attribute - the query gets passed into the thread with the wrong data.  I'm assuming that this is because CFTHREAD duplicates any query objects being passed as an attribute.

    This topic has been closed for replies.

    1 reply

    May 18, 2011

    Environment CF9.01, HF1

    SQL Server 2008R2

    Windows 7 64bit