Bug #27905 MyODBC 5/ ADO record set MaxRecords Property isn't working
Submitted: 17 Apr 2007 22:59 Modified: 7 Nov 2007 13:10
Reporter: Erica Moss Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.0.12 OS:Windows (XP sp 2)
Assigned to: CPU Architecture:Any

[17 Apr 2007 22:59] Erica Moss
Description:
This problem was found while running the ADO compliance test:
level1/rsmaxrecords_vbs.TestExecuteValidClient()

This test runs fine against MyODBC 3.51.14
After setting the recset.MaxRecords property to some value less than the total number of records in a table, and then executing SELECT * from that table, the total number of records is equal to the value of recset.MaxRecords

However when run against MyODBC 5.0.12, the total number of records in the record set==the total number of records in the table.  It was verified that the value of MaxRecords was actually set to the requested value, however it doesn't have the desired effect.

How to repeat:
VBScript: see the full test suite in SVN, to run this in the framework

Sub TestExecuteValidClient()
	On Error Resume Next
	Dim connection1, recset1, strSQL, fld, iRecordCount
	Set connection1 = CreateObject("ADODB.Connection")
	Set recset1 = CreateObject("ADODB.RecordSet")
    ' open connection
    connection1.ConnectionString = connstr
    connection1.CursorLocation = adUseClient
    connection1.Open
    strSQL = "SELECT * FROM ado_test"
	
	' Open the recordset
	recset1.Open strSQL, connection1, adOpenForwardOnly, adCmdText
	
	iRecordCount = recset1.RecordCount
	recset1.MoveFirst

	If iRecordCount <> -1 Then
		If iRecordCount = 0 Then
			Call Cleanup (connection1, recset1)
			On Error Goto 0
			Assert.Failure "There are no records in the test table"
			Exit Sub
		End If
	Else
		' the record count property isn't supported so have to find out the max num of records another way
		dim iTemp: iTemp = 0
		while NOT recset1.EOF
			recset1.MoveNext
			iTemp = iTemp + 1
		wend
		iRecordCount = iTemp
	End If
	recset1.Close

	' Start Test
	recset1.LockType = adLockReadOnly
    recset1.MaxRecords = iRecordCount - 75
	
	' open recordset
    recset1.Open strSQL, connection1, adOpenForwardOnly, adCmdText
    iTemp = 0
    Do While Not recset1.EOF
        recset1.MoveNext
        iTemp = iTemp + 1
    Loop
	
    If iTemp <> iRecordCount - 75 Then
		Call Cleanup (connection1, recset1)
		On Error Goto 0
		Assert.Failure "The number of records returned didn't equal the MaxRecords Property"
		Exit Sub
    End If
	Call Cleanup (connection1, recset1)
End Sub
[31 Oct 2007 22:22] Erica Moss
Tested against MyODBC 3.51 and MyODBC 5.1.0  Problem is resovled.

ado-compliance\trunk\level1\rsmaxrecords.vbs

runs successfully using both client and server side cursors
[7 Nov 2007 13:10] Susanne Ebrecht
Eric,

many thanks.
I'll close this bug now, because this behaviour don't occur in our new version MyODBC v5.1.

Thank you for trusting MySQL.

Kind Regards,

Susanne