[freetds] Problem retrieveing results from bottom to top

Frediano Ziglio freddy77 at gmail.com
Wed Jun 18 05:02:03 EDT 2008


Il giorno mar, 17/06/2008 alle 18.28 -0400, James K. Lowden ha scritto:
> Daniel A. Veiga wrote:
> > I believe the approach of MSSQL ODBC driver (fetching the row
> > number only when needed) is better than the one I found in the
> > jDBC driver. So I implemented
> > SQLGetStmtAttr(SQL_ATTR_ROW_NUMBER) that way. 
> 
> Hi Daniel, 
> 
> I don't want your patch to get lost; it's nice work.  When you don't see
> an answer to serious work on this list for a few days, it's usually
> because it need serious consideration and no one's been able to look at it
> carefully.  
> 
> Your patch is a little difficult to apply easily because of how it's
> generated.  Could I ask you to redo it?  
> 
> The command you want is:
> 
> 	$ diff -u /path/to/freetds-orig . > odbc.cursor7.diff
> 
> while '.' represents the top of your patched FreeTDS source tree.  
> 
> A universal diff is much easier to review (for these eyes, at least) and
> easier to edit and apply.  If you don't do that, I'll have to apply each
> patch one at at time, then use CVS to generate a universal (-u) diff, and
> start again.  
> 

yes, it would help, mainly for tds.h patch, it's not that easy to
understand where to put the added line...

> Unless Frediano objects, I expect to review and apply your patch more or
> less as is and let the chips fall where they may.  If it creates a
> problem, we can always back it out.  Of course, I'm not expecting
> problems.  
> 

I would change some small points but mainly the patch is fine:
- INIT_HTSMT is not necessary at that point
- tds_cursor_get_cursor_info should return TDS_SUCCEED/TDS_FAIL

attached an update patch.

result


Creating table #cursor7_test with 12 records.
	CREATE TABLE #cursor7_test (i INT, c VARCHAR(20))
	INSERT INTO #cursor7_test(i,c) VALUES(1, 'a1b1c1')
	INSERT INTO #cursor7_test(i,c) VALUES(2, 'a2b2c2')
	INSERT INTO #cursor7_test(i,c) VALUES(3, 'a3b3c3')
	INSERT INTO #cursor7_test(i,c) VALUES(4, 'a4b4c4')
	INSERT INTO #cursor7_test(i,c) VALUES(5, 'a5b5c5')
	INSERT INTO #cursor7_test(i,c) VALUES(6, 'a6b6c6')
	INSERT INTO #cursor7_test(i,c) VALUES(7, 'a7b7c7')
	INSERT INTO #cursor7_test(i,c) VALUES(8, 'a8b8c8')
	INSERT INTO #cursor7_test(i,c) VALUES(9, 'a9b9c9')
	INSERT INTO #cursor7_test(i,c) VALUES(10, 'a10b10c10')
	INSERT INTO #cursor7_test(i,c) VALUES(11, 'a11b11c11')
	INSERT INTO #cursor7_test(i,c) VALUES(12, 'a12b12c12')


Reading records from last to first:
	 12, a12b12c12
	 11, a11b11c11
	 10, a10b10c10
	 9, a9b9c9
	 8, a8b8c8
---> We are in record No: 8
	 7, a7b7c7
	 6, a6b6c6
	 5, a5b5c5
	 4, a4b4c4
	 3, a3b3c3
---> We are in record No: 3
	 2, a2b2c2
	 1, a1b1c1
---> We are in record No: 1

which is correct!

Perhaps we should try to convert to int with tds_convert insted of doing
all data check in  tds_cursor_get_cursor_info.

freddy77

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cursor7.diff
Type: text/x-patch
Size: 10372 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20080618/45f305be/attachment.bin 


More information about the FreeTDS mailing list