google-code-export / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

HY010 Function sequence error #115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
- What steps will reproduce the problem?
- What is the expected output? What do you see instead?

Not an exact way to reproduce the problem anyway...

I could understand I get the problem when reading/writing "many"
records (not so many tough). For example I have a table with about
1700 records and the Mytable.objects.all().delete() works for the
first 100 records and then the above error is raised (note that django
has an internal setting CHUNK_SIZE setted up to 100!).

Another example is then Mytable is empty and I do this:
for item in Mytable2.objects.all():
    Mytable.objects.create(...)

600 records are created and then the error is raised (Mytable2 has
about 1700 records...) 

Sample traceback...
...
...
...
File "C:\MyApp\Python26\lib\site-packages\django\db\models\query.py",
line 106, in _result_iter
    self._fill_cache()

  File "C:\MyApp\Python26\lib\site-packages\django\db\models
\query.py", line 760, in _fill_cache
    self._result_cache.append(self._iter.next())

  File "C:\MyApp\Python26\lib\site-packages\django\db\models
\query.py", line 269, in iterator
    for row in compiler.results_iter():

  File "C:\MyApp\Python26\lib\site-packages\django\db\models\sql
\compiler.py", line 672, in results_iter
    for rows in self.execute_sql(MULTI):

  File "C:\MyApp\Python26\lib\site-packages\django\db\models\sql
\compiler.py", line 745, in <lambda>
    result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),

  File "C:\MyApp\Python26\lib\site-packages\sql_server\pyodbc
\base.py", line 358, in fetchmany
    return [self.format_results(row) for row in
self.cursor.fetchmany(chunk)]

Error: ('HY010', '[HY010] [Microsoft][ODBC Driver Manager] Function
sequence error (0) (SQLFetch)')

note: GET_ITERATOR_CHUNK_SIZE for django is 100! 

- What version of the product are you using? On what operating system?

I'm using Python 2.6, Django 1.2.0, pyodbc 2.1.7, django-pyodbc (not
the last version, but it's ok for this django version). 
Sql Server 2005 or 2008 too.
The use of pyodbc 2.1.11 or the last version of django-pyodbc doesn't solve the 
problem.

In the settings the DATABASES['default']['OPTIONS']['driver'] is
setted up to 'SQL Native Client' or 'SQL Server Native Client 10.0'
and the MARS_Connection is True.

I get the error "HY010 Function sequence error" when doing some query,
I don't get the error if using 'SQL Server' as driver (but it's slow
since it can't use MARS well, I mean chunked reads). 

Original issue reported on code.google.com by claudiom...@gmail.com on 26 Sep 2011 at 2:55